Próbuję dokonać modyfikacji systemu newsów PSNews 1.3, tak, aby obok komentarzy wyświetlał się nr IP i Host osoby komentującej. Niestety nie znam PHP a obecny efekt końcowy jest taki, że obok wszystkich komentarzy wyświetla się IP i Host, tyle tylko, że mój, a nie użytkowników ...Jak powiązać zmienne odpowiadające za ip oraz host z komenatrzami, by nastąpiło zróżnicowanie? Poniżej zamieszczam kod pliku show.php
} $newspath = "news"; } include("$newspath/functions.php"); $config = confload($newspath); $userlist[$expl[0]] = $expl; } function news_wiadomosc($wiadomosc){ } switch($_GET["function"]){ default: if($config["stronicownie"] != "off"){ else{ $npage = $_GET["npage"]; } $ilestron = $count/$config["stronicowanie"]; $begin = $count - $config["stronicowanie"]*($npage-1); if($begin>$count){ $begin = $count; } $end = $begin - $config["stronicowanie"]; if($end<0){ $end = 0; } } else{ $begin = $count; $end = 0; } for($i=$begin-1; $i>=$end;$i--){ if($config["skracanie"] != "off"){ $news[2] = ps_substr($news[2], $config["skracanie"], "... [<a href=\"".$config["adres"]."function=show_all&no=$news[0]\">więcej</a>]"); } $news[2] = pscode($news[2]); if($config["emoty_news"] == "tak"){ $news[2] = emots($news[2], $newspath); } //$news[1] = wordwrap($news[1], 50, " ", 1); //$news[2] = wordwrap($news[2], 50, " ", 1); if($config["nimgs"]=="tak"){ $img_path = "$newspath/nimgs/$news[5]"; $news[2] = "<img src=\"$img_path\" align=\"".$config["nimgs_align"]."\" border=0> ".$news[2]; } } } else{ $ilekomentarzy = 0; } $userlist[$news[4]][3],$userlist[$news[4]][4],$data,$config["adres"]."function=show_all&no=$news[0]",$ilekomentarzy),$config["template"],$newspath,"news.html"); } if($config["stronicownie"] != "off"){ $print_center.= "<br><center>"; if($npage>1){ $prevp = $npage-1; $print_center.= "<a href=\"".$config["adres"]."npage=$prevp\"><<</a>"; } else{ $print_center.= "<<"; } $print_center.= " $npage z $ilestron "; if($npage<$ilestron){ $nextp = $npage+1; $print_center.= "<a href=\"". $config["adres"] ."npage=$nextp\">>></a>"; } else{ $print_center.= ">>"; } $print_center.= "</center><br>"; } break; /* CAŁOŚĆ NEWSA + KOMENTARZE */ case show_all: foreach($newsfile as $news){ if($news[0] == $_GET["no"]){ $news[2] = pscode($news[2]); if($config["emoty_news"] == "tak"){ $news[2] = emots($news[2], $newspath); } //$news[1] = wordwrap($news[1], 50, " ", 1); //$news[2] = wordwrap($news[2], 50, " ", 1); if($config["nimgs"]=="tak"){ $img_path = "$newspath/nimgs/$news[5]"; $news[2] = "<img src=\"$img_path\" align=\"".$config["nimgs_align"]."\" border=0> ".$news[2]; } } } else{ $ilekomentarzy = 0; } [2],$userlist[$news[4]][3],$userlist[$news[4]][4],$data,$config["adres"]."function=show_all&no=$news[0]",$ilekomentarzy),$config["template"],$newspath,"news.html"); } } $print_center.= "<center>[<a href=\"". $config["adres"] ."function=add_kom&no=". $_GET["no"] ."\">skomentuj</a>] [<a href=\"". $config["adres"] ."\">wróć do newsów</a>]</center><br>"; if($ilekomentarzy<1){ $print_center.= news_wiadomosc("Do tego newsa nie dodano jeszcze żadnego komentarza.<br>[<a href=\"".$config ["adres"]."function=add_kom&no=".$_GET["no"]."\">skomentuj</a>]"); } else{ foreach($komfile as $kom){ if($config["emoty_kom"] == "tak"){ $kom[1] = emots($kom[1], $newspath); } $ip = $_SERVER['REMOTE_ADDR']; $host = gethostbyaddr($_SERVER['REMOTE_ADDR']); $host),$config["template"],$newspath,"komentarz.html"); } } break; /* DODAWANIE KOMENTARZA */ case add_kom: $ip = $_SERVER["REMOTE_ADDR"]; $ban = "false"; foreach($banfile as $linia){ if($linia[0] == $ip){ $ban = "true"; } } if($ban == "true"){ $print_center = news_wiadomosc("Przepraszamy, ale nie masz zezwolenia na dodanie komentarza, ponieważ twoje IP ($ip) zostało zablokowane przez administratora.<br>[<a href=\"".$config["adres"]."\">wróć do newsów</a>]"); } else{ if($_GET["do"] == "save"){ if($_POST['kom_autor']=="" || $_POST['komentarz']==""){ $print_center = news_wiadomosc("Wypełnij wszystkie wymagane pola!<br>[<a href=\"java script:history.back()\">wróć</a>]"); } else{ $filename = "$newspath/komentarze/".$_GET["no"]; $kom_autor = $_POST["kom_autor"]; $kom_email = $_POST["kom_email"]; $komentarz = $_POST["komentarz"]; $numer = max_l_plik(0, "||", $filename)+1; $print_center = news_wiadomosc("Twój komentarz został dodany.<br>[<a href=".$config["adres"].">wróć do newsów</a>]"); } else{ $print_center = news_wiadomosc("Nie można dodać komentarza - brak pliku z bazą danych do tego newsa.<br>[<a href=". $config["adres"].">wróć do newsów</a>]"); } } } else{ $print_center.= " <form action=\"". $config["adres"]."function=add_kom&no=".$_GET["no"]."&do=save\" method=post name=formularz> *Autor:<br><input type=text name=\"kom_autor\"><br> Email:<br><input type=text name=\"kom_email\"><br> *Komentarz:<br>"; if($config["emoty_kom"] == "tak"){ $print_center.= list_emots($newspath,"komentarz")."<br>"; } $print_center.= "<textarea style=\"width:300; height:150\" name=\"komentarz\"></textarea> <br>* - pola wymagane<br><br> <input type=submit value=\"dodaj\"> <br><a href=\"".$config["adres"]."\">[rezygnuj]</a> </form> "; } } break; }
Dodam jeszcze, że ingerowałem w ten fragment (dodając zmienne ip oraz host)
$ip = $_SERVER['REMOTE_ADDR']; $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
Z góry dziękuję za pomoc!
Próbowałem zmienić nazwę zmiennych dla $kom, jednak nadal wyświetla się wyłącznie moje IP. Pomoże ktoś? Wiem że dla Was to banalna sprawa...