Ignore:
Timestamp:
Aug 13, 2007, 9:05:34 PM (17 years ago)
Author:
george
Message:

Aktualizace MaNGOS Minimanageru na verzi 0.1.4a.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • minimanager/register.php

    r5 r19  
    1010 require_once("header.php");
    1111
    12 
    1312//#####################################################################################################
    1413// DO REGISTER
     
    1817                $send_mail_on_creation, $create_acc_locked, $from_mail, $mailer_type, $smtp_cfg, $title;
    1918
    20  if (empty($_COOKIE['terms']) || ($_COOKIE['terms']) != 'i_do') redirect("register.php?err=13");
    21 
    22  //make sure all got by post
    2319 if ( empty($_POST['pass']) || empty($_POST['email']) || empty($_POST['username']) ) {
    2420   redirect("register.php?err=1");
     
    5450 }
    5551 
    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']);
    6258
    6359        //make sure username/pass at least 4 chars long and less than max
    6460        if ((strlen($user_name) < 4) || (strlen($user_name) > 15)){
    65                 $mysql->close();
     61                $sql->close();
    6662        redirect("register.php?err=5");
    6763        }
     
    7167        //make sure it doesnt contain non english chars.
    7268        if (!alphabetic($user_name)) {
    73                 $mysql->close();
     69                $sql->close();
    7470        redirect("register.php?err=6");
    7571        }
    7672
    7773        //make sure the mail is valid mail format
    78         $mail = $mysql->quote_smart(trim($_POST['email']));
     74        $mail = $sql->quote_smart(trim($_POST['email']));
    7975        if ((!is_email($mail))||(strlen($mail)  > 224)) {
    80                         $mysql->close();
     76                        $sql->close();
    8177                redirect("register.php?err=7");
    8278                }
     
    8480        $per_ip = ($limit_acc_per_ip) ? "OR last_ip='$last_ip'" : "";
    8581
    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'");
    8783        //IP is in ban list
    88         if ($mysql->num_rows($result)){
    89                         $mysql->close();
     84        if ($sql->num_rows($result)){
     85                        $sql->close();
    9086                redirect("register.php?err=8&usr=$last_ip");
    9187        }
    9288
    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");
    9490
    9591        //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();
    9894                redirect("register.php?err=3&usr=$user_name");
    9995        } 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)
    10399                                VALUES ('$user_name','$pass',0,'$mail',current_date(),'$last_ip',0,$create_acc_locked,NULL,0,$tbc)");
    104                 $mysql->close();
     100                $sql->close();
    105101               
    106102                setcookie ("terms", "", time() - 3600);
    107103
    108104                if ($send_mail_on_creation){
    109                         require_once("scripts/class.phpmailer.php");
     105                        require_once("scripts/mailer/class.phpmailer.php");
    110106                        $mailer = new PHPMailer();
    111107                        $mailer->Mailer = $mailer_type;
     
    166162                        }
    167163                }
     164                answerbox.btn_ok='{$lang_register['i_agree']}';
     165                answerbox.btn_cancel='{$lang_register['i_dont_agree']}';
     166                answerbox.btn_icon='';
    168167        </script>
    169 
    170168        <fieldset style=\"width: 550px;\">
    171169        <legend>{$lang_register['create_acc']}</legend>
     
    205203        <tr><td colspan=\"2\"><hr /></td></tr>
    206204        <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>
    208206        </tr>
    209207        <tr><td colspan=\"2\"><hr / ></td></tr>
    210208        <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);
    212217$output .= "</td><td>";
    213                 makebutton($lang_global['back'], "javascript:window.history.back()", 328);
     218                makebutton($lang_global['back'], "login.php", 328);
    214219 $output .= "</td></tr>
    215220    </table>
     
    258263 if ( empty($_POST['username']) || empty($_POST['email']) ) redirect("register.php?action=pass_recovery&err=1");
    259264
    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");
    271276        $mail = new PHPMailer();
    272277        $mail->Mailer = $mailer_type;
     
    292297        $body = str_replace("<password>", substr(sha1(strtoupper($user_name)),0,7), $body);
    293298        $body = str_replace("<activate_link>",
    294                 $_SERVER['HTTP_HOST']."/register.php?action=do_pass_activate&amp;h=".$mysql->result($result, 0, 'I')."&amp;p=".substr(sha1(strtoupper($user_name)),0,7), $body);
     299                $_SERVER['HTTP_HOST']."/register.php?action=do_pass_activate&amp;h=".$sql->result($result, 0, 'I')."&amp;p=".substr(sha1(strtoupper($user_name)),0,7), $body);
    295300        $body = str_replace("<base_url>", $_SERVER['HTTP_HOST'], $body);
    296301
     
    323328 if ( empty($_GET['h']) || empty($_GET['p']) ) redirect("register.php?action=pass_recovery&err=1");
    324329
    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'");
    338343                redirect("login.php");
    339344                }
     
    348353// MAIN
    349354//#####################################################################################################
    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 
    357355$err = (isset($_GET['err'])) ? $_GET['err'] : NULL;
    358356
     
    398396   $output .= "<h1><font class=\"error\">{$lang_register['recovery_mail_sent']}</font></h1>";
    399397   break;
    400 case 13:
    401    $output .= "<h1><font class=\"error\">{$lang_register['error_terms']}</font></h1>";
    402    break;
    403398default:
    404399   $output .= "<h1><font class=\"error\">{$lang_register['fill_all_fields']}</font></h1>";
Note: See TracChangeset for help on using the changeset viewer.