summaryrefslogtreecommitdiffstats
path: root/globe.php
blob: 760a253ed76196fd83d8c467b178d4b2a125fe3b (plain)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?PHP
date_default_timezone_set('America/New_York'); 
if (!session_id())
	session_start();
//session_regenerate_id();

include_once "includes/sqlEmbedded.php";

function LogError($error) {
	
	$today = date("Y-m-d H:i:s");
	$fd = fopen("includes/errorlogs.txt", "a");
	fwrite($fd, "$today:$error\n");
	fclose($fd);
}

function linkEmblem($emblem, $orientation) {
	$orientation = $orientation - 0;
	$url = 'images/marks/';
	if ($orientation == 0) return $url.$emblem;
	return $url.'rotate.php?r='.$orientation.'&emblem='.$emblem;
}

function soundManager1() {
	return '
	<div>
<script src="sounds/script/soundmanager.js"></script>
<script type="text/javascript">soundManagerInit();</script>
	</div>
	';
}

function soundManager2() {
	return "
<script src='sounds/script/soundmanager2-nodebug-jsmin.js'></script>
<script>
soundManager.setup({
	url: '/sounds/swf/',
	flashVersion: 9, // optional: shiny features (default = 8)
	useFlashBlock: false, // optionally, enable when you're ready to dive in/**
	onready: function() {
    // Ready to use; soundManager.createSound() etc. can now be called.
		soundManager.createSound({id: 'achieve',url: '/sounds/achieve.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'ufoblip', url: '/sounds/ufoblip.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'bling', url: '/sounds/bling.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'blingb', url: '/sounds/blingb.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'charm',url: '/sounds/charm.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'blip',url: '/sounds/blip.mp3',autoLoad: true,volume: 50});
		soundManager.createSound({id: 'cap',url: '/sounds/cap.mp3'});
		soundManager.createSound({id: 'click',url: '/sounds/click.mp3'});
		soundManager.createSound({id: 'sc',url: '/sounds/transmission.mp3'});
		soundManager.createSound({id: 'hologram',url: '/sounds/hologram.mp3'});
		soundManager.createSound({id: 'pit',url: '/sounds/pit.mp3'});
		soundManager.createSound({id: 'select',url: '/sounds/select.mp3'});
	}
});
</script>
";
}


function sql_clean($string) { 
   if (get_magic_quotes_gpc()) { 
      $string = stripslashes($string); 
   }
   $string = mysql_real_escape_string($string);  
   return $string; 
} 

function CookieLogin() {
	global $accepted, $mydomain;
	$userID = $_COOKIE['userID'];
	$auth = $_COOKIE['auth'];

	$sql = "SELECT `openID`, `email`, `displayName`, `dateJoined`, `isAdmin`
	FROM `users`
	WHERE `ID` = '$userID'
	";
	
	$result = mysql_query($sql);
	if (mysql_num_rows($result) == 0) return;
		
	list($claimedid, $email, $display, $dateJoined, $isAdmin) = mysql_fetch_row($result);
	
	//I last-see you now!
	$sql = "UPDATE `users`
	SET `dateLogin` = NOW()
	WHERE `ID` = '$userID'";
	mysql_query($sql);
		
	$salt = "33qs5d4j6z98gt1a7n6b5d4x1c66f5nuh8a6d8g9j09aphgf56z5745";
	$pepper = "chilis baby-back ribss! I want my baby back, baby back, baby back, baby back, baby back, I want my, baby backTREE3!";
	$one = MD5($claimedid);
	$two = MD5($one.$salt);
	$three = MD5($pepper.$two);
	
	if ($auth == $three) {
		$_SESSION['accepted'] = 1;
		$accepted = 1;
		$_SESSION['userID'] = $userID;
		$_SESSION['email'] = $email;
		$_SESSION['displayName'] = $display;
		$_SESSION['dateJoined'] = $dateJoined;
		if ($isAdmin == 1) $_SESSION['isAdmin'] = true;
		header("Location: $mydomain");
	} else {
		setcookie("doLogin", "lastAttemptFailed");
		setcookie("userID", "");
		setcookie("auth", "");
		return false;
	}
}

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) {
   //TODO:
   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;
   }
}

Function DoRedirect($message = "Thanks", $to = NULL, $duration = "3") {
	global $mydomain;
   $to = (is_null($to)?$mydomain:$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 to: $to
      <br /><a href='$to'>Click here if not redirected in $duration seconds.</a>
      </center>
   </td></tr>
   </table>
   </center>
   </body>
   </html>
";
}

function EmailError($data, $subject = "Pathery Error Report") {
   $to = 'snapwilliam@gmail.com';
   $mycompany = "Pathery";
   
   $fromemail = "snap@pathery.com";
   $replyemail = "snap@pathery.com";

   # -=-=-=- MIME BOUNDARY
   $mime_boundary = "----$mycompany----".md5(time());
   # -=-=-=- MAIL HEADERS

   $headers = "From: $mycompany <$fromemail>\n";
   $headers .= "Reply-To: $mycompany <$replyemail>\n";
   $headers .= "MIME-Version: 1.0\n";
   $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

   # -=-=-=- TEXT EMAIL PART

   $message = "--$mime_boundary\n";
   $message .= "Content-Type: text/plain; charset=UTF-8\n";
   $message .= "Content-Transfer-Encoding: 8bit\n\n";

   $message .= "Request from website: \n";
	foreach ($data as $title => $value)
		$message.= "$title: $value\n";

   # -=-=-=- HTML EMAIL PART
   //None
   # -=-=-=- FINAL BOUNDARY
   $message .= "--$mime_boundary--\n\n";
   # -=-=-=- SEND MAIL
   $mail_sent = @mail( $to, $subject, $message, $headers );
   Return $mail_sent;
}

?>