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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
<?PHP
session_start();
//session_regenerate_id();
//Database login:
//include_once 'db.inc.php';
$mydomain = "http://www.snapems.com/";
//https://www.google.com/accounts/o8/id?id=AItOawl4GX29ka40T4ZeuXnR2FVsP4LZWaED_T8
//https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawl
include_once("./includes/header.php");
function sql_clean($string) {
if (get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
$string = mysql_real_escape_string($string);
return $string;
}
function CookieLogin() {
include_once "includes/db.inc.php";
$userID = $_COOKIE['userID'];
$auth = $_COOKIE['auth'];
$sql = "SELECT `openID`, `displayName`, `isAdmin`
FROM `users`
WHERE `ID` = '$userID'
";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0)
return;
list($claimedid, $display, $isAdmin) = mysql_fetch_row($result);
$salt = "33qs5d4j6z98gt1a7n6b5d4x1c66f5nuh8a6d8g9j09aphgf56z5745";
$pepper = "Dear sir, have you ever heard of a wild goose chase?
If you've gotten this far, please email me: snapwilliam@gmail.com with this message.
I'll give you some sort of prize.";
$one = MD5($claimedid);
$two = MD5($one.$salt);
$three = MD5($pepper.$two);
if ($auth == $three) {
$_SESSION['accepted'] = 1;
$_SESSION['userID'] = $userID;
$_SESSION['displayName'] = $display;
if ($isAdmin == 1)
$_SESSION['isAdmin'] = true;
}
header("Location: $mydomain");
}
Function DoLogin($Username, $Password, $RememberMe = False, $EN = False) {
If ($EN == False) {
$MD5Salt = "LoveSnap";
$Password = MD5($Password.$MD5Salt);
//Echo " .Encrypted Entry. ";
}
If ($RememberMe = True) {
setcookie("RUsername", $Username, time()+(60*60*24*30));
setcookie("RPassword", $Password, time()+(60*60*24*30));
setcookie("DoLogin", "True", time()+(60*60*24*30));
}
//Echo "Logging in...";
$sql = "SELECT `ID`, `Username`, `Password`, `Status` FROM `USERS`
WHERE `Username` = '$Username' AND `Password` = '$Password'";
$result = mysql_query($sql);
If (mysql_num_rows($result) == 0) {
Return "Error username/password did not match";
} Else {
$theID = mysql_result($result, 0, 'ID');
$Username = mysql_result($result, 0, 'Username');
$Password = mysql_result($result, 0, 'Password');
$Status = mysql_result($result, 0, 'Status');
$Pepper = "MyPepperWuvsMe!@#$1234";
$_SESSION['accepted'] = 1;
//If 'remember me' use this for cookie password
$_SESSION['passcode'] = MD5($Password.$Pepper.$Username);
$_SESSION['userID'] = $theID;
$_SESSION['displayName'] = $Username;
$_SESSION['status'] = $Status;
$sql = "UPDATE `USERS` SET `Last_Logon` = ".Time()." WHERE `ID` = $theID LIMIT 1";
$result = mysql_query($sql);
return 1;
exit;
}
}
Function CheckAuth($page) {
//!!
if ($_SESSION['Accepted'] == 1) {
return true;
} else {
//DoRedirect("Logging you in...", "$mydomain?page=login&ref=$mydomain$page", 1);
header("Location: $mydomain?page=login&ref=$mydomain?page=$page");
return false;
}
}
//!! Contains domain !!
Function DoRedirect($message = "Thanks", $to = "http://www.snapems.com/", $duration = "3") {
$to=(is_null($to)?'http://www.snapems.com/':$to);
if ($duration == 0) {
header("Location: $to");
}
//require "format/header.php";
echo "
<meta http-equiv='refresh' content='$duration; url=$to' />
<br />
<br />
<br />
<br />
<br />
<center>
<table>
<tr><td>
<center>$message
<br />You are now being redirected.
<br /><a href='$to'>Click here if not redirected in $duration seconds.</a>
</center>
</td></tr>
</table>
</center>
</body>
</html>
";
}
?>
|