Advertisement
Guest User

Untitled

a guest
Oct 19th, 2014
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.31 KB | None | 0 0
  1. <?php
  2. session_start();
  3. error_reporting(0);
  4. if (
  5.         isset ( $_POST['full_name'] )
  6.         && !empty( $_POST['full_name'] )
  7.         && isset ( $_POST['username'] )
  8.         && !empty( $_POST['username'] )
  9.         && isset ( $_POST['email'] )
  10.         && !empty( $_POST['email'] )
  11.         && isset ( $_POST['password'] )
  12.         && isset ( $_POST['captcha'] )
  13. ) {
  14.    
  15.     /*
  16.      * --------------------------
  17.      *   Require/Include Files
  18.      * -------------------------
  19.      */
  20.     require_once('../../class_ajax_request/classAjax.php');
  21.     include_once('../../application/functions.php');
  22.     include_once('../../application/DataConfig.php');  
  23.     /*
  24.      * ----------------------
  25.      *   Instance Class
  26.      * ----------------------
  27.      */
  28.     $obj = new AjaxRequest();
  29.  
  30.  
  31.        
  32.       $_POST['code']           = sha1 ( $_SERVER['REMOTE_ADDR'] . microtime() . mt_rand ( 1,100000 ) )._Function::randomString( 40, TRUE, TRUE, TRUE );
  33.       $_POST['email']          = trim( $_POST['email']);
  34.       $_POST['full_name']      = _Function::spaces( trim( $_POST['full_name']) );
  35.       $_POST['username']       = _Function::spaces( trim( $_POST['username'] ) );
  36.       $_POST['password']       = _Function::spaces( trim( $_POST['password'] ) );
  37.       $admin                   = $obj->getSettings();
  38.       $emailAddress            = $_POST['email'];
  39.        
  40.         if ( $_POST['full_name'] == ''
  41.             || mb_strlen( $_POST['full_name'], 'utf8' ) < 2
  42.             || mb_strlen( $_POST['full_name'], 'utf8' )  > 20
  43.         )
  44.         {
  45.             echo json_encode( array( 'res' => $_SESSION['LANG']['full_name_error'], 'focus' => 'full_name' ) );
  46.            
  47.         } else if ( preg_match( '/[^a-z0-9\_]/i',$_POST['username'] ) ) {
  48.            
  49.             echo json_encode( array( 'res' => $_SESSION['LANG']['username_not_valid'], 'focus' => 'username' ) );
  50.            
  51.         } else if ( strlen( $_POST['username'] ) < 1 || strlen( $_POST['username'] ) > 15 ) {
  52.            
  53.             echo json_encode( array( 'res' => $_SESSION['LANG']['username_not_valid'], 'focus' => 'username' ) );
  54.            
  55.         } else if ( !filter_var( $emailAddress, FILTER_VALIDATE_EMAIL ) ) {
  56.            
  57.             echo json_encode( array( 'res' => $_SESSION['LANG']['email_not_valid'], 'focus' => 'email' ) );
  58.            
  59.         } else if ( mb_strlen( $_POST['password'], 'utf8' ) < 5 || mb_strlen( $_POST['password'], 'utf8' ) > 20 ) {
  60.            
  61.             echo json_encode( array( 'res' => $_SESSION['LANG']['password'], 'focus' => 'username' ) );
  62.            
  63.         }  else if ( $_POST['terms'] == '' ) {
  64.            
  65.             echo json_encode( array( 'res' => $_SESSION['LANG']['can_not_register'], ) );
  66.         } else {
  67.            
  68.             /* INSERT DATABASE */
  69.             $res = $obj->signUp();
  70.            
  71.             /* EMAIL TEMPLATE */
  72.            
  73.             $messageEmail = '
  74.             <table width="550" cellpadding="0" cellspacing="0" style="font-family:Arial,Helvetica,sans-serif; font-size: 14px; color: #666;" align="center">
  75.     <tbody>
  76.         <tr>
  77.             <td width="550" height="50" align="center" style="background: #333;">
  78.                 <img style="width: 130px;" src="'. URL_BASE .'public/img/logo.png" />
  79.             </td>
  80.         </tr>
  81.        
  82.         <tr>
  83.             <td width="558" align="center" style="background: #FFF; line-height: 18px; padding: 10px;  border-bottom: 1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #DDD;">
  84.                 <p style="margin-bottom: 10px;">
  85.                     Thanks for signing up on '. $admin->title .' <strong>"'. $_POST['full_name'] .'"</strong>
  86.                 </p>
  87.                 <p style="margin-bottom: 10px;">
  88.                     <a style="text-decoration: none; color: #FFF; padding: 5px 10px; background: #FF7000; border-radius: 3px; -webkit-border-radius: 3px;" rel="nofollow" href="'. URL_BASE .'?validate='. $_POST['code'].'" target="_blank">
  89.                     <strong>
  90.                         Click here to activate your account
  91.                     </strong></a>
  92.                 </p>
  93.                     <p style="text-align: center; font-size: 11px; padding: 5px 0 0 0;">
  94.                         © '.date('Y') .' '. $admin->title .'
  95.                     </p>
  96.             </td>
  97.         </tr>
  98.     </tbody>
  99. </table>';
  100.            
  101.             if( $res == 1 ) {
  102.            
  103.             echo json_encode( array( 'res' => $_SESSION['LANG']['sign_up_success'], 'success' => 1 ) );
  104.            
  105.             _Function::send_mail(
  106.             $admin->title.' <'.EMAIL_ACTIVE_ACCOUNT.'>',
  107.              $_POST['email'],
  108.              'Activate Account',
  109.              $messageEmail
  110.              );
  111.           } else if ( $res == 2 ) {
  112.            
  113.             echo json_encode( array( 'res' => $_POST['username'].' '.$_SESSION['LANG']['username_already_use'] ) );
  114.         } else {
  115.             echo json_encode( array( 'res' => $_SESSION['LANG']['email_already_use'] ) );
  116.      }// ELSE
  117.    }// ELSE
  118.  } else {
  119.     echo $_SESSION['LANG']['error'];
  120. }
  121.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement