Advertisement
Peowdie

Current code

Aug 25th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.17 KB | None | 0 0
  1. <?php
  2. get_header();
  3. registerNow();
  4. get_sidebar();
  5. echo "</div>";
  6. get_footer();
  7.  
  8. // -- Begin changes (1 of 3) for the Are You A Human PlayThru CAPTCHA alternative.
  9. // IMPORTANT:
  10. // In order for the PlayThru code to work correctly...
  11. // - all the files from the ayah_php_bundle zipe file must be in the same folder as
  12. // this script file.
  13. // - the ayah_config.php file must contain your correct publisher_key and scoring key.
  14. require_once("ayah.php");
  15. $ayah = new AYAH();
  16.  
  17.  
  18. function registerNow()
  19. {
  20. global $wpdb,$table_prefix,$wp_version,$userdata,$current_user, $user_ID,$post,$wp_rewrite,$g_content, $ayah;
  21. get_currentuserinfo();
  22. ob_start();
  23.  
  24. require_once(ABSPATH."/wp-includes/registration.php");
  25. echo "<div id='left'>";
  26.  
  27. $errors = array();
  28. nocache_headers();
  29. $user_login = '';
  30. $user_pass = '';
  31. $confirm_pass = '';
  32. $using_cookie = FALSE;
  33. $m_siteurl = get_option('home');
  34. $m_errorHead = '<div>';
  35. $m_errorHead .= '<h2>Error</h2><br />';
  36. $m_errorHead .= "<hr><br />";
  37. $m_errorTail = '</div>';
  38. $m_srReadSuccessHead = '<div>';
  39. $m_srReadSuccessHead .= '<h2>Signup For Your Account:</h2><br />';
  40. $m_srReadSuccessTail = '</div>';
  41.  
  42. //$m_registerURL1 = get_option('land_signup');
  43. $m_registerURL = get_option('home')."/?s=Register";
  44. $m_stReadErrorString = "<BR /> <BR />Please click <a href='".$m_registerURL."'> Here </a> to retry,thanks.<br /><br />";
  45.  
  46. if (isset($_POST['landRegisterUser']))
  47. {
  48. $user_login = $wpdb->escape($_POST['landRegisterUser']);
  49. if (empty($user_login))
  50. {
  51. die($m_errorHead."Please enter a username".$m_stReadErrorString.$m_errorTail);
  52. }
  53. $user_login = sanitize_user( $user_login );
  54. $user_email = $wpdb->escape($_POST['landRegisterEmail']);
  55. if (empty($user_email))
  56. {
  57. die($m_errorHead."Please enter your email".$m_stReadErrorString.$m_errorTail);
  58. }
  59.  
  60. $user_pass = $wpdb->escape($_POST['landFirstPass']);
  61.  
  62. if (empty($user_pass))
  63. {
  64. die($m_errorHead."Please enter a password".$m_stReadErrorString.$m_errorTail);
  65. }
  66.  
  67. $confirm_pass = $wpdb->escape($_POST['landAgainPass']);
  68. if (empty($user_pass))
  69. {
  70. die($m_errorHead."You must input postcode!".$m_stReadErrorString.$m_errorTail);
  71. }
  72.  
  73. if (isset($user_login))
  74. {
  75. $table_name = $table_prefix . "users";
  76. $m_stSearchUserSql = "SELECT `ID`,`user_email`,`user_login` FROM `" .$table_name."` WHERE `user_login` = '".$user_login."' OR `user_email` = '".$user_email."' LIMIT 1";
  77. $m_stSearchUserResult = $wpdb->get_results($m_stSearchUserSql,ARRAY_A);
  78. if ((!(empty($m_stSearchUserResult[0]['ID']))) || (!(empty($m_stSearchUserResult[0]['user_email']))))
  79. {
  80. if ($m_stSearchUserResult[0]['user_email'] == $user_email)
  81. {
  82. die($m_errorHead."This user email had been registered!".$m_stReadErrorString.$m_errorTail);
  83. }
  84.  
  85. if (!(empty($m_stSearchUserResult[0]['ID'])))
  86. {
  87. die($m_errorHead."This user name had been registered!".$m_stReadErrorString.$m_errorTail);
  88. }
  89. }
  90. else
  91. {
  92. // -- Begin changes (2 of 3) for the Are You A Human PlayThru CAPTCHA alternative.
  93. // -- End changes (1 of 3) -- //
  94. // Use the AYAH object to get the score.
  95. $score = $ayah->scoreResult();
  96.  
  97. // Only do the rest if the score is ok.
  98. if ($score)
  99. {
  100. $end_pass = md5($user_pass);
  101. $user_id = wp_create_user( $user_login, $end_pass, $user_email );
  102. if ( !$user_id )
  103. {
  104. die($m_errorHead."Sorry, We can not create new user now, please contact support!".$m_stReadErrorString.$m_errorTail);
  105. }
  106. else
  107. {
  108. $m_table = $table_prefix."users";
  109. $m_sql = "update `".$m_table."` set `user_pass` = '".$end_pass."' where `ID` = '".$user_id."'";
  110. $m_result = $wpdb->query($m_sql);
  111. $m_stSiteURL = get_option('home');
  112. $m_stSiteURL = str_replace("http://","",$m_stSiteURL);
  113. $m_stSiteLink = get_option('home');
  114. $m_stTitle = "Congratulations, New user account created in ".$m_stSiteURL."!";
  115. $m_nowFormat = get_option('answeremailformat');
  116. if (!(empty($m_nowFormat)))
  117. {
  118. $m_nowFormat = stripcslashes($m_nowFormat);
  119. $m_nowFormat = stripcslashes($m_nowFormat);
  120. $m_nowFormat = str_replace("{%username%}",$user_login,$m_nowFormat);
  121. $m_nowFormat = str_replace("{%sitename%}",$m_stSiteURL,$m_nowFormat);
  122. $m_nowFormat = str_replace("{%sitelink%}",$m_stSiteLink,$m_nowFormat);
  123. $m_nowFormat = str_replace("{%password%}",$user_pass,$m_nowFormat);
  124. $m_stMessage = "<pre>".$m_nowFormat."</pre>";
  125. }
  126. else
  127. {
  128. $m_stMessage = "<pre>
  129. $user_login:
  130.  
  131. Welcome to <a href='$m_stSiteLink'>$m_stSiteURL</a>
  132.  
  133. Your username is $user_login and your password is:$user_pass,
  134.  
  135. Regards, $m_stSiteURL
  136.  
  137. </pre>
  138. ";
  139. /*
  140. $m_stMessage = "<pre>
  141. Congratulations:
  142.  
  143. Welcome to <a href='$m_stSiteLink'>$m_stSiteURL</a>
  144. Your account: <b><i>$user_login</i></b> had been created
  145. Your password is:$user_pass
  146. thanks!
  147.  
  148. </pre>
  149. ";
  150. */
  151. }
  152. echo "<div><h2>Thank you</h2>".$m_stMessage;
  153. echo "<div style='float:right;'>";
  154. echo "You can click <a href='".get_option('home')."'> HERE </a> to continue .";
  155. echo "<br />";
  156. echo "<br />";
  157. echo $m_srReadSuccessTail."</div>";
  158. echo "<div style='clear:both;'></div>";
  159.  
  160. $nowUserInfo = get_userdata(1);
  161. $fromAdminMail = $nowUserInfo->user_email;
  162. //$headers = "From: ". "Money Digger" ." <" . $fromAdminMail . ">\r\n";
  163. $headers = "From: ". get_option("blogname") ." <" . $fromAdminMail . ">\r\n";
  164.  
  165. $m_checkURL = get_option('home')."/?page_id=".get_option('land_email_confirm');
  166. $me_title = "Thank you for your registration";
  167.  
  168. mail($user_email,$me_title,$m_stMessage,$headers);
  169. }
  170. }
  171. }
  172. }
  173.  
  174. }
  175. else
  176. {
  177. echo '<form id="registerFirstForm" action="" method="POST">';
  178. //echo '<div style="width:350px;border:1px solid #ccc;background:#eee;margin:3px 0px 50px 0px;padding:20px 18px;font-size:12px;font-family: Arial,Verdana,Sans-Serif;">';
  179. echo "<div>";
  180. echo '<h2>Signup here for your new account</h2>';
  181. echo '<br />';
  182. if ( FALSE == get_option('users_can_register') )
  183. {
  184. echo "<p>";
  185. echo "Sorry,At this time user registration is disabled. We will open registration soon!";
  186. echo "</p>";
  187. exit;
  188. }
  189. else
  190. {
  191. echo '<label class="formlabel">Email:</label><br />';
  192. echo '<input type="text" id="landRegisterEmail" name="landRegisterEmail" class="input">';
  193. echo '<label class="formlabel">Username:</label><br />';
  194. echo '<input type="text" id="landRegisterUser" name="landRegisterUser" class="input">';
  195. echo '<label class="formlabel">Password :</label><br />';
  196. echo '<input type="password" id="landFirstPass" name="landFirstPass" class="input">';
  197. echo '<br />';
  198.  
  199.  
  200. echo '<br />';
  201. echo '<input type="hidden" id="userHidden" name="userHidden" value="should not see this">';
  202.  
  203. // -- Begin changes (3 of 3) for the Are You A Human PlayThru CAPTCHA alternative.
  204. // Use the AYAH object to get the HTML code needed to
  205. // load and run the PlayThru™.
  206. echo $ayah->getPublisherHTML();
  207.  
  208. echo '<button type="submit" id="usersubmit" name="usersubmit" value="Register" style="background:#4682b4;color:#fff;padding:3px 6px;margin-left:10px;"><span class="btn">Register</span></span></button>';
  209. }
  210. echo "</div>";
  211. echo '</form>';
  212.  
  213. }
  214. echo "</div>";
  215. }
  216.  
  217. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement