Autor Zpráva
Santino Corleone
Profil *
Na www.santino-corleone.com mám návštěvní knihu. Funguje perfektně až na to, že nezapisuje hodnoty ICQ, www a e-mail. Nevíte, kde je chyba?
Děkuju


<?php
function getIP(){
$ip1=getenv('REMOTE_ADDR');$ip2=getenv('HTTP_X_FORWARDED_FOR'); /* ip1-proxy, ip2-behind proxy */
$ip=($ip2!='' && ip2long($ip2)!=-1)?ip2long($ip2):$ip1;
$ip=substr($ip,0,15);
if (!EReg("^([0-9]{1,3}.){3}[0-9]{1,3}$",$ip)) $ip="";
return $ip;
}

$msg = array();
$msg['ip'] = getIP();
$msg['date'] = date("Y-m-d H:i:s",time());

if(count($HTTP_POST_VARS))
{
$msg['name'] = $_POST['msgname'];
$msg['mail'] = $_POST['msgmail'];
$msg['icq'] = $_POST['msgicq'];
$msg['www'] = $_POST['msgwww'];
$msg['text'] = $_POST['msgtext'];

$msg['name'] = substr($msg['name'],0,32);
$msg['name'] = Ereg_Replace("[^a-zA-Z0-9]","",$msg['name']);

$msg['Mail'] = substr($msg['mail'],0,255);

$msg['Mail'] = Ereg_Replace("@","\@",$msg['mail']);

if ( !EReg("^[0-9]{1,10}$",$msg['icq']) ) $msg['icq']="";

if ( !EReg("http://(.*)",$msg['www']) ) $msg['www'] = "http://".$msg['www'];
if ( !EReg("^http:\/\/[[:alnum:]]+([-_\.]?[[:alnum:]])*\.[[:alpha:]]{2,4}(\ /{1}[-_~&=\?\.a-z0-9]*)*$",$msg['www']) ) $msg['www']="";

$msg['text'] = HTMLSpecialChars($msg['text']);

$savemsg=0; if ($msg['name']!=="" && $msg['text']!=="") $savemsg=1;
}

?>






<form name="f" action="guestbook.php" method="post">

<table>
<tr>
<td><font class="povinne">Jméno:</font></td>
<td><input type="text" name="msgname" size="12" /></td>
<td><font class="povinne">Mail:</font></td>
<td><input type="text" name="msgmail" size="24" /></td>
</tr>
<tr>
<td><font class="nepovinne">ICQ:</font></td>
<td><input type="text" name="msgicq" size="12" /></td>
<td><font class="nepovinne">Web:</font></td>
<td><input type="text" name="msgwww" size="24" /></td>
</tr>
<tr>
<td valign="top"><font class="povinne">Text:</font></td>
<td colspan="3"><textarea cols="36" rows="5" name="msgtext"></textarea></td>
</tr>
</table>

<center>
<input type="submit" value="Odeslat"/>
<input type="reset" value="Smazat" />
</center>

</form>


<?php
$fname = "./data.txt";
if (!file_exists($fname)) {$ft = fopen($fname,"w+");fwrite($ft,"\n<hr/>");fclose($ft);}

if ($savemsg===1)
{
$data = "\n<hr />";
$data.= "\n<font class=\"cas\">".$msg['date']."</font>";
$data.= "\n<!--".$msg['ip']."-->";
$data.= "\n<br />";
$data.= "\n<font class=\"jmeno\">".$msg['name']."</font>";

$msg['mail'] = ($msg['mail']!=="")?'<a href="mailto:'.$mail.'">mail</a>':'';
$msg['icq'] = ($msg['icq'] !=="")?'<a href="http://web.icq.com/wwp?Uin='.$icq.'">icq</a>':'';
$msg['www'] = ($msg['www'] !=="")?'<a href="'.$www.'">www</a>':'';
$s =$msg['mail'];
$s.=(($s!=="" && $msg['icq']!=="")?", ":"").$msg['icq'];
$s.=(($s!=="" && $msg['www']!=="")?", ":"").$msg['www'];
$s =$s!==""?"(".$s.") ":"";

$data.= "\n".$s;
$data.= "\n<p>".$msg['text']."</p>";

$ft1 = file($fname);
$ft = fopen($fname, "w+");
fseek($ft, 0);
fwrite($ft, $data);
for ($i=0; $i<count($ft1); $i++) {fputs($ft, $ft1[$i]);}
fclose($ft);
}


include($fname);
?>
skyver
Profil *
Neni toto spatne?

$msg['mail'] = ($msg['mail']!=="")?'<a href="mailto:'.$mail.'">mail</a>':'';
$msg['icq'] = ($msg['icq'] !=="")?'<a href="http://web.icq.com/wwp?Uin='.$icq.'">icq</a>':'';

nemelo by to byt?

$msg['mail'] = ($msg['mail']!=="")?'<a href="mailto:'.$msg['mail'].'">mail</a>':'';
$msg['icq'] = ($msg['icq'] !=="")?'<a href="http://web.icq.com/wwp?Uin='.$msg['icq'].'">icq</a>':'';
Santino Corleone
Profil *
Jasně bylo to v tom.

Tohle bylo špatně:

$msg['mail'] = ($msg['mail']!=="")?'<a href="mailto:'.$mail.'">mail</a>':'';
$msg['icq'] = ($msg['icq'] !=="")?'<a href="http://web.icq.com/wwp?Uin='.$icq.'">icq</a>':'';
$msg['www'] = ($msg['www'] !=="")?'<a href="'.$www.'">www</a>':'';

A takhle to mělo být:

$msg['mail'] = ($msg['mail']!=="")?'<a href="mailto:'.$msg['mail'].'">mail</a>':'';
$msg['icq'] = ($msg['icq'] !=="")?'<a href="http://web.icq.com/wwp?Uin='.$msg['icq'].'">icq</a>':'';
$msg['www'] = ($msg['www'] !=="")?'<a href="'.$msg['www'].'">www</a>':'';
Toto téma je uzamčeno. Odpověď nelze zaslat.