plugins/SpecialUserFuncs.php
changeset 221 e5302cb1945c
parent 210 2b283402e4e4
child 227 0eca1498a77b
equal deleted inserted replaced
220:d44492e34ab3 221:e5302cb1945c
   426           );
   426           );
   427         redirect( makeUrl($_POST['return_to'], false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   427         redirect( makeUrl($_POST['return_to'], false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   428       }
   428       }
   429       else
   429       else
   430       {
   430       {
   431         redirect( makeUrl(getConfig('main_page'), false, true), 'Login successful', 'You have successfully logged into the '.getConfig('site_name').' site as "'.$session->username.'". Redirecting to the main page...' );
   431         $subst = array(
       
   432             'username' => $session->username,
       
   433             'redir_target' => $lang->get('user_login_success_body_mainpage')
       
   434           );
       
   435         redirect( makeUrl(getConfig('main_page'), false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   432       }
   436       }
   433     }
   437     }
   434     else
   438     else
   435     {
   439     {
   436       $GLOBALS['__login_status'] = $result;
   440       $GLOBALS['__login_status'] = $result;
   467   {
   471   {
   468     
   472     
   469     redirect(makeUrl(getConfig('main_page'), false, true), $lang->get('user_logout_success_title'), $lang->get('user_logout_success_body'), 4);
   473     redirect(makeUrl(getConfig('main_page'), false, true), $lang->get('user_logout_success_title'), $lang->get('user_logout_success_body'), 4);
   470   }
   474   }
   471   $template->header();
   475   $template->header();
   472   echo '<h3>An error occurred during the logout process.</h3><p>'.$l.'</p>';
   476   echo '<h3>' . $lang->get('user_logout_err_title') . '</h3>';
       
   477   echo '<p>' . $l . '</p>';
   473   $template->footer();
   478   $template->footer();
   474 }
   479 }
   475 
   480 
   476 function page_Special_Register()
   481 function page_Special_Register()
   477 {
   482 {
   478   global $db, $session, $paths, $template, $plugins; // Common objects
   483   global $db, $session, $paths, $template, $plugins; // Common objects
       
   484   global $lang;
   479   
   485   
   480   // form field trackers
   486   // form field trackers
   481   $username = '';
   487   $username = '';
   482   $email = '';
   488   $email = '';
   483   $realname = '';
   489   $realname = '';
   484   
   490   
   485   if(getConfig('account_activation') == 'disable' && ( ( $session->user_level >= USER_LEVEL_ADMIN && !isset($_GET['IWannaPlayToo']) ) || $session->user_level < USER_LEVEL_ADMIN || !$session->user_logged_in ))
   491   if(getConfig('account_activation') == 'disable' && ( ( $session->user_level >= USER_LEVEL_ADMIN && !isset($_GET['IWannaPlayToo']) ) || $session->user_level < USER_LEVEL_ADMIN || !$session->user_logged_in ))
   486   {
   492   {
   487     $s = ($session->user_level >= USER_LEVEL_ADMIN) ? '<p>Oops...it seems that you <em>are</em> the administrator...hehe...you can also <a href="'.makeUrl($paths->page, 'IWannaPlayToo', true).'">force account registration to work</a>.</p>' : '';
   493     $s = ($session->user_level >= USER_LEVEL_ADMIN) ? '<p>' . $lang->get('user_reg_err_disabled_body_adminblurb', array( 'reg_link' => makeUrl($paths->page, 'IWannaPlayToo&coppa=no', true) )) . '</p>' : '';
   488     die_friendly('Registration disabled', '<p>The administrator has disabled new user registration on this site.</p>' . $s);
   494     die_friendly($lang->get('user_reg_err_disabled_title'), '<p>' . $lang->get('user_reg_err_disabled_body') . '</p>' . $s);
   489   }
   495   }
   490   if ( $session->user_level < USER_LEVEL_ADMIN && $session->user_logged_in )
   496   if ( $session->user_level < USER_LEVEL_ADMIN && $session->user_logged_in )
   491   {
   497   {
   492     $paths->main_page();
   498     $paths->main_page();
   493   }
   499   }
   496     $_GET['coppa'] = ( isset($_POST['coppa']) ) ? $_POST['coppa'] : 'x';
   502     $_GET['coppa'] = ( isset($_POST['coppa']) ) ? $_POST['coppa'] : 'x';
   497     
   503     
   498     $captcharesult = $session->get_captcha($_POST['captchahash']);
   504     $captcharesult = $session->get_captcha($_POST['captchahash']);
   499     if($captcharesult != $_POST['captchacode'])
   505     if($captcharesult != $_POST['captchacode'])
   500     {
   506     {
   501       $s = 'The confirmation code you entered was incorrect.';
   507       $s = $lang->get('user_reg_err_captcha');
   502     }
   508     }
   503     else
   509     else
   504     {
   510     {
   505       if ( getConfig('enable_coppa') == '1' && ( !isset($_POST['coppa']) || ( isset($_POST['coppa']) && !in_array($_POST['coppa'], array('yes', 'no')) ) ) )
   511       if ( getConfig('enable_coppa') == '1' && ( !isset($_POST['coppa']) || ( isset($_POST['coppa']) && !in_array($_POST['coppa'], array('yes', 'no')) ) ) )
   506       {
   512       {
   520         {
   526         {
   521           $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE);
   527           $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE);
   522           $crypt_key = $session->fetch_public_key($_POST['crypt_key']);
   528           $crypt_key = $session->fetch_public_key($_POST['crypt_key']);
   523           if ( !$crypt_key )
   529           if ( !$crypt_key )
   524           {
   530           {
   525             $s = 'Couldn\'t look up public encryption key';
   531             $s = $lang->get('user_reg_err_missing_key');
   526           }
   532           }
   527           else
   533           else
   528           {
   534           {
   529             $data = $_POST['crypt_data'];
   535             $data = $_POST['crypt_data'];
   530             $bin_key = hexdecode($crypt_key);
   536             $bin_key = hexdecode($crypt_key);
   547     {
   553     {
   548       switch(getConfig('account_activation'))
   554       switch(getConfig('account_activation'))
   549       {
   555       {
   550         case "none":
   556         case "none":
   551         default:
   557         default:
   552           $str = 'You may now <a href="'.makeUrlNS('Special', 'Login').'">log in</a> with the username and password that you created.';
   558           $str = $lang->get('user_reg_msg_success_activ_none', array('login_link' => makeUrlNS('Special', 'Login', false, true)));
   553           break;
   559           break;
   554         case "user":
   560         case "user":
   555           $str = 'Because this site requires account activation, you have been sent an e-mail with further instructions. Please follow the instructions in that e-mail to continue your registration.';
   561           $str = $lang->get('user_reg_msg_success_activ_user');
   556           break;
   562           break;
   557         case "admin":
   563         case "admin":
   558           $str = 'Because this site requires administrative account activation, you cannot use your account at the moment. A notice has been sent to the site administration team that will alert them that your account has been created.';
   564           $str = $lang->get('user_reg_msg_success_activ_admin');
   559           break;
   565           break;
   560       }
   566       }
   561       die_friendly('Registration successful', '<p>Thank you for registering, your user account has been created. '.$str.'</p>');
   567       die_friendly($lang->get('user_reg_msg_success_title'), '<p>' . $lang->get('user_reg_msg_success_body') . ' ' . $str . '</p>');
   562     }
   568     }
   563     else if ( $s == 'success' && $coppa )
   569     else if ( $s == 'success' && $coppa )
   564     {
   570     {
   565       $str = 'However, in compliance with the Childrens\' Online Privacy Protection Act, you must have your parent or legal guardian activate your account. Please ask them to check their e-mail for further information.';
   571       $str = $lang->get('user_reg_msg_success_activ_coppa');
   566       die_friendly('Registration successful', '<p>Thank you for registering, your user account has been created. '.$str.'</p>');
   572       die_friendly($lang->get('user_reg_msg_success_title'), '<p>' . $lang->get('user_reg_msg_success_body') . ' ' . $str . '</p>');
   567     }
   573     }
   568     $username = htmlspecialchars($_POST['username']);
   574     $username = htmlspecialchars($_POST['username']);
   569     $email    = htmlspecialchars($_POST['email']);
   575     $email    = htmlspecialchars($_POST['email']);
   570     $realname = htmlspecialchars($_POST['real_name']);
   576     $realname = htmlspecialchars($_POST['real_name']);
   571   }
   577   }
   572   $template->header();
   578   $template->header();
   573   echo 'A user account enables you to have greater control over your browsing experience.';
   579   echo $lang->get('user_reg_msg_greatercontrol');
   574   
   580   
   575   if ( getConfig('enable_coppa') != '1' || ( isset($_GET['coppa']) && in_array($_GET['coppa'], array('yes', 'no')) ) )
   581   if ( getConfig('enable_coppa') != '1' || ( isset($_GET['coppa']) && in_array($_GET['coppa'], array('yes', 'no')) ) )
   576   {
   582   {
   577     $coppa = ( isset($_GET['coppa']) && $_GET['coppa'] == 'yes' );
   583     $coppa = ( isset($_GET['coppa']) && $_GET['coppa'] == 'yes' );
   578     $session->kill_captcha();
   584     $session->kill_captcha();
   580     
   586     
   581     $pubkey = $session->rijndael_genkey();
   587     $pubkey = $session->rijndael_genkey();
   582     $challenge = $session->dss_rand();
   588     $challenge = $session->dss_rand();
   583     
   589     
   584     ?>
   590     ?>
   585       <h3>Create a user account</h3>
   591       <h3><?php echo $lang->get('user_reg_msg_table_title'); ?></h3>
   586       <form name="regform" action="<?php echo makeUrl($paths->page); ?>" method="post" onsubmit="runEncryption();">
   592       <form name="regform" action="<?php echo makeUrl($paths->page); ?>" method="post" onsubmit="return runEncryption();">
   587         <div class="tblholder">
   593         <div class="tblholder">
   588           <table border="0" width="100%" cellspacing="1" cellpadding="4">
   594           <table border="0" width="100%" cellspacing="1" cellpadding="4">
   589             <tr><th class="subhead" colspan="3">Please tell us a little bit about yourself.</th></tr>
   595             <tr><th class="subhead" colspan="3"><?php echo $lang->get('user_reg_msg_table_subtitle'); ?></th></tr>
   590             
   596             
   591             <?php if(isset($_POST['submit'])) echo '<tr><td colspan="3" class="row2" style="color: red;">'.$s.'</td></tr>'; ?>
   597             <?php if(isset($_POST['submit'])) echo '<tr><td colspan="3" class="row2" style="color: red;">'.$s.'</td></tr>'; ?>
   592             
   598             
   593             <!-- FIELD: Username -->
   599             <!-- FIELD: Username -->
   594             <tr>
   600             <tr>
   595               <td class="row1" style="width: 50%;">
   601               <td class="row1" style="width: 50%;">
   596                 Preferred username:
   602                 <?php echo $lang->get('user_reg_lbl_field_username'); ?>
   597                 <span id="e_username"></span>
   603                 <span id="e_username"></span>
   598               </td>
   604               </td>
   599               <td class="row1" style="width: 50%;">
   605               <td class="row1" style="width: 50%;">
   600                 <input tabindex="1" type="text" name="username" size="30" value="<?php echo $username; ?>" onkeyup="namegood = false; validateForm();" onblur="checkUsername();" />
   606                 <input tabindex="1" type="text" name="username" size="30" value="<?php echo $username; ?>" onkeyup="namegood = false; validateForm(this);" onblur="checkUsername();" />
   601               </td>
   607               </td>
   602               <td class="row1" style="max-width: 24px;">
   608               <td class="row1" style="max-width: 24px;">
   603                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_username" />
   609                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_username" />
   604               </td>
   610               </td>
   605             </tr>
   611             </tr>
   606             
   612             
   607             <!-- FIELD: Password -->
   613             <!-- FIELD: Password -->
   608             <tr>
   614             <tr>
   609               <td class="row3" style="width: 50%;" rowspan="<?php echo ( getConfig('pw_strength_enable') == '1' ) ? '3' : '2'; ?>">
   615               <td class="row3" style="width: 50%;" rowspan="<?php echo ( getConfig('pw_strength_enable') == '1' ) ? '3' : '2'; ?>">
   610                 Password:
   616                 <?php echo $lang->get('user_reg_lbl_field_password'); ?>
   611                 <span id="e_password"></span>
   617                 <span id="e_password"></span>
   612                 <?php if ( getConfig('pw_strength_enable') == '1' && getConfig('pw_strength_minimum') > -10 ): ?>
   618                 <?php if ( getConfig('pw_strength_enable') == '1' && getConfig('pw_strength_minimum') > -10 ): ?>
   613                 <small>It needs to score at least <b><?php echo getConfig('pw_strength_minimum'); ?></b> for your registration to be accepted.</small>
   619                 <small><?php echo $lang->get('user_reg_msg_password_score'); ?></small>
   614                 <?php endif; ?>
   620                 <?php endif; ?>
   615               </td>
   621               </td>
   616               <td class="row3" style="width: 50%;">
   622               <td class="row3" style="width: 50%;">
   617                 <input tabindex="2" type="password" name="password" size="15" onkeyup="<?php if ( getConfig('pw_strength_enable') == '1' ): ?>password_score_field(this); <?php endif; ?>validateForm();" /><?php if ( getConfig('pw_strength_enable') == '1' ): ?><span class="password-checker" style="font-weight: bold; color: #aaaaaa;"> Loading...</span><?php endif; ?>
   623                 <input tabindex="2" type="password" name="password" size="15" onkeyup="<?php if ( getConfig('pw_strength_enable') == '1' ): ?>password_score_field(this); <?php endif; ?>validateForm(this);" /><?php if ( getConfig('pw_strength_enable') == '1' ): ?><span class="password-checker" style="font-weight: bold; color: #aaaaaa;"> Loading...</span><?php endif; ?>
   618               </td>
   624               </td>
   619               <td rowspan="<?php echo ( getConfig('pw_strength_enable') == '1' ) ? '3' : '2'; ?>" class="row3" style="max-width: 24px;">
   625               <td rowspan="<?php echo ( getConfig('pw_strength_enable') == '1' ) ? '3' : '2'; ?>" class="row3" style="max-width: 24px;">
   620                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_password" />
   626                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_password" />
   621               </td>
   627               </td>
   622             </tr>
   628             </tr>
   623             
   629             
   624             <!-- FIELD: Password confirmation -->
   630             <!-- FIELD: Password confirmation -->
   625             <tr>
   631             <tr>
   626               <td class="row3" style="width: 50%;">
   632               <td class="row3" style="width: 50%;">
   627                 <input tabindex="3" type="password" name="password_confirm" size="15" onkeyup="validateForm();" /> <small>Enter your password again to confirm.</small>
   633                 <input tabindex="3" type="password" name="password_confirm" size="15" onkeyup="validateForm(this);" /> <small><?php echo $lang->get('user_reg_lbl_field_password_confirm'); ?></small>
   628               </td>
   634               </td>
   629             </tr>
   635             </tr>
   630             
   636             
   631             <!-- FIELD: Password strength meter -->
   637             <!-- FIELD: Password strength meter -->
   632             
   638             
   640             
   646             
   641             <!-- FIELD: E-mail address -->
   647             <!-- FIELD: E-mail address -->
   642             <tr>
   648             <tr>
   643               <td class="row1" style="width: 50%;">
   649               <td class="row1" style="width: 50%;">
   644                 <?php
   650                 <?php
   645                   if ( $coppa ) echo 'Your parent or guardian\'s e'; 
   651                   if ( $coppa )
   646                   else echo 'E';
   652                   {
   647                 ?>-mail address:
   653                     echo $lang->get('user_reg_lbl_field_email_coppa');
       
   654                   }
       
   655                   else
       
   656                   {
       
   657                     echo $lang->get('user_reg_lbl_field_email');
       
   658                   }
       
   659                 ?>
   648                 <?php
   660                 <?php
   649                   if ( ( $x = getConfig('account_activation') ) == 'user' )
   661                   if ( ( $x = getConfig('account_activation') ) == 'user' )
   650                   {
   662                   {
   651                     echo '<br /><small>An e-mail with an account activation key will be sent to this address, so please ensure that it is correct.</small>';
   663                     echo '<br /><small>' . $lang->get('user_reg_msg_email_activuser') . '</small>';
   652                   }
   664                   }
   653                 ?>
   665                 ?>
   654               </td>
   666               </td>
   655               <td class="row1" style="width: 50%;">
   667               <td class="row1" style="width: 50%;">
   656                 <input tabindex="4" type="text" name="email" size="30" value="<?php echo $email; ?>" onkeyup="validateForm();" />
   668                 <input tabindex="4" type="text" name="email" size="30" value="<?php echo $email; ?>" onkeyup="validateForm(this);" />
   657               </td>
   669               </td>
   658               <td class="row1" style="max-width: 24px;">
   670               <td class="row1" style="max-width: 24px;">
   659                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_email" />
   671                 <img alt="Good/bad icon" src="<?php echo scriptPath; ?>/images/bad.gif" id="s_email" />
   660               </td>
   672               </td>
   661             </tr>
   673             </tr>
   662             
   674             
   663             <!-- FIELD: Real name -->
   675             <!-- FIELD: Real name -->
   664             <tr>
   676             <tr>
   665               <td class="row3" style="width: 50%;">
   677               <td class="row3" style="width: 50%;">
   666                 Real name:<br />
   678                 <?php echo $lang->get('user_reg_lbl_field_realname'); ?><br />
   667                 <small>Giving your real name is totally optional. If you choose to provide your real name, it will be used to provide attribution for any edits or contributions you may make to this site.</small>
   679                 <small><?php echo $lang->get('user_reg_msg_realname_optional'); ?></small>
   668               </td>
   680               </td>
   669               <td class="row3" style="width: 50%;">
   681               <td class="row3" style="width: 50%;">
   670                 <input tabindex="5" type="text" name="real_name" size="30" value="<?php echo $realname; ?>" /></td><td class="row3" style="max-width: 24px;">
   682                 <input tabindex="5" type="text" name="real_name" size="30" value="<?php echo $realname; ?>" /></td><td class="row3" style="max-width: 24px;">
   671               </td>
   683               </td>
   672             </tr>
   684             </tr>
   673             
   685             
   674             <!-- FIELD: CAPTCHA image -->
   686             <!-- FIELD: CAPTCHA image -->
   675             <tr>
   687             <tr>
   676               <td class="row1" style="width: 50%;" rowspan="2">
   688               <td class="row1" style="width: 50%;" rowspan="2">
   677                 Visual confirmation<br />
   689                 <?php echo $lang->get('user_reg_lbl_field_captcha'); ?><br />
   678                 <small>
   690                 <small>
   679                   Please enter the code shown in the image to the right into the text box. This process helps to ensure that this registration is not being performed by an automated bot. If the image to the right is illegible, you can <a href="#" onclick="regenCaptcha(); return false;">generate a new image</a>.<br />
   691                   <?php echo $lang->get('user_reg_msg_captcha_pleaseenter', array('regen_flags' => 'href="#" onclick="regenCaptcha(); return false;"')); ?><br />
   680                   <br />
   692                   <br />
   681                   If you are visually impaired or otherwise cannot read the text shown to the right, please contact the site management and they will create an account for you.
   693                   <?php echo $lang->get('user_reg_msg_captcha_blind'); ?>
   682                 </small>
   694                 </small>
   683               </td>
   695               </td>
   684               <td colspan="2" class="row1">
   696               <td colspan="2" class="row1">
   685                 <img id="captchaimg" alt="CAPTCHA image" src="<?php echo makeUrlNS('Special', 'Captcha/'.$captchacode); ?>" />
   697                 <img id="captchaimg" alt="CAPTCHA image" src="<?php echo makeUrlNS('Special', 'Captcha/'.$captchacode); ?>" />
   686                 <span id="b_username"></span>
   698                 <span id="b_username"></span>
   688             </tr>
   700             </tr>
   689             
   701             
   690             <!-- FIELD: CAPTCHA input field -->
   702             <!-- FIELD: CAPTCHA input field -->
   691             <tr>
   703             <tr>
   692               <td class="row1" colspan="2">
   704               <td class="row1" colspan="2">
   693                 Code:
   705                 <?php echo $lang->get('user_reg_lbl_field_captcha_code'); ?>
   694                 <input tabindex="6" name="captchacode" type="text" size="10" />
   706                 <input tabindex="6" name="captchacode" type="text" size="10" />
   695                 <input type="hidden" name="captchahash" value="<?php echo $captchacode; ?>" />
   707                 <input type="hidden" name="captchahash" value="<?php echo $captchacode; ?>" />
   696               </td>
   708               </td>
   697             </tr>
   709             </tr>
   698             
   710             
   738         function runEncryption()
   750         function runEncryption()
   739         {
   751         {
   740           var frm = document.forms.regform;
   752           var frm = document.forms.regform;
   741           if ( frm.password.value.length < 1 )
   753           if ( frm.password.value.length < 1 )
   742             return true;
   754             return true;
       
   755           pass1 = frm.password.value;
       
   756           pass2 = frm.password_confirm.value;
       
   757           if ( pass1 != pass2 )
       
   758           {
       
   759             alert($lang.get('user_reg_err_alert_password_nomatch'));
       
   760             return false;
       
   761           }
       
   762           if ( pass1.length < 6 && pass1.length > 0 )
       
   763           {
       
   764             alert($lang.get('user_reg_err_alert_password_tooshort'));
       
   765             return false;
       
   766           }
   743           if(aes_testpassed)
   767           if(aes_testpassed)
   744           {
   768           {
   745             frm.use_crypt.value = 'yes';
   769             frm.use_crypt.value = 'yes';
   746             var cryptkey = frm.crypt_key.value;
   770             var cryptkey = frm.crypt_key.value;
   747             frm.crypt_key.value = hex_md5(cryptkey);
   771             frm.crypt_key.value = hex_md5(cryptkey);
   750             {
   774             {
   751               frm.submit.disabled = true;
   775               frm.submit.disabled = true;
   752               len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
   776               len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
   753               alert('The key is messed up\nType: '+typeof(cryptkey)+len);
   777               alert('The key is messed up\nType: '+typeof(cryptkey)+len);
   754             }
   778             }
   755           }
       
   756           pass1 = frm.password.value;
       
   757           pass2 = frm.password_confirm.value;
       
   758           if ( pass1 != pass2 )
       
   759           {
       
   760             alert('The passwords you entered do not match.');
       
   761             return false;
       
   762           }
       
   763           if ( pass1.length < 6 && pass1.length > 0 )
       
   764           {
       
   765             alert('The new password must be 6 characters or greater in length.');
       
   766             return false;
       
   767           }
       
   768           if(aes_testpassed)
       
   769           {
       
   770             pass = frm.password.value;
   779             pass = frm.password.value;
   771             pass = stringToByteArray(pass);
   780             pass = stringToByteArray(pass);
   772             cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
   781             cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
   773             if(!cryptstring)
   782             if(!cryptstring)
   774             {
   783             {
   786       <!-- Don't optimize this script, it fails when compressed -->
   795       <!-- Don't optimize this script, it fails when compressed -->
   787       <enano:no-opt>
   796       <enano:no-opt>
   788         <script type="text/javascript">
   797         <script type="text/javascript">
   789           // <![CDATA[
   798           // <![CDATA[
   790           var namegood = false;
   799           var namegood = false;
   791           function validateForm()
   800           function validateForm(field)
   792           {
   801           {
       
   802             if ( typeof(field) != 'object' )
       
   803             {
       
   804               field = {
       
   805                 name: '_nil',
       
   806                 value: '_nil',
       
   807               }
       
   808             }
       
   809             // wait until $lang is initted
       
   810             if ( typeof($lang) != 'object' )
       
   811             {
       
   812               setTimeout('validateForm();', 200);
       
   813               return false;
       
   814             }
   793             var frm = document.forms.regform;
   815             var frm = document.forms.regform;
   794             failed = false;
   816             failed = false;
   795             
   817             
   796             // Username
   818             // Username
   797             if(!namegood)
   819             if(!namegood && ( field.name == 'username' || field.name == '_nil' ) ) 
   798             {
   820             {
   799               //if(frm.username.value.match(/^([A-z0-9 \!@\-\(\)]+){2,}$/ig))
   821               //if(frm.username.value.match(/^([A-z0-9 \!@\-\(\)]+){2,}$/ig))
   800               var regex = new RegExp('^([^<>_&\?]+){2,}$', 'ig');
   822               var regex = new RegExp('^([^<>_&\?]+){2,}$', 'ig');
   801               if ( frm.username.value.match(regex) )
   823               if ( frm.username.value.match(regex) )
   802               {
   824               {
   803                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/unknown.gif';
   825                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/unknown.gif';
   804                 document.getElementById('e_username').innerHTML = ''; // '<br /><small><b>Checking availability...</b></small>';
   826                 document.getElementById('e_username').innerHTML = '&nbsp;';
   805               } else {
   827               } else {
   806                 failed = true;
   828                 failed = true;
   807                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   829                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   808                 document.getElementById('e_username').innerHTML = '<br /><small>Your username must be at least two characters in length and may contain only alphanumeric characters (A-Z and 0-9), spaces, and the following characters: :, !, @, #, *.</small>';
   830                 document.getElementById('e_username').innerHTML = '<br /><small>' + $lang.get('user_reg_err_username_invalid') + '</small>';
   809               }
   831               }
   810             }
   832             }
   811             document.getElementById('b_username').innerHTML = '';
   833             document.getElementById('b_username').innerHTML = '';
   812             if(hex_md5(frm.real_name.value) == '5a397df72678128cf0e8147a2befd5f1')
   834             if(hex_md5(frm.real_name.value) == '5a397df72678128cf0e8147a2befd5f1')
   813             {
   835             {
   814               document.getElementById('b_username').innerHTML = '<br /><br />Hey...I know you!<br /><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Bill_Gates_2004_cr.jpg/220px-Bill_Gates_2004_cr.jpg" />';
   836               document.getElementById('b_username').innerHTML = '<br /><br />Hey...I know you!<br /><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Bill_Gates_2004_cr.jpg/220px-Bill_Gates_2004_cr.jpg" />';
   815             }
   837             }
   816             
   838             
   817             // Password
   839             // Password
   818             if(frm.password.value.match(/^(.+){6,}$/ig) && frm.password_confirm.value.match(/^(.+){6,}$/ig) && frm.password.value == frm.password_confirm.value)
   840             if ( field.name == 'password' || field.name == 'password_confirm' || field.name == '_nil' )
   819             {
   841             {
   820               document.getElementById('s_password').src='<?php echo scriptPath; ?>/images/good.gif';
   842               if(frm.password.value.match(/^(.+){6,}$/ig) && frm.password_confirm.value.match(/^(.+){6,}$/ig) && frm.password.value == frm.password_confirm.value )
   821               document.getElementById('e_password').innerHTML = '<br /><small>The password you entered is valid.</small>';
       
   822             } else {
       
   823               failed = true;
       
   824               if(frm.password.value.length < 6)
       
   825               {
   843               {
   826                 document.getElementById('e_password').innerHTML = '<br /><small>Your password must be at least six characters in length.</small>';
   844                 document.getElementById('s_password').src='<?php echo scriptPath; ?>/images/good.gif';
       
   845                 document.getElementById('e_password').innerHTML = '<br /><small>' + $lang.get('user_reg_err_password_good') + '</small>';
       
   846               } else {
       
   847                 failed = true;
       
   848                 if(frm.password.value.length < 6)
       
   849                 {
       
   850                   document.getElementById('e_password').innerHTML = '<br /><small>' + $lang.get('user_reg_msg_password_length') + '</small>';
       
   851                 }
       
   852                 else if(frm.password.value != frm.password_confirm.value)
       
   853                 {
       
   854                   document.getElementById('e_password').innerHTML = '<br /><small>' + $lang.get('user_reg_msg_password_needmatch') + '</small>';
       
   855                 }
       
   856                 else
       
   857                 {
       
   858                   document.getElementById('e_password').innerHTML = '';
       
   859                 }
       
   860                 document.getElementById('s_password').src='<?php echo scriptPath; ?>/images/bad.gif';
   827               }
   861               }
   828               else if(frm.password.value != frm.password_confirm.value)
       
   829               {
       
   830                 document.getElementById('e_password').innerHTML = '<br /><small>The passwords you entered do not match.</small>';
       
   831               }
       
   832               else
       
   833               {
       
   834                 document.getElementById('e_password').innerHTML = '';
       
   835               }
       
   836               document.getElementById('s_password').src='<?php echo scriptPath; ?>/images/bad.gif';
       
   837             }
   862             }
   838             
   863             
   839             // E-mail address
   864             // E-mail address
   840             
   865             
   841             // workaround for idiot jEdit bug
   866             // workaround for idiot jEdit bug
   842             if ( validateEmail(frm.email.value) )
   867             if ( validateEmail(frm.email.value) && ( field.name == 'email' || field.name == '_nil' ) )
   843             {
   868             {
   844               document.getElementById('s_email').src='<?php echo scriptPath; ?>/images/good.gif';
   869               document.getElementById('s_email').src='<?php echo scriptPath; ?>/images/good.gif';
   845             } else {
   870             } else {
   846               failed = true;
   871               failed = true;
   847               document.getElementById('s_email').src='<?php echo scriptPath; ?>/images/bad.gif';
   872               document.getElementById('s_email').src='<?php echo scriptPath; ?>/images/bad.gif';
   857           {
   882           {
   858             var frm = document.forms.regform;
   883             var frm = document.forms.regform;
   859             
   884             
   860             if(!namegood)
   885             if(!namegood)
   861             {
   886             {
   862               if(frm.username.value.match(/^([A-z0-9 \.:\!@\#\*]+){2,}$/ig))
   887               var r = new RegExp('^([A-z0-9 \.:\!@\#\*]+){2,}$', 'g');
       
   888               if(frm.username.value.match(r))
   863               {
   889               {
   864                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/unknown.gif';
   890                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/unknown.gif';
   865                 document.getElementById('e_username').innerHTML = '';
   891                 document.getElementById('e_username').innerHTML = '&nbsp;';
   866               } else {
   892               } else {
   867                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   893                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   868                 document.getElementById('e_username').innerHTML = '<br /><small>Your username must be at least two characters in length and may contain only alphanumeric characters (A-Z and 0-9), spaces, and the following characters: :, !, @, #, *.</small>';
   894                 document.getElementById('e_username').innerHTML = '<br /><small>' + $lang.get('user_reg_err_username_invalid') + '</small>';
   869                 return false;
   895                 return false;
   870               }
   896               }
   871             }
   897             }
   872             
   898             
   873             document.getElementById('e_username').innerHTML = '<br /><small><b>Checking availability...</b></small>';
   899             document.getElementById('e_username').innerHTML = '<br /><small><b>' + $lang.get('user_reg_msg_username_checking') + '</b></small>';
   874             ajaxGet('<?php echo scriptPath; ?>/ajax.php?title=null&_mode=checkusername&name='+escape(frm.username.value), function() {
   900             ajaxGet('<?php echo scriptPath; ?>/ajax.php?title=null&_mode=checkusername&name='+escape(frm.username.value), function() {
   875               if(ajax.readyState == 4)
   901               if(ajax.readyState == 4)
   876                 if(ajax.responseText == 'good')
   902                 if(ajax.responseText == 'good')
   877                 {
   903                 {
   878                   document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/good.gif';
   904                   document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/good.gif';
   879                   document.getElementById('e_username').innerHTML = '<br /><small><b>This username is available.</b></small>';
   905                   document.getElementById('e_username').innerHTML = '<br /><small><b>' + $lang.get('user_reg_msg_username_available') + '</b></small>';
   880                   namegood = true;
   906                   namegood = true;
   881                 } else if(ajax.responseText == 'bad') {
   907                 } else if(ajax.responseText == 'bad') {
   882                   document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   908                   document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/bad.gif';
   883                   document.getElementById('e_username').innerHTML = '<br /><small><b>Error: that username is already taken.</b></small>';
   909                   document.getElementById('e_username').innerHTML = '<br /><small><b>' + $lang.get('user_reg_msg_username_unavailable') + '</b></small>';
   884                   namegood = false;
   910                   namegood = false;
   885                 } else {
   911                 } else {
   886                   document.getElementById('e_username').innerHTML = ajax.responseText;
   912                   document.getElementById('e_username').innerHTML = ajax.responseText;
   887                 }
   913                 }
   888             });
   914             });
   917     // COPPA enabled, ask age
   943     // COPPA enabled, ask age
   918     echo '<div class="tblholder">';
   944     echo '<div class="tblholder">';
   919     echo '<table border="0" cellspacing="1" cellpadding="4">';
   945     echo '<table border="0" cellspacing="1" cellpadding="4">';
   920     echo '<tr>
   946     echo '<tr>
   921             <td class="row1">
   947             <td class="row1">
   922               Before you can register, please tell us your age.
   948               ' . $lang->get('user_reg_coppa_title') . '
   923             </td>
   949             </td>
   924           </tr>
   950           </tr>
   925           <tr>
   951           <tr>
   926             <td class="row3">
   952             <td class="row3">
   927               <a href="' . $link_coppa_no  . '">I was born <b>on or before</b> ' . $yo13_date . ' and am <b>at least</b> 13 years of age</a><br />
   953               <a href="' . $link_coppa_no  . '">' . $lang->get('user_reg_coppa_link_atleast13', array( 'yo13_date' => $yo13_date )) . '</a><br />
   928               <a href="' . $link_coppa_yes . '">I was born <b>after</b> ' . $yo13_date . ' and am <b>less than</b> 13 years of age</a>
   954               <a href="' . $link_coppa_yes . '">' . $lang->get('user_reg_coppa_link_not13', array( 'yo13_date' => $yo13_date )) . '</a>
   929             </td>
   955             </td>
   930           </tr>';
   956           </tr>';
   931     echo '</table>';
   957     echo '</table>';
   932     echo '</div>';
   958     echo '</div>';
   933   }
   959   }