В чате при регистрации пишет неверный код!в чем проблемма?
ОБСУЖДЕНИЕ
в чём проблемма?
мы же тут ванги:)
RGame, привет поможешь ошибки исправить? пожалуйста, когда регистрирую ник в чате пишет неверный код, помоги пожалуйста.
ну ты код покажи.
RGame, <?php
include './var/ini_set.php';
session_start('sn');
function hex($q) {
$q3 = array (
"a" => "10",
"b" => "11",
"c" => "12",
"d" => "13",
"e" => "14",
"f" => "15",
);
if (!isset($_SESSION['wap'])) exit;
$q1 = substr(strtolower($q), 0, 1);
$q2 = substr(strtolower($q), 1, 1);
$q1 = intval(strtr($q1, $q3));
$q2 = intval(strtr($q2, $q3));
return ($q1*16 + $q2);
}
header('Content-type: image/gif');
$im = imagecreate (110, 45);
$div1 = explode(':', $_SESSION['col']);
if (!empty($_SESSION['wap'])) {
$bg = imagecolorallocate($im, hex(substr
($div1[5], 0, 2)), hex(substr($div1[5], 2,
2)), hex(substr($div1[5], 4, 2)));
$tx = imagecolorallocate($im, hex(substr
($div1[6], 0, 2)), hex(substr($div1[6], 2,
2)), hex(substr($div1[6], 4, 2)));
}
else {
$bg = imagecolorallocate($im, 255, 255,
255);
$tx = imagecolorallocate($im, 0, 0, 0);
}
imagefill ($im, 0, 0, $bg);
$reg = '';
$ic = 0;
while ($ic <= 4) {
$rnd = mt_rand(0,9); $reg = $reg.$rnd;
imagettftext ($im, 25, mt_rand(-30, 30), 5
+ (20*$ic), 25 + mt_rand(0, 15), $tx, "./
f.ttf", $rnd);
$ic++;
}
for($ic = 1; $ic <= 3; $ic++){
if (!empty($_SESSION['wap'])) $r =
imagecolorallocate($im, mt_rand(0, 255),
mt_rand(0, 255), mt_rand(0, 255));
else $r = imagecolorallocate($im, 0, 0, 0);
imageline($im, mt_rand(0, 20), mt_rand(0,
40), mt_rand(80, 100), mt_rand(0, 40), $r);
}
imagegif ($im);
imagedestroy ($im);
$_SESSION['regs'] = md5($reg);
?>
include './var/ini_set.php';
session_start('sn');
function hex($q) {
$q3 = array (
"a" => "10",
"b" => "11",
"c" => "12",
"d" => "13",
"e" => "14",
"f" => "15",
);
if (!isset($_SESSION['wap'])) exit;
$q1 = substr(strtolower($q), 0, 1);
$q2 = substr(strtolower($q), 1, 1);
$q1 = intval(strtr($q1, $q3));
$q2 = intval(strtr($q2, $q3));
return ($q1*16 + $q2);
}
header('Content-type: image/gif');
$im = imagecreate (110, 45);
$div1 = explode(':', $_SESSION['col']);
if (!empty($_SESSION['wap'])) {
$bg = imagecolorallocate($im, hex(substr
($div1[5], 0, 2)), hex(substr($div1[5], 2,
2)), hex(substr($div1[5], 4, 2)));
$tx = imagecolorallocate($im, hex(substr
($div1[6], 0, 2)), hex(substr($div1[6], 2,
2)), hex(substr($div1[6], 4, 2)));
}
else {
$bg = imagecolorallocate($im, 255, 255,
255);
$tx = imagecolorallocate($im, 0, 0, 0);
}
imagefill ($im, 0, 0, $bg);
$reg = '';
$ic = 0;
while ($ic <= 4) {
$rnd = mt_rand(0,9); $reg = $reg.$rnd;
imagettftext ($im, 25, mt_rand(-30, 30), 5
+ (20*$ic), 25 + mt_rand(0, 15), $tx, "./
f.ttf", $rnd);
$ic++;
}
for($ic = 1; $ic <= 3; $ic++){
if (!empty($_SESSION['wap'])) $r =
imagecolorallocate($im, mt_rand(0, 255),
mt_rand(0, 255), mt_rand(0, 255));
else $r = imagecolorallocate($im, 0, 0, 0);
imageline($im, mt_rand(0, 20), mt_rand(0,
40), mt_rand(80, 100), mt_rand(0, 40), $r);
}
imagegif ($im);
imagedestroy ($im);
$_SESSION['regs'] = md5($reg);
?>
Александр, это каптча,файл где пишет ошибку
RGame, это файл регистрации.
каптча это
RGame, else $bday = str_pad($bday, 2, "0", STR_PAD_LEFT);
if ($sex != 0 and $sex != 1) $sex = 0;
$name = substr(conv($name), 0, 64);
$live = substr(conv($live), 0, 128);
$about = substr(conv($about), 0, 2048);
if (empty($login)||empty($name)||empty($live)||empty($about)) $erreg .= '<br/>Заполните обязательные поля...';
if ($check != $_SESSION['regs']) $erreg .= '<br/>Неправильно введено проверочное число...';
if (!empty($erreg)) {
$_SESSION['s_login'] = addslashes(htmlspecialchars($login));
$_SESSION['s_pass'] = addslashes(htmlspecialchars($pass));
$_SESSION['s_name'] = addslashes(htmlspecialchars($name));
$_SESSION['s_live'] = addslashes(htmlspecialchars($live));
$_SESSION['s_sex'] = addslashes(htmlspecialchars($sex));
$_SESSION['s_bday'] = addslashes(htmlspecialchars($bday));
$_SESSION['s_bmonth'] = addslashes(htmlspecialchars($bmonth));
$_SESSION['s_byear'] = addslashes(htmlspecialchars($byear));
$_SESSION['s_about'] = addslashes(htmlspecialchars($about));
$erreg = substr($erreg, 5);
redirect ('Ошибка', './'.$_SESSION['s'].'/11/1', $erreg);
}
else {
$rdate = getdate(realtime());
$rtime = mktime(0, 0, 0, $rdate['mon'], $rdate['mday'], $rdate['year']);
if (mysql_query("INSERT INTO `chat_users` SET login = '$login', pass = '$pass', name = '$name', sex = '$sex', bday = '".$bday.":".$bmonth.":".$byear."', live = '$live', about = '$about', rtime = '".realtime()."', ltime = '".realtime()."', stime = '".realtime()."', ip = '$idip', soft = '".conv($_SERVER['HTTP_USER_AGENT'])."', ch_set = '1:1:0:2:0:0:0:15:10:1:1:0:0:0:1:0:0:1:0:1:1:1:0:0:0:1:1:0', but_set = '1:1:1:1:1:1:1:1:1:1', col = '".$_SESSION['col']."', stats = '".$rtime.":0:0:0', refer = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."', mod_reg = '$mod_reg'")) {
$_SESSION['i'] = mysql_insert_id();
unset($_SESSION['regs']);
if (!empty($_SESSION['ref_numb'])) {
$p_refer = mysql_fetch_assoc(mysql_query("select * from `chat_partner` where `id` = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."' limit 1;"));
if (!empty($p_refer['id'])) {
$p_refer['reg_count']++;
mysql_query("update `chat_partner` set `reg_count` = '".$p_refer['reg_count']."' where `id` = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."' limit 1;");
вот кусок кода из регистрации,
if ($sex != 0 and $sex != 1) $sex = 0;
$name = substr(conv($name), 0, 64);
$live = substr(conv($live), 0, 128);
$about = substr(conv($about), 0, 2048);
if (empty($login)||empty($name)||empty($live)||empty($about)) $erreg .= '<br/>Заполните обязательные поля...';
if ($check != $_SESSION['regs']) $erreg .= '<br/>Неправильно введено проверочное число...';
if (!empty($erreg)) {
$_SESSION['s_login'] = addslashes(htmlspecialchars($login));
$_SESSION['s_pass'] = addslashes(htmlspecialchars($pass));
$_SESSION['s_name'] = addslashes(htmlspecialchars($name));
$_SESSION['s_live'] = addslashes(htmlspecialchars($live));
$_SESSION['s_sex'] = addslashes(htmlspecialchars($sex));
$_SESSION['s_bday'] = addslashes(htmlspecialchars($bday));
$_SESSION['s_bmonth'] = addslashes(htmlspecialchars($bmonth));
$_SESSION['s_byear'] = addslashes(htmlspecialchars($byear));
$_SESSION['s_about'] = addslashes(htmlspecialchars($about));
$erreg = substr($erreg, 5);
redirect ('Ошибка', './'.$_SESSION['s'].'/11/1', $erreg);
}
else {
$rdate = getdate(realtime());
$rtime = mktime(0, 0, 0, $rdate['mon'], $rdate['mday'], $rdate['year']);
if (mysql_query("INSERT INTO `chat_users` SET login = '$login', pass = '$pass', name = '$name', sex = '$sex', bday = '".$bday.":".$bmonth.":".$byear."', live = '$live', about = '$about', rtime = '".realtime()."', ltime = '".realtime()."', stime = '".realtime()."', ip = '$idip', soft = '".conv($_SERVER['HTTP_USER_AGENT'])."', ch_set = '1:1:0:2:0:0:0:15:10:1:1:0:0:0:1:0:0:1:0:1:1:1:0:0:0:1:1:0', but_set = '1:1:1:1:1:1:1:1:1:1', col = '".$_SESSION['col']."', stats = '".$rtime.":0:0:0', refer = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."', mod_reg = '$mod_reg'")) {
$_SESSION['i'] = mysql_insert_id();
unset($_SESSION['regs']);
if (!empty($_SESSION['ref_numb'])) {
$p_refer = mysql_fetch_assoc(mysql_query("select * from `chat_partner` where `id` = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."' limit 1;"));
if (!empty($p_refer['id'])) {
$p_refer['reg_count']++;
mysql_query("update `chat_partner` set `reg_count` = '".$p_refer['reg_count']."' where `id` = '".addslashes(htmlspecialchars($_SESSION['ref_numb']))."' limit 1;");
вот кусок кода из регистрации,
Александр, $check не определена
RGame, кинь исправлены код пожалуйста как надо.