Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. <?php
  2. $page = "signup";
  3. include "header.php";
  4.  
  5. if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "step1"; }
  6.  
  7. // SET ERROR VARS
  8. $is_error = 0;
  9.  
  10.  
  11. // IF USER IS ALREADY LOGGED IN, FORWARD TO USER HOME PAGE
  12. if($user->user_exists != 0) { header("Location: user_home.php"); exit(); }
  13.  
  14.  
  15.  
  16. // CHECK IF USER SIGNUP COOKIES SET (STEPS 3, 4, 5)
  17. $signup_logged_in = 0;
  18. if($task != "step1" && $task != "step1do" && $task != "step2" && $task != "step2do") {
  19. if(isset($_COOKIE['signup_id']) && isset($_COOKIE['signup_email']) && isset($_COOKIE['signup_password'])) {
  20.  
  21. // GET USER ROW IF AVAILABLE
  22. $user_id = $_COOKIE['signup_id'];
  23. $new_user = new se_user(Array($user_id));
  24.  
  25. // VERIFY USER LOGIN COOKIE VALUES AND RESET USER LOGIN VARIABLE
  26. if($_COOKIE['signup_email'] == crypt($new_user->user_info[user_email], "$1$".$new_user->user_info[user_code]."$") && $_COOKIE['signup_password'] == $new_user->user_info[user_password]) {
  27. $signup_logged_in = 1;
  28. }
  29. }
  30.  
  31. if($signup_logged_in != 1) { cheader("signup.php"); exit(); }
  32. }
  33.  
  34. if($signup_logged_in != 1) {
  35. setcookie("signup_id", "", 0, "/");
  36. setcookie("signup_email", "", 0, "/");
  37. setcookie("signup_password", "", 0, "/");
  38. $_COOKIE['signup_id'] = "";
  39. $_COOKIE['signup_email'] = "";
  40. $_COOKIE['signup_password'] = "";
  41. $new_user = new se_user();
  42. if($task == "step1") {
  43. if(isset($_GET['signup_email'])) { $signup_email = $_GET['signup_email']; } else { $signup_email = ""; }
  44. if(isset($_GET['signup_invite'])) { $signup_invite = $_GET['signup_invite']; }
  45. $signup_password = "";
  46. $signup_timezone = $setting['setting_timezone'];
  47. }
  48. }
  49.  
  50.  
  51.  
  52. // PROCESS INPUT FROM FIRST STEP (OR DOUBLE CHECK VALUES), CONTINUE TO SECOND STEP (OR SECOND STEP PROCESSING)
  53. if($task == "step1do" || $task == "step2do") {
  54. $signup_email = $_POST['signup_email'];
  55. $signup_password = $_POST['signup_password'];
  56. $signup_password2 = $_POST['signup_password2'];
  57. $step = $_POST['step'];
  58. if($task == "step2do" && $step != "1") {
  59. $signup_password = base64_decode($signup_password);
  60. $signup_password2 = base64_decode($signup_password2);
  61. }
  62. $signup_username = $_POST['signup_username'];
  63. $signup_timezone = $_POST['signup_timezone'];
  64. $signup_invite = $_POST['signup_invite'];
  65. $signup_cat = $_POST['signup_cat'];
  66.  
  67. // GET LANGUAGE PACK SELECTION
  68. if($setting[setting_lang_allow] != 1) { $signup_lang = 0; } else { $signup_lang = $_POST['signup_lang']; }
  69.  
  70. // TEMPORARILY SET PASSWORD IF RANDOM PASSWORD ENABLED
  71. if($setting[setting_signup_randpass] != 0) {
  72. $signup_password = "temporary";
  73. $signup_password2 = "temporary";
  74. }
  75.  
  76. // CHECK USER ERRORS
  77. $new_user->user_password('', $signup_password, $signup_password2, 0);
  78. $new_user->user_account($signup_email, $signup_username);
  79. $is_error = $new_user->is_error;
  80.  
  81. // CHECK INVITE CODE IF NECESSARY
  82. if($setting[setting_signup_invite] != 0) {
  83. if($setting[setting_signup_invite_checkemail] != 0) {
  84. $invite = $database->database_query("SELECT invite_id FROM se_invites WHERE invite_code='$signup_invite' AND invite_email='$signup_email'");
  85. $invite_error_message = 705;
  86. } else {
  87. $invite = $database->database_query("SELECT invite_id FROM se_invites WHERE invite_code='$signup_invite'");
  88. $invite_error_message = 706;
  89. }
  90. if($database->database_num_rows($invite) == 0) { $is_error = $invite_error_message; }
  91. }
  92.  
  93. // CHECK TERMS OF SERVICE AGREEMENT IF NECESSARY
  94. if($setting[setting_signup_tos] != 0) {
  95. $signup_agree = $_POST['signup_agree'];
  96. if($signup_agree != 1) {
  97. $is_error = 707;
  98. }
  99. }
  100.  
  101. // RETRIEVE AND CHECK SECURITY CODE IF NECESSARY
  102. if($setting[setting_signup_code] != 0) {
  103. session_start();
  104. $code = $_SESSION['code'];
  105. if($code == "") { $code = randomcode(); }
  106. $signup_secure = $_POST['signup_secure'];
  107.  
  108. if($signup_secure != $code) {
  109. $is_error = 708;
  110. }
  111. }
  112.  
  113. // IF THERE IS NO ERROR, CONTINUE TO STEP 2 OR PROCESS STEP 2
  114. if($is_error == 0) {
  115. // ONLY IF ON STEP ONE, CONTINUE TO STEP 2 - ELSE GO TO PROCESSING STEP 2
  116. if($task == "step1do") { $task = "step2"; }
  117.  
  118. // IF THERE WAS AN ERROR, GO BACK TO STEP 1
  119. } else {
  120. $task = "step1";
  121. }
  122.  
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. if($task == "step1" || $task == "step1do" || $task == "step2" || $task == "step2do") {
  137. if($database->database_num_rows($database->database_query("SELECT NULL FROM se_profilecats WHERE profilecat_id='$signup_cat' AND profilecat_dependency='0'")) != 1) {
  138. $cat_info = $database->database_fetch_assoc($database->database_query("SELECT profilecat_id FROM se_profilecats WHERE profilecat_dependency='0' ORDER BY profilecat_order LIMIT 1"));
  139. $signup_cat = $cat_info[profilecat_id];
  140. }
  141. if($task == "step2do") { $validate = 1; } else { $validate = 0; }
  142. if($task != "step1") { $cat_where = "profilecat_signup='1' AND profilecat_id='$signup_cat'"; } else { $cat_where = "profilecat_signup='1'"; }
  143. $field = new se_field("profile");
  144. $field->cat_list($validate, 0, 0, $cat_where, "", "profilefield_signup='1'");
  145. $cat_array = $field->cats;
  146. if($task != "step1" && count($cat_array) == 0) { $task = "step1"; }
  147. if($validate == 1) { $is_error = $field->is_error; }
  148. if($task != "step1" && count($field->fields_all) == 0) { $task = "step2do"; }
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. if($task == "step2do") {
  160.  
  161.  
  162. // PROFILE FIELD INPUTS PROCESSED AND CHECKED FOR ERRORS ABOVE
  163. // IF THERE IS NO ERROR, ADD USER AND USER PROFILE AND CONTINUE TO STEP 3
  164. if($is_error == 0) {
  165. $new_user->user_create($signup_email, $signup_username, $signup_password, $signup_timezone, $signup_lang, $signup_cat, $field->field_query);
  166.  
  167. // INVITE CODE FEATURES
  168. if($setting[setting_signup_invite] != 0) {
  169. if($setting[setting_signup_invite_checkemail] != 0) {
  170. $invitation = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_invites WHERE invite_code='$signup_invite' AND invite_email='$signup_email' LIMIT 1"));
  171. } else {
  172. $invitation = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_invites WHERE invite_code='$signup_invite' LIMIT 1"));
  173. }
  174.  
  175. // ADD USER TO INVITER'S FRIENDLIST
  176. $friend = new se_user(Array($invitation[invite_user_id]));
  177. if($friend->user_exists == 1) {
  178. if($setting[setting_connection_allow] == 3 || $setting[setting_connection_allow] == 1 || ($setting[setting_connection_allow] == 2 && $new_user->user_info[user_subnet_id] == $friend->user_info[user_subnet_id])) {
  179. // SET RESULT, DIRECTION, STATUS
  180. switch($setting[setting_connection_framework]) {
  181. case "0":
  182. $direction = 2;
  183. $friend_status = 0;
  184. break;
  185. case "1":
  186. $direction = 1;
  187. $friend_status = 0;
  188. break;
  189. case "2":
  190. $direction = 2;
  191. $friend_status = 1;
  192. break;
  193. case "3":
  194. $direction = 1;
  195. $friend_status = 1;
  196. break;
  197. }
  198.  
  199. // INSERT FRIENDS INTO FRIEND TABLE AND EXPLANATION INTO EXPLAIN TABLE
  200. $friend->user_friend_add($new_user->user_info[user_id], $friend_status, '', '');
  201.  
  202. // IF TWO-WAY CONNECTION AND NON-CONFIRMED, INSERT OTHER DIRECTION
  203. if($direction == 2 && $friend_status == 1) { $new_user->user_friend_add($friend->user_info[user_id], $friend_status, '', ''); }
  204. }
  205. }
  206.  
  207.  
  208. // DELETE INVITE CODE
  209. $database->database_query("DELETE FROM se_invites WHERE invite_id='$invitation[invite_id]' LIMIT 1");
  210.  
  211. }
  212.  
  213. // SET SIGNUP COOKIE
  214. $id = $new_user->user_info[user_id];
  215. $em = crypt($new_user->user_info[user_email], "$1$".$new_user->user_info[user_code]."$");
  216. $pass = $new_user->user_info[user_password];
  217. setcookie("signup_id", "$id", 0, "/");
  218. setcookie("signup_email", "$em", 0, "/");
  219. setcookie("signup_password", "$pass", 0, "/");
  220.  
  221.  
  222. // SEND USER TO PHOTO UPLOAD IF SPECIFIED BY ADMIN
  223. // OR TO USER INVITE IF NO PHOTO UPLOAD
  224. if($setting[setting_signup_photo] == 0) {
  225. if($setting[setting_signup_invitepage] == 0) {
  226. $task = "step5";
  227. } else {
  228. $task = "step4";
  229. }
  230. } else {
  231. $task = "step3";
  232. }
  233.  
  234. // IF THERE WAS AN ERROR, GO BACK TO STEP 2
  235. } else {
  236. $task = "step2";
  237. }
  238. }
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246. // UPLOAD PHOTO
  247. if($task == "step3do") {
  248. $new_user->user_photo_upload("photo");
  249. $is_error = $new_user->is_error;
  250. $task = "step3";
  251. }
  252.  
  253.  
  254.  
  255.  
  256. // SEND INVITE EMAILS
  257. if($task == "step4do") {
  258.  
  259. $invite_emails = $_POST['invite_emails'];
  260. $invite_message = $_POST['invite_message'];
  261.  
  262. if($invite_emails != "") {
  263. send_systememail('invite', $invite_emails, Array($new_user->user_displayname, $new_user->user_info[user_email], $invite_message, "<a href=\"".$url->url_base."signup.php\">".$url->url_base."signup.php</a>"), TRUE);
  264. }
  265.  
  266. // SEND USER TO THANK YOU PAGE
  267. $task = "step5";
  268.  
  269. }
  270.  
  271.  
  272.  
  273.  
  274.  
  275. // SIGNUP TERMINAL VELOCITY POINT HOOK
  276. ($hook = SE_Hook::exists('se_signup_decide')) ? SE_Hook::call($hook, array()) : NULL;
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284. // SHOW COMPLETION PAGE
  285. if($task == "step5") {
  286. // UNSET SIGNUP COOKIES
  287. setcookie("signup_id", "", 0, "/");
  288. setcookie("signup_email", "", 0, "/");
  289. setcookie("signup_password", "", 0, "/");
  290.  
  291. // UPDATE SIGNUP STATS
  292. update_stats("signups");
  293.  
  294. // DISPLAY THANK YOU
  295. $step = 5;
  296. }
  297.  
  298.  
  299.  
  300.  
  301. // SHOW FOURTH STEP
  302. if($task == "step4") {
  303. $step = 4;
  304. $next_task = "step4do";
  305. if($setting[setting_signup_invitepage] == 0) { $task = "step3"; }
  306. }
  307.  
  308.  
  309.  
  310.  
  311.  
  312. // SHOW THIRD STEP
  313. if($task == "step3") {
  314. $step = 3;
  315. $next_task = "step3do";
  316. if($setting[setting_signup_invitepage] == 0) { $last_task = "step5"; } else { $last_task = "step4"; }
  317. if($setting[setting_signup_photo] == 0) { $task = "step2"; }
  318. }
  319.  
  320.  
  321.  
  322.  
  323.  
  324. // SHOW SECOND STEP
  325. if($task == "step2") {
  326. $step = 2;
  327. $next_task = "step2do";
  328. if(count($field->cats) == 0) { $task = "step1"; }
  329. $signup_password = base64_encode($signup_password);
  330. $signup_password2 = base64_encode($signup_password2);
  331. }
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. // SHOW FIRST STEP
  340. if($task == "step1") {
  341. $step = 1;
  342. $next_task = "step1do";
  343.  
  344. // GET LANGUAGE PACK LIST
  345. $lang_packlist = SE_Language::list_packs();
  346. ksort($lang_packlist);
  347. $lang_packlist = array_values($lang_packlist);
  348.  
  349. }
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356. // SET GLOBAL PAGE TITLE
  357. $global_page_title[0] = 679;
  358. $global_page_description[0] = 680;
  359.  
  360.  
  361.  
  362. // ASSIGN VARIABLES AND INCLUDE FOOTER
  363. $smarty->assign('is_error', $is_error);
  364. $smarty->assign('new_user', $new_user);
  365. $smarty->assign('cats', $field->cats);
  366. $smarty->assign('signup_email', $signup_email);
  367. $smarty->assign('signup_password', $signup_password);
  368. $smarty->assign('signup_password2', $signup_password2);
  369. $smarty->assign('signup_username', $signup_username);
  370. $smarty->assign('signup_timezone', $signup_timezone);
  371. $smarty->assign('signup_lang', $signup_lang);
  372. $smarty->assign('signup_invite', $signup_invite);
  373. $smarty->assign('signup_secure', $signup_secure);
  374. $smarty->assign('signup_agree', $signup_agree);
  375. $smarty->assign('signup_cat', $signup_cat);
  376. $smarty->assign('lang_packlist', $lang_packlist);
  377. $smarty->assign('next_task', $next_task);
  378. $smarty->assign('last_task', $last_task);
  379. $smarty->assign('step', $step);
  380. include "footer.php";
  381. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement