PHP: <?$sql = ("SELECT count(*) FROM `DoD_chat_ipban` WHERE `ip` = '".$_SERVER['REMOTE_ADDR']."' LIMIT 1"); $sql = mysql_query($sql) or die ('Не могу проверить IP');?> Сделал так... как теперь узнать значение коунт?? раньше было без коунта и было PHP: if (mysql_num_rows ($sql) > 0) { А теперь бага ))
Luge, а теперь как ЭТО работает в php??? PHP: <? // Кодируем $sql = "UPDATE `DoD_chat_users` SET `user_chat_ip` = '".INET_ATON('$_SERVER['REMOTE_ADDR']')."' WHERE `user_chat_id` = ".$_SESSION['user_id']" ?> Я так понял? А вытаскивать как??? Тут с вставленным кодом... а мне придется сначала кодировать? Так этож лишнии ресы... или я не прав?
PHP: <?// // Функция вырезания "опасных" символов // function mreplace($text) { $text = str_replace("<", "<", $text); $text = str_replace(">", ">", $text); $text = str_replace(")" ,")" , $text ); $text = str_replace("(" ,"(" , $text ); $text = str_replace("javascript:" ,"javascript<b></b>:" , $text ); $text = str_replace("vdscript:" ,"vdscript<b></b>:" , $text ); $text = str_replace("'", "'", $text); $text = str_replace('"', """, $text); $text = str_replace("\r","",$text); $text = str_replace("\n","<br>",$text); $text = str_replace("\\", "\", $text); return $text; } // // Функция занесения сообщений пользователей в логи чата // function log_write($who, $what, $status = null, $privat = null, $time = null, $html = null) { $sql = ("UPDATE `DoD_chat_users` SET `user_chat_action` = '".time()."' WHERE `user_chat_id` = '".$_SESSION['user_chat_id']."' LIMIT 1"); $sql = mysql_query($sql) or die ('Не могу обновить время последнего действия пользователя: '.mysql_error()); mreplace($what); mreplace($who); mreplace($status); mreplace($privat); $t1 = chr(10); $t2 = chr(13); $what = trim(stripslashes(htmlspecialchars($what))); $what = str_replace($t1,'<br>',$what); $what = str_replace($t2,'<br>',$what); $what = preg_replace('/(.{3})\1*/i','$1',$what); if (isset($html)) { } // Если сообщение приватное if (isset($privat)) { if (isset($_POST['status'])) { // $status = trim(stripslashes(htmlspecialchars($status))); $status = '['.$status.'] '; } $sql = ("INSERT INTO `DoD_chat_logs` VALUES ('', '".date('Y-m-d')."', '$time', '$who', '$what', '$status', '$privat', '".$_SESSION['user_chat_login']."')"); $sql = mysql_query($sql) or die (mysql_error()); } // Если сообщение в общий чат else { if (isset($_POST['status'])) { // $status = trim(stripslashes(htmlspecialchars($status))); $status = '['.$status.'] '; } $sql = ("INSERT INTO `DoD_chat_logs` VALUES ('', '".date('Y-m-d')."' ,'$time' , '$who', '$what', '$status', '$privat', '".$_SESSION['user_chat_login']."')"); $sql = mysql_query($sql) or die (mysql_error()); } } 1. Где я не прав ) 2. как заставить в первой функции срабатывать вторую 3. То, что я сделал п.2 и в этом не прав, знаю, но так надо и надо что бы работало ))) По другому никак (( 4. И объясните что такое ссылка на функцию???
Nemo везде http://php.net/mysql_real_escape_string http://phpfaq.ru/slashes твой велосипед не спасёт от мультибайтовых символов. Кодировка GBK, например. PHP: <? $what = mreplace($what); или PHP: <?php function mreplace(&$text) { // … $text = str_replace("<", "<", $text); // … } mreplace($what); http://www.php.net/manual/ru/language.references.php
=))) new function version > PHP: function mreplace($text) { $text=htmlspecialchars($text,ENT_QUOTES); $text = str_replace("\r","",$text); $text = str_replace("\n","<br>",$text); $text = str_replace("\\", "\", $text); return $text; }
хмм, обнаружил что на хостинге strtolower не ловерит Заглавные Русские буквы, что-то нужно в пхп ini дописать?
http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://phpfaq.ru/slashes http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string http://php.net/mysql_real_escape_string
PHP: <? function mreplace($text) { $t1 = chr(10); $t2 = chr(13); $text = mysql_real_escape_string ($text); $text = str_replace($t1,'<br>',$text); $text = str_replace($t2,'<br>',$text); $text = trim(stripslashes(htmlspecialchars($text))); return $text; } Следующий вопрос Если я выполняю функцию Код (Text): function log_write($who, $what, $status = null, $privat = null, $time = null, $html = null) { собственно функцией, т.е. сразу подставляю значение поля $what , все нормально работает, но как только этой переменной присваевается значение из формы чата, оно превращается в УТФ (все файлы ANSI!!!)