Advertisement
Guest User

Untitled

a guest
Feb 8th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.12 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /*
  5. =====================================================
  6. vldPersonals - by VLD Interactive Inc.
  7. ----------------------------------------------------
  8. http://www.vldpersonals.com/
  9. http://www.vldinteractive.com/
  10. -----------------------------------------------------
  11. Copyright (c) 2005-2014 VLD Interactive Inc.
  12. =====================================================
  13. THIS IS COPYRIGHTED SOFTWARE
  14. PLEASE READ THE LICENSE AGREEMENT
  15. http://www.vldpersonals.com/agreement/
  16. =====================================================
  17. */
  18.  
  19. //------------------------------------------------
  20. // Includes
  21. //------------------------------------------------
  22. include SYS_PATH . 'includes/languages/' . SYS_LANG . '/lang.lib.account_register.php';
  23. include SYS_PATH . 'includes/fns/fns.validate.php';
  24. include SYS_PATH . 'includes/core/core.image.php';
  25.  
  26.  
  27. //------------------------------------------------
  28. // Check if the user is logged in
  29. //------------------------------------------------
  30. if ($SESSION->auth)
  31. redirect(VIR_PATH);
  32.  
  33.  
  34. //------------------------------------------------
  35. // Select registration form
  36. //------------------------------------------------
  37. show_register();
  38.  
  39.  
  40. //------------------------------------------------
  41. // Show registration form
  42. //------------------------------------------------
  43. function show_register()
  44. {
  45. global $DB, $LANG, $TEMPLATE, $SESSION, $PREFS;
  46.  
  47.  
  48. //------------------------------------------------
  49. // Set template file
  50. //------------------------------------------------
  51. $TEMPLATE->set_template("account_register.tpl");
  52.  
  53.  
  54. //------------------------------------------------
  55. // Assign page title
  56. //------------------------------------------------
  57. $TEMPLATE->assign("app_page", ($LANG['register']['app_register']));
  58.  
  59.  
  60. //------------------------------------------------
  61. // Check if registration is allowed
  62. //------------------------------------------------
  63. if ($PREFS->conf['allow_registration'] != 1)
  64. {
  65. $TEMPLATE->set_message("info", ($LANG['register']['no_registration']), 0, 1);
  66. return 0;
  67. }
  68.  
  69.  
  70. //------------------------------------------------
  71. // Set default values
  72. //------------------------------------------------
  73. $username = isset($_POST['username']) && $_POST['username'] ? $DB->strip_slashes(trim($_POST['username'])) : "";
  74. $password = isset($_POST['password']) && $_POST['password'] ? $DB->strip_slashes(trim($_POST['password'])) : "";
  75. $password_confirm = isset($_POST['password_confirm']) && $_POST['password_confirm'] ? $DB->strip_slashes(trim($_POST['password_confirm'])) : "";
  76. $email = isset($_POST['email']) && $_POST['email'] ? $DB->strip_slashes(trim($_POST['email'])) : "";
  77. $email_confirm = isset($_POST['email_confirm']) && $_POST['email_confirm'] ? $DB->strip_slashes(trim($_POST['email_confirm'])) : "";
  78. $captcha = isset($_POST['captcha']) && $_POST['captcha'] ? $DB->strip_slashes(trim($_POST['captcha'])) : "";
  79. $tos = isset($_POST['tos']) && $_POST['tos'] ? 1 : 0;
  80. $photo = isset($_FILES['photo']) ? $_FILES['photo'] : "";
  81. if ( isset($_POST['type_id']) && is_numeric($_POST['type_id']) && isset($PREFS->conf['profile_types'][$_POST['type_id']]) ) {
  82. $type_id = intval($_POST['type_id']);
  83. }
  84. elseif ( isset($_GET['type_id']) && is_numeric($_GET['type_id']) && isset($PREFS->conf['profile_types'][$_GET['type_id']]) ) {
  85. $type_id = intval($_GET['type_id']);
  86. }
  87. else {
  88. $type_id = $PREFS->conf['default_profile_type'];
  89. }
  90.  
  91.  
  92. $t = $index_type_id = 0;
  93. $fields = $default_fields = array();
  94. //------------------------------------------------
  95. // Parse profile groups and fields
  96. //------------------------------------------------
  97. foreach ($PREFS->conf['profile_types'] as $profile_type)
  98. {
  99. $i = 0;
  100.  
  101. $fields[$t]['type_id'] = $profile_type['type_id'];
  102. $fields[$t]['type_label'] = $profile_type['type_label'];
  103. $fields[$t]['type_name'] = $profile_type['type_name'];
  104.  
  105. foreach ($profile_type['profile_groups'] as $profile_group)
  106. {
  107. $j = 0;
  108.  
  109. //------------------------------------------------
  110. // Assign dynamic group
  111. //------------------------------------------------
  112. if ($profile_group['group_in_registration'])
  113. {
  114. $fields[$t]['profile_groups'][$i] = $profile_group;
  115. $fields[$t]['profile_groups'][$i]['profile_fields'] = array();
  116.  
  117.  
  118. //------------------------------------------------
  119. // Assign static group
  120. //------------------------------------------------
  121. $TEMPLATE->assign('profile_group_' . $profile_group['group_label'], $profile_group['group_name']);
  122. }
  123.  
  124.  
  125. foreach ($profile_group['profile_fields'] as $profile_field)
  126. {
  127. if ($profile_field['field_in_registration'] && $profile_group['group_in_registration'])
  128. {
  129. //------------------------------------------------
  130. // Assign dynamic field
  131. //------------------------------------------------
  132. $fields[$t]['profile_groups'][$i]['profile_fields'][$j] = $profile_field;
  133.  
  134. //------------------------------------------------
  135. // Create years
  136. //------------------------------------------------
  137. if ($profile_field['field_type'] == "date" || $profile_field['field_type'] == "time" || $profile_field['field_type'] == "datetime")
  138. {
  139. $default_years = explode("\n", $profile_field['field_default'], 2);
  140. if ( count($default_years) == 2 ) {
  141. $startyear = date("Y") + $default_years[0];
  142. $endyear = date("Y") + $default_years[1];
  143. }
  144. else {
  145. $startyear = $endyear = date("Y");
  146. }
  147. $years = array();
  148. for ($y = $startyear; $y <= $endyear; $y++) {
  149. $years[$y] = $y;
  150. }
  151. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['years'] = $years;
  152. }
  153.  
  154.  
  155. //------------------------------------------------
  156. // Set value
  157. //------------------------------------------------
  158. $value = $profile_field['field_type'] != "checkbox" ? '' : array();
  159.  
  160.  
  161. if (isset($_POST['isregister']) && $_POST['isregister'] && $profile_type['type_id'] == $type_id)
  162. {
  163. $index_type_id = $t;
  164. //------------------------------------------------
  165. // Set custom
  166. //------------------------------------------------
  167. if ($profile_field['field_type'] == "birthday")
  168. {
  169. $date_day = isset($_POST[$profile_field['field_label'].'_day']) && $_POST[$profile_field['field_label'].'_day'] ? intval($_POST[$profile_field['field_label'].'_day']) : 0;
  170. $date_month = isset($_POST[$profile_field['field_label'].'_month']) && $_POST[$profile_field['field_label'].'_month'] ? intval($_POST[$profile_field['field_label'].'_month']) : 0;
  171. $date_year = isset($_POST[$profile_field['field_label'].'_year']) && $_POST[$profile_field['field_label'].'_year'] ? intval($_POST[$profile_field['field_label'].'_year']) : 0;
  172. $value = ( $date_day && $date_month && $date_year ) ? str_pad($date_year, 4, "0", STR_PAD_LEFT) . str_pad($date_month, 2, "0", STR_PAD_LEFT) . str_pad($date_day, 2, "0", STR_PAD_LEFT) : '';
  173. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_day'] = $date_day;
  174. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_month'] = $date_month;
  175. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_year'] = $date_year;
  176. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_day', $date_day);
  177. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_month', $date_month);
  178. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_year', $date_year);
  179. }
  180. elseif ($profile_field['field_type'] == "date" || $profile_field['field_type'] == "time" || $profile_field['field_type'] == "datetime")
  181. {
  182. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_minute']= isset($_POST[$profile_field['field_label'].'_minute']) && $_POST[$profile_field['field_label'].'_minute'] ? intval($_POST[$profile_field['field_label'].'_minute']) : 0;
  183. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_hour'] = isset($_POST[$profile_field['field_label'].'_hour']) && $_POST[$profile_field['field_label'].'_hour'] ? intval($_POST[$profile_field['field_label'].'_hour']) : 0;
  184. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_day'] = isset($_POST[$profile_field['field_label'].'_day']) && $_POST[$profile_field['field_label'].'_day'] ? intval($_POST[$profile_field['field_label'].'_day']) : 0;
  185. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_month'] = isset($_POST[$profile_field['field_label'].'_month']) && $_POST[$profile_field['field_label'].'_month'] ? intval($_POST[$profile_field['field_label'].'_month']) : 0;
  186. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_year'] = isset($_POST[$profile_field['field_label'].'_year']) && $_POST[$profile_field['field_label'].'_year'] ? intval($_POST[$profile_field['field_label'].'_year']) : 0;
  187. $value = mktime($fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_hour'], $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_minute'], 0, $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_month'], $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_day'], $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_year']);
  188. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_minute', $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_minute']);
  189. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_hour', $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_hour']);
  190. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_day', $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_day']);
  191. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_month', $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_month']);
  192. $TEMPLATE->assign('profile_field_' . $profile_field['field_label'] . '_value_year', $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_year']);
  193. }
  194. elseif ($profile_field['field_type'] == "checkbox")
  195. {
  196. $value = ( isset($_POST[$profile_field['field_label']]) ) ? $_POST[$profile_field['field_label']] : array();
  197. }
  198. elseif ($profile_field['field_type'] == "textarea")
  199. {
  200. $value = isset($_POST[$profile_field['field_label']]) ? $DB->strip_slashes(trim($_POST[$profile_field['field_label']])) : "";
  201. $value = str_replace("\r", '', $value);
  202. $value = preg_replace('/[ ]+/', ' ', $value);
  203. $value = preg_replace('/\n{3,}/', "\n\n", $value);
  204. $value = filter_wordwrap($value);
  205. }
  206. else
  207. {
  208. $value = isset($_POST[$profile_field['field_label']]) ? $DB->strip_slashes(trim($_POST[$profile_field['field_label']])) : "";
  209. }
  210.  
  211.  
  212. //------------------------------------------------
  213. // Apply filter if necessary
  214. //------------------------------------------------
  215. if ($SESSION->conf['apply_word_filter'] && ($profile_field['field_type'] == "textarea" || $profile_field['field_type'] == "text")) {
  216. $value = filter_words($value);
  217. }
  218.  
  219.  
  220. //------------------------------------------------
  221. // Assign dynamic field
  222. //------------------------------------------------
  223. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value'] = $value;
  224. }
  225. else
  226. {
  227. if ( in_array($profile_field['field_type'], array("radio", "combo")) )
  228. {
  229. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value'] = $profile_field['field_default'];
  230. }
  231. elseif ( in_array($profile_field['field_type'], array("date", "datetime", "time", "birthday")) )
  232. {
  233. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_day'] = '';
  234. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_month'] = '';
  235. $fields[$t]['profile_groups'][$i]['profile_fields'][$j]['field_value_year'] = '';
  236. }
  237. }
  238.  
  239.  
  240. //------------------------------------------------
  241. // Assign static field
  242. //------------------------------------------------
  243. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_name', $profile_field['field_name']);
  244. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_type', $profile_field['field_type']);
  245. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_maxlength', $profile_field['field_maxlength']);
  246. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_default', $profile_field['field_default']);
  247. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_items', $profile_field['field_items']);
  248. $TEMPLATE->assign('profile_field_' . $profile_type['type_label'] . '_' . $profile_field['field_label'] . '_value', $value);
  249.  
  250.  
  251. $j++;
  252. }
  253. elseif ( $profile_type['type_id'] == $type_id )
  254. {
  255. $default_fields[] = $profile_field;
  256. }
  257. }
  258.  
  259. if ($profile_group['group_in_registration'])
  260. {
  261. $i++;
  262. }
  263. }
  264. $t++;
  265. }
  266.  
  267.  
  268. //------------------------------------------------
  269. // Check if the user has clicked on Submit
  270. //------------------------------------------------
  271. if (isset($_POST['isregister']) && $_POST['isregister'])
  272. {
  273. //------------------------------------------------
  274. // Register user
  275. //------------------------------------------------
  276. save_register($type_id, $index_type_id, $username, $password, $password_confirm, $email, $email_confirm, $photo, $tos, $captcha, $fields, $default_fields);
  277.  
  278. }
  279. else
  280. {
  281. //------------------------------------------------
  282. // Set default birthday
  283. //------------------------------------------------
  284. $birthday_day = 1;
  285. $birthday_month = 1;
  286. $birthday_year = date("Y") - $PREFS->conf['min_age'];
  287. }
  288. $_SESSION['captcha'] = random_string(5);
  289.  
  290.  
  291. //------------------------------------------------
  292. // Create minutes array
  293. //------------------------------------------------
  294. for ($i = 0; $i <= 59; $i++)
  295. $minutes[str_pad($i, 2, '0', STR_PAD_LEFT)] = str_pad($i, 2, '0', STR_PAD_LEFT);
  296.  
  297.  
  298. //------------------------------------------------
  299. // Create hours array
  300. //------------------------------------------------
  301. for ($i = 0; $i <= 23; $i++)
  302. $hours[str_pad($i, 2, '0', STR_PAD_LEFT)] = str_pad($i, 2, '0', STR_PAD_LEFT);
  303.  
  304.  
  305. //------------------------------------------------
  306. // Create days array
  307. //------------------------------------------------
  308. for ($i = 1; $i <= 31; $i++)
  309. $days[$i] = $i;
  310.  
  311.  
  312. //------------------------------------------------
  313. // Create years array
  314. //------------------------------------------------
  315. $startyear = date("Y") - $PREFS->conf['min_age'];
  316. $endyear = date("Y") - 90;
  317. $birthdayyears = array();
  318. for ($i = $startyear; $i >= $endyear; $i--)
  319. $birthdayyears[$i] = $i;
  320.  
  321.  
  322. //------------------------------------------------
  323. // Create months array
  324. //------------------------------------------------
  325. $months[1] = ($LANG['core']['bday_january']);
  326. $months[2] = ($LANG['core']['bday_february']);
  327. $months[3] = ($LANG['core']['bday_march']);
  328. $months[4] = ($LANG['core']['bday_april']);
  329. $months[5] = ($LANG['core']['bday_may']);
  330. $months[6] = ($LANG['core']['bday_june']);
  331. $months[7] = ($LANG['core']['bday_july']);
  332. $months[8] = ($LANG['core']['bday_august']);
  333. $months[9] = ($LANG['core']['bday_september']);
  334. $months[10] = ($LANG['core']['bday_october']);
  335. $months[11] = ($LANG['core']['bday_november']);
  336. $months[12] = ($LANG['core']['bday_december']);
  337.  
  338.  
  339. //------------------------------------------------
  340. // Create yes/no array
  341. //------------------------------------------------
  342.  
  343.  
  344. $yesnobox[1] = ($LANG['core']['yes']);
  345. $yesnobox[0] = ($LANG['core']['no']);
  346.  
  347.  
  348. //------------------------------------------------
  349. // Get profile types
  350. //------------------------------------------------
  351. $profiletypes = get_profile_types(1);
  352.  
  353.  
  354. //------------------------------------------------
  355. // Assign template vars
  356. //------------------------------------------------
  357. $TEMPLATE->assign("registration_username", htmlentities2utf8($username));
  358. $TEMPLATE->assign("registration_password", htmlentities2utf8($password));
  359. $TEMPLATE->assign("registration_password_confirm", htmlentities2utf8($password_confirm));
  360. $TEMPLATE->assign("registration_email", htmlentities2utf8($email));
  361. $TEMPLATE->assign("registration_email_confirm", htmlentities2utf8($email_confirm));
  362. $TEMPLATE->assign("registration_type_id", $type_id);
  363. $TEMPLATE->assign("is_tos", $PREFS->conf['registration_tos']);
  364. $TEMPLATE->assign("is_captcha", $PREFS->conf['registration_captcha'] && extension_loaded('gd'));
  365. $TEMPLATE->assign("registration_tos", $tos);
  366. $TEMPLATE->assign("days", $days);
  367. $TEMPLATE->assign("months", $months);
  368. $TEMPLATE->assign("birthday_years", $birthdayyears);
  369. $TEMPLATE->assign("minutes", $minutes);
  370. $TEMPLATE->assign("hours", $hours);
  371. $TEMPLATE->assign("profile_types", $fields);
  372. $TEMPLATE->assign("yesnobox", $yesnobox);
  373. $TEMPLATE->assign("profiletypes", $profiletypes);
  374.  
  375.  
  376. return 1;
  377. }
  378. // End Function
  379.  
  380.  
  381.  
  382. //------------------------------------------------
  383. // Save registration form
  384. //------------------------------------------------
  385. function save_register($type_id, $index_type_id, $username, $password, $password_confirm, $email, $email_confirm, $photo, $tos, $captcha, $fields, $default_fields)
  386. {
  387. global $DB, $LANG, $TEMPLATE, $PREFS, $SESSION;
  388.  
  389.  
  390. //------------------------------------------------
  391. // Validate username
  392. //------------------------------------------------
  393. $valid_username = validate_username($username, $PREFS->conf['min_username_length']);
  394. if ($username == "")
  395. {
  396. $TEMPLATE->set_message("error", ($LANG['register']['empty_username']), 0, 0);
  397. return 0;
  398. }
  399. elseif ($valid_username == 1)
  400. {
  401. $TEMPLATE->set_message("error", str_replace("%1%", $PREFS->conf['min_username_length'], ($LANG['register']['username_too_long'])), 0, 0);
  402. return 0;
  403. }
  404. elseif ($valid_username == 2)
  405. {
  406. $TEMPLATE->set_message("error", ($LANG['register']['invalid_username']), 0, 0);
  407. return 0;
  408. }
  409. elseif ($valid_username == 3)
  410. {
  411. $TEMPLATE->set_message("error", ($LANG['register']['invalid_username_digits']), 0, 0);
  412. return 0;
  413. }
  414.  
  415.  
  416. //------------------------------------------------
  417. // Check if username is banned
  418. //------------------------------------------------
  419. $usernames = array_map('trim', explode("\n", $PREFS->conf['banned_usernames']));
  420. if ( in_array($username, $usernames) )
  421. {
  422. $TEMPLATE->set_message("error", ($LANG['register']['banned_username']), 0, 0);
  423. return 0;
  424. }
  425.  
  426.  
  427. //------------------------------------------------
  428. // Validate password
  429. //------------------------------------------------
  430. $valid_password = validate_password($password, $PREFS->conf['min_password_length']);
  431. if ($password == "" || $password_confirm == "")
  432. {
  433. $TEMPLATE->set_message("error", ($LANG['register']['empty_passwords']), 0);
  434. return 0;
  435. }
  436. elseif ($valid_password == 1)
  437. {
  438. $TEMPLATE->set_message("error", str_replace("%1%", $PREFS->conf['min_password_length'], ($LANG['register']['password_too_long'])), 0, 0);
  439. return 0;
  440. }
  441. elseif ($valid_password == 2)
  442. {
  443. $TEMPLATE->set_message("error", ($LANG['register']['invalid_password']), 0, 0);
  444. return 0;
  445. }
  446. elseif ($password != $password_confirm)
  447. {
  448. $TEMPLATE->set_message("error", ($LANG['register']['passwords_dont_match']), 0, 0);
  449. return 0;
  450. }
  451.  
  452.  
  453. //------------------------------------------------
  454. // Validate email
  455. //------------------------------------------------
  456. $valid_email = validate_email($email);
  457. if ($email == "")
  458. {
  459. $TEMPLATE->set_message("error", ($LANG['register']['empty_emails']), 0, 0);
  460. return 0;
  461. }
  462. elseif ($valid_email == 1)
  463. {
  464. $TEMPLATE->set_message("error", str_replace("%1%", 4, ($LANG['register']['email_too_long'])), 0, 0);
  465. return 0;
  466. }
  467. elseif ($valid_email == 2)
  468. {
  469. $TEMPLATE->set_message("error", ($LANG['register']['invalid_email']), 0, 0);
  470. return 0;
  471. }
  472. elseif ($email != $email_confirm)
  473. {
  474. $TEMPLATE->set_message("error", ($LANG['register']['emails_dont_match']), 0, 0);
  475. return 0;
  476. }
  477.  
  478.  
  479. //------------------------------------------------
  480. // Check if email address is allowed
  481. //------------------------------------------------
  482. $emails = explode("\n", $PREFS->conf['banned_emails']);
  483.  
  484.  
  485. //------------------------------------------------
  486. // Check if the email is banned
  487. //------------------------------------------------
  488. foreach ($emails as $value)
  489. {
  490. $value = trim($value);
  491. if (substr($value, 0, 1) == '@' && strpos(strtolower($email), strtolower($value)) !== false)
  492. {
  493. $TEMPLATE->set_message("error", ($LANG['register']['banned_email']), 0, 0);
  494. return 0;
  495. }
  496. elseif ($value == $email)
  497. {
  498. $TEMPLATE->set_message("error", ($LANG['register']['banned_email']), 0, 0);
  499. return 0;
  500. }
  501. }
  502.  
  503.  
  504. if (!$type_id)
  505. {
  506. $TEMPLATE->set_message("error", ($LANG['register']['empty_type_id']), 0, 0);
  507. return 0;
  508. }
  509.  
  510.  
  511. $query_keys = $query_values = "";
  512. $items_values = array();
  513. //------------------------------------------------
  514. // Validate profile fields
  515. //------------------------------------------------
  516. if ( isset($fields[$index_type_id]['profile_groups']) )
  517. {
  518. foreach ($fields[$index_type_id]['profile_groups'] as $field_group)
  519. {
  520. foreach($field_group['profile_fields'] as $field)
  521. {
  522. if ($field_group['group_in_registration'] && $field['field_in_registration'])
  523. {
  524. //------------------------------------------------
  525. // Parse items
  526. //------------------------------------------------
  527. if ($field['field_type'] == 'checkbox')
  528. {
  529. foreach ( $field['field_value'] as $item_id ) {
  530. if ( is_numeric($item_id) && isset($field['field_items'][$item_id]) ) {
  531. $items_values[$field['field_id']][] = $item_id;
  532. }
  533. }
  534. if ($field['field_required'] && (!isset($items_values[$field['field_id']]) || !$items_values[$field['field_id']]) ) {
  535. $TEMPLATE->set_message("error", str_replace("%1%", $field['field_name'], ($LANG['register']['empty_required'])), 0, 0);
  536. return 0;
  537. }
  538. }
  539. elseif ($field['field_type'] == 'birthday')
  540. {
  541. $member_age = $field['field_value_year'].str_pad($field['field_value_month'], 2, '0', STR_PAD_LEFT).str_pad($field['field_value_day'], 2, '0', STR_PAD_LEFT);
  542. $allowed_age = (date("Y") - $PREFS->conf['min_age']).date("md");
  543. if ( $member_age > $allowed_age )
  544. {
  545. $TEMPLATE->set_message("error", str_replace("%age%", $PREFS->conf['min_age'], ($LANG['register']['young_member'])), 0, 0);
  546. return 0;
  547. }
  548. }
  549.  
  550. //------------------------------------------------
  551. // Validate the value
  552. //------------------------------------------------
  553. if ($field['field_required'] && ($field['field_type'] != "image" && $field['field_value'] == ""))
  554. {
  555. $TEMPLATE->set_message("error", str_replace("%1%", $field['field_name'], ($LANG['register']['empty_required'])), 0, 0);
  556. return 0;
  557. }
  558. elseif ($field['field_maxlength'] && strlen($field['field_value']) > $field['field_maxlength'])
  559. {
  560. $TEMPLATE->set_message("error", str_replace("%1%", $field['field_name'], str_replace("%2%", $field['field_maxlength'], ($LANG['register']['field_too_long']))), 0, 0);
  561. return 0;
  562. }
  563.  
  564. //------------------------------------------------
  565. // Build query
  566. //------------------------------------------------
  567. if ($field['field_type'] != "image" && $field['field_type'] != "checkbox") {
  568. $query_keys .= ",data_" . $field['field_label'];
  569. $query_values .= ",'" . mysql_real_escape_string($field['field_value']) . "'";
  570. }
  571. }
  572. }
  573. }
  574. }
  575.  
  576.  
  577. //------------------------------------------------
  578. // Validate profile fields
  579. //------------------------------------------------
  580. foreach ($default_fields as $field)
  581. {
  582. if ($field['field_type'] != "checkbox") {
  583. $query_keys .= ",data_" . $field['field_label'];
  584. $query_values .= ",'" . mysql_real_escape_string($field['field_default']) . "'";
  585. }
  586. elseif ($field['field_type'] != "image") {
  587. if ( $field['field_default'] ) {
  588. $field['field_default'] = @array_map("intval", explode(",", $field['field_default']));
  589. if ( isset($field['field_default'][0]) && $field['field_default'][0] == 0 ) {
  590. unset($field['field_default'][0]);
  591. }
  592. if ( $field['field_default'] ) {
  593. $items_values[$field['field_id']] = $field['field_default'];
  594. }
  595. }
  596. }
  597. }
  598.  
  599.  
  600. //------------------------------------------------
  601. // Check if TOS is available and accepted
  602. //------------------------------------------------
  603. if ($PREFS->conf['registration_tos'] != 0 && !$tos)
  604. {
  605. $TEMPLATE->set_message("error", ($LANG['register']['no_tos']), 0, 0);
  606. return 0;
  607. }
  608.  
  609.  
  610. //------------------------------------------------
  611. // Check if captcha is available and accepted
  612. //------------------------------------------------
  613. if ($PREFS->conf['registration_captcha'] != 0 && strcasecmp($_SESSION['captcha'], $captcha) != 0 && extension_loaded('gd'))
  614. {
  615. //------------------------------------------------
  616. // Set the message
  617. //------------------------------------------------
  618. $TEMPLATE->set_message("error", ($LANG['register']['invalid_catcha']), 0, 0);
  619. return 0;
  620. }
  621.  
  622.  
  623. //------------------------------------------------
  624. // Escape the ip
  625. //------------------------------------------------
  626. $ipaddress = mysql_real_escape_string(trim($SESSION->get_ip()));
  627. $joindate = time();
  628.  
  629.  
  630. //------------------------------------------------
  631. // Make sure username and email are unique
  632. //------------------------------------------------
  633. $result = $DB->query("SELECT username, email, ipaddress, joindate
  634. FROM " . DB_PREFIX . "members
  635. WHERE username='$username' OR email='$email' OR (ipaddress='$ipaddress' AND joindate>".($joindate-$PREFS->conf['registration_delay']*60*60).")
  636. LIMIT 1");
  637.  
  638.  
  639. //------------------------------------------------
  640. // Check if resultset contains rows
  641. //------------------------------------------------
  642. if ($DB->num_rows($result))
  643. {
  644. //------------------------------------------------
  645. // Fetch result set
  646. //------------------------------------------------
  647. $obj = $DB->fetch_object($result);
  648.  
  649.  
  650. //------------------------------------------------
  651. // Check if username or email was taken
  652. //------------------------------------------------
  653. if (strcmp(strtolower($obj->username), strtolower($username)) == 0)
  654. {
  655. //------------------------------------------------
  656. // Set the message
  657. //------------------------------------------------
  658. $TEMPLATE->set_message("error", ($LANG['register']['username_taken']), 0, 0);
  659. return 0;
  660. }
  661. elseif (strcmp(strtolower($obj->email), strtolower($email)) == 0)
  662. {
  663. //------------------------------------------------
  664. // Set the message
  665. //------------------------------------------------
  666. $TEMPLATE->set_message("error", ($LANG['register']['email_taken']), 0, 0);
  667. return 0;
  668. }
  669. elseif (strcmp($obj->ipaddress, $ipaddress) == 0 && $joindate-$obj->joindate < ($PREFS->conf['registration_delay']*60*60))
  670. {
  671. //------------------------------------------------
  672. // Set the message
  673. //------------------------------------------------
  674. $TEMPLATE->set_message("error", (str_replace('%hours%', $PREFS->conf['registration_delay'],$LANG['register']['double_registration'])), 0, 0);
  675. return 0;
  676. }
  677. }
  678.  
  679.  
  680. //------------------------------------------------
  681. // Clean up
  682. //------------------------------------------------
  683. unset($obj);
  684. unset($result);
  685.  
  686.  
  687. //------------------------------------------------
  688. // Check if file was selected
  689. //------------------------------------------------
  690. if ( $PREFS->conf['enable_registration_photo'] && $PREFS->conf['require_registration_photo'] && ( !isset($photo['error']) || $photo['error'] ) )
  691. {
  692. $TEMPLATE->set_message("error", ($LANG['register']['empty_photo']), 0, 0);
  693. return;
  694. }
  695. elseif ( $PREFS->conf['enable_registration_photo'] && isset($photo['error']) && !$photo['error'] )
  696. {
  697. //------------------------------------------------
  698. // Check if file was uploaded
  699. //------------------------------------------------
  700. if (!@is_uploaded_file($photo['tmp_name']))
  701. {
  702. $TEMPLATE->set_message("error", ($LANG['register']['cant_upload']), 0, 0);
  703. return;
  704. }
  705.  
  706.  
  707. //------------------------------------------------
  708. // Get picture's extention and it's length
  709. //------------------------------------------------
  710. $fext = explode('.', $photo['name']);
  711. $fext = strtolower(end($fext));
  712. $fextlen = strlen($fext . "0") + 1;
  713.  
  714.  
  715. //------------------------------------------------
  716. // Check file format
  717. //------------------------------------------------
  718. if ($fext != "gif" && $fext != "jpg" && $fext != "jpeg" && $fext != "png")
  719. {
  720. $TEMPLATE->set_message("error", ($LANG['register']['invalid_photo_file']), 0, 0);
  721. return;
  722. }
  723.  
  724.  
  725. //------------------------------------------------
  726. // Check file size
  727. //------------------------------------------------
  728. if ($photo['size'] >= ($PREFS->conf['max_photo_size'] * 1024))
  729. {
  730. ($LANG['register']['photo_file_too_big'] = str_replace("%size%", $PREFS->conf['max_photo_size'], $LANG['register']['photo_file_too_big']));
  731. $TEMPLATE->set_message("error", ($LANG['register']['photo_file_too_big']), 0, 0);
  732. return;
  733. }
  734.  
  735.  
  736. //------------------------------------------------
  737. // Generate unique filename
  738. //------------------------------------------------
  739. do
  740. {
  741. $fname = 'photo_0' . random_string(32 - $fextlen, 0);
  742. $picname = $fname . '.' . $fext;
  743. }
  744. while(@is_file(SYS_PIC_PATH . $picname));
  745.  
  746.  
  747.  
  748. //------------------------------------------------
  749. // Generate unique filename for album
  750. //------------------------------------------------
  751. if ( $PREFS->conf['default_album_name'] )
  752. {
  753. do
  754. {
  755. $fname2 = 'picture_0' . random_string(32 - $fextlen, 0);
  756. $picname2 = $fname2 . '.' . $fext;
  757. }
  758. while(@is_file(SYS_PIC_PATH . $picname2));
  759. }
  760.  
  761.  
  762. //------------------------------------------------
  763. // Make sure picture is not too small
  764. //------------------------------------------------
  765. list($width, $height) = @getimagesize($photo['tmp_name']);
  766. if ($width < $PREFS->conf['min_photo_width'] || $height < $PREFS->conf['min_photo_height'])
  767. {
  768. ($LANG['register']['photo_too_small'] = str_replace("%height%", $PREFS->conf['min_photo_height'], $LANG['register']['photo_too_small']));
  769. ($LANG['register']['photo_too_small'] = str_replace("%width%", $PREFS->conf['min_photo_width'], $LANG['register']['photo_too_small']));
  770. $TEMPLATE->set_message("error", ($LANG['register']['photo_too_small']), 0, 0);
  771. return;
  772. }
  773.  
  774.  
  775. //------------------------------------------------
  776. // Move the picture to member's folder
  777. //------------------------------------------------
  778. if (!@move_uploaded_file($photo['tmp_name'], SYS_PIC_PATH . $picname))
  779. {
  780. $picname = '';
  781. }
  782. else
  783. {
  784. @chmod(SYS_PIC_PATH . $picname, 0644);
  785. }
  786.  
  787.  
  788. //------------------------------------------------
  789. // Copy for album
  790. //------------------------------------------------
  791. if ( $PREFS->conf['default_album_name'] )
  792. {
  793. @copy(SYS_PIC_PATH . $picname, SYS_PIC_PATH . $picname2);
  794. @chmod(SYS_PIC_PATH . $picname2, 0644);
  795. }
  796.  
  797.  
  798. //------------------------------------------------
  799. // Create image class
  800. //------------------------------------------------
  801. $IMG = new Image(SYS_PIC_PATH);
  802.  
  803.  
  804. //------------------------------------------------
  805. // Resize photo
  806. //------------------------------------------------
  807. if ( isset($picname) && $picname && extension_loaded('gd') )
  808. {
  809. //------------------------------------------------
  810. // Resize original image
  811. //------------------------------------------------
  812. $IMG->prefix = TN_PREFIX;
  813. $IMG->cutoff = $PREFS->conf['cut_photos'];
  814. if (!$IMG->resize($fname, $fext, $PREFS->conf['thumbnail_photo_width'], $PREFS->conf['thumbnail_photo_height'], (isset($PREFS->conf['enable_photo_watermark']) && $PREFS->conf['enable_photo_watermark'] ? 'overlay_photo.png' : '')))
  815. {
  816. $picname = '';
  817. }
  818. else
  819. {
  820. @chmod(SYS_PIC_PATH . TN_PREFIX . $picname, 0644);
  821. //------------------------------------------------
  822. // Create thumbnail from the original image
  823. //------------------------------------------------
  824. $IMG->prefix = '';
  825. $IMG->cutoff = 0;
  826. if (!$IMG->resize($fname, $fext, $PREFS->conf['image_width'], $PREFS->conf['image_height'], (isset($PREFS->conf['enable_photo_watermark']) && $PREFS->conf['enable_photo_watermark'] ? 'overlay_photo.png' : '')))
  827. {
  828. @unlink(SYS_PIC_PATH . TN_PREFIX . $picname);
  829. $picname = '';
  830. }
  831. else
  832. {
  833. @chmod(SYS_PIC_PATH . $picname, 0644);
  834. }
  835. }
  836. }
  837.  
  838.  
  839. //------------------------------------------------
  840. // Resize album picture
  841. //------------------------------------------------
  842. if ( $PREFS->conf['default_album_name'] && isset($picname2) && $picname2 && extension_loaded('gd') )
  843. {
  844. if ($PREFS->conf['thumbnails'] && extension_loaded('gd'))
  845. {
  846. $IMG->prefix = $PREFS->conf['thumbnail_prefix'];
  847. $IMG->cutoff = $PREFS->conf['cut_images'];
  848. if (!$IMG->resize($fname2, $fext, $PREFS->conf['thumbnail_width'], $PREFS->conf['thumbnail_height'], (isset($PREFS->conf['enable_sm_watermark']) && $PREFS->conf['enable_sm_watermark'] ? 'overlay_picture_small.png' : '')))
  849. {
  850. $picname2 = '';
  851. }
  852. else
  853. {
  854. @chmod(SYS_PIC_PATH . $PREFS->conf['thumbnail_prefix'] . $picname2, 0644);
  855. }
  856. }
  857. else
  858. {
  859. @copy(SYS_PIC_PATH . $picname2, SYS_PIC_PATH . TN_PREFIX . $picname2);
  860. @chmod(SYS_PIC_PATH . TN_PREFIX . $picname2, 0644);
  861. }
  862.  
  863. if ($PREFS->conf['resize_image'] && extension_loaded('gd'))
  864. {
  865. $IMG->prefix = '';
  866. $IMG->cutoff = 0;
  867. if (!$IMG->resize($fname2, $fext, $PREFS->conf['image_width'], $PREFS->conf['image_height'], (isset($PREFS->conf['enable_lg_watermark']) && $PREFS->conf['enable_lg_watermark'] ? 'overlay_picture_big.png' : '')))
  868. {
  869. $picname2 = '';
  870. }
  871. else
  872. {
  873. @chmod(SYS_PIC_PATH . $picname2, 0644);
  874. }
  875. }
  876. }
  877. }
  878.  
  879.  
  880. //------------------------------------------------
  881. // Get referal id
  882. //------------------------------------------------
  883. if ($PREFS->conf['enable_referals'] && isset($_COOKIE['ref']) && is_numeric($_COOKIE['ref']))
  884. {
  885. $refid = intval($_COOKIE['ref']);
  886.  
  887.  
  888. //------------------------------------------------
  889. // Get referal
  890. //------------------------------------------------
  891. $result = $DB->query("SELECT group_id, totalreferrals FROM " . DB_PREFIX . "members WHERE member_id='$refid' LIMIT 1");
  892.  
  893.  
  894. //------------------------------------------------
  895. // Check if resultset contains any rows
  896. //------------------------------------------------
  897. if ($DB->num_rows($result))
  898. {
  899. //------------------------------------------------
  900. // Fetch resultset
  901. //------------------------------------------------
  902. $obj = $DB->fetch_object($result);
  903.  
  904.  
  905. //------------------------------------------------
  906. // Check if member can refer members
  907. //------------------------------------------------
  908. if ($PREFS->get_permissions($obj->group_id, 'can_refer_members'))
  909. {
  910. //------------------------------------------------
  911. // Update referal's counter
  912. //------------------------------------------------
  913. $DB->query("UPDATE " . DB_PREFIX . "members SET totalreferrals=totalreferrals+1 WHERE member_id='$refid' LIMIT 1");
  914. $obj->totalreferrals++;
  915.  
  916.  
  917. //------------------------------------------------
  918. // Check if referal upgrades are enabled
  919. //------------------------------------------------
  920. if ($PREFS->conf['referals_upgrade_members'] && $PREFS->get_permissions($obj->group_id, 'can_refer_upgrades'))
  921. {
  922. //------------------------------------------------
  923. // Check if upgrade is required
  924. //------------------------------------------------
  925. if ( $obj->totalreferrals && ($obj->totalreferrals % $PREFS->conf['referals_upgrade_members']) == 0)
  926. {
  927. //------------------------------------------------
  928. // Update member's group
  929. //------------------------------------------------
  930. set_membership_term($refid, 0, $PREFS->conf['referals_member_group'], 'day', $PREFS->conf['referals_upgrade_length']);
  931. }
  932. }
  933.  
  934.  
  935. //------------------------------------------------
  936. // Delete cookie
  937. //------------------------------------------------
  938. @setcookie("ref", "", time()-60, "/");
  939. }
  940. else
  941. $refid = 0;
  942. }
  943. else
  944. $refid = 0;
  945. }
  946. else
  947. $refid = 0;
  948.  
  949.  
  950. //------------------------------------------------
  951. // Set expiration date if trial is enabled
  952. //------------------------------------------------
  953. $expiration = $PREFS->conf['trial_member_length'] ? (time() + 60*60*24*$PREFS->conf['trial_member_length']) : 0;
  954. if ($expiration) $PREFS->conf['regular_member_group'] = $PREFS->conf['trial_member_group'];
  955. $joindate = time();
  956.  
  957.  
  958. //------------------------------------------------
  959. // Generate activation hash
  960. //------------------------------------------------
  961. $sessionhash = md5($username.md5($password));
  962.  
  963.  
  964. //------------------------------------------------
  965. // Get welcome defaults
  966. //------------------------------------------------
  967. $favorites_ids = $PREFS->conf['def_favorites_ids'] ? explode(",", $PREFS->conf['def_favorites_ids']) : array();
  968. $totalfavorites = count($favorites_ids);
  969.  
  970. $totalalbums = $PREFS->conf['default_album_name'] && isset($picname2) && $picname2 ? 1 : 0;
  971. $totalaguestbooks = $PREFS->conf['def_signee_id'] && $PREFS->conf['def_welcome_guestbook'] ? 1 : 0;
  972. $totalimessages = $PREFS->conf['def_signee_id'] && $PREFS->conf['def_welcome_msg_subject'] ? 1 : 0;
  973. $newmessages = $PREFS->conf['def_signee_id'] && $PREFS->conf['def_welcome_msg_subject'] ? 1 : 0;
  974. $actpic = $PREFS->get_permissions($PREFS->conf['regular_member_group'], 'can_approve_own_pictures') ? 1 : 0 ;
  975.  
  976.  
  977. //------------------------------------------------
  978. // Save user details to the database
  979. //------------------------------------------------
  980. $DB->query("INSERT INTO " . DB_PREFIX . "members (group_id, type_id, username, password, email, ipaddress, picture, picture_active, picture_date,
  981. joindate, expirationdate, active, totalfavorites, totalaguestbooks, totalimessages, newmessages, totalalbums, referral_id, totalcredits)
  982. VALUES ('" . ($PREFS->conf['activation_type'] == 1 ? $PREFS->conf['regular_member_group'] : $PREFS->conf['pending_member_group']) . "', '$type_id',
  983. '$username', '" . md5($password) . "', '$email', '$ipaddress',
  984. " . ( isset($picname) && $picname ? "'".substr($picname, 6)."'" : "''" ) . ",
  985. " . ( isset($picname) && $picname && $actpic ? 1 : 0 ). ",
  986. " . ( isset($picname) && $picname ? time() : 0 ). ",
  987. '" . $joindate . "', '$expiration', '1', '$totalfavorites', '$totalaguestbooks', '$totalimessages', '$newmessages', '$totalalbums',
  988. '$refid', '".$PREFS->conf['trial_member_credits']."')");
  989.  
  990.  
  991. //------------------------------------------------
  992. // Get insert id
  993. //------------------------------------------------
  994. $user_id = $DB->get_insert_id();
  995.  
  996.  
  997. //------------------------------------------------
  998. // Save user config and data to the database
  999. //------------------------------------------------
  1000. $config_data = array(
  1001. 'notify_private_messages' => $PREFS->conf['def_notify_private_messages'],
  1002. 'notify_gifts' => $PREFS->conf['def_notify_gifts'],
  1003. 'notify_blog_comments' => $PREFS->conf['def_notify_blog_comments'],
  1004. 'notify_guestbook_comments' => $PREFS->conf['def_notify_guestbook_comments'],
  1005. 'access_guestbook_moderate' => $PREFS->conf['def_moderate_guestbooks'],
  1006. 'notify_pictures_comments' => $PREFS->conf['def_notify_pictures_comments'],
  1007. 'notify_videos_comments' => $PREFS->conf['def_notify_videos_comments'],
  1008. 'notify_friends_requests' => $PREFS->conf['def_notify_friends_requests'],
  1009. 'notify_limit' => $PREFS->conf['def_notify_daily_limit'],
  1010. 'enable_newsletters' => $PREFS->conf['def_enable_newsletters'],
  1011. 'showadult' => $PREFS->conf['default_adult_pictures'],
  1012. 'timeformat' => $PREFS->conf['timeformat'],
  1013. 'timezone' => $PREFS->conf['timezone'],
  1014. 'template_id' => $SESSION->conf['template_id'],
  1015. 'language_id' => $SESSION->conf['language_id'],
  1016. );
  1017. $config_keys = implode(",", array_keys($config_data));
  1018. $config_values = implode(",", $config_data);
  1019. $DB->query("INSERT INTO " . DB_PREFIX . "members_conf (conf_id, $config_keys) VALUES ($user_id, $config_values)");
  1020. $DB->query("INSERT INTO " . DB_PREFIX . "members_data_".$PREFS->conf['profile_types'][$type_id]['type_label']." (data_id $query_keys) VALUES ($user_id $query_values)");
  1021.  
  1022. foreach ( $items_values as $field_id => $items_value ) {
  1023. foreach ( $items_value as $item_val ) {
  1024. $DB->query("INSERT INTO " . DB_PREFIX . "members_items (data_id, field_id, item_id) VALUES($user_id, $field_id, $item_val)");
  1025. }
  1026. }
  1027.  
  1028.  
  1029. //------------------------------------------------
  1030. // Add member to integrated software if enabled
  1031. //------------------------------------------------
  1032. call_module_function('members', 'update', array(
  1033. 'member_id' => $user_id,
  1034. 'password' => ($password ? $password : ''),
  1035. 'block' => ($PREFS->conf['activation_type'] == 1 ? 0 : 1),
  1036. ));
  1037.  
  1038.  
  1039. //------------------------------------------------
  1040. // Create media folder
  1041. //------------------------------------------------
  1042. $mediapath = get_media_path($joindate, $user_id);
  1043. recursive_mkdir(SYS_PIC_PATH, $mediapath, $PREFS->conf['chmod_folder']);
  1044.  
  1045.  
  1046. //------------------------------------------------
  1047. // Move profile picture
  1048. //------------------------------------------------
  1049. if ( isset($picname) && $picname ) {
  1050. @rename(SYS_PIC_PATH . $picname, SYS_PIC_PATH . $mediapath . $picname);
  1051. @rename(SYS_PIC_PATH . TN_PREFIX . $picname, SYS_PIC_PATH . $mediapath . TN_PREFIX . $picname);
  1052.  
  1053. // WALL
  1054. @copy(SYS_PIC_PATH . $mediapath . TN_PREFIX . $picname, './wall/media/profile/'.$picname);
  1055. $sURLPhoto = $picname;
  1056. // JTCHAT
  1057. @copy(SYS_PIC_PATH . $mediapath . TN_PREFIX . $picname, './jtchat/avatar/'.$picname);
  1058. }
  1059.  
  1060.  
  1061. //------------------------------------------------
  1062. // Move album picture
  1063. //------------------------------------------------
  1064. if ( isset($picname2) && $picname2 ) {
  1065. @rename(SYS_PIC_PATH . $picname2, SYS_PIC_PATH . $mediapath . $picname2);
  1066. @rename(SYS_PIC_PATH . TN_PREFIX . $picname2, SYS_PIC_PATH . $mediapath . TN_PREFIX . $picname2);
  1067. }
  1068.  
  1069.  
  1070. //------------------------------------------------
  1071. // Add favorites
  1072. //------------------------------------------------
  1073. foreach ( $favorites_ids as $favorite_id ) {
  1074. $DB->query("INSERT INTO " . DB_PREFIX . "favorites (member_id, favorite_id) VALUES('$user_id', '$favorite_id')");
  1075. }
  1076.  
  1077.  
  1078. //------------------------------------------------
  1079. // Add guestbook message
  1080. //------------------------------------------------
  1081. if ( $totalaguestbooks ) {
  1082. $PREFS->conf['def_welcome_guestbook'] = str_replace(
  1083. array(
  1084. '{username}',
  1085. '{email}',
  1086. '{website}',
  1087. ),
  1088. array(
  1089. $username,
  1090. $email,
  1091. VIR_PATH,
  1092. ), $PREFS->conf['def_welcome_guestbook']);
  1093. $DB->query("INSERT INTO " . DB_PREFIX . "guestbooks (member_id, poster_id, postdate, body, active)
  1094. VALUES('$user_id', '".$PREFS->conf['def_signee_id']."', '".time()."', '".mysql_real_escape_string($PREFS->conf['def_welcome_guestbook'])."', '1')");
  1095. }
  1096.  
  1097.  
  1098. //------------------------------------------------
  1099. // Add private message
  1100. //------------------------------------------------
  1101. if ( $totalimessages ) {
  1102. $PREFS->conf['def_welcome_msg_body'] = str_replace(
  1103. array(
  1104. '{username}',
  1105. '{email}',
  1106. '{website}',
  1107. ),
  1108. array(
  1109. $username,
  1110. $email,
  1111. VIR_PATH,
  1112. ), $PREFS->conf['def_welcome_msg_body']);
  1113. $DB->query("INSERT INTO " . DB_PREFIX . "messages (member_id1, member_id2, senddate, subject, body, new, delete1, delete2)
  1114. VALUES('".$PREFS->conf['def_signee_id']."', '$user_id', '".time()."', '".mysql_real_escape_string($PREFS->conf['def_welcome_msg_subject'])."',
  1115. '".mysql_real_escape_string($PREFS->conf['def_welcome_msg_body'])."', '1', '1', '0')");
  1116. }
  1117.  
  1118.  
  1119. //------------------------------------------------
  1120. // Add default album
  1121. //------------------------------------------------
  1122. if ( $PREFS->conf['default_album_name'] && isset($picname2) && $picname2 )
  1123. {
  1124. $DB->query("INSERT INTO " . DB_PREFIX . "albums (member_id, filename, description, dateadded, dateupdated, totalapictures, totalipictures, accesslevel)
  1125. VALUES('$user_id', '".substr($picname2, 8)."', '".mysql_real_escape_string($PREFS->conf['default_album_name'])."',
  1126. '" . time() . "', '0', '".($actpic ? 1 : 0)."', '".($actpic ? 0 : 1)."', '0')");
  1127. $aid = $DB->get_insert_id();
  1128.  
  1129. $DB->query("INSERT INTO " . DB_PREFIX . "pictures (member_id, album_id, filename, description, adult, rated, comments, dateadded, active, albumcover, orderid)
  1130. VALUES('$user_id', '$aid', '".substr($picname2, 8)."', '', '0', '1', '1', '" . time() . "', '$actpic', '1', '".($actpic ? 1 : 0)."')");
  1131. }
  1132.  
  1133.  
  1134. //------------------------------------------------
  1135. // Notify admin about user registration
  1136. //------------------------------------------------
  1137. if ($PREFS->conf['admin_notify_registration'])
  1138. {
  1139. send_email_template($PREFS->conf['admin_email'], 'admin_notify_registration', array(
  1140. 'username' => $username,
  1141. 'password' => $password,
  1142. 'email' => $email,
  1143. 'hash' => $sessionhash,
  1144. 'activation_link' => VIR_PATH . ($PREFS->conf['fancy_urls'] ? "account/activate/$user_id/$sessionhash/" : "index.php?m=account_activate&id=$user_id&hash=$sessionhash&a=1"),
  1145. 'decline_link' => VIR_PATH . ($PREFS->conf['fancy_urls'] ? "account/decline/$user_id/$sessionhash/" : "index.php?m=account_activate&id=$user_id&hash=$sessionhash&a=2"),
  1146. ), $SESSION->conf['language_id']);
  1147. }
  1148.  
  1149.  
  1150. //------------------------------------------------
  1151. // Auto activation
  1152. //------------------------------------------------
  1153. if ($PREFS->conf['activation_type'] == 1)
  1154. {
  1155. //------------------------------------------------
  1156. // Send out welcome message to user
  1157. //------------------------------------------------
  1158. if ($PREFS->conf['member_notify_registration'])
  1159. {
  1160. send_email_template($email, 'validated_member_notify', array(
  1161. 'username' => $username,
  1162. 'password' => $password,
  1163. 'email' => $email,
  1164. ), $SESSION->conf['language_id']);
  1165. }
  1166.  
  1167.  
  1168. //------------------------------------------------
  1169. // Set the message
  1170. //------------------------------------------------
  1171. $TEMPLATE->set_message("info", ($LANG['register']['auto_activation']), 0, 0);
  1172.  
  1173.  
  1174. //------------------------------------------------
  1175. // Login member
  1176. //------------------------------------------------
  1177. $_SESSION['member_id'] = $user_id;
  1178. $_SESSION['member_code'] = md5($email.md5($password));
  1179. $_SESSION['member_name'] = $username;
  1180. $_SESSION['username'] = $username;
  1181. $_SESSION['member_time'] = time();
  1182. redirect( VIR_PATH . ($PREFS->conf['fancy_urls'] ? "account/home/active" : "index.php?m=account_home&active=1") );
  1183. }
  1184. //------------------------------------------------
  1185. // Email activation
  1186. //------------------------------------------------
  1187. elseif ($PREFS->conf['activation_type'] == 2)
  1188. {
  1189. send_email_template($email, 'member_activation_instructions', array(
  1190. 'username' => $username,
  1191. 'password' => $password,
  1192. 'email' => $email,
  1193. 'hash' => $sessionhash,
  1194. 'activation_link' => VIR_PATH . ($PREFS->conf['fancy_urls'] ? "account/activate/$user_id/$sessionhash/" : "index.php?m=account_activate&id=$user_id&hash=$sessionhash&a=1"),
  1195. ), $SESSION->conf['language_id']);
  1196.  
  1197.  
  1198. //------------------------------------------------
  1199. // Set the message
  1200. //------------------------------------------------
  1201. $TEMPLATE->set_message("info", ($LANG['register']['email_activation']), 0, 0);
  1202. }
  1203. //------------------------------------------------
  1204. // Admin activation
  1205. //------------------------------------------------
  1206. elseif ($PREFS->conf['activation_type'] == 3)
  1207. {
  1208. send_email_template($email, 'member_activation_instructions', array(
  1209. 'username' => $username,
  1210. 'password' => $password,
  1211. 'email' => $email,
  1212. 'hash' => '',
  1213. 'activation_link' => 'Pending administrator review',
  1214. ), $SESSION->conf['language_id']);
  1215.  
  1216.  
  1217. //------------------------------------------------
  1218. // Set the message
  1219. //------------------------------------------------
  1220. $TEMPLATE->set_message("info", ($LANG['register']['admin_activation']), 0, 0);
  1221. }
  1222.  
  1223.  
  1224.  
  1225. //------------------------------------------------
  1226. // Redirect to the registration page
  1227. //------------------------------------------------
  1228. redirect(VIR_PATH . ($PREFS->conf['fancy_urls'] ? "account/login/" : "index.php?m=account_login"));
  1229.  
  1230.  
  1231. return 1;
  1232.  
  1233. }
  1234. // End Function
  1235.  
  1236.  
  1237. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement