diff options
Diffstat (limited to 'central')
-rw-r--r-- | central/trunk/instadisc.php | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index 46d8404..e2796aa 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php | |||
@@ -3,6 +3,7 @@ | |||
3 | /* InstaDisc Server - A Four Island Project */ | 3 | /* InstaDisc Server - A Four Island Project */ |
4 | 4 | ||
5 | include_once('db.php'); | 5 | include_once('db.php'); |
6 | include_once('class.phpmailer.php'); | ||
6 | 7 | ||
7 | function instaDisc_checkVerification($username, $verification, $verificationID, $table, $nameField, $passField) | 8 | function instaDisc_checkVerification($username, $verification, $verificationID, $table, $nameField, $passField) |
8 | { | 9 | { |
@@ -127,4 +128,105 @@ function instaDisc_addItem($username, $subscription, $title, $author, $url, $sem | |||
127 | } | 128 | } |
128 | } | 129 | } |
129 | 130 | ||
131 | function instaDisc_phpMailer() | ||
132 | { | ||
133 | $mail = new PHPMailer(); | ||
134 | $mail->IsSMTP(); | ||
135 | $mail->From = 'instadisc@' . getConfig('mailDomain'); | ||
136 | $mail->FromName = 'InstaDisc'; | ||
137 | $mail->Host = getConfig('smtpHost'); | ||
138 | if (getConfig('smtpAuth') == 'true') | ||
139 | { | ||
140 | $mail->SMTPAuth = true; | ||
141 | $mail->Username = getConfig('smtpUser'); | ||
142 | $mail->Password = getConfig('smtpPass'); | ||
143 | } | ||
144 | $mail->Helo = $_SERVER['HTTP_HOST']; | ||
145 | $mail->ClearAddresses(); | ||
146 | |||
147 | return $mail; | ||
148 | } | ||
149 | |||
150 | function instaDisc_sendActivationEmail($username, $password, $email) | ||
151 | { | ||
152 | $penKey = md5(rand(1,65536)); | ||
153 | |||
154 | $inspending = "INSERT INTO pending (username, password, email, key) VALUES (\"" . mysql_escape_string($username) . "\", \"" . mysql_escape_string($password) . "\", \"" . mysql_escape_string($email) . "\", \"" . mysql_escape_string($penKey) . "\")"; | ||
155 | $inspending2 = mysql_query($inspending); | ||
156 | |||
157 | $mail = instaDisc_phpMailer(); | ||
158 | $mail->AddAddress($email, $username); | ||
159 | $mail->Subject = 'InstaDisc Account Verification'; | ||
160 | $mail->Body = "Hello, someone has recently registered an account at " . $_SERVER['HTTP_HOST'] . " with your email address. If that was you, and your chosen username IS " . $username . ", then copy the account verification code below to our Account Verification page, enter your username and press Activate!\r\n\r\n" . $penKey . "\r\n\r\nIf that was not you, copy the above code to our Account Verification page, enter the above username, and click Delete."; | ||
161 | |||
162 | return $mail->Send(); | ||
163 | } | ||
164 | |||
165 | function instaDisc_activateAccount($username, $penKey) | ||
166 | { | ||
167 | $getuser = "SELECT * FROM pending WHERE username = \"" . mysql_escape_string($username) . "\" AND key = \"" . mysql_escape_string($penKey) . "\""; | ||
168 | $getuser2 = mysql_query($getuser); | ||
169 | $getuser3 = mysql_fetch_array($getuser2); | ||
170 | if ($getuser3['username'] == $username) | ||
171 | { | ||
172 | $insuser = "INSERT INTO users (username, password, email) VALUES (\"" . mysql_escape_string($username) . "\", \"" . mysql_escape_string($password) . "\", \"" . mysql_escape_string($email) . "\")"; | ||
173 | $insuser2 = mysql_query($insuser); | ||
174 | |||
175 | $delpending = "DELETE FROM pending WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
176 | $delpending2 = mysql_query($delpending); | ||
177 | |||
178 | $mail = instaDisc_phpMailer(); | ||
179 | $mail->AddAddress($getuser3['email'], $username); | ||
180 | $mail->Subject = 'Welcome to InstaDisc!'; | ||
181 | $mail->Body = "Welcome to InstaDisc! Thank you for registering at " . getConfig('siteName') . " Central Server, we hope you enjoy our service! Now, when you download an InstaDisc Client, it will ask you for the following information which you will need to enter into it for it to work:\r\n\r\nUsername: " . $username . "\r\nPassword: (you should know this, it's not displayed here for security reasons)\r\nCentral Server URL: " . getConfig("xmlrpcURL") . "\r\n\r\nOnce again, thank you for choosing " . getConfig("siteName") . "!"; | ||
182 | |||
183 | return $mail->Send(); | ||
184 | } else { | ||
185 | return false; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | function instaDisc_deactivateAccount($username, $penKey) | ||
190 | { | ||
191 | $getuser = "SELECT * FROM pending WHERE username = \"" . mysql_escape_string($username) . "\" AND key = \"" . mysql_escape_string($penKey) . "\""; | ||
192 | $getuser2 = mysql_query($getuser); | ||
193 | $getuser3 = mysql_fetch_array($getuser2); | ||
194 | if ($getuser3['username'] == $username) | ||
195 | { | ||
196 | $delpending = "DELETE FROM pending WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
197 | $delpending2 = mysql_query($delpending); | ||
198 | |||
199 | return true; | ||
200 | } else { | ||
201 | return false; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | function instaDisc_verifyUser($username, $password) | ||
206 | { | ||
207 | return instaDisc_checkVerification($username, md5($username . ':' . md5($password) . ':0'), 0, 'users', 'username', 'password'); | ||
208 | } | ||
209 | |||
210 | function instaDisc_deleteAccount($username) | ||
211 | { | ||
212 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
213 | $getuser2 = mysql_query($getuser); | ||
214 | $getuser3 = mysql_fetch_array($getuser2); | ||
215 | if ($getuser3['username'] == $username) | ||
216 | { | ||
217 | $deluser = "DELETE FROM users WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
218 | $deluser2 = mysql_query($deluser); | ||
219 | |||
220 | $delsubs = "DELETE FROM subscriptions WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
221 | $delsubs2 = mysql_query($delsubs); | ||
222 | |||
223 | $delitems = "DELETE FROM inbox WHERE username = \"" . mysql_escape_string($username) . "\""; | ||
224 | $delitems2 = mysql_query($delitems); | ||
225 | |||
226 | return true; | ||
227 | } | ||
228 | |||
229 | return false; | ||
230 | } | ||
231 | |||
130 | ?> | 232 | ?> |