Jump to content

[SOLVED] Newbie Help... PHP Guestbook nuked !


Smokey AU

Recommended Posts

Hi There,

 

I am a newbie to PHP and this forum as I am in need of some desperate help.

 

I implemented a guestbook on a clients site, with very little knowledge, but since the client wanted the hosting moved and now the guestbook is fried.

 

The previous server was running PHP v4.3.2-43.ent and the new one 5.2.6. I have no idea if that makes any difference, but something on this new server is killing my code.

 

Basically the GB calls a comments dat file and outputs it, but for some reason this file cannot be found. I know it must be something to do with the directories, but in all my debugging i cannot find the solution.

 

<? 
$siteRoot=getenv("DOCUMENT_ROOT")."/";

$gbRoot = $siteRoot."__framework/_guest-book/comments/";

$data_file = $gbRoot."comments.dat";

$do = isset($_REQUEST['do']) ? trim($_REQUEST['do']) : "";
$id = isset($_GET['id']) ? trim($_GET['id']) : "";
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$self = $_SERVER['PHP_SELF'];

if (!file_exists($data_file)) {
    echo "<b>Error !!</b> Can't find data file : $data_file.<br />";
exit;
} else {
if ($max_record_in_data_file != "0") {
	$f = file($data_file);
	rsort($f);
	$j = count($f);
	if ($j > $max_record_in_data_file) {
		$rf = fopen($data_file,"w");
            if (strtoupper($os) == "UNIX") {
           if (flock($rf,LOCK_EX)) {
                  for ($i=0; $i<$max_record_in_data_file; $i++) {
                      fwrite($rf,$f[$i]);	     
		      }
                  flock($rf,LOCK_UN);
           }
            } else {
               for ($i=0; $i<$max_record_in_data_file; $i++) {
                  fwrite($rf,$f[$i]);	     
           }
        }
		fclose($rf);
	}
}
}
$newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n";
switch ($do) {
case "":
   $record = file($data_file);
   rsort($record);
   $jmlrec = count($record);
?>

 

This is what is output.

 

Error !! Can't find data file : $data_file.
"; exit; } else { if ($max_record_in_data_file != "0") { $f = file($data_file); rsort($f); $j = count($f); if ($j > $max_record_in_data_file) { $rf = fopen($data_file,"w"); if (strtoupper($os) == "UNIX") { if (flock($rf,LOCK_EX)) { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } flock($rf,LOCK_UN); } } else { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } } fclose($rf); } } } $newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n"; switch ($do) { case "": $record = file($data_file); rsort($record); $jmlrec = count($record); ?>
'; } $w = 0; //--Color for ($i=0; $i<$max_entry_per_page; $i++) { $nomrec++; $no++; //$no--; $recno = $nomrec-1; if (isset($record[$recno])) { $row = explode("|~|",$record[$recno]); if ($w==0) { $warna = $table_content_1a; $warna2 = $table_content_1b; $w=1; } else { $warna = $table_content_2a; $warna2 = $table_content_2b; $w=0; } echo "'; echo ""; } //--end if } //--end for echo "'; ?>

 

 

Any help would be much appreciated. If you need more info please let me know.

Link to comment
https://forums.phpfreaks.com/topic/144573-solved-newbie-help-php-guestbook-nuked/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.