Перейти к публикации

Незнакомец

местные
  • Публикации

    23
  • Зарегистрирован

  • Посещение

Сообщения, опубликованные пользователем Незнакомец

  1. Что в Вашем понимании слово "дизайн" ? Я, конечно, понимаю, что критика это хорошо, но надо давать обоснованную критику… А для меня все ваши слова ни что, без обоснования.

    Слова типа "дизайн у тебя отсутствует" – это не обоснования!

  2. Скачиваем файлы http://rapidshare.de/files/7269406/bot.zip.html

    Файлы register.php и antibot.php копируем в /engine/modules/

    Файл website.lng копируем в /language/Russian/

    Файл registration.tpl копируем в /templates/Default/

    Теперь работает?

  3. Защита от ботов!

    В engine/modules/ создаём файл antibot.php в нём пишем:


    <?php
    /*
    =====================================================
    Plugin for DataLife Engine - by SoftNews Media Group
    -----------------------------------------------------
    author: Незнакомец, 2005 email: neznacomec@gmail.com
    =====================================================
    Файл: antibot.php
    -----------------------------------------------------
    Назначение: Генерация изображения со случайным кодом
    =====================================================
    */

    class genrandomimage
    {
    var $lenght = 6; // Длина строки
    var $string = ''; // Результирующая строка

    # Генерация строки
    function genstring()
    {
    $chars = array ('1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
    $result_string = '';

    for($i = 0; $i < $this -> lenght; $i++)
    {
    $random_char = mt_rand( 0, ( count ( $chars ) - 1 ) );
    $result_string .= $chars[$random_char];
    }
    $this -> string = $result_string;
    }

    # Генерация изображения
    function genimage()
    {
    $im = imagecreate( 10 * $this -> lenght + 5, 20 );

    $gray = imagecolorallocate( $im, 228, 228, 228 );
    $black_1 = imagecolorallocate( $im, 150, 150, 150 );
    $black = imagecolorallocate( $im, 0, 0, 0 );
    $white = imagecolorallocate( $im , 255, 255, 255 );
    $string = imagecolorallocate( $im, 90, 90, 90 );

    /* Генерация шума */
    for($i = -2; $i < ceil ( ( 10 * $this -> lenght ) / 5 ); $i++)
    {
    imageline( $im, $i * 5, 20, $i * 5 + 20, 0, $black_1 );
    }
    for($i = -2; $i < ceil ( (10 * $this -> lenght) / 5 ); $i++)
    {
    imageline( $im, $i * 5+20, 20, $i * 5 , 0, $white );
    }
    /* Конец генерации шума */

    # Рисуем строку на картинке
    imagestring( $im, 5, 6, 2, $this -> string, $string );

    # Рамка
    imageline( $im, 0, 0, 10*$this -> lenght + 5, 0, $black );
    imageline( $im, 0, 19, 10*$this -> lenght + 5, 19, $black );
    imageline( $im, 0, 0, 0, 20, $black );
    imageline( $im, 10*$this -> lenght + 4, 0, 10*$this -> lenght + 4, 20, $black );

    header('Content-type: image/png');
    imagepng($im);
    }

    }


    session_start();
    session_name('regcode');

    $im = new genrandomimage ();
    $im -> genstring();

    $_SESSION['reg_session'] = $im -> string;

    $im -> genimage();

    ?>
    [/codebox]

    Открываем файл engine/modules/register.php , все удаляем, вставляем вот это:

    [codebox]
    <?php
    /*
    =====================================================
    DataLife Engine - by SoftNews Media Group
    -----------------------------------------------------
    [url="http://www.pc-soft.ru/"]http://www.pc-soft.ru/[/url]
    -----------------------------------------------------
    Copyright © 2004,2005 SoftNews Media Group
    =====================================================
    Данный код защищен авторскими правами
    =====================================================
    Файл: register.php
    -----------------------------------------------------
    Назначение: регистрация посетителя
    =====================================================
    */
    if(!defined('DATALIFEENGINE'))
    {
    die("Hacking attempt!");
    }


    if (isset ($_REQUEST['doaction'])) $doaction = $_REQUEST['doaction']; else $doaction = "";

    function check_reg ($name, $email, $password1, $password2, $reg_forms, $reg_sessions) {
    global $lang, $db;
    $stop = "";

    if ($password1!=$password2)
    {

    $stop .= $lang['reg_err_1'];
    }

    if ((strlen($password1)<6 || strlen($password1) >20)and(strlen($password2)<6 || strlen($password2) >20))
    {

    $stop .= $lang['reg_err_2'];
    }
    if (strlen($name) > 20)
    {

    $stop .= $lang['reg_err_3'];
    }
    if (preg_match("/[\||\'|\"|\!]/",$name))
    {

    $stop .= $lang['reg_err_4'];
    }

    if (preg_match("/[^(\w)|(\x7F-\xFF)|(\s)]/",$password1))
    {

    $stop .= $lang['reg_err_5'];
    }

    if ((!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email))or(empty($email)))
    {

    $stop .= $lang['reg_err_6'];
    }

    if ( $reg_forms != $reg_sessions )
    {

    $stop .= $lang['reg_err_19'];
    }

    if (empty($name))
    {

    $stop .= $lang['reg_err_7'];
    }


    if (!$stop)
    {
    $dupe_email = $db->query ("SELECT * FROM " . PREFIX . "_users where email = '$email' OR name ='$name'");

    if ($db->num_rows($dupe_email)>0)
    {
    $stop .= $lang['reg_err_8'];
    }
    }
    return $stop;
    }


    $stopregistration = FALSE;

    $row = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_users");

    if ($config_allow_registration != "yes")
    {

    msgbox ($lang['all_info'], $lang['reg_err_9']);
    $stopregistration = TRUE;

    } elseif ($config_max_users > 0 AND $row['count'] > $config_max_users)
    {

    msgbox ($lang['all_info'], $lang['reg_err_10']);
    $stopregistration = TRUE;

    }


    if (isset($_POST['submit_reg']))
    {
    session_start();
    session_name('regcode');

    $password1 = mysql_escape_string($_POST['password1']);
    $password2 = mysql_escape_string($_POST['password2']);
    $name = trim(mysql_escape_string($_POST['name']));
    $email = trim(mysql_escape_string($_POST['email']));

    $reg_forms = trim($_POST['reg_form']);
    $reg_sessions = trim($_SESSION['reg_session']);

    $reg_error = check_reg ($name, $email, $password1, $password2, $reg_forms, $reg_sessions);

    if (!$reg_error) {

    if ($config_registration_type) {

    $row = $db->super_query("SELECT template FROM " . PREFIX . "_email where name='reg_mail' LIMIT 0,1");

    $row['template'] = stripslashes($row['template']);

    $idlink = urlencode(base64_encode ($name."||".$email."||".$password1));

    $vallink = $config_http_home_url."index.php?do=register&doaction=validating&id=".$idlink;

    $row['template'] = str_replace("{%username%}",$name, $row['template']);
    $row['template'] = str_replace("{%validationlink%}",$vallink, $row['template']);

    $var['subj'] = $lang['reg_subj'];
    $var['header'] = "From: ".$config_admin_mail."\r\n";
    $var['header'] .= "MIME-Version: 1.0\r\n";
    $var['header'] .= "Content-Transfer-Encoding: 8bit\r\n";
    $var['header'] .= "Content-Type: text/plain; charset=\"Windows-1251\"\r\n";
    $var['header'] .= "X-Mailer: PHP v.".phpversion();

    @mail($name." <".$email.">",$var['subj'],$row['template'],$var['header']);

    msgbox ($lang['reg_vhead'], $lang['reg_vtext']);
    $stopregistration = TRUE;

    } else {

    $idlink = urlencode(base64_encode ($name."||".$email."||".$password1));
    $vallink = $config_http_home_url."index.php?do=register&doaction=validating&id=".$idlink;
    $doaction = "validating";
    $_GET['id'] = $idlink;
    }

    } else msgbox ($lang['reg_err_11'], $reg_error);



    }



    if ($doaction != "validating" AND !$stopregistration) {

    $tpl->load_template('registration.tpl');

    $tpl->set('{reg_code}',"<img src=\"${config_http_script_dir}modules\antibot.php\" border=\"0\">");

    $tpl->set('[registration]',"");
    $tpl->set('[/registration]',"");
    $tpl->set_block("'\\[validation\\].*?\\[/validation\\]'si","");

    $tpl->copy_template = "<form method=\"post\" name=\"registration\" id=\"registration\" action=\"\">\n".$tpl->copy_template."
    <input name=\"submit_reg\" type=\"hidden\" id=\"submit_reg\" value=\"submit_reg\">
    </form>";
    $tpl->compile('content');
    $tpl->clear();
    }

    if (isset($_POST['submit_val']))
    {

    $fullname = mysql_escape_string($_POST['fullname']);
    $land = mysql_escape_string($_POST['land']);
    $icq = mysql_escape_string($_POST['icq']);
    $info = replace_comment("add", $_POST['info']);

    $image = $_FILES['image']['tmp_name'];
    $image_name = $_FILES['image']['name'];
    $image_size = $_FILES['image']['size'];
    $image_name = str_replace(" ", "_", $image_name);
    $img_name_arr = explode(".",$image_name);
    $type = end($img_name_arr);

    $user_arr = explode ("||", base64_decode(urldecode($_GET['id'])));
    $user = trim(mysql_escape_string($user_arr[0]));

    $row = $db->super_query("SELECT * FROM " . PREFIX . "_users where name = '$user'");

    if (is_uploaded_file($image)) {

    if ($image_size < 100000) {

    $allowed_extensions = array("jpg", "png", "jpe", "jpeg");

    if ((in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) and $image_name) {

    include_once $dl_path.'/inc/makethumb.php';

    $res = @move_uploaded_file($image, $root_path."/uploads/fotos/".$row['user_id'].".".$type);

    if ($res) {

    $thumb=new thumbnail($root_path."/uploads/fotos/".$row['user_id'].".".$type);
    $thumb->size_auto($config_max_foto);
    $thumb->jpeg_quality($config_jpeg_quality);
    $thumb->save($root_path."/uploads/fotos/foto_".$row['user_id'].".".$type);

    @unlink ($root_path."/uploads/fotos/".$row['user_id'].".".$type);
    $foto_name = "foto_".$row['user_id'].".".$type;

    $db->query("UPDATE " . PREFIX . "_users set foto='$foto_name' where name='$user'");
    } else $stop = $lang['reg_err_12'];
    } else $stop = $lang['reg_err_13'];
    } else $stop = $lang['news_err_16'];

    }

    if (strlen($info) > 500)
    {

    $stop .= $lang['reg_err_14'];
    }
    if (strlen($fullname) > 100)
    {

    $stop .= $lang['reg_err_15'];
    }
    if (strlen($land) > 100)
    {

    $stop .= $lang['reg_err_16'];
    }
    if (strlen($icq) > 20)
    {

    $stop .= $lang['reg_err_17'];
    }

    if ($stop){ msgbox ($lang['reg_err_18'], $stop);}

    else {

    $db->query("UPDATE " . PREFIX . "_users set fullname='$fullname', info='$info', land='$land', icq='$icq' where name='$user'");

    msgbox ($lang['reg_ok'], $lang['reg_ok_1']);

    $stopregistration = TRUE;
    }
    }


    if ($doaction == "validating" AND !$stopregistration AND !$_POST['submit_val']) {

    $user_arr = explode ("||", base64_decode(urldecode($_GET['id'])));

    $password1 = mysql_escape_string($user_arr[2]);
    $name = trim(mysql_escape_string($user_arr[0]));
    $email = trim(mysql_escape_string($user_arr[1]));

    $reg_error = check_reg ($name, $email, $password1, $password1);
    if (!$reg_error) {

    $add_time = time()+($config_date_adjust*60);

    $regpassword = md5($password1);
    $db->query("INSERT INTO " . PREFIX . "_users (name, password, email, reg_date, lastdate) values ('$name', '$regpassword', '$email', '$add_time', '$add_time')");

    } else {msgbox ($lang['reg_err_11'], $reg_error); $stopregistration = TRUE;}

    }

    if ($doaction == "validating" AND !$stopregistration) {
    $tpl->load_template('registration.tpl');

    $tpl->set('[validation]',"");
    $tpl->set('[/validation]',"");
    $tpl->set_block("'\\[registration\\].*?\\[/registration\\]'si","");

    $tpl->copy_template = "<form method=\"post\" name=\"registration\" enctype=\"multipart/form-data\" action=\"".$vallink."\">\n".$tpl->copy_template."
    <input name=\"submit_val\" type=\"hidden\" id=\"submit_val\" value=\"submit_val\">
    </form>";
    $tpl->compile('content');
    $tpl->clear();
    }
    ?>

    Открываем файл шаблона registration.tpl, все удаляем, вставляем вот это: (эта для шаблона по умолчанию)


    <div style="margin-top:7px;">
    <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="13"><img src="{THEME}/images/m_left.gif" width="13" height="24" border="0"></td>
    <td background="{THEME}/images/m_center.gif" class=newstitle><b>[registration]Регистрация нового пользователя[/registration][validation]Обновление профиля пользователя[/validation]</b></td>
    <td width="9"><img src="{THEME}/images/m_right.gif" width="9" height="24" border="0"></td>
    </tr>
    </table>
    <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="9" background="{THEME}/images/m_left_m.gif"> </td>
    <td class=newsbody bgcolor="#FDFDFD">
    [registration]Добрый день уважаемый посетитель нашего сайта...[/registration]
    [validation]Уважаемый посетитель Ваш аккаунт был зарегистрирован.[/validation]</td>
    <td width="9" background="{THEME}/images/m_right_m.gif"><img src="{THEME}/images/m_right_m.gif" width="9" height="4" border="0"></td>
    </tr>
    <tr>
    <td width="9" background="{THEME}/images/m_left_m.gif"> </td>
    <td class="style2" bgcolor="#FDFDFD">
    <table width="314" border="0" cellspacing="0" cellpadding="0">
    [registration]

    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Логин</td>
    <td height="25" align="left"><input type="text" name="name" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Пароль</td>
    <td height="25" align="left"><input type="password" name="password1" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Повторите пароль</td>
    <td height="25" align="left"><input type="password" name="password2" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Ваш E-Mail</td>
    <td height="25" align="left"><input type="text" name="email" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>

    <tr align="left" valign="middle">
    <td colspan="2" height="25" class="style1"><b>Подтверждение кода безопасности</b></td>
    </tr>

    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Код безопасности</td>
    <td height="25" align="left">{reg_code}</td>
    </tr>
    <tr align="left" valign="middle">
    <td width="140" height="25" class="style1">Введите код безопасности</td>
    <td height="25" align="left"><input type="text" name="reg_form" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>

    [/registration]
    [validation] <tr align="left" valign="middle">
    <td width="120" height="25" align="left" class="style1">Ваше Имя</td>
    <td height="25" align="left"><input type="text" name="fullname" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="120" height="25" align="left" class="style1"><nobr>Место жительства  </nobr></td>
    <td height="25" align="left"><input type="text" name="land" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="120" height="25" align="left" class="style1">Номер ICQ</td>
    <td height="25" align="left"><input type="text" name="icq" style="width:167px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="120" height="25" align="left" class="style1">Фото:</td>
    <td colspan=2 height="25" align="left" class="style1"><input type="file" name="image" style="width:278px; height:20px; font-family:tahoma; font-size:11px; border:1px solid #E0E0E0 "></td>
    </tr>
    <tr align="left" valign="middle">
    <td width="120" height="25" align="left" class="style1">О себе</td>
    <td colspan=2 height="25" align="left"><textarea name=info style="width:320px; height:70px; font-family:verdana; font-size:11px; border:1px solid #E0E0E0 "></textarea></td>
    </tr>
    [/validation]
    <tr align="left" valign="middle">
    <td width="120" height="25" align="right" class="style1"> </td>
    <td height="25" align="right"><div style="padding-top:2px; padding-left:0px;">
    <input name="image" type="image" src="{THEME}/images/send.png">
    </div></td>
    </tr>
    </table>
    </td>
    <td width="9" background="{THEME}/images/m_right_m.gif"><img src="{THEME}/images/m_right_m.gif" width="9" height="4" border="0"></td>
    </tr>

    </table>
    <table cellpadding="0" cellspacing="0" width="100%" height="7">
    <tr>
    <td width="13" background="{THEME}/images/m_left_b.gif"><img src="{THEME}/images/m_left_b.gif" width="13" height="7" border="0"></td>
    <td background="{THEME}/images/m_center_b.gif"><img src="{THEME}/images/spacer.gif" width="1" height="1"></td>
    <td width="13"><img src="{THEME}/images/m_right_b.gif" width="13" height="7" border="0"></td>
    </tr>
    </table></div>
    [/codebox]

×
×
  • Создать...