Potrebujem poradit.. mam script, v ktorom nefunguje
$_POST["prispevok"] = Str_Replace("n","",$_POST["prispevok"]);
a vobec nechapem preco... iny str_replace pri nahradzovani napr. :) smajlikom fici v pohode.. funkciu nl2br() pouzivat nechcem pretoze vypis z db je potom zle zarovnany.. script vyzera takto:
?
define('BASE_URL', "http://localhost/Pacienti/");
function escape($str) {
if(get_magic_quotes_gpc())
$str = stripslashes($str);
if(function_exists("mysql_real_escape_string"))
$str = mysql_real_escape_string($str, $GLOBALS["spojeni"]);
else
$str = addslashes($str);
return $str;
}
if(isset($_POST["odeslano"])) {
//oriznuti o zbytecne netisknutelne znaky
$_POST = array_map("trim", $_POST);
//proti SQL injesction
$_POST = array_map("escape", $_POST);
//Prevest html tagy na entity
$_POST = array_map("htmlspecialchars", $_POST);
//prevedenie /n na <br>
if(!empty($_POST["prispevok"])) {
$user_id=mysql_query("Select id from admin where Login='$db_administration_login'");
$u_id=mysql_fetch_array($user_id);
$uid=$u_id["id"];
$datum=date("d.m.Y");
$cas=date("H:i:s");
$najst=array
(
":)",
":lol:",
":D",
":Q",
";)",
":P",
":fuck:",
":B",
":hmm:",
":O",
"8)",
":(",
":grr:",
"8I",
":heh:",
":x",
":wohoow:",
":coo:",
":goood:",
":baad:",
":pc:",
":pivo:",
":ahaa:",
":E",
":buee:",
":ziiiv:",
":hek:",
":love:",
":ups:",
":zuby:",
":zzz:",
":sibe:",
":ucim:",
);
$nahradit=array
(
"<img src="Data/Images/Smilies/1.gif" alt=":)">",
"<img src="Data/Images/Smilies/2.gif" alt=":lol:">",
"<img src="Data/Images/Smilies/3.gif" alt=":D">",
"<img src="Data/Images/Smilies/4.gif" alt=":Q">",
"<img src="Data/Images/Smilies/5.gif" alt=";)">",
"<img src="Data/Images/Smilies/6.gif" alt=":P">",
"<img src="Data/Images/Smilies/7.gif" alt=":fuck:">",
"<img src="Data/Images/Smilies/8.gif" alt=":B">",
"<img src="Data/Images/Smilies/9.gif" alt=":hmm:">",
"<img src="Data/Images/Smilies/10.gif" alt=":0">",
"<img src="Data/Images/Smilies/11.gif" alt="8)">",
"<img src="Data/Images/Smilies/12.gif" alt=":(">",
"<img src="Data/Images/Smilies/13.gif" alt=":grr:">",
"<img src="Data/Images/Smilies/15.gif" alt="8I">",
"<img src="Data/Images/Smilies/16.gif" alt=":heh:">",
"<img src="Data/Images/Smilies/17.gif" alt=":x">",
"<img src="Data/Images/Smilies/18.gif" alt=":wohoow:">",
"<img src="Data/Images/Smilies/19.gif" alt=":coo:">",
"<img src="Data/Images/Smilies/20.gif" alt=":goood:">",
"<img src="Data/Images/Smilies/21.gif" alt=":baad:">",
"<img src="Data/Images/Smilies/22.gif" alt=":pc:">",
"<img src="Data/Images/Smilies/23.gif" alt=":pivo:">",
"<img src="Data/Images/Smilies/24.gif" alt=":ahaa:">",
"<img src="Data/Images/Smilies/25.gif" alt=":E">",
"<img src="Data/Images/Smilies/27.gif" alt=":buee:">",
"<img src="Data/Images/Smilies/28.gif" alt=":ziiiv:">",
"<img src="Data/Images/Smilies/29.gif" alt=":hek:">",
"<img src="Data/Images/Smilies/32.gif" alt=":love:">",
"<img src="Data/Images/Smilies/33.gif" alt=":ups:">",
"<img src="Data/Images/Smilies/34.gif" alt=":zuby:">",
"<img src="Data/Images/Smilies/35.gif" alt=":zzz:">",
"<img src="Data/Images/Smilies/36.gif" alt=":sibe:">",
"<img src="Data/Images/Smilies/37.gif" alt=":ucim:">",
);
echo '<table align="center"><tr><td align="center" class="bold_w">Pr?spevok bol ?spe?ne pridan?.</td></tr></table>';
$_POST["prispevok"] = preg_replace(array("/((http|ftp|buhvi_co_jeste)://.*)/imU", "/(.*)/imU", "/[email](.*)[/email]/imU", "/[i](.*)[/i]/imU", "/[B](.*)[/B]/imU"),
array("<a class="hypforum_o" target="_blank" href="".BASE_URL."/redir.php?url=1">1</a>", "<a class="hypforum_o" target="_blank" href="".BASE_URL."/redir.php?url=http://1">http://1</a>", "<a class="hypforum_o" href="mailto:1">1</a>", "<em>1</em>", "<strong style="font-size:12px;">1</strong>"),
$_POST["prispevok"]);
$_POST["prispevok"] = Str_Replace($najst, $nahradit, $_POST["prispevok"]);
$_POST["prispevok"] = Str_Replace("n","",$_POST["prispevok"]);//nefunguje
MySQL_Query("INSERT INTO prispevok_forum VALUES('','$id_tema','$uid','$_POST[prispevok]','$datum','$cas',now())");
echo MySQL_error();
}
else {
echo '<table align="center"><tr><td align="center" class="bold_w">Nie je mo?n? prida? pr?zdny pr?spevok!</td></tr></table>';
}
}
?
Fakt si neviem rady... ?:helpme:??:error:?dikes za kazdu radu