За последние 24 часа нас посетили 34600 программистов и 1695 роботов. Сейчас ищут 673 программиста ...

dle register.php

Тема в разделе "Прочие вопросы по PHP", создана пользователем Almere, 25 апр 2012.

  1. Almere

    Almere Активный пользователь

    С нами с:
    8 фев 2011
    Сообщения:
    53
    Симпатии:
    0
    Здраствуйте.

    Возникла необходимость, несколько изменить скрипт регистрации юзеров в дле 9.5.

    Необходимо, что бы мыла юзера резалось и в итоге я получал домен(пример: user@example.com , мне нужно получить след: example.com и example).

    Делаю это так:


    Код (Text):
    1. $extension1 = explode("@", $email);
    2. $gemeente1 = explode(".", $extension1[1]);
    3.  
    4. $extension = stripslashes(trim($extension1));
    5. $gemeente = stripslashes(trim($gemeente1));
    После этого необходимо занести эти значения в таблицу к юзеру, который регистрируется. Делаю так:


    Код (Text):
    1. $db->query( "INSERT INTO " . USERPREFIX . "_users (name, password, email, reg_date, lastdate, user_group, info, signature, favorites, xfields, logged_ip, gemeente, extension) VALUES ('$name', '$regpassword', '$email', '$add_time', '$add_time', '" . $config['reg_group'] . "', '', '', '', '', '" . $_IP . "', '$gemeente', '$extension')" );
    - тут понеслась... не добавляет данные, где косяк?!!

    далле необходимо обновить таблицу , мол зарегистрировался ещё один юзер из этого сообщества, делаю так:






    Код (Text):
    1. $row22 = $db->super_query( "SELECT amount_people FROM " . USERPREFIX . "_gemeenten WHERE name = '{$gemeente}'" );
    2. $amount = $row22['amount_people'];
    3. $amount_new1 = $amount++;
    4. $amount_new = stripslashes(trim($amount_new1));
    5. $db->free();
    6. //insert a new value of people in gemeente
    7. $db->query( "UPDATE " . USERPREFIX . "_gemeenten SET amount_people='$amount_new' WHERE name='{$gemeentee}'" );
    8. $db->free();
    и это тоже не обрабатывается...

    Где баян, в чём проблема?

    подскажите, пожалуйста. Заранее спасибо.

    Полный код(519 строка, примерно):

    Код (Text):
    1. <?php
    2. /*
    3. =====================================================
    4. DataLife Engine - by SoftNews Media Group
    5. -----------------------------------------------------
    6. http://dle-news.ru/
    7. -----------------------------------------------------
    8. Copyright (c) 2004,2012 SoftNews Media Group
    9. =====================================================
    10. Данный код защищен авторскими правами
    11. =====================================================
    12. Файл: register.php
    13. -----------------------------------------------------
    14. Назначение: регистрация посетителя
    15. =====================================================
    16. */
    17.  
    18. if( ! defined( 'DATALIFEENGINE' ) ) {
    19. die( "Hacking attempt!" );
    20. }
    21.  
    22. require_once ENGINE_DIR . '/classes/parse.class.php';
    23.  
    24. $parse = new ParseFilter( );
    25. $parse->safe_mode = true;
    26. $parse->allow_url = false;
    27. $parse->allow_image = false;
    28. $stopregistration = FALSE;
    29.  
    30. if( isset( $_REQUEST['doaction'] ) ) $doaction = $_REQUEST['doaction']; else $doaction = "";
    31. $config['reg_group'] = intval( $config['reg_group'] ) ? intval( $config['reg_group'] ) : 4;
    32.  
    33. function check_reg($name, $email, $password1, $password2, $sec_code = 1, $sec_code_session = 1) {
    34. global $lang, $db, $banned_info, $relates_word;
    35. $stop = "";
    36.  
    37. if( $sec_code != $sec_code_session OR !$sec_code_session ) $stop .= $lang['reg_err_19'];
    38. if( $password1 != $password2 ) $stop .= $lang['reg_err_1'];
    39. if( strlen( $password1 ) < 6 ) $stop .= $lang['reg_err_2'];
    40. if( strlen( $name ) > 20 ) $stop .= $lang['reg_err_3'];
    41. if( preg_match( "/[\||\'|\<|\>|\[|\]|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\{\+]/", $name ) ) $stop .= $lang['reg_err_4'];
    42. if( empty( $email ) OR strlen( $email ) > 50 OR @count(explode("@", $email)) != 2) $stop .= $lang['reg_err_6'];
    43. if( $name == "" ) $stop .= $lang['reg_err_7'];
    44. if (strpos( strtolower ($name) , '.php' ) !== false) $stop .= $lang['reg_err_4'];
    45.  
    46.  
    47. if( count( $banned_info['name'] ) ) foreach ( $banned_info['name'] as $banned ) {
    48.  
    49. $banned['name'] = str_replace( '\*', '.*', preg_quote( $banned['name'], "#" ) );
    50.  
    51. if( $banned['name'] and preg_match( "#^{$banned['name']}$#i", $name ) ) {
    52.  
    53. if( $banned['descr'] ) {
    54. $lang['reg_err_21'] = str_replace( "{descr}", $lang['reg_err_22'], $lang['reg_err_21'] );
    55. $lang['reg_err_21'] = str_replace( "{descr}", $banned['descr'], $lang['reg_err_21'] );
    56. } else
    57. $lang['reg_err_21'] = str_replace( "{descr}", "", $lang['reg_err_21'] );
    58.  
    59. $stop .= $lang['reg_err_21'];
    60. }
    61. }
    62.  
    63. if( count( $banned_info['email'] ) ) foreach ( $banned_info['email'] as $banned ) {
    64.  
    65. $banned['email'] = str_replace( '\*', '.*', preg_quote( $banned['email'], "#" ) );
    66.  
    67. if( $banned['email'] and preg_match( "#^{$banned['email']}$#i", $email ) ) {
    68.  
    69. if( $banned['descr'] ) {
    70. $lang['reg_err_23'] = str_replace( "{descr}", $lang['reg_err_22'], $lang['reg_err_23'] );
    71. $lang['reg_err_23'] = str_replace( "{descr}", $banned['descr'], $lang['reg_err_23'] );
    72. } else
    73. $lang['reg_err_23'] = str_replace( "{descr}", "", $lang['reg_err_23'] );
    74.  
    75. $stop .= $lang['reg_err_23'];
    76. }
    77. }
    78.  
    79. if( $stop == "" ) {
    80. $name = strtolower( $name );
    81. $search_name = strtr( $name, $relates_word );
    82.  
    83. $row = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE email = '$email' OR LOWER(name) REGEXP '[[:<:]]{$search_name}[[:>:]]' OR name = '$name'" );
    84.  
    85. if( $row['count'] ) $stop .= $lang['reg_err_8'];
    86. }
    87.  
    88. return $stop;
    89.  
    90. }
    91.  
    92. if( $config['allow_registration'] != "yes" ) {
    93.  
    94. msgbox( $lang['all_info'], $lang['reg_err_9'] );
    95. $stopregistration = TRUE;
    96.  
    97. } elseif( $config['max_users'] > 0 ) {
    98.  
    99. $row = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users" );
    100.  
    101. if ( $row['count'] >= $config['max_users'] ) {
    102. msgbox( $lang['all_info'], $lang['reg_err_10'] );
    103. $stopregistration = TRUE;
    104. }
    105.  
    106. }
    107.  
    108. if( isset( $_POST['submit_reg'] ) ) {
    109.  
    110. if( $config['allow_sec_code'] == "yes" ) {
    111.  
    112. if ($config['allow_recaptcha']) {
    113.  
    114. require_once ENGINE_DIR . '/classes/recaptcha.php';
    115. $sec_code = 1;
    116. $sec_code_session = false;
    117.  
    118. if ($_POST['recaptcha_response_field'] AND $_POST['recaptcha_challenge_field']) {
    119.  
    120. $resp = recaptcha_check_answer ($config['recaptcha_private_key'],
    121.                                                                         $_SERVER["REMOTE_ADDR"],
    122.                                                                         $_POST['recaptcha_challenge_field'],
    123.                                                                         $_POST['recaptcha_response_field']);
    124.  
    125.            if ($resp->is_valid) {
    126.  
    127. $sec_code = 1;
    128. $sec_code_session = 1;
    129.  
    130.            }
    131. }
    132.  
    133. } else {
    134. $sec_code = $_POST['sec_code'];
    135. $sec_code_session = ($_SESSION['sec_code_session'] != '') ? $_SESSION['sec_code_session'] : false;
    136. }
    137.  
    138. } else {
    139. $sec_code = 1;
    140. $sec_code_session = 1;
    141. }
    142.  
    143. $password1 = $_POST['password1'];
    144. $password2 = $_POST['password2'];
    145. $name = $db->safesql( $parse->process( htmlspecialchars( trim( $_POST['name'] ) ) ) );
    146. $name = preg_replace('#\s+#i', ' ', $name);
    147.  
    148. $not_allow_symbol = array ("\x22", "\x60", "    ", '\n', '\r', "\n", "\r", '\\', ",", "/", "¬", "#", ";", ":", "~", "[", "]", "{", "}", ")", "(", "*", "^", "%", "$", "<", ">", "?", "!", '"', "'", " " );
    149. $email = $db->safesql(trim( str_replace( $not_allow_symbol, '', strip_tags( stripslashes( $_POST['email'] ) ) ) ) );
    150.  
    151. $reg_error = check_reg( $name, $email, $password1, $password2, $sec_code, $sec_code_session );
    152.  
    153. if( $config['reg_question'] ) {
    154.  
    155. if ( intval($_SESSION['question']) ) {
    156.  
    157. $answer = $db->super_query("SELECT id, answer FROM " . PREFIX . "_question WHERE id='".intval($_SESSION['question'])."'");
    158.  
    159. $answers = explode( "\n", $answer['answer'] );
    160.  
    161. $pass_answer = false;
    162.  
    163. if( function_exists('mb_strtolower') ) {
    164. $question_answer = trim(mb_strtolower($_POST['question_answer'], $config['charset']));
    165. } else {
    166. $question_answer = trim(strtolower($_POST['question_answer']));
    167. }
    168.  
    169. if( count($answers) AND $question_answer ) {
    170. foreach( $answers as $answer ){
    171.  
    172. if( function_exists('mb_strtolower') ) {
    173. $answer = trim(mb_strtolower($answer, $config['charset']));
    174. } else {
    175. $answer = trim(strtolower($answer));
    176. }
    177.  
    178. if( $answer AND $answer == $question_answer ) {
    179. $pass_answer = true;
    180. break;
    181. }
    182. }
    183. }
    184.  
    185. if( !$pass_answer ) $reg_error .= $lang['reg_err_24'];
    186.  
    187. } else $reg_error .= $lang['reg_err_24'];
    188.  
    189. }
    190.  
    191. if( ! $reg_error ) {
    192.  
    193. if( $config['registration_type'] ) {
    194.  
    195. include_once ENGINE_DIR . '/classes/mail.class.php';
    196. $mail = new dle_mail( $config );
    197.  
    198. $row = $db->super_query( "SELECT template FROM " . PREFIX . "_email where name='reg_mail' LIMIT 0,1" );
    199.  
    200. $row['template'] = stripslashes( $row['template'] );
    201.  
    202. $idlink = rawurlencode( base64_encode( $name . "||" . $email . "||" . md5( $password1 ) . "||" . md5( sha1( $name . $email . DBHOST . DBNAME . $config['key'] ) ) ) );
    203.  
    204. $row['template'] = str_replace( "{%username%}", $name, $row['template'] );
    205. $row['template'] = str_replace( "{%validationlink%}", $config['http_home_url'] . "index.php?do=register&doaction=validating&id=" . $idlink, $row['template'] );
    206. $row['template'] = str_replace( "{%password%}", $password1, $row['template'] );
    207.  
    208. $mail->send( $email, $lang['reg_subj'], $row['template'] );
    209.  
    210. if( $mail->send_error ) msgbox( $lang['all_info'], $mail->smtp_msg );
    211. else msgbox( $lang['reg_vhead'], $lang['reg_vtext'] );
    212.  
    213. $_SESSION['sec_code_session'] = false;
    214. $_SESSION['question'] = false;
    215.  
    216. $stopregistration = TRUE;
    217.  
    218. } else {
    219.  
    220. $doaction = "validating";
    221. $_REQUEST['id'] = rawurlencode( base64_encode( $name . "||" . $email . "||" . md5( $password1 ) . "||" . md5( sha1( $name . $email . DBHOST . DBNAME . $config['key'] ) ) ) );
    222. }
    223.  
    224. } else {
    225. msgbox( $lang['reg_err_11'], "<ul>" . $reg_error . "</ul>" );
    226. }
    227.  
    228. }
    229.  
    230. if( $doaction != "validating" AND !$stopregistration ) {
    231.  
    232. if( $_POST['dle_rules_accept'] == "yes" ) {
    233.  
    234. $_SESSION['dle_rules_accept'] = "1";
    235.  
    236. }
    237.  
    238. if( $config['registration_rules'] and ! $_SESSION['dle_rules_accept'] ) {
    239.  
    240. $_GET['page'] = "dle-rules-page";
    241. include ENGINE_DIR . '/modules/static.php';
    242.  
    243. } else {
    244.  
    245. $tpl->load_template( 'registration.tpl' );
    246.  
    247. $tpl->set( '[registration]', "" );
    248. $tpl->set( '[/registration]', "" );
    249. $tpl->set_block( "'\\[validation\\](.*?)\\[/validation\\]'si", "" );
    250. $path = parse_url( $config['http_home_url'] );
    251.  
    252. if( $config['reg_question'] ) {
    253.  
    254. $tpl->set( '[question]', "" );
    255. $tpl->set( '[/question]', "" );
    256.  
    257. $question = $db->super_query("SELECT id, question FROM " . PREFIX . "_question ORDER BY RAND() LIMIT 1");
    258. $tpl->set( '{question}', htmlspecialchars( stripslashes( $question['question'] ), ENT_QUOTES ) );
    259.  
    260. $_SESSION['question'] = $question['id'];
    261.  
    262. } else {
    263.  
    264. $tpl->set_block( "'\\[question\\](.*?)\\[/question\\]'si", "" );
    265. $tpl->set( '{question}', "" );
    266.  
    267. }
    268.  
    269. if( $config['allow_sec_code'] == "yes" ) {
    270.  
    271. if ( $config['allow_recaptcha'] ) {
    272.  
    273. $tpl->set( '[recaptcha]', "" );
    274. $tpl->set( '[/recaptcha]', "" );
    275.  
    276. $tpl->set( '{recaptcha}', '
    277. <script language="javascript" type="text/javascript">
    278. <!--
    279. var RecaptchaOptions = {
    280.                 theme: \''.$config['recaptcha_theme'].'\',
    281.                 lang: \''.$lang['wysiwyg_language'].'\'
    282. };
    283.  
    284. //-->
    285. </script>
    286. <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k='.$config['recaptcha_public_key'].'"></script>' );
    287.  
    288. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
    289. $tpl->set( '{reg_code}', "" );
    290.  
    291. } else {
    292.  
    293. $tpl->set( '[sec_code]', "" );
    294. $tpl->set( '[/sec_code]', "" );
    295. $tpl->set( '{reg_code}', "<span id=\"dle-captcha\"><img src=\"" . $path['path'] . "engine/modules/antibot.php\" alt=\"{$lang['sec_image']}\" border=\"0\" /><br /><a onclick=\"reload(); return false;\" href=\"#\">{$lang['reload_code']}</a></span>" );
    296. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
    297. $tpl->set( '{recaptcha}', "" );
    298. }
    299.  
    300. } else {
    301.  
    302. $tpl->set( '{reg_code}', "" );
    303. $tpl->set( '{recaptcha}', "" );
    304. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
    305. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
    306. }
    307.  
    308. $tpl->copy_template = "<form  method=\"post\" name=\"registration\" onsubmit=\"if (!check_reg_daten()) {return false;};\" id=\"registration\" action=\"\">\n" . $tpl->copy_template . "
    309. <input name=\"submit_reg\" type=\"hidden\" id=\"submit_reg\" value=\"submit_reg\" />
    310. <input name=\"do\" type=\"hidden\" id=\"do\" value=\"register\" />
    311. </form>";
    312.  
    313. $tpl->copy_template .= <<<HTML
    314. <script language='javascript' type="text/javascript">
    315. <!--
    316. function reload () {
    317.  
    318. var rndval = new Date().getTime();
    319.  
    320. document.getElementById('dle-captcha').innerHTML = '<img src="{$path['path']}engine/modules/antibot.php?rndval=' + rndval + '" border="0" width="120" height="50" alt="" /><br /><a onclick="reload(); return false;" href="#">{$lang['reload_code']}</a>';
    321.  
    322. };
    323. function check_reg_daten () {
    324.  
    325. if(document.forms.registration.name.value == '') {
    326.  
    327. DLEalert('{$lang['reg_err_30']}', dle_info);return false;
    328.  
    329. }
    330.  
    331. if(document.forms.registration.password1.value.length < 6) {
    332.  
    333. DLEalert('{$lang['reg_err_31']}', dle_info);return false;
    334.  
    335. }
    336.  
    337. if(document.forms.registration.password1.value != document.forms.registration.password2.value) {
    338.  
    339. DLEalert('{$lang['reg_err_32']}', dle_info);return false;
    340.  
    341. }
    342.  
    343. if(document.forms.registration.email.value == '') {
    344.  
    345. DLEalert('{$lang['reg_err_33']}', dle_info);return false;
    346.  
    347. }
    348.  
    349. return true;
    350.  
    351. };
    352. //-->
    353. </script>
    354. HTML;
    355. $tpl->compile( 'content' );
    356. $tpl->clear();
    357.  
    358. }
    359.  
    360. }
    361.  
    362. if( isset( $_POST['submit_val'] ) ) {
    363.  
    364. $fullname = $db->safesql( $parse->process( $_POST['fullname'] ) );
    365. $land = $db->safesql( $parse->process( $_POST['land'] ) );
    366. $icq = intval( str_replace("-", "", $_POST['icq'] ) );
    367. if( $icq < 1 ) $icq = "";
    368. $info = $db->safesql( $parse->BB_Parse( $parse->process( $_POST['info'] ), false ) );
    369.  
    370. $image = $_FILES['image']['tmp_name'];
    371. $image_name = $_FILES['image']['name'];
    372. $image_size = $_FILES['image']['size'];
    373. $image_name = str_replace( " ", "_", $image_name );
    374. $img_name_arr = explode( ".", $image_name );
    375. $type = totranslit( end( $img_name_arr ) );
    376.  
    377. if( stripos ( $image_name, "php" ) !== false ) die("Hacking attempt!");
    378.  
    379. $user_arr = explode( "||", base64_decode( @rawurldecode( $_POST['id'] ) ) );
    380.  
    381. if( $user_arr[0] == "" OR  $user_arr[2]== "" ) die("Hacking attempt!");
    382.  
    383. $user = $db->safesql( trim( $user_arr[0] ) );
    384. $email = $db->safesql( trim( $user_arr[1] ) );
    385. $pass = md5( $user_arr[2] );
    386.  
    387. if( md5( sha1( $user . $email . DBHOST . DBNAME . $config['key'] ) ) != $user_arr[3] ) die( 'ID not valid!' );
    388.  
    389. if( preg_match( "/[\||\'|\<|\>|\[|\]|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\{\+]/", $user ) ) die( 'USER not valid!' );
    390.  
    391. $row = $db->super_query( "SELECT * FROM " . USERPREFIX . "_users WHERE name = '$user' AND password='$pass'" );
    392.  
    393. if( !$row['user_id'] ) die("Access Denied!");
    394.  
    395. $db->free();
    396.  
    397. if( is_uploaded_file( $image ) and ! $stop ) {
    398.  
    399. if( intval( $user_group[$member_id['user_group']]['max_foto'] ) > 0 ) {
    400.  
    401. if( $image_size < 100000 ) {
    402.  
    403. $allowed_extensions = array ("jpg", "png", "jpe", "jpeg", "gif" );
    404.  
    405. if( in_array( $type, $allowed_extensions ) AND $image_name ) {
    406.  
    407. include_once ENGINE_DIR . '/classes/thumb.class.php';
    408.  
    409. $res = @move_uploaded_file( $image, ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type );
    410.  
    411. if( $res ) {
    412.  
    413. @chmod( ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type, 0666 );
    414. $thumb = new thumbnail( ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type );
    415. $thumb->size_auto( $user_group[$config['reg_group']]['max_foto'] );
    416. $thumb->jpeg_quality( $config['jpeg_quality'] );
    417. $thumb->save( ROOT_DIR . "/uploads/fotos/foto_" . $row['user_id'] . "." . $type );
    418.  
    419. @unlink( ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . "." . $type );
    420. $foto_name = "foto_" . $row['user_id'] . "." . $type;
    421.  
    422. $db->query( "UPDATE " . USERPREFIX . "_users SET foto='$foto_name' WHERE user_id='{$row['user_id']}'" );
    423.  
    424. } else
    425. $stop = $lang['reg_err_12'];
    426. } else
    427. $stop = $lang['reg_err_13'];
    428. } else
    429. $stop = $lang['news_err_16'];
    430. } else
    431. $stop .= $lang['news_err_32'];
    432.  
    433. }
    434.  
    435. if( intval( $user_group[$member_id['user_group']]['max_info'] ) > 0 and dle_strlen( $info, $config['charset'] ) > $user_group[$member_id['user_group']]['max_info'] ) $stop .= $lang['reg_err_14'];
    436. if( dle_strlen( $fullname, $config['charset'] ) > 100 ) $stop .= $lang['reg_err_15'];
    437. if( dle_strlen( $land, $config['charset'] ) > 100 ) $stop .= $lang['reg_err_16'];
    438. if( strlen( $icq ) > 20 ) $stop .= $lang['reg_err_17'];
    439. if( $parse->not_allowed_tags ) $stop .= $lang['news_err_34'];
    440.  
    441. if ( preg_match( "/[\||\'|\<|\>|\"|\!|\]|\?|\$|\@|\/|\\\|\&\~\*\+]/", $fullname ) ) {
    442.  
    443. $stop .= $lang['news_err_35'];
    444. }
    445.  
    446. if ( preg_match( "/[\||\'|\<|\>|\"|\!|\]|\?|\$|\@|\/|\\\|\&\~\*\+]/", $land ) ) {
    447.  
    448. $stop .= $lang['news_err_36'];
    449. }
    450.  
    451. if( $stop ) {
    452. msgbox( $lang['reg_err_18'], $stop );
    453. } else {
    454.  
    455. $xfieldsaction = "init";
    456. $xfieldsadd = true;
    457. $xfieldsid = "";
    458. include (ENGINE_DIR . '/inc/userfields.php');
    459. $filecontents = array ();
    460.  
    461. if( ! empty( $postedxfields ) ) {
    462. foreach ( $postedxfields as $xfielddataname => $xfielddatavalue ) {
    463. if( ! $xfielddatavalue ) {
    464. continue;
    465. }
    466.  
    467. $xfielddatavalue = $db->safesql( $parse->BB_Parse( $parse->process( $xfielddatavalue ), false ) );
    468.  
    469. $xfielddataname = $db->safesql( $xfielddataname );
    470.  
    471. $xfielddataname = str_replace( "|", "&#124;", $xfielddataname );
    472. $xfielddatavalue = str_replace( "|", "&#124;", $xfielddatavalue );
    473. $filecontents[] = "$xfielddataname|$xfielddatavalue";
    474. }
    475.  
    476. $filecontents = implode( "||", $filecontents );
    477. } else
    478. $filecontents = '';
    479.  
    480. $db->query( "UPDATE " . USERPREFIX . "_users SET fullname='$fullname', info='$info', land='$land', icq='$icq', xfields='$filecontents' WHERE user_id='{$row['user_id']}'" );
    481.  
    482. msgbox( $lang['reg_ok'], $lang['reg_ok_1'] );
    483.  
    484. $stopregistration = TRUE;
    485. }
    486. }
    487.  
    488. if( $doaction == "validating" AND !$stopregistration AND !$_POST['submit_val'] ) {
    489.  
    490. $user_arr = explode( "||", base64_decode( @rawurldecode( $_REQUEST['id'] ) ) );
    491.  
    492. $regpassword = md5( $user_arr[2] );
    493. $name = trim( $db->safesql( htmlspecialchars( $parse->process( $user_arr[0] ) ) ) );
    494.  
    495. $not_allow_symbol = array ("\x22", "\x60", "    ", '\n', '\r', "\n", "\r", '\\', ",", "/", "¬", "#", ";", ":", "~", "[", "]", "{", "}", ")", "(", "*", "^", "%", "$", "<", ">", "?", "!", '"', "'", " " );
    496. $email = $db->safesql(trim( str_replace( $not_allow_symbol, '', strip_tags( stripslashes( $user_arr[1] ) ) ) ) );
    497.  
    498. if( md5( sha1( $name . $email . DBHOST . DBNAME . $config['key'] ) ) != $user_arr[3] ) die( 'ID not valid!' );
    499.  
    500. $name = preg_replace('#\s+#i', ' ', $name);
    501. $reg_error = check_reg( $name, $email, $regpassword, $regpassword );
    502.  
    503. if( $reg_error != "" ) {
    504. msgbox( $lang['reg_err_11'], $reg_error );
    505. $stopregistration = TRUE;
    506. } else {
    507.  
    508. if( ($_REQUEST['step'] != 2) and $config['registration_type'] ) {
    509. $stopregistration = TRUE;
    510. $lang['confirm_ok'] = str_replace( '{email}', $email, $lang['confirm_ok'] );
    511. $lang['confirm_ok'] = str_replace( '{login}', $name, $lang['confirm_ok'] );
    512. msgbox( $lang['all_info'], $lang['confirm_ok'] . "<br /><br /><a href=\"" . $config['http_home_url'] . "index.php?do=register&doaction=validating&step=2&id=" . rawurlencode( $_REQUEST['id'] ) . "\">" . $lang['reg_next'] . "</a>" );
    513. } else {
    514.  
    515. $add_time = time() + ($config['date_adjust'] * 60);
    516. $_IP = $db->safesql( $_SERVER['REMOTE_ADDR'] );
    517. if( intval( $config['reg_group'] ) < 3 ) $config['reg_group'] = 4;
    518.  
    519. $extension1 = explode("@", $email);
    520. $gemeente1 = explode(".", $extension1[1]);
    521.  
    522. $extension = stripslashes(trim($extension1));
    523. $gemeente = stripslashes(trim($gemeente1));
    524.  
    525. //get amount_people
    526. $row22 = $db->super_query( "SELECT amount_people FROM " . USERPREFIX . "_gemeenten WHERE name = '{$gemeente}'" );
    527. $amount = $row22['amount_people'];
    528. $amount_new1 = $amount++;
    529. $amount_new = stripslashes(trim($amount_new1));
    530. $db->free();
    531. //insert a new value of people in gemeente
    532. $db->query( "UPDATE " . USERPREFIX . "_gemeenten SET amount_people='$amount_new' WHERE name='{$gemeentee}'" );
    533. $db->free();
    534.  
    535. $db->query( "INSERT INTO " . USERPREFIX . "_users (name, password, email, reg_date, lastdate, user_group, info, signature, favorites, xfields, logged_ip, gemeente, extension) VALUES ('$name', '$regpassword', '$email', '$add_time', '$add_time', '" . $config['reg_group'] . "', '', '', '', '', '" . $_IP . "', '$gemeente', '$extension')" );
    536. $id = $db->insert_id();
    537.  
    538. set_cookie( "dle_user_id", $id, 365 );
    539. set_cookie( "dle_password", $user_arr[2], 365 );
    540.  
    541. $_SESSION['dle_user_id'] = $id;
    542. $_SESSION['dle_password'] = $user_arr[2];
    543.  
    544. }
    545.  
    546. }
    547.  
    548. }
    549.  
    550. if( $doaction == "validating" and ! $stopregistration ) {
    551.  
    552. $tpl->load_template( 'registration.tpl' );
    553.  
    554. $tpl->set( '[validation]', "" );
    555. $tpl->set( '[/validation]', "" );
    556. $tpl->set_block( "'\\[registration\\].*?\\[/registration\\]'si", "" );
    557.  
    558. $xfieldsaction = "list";
    559. $xfieldsadd = true;
    560. include (ENGINE_DIR . '/inc/userfields.php');
    561. $tpl->set( '{xfields}', $output );
    562.  
    563. $_REQUEST['id'] = htmlspecialchars( $_REQUEST['id'], ENT_QUOTES );
    564.  
    565. $tpl->copy_template = "<form  method=\"post\" name=\"registration\" enctype=\"multipart/form-data\" action=\"\">\n" . $tpl->copy_template . "
    566. <input name=\"submit_val\" type=\"hidden\" id=\"submit_val\" value=\"submit_val\" />
    567. <input name=\"do\" type=\"hidden\" id=\"do\" value=\"register\" />
    568. <input name=\"doaction\" type=\"hidden\" id=\"doaction\" value=\"validating\" />
    569. <input name=\"id\" type=\"hidden\" id=\"id\" value=\"{$_REQUEST['id']}\" />
    570. </form>";
    571.  
    572. $tpl->compile( 'content' );
    573. $tpl->clear();
    574. }
    575.  
    576. ?>
     
  2. sobachnik

    sobachnik Старожил

    С нами с:
    20 апр 2007
    Сообщения:
    3.380
    Симпатии:
    13
    Адрес:
    Дмитров, МО
    Функция trim (как и stripslashes) работают со строками, а ты им массивы строк подсовываешь.
     
  3. Almere

    Almere Активный пользователь

    С нами с:
    8 фев 2011
    Сообщения:
    53
    Симпатии:
    0
    Спасибо, спасло.

    А как поступить со второй проблемой?

    Код (Text):
    1.  
    2. $row22 = $db->super_query( "SELECT amount_people FROM " . USERPREFIX . "_gemeenten WHERE name = '{$gemeente}'" );
    3. $amount = $row22['amount_people'];
    4. $amount_new1 = $amount++;
    5. $amount_new = stripslashes(trim($amount_new1));
    6. $db->free();
    7. //insert a new value of people in gemeente
    8. $db->query( "UPDATE " . USERPREFIX . "_gemeenten SET amount_people='$amount_new' WHERE name='{$gemeentee}'" );
    9. $db->free();
    Добавлено спустя 31 минуту 12 секунд:
    проблема решена. Спасибо.