Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.17 KB | None | 0 0
  1. <?php
  2. require_once("./header.php");
  3. require_once("./includes/class.phpmailer.php");
  4. define(TABLE_VOUCHERS, 'vouchers');
  5. if (!$checkLogin) {
  6. function random_gen($length) {
  7. $random = "";
  8. srand((double)microtime()*1000000);
  9. $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  10. $char_list .= "abcdefghijklmnopqrstuvwxyz";
  11. $char_list .= "1234567890";
  12. for($i = 0; $i < $length; $i++) {
  13. $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
  14. }
  15. return $random;
  16. }
  17. $showForm = true;
  18. if (isset($_GET["r"]) && trim($_GET["r"]) != "") {
  19. $_POST["user_reference"] = trim($_GET["r"]);
  20. }
  21. if ($_POST["btnRegister"] != "") {
  22. if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {
  23. if ($db_config["enable_voucher"]) {
  24. if (isset($_POST["voucher"]) || trim($_POST["voucher"]) != "") {
  25. $sql = "SELECT * FROM `".TABLE_VOUCHERS."` WHERE voucher_code = '".$db->escape($_POST["voucher"])."'";
  26. $user_vourcer = $db->query_first($sql);
  27. if ($user_vourcer) {
  28. if ($user_vourcer["voucher_userid"] == "0") {
  29. $voucherError = "";
  30. } else {
  31. $voucherError = "This voucher were used by other account";
  32. }
  33. } else {
  34. $voucherError = "This voucher is incorrect";
  35. }
  36. } else {
  37. $voucherError = "Please enter voucher";
  38. }
  39. } else {
  40. $voucherError = "";
  41. }
  42. if ($db_config["enable_confirm"]) {
  43. $user_add["user_groupid"] = intval(PER_UNCONFIRM);
  44. } else {
  45. if ($db_config["enable_activate"]) {
  46. $user_add["user_groupid"] = intval(PER_UNACTIVATE);
  47. } else {
  48. $user_add["user_groupid"] = intval(PER_USER);
  49. }
  50. }
  51. switch (emailFaild($_POST["user_mail"])) {
  52. case 0:
  53. $emailError = "";
  54. $user_add["user_mail"] = $_POST["user_mail"];
  55. break;
  56. case 1:
  57. $emailError = "Invalid e-mail address.";
  58. break;
  59. case 2:
  60. }
  61. if ($emailError == "") {
  62. $sql = "SELECT count(*) FROM `".TABLE_USERS."` WHERE user_mail = '".$db->escape($_POST["user_mail"])."'";
  63. $user_mailCount = $db->query_first($sql);
  64. if ($user_mailCount) {
  65. if (intval($user_mailCount["count(*)"]) != intval(0)) {
  66. $emailError = "This email has been used.";
  67. }
  68. } else {
  69. $emailError = "Check email error, please try again";
  70. }
  71. }
  72. if ($_POST["user_yahoo"] == "" || preg_match("@^[a-zA-Z0-9._-]+$@", $_POST["user_yahoo"])) {
  73. $user_add["user_yahoo"] = $_POST["user_yahoo"];
  74. $yahooError = "";
  75. } else {
  76. $yahooError = "Invalid Yahoo ID";
  77. }
  78. if ($_POST["user_icq"] == "" || preg_match("@^[a-zA-Z0-9._-]+$@", $_POST["user_icq"])) {
  79. $user_add["user_icq"] = $_POST["user_icq"];
  80. $icqError = "";
  81. } else {
  82. $icqError = "Invalid ICQ ID";
  83. }
  84. switch (passwordFaild($_POST["user_pass"], $_POST["user_pass_re"])) {
  85. case 0:
  86. $passwordError = "";
  87. $user_add["user_salt"] = rand(100,999);
  88. $user_add["user_pass"] = md5(md5($_POST["user_pass"]).$user_add["user_salt"]);
  89. break;
  90. case 1:
  91. $passwordError = "Password is too short.";
  92. break;
  93. case 2:
  94. $passwordError = "Password is too long.";
  95. break;
  96. case 3:
  97. $passwordError = "Password doesn't match.";
  98. break;
  99. }
  100. switch (usernameFaild($_POST["user_name"])) {
  101. case 0:
  102. $usernameError = "";
  103. $user_add["user_name"] = $_POST["user_name"];
  104. break;
  105. case 1:
  106. $usernameError = "Username is too short.";
  107. break;
  108. case 2:
  109. $usernameError = "Username is too long.";
  110. break;
  111. case 3:
  112. $usernameError = "Username is only accept digits, character and underscore.";
  113. break;
  114. }
  115. if ($_POST["user_reference"] != "") {
  116. $sql = "SELECT user_id FROM `".TABLE_USERS."` WHERE user_name = '".$db->escape($_POST["user_reference"])."'";
  117. $user_reference = $db->query_first($sql);
  118. if ($user_reference) {
  119. $user_add["user_referenceid"] = $user_reference["user_id"];
  120. $referenceError = "";
  121. } else {
  122. $referenceError = "This username doesn't exist.";
  123. }
  124. } else {
  125. $user_add["user_referenceid"] = "0";
  126. $referenceError = "";
  127. }
  128. if ($usernameError == "") {
  129. $sql = "SELECT count(*) FROM `".TABLE_USERS."` WHERE user_name = '".$db->escape($_POST["user_name"])."'";
  130. $user_nameCount = $db->query_first($sql);
  131. if ($user_nameCount) {
  132. if (intval($user_nameCount["count(*)"]) != intval(0)) {
  133. $usernameError = "This username has been used.";
  134. }
  135. } else {
  136. $usernameError = "Check username error, please try again";
  137. }
  138. }
  139. $user_add["user_balance"] = doubleval(DEFAULT_BALANCE);
  140. $user_add["user_activecode"] = random_gen(10);
  141. $user_add["user_regdate"] = time();
  142. if ($voucherError == "" && $emailError == "" && $yahooError == "" && $icqError == "" && $passwordError == "" && $usernameError == "" && $referenceError == "") {
  143. if($db->insert(TABLE_USERS, $user_add)) {
  144. $voucher_update = array();
  145. $sql = "SELECT * FROM `".TABLE_USERS."` WHERE user_name = '".$user_add["user_name"]."'";
  146. $user_info = $db->query_first($sql);
  147. if ($user_info) {
  148. $voucher_update["voucher_userid"] = $user_info["user_id"];
  149. $voucher_update["voucher_time"] = time();
  150. if (!$db_config["enable_voucher"] || $db->update(TABLE_VOUCHERS, $voucher_update, "voucher_code = '".$db->escape($_POST["voucher"])."'")) {
  151. if ($db_config["enable_confirm"]) {
  152. $mail = new PHPMailer();
  153. $mail->IsSMTP();
  154. $mail->SMTPAuth = $smtp_auth;
  155. $mail->SMTPSecure = $smtp_secure;
  156. $mail->Host = $smtp_host;
  157. $mail->Port = $smtp_port;
  158. $mail->Username = $smtp_user;
  159. $mail->Password = $smtp_pass;
  160. $mail->From = $smtp_from;
  161. $mail->FromName = $smtp_alias;
  162. $mail->Subject = "Confirm email address for ".$user_info["user_name"]." at ".$db_config["site_url"];
  163. $mail->Body = "Hello ".$user_info["user_name"]."<br />Please <a href='".$db_config["site_url"]."/confirm.php?u=".$user_info["user_id"]."&c=".$user_info["user_activecode"]."'>click here</a> to confirm your email address or copy and pass the bellow url to your browser to confirm your email address<br /><br />".$db_config["site_url"]."/confirm.php?u=".$user_info["user_id"]."&c=".$user_info["user_activecode"]; //HTML Body
  164. $mail->MsgHTML($mail->Body);
  165. $mail->AddAddress($user_info["user_mail"]);
  166. $mail->IsHTML(true);
  167. if (!$mail->Send()) {
  168. $registerResult = "<span class=\"error\">Your account has been created successful but we can not send the email cofnirmation. Please send the bellow information to the administrator:<br/>".$mail->ErrorInfo."</span>";
  169. } else {
  170. $registerResult = "<span class=\"success\">Welcome [".$user_add["user_name"]."], we have sent a email with confirmation link, please check your email address to confirm it. <a href=\"./login.php\">After it, you can click here to login.</a></span>";
  171. }
  172. } else {
  173. $registerResult = "<script type=\"text/javascript\">setTimeout(\"window.location = './login.php'\", 1000);</script><span class=\"success\">Welcome [".$user_add["user_name"]."], click <a href=\"./login.php\">here</a> to login.</span>";
  174. }
  175. $showForm = false;
  176. } else {
  177. $registerResult = "<span class=\"error\">Register new user error.</span>";
  178. }
  179. } else {
  180. $registerResult = "<span class=\"error\">Register new user error.</span>";
  181. }
  182. }
  183. else {
  184. $registerResult = "<span class=\"error\">Register new user error.</span>";
  185. }
  186. }
  187. else {
  188. $registerResult = "<span class=\"error\">Please correct all information.</span>";
  189. }
  190. unset($_SESSION['security_code']);
  191. } else {
  192. $registerResult = "<span class=\"error\">Sorry, you have provided an invalid security code.</span>";
  193. }
  194. }
  195. ?>
  196. <div id="cards">
  197. <div class="section_title">USER REGISTER</div>
  198. <?php
  199. if ($db_config["enable_voucher"]) {
  200. ?>
  201. <div class="section_title"><font color="lime">Registration Can Only Done By Voucher (Registration Code) , You Can Get One From Support or PM on Forum </font></div>
  202. <?php
  203. }
  204. ?>
  205. <div class="section_title"><?=$registerResult?></div>
  206. <?php
  207. if ($showForm) {
  208. ?>
  209. <div class="section_content">
  210. <table class="content_table" style="border:none;">
  211. <tbody>
  212. <form name="login" method="post" action="" autocomplete="off">
  213. <tr>
  214. <td align="center">
  215. <table class="borderstyle">
  216. <tbody>
  217. <?php
  218. if ($db_config["enable_voucher"]) {
  219. ?>
  220. <tr>
  221. <td class="bold centered">
  222. Voucher: (Register Code)
  223. </td>
  224. <td class="centered">
  225. <input name="voucher" type="text" class="formstyle" id="voucher" value="<?=$_POST["voucher"]?>" maxlength="24" size="24">
  226. </td>
  227. <td class="error">
  228. <?=$voucherError?>
  229. </td>
  230. </tr>
  231. <?php
  232. }
  233. ?>
  234. <tr>
  235. <td class="bold centered">
  236. Username:
  237. </td>
  238. <td class="centered">
  239. <input name="user_name" type="text" class="formstyle" id="user_name" value="<?=$_POST["user_name"]?>" size="24">
  240. </td>
  241. <td class="error">
  242. <?=$usernameError?>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td class="bold centered">
  247. Password:
  248. </td>
  249. <td class="centered">
  250. <input name="user_pass" type="password" class="formstyle" id="user_pass" size="24">
  251. </td>
  252. <td class="error">
  253. <?=$passwordError?>
  254. </td>
  255. </tr>
  256. <tr>
  257. <td class="bold centered">
  258. Verify Password:
  259. </td>
  260. <td class="centered">
  261. <input name="user_pass_re" type="password" class="formstyle" id="user_pass_re" size="24">
  262. </td>
  263. <td class="error">
  264. </td>
  265. </tr>
  266. <tr>
  267. <td class="bold centered">
  268. Email:
  269. </td>
  270. <td class="centered">
  271. <input name="user_mail" type="text" class="formstyle" id="user_mail" value="<?=$_POST["user_mail"]?>" size="24">
  272. </td>
  273. <td class="error">
  274. <?=$emailError?>
  275. </td>
  276. </tr>
  277. <!--tr>
  278. <td class="centered">
  279. Yahoo:
  280. </td>
  281. <td class="centered">
  282. <input name="user_yahoo" type="text" class="formstyle" id="user_yahoo" value="<?=$_POST["user_yahoo"]?>" size="24">
  283. </td>
  284. <td class="error">
  285. <?=$yahooError?>
  286. </td>
  287. </tr>
  288. <tr>
  289. <td class="centered">
  290. ICQ:
  291. </td>
  292. <td class="centered">
  293. <input name="user_icq" type="text" class="formstyle" id="user_icq" value="<?=$_POST["user_icq"]?>" size="24">
  294. </td>
  295. <td class="error">
  296. <?=$icqError?>
  297. </td>
  298. </tr>
  299. <tr>
  300. <td class="centered">
  301. Reference by:
  302. </td>
  303. <td class="centered">
  304. <input name="user_reference" type="text" class="formstyle" id="user_reference" value="<?=$_POST["user_reference"]?>">
  305. </td>
  306. <td class="error">
  307. <?=$referenceError?>
  308. </td>
  309. </tr-->
  310. <tr>
  311. <td class="centered">
  312. <img src="./captcha.php?width=100&height=40&characters=5" width="100px" height="40px" />
  313. </td>
  314. <td class="centered">
  315. <input name="security_code" type="text" class="formstyle" id="security_code" maxlength="5" size="24">
  316. </td>
  317. <td class="error">
  318. </td>
  319. </tr>
  320. <tr>
  321. <td colspan="3" class="centered">
  322. <div align="center">
  323. <input name="btnRegister" type="submit" class="formstyle" id="btnRegister" value="Register">
  324. <input name="btnCancel" type="button" class="formstyle" id="btnCancel" value="Cancel" onclick="window.location='./'">
  325. </div>
  326. </td>
  327. </tr>
  328. </tbody>
  329. </table>
  330. </td>
  331. </tr>
  332. </form>
  333. </tbody>
  334. </table>
  335. </div>
  336. <?php
  337. }
  338. ?>
  339. </div>
  340. <?php
  341. }
  342. else {
  343. ?>
  344. <div id="cards">
  345. <div class="section_title">USER REGISTER</div>
  346. <div class="section_content">
  347. <table class="content_table" style="border:none;">
  348. <tbody>
  349. <tr>
  350. <td align="center">
  351. <span class="error">You have already logged with username [<?=$_SESSION["user_name"]?>], please logout to register new account or click <a href="./">here</a> to go back.</span>
  352. </td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. </div>
  357. </div>
  358. <?php
  359. }
  360. require("./footer.php");
  361. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement