[php] skrypt z dodawaniem komentarza

0

Witam, dopiero zaczynam swoja przygode z php i natrafilem na maly problem, a mianowicie umiescilem skrypt na stronce. Skrypt mial na celu dodawanie komentarzy przez uzytkownikow, wszytko bylo by spoko tylko gdzie sie pojawiaja te komentarze??? Napisze komentar,nacisne na wyslij i sie odswieza strona ale komentarz sie nie wyswietla, co jest nie tak??

I jeszcze mam takie pytanko co trzeba wpisac i gdzie aby nadac prawo zapisu i odczytu dla katalogu i pliku (cos z chmod 777)

a to jest ten skrypt :

<?
//updated: 17:15 14/09/2002
///////////////////////////////////////////////////////////////////////////////
//                              talkback v1.12                               //
//                         created by James Maglo                            //
//           Download: http://php.umbagu.net/files/talkback.zip              //
//               Support: http://php.umbagu.net/support                      //
//									     //
///////////////////////////////////////////////////////////////////////////////


$address        =   "http://student.wtorek.net/~std6360/"; //Full URL to where the talkback.php script is installed
$file           =   "comment.dat"; //name of the file where data will be stored.  the default comment.dat value is recommended
$path           =   "http://student.wtorek.net/~std6360/talkback.php";// Finally, the full path to the script directory
$img            =   "1"; // 1 - user can post images   0  - images are disabled 
$title_colour   =   "#0066AA"; //background colour of the part where user's name is displayed
$message_colour =   "#CECEFF"; //background colour of the message displayed

// CHMOD THE DIRECTORY WHICH YOU SPECIFIED IN $address TO 0777!!!
//THATS ALL YOU NEED TO EDIT, PLEASE STOP NOW.  TO USE THE SCRIPT, USE include("path/to/script/talkback.php");
$version = "1.1";
$maxlen = 30;
$route = "true";
if($img){
$imgnfo = "enabled. \\n\\n[img=http://imageaddress.com/image.jpg][/img]";
}
else{
$imgnfo = "disabled";
}

function reWriteDataInFile($fileData,$fileName =  "talkback.tb")
	{
		if(!file_exists($fileName))
		{
			@$createFile = fopen($fileName, "w") or die ("Can't create file ".$fileName."");
			fwrite ($createFile,"",0);
			@chmod($fileName, 0777);
			fclose($createFile);
		}
		@$openFile = fopen($fileName,"w+") or die ("Access is denied. Set permission to ".$fileName." by command in console \"chmod 777 ".$fileName."\"");
		if ($openFile && flock($openFile,LOCK_EX)) {
			@fwrite($openFile,$fileData);
		}
		fclose($openFile);
	}

function createFile($fileName)
	{
		if(!file_exists($fileName))
		{
			@$createFile = fopen($fileName, "w") or die ("Can't create file ".$fileName."");
			fwrite ($createFile,"",0);
			@chmod($fileName, 0777);
			fclose($createFile);
		}
	}

function convertLink($content)
	{
		global $constant;
		$content = preg_replace('/(http|ftp|news|https)(:\/\/)([^<> ])+/i', "<a href='\\0' class='messagelink'>\\0</a>", $content);
		$content = preg_replace('/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))/i', "<a href='mailto:\\1'>\\1</a>", $content);
		return $content;
	}

function divideWord($content,$maxWordLength = "30")
	{
		return wordwrap($content, $maxWordLength, " ", 1);
	}


$back = "$HTTP_REFERER";
$time = date("d M, Y - H:i");
//############
//start of the script for adding
//############
if($action){
if($name){
if($comment){

$id =  date("dMYHis");

	if (file_exists("${file}"))
		include("${file}");
	else
		createFile("${file}");

		$comment = ereg_replace("[ ]{2,}", " ", $comment);
		$comment = convertLink($comment);
		$comment = str_replace("\"", "&quot;", $comment);
		$comment = str_replace("\n", " <br/>", $comment);
		$comment = str_replace("\$", " &#36;", $comment);
		$comment = strip_tags($comment, '');
if($img){
		$comment = str_replace("[img=", "<img src='", $comment);
		$comment = str_replace("][/img]", "'>", $comment);
}
		$comment = trim($comment);
		$comment = stripslashes($comment);


$cnt = 0;
	$addContent = "<?php\n";

	$addContent .= "\t\$content[0]['page'] = \"".$page."\";\n";
	$addContent .= "\t\$content[0]['delete'] = \"".$id."\";\n";
	$addContent .= "\t\$content[0]['name'] = \"".$name."\";\n";
	$addContent .= "\t\$content[0]['comment'] = \"".$comment."\";\n";
	$addContent .= "\t\$content[0]['time'] = \"".$time."\";\n";



	$contentCnt = sizeof($content);
	if ($contentCnt != 0)
		$addContent .= "\n";
	for($i = 0; $i < $contentCnt; $i++)
	{
		$cnt++;
		while(list($key, $value) = each($content[$i]))
		{
			$addContent .= "\t\$content[".$cnt."]['".$key."'] = \"".$value."\";\n";
		}
		if ($i != $contentCnt-1)
			$addContent .= "\n";
	}
	$addContent .= "?>";
	reWriteDataInFile ($addContent, "$file");





}}
header ("location: $back");
exit;}
//#############
//end of script for adding
//#############
//show the entry form if nothing has been added
//#############
$page = "${HTTP_HOST}${PHP_SELF}";
	if (file_exists("${path}${file}"))
include("${path}${file}");

print<<<END
<p><b><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Talkback</font></b><br><font size="1" face="verdana">the smart way to voice your opinion</font></p>
<form action="${address}talkback.php" name="f" method="post">
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="64"> 
        <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">name:</font></b></div>
      </td>
      <td width="436"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000"> 
        <input type="text" maxlength="40" name="name" style="width: 300;font-size: 7pt; font-family: Arial; background-color: #FFFFFF; color: black; border: 1 solid #000000" size="10">
        </font></font></b></td>
    </tr>
    <tr> 
      <td width="64" valign="top"> <script language="Javascript">
function help(){
alert("INFORMATION\\n\\n Images are $imgnfo\\n\\n    talkback - http://php.umbagu.net");
}
</script>
        <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">comment:</font></b></div><div align="center"><font face="verdana" size="1"> <a href="javascript:help()"><font color="blue">help</font></a></font></div>
      </td>
      <td width="436"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000"> 
        <textarea name="comment" style="width: 300;font-size: 7pt; font-family: Arial; background-color: #FFFFFF; color: black; border: 1 solid #000000" cols="10" rows="4"></textarea>
        </font></font></b></td>
    </tr>
    <tr> 
      <td width="64"> 
        <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2"><font size="2"><b></b></font></font></font></font></div>
      </td>
      <td width="436"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
        <input type="submit" name="Submit" value="Submit" style="width: 300;font-size: 7pt;" ><input type="hidden" name="action" value="yeah_baby"><input type="hidden" name="page" value="$page">
        </font></b></td>
    </tr>
  </table>
</form>

END;



?>
</font></font><br>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<?
$now = "${HTTP_HOST}${PHP_SELF}";


$currentContent = $content;
	for ($i = 0; $i < sizeof($currentContent); $i++)
	{
$try = $currentContent[$i]['page'];
$message = $currentContent[$i]['comment'];
$message = str_replace("javascript:", "[talkback JS filter]", $message);
if($try == $now){
?>
  <tr>
    <td bgcolor="<?echo $title_colour;?>"><font face="Verdana, Arial, Helvetica, sans-serif"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'> 
      <font size="2" color="#FFFFFF"> <b>
      <?=$currentContent[$i]['name']?>
      </b></font></font></font></font><b><font size="2" color="#FFFFFF">commented 
      at </font></b></font><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"> 
      <?=$currentContent[$i]['time']?>
      </font></b><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'> 
      </font></font></font></td>
  </tr>
  <tr>
    <td bgcolor="<?echo $message_colour;?>"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font color='navy'><font color='black'>
      &nbsp;<?=$message?>&nbsp;
      </font></font></font></td>
  </tr><?}}?>
</table>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" color="blue" size="1">
<a href="http://php.umbagu.net">&copy; James Maglo - umbagu </a>
</font></p>
0

w kliencie ftp

0

Nie widzisz komentarzy ponieważ nie masz ustawionej "mozliwosci oczytu i zapisu" (owego chmod 777) dla pliku w ktorym przechowujesz komentarze..!

0

probowalem ustawic wlasnie te chomdy ale wyswietla mi sie komunikat: „Nie mogę zmienić atrybutów zdalnych plików!”. Co to jest i jak temu zaradzic??

0

A w jaki sposób to robisz..? masz uprawnienia..?

0

przez Total Commandera
Plik --> Zmien atrybut i tam wpisuje 777 lub 666
i biore ok i wtedy pojawia sie ten komunikat

0

a czy mam uprawnienia to nie wiem nie jestem adnimistratorem tego serwera wiec pewnie nie mam

0

Żeby zmienić atrybuty pliku wystarczy być właścicielem danego pliku, nie administratorem serwera.

0

a wpisz po prostu

chmod 666 plik.txt

0
Adamo napisał(a)

a wpisz po prostu

chmod 666 plik.txt

jak to wpisz po prostu, gdzie??

kontaktowalem sie z administratorem serwera i mi odpisal ze
"uzytkownicy nie moga nadawac wyzszych praw chmod niz ma ich katalog domowy",
a niby do katalogu domowego moge zapisywac pliki, wiec powinienem miec mozliwosc zapisu?? tak,czy zle kominuje??

1 użytkowników online, w tym zalogowanych: 0, gości: 1