[ PHPXref.com ] [ Generated: Sun Jul 20 20:10:38 2008 ] [ RunCms 1.3B ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/runcms13B/ -> register.php (source)

   1  <?php
   2  // $Id: register.php,v 1.2 2006/01/20 23:26:44 FARSUS Exp $

   3  //***********************************************************/

   4  //*                 RUNCMS                              */

   5  //*              Simplicity & ease off use                  */

   6  //*             < http://www.runcms.org >                   */

   7  //***********************************************************/

   8  // Original Author: The Xoops Project

   9  // Author Website : http://www.xoops.org

  10  // License Type   : GPL: See /manual/LICENSES/GPL.txt

  11  // --------------------------------------------------------- //

  12  
  13  $xoopsOption['pagetype']   = 'user';
  14  $xoopsOption['page_style'] = 8;
  15  $xoopsOption['nocache']    = 1;
  16  
  17  include_once ("./mainfile.php");
  18  
  19  if ( empty($xoopsConfig['allow_register']) ) {
  20    redirect_header('index.php', 1, _US_NOREG);
  21    exit();
  22  }
  23  //---------------------------------------------------------------------------------------//

  24  /**

  25  * Description

  26  *

  27  * @param type $var description

  28  * @return type description

  29  */
  30  function userCheck($uname, $email, $pass, $vpass, $verify_text, $verify_crc) {
  31  global $xoopsConfig, $db, $myts, $xoopsBadEmails, $xoopsBadUnames;
  32  
  33  $stop = "";
  34  
  35  if ( !checkEmail($email) ) {
  36    $stop .= _US_INVALIDMAIL."<br />";
  37  }
  38  
  39  if ( strrpos($uname,' ') > 0 ) {
  40    $stop .= _US_EMAILNOSPACES."<br />";
  41  }
  42  
  43  $uname  = $myts->oopsStripSlashesGPC($uname);
  44  $strict = "^a-zA-Z0-9_";
  45  $medium = $strict."<>,.$%#@!\'\"";
  46  $loose  = $medium."?{}\[\]\(\)\^&*`~;:\\+=";
  47  
  48  switch ( $xoopsConfig['uname_test_level'] ) {
  49    case 0:
  50      $restriction = $strict;
  51      break;
  52  
  53    case 1:
  54      $restriction = $medium;
  55      break;
  56  
  57    case 2:
  58      $restriction = $loose;
  59      break;
  60    }
  61  
  62  if ( empty($uname) || preg_match('#['.$restriction.'-]#', $uname) ) {
  63    $stop .= _US_INVALIDNICKNAME."<br />";
  64  }
  65  
  66  if ( strlen($uname) > 25 ) {
  67    $stop .= _US_NICKNAMETOOLONG."<br />";
  68  }
  69  
  70  if ( !empty($xoopsBadUnames) && hasMatch($xoopsBadUnames, $uname) ) {
  71    $stop .= _US_NAMERESERVED."<br />";
  72  //  break;

  73  }
  74  
  75  if ( strrpos($uname, ' ') > 0 ) {
  76    $stop .= _US_NICKNAMENOSPACES."<br />";
  77  }
  78  
  79  $sql    = "SELECT COUNT(*) FROM ".RC_USERS_TBL." WHERE uname='".addslashes($uname)."'";
  80  $result = $db->query($sql);
  81  list($count) = $db->fetch_row($result);
  82  
  83  if ($count > 0) {
  84    $stop .= _US_NICKNAMETAKEN."<br />";
  85  }
  86  
  87  $count = 0;
  88  
  89  if ($email) {
  90    if ( !empty($xoopsBadEmails) && hasMatch($xoopsBadEmails, $email) ) {
  91      $stop .= _US_EMAILRESERVED."<br />";
  92  //    break;

  93    }
  94    $sql    = "SELECT COUNT(*) FROM ".RC_USERS_TBL." WHERE email='".$myts->makeTboxData4Save($email)."'";
  95    $result = $db->query($sql);
  96    list($count) = $db->fetch_row($result);
  97      if ( $count > 0 ) {
  98        $stop .= _US_EMAILTAKEN."<br />";
  99      }
 100  }
 101  
 102  if ( empty($pass) || empty($vpass) ) {
 103    $stop .= _US_ENTERPWD."<br />";
 104  }
 105  
 106  if ( (isset($pass)) && ($pass != $vpass) ) {
 107    $stop .= _US_PASSNOTSAME."<br />";
 108    } elseif ( ($pass != "") && (strlen($pass) < $xoopsConfig['minpass']) ) {
 109      $stop .= sprintf(_US_PWDTOOSHORT, $xoopsConfig['minpass'])."<br />";
 110    }
 111  
 112  if ($xoopsConfig['img_verify'] == 1 && function_exists('imagecreate')) {
 113    include_once (XOOPS_ROOT_PATH."/class/rc4.crypt.php");
 114    $rc4 = new rc4_crypt();
 115    $rc4->key(strtoupper($verify_text));
 116    $verify_crc = base64_decode($verify_crc);
 117    $rc4->decrypt($verify_crc);
 118  
 119    if ( empty($verify_text) || $verify_crc != "verified" ) {
 120      $stop .= _US_BADVERIF."<br />";
 121    }
 122  }
 123  
 124  return $stop;
 125  }
 126  
 127  //---------------------------------------------------------------------------------------//

 128  $op = "register";
 129  foreach ($_POST as $k => $v) {
 130    $$k = $v;
 131  }
 132  
 133  switch ($op) {
 134  
 135  case "register":
 136    include_once ("header.php");
 137    OpenTable();
 138    include_once ("include/registerform.php");
 139    $reg_form->display();
 140    CloseTable();
 141    include_once ("footer.php");
 142    break;
 143  
 144  case "newuser":
 145    include_once ("header.php");
 146    $uname       = trim($uname);
 147    $email       = trim($email);
 148    $pass        = trim($pass);
 149    $vpass       = trim($vpass);
 150    $language    = trim($language);
 151    $verify_text = trim($verify_text);
 152    $verify_crc  = trim($verify_crc);
 153    $stop        = userCheck($uname, $email, $pass, $vpass, $verify_text, $verify_crc);
 154  
 155    if ( empty($stop) ) {
 156      OpenTable();
 157    $f_timezone = ($timezone_offset < 0) ? "GMT ".$timezone_offset : "GMT +".$timezone_offset;
 158    echo "
 159      <center><table width='60%'  border='0' cellspacing='2' cellpadding='2'>
 160      <tr align='center' class='bg4'>
 161        <td colspan='2'><strong>"._US_USERREG."</strong></td>
 162      </tr>
 163      <tr class='bg3'>
 164        <td nowrap>&nbsp;"._US_USERNAME."</td>
 165        <td>&nbsp;".$myts->makeTboxData4Preview($uname)."</td>
 166      </tr>
 167      <tr class='bg3'>
 168        <td nowrap>&nbsp;"._US_EMAIL."</td>
 169        <td>&nbsp;".$myts->makeTboxData4Preview($email)."</td>
 170      </tr>
 171      <tr class='bg3'>
 172        <td nowrap>&nbsp;"._US_LNG."</td>
 173        <td>&nbsp;".$myts->makeTboxData4Preview($language)."</td>
 174      </tr>
 175      <tr class='bg3'>
 176        <td nowrap>&nbsp;"._US_TIMEZONE."</td>
 177        <td>&nbsp;".$f_timezone."</td>
 178      </tr>";
 179      if ( isset($url) && $url != "" ) {
 180        $url = formatURL($myts->makeTboxData4Preview($url));
 181      echo "
 182      <tr class='bg3'>
 183        <td nowrap>&nbsp;"._US_WEBSITE."</td>
 184        <td>&nbsp;".$url."</td>
 185      </tr>";
 186      }
 187      if ( $user_avatar != "" ) {
 188      echo "
 189      <tr class='bg3'>
 190        <td nowrap>&nbsp;"._US_AVATAR."</td>
 191        <td>&nbsp;<img src='images/avatar/".$user_avatar."' alt='".$uname."' /></td>
 192      </tr>";
 193      }
 194      echo "
 195      </table></center>
 196      <form action='register.php' method='post'>
 197      <input type='hidden' name='uname' value='".$myts->makeTboxData4PreviewInForm($uname)."' />
 198      <input type='hidden' name='email' value='".$myts->makeTboxData4PreviewInForm($email)."' />
 199      <input type='hidden' name='user_viewemail' value='".intval($user_viewemail)."' />
 200      <input type='hidden' name='user_avatar' value='".$myts->makeTboxData4PreviewInForm($user_avatar)."' />
 201      <input type='hidden' name='timezone_offset' value='".(float)$timezone_offset."' />
 202      <input type='hidden' name='url' value='".$myts->makeTboxData4PreviewInForm($url)."' />
 203      <input type='hidden' name='language' value='".$myts->makeTboxData4PreviewInForm($language)."' />
 204      <input type='hidden' name='pass' value='".$myts->makeTboxData4PreviewInForm($pass)."' />
 205      <input type='hidden' name='vpass' value='".$myts->makeTboxData4PreviewInForm($vpass)."' />
 206      <input type='hidden' name='user_mailok' value='".intval($user_mailok)."' />
 207      <input type='hidden' name='verify_text' value='".$myts->makeTboxData4PreviewInForm($verify_text)."' />
 208      <input type='hidden' name='verify_crc' value='".$myts->makeTboxData4PreviewInForm($verify_crc)."' />
 209      <br /><br /><center><input type='hidden' name='op' value='finish' /><input type='submit' class='button' value='". _US_FINISH ."' />
 210      </center></form>";
 211      CloseTable();
 212      } else {
 213        echo "<span style='color:#ff0000;'>$stop</span>";
 214        include_once ("include/registerform.php");
 215        $reg_form->display();
 216      }
 217  
 218    include_once ("footer.php");
 219    break;
 220  
 221  case "finish":
 222    include_once ("header.php");
 223    $uname       = trim($uname);
 224    $email       = trim($email);
 225    $pass        = trim($pass);
 226    $vpass       = trim($vpass);
 227    $language    = trim($language);
 228    $verify_text = trim($verify_text);
 229    $verify_crc  = trim($verify_crc);
 230    $stop        = userCheck($uname, $email, $pass, $vpass, $verify_text, $verify_crc);
 231  
 232    if ( empty($stop) ) {
 233      $newuser = new XoopsUser();
 234  
 235      if ( isset($user_viewemail) ) {
 236        $newuser->setVar("user_viewemail", $user_viewemail);
 237      }
 238  
 239      if (isset($attachsig)) {
 240        $newuser->setVar("attachsig",$attachsig);
 241      }
 242  
 243      $newuser->setVar("name" , $name);
 244      $newuser->setVar("uname", $uname);
 245      $newuser->setVar("email", $email);
 246  
 247      if (!empty($url)) {
 248        $newuser->setVar("url", formatURL($url));
 249      }
 250  
 251      $newuser->setVar("user_avatar", $user_avatar);
 252      $newuser->setVar("actkey", substr(md5(makepass()), 0, 8));
 253      $newuser->setVar("pass", md5($pass));
 254      $newuser->setVar("timezone_offset", $timezone_offset);
 255      $newuser->setVar("user_regdate", time());
 256      $newuser->setVar("uorder", $xoopsConfig['com_order']);
 257      $newuser->setVar("umode", $xoopsConfig['com_mode']);
 258      $newuser->setVar("user_mailok", $user_mailok);
 259      $newuser->setVar("language", $language);
 260      $newuser->setVar("regip", _REMOTE_ADDR);
 261      $newid = $newuser->store();
 262  
 263      if (!$newid) {
 264        OpenTable();
 265        echo _US_REGISTERNG;
 266        foreach($newuser->errors as $value) {
 267          echo "<br />-->".$value;
 268        }
 269        CloseTable();
 270        include_once ("footer.php");
 271        exit();
 272      }
 273  
 274      if (!empty($xoopsConfig['auto_register'])) {
 275        $newuser->setVar("uid", $newid);
 276        if ($newuser->activate()) {
 277          OpenTable();
 278          printf(_US_AUTOREGISTERED, $uname);
 279          CloseTable();
 280          include_once ("footer.php");
 281          exit();
 282        }
 283      }
 284  
 285      $xoopsMailer =& getMailer();
 286      $xoopsMailer->useMail();
 287      if ($xoopsConfig['coppa']) {
 288        $xoopsMailer->setTemplate("coppa.tpl");
 289        $xoopsMailer->assign("UEMAIL"  , $email);
 290        $xoopsMailer->assign("UWEBSITE", $url);
 291        $xoopsMailer->assign("UNAME"   , $uname);
 292        $xoopsMailer->assign("UPASS"   , $pass);
 293        } else {
 294          $xoopsMailer->setTemplate("register.tpl");
 295        }
 296  
 297      $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $uname));
 298      $xoopsMailer->assign("SITENAME", $meta['title']);
 299      $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
 300      $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
 301      $xoopsMailer->assign("IP", _REMOTE_ADDR);
 302      $xoopsMailer->setToUsers($newid);
 303      $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
 304      $xoopsMailer->setFromName($meta['title']);
 305      $xoopsMailer->setPriority(2);
 306      OpenTable();
 307  
 308      if ( !$xoopsMailer->send() ) {
 309        echo _US_YOURREGMAILNG;
 310        foreach($xoopsMailer->errors as $value) {
 311          echo "<br />-->".$value;
 312        }
 313        } else {
 314          echo _US_YOURREGISTERED;
 315        }
 316  
 317      CloseTable();
 318      if ( $xoopsConfig['new_user_notify'] == 1 && !empty($xoopsConfig['new_user_notify_group']))
 319      {
 320              $xoopsMailer =& getMailer();
 321              $xoopsMailer->useMail();
 322              $xoopsMailer->setTemplate("justreg.tpl");
 323              $xoopsMailer->assign("SITENAME", $meta['title']);
 324              $xoopsMailer->assign("IP", _REMOTE_ADDR);
 325              $xoopsMailer->assign("UEMAIL", $email);
 326              $xoopsMailer->assign("UNAME", $uname);
 327              $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
 328              $xoopsMailer->setToGroups($xoopsConfig['new_user_notify_group']);
 329              $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
 330              $xoopsMailer->setFromName($meta['title']);
 331              $xoopsMailer->setSubject(sprintf(_US_NEWUSERREGAT, $meta['title']));
 332              $xoopsMailer->send();
 333      }
 334  
 335      } else {
 336        echo "<span style='font-weight:bold;'>$stop</span>";
 337        include_once ("include/registerform.php");
 338        $reg_form->display();
 339      }
 340  
 341    include_once ("footer.php");
 342    break;
 343  }
 344  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]