plugins/SpecialUserFuncs.php
changeset 832 7152ca0a0ce9
parent 801 eb8b23f11744
child 843 4415e50e4e84
equal deleted inserted replaced
831:45e887f23282 832:7152ca0a0ce9
   511       $session->start();
   511       $session->start();
   512       
   512       
   513       $template->load_theme($session->theme, $session->style);
   513       $template->load_theme($session->theme, $session->style);
   514       if(isset($_POST['return_to']))
   514       if(isset($_POST['return_to']))
   515       {
   515       {
   516         $name = ( isset($paths->pages[$_POST['return_to']]['name']) ) ? $paths->pages[$_POST['return_to']]['name'] : $_POST['return_to'];
   516         $name = ( isPage($_POST['return_to']['name']) ) ? $paths->pages[$_POST['return_to']]['name'] : $_POST['return_to'];
   517         $subst = array(
   517         $subst = array(
   518             'username' => $session->username,
   518             'username' => $session->username,
   519             'redir_target' => $name
   519             'redir_target' => $name
   520           );
   520           );
   521         redirect( makeUrl($_POST['return_to'], false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   521         redirect( makeUrl($_POST['return_to'], false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
   599 function page_Special_Register()
   599 function page_Special_Register()
   600 {
   600 {
   601   global $db, $session, $paths, $template, $plugins; // Common objects
   601   global $db, $session, $paths, $template, $plugins; // Common objects
   602   global $lang;
   602   global $lang;
   603   
   603   
   604   if ( $session->user_logged_in )
   604   if ( $session->user_level < USER_LEVEL_ADMIN && $session->user_logged_in )
   605   {
   605   {
   606     $paths->main_page();
   606     $paths->main_page();
   607   }
   607   }
   608   
   608   
   609   // form field trackers
   609   // form field trackers
   634       $time_rem = intval(getConfig('lockout_duration')) - round((time() - $row['timestamp']) / 60);
   634       $time_rem = intval(getConfig('lockout_duration')) - round((time() - $row['timestamp']) / 60);
   635       die_friendly($lang->get('user_reg_err_disabled_title'), '<p>' . $lang->get('user_reg_err_locked_out', array('time' => $time_rem)) . '</p>');
   635       die_friendly($lang->get('user_reg_err_disabled_title'), '<p>' . $lang->get('user_reg_err_locked_out', array('time' => $time_rem)) . '</p>');
   636     }
   636     }
   637     $db->free_result();
   637     $db->free_result();
   638   }
   638   }
   639   if ( $session->user_level < USER_LEVEL_ADMIN && $session->user_logged_in )
       
   640   {
       
   641     $paths->main_page();
       
   642   }
       
   643   if(isset($_POST['submit'])) 
   639   if(isset($_POST['submit'])) 
   644   {
   640   {
   645     $_GET['coppa'] = ( isset($_POST['coppa']) ) ? $_POST['coppa'] : 'x';
   641     $_GET['coppa'] = ( isset($_POST['coppa']) ) ? $_POST['coppa'] : 'x';
   646     
   642     
   647     $captcharesult = $session->get_captcha($_POST['captchahash']);
   643     $captcharesult = $session->get_captcha($_POST['captchahash']);
   648     $session->kill_captcha();
   644     $session->kill_captcha();
   649     if ( strtolower($captcharesult) != strtolower($_POST['captchacode']) )
   645     // bypass captcha if logged in (at this point, if logged in, we're admin)
       
   646     if ( !$session->user_logged_in && strtolower($captcharesult) != strtolower($_POST['captchacode']) )
   650     {
   647     {
   651       $s = $lang->get('user_reg_err_captcha');
   648       $s = $lang->get('user_reg_err_captcha');
   652     }
   649     }
   653     else
   650     else
   654     {
   651     {
   655       if ( getConfig('enable_coppa') == '1' && ( !isset($_POST['coppa']) || ( isset($_POST['coppa']) && !in_array($_POST['coppa'], array('yes', 'no')) ) ) )
   652       if ( getConfig('enable_coppa') == '1' && ( !isset($_POST['coppa']) || ( isset($_POST['coppa']) && !in_array($_POST['coppa'], array('yes', 'no')) ) ) )
   656       {
   653       {
   657         $s = 'Invalid COPPA input';
   654         $s = 'Invalid COPPA input';
   658       }
   655       }
   659       else if ( !empty($terms) && !isset($_POST['tou_agreed']) )
   656       else if ( !$session->user_logged_in && !empty($terms) && !isset($_POST['tou_agreed']) )
   660       {
   657       {
   661         $s = $lang->get('user_reg_err_accept_tou');
   658         $s = $lang->get('user_reg_err_accept_tou');
   662       }
   659       }
   663       else
   660       else
   664       {
   661       {
   750     ?>
   747     ?>
   751       <h3><?php echo $lang->get('user_reg_msg_table_title'); ?></h3>
   748       <h3><?php echo $lang->get('user_reg_msg_table_title'); ?></h3>
   752       <form name="regform" action="<?php echo makeUrl($paths->page); ?>" method="post" onsubmit="return runEncryption();">
   749       <form name="regform" action="<?php echo makeUrl($paths->page); ?>" method="post" onsubmit="return runEncryption();">
   753         <div class="tblholder">
   750         <div class="tblholder">
   754           <table border="0" width="100%" cellspacing="1" cellpadding="4">
   751           <table border="0" width="100%" cellspacing="1" cellpadding="4">
   755             <tr><th class="subhead" colspan="3"><?php echo $lang->get('user_reg_msg_table_subtitle'); ?></th></tr>
   752             <tr><th colspan="3"><?php echo $lang->get('user_reg_msg_table_subtitle'); ?></th></tr>
   756             
   753             
   757             <?php if(isset($_POST['submit'])) echo '<tr><td colspan="3" class="row2" style="color: red;">'.$s.'</td></tr>'; ?>
   754             <?php if(isset($_POST['submit'])) echo '<tr><td colspan="3" class="row2" style="color: red;">'.$s.'</td></tr>'; ?>
   758             
   755             
   759             <!-- FIELD: Username -->
   756             <!-- FIELD: Username -->
   760             <tr>
   757             <tr>
   857               eval($cmd);
   854               eval($cmd);
   858             }
   855             }
   859             ?>
   856             ?>
   860             
   857             
   861             <!-- FIELD: CAPTCHA image -->
   858             <!-- FIELD: CAPTCHA image -->
       
   859             <?php
       
   860             if ( !$session->user_logged_in ):
       
   861             ?>
   862             <tr>
   862             <tr>
   863               <td class="row1" style="width: 50%;" rowspan="2">
   863               <td class="row1" style="width: 50%;" rowspan="2">
   864                 <?php echo $lang->get('user_reg_lbl_field_captcha'); ?><br />
   864                 <?php echo $lang->get('user_reg_lbl_field_captcha'); ?><br />
   865                 <small>
   865                 <small>
   866                   <?php echo $lang->get('user_reg_msg_captcha_pleaseenter', array('regen_flags' => 'href="#" onclick="regenCaptcha(); return false;"')); ?><br />
   866                   <?php echo $lang->get('user_reg_msg_captcha_pleaseenter', array('regen_flags' => 'href="#" onclick="regenCaptcha(); return false;"')); ?><br />
   867                   <br />
   867                   <br />
   868                   <?php echo $lang->get('user_reg_msg_captcha_blind'); ?>
   868                   <?php echo $lang->get('user_reg_msg_captcha_blind'); ?>
   869                 </small>
   869                 </small>
   870               </td>
   870               </td>
   871               <td colspan="2" class="row1">
   871               <td class="row1">
   872                 <img id="captchaimg" alt="CAPTCHA image" src="<?php echo makeUrlNS('Special', 'Captcha/'.$captchacode); ?>" />
   872                 <img id="captchaimg" alt="CAPTCHA image" src="<?php echo makeUrlNS('Special', 'Captcha/'.$captchacode); ?>" /><br />
   873                 <span id="b_username"></span>
   873                 <span id="b_username"></span>
       
   874               </td>
       
   875               <td class="row1">
   874               </td>
   876               </td>
   875             </tr>
   877             </tr>
   876             
   878             
   877             <!-- FIELD: CAPTCHA input field -->
   879             <!-- FIELD: CAPTCHA input field -->
   878             <tr>
   880             <tr>
   912                 </p>
   914                 </p>
   913               </td>
   915               </td>
   914             </tr>
   916             </tr>
   915             
   917             
   916             <?php
   918             <?php
   917             endif;
   919             endif; // !empty($terms)
       
   920             endif; // $session->user_logged_in
   918             ?>
   921             ?>
   919             
   922             
   920             <!-- FIELD: submit button -->
   923             <!-- FIELD: submit button -->
   921             <tr>
   924             <tr>
   922               <th class="subhead" colspan="3" style="text-align: center;">
   925               <th class="subhead" colspan="3" style="text-align: center;">
  1017                 failed = true;
  1020                 failed = true;
  1018                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/checkbad.png';
  1021                 document.getElementById('s_username').src='<?php echo scriptPath; ?>/images/checkbad.png';
  1019                 document.getElementById('e_username').innerHTML = '<br /><small>' + $lang.get('user_reg_err_username_invalid') + '</small>';
  1022                 document.getElementById('e_username').innerHTML = '<br /><small>' + $lang.get('user_reg_err_username_invalid') + '</small>';
  1020               }
  1023               }
  1021             }
  1024             }
  1022             document.getElementById('b_username').innerHTML = '';
  1025             if ( document.getElementById('b_username') )
  1023             if(hex_md5(frm.real_name.value) == '5a397df72678128cf0e8147a2befd5f1')
       
  1024             {
  1026             {
  1025               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" />';
  1027               document.getElementById('b_username').innerHTML = '';
       
  1028               if(hex_md5(frm.real_name.value) == '5a397df72678128cf0e8147a2befd5f1')
       
  1029               {
       
  1030                 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" />';
       
  1031               }
  1026             }
  1032             }
  1027             
  1033             
  1028             // Password
  1034             // Password
  1029             if ( field.name == 'password' || field.name == 'password_confirm' || field.name == '_nil' )
  1035             if ( field.name == 'password' || field.name == 'password_confirm' || field.name == '_nil' )
  1030             {
  1036             {