-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreg_do.php
More file actions
71 lines (42 loc) · 1.9 KB
/
reg_do.php
File metadata and controls
71 lines (42 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
include(dirname(__FILE__)."/function.php");
$Wormdb = @mysql_connect($db_host, $db_user, $db_pass) or die ('錯誤:數據庫連接失敗');
mysql_select_db ($db_name);
$schoolid=mysql_real_escape_string($_POST['schoolid']);
$phone=mysql_real_escape_string($_POST['phone']);
if(!preg_match("/0[\d]{9}/", $phone)){
header("location:index.php?msg=phoneerror");
}
//facebook===========
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $secret,
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$fbid=$user_profile['id'];
$uid=fbid_to_uid($fbid);
if($uid==''){
$d = mysql_query('INSERT INTO `account` (`fbid`,`schoolid`,`ip`,`hostname`,`phone`,`phone_ok`,`lastalarm`,`alarmcount`,`email_ok`)VALUES ("'.$fbid.'","'.$schoolid.'","'.$ip.'","'.(gethostbyaddr($ip)).'","'.$phone.'","0","0","0","0")');
$d = mysql_query('INSERT INTO `dormiptable` (`uid`,`hostname`,`ip`,`time`,`flow`)VALUES ("'.(fbid_to_uid($fbid)).'","'.(gethostbyaddr($ip)).'","'.$ip.'","0","0")');
Getflow_toDB($ip);
//echo ('INSERT INTO `account` (`fbid`,`schoolid`,`ip`,`hostname`,`phone`,`phone_ok`,`lastalarm`,`alarmcount`,`flowcount`)VALUES ("'.$fbid.'","'.$schoolid.'","'.$ip.'","'.(gethostbyaddr($ip)).'","'.$phone.'","0","0","0","0")');
header("location:dashboard.php?msg=regok");
}else{
//already reg
header("location:index.php?msg=already_reg");
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
header("location:index.php?msg=fb_not_login");
}
}else{
header("location:index.php?msg=fb_not_login");
}
?>