Advertisement
Guest User

Untitled

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