Advertisement
WiziSocialWork

Registration

Jun 1st, 2025
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.12 KB | None | 0 0
  1. <?php
  2. if ($f == 'register') {
  3. if (!empty($_SESSION['user_id'])) {
  4. $_SESSION['user_id'] = '';
  5. unset($_SESSION['user_id']);
  6. }
  7. if (!empty($_COOKIE['user_id'])) {
  8. $_COOKIE['user_id'] = '';
  9. unset($_COOKIE['user_id']);
  10. setcookie('user_id', '', -1);
  11. setcookie('user_id', '', -1, '/');
  12. }
  13. if ($wo['config']['auto_username'] == 1) {
  14. $_POST['username'] = time() . rand(111111, 999999);
  15. if (empty($_POST['first_name']) || empty($_POST['last_name'])) {
  16. $errors = $error_icon . $wo['lang']['first_name_last_name_empty'];
  17. header("Content-type: application/json");
  18. echo json_encode(array(
  19. 'errors' => $errors
  20. ));
  21. exit();
  22. }
  23. if (preg_match('/[^\w\s]+/u', $_POST['first_name']) || preg_match('/[^\w\s]+/u', $_POST['last_name'])) {
  24. $errors = $error_icon . $wo['lang']['username_invalid_characters'];
  25. }
  26. }
  27. $fields = Wo_GetWelcomeFileds();
  28. if (empty($_POST['email']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirm_password']) || empty($_POST['gender'])) {
  29. $errors = $error_icon . $wo['lang']['please_check_details'];
  30. } else {
  31. $is_exist = Wo_IsNameExist($_POST['username'], 0);
  32. if (empty($_POST['phone_num']) && $wo['config']['sms_or_email'] == 'sms') {
  33. $errors = $error_icon . $wo['lang']['worng_phone_number'];
  34. }
  35. if (in_array(true, $is_exist)) {
  36. $errors = $error_icon . $wo['lang']['username_exists'];
  37. }
  38. if (Wo_IsBanned($_POST['username'])) {
  39. $errors = $error_icon . $wo['lang']['username_is_banned'];
  40. }
  41. if (Wo_IsBanned($_POST['email'])) {
  42. $errors = $error_icon . $wo['lang']['email_is_banned'];
  43. }
  44. if (preg_match_all('~@(.*?)(.*)~', $_POST['email'], $matches) && !empty($matches[2]) && !empty($matches[2][0]) && Wo_IsBanned($matches[2][0])) {
  45. $errors = $error_icon . $wo['lang']['email_provider_banned'];
  46. }
  47. if (Wo_CheckIfUserCanRegister($wo['config']['user_limit']) === false) {
  48. $errors = $error_icon . $wo['lang']['limit_exceeded'];
  49. }
  50. if (in_array($_POST['username'], $wo['site_pages'])) {
  51. $errors = $error_icon . $wo['lang']['username_invalid_characters'];
  52. }
  53. if (strlen($_POST['username']) < 5 OR strlen($_POST['username']) > 32) {
  54. $errors = $error_icon . $wo['lang']['username_characters_length'];
  55. }
  56. if (!preg_match('/^[\w]+$/', $_POST['username'])) {
  57. $errors = $error_icon . $wo['lang']['username_invalid_characters'];
  58. }
  59. if ($wo['config']['reserved_usernames_system'] == 1 && in_array($_POST["username"], $wo['reserved_usernames'])) {
  60. $errors = $error_icon . $wo['lang']['username_is_disallowed'];
  61. }
  62. if (!empty($_POST['phone_num'])) {
  63. if (!preg_match('/^\+?\d+$/', $_POST['phone_num'])) {
  64. $errors = $error_icon . $wo['lang']['worng_phone_number'];
  65. } else {
  66. if (Wo_PhoneExists($_POST['phone_num']) === true) {
  67. $errors = $error_icon . $wo['lang']['phone_already_used'];
  68. }
  69. }
  70. }
  71. if (Wo_EmailExists($_POST['email']) === true) {
  72. $errors = $error_icon . $wo['lang']['email_exists'];
  73. }
  74. if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
  75. $errors = $error_icon . $wo['lang']['email_invalid_characters'];
  76. }
  77. if (strlen($_POST['password']) < 6) {
  78. $errors = $error_icon . $wo['lang']['password_short'];
  79. }
  80. if ($_POST['password'] != $_POST['confirm_password']) {
  81. $errors = $error_icon . $wo['lang']['password_mismatch'];
  82. }
  83. if ($config['reCaptcha'] == 1) {
  84. if (!isset($_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
  85. $errors = $error_icon . $wo['lang']['reCaptcha_error'];
  86. }
  87. }
  88. $gender = 'male';
  89. if (in_array($_POST['gender'], array_keys($wo['genders']))) {
  90. $gender = $_POST['gender'];
  91. }
  92. if (!empty($fields) && count($fields) > 0) {
  93. foreach ($fields as $key => $field) {
  94. if (empty($_POST[$field['fid']])) {
  95. $errors = $error_icon . $field['name'] . ' is required';
  96. }
  97. if (mb_strlen($_POST[$field['fid']]) > $field['length']) {
  98. $errors = $error_icon . $field['name'] . ' field max characters is ' . $field['length'];
  99. }
  100. }
  101. }
  102. }
  103. $field_data = array();
  104. if (empty($errors)) {
  105. if (!empty($fields) && count($fields) > 0) {
  106. foreach ($fields as $key => $field) {
  107. if (!empty($_POST[$field['fid']])) {
  108. $name = $field['fid'];
  109. if (!empty($_POST[$name])) {
  110. $field_data[] = array(
  111. $name => $_POST[$name]
  112. );
  113. }
  114. }
  115. }
  116. }
  117. $activate = ($wo['config']['emailValidation'] == '1') ? '0' : '1';
  118. $code = md5(rand(1111, 9999) . time());
  119. $re_data = array(
  120. 'email' => Wo_Secure($_POST['email'], 0),
  121. 'username' => Wo_Secure($_POST['username'], 0),
  122. 'password' => $_POST['password'],
  123. 'email_code' => Wo_Secure($code, 0),
  124. 'src' => 'site',
  125. 'gender' => Wo_Secure($gender),
  126. 'lastseen' => time(),
  127. 'active' => Wo_Secure($activate),
  128. 'birthday' => '0000-00-00'
  129. );
  130. if ($wo['config']['disable_start_up'] == '1') {
  131. $re_data['start_up'] = '1';
  132. $re_data['start_up_info'] = '1';
  133. $re_data['startup_follow'] = '1';
  134. $re_data['startup_image'] = '1';
  135. }
  136. if ($wo['config']['website_mode'] == 'linkedin' && !empty($_POST['currently_working']) && in_array($_POST['currently_working'], array(
  137. 'yes',
  138. 'am_looking_to_work',
  139. 'am_looking_for_employees'
  140. ))) {
  141. $re_data['currently_working'] = Wo_Secure($_POST['currently_working'], 0);
  142. }
  143. if ($wo['config']['auto_username'] == 1) {
  144. if (!empty($_POST['first_name'])) {
  145. $re_data['first_name'] = Wo_Secure($_POST['first_name'],1);
  146. }
  147. if (!empty($_POST['last_name'])) {
  148. $re_data['last_name'] = Wo_Secure($_POST['last_name'],1);
  149. }
  150. }
  151. if ($gender == 'female') {
  152. $re_data['avatar'] = "upload/photos/f-avatar.jpg";
  153. }
  154. if (!empty($_SESSION['ref']) && $wo['config']['affiliate_type'] == 0) {
  155. $ref_user_id = Wo_UserIdFromUsername($_SESSION['ref']);
  156. if (!empty($ref_user_id) && is_numeric($ref_user_id)) {
  157. $re_data['referrer'] = Wo_Secure($ref_user_id);
  158. $re_data['src'] = Wo_Secure('Referrer');
  159. if ($wo['config']['affiliate_level'] < 2) {
  160. $update_balance = Wo_UpdateBalance($ref_user_id, $wo['config']['amount_ref']);
  161. }
  162. unset($_SESSION['ref']);
  163. }
  164. } elseif (!empty($_SESSION['ref']) && $wo['config']['affiliate_type'] == 1) {
  165. $ref_user_id = Wo_UserIdFromUsername($_SESSION['ref']);
  166. if (!empty($ref_user_id) && is_numeric($ref_user_id)) {
  167. $re_data['ref_user_id'] = Wo_Secure($ref_user_id);
  168. }
  169. }
  170. if (!empty($_POST['phone_num'])) {
  171. $re_data['phone_number'] = Wo_Secure($_POST['phone_num']);
  172. }
  173. $in_code = (isset($_POST['invited'])) ? Wo_Secure($_POST['invited']) : false;
  174. if (empty($_POST['phone_num'])) {
  175. $register = Wo_RegisterUser($re_data, $in_code);
  176. } else {
  177. if ($activate == 1) {
  178. $register = Wo_RegisterUser($re_data, $in_code);
  179. } else {
  180. $register = true;
  181. }
  182. }
  183. if ($register === true) {
  184. $r_id = Wo_UserIdFromUsername($_POST['username']);
  185. if (!empty($re_data['referrer']) && is_numeric($wo['config']['affiliate_level']) && $wo['config']['affiliate_level'] > 1) {
  186. AddNewRef($re_data['referrer'], $r_id, $wo['config']['amount_ref']);
  187. }
  188. if ($activate == 1 || ($wo['config']['sms_or_email'] == 'mail' && $activate != 1)) {
  189. $wo['user'] = Wo_UserData($r_id);
  190. if ($wo['config']['auto_username'] == 1) {
  191. $_POST['username'] = $_POST['username'] . "_" . $r_id;
  192. $db->where('user_id', $r_id)->update(T_USERS, array(
  193. 'username' => $_POST['username']
  194. ));
  195. cache($r_id, 'users', 'delete');
  196. }
  197. if (!empty($wo['config']['auto_friend_users'])) {
  198. $autoFollow = Wo_AutoFollow(Wo_UserIdFromUsername($_POST['username']));
  199. }
  200. if (!empty($wo['config']['auto_page_like'])) {
  201. Wo_AutoPageLike(Wo_UserIdFromUsername($_POST['username']));
  202. }
  203. if (!empty($wo['config']['auto_group_join'])) {
  204. Wo_AutoGroupJoin(Wo_UserIdFromUsername($_POST['username']));
  205. }
  206. }
  207. if ($activate == 1) {
  208. $data = array(
  209. 'status' => 200,
  210. 'message' => $success_icon . $wo['lang']['successfully_joined_label']
  211. );
  212. $login = Wo_Login($_POST['username'], $_POST['password']);
  213. if ($login === true) {
  214. $session = Wo_CreateLoginSession(Wo_UserIdFromUsername($_POST['username']));
  215. $_SESSION['user_id'] = $session;
  216. setcookie("user_id", $session, time() + (10 * 365 * 24 * 60 * 60));
  217. }
  218. $data['location'] = Wo_SeoLink('index.php?link1=start-up');
  219. if ($wo['config']['membership_system'] == 1) {
  220. $data['location'] = Wo_SeoLink('index.php?link1=go-pro');
  221. }
  222. } else if ($wo['config']['sms_or_email'] == 'mail') {
  223. $wo['code'] = $code;
  224. $body = Wo_LoadPage('emails/activate');
  225. $send_message_data = array(
  226. 'from_email' => $wo['config']['siteEmail'],
  227. 'from_name' => $wo['config']['siteName'],
  228. 'to_email' => $_POST['email'],
  229. 'to_name' => $_POST['username'],
  230. 'subject' => $wo['lang']['account_activation'],
  231. 'charSet' => 'utf-8',
  232. 'message_body' => $body,
  233. 'is_html' => true
  234. );
  235. $send = Wo_SendMessage($send_message_data);
  236. $errors = $success_icon . $wo['lang']['successfully_joined_verify_label'];
  237. } else if ($wo['config']['sms_or_email'] == 'sms' && !empty($_POST['phone_num'])) {
  238. $random_activation = Wo_Secure(rand(11111, 99999));
  239. $message = "Your confirmation code is: {$random_activation}";
  240. if (Wo_SendSMSMessage($_POST['phone_num'], $message) === true) {
  241. $register = Wo_RegisterUser($re_data, $in_code);
  242. if ($wo['config']['auto_username'] == 1) {
  243. $r_id = Wo_UserIdFromUsername($_POST['username']);
  244. $_POST['username'] = $_POST['username'] . "_" . $r_id;
  245. $db->where('user_id', $r_id)->update(T_USERS, array(
  246. 'username' => $_POST['username']
  247. ));
  248. cache($r_id, 'users', 'delete');
  249. }
  250. $user_id = Wo_UserIdFromUsername($_POST['username']);
  251. $query = mysqli_query($sqlConnect, "UPDATE " . T_USERS . " SET `sms_code` = '{$random_activation}' WHERE `user_id` = {$user_id}");
  252. cache($user_id, 'users', 'delete');
  253. $data = array(
  254. 'status' => 300,
  255. 'location' => Wo_SeoLink('index.php?link1=confirm-sms?code=' . $code)
  256. );
  257. } else {
  258. $errors = $error_icon . $wo['lang']['failed_to_send_code_email'];
  259. }
  260. }
  261. }
  262. if (!empty($field_data)) {
  263. $user_id = Wo_UserIdFromUsername($_POST['username']);
  264. $insert = Wo_UpdateUserCustomData($user_id, $field_data, false);
  265. }
  266. }
  267. header("Content-type: application/json");
  268. if (isset($errors)) {
  269. echo json_encode(array(
  270. 'errors' => $errors
  271. ));
  272. } else {
  273. echo json_encode($data);
  274. }
  275. exit();
  276. }
  277.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement