Changeset 19 for minimanager/register.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/register.php
r5 r19 10 10 require_once("header.php"); 11 11 12 13 12 //##################################################################################################### 14 13 // DO REGISTER … … 18 17 $send_mail_on_creation, $create_acc_locked, $from_mail, $mailer_type, $smtp_cfg, $title; 19 18 20 if (empty($_COOKIE['terms']) || ($_COOKIE['terms']) != 'i_do') redirect("register.php?err=13");21 22 //make sure all got by post23 19 if ( empty($_POST['pass']) || empty($_POST['email']) || empty($_POST['username']) ) { 24 20 redirect("register.php?err=1"); … … 54 50 } 55 51 56 $ mysql = new MySQL;57 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);58 59 $user_name = $ mysql->quote_smart(trim($_POST['username']));60 $pass = $ mysql->quote_smart($_POST['pass']);61 $pass1 = $ mysql->quote_smart($_POST['pass1']);52 $sql = new SQL; 53 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 54 55 $user_name = $sql->quote_smart(trim($_POST['username'])); 56 $pass = $sql->quote_smart($_POST['pass']); 57 $pass1 = $sql->quote_smart($_POST['pass1']); 62 58 63 59 //make sure username/pass at least 4 chars long and less than max 64 60 if ((strlen($user_name) < 4) || (strlen($user_name) > 15)){ 65 $ mysql->close();61 $sql->close(); 66 62 redirect("register.php?err=5"); 67 63 } … … 71 67 //make sure it doesnt contain non english chars. 72 68 if (!alphabetic($user_name)) { 73 $ mysql->close();69 $sql->close(); 74 70 redirect("register.php?err=6"); 75 71 } 76 72 77 73 //make sure the mail is valid mail format 78 $mail = $ mysql->quote_smart(trim($_POST['email']));74 $mail = $sql->quote_smart(trim($_POST['email'])); 79 75 if ((!is_email($mail))||(strlen($mail) > 224)) { 80 $ mysql->close();76 $sql->close(); 81 77 redirect("register.php?err=7"); 82 78 } … … 84 80 $per_ip = ($limit_acc_per_ip) ? "OR last_ip='$last_ip'" : ""; 85 81 86 $result = $ mysql->query("SELECT ip FROM ip_banned WHERE ip = '$last_ip'");82 $result = $sql->query("SELECT ip FROM ip_banned WHERE ip = '$last_ip'"); 87 83 //IP is in ban list 88 if ($ mysql->num_rows($result)){89 $ mysql->close();84 if ($sql->num_rows($result)){ 85 $sql->close(); 90 86 redirect("register.php?err=8&usr=$last_ip"); 91 87 } 92 88 93 $result = $ mysql->query("SELECT username,email FROM account WHERE username='$user_name' OR email='$mail' $per_ip");89 $result = $sql->query("SELECT username,email FROM account WHERE username='$user_name' OR email='$mail' $per_ip"); 94 90 95 91 //there is already someone with same user/mail 96 if ($ mysql->num_rows($result)){97 $ mysql->close();92 if ($sql->num_rows($result)){ 93 $sql->close(); 98 94 redirect("register.php?err=3&usr=$user_name"); 99 95 } else { 100 $tbc = (isset($_POST['tbc'])) ? $ mysql->quote_smart($_POST['tbc']) : 0;101 102 $result = $ mysql->query("INSERT INTO account (username,I,gmlevel,email, joindate,last_ip,failed_logins,locked,last_login,online,tbc)96 $tbc = (isset($_POST['tbc'])) ? $sql->quote_smart($_POST['tbc']) : 0; 97 98 $result = $sql->query("INSERT INTO account (username,I,gmlevel,email, joindate,last_ip,failed_logins,locked,last_login,online,tbc) 103 99 VALUES ('$user_name','$pass',0,'$mail',current_date(),'$last_ip',0,$create_acc_locked,NULL,0,$tbc)"); 104 $ mysql->close();100 $sql->close(); 105 101 106 102 setcookie ("terms", "", time() - 3600); 107 103 108 104 if ($send_mail_on_creation){ 109 require_once("scripts/ class.phpmailer.php");105 require_once("scripts/mailer/class.phpmailer.php"); 110 106 $mailer = new PHPMailer(); 111 107 $mailer->Mailer = $mailer_type; … … 166 162 } 167 163 } 164 answerbox.btn_ok='{$lang_register['i_agree']}'; 165 answerbox.btn_cancel='{$lang_register['i_dont_agree']}'; 166 answerbox.btn_icon=''; 168 167 </script> 169 170 168 <fieldset style=\"width: 550px;\"> 171 169 <legend>{$lang_register['create_acc']}</legend> … … 205 203 <tr><td colspan=\"2\"><hr /></td></tr> 206 204 <tr> 207 <td colspan=\"2\">{$lang_register['read_terms']} : <a href=\"javascript:popUp('terms.php?action=terms')\">{$lang_register['terms']}</a></td>205 <td colspan=\"2\">{$lang_register['read_terms']}.</td> 208 206 </tr> 209 207 <tr><td colspan=\"2\"><hr / ></td></tr> 210 208 <tr><td>"; 211 makebutton($lang_register['create_acc_button'], "javascript:do_submit_data()",150); 209 210 $terms = "<textarea rows=\'18\' cols=\'80\' readonly=\'readonly\'>"; 211 $fp = fopen("mail_templates/terms.tpl", 'r') or die (error("Couldn't Open terms.tpl File!")); 212 while (!feof($fp)) $terms .= fgets($fp, 1024); 213 fclose($fp); 214 $terms .= "</textarea>"; 215 216 makebutton($lang_register['create_acc_button'], "javascript:answerBox('{$lang_register['terms']}<br />$terms', 'javascript:do_submit_data()')",150); 212 217 $output .= "</td><td>"; 213 makebutton($lang_global['back'], " javascript:window.history.back()", 328);218 makebutton($lang_global['back'], "login.php", 328); 214 219 $output .= "</td></tr> 215 220 </table> … … 258 263 if ( empty($_POST['username']) || empty($_POST['email']) ) redirect("register.php?action=pass_recovery&err=1"); 259 264 260 $ mysql = new MySQL;261 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);262 263 $user_name = $ mysql->quote_smart(trim($_POST['username']));264 $email_addr = $ mysql->quote_smart($_POST['email']);265 266 $result = $ mysql->query("SELECT I FROM account WHERE username = '$user_name' AND email = '$email_addr'");267 268 if ($ mysql->num_rows($result) == 1){269 270 require_once("scripts/ class.phpmailer.php");265 $sql = new SQL; 266 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 267 268 $user_name = $sql->quote_smart(trim($_POST['username'])); 269 $email_addr = $sql->quote_smart($_POST['email']); 270 271 $result = $sql->query("SELECT I FROM account WHERE username = '$user_name' AND email = '$email_addr'"); 272 273 if ($sql->num_rows($result) == 1){ 274 275 require_once("scripts/mailer/class.phpmailer.php"); 271 276 $mail = new PHPMailer(); 272 277 $mail->Mailer = $mailer_type; … … 292 297 $body = str_replace("<password>", substr(sha1(strtoupper($user_name)),0,7), $body); 293 298 $body = str_replace("<activate_link>", 294 $_SERVER['HTTP_HOST']."/register.php?action=do_pass_activate&h=".$ mysql->result($result, 0, 'I')."&p=".substr(sha1(strtoupper($user_name)),0,7), $body);299 $_SERVER['HTTP_HOST']."/register.php?action=do_pass_activate&h=".$sql->result($result, 0, 'I')."&p=".substr(sha1(strtoupper($user_name)),0,7), $body); 295 300 $body = str_replace("<base_url>", $_SERVER['HTTP_HOST'], $body); 296 301 … … 323 328 if ( empty($_GET['h']) || empty($_GET['p']) ) redirect("register.php?action=pass_recovery&err=1"); 324 329 325 $ mysql = new MySQL;326 $ mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);327 328 $pass = $ mysql->quote_smart(trim($_GET['p']));329 $hash = $ mysql->quote_smart($_GET['h']);330 331 $result = $ mysql->query("SELECT id,username FROM account WHERE I = '$hash'");332 333 if ($ mysql->num_rows($result) == 1){334 $username = $ mysql->result($result, 0, 'username');335 $id = $ mysql->result($result, 0, 'id');336 if (substr(sha1(strtoupper($ mysql->result($result, 0, 'username'))),0,7) == $pass){337 $ mysql->query("UPDATE account SET I=SHA1(CONCAT(UPPER('$username'),':',UPPER('$pass'))) WHERE id = '$id'");330 $sql = new SQL; 331 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 332 333 $pass = $sql->quote_smart(trim($_GET['p'])); 334 $hash = $sql->quote_smart($_GET['h']); 335 336 $result = $sql->query("SELECT id,username FROM account WHERE I = '$hash'"); 337 338 if ($sql->num_rows($result) == 1){ 339 $username = $sql->result($result, 0, 'username'); 340 $id = $sql->result($result, 0, 'id'); 341 if (substr(sha1(strtoupper($sql->result($result, 0, 'username'))),0,7) == $pass){ 342 $sql->query("UPDATE account SET I=SHA1(CONCAT(UPPER('$username'),':',UPPER('$pass'))) WHERE id = '$id'"); 338 343 redirect("login.php"); 339 344 } … … 348 353 // MAIN 349 354 //##################################################################################################### 350 $output .= "<script type=\"text/javascript\">351 function popUp(URL) {352 m_window = window.open(URL, 'm_window', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=400');353 m_window.moveTo(100,100);354 }355 </script>";356 357 355 $err = (isset($_GET['err'])) ? $_GET['err'] : NULL; 358 356 … … 398 396 $output .= "<h1><font class=\"error\">{$lang_register['recovery_mail_sent']}</font></h1>"; 399 397 break; 400 case 13:401 $output .= "<h1><font class=\"error\">{$lang_register['error_terms']}</font></h1>";402 break;403 398 default: 404 399 $output .= "<h1><font class=\"error\">{$lang_register['fill_all_fields']}</font></h1>";
Note:
See TracChangeset
for help on using the changeset viewer.