PDA

View Full Version : What's wrong


arne2
05-06-2007, 03:36 PM
<?
/*
Nieuw scriptje van arne voor ozzen thomsy he
I'll put everything i say in english because on your site you also have a lot of english, i hope that's ok with you , thomsy ;)
*/

// *** LOADING CONFIG FILE
include "var.inc.php";
include "/home/webhelp/public_html/global.php";
// *** CHECKING FILE EXISTING
if (!file_exists($data)){
disperr("File &quot;$data&quot; not found!");
exit;
}

?>
<html>
<head>

<style type=text/css>
body {background-image: url(../images/index_21.jpg);
background-attachment: fixed;
}
</style>

<script language="javascript">
<!--
function jumlahKata(form)
{ with (form)
{ sisa.value = <?=$maxchar?>-fcomment.value.length;
if (parseInt(sisa.value)<0) { sisa.value = '0'; }
fcomment.value = fcomment.value.substr(0,<?=$maxchar?>);
}
return;
}
//-->
</script>

</head>
<body background="/images/index_21.jpg">
<p>
<?

// *** LOADING DATA
if($file=fopen($data,"r"))
{
while(!feof($file))
{
$contents_old.=fgets($file,255);
}
fclose($file);
}





// *** UPDATING CONTENT
if ($btpost=="Post"){

//SPAMFILTER

if(eregi('sex', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('porn', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('porno', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('ejaculation', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('nude', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }

if(eregi('www', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('http', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('.com', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('.net', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('.be', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('href', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }
if(eregi('</a>', $fcomment)) { $ferr="Sorry, but your message has been recognized as being spam."; }


//END SPAMFILTER



if (empty($fname)){ $ferr.="<font color=white><li>Please Fill In Your Name</font>"; }

if (empty($fcomment)){ $ferr.="<font color=white><li>Please Fill In Your Comments</font>"; }
if ($fhomepage == 'http://'){
$fhomepage="";
}


if (!empty($ferr)){
disperr($ferr);
} else {
$ftanggal=date("d M Y - H:i");
splitwordx($fname,30,30);
splitwordx($femail,50,30);
splitwordx($fhomepage,50,30);
splitwordx($fcomment,40,40);
$fcomment=substr($fcomment,0,$maxchar);
$contents_new="|line|$ftanggal";
$contents_entry="|#|$fname|#|$femail|#|$femail_show|#|$fhomepage|#|$fcomment";
$contents_new.=$contents_entry;
$contents_new=stripslashes($contents_new);
$contents_new=conv_asc2html($contents_new,1);
if (strstr($contents_old,$contents_entry)){
disperr("Duplicate entry");
} else {
if ($file=fopen($data,"w")){
$contents_new=$contents_new. "\r\n" . $contents_old;
fputs($file,$contents_new);
fclose($file);
$contents_old=$contents_new;
}
}
}
}

echo "<center><table border=1 cellspacing=0 cellpadding=5 style=\"border-collapse:collapse\" bordercolor=#000000>\n";
echo "<FORM name=pesan METHOD=\"post\" ACTION=\"".$PHP_SELF."\">\n";
echo "<tr><td>Name* :<td><input name=\"fname\"></tr>\n";
echo "<tr><td>Email :<td><input name=\"femail\" width=10> \n";
echo "<input type=\"checkbox\" name=\"femail_show\" value=\"y\" checked><small>show my email</tr>\n";
echo "<tr><td>Homepage :<td><input name=\"fhomepage\" size=30 value=\"http://\"></tr>\n";
echo "<tr><td>Comment* :<td><textarea max=\"$machar\" name=\"fcomment\" rows=5 cols=40 ";
echo " onKeyup='jumlahKata(document.pesan);' RAP";
echo "></textarea><small><br>Max $maxchar chars.";
echo "Chars left : <input type=\"text\" size=3 name=sisa maxlength=3 value=\"$maxchar\">";
echo "</tr>\n";
echo "<tr><td colspan=2><div>*: <small>Required field</small></div><div align=center><input type=\"submit\" name=\"btpost\" value=\"Post\"> <input type=\"Reset\" value=\"Reset\"></div></tr>\n";
echo "</FORM>";
echo "</table><br><br></center>";



$contents_old=conv_asc2html($contents_old,2);
$ar_row=explode("|line|",$contents_old);

$recperpage=10;
$row_first=1;
$row_last=count($ar_row)-1;
if (empty($row_start)){ $row_start=$row_first; }
$row_end=$row_start+$recperpage-1;
if ($row_end>$row_last){ $row_end=$row_last; }

if ($row_last>$recperpage){
echo "Page : ";
for ($p=1; $p<=ceil($row_last / $recperpage); $p++){
if ($p>1){ $start=((($p-1)*$recperpage)+1);
} else { $start=1; }
if ($p==ceil($row_start/$recperpage)){ $tdcol="#666666"; } else { $tdcol="#CCCCCC"; }
echo "<font style=\"background-color:$tdcol\">[<a href=\"$PHP_SELF?row_start=$start\">$p</a>]</font> ";
}
}


//echo "first:$row_first|start:$row_start|end:$row_end|last:$row_last";
echo "&nbsp;<table bgcolor=#666666 border=1 cellspacing=0 cellpadding=5 style=\"border-collapse:collapse\" bordercolor=#FFFFFF>\n";
for ($r=$row_start; $r<=$row_end; $r++){
$ar_field=explode("|#|",$ar_row[$r]);
$tanggal=$ar_field[0];
$name=$ar_field[1];
$email=$ar_field[2];
$email_show=$ar_field[3];
if ($email_show=="y"){
$email="(<a href=\"mailto:$email\">$email</a>)";
} else {
$email="(<strike><font color=#666666>hidden</font></strike>)";
}
$homepage=$ar_field[4];
$homepage="<a href=\"$homepage\" target=\"_blank\">$homepage</a>\n";
$comment=$ar_field[5];
echo "<tr><td rowspan=2>$r <td><small>$tanggal<td><small>$name $email<td><small>$homepage</tr>\n";
echo "<tr><td bgcolor=#999999 colspan=3><font color=white>$comment</font></tr>\n";
}
echo "</table>\n";

?>
</body>
</html>


It isn't posting, what's wrong?

arne2
05-06-2007, 03:37 PM
Sorry for the bad topic title...
I'm sure the data.txt file is writeable etc. It worked before and now it doesn't anymore...

(url for live example: http://www.webmasterhelp.biz => click guestbook)

arne2
05-07-2007, 03:57 PM
anyone?

rafiki
05-07-2007, 05:20 PM
use functions like
is_writable() (http://uk2.php.net/is_writable)
to double check
chmod the file (http://uk2.php.net/manual/en/function.chmod.php)
if its not writable

the-dream
05-07-2007, 05:29 PM
you should use a data base

rafiki
05-07-2007, 05:35 PM
maybe he doesnt have access to a database, i reccomend using database if you have though

arne2
05-08-2007, 04:50 PM
well you guys think the same as me as i usually use a database but on the clients webserver it's not available so i had to recode it to use a datafile instead of a database

rafiki
05-08-2007, 04:51 PM
did those functions help?

arne2
05-08-2007, 05:03 PM
No, but something very funny occured. When i upload the same codes to another server, the guestbook works. I'm clueless, can anyone help me please?:)

EDIT: Note that it did work on this server before

rafiki
05-08-2007, 05:06 PM
maybe it was a change of PHP versions that changed something check the version it works on to the version it doesnt work on

arne2
05-08-2007, 05:06 PM
Just noticed that everything else is also not working anymore. If i click to view another page of the guestbook, it doesn't change the page and still renders me the same page. If i don't fill in enough in the form (so that i should tell me i have to fill in more stuff), it doesn't give me any errors or something, it just does nothing and refreshes.

I could use some quick help

arne2
05-08-2007, 05:07 PM
Rafiki, thanks for your help. I'm not the real server owner so i don't know anything about changes or something. Is there a way i can check this or something?

rafiki
05-08-2007, 05:11 PM
<?php
phpinfo();
?>

http://uk3.php.net/phpinfo
or just
<?php
phpversion();
?>

http://uk3.php.net/manual/en/function.phpversion.php

arne2
05-08-2007, 05:21 PM
it's not working on the server that has : PHP Version 4.4.4

EDIT: lol, just checked the other server, it has the same php version
(http://mafiaruler.com/test/phpversion.php and http://www.webmasterhelp.biz/Guestbook/phpversion.php).

It should work, but it doesn't, please help! THank you

aedrin
05-08-2007, 05:36 PM
Turn on displaying of errors using ini_set().

arne2
05-08-2007, 05:46 PM
How? i just put that on top of the page or what?

rafiki
05-08-2007, 05:56 PM
yes if your not sure on using a function the manual gives reference to it just type www.php.net/function.name for example
www.php.net/function.ini-set

arne2
05-09-2007, 07:44 PM
why do i need this function as what parameters do i have to change as ini_set is to change parameters it says on the function page.
When i include it like ini_set(); it says : wrong parameter. Please help me i need those gbooks back online

arne2
05-10-2007, 03:43 PM
I could use some help..

Fumigator
05-10-2007, 04:02 PM
You're not giving us anything to work with. There's only so much we can guess and surmise at with the info you've provided.

arne2
05-10-2007, 04:26 PM
then what else do you need to know? I already gave you the code, the problem and the php version...

aedrin
05-10-2007, 04:49 PM
<?php
ini_set("display_errors", true);
?>


Always have display_errors on when debugging. In production this should be off obviously.

EDIT: Put this code somewhere at the top of your file.

If there are no errors you know it's a logic issue.

Considering it works for other servers, I'm guessing it's most likely a plain error causing it. Otherwise it would work fine.

rafiki
05-10-2007, 04:59 PM
<?php
ini_set("display_errrors", true);
?>


Always have display_errors on when debugging. In production this should be off obviously.

EDIT: Put this code somewhere at the top of your file.

If there are no errors you know it's a logic issue.

Considering it works for other servers, I'm guessing it's most likely a plain error causing it. Otherwise it would work fine.

<?php
ini_set("display_errors", true);
?>

errors does have 3 r's in total right?

aedrin
05-10-2007, 05:59 PM
That was a typo. It's fixed now.

rafiki
05-10-2007, 06:08 PM
That was a typo. It's fixed now.

lol i gathered as you correctly spelt it in the same post

arne2
05-11-2007, 04:23 PM
Ok, i added it at the very top and I don't get any errors or something. It's very weird as I can't post anything, but i also can't go through all the post as it only displays the first page. When i click on second page, it refreshes but still shows the same first page. The code i'm now using is the following :
<?

ini_set("display_errors", true);

/*
Nieuw scriptje van arne voor ozzen thomsy he
I'll put everything i say in english because on your site you also have a lot of english, i hope that's ok with you , thomsy ;)
*/

// *** LOADING CONFIG FILE
include "var.inc.php";
// *** CHECKING FILE EXISTING
if (!file_exists($data)){
disperr("File &quot;$data&quot; not found!");
exit;
}

?>
<html>
<head>

<style type=text/css>
body {background-image: url(../images/index_21.jpg);
background-attachment: fixed;
}
</style>

<script language="javascript">
<!--
function jumlahKata(form)
{ with (form)
{ sisa.value = <?=$maxchar?>-fcomment.value.length;
if (parseInt(sisa.value)<0) { sisa.value = '0'; }
fcomment.value = fcomment.value.substr(0,<?=$maxchar?>);
}
return;
}
//-->
</script>

</head>
<body background="/images/index_21.jpg">
<p>
<?

// *** LOADING DATA
if($file=fopen($data,"r"))
{
while(!feof($file))
{
$contents_old.=fgets($file,255);
}
fclose($file);
}





// *** UPDATING CONTENT
if ($btpost=="Post"){



if (empty($fname)){ $ferr.="<font color=white><li>Please Fill In Your Name</font>"; }

if (empty($fcomment)){ $ferr.="<font color=white><li>Please Fill In Your Comments</font>"; }
if ($fhomepage == 'http://'){
$fhomepage="";
}


if (!empty($ferr)){
disperr($ferr);
} else {
$ftanggal=date("d M Y - H:i");
splitwordx($fname,30,30);
splitwordx($femail,50,30);
splitwordx($fhomepage,50,30);
splitwordx($fcomment,40,40);
$fcomment=substr($fcomment,0,$maxchar);
$contents_new="|line|$ftanggal";
$contents_entry="|#|$fname|#|$femail|#|$femail_show|#|$fhomepage|#|$fcomment";
$contents_new.=$contents_entry;
$contents_new=stripslashes($contents_new);
$contents_new=conv_asc2html($contents_new,1);
if (strstr($contents_old,$contents_entry)){
disperr("Duplicate entry");
} else {
if ($file=fopen($data,"w")){
$contents_new=$contents_new. "\r\n" . $contents_old;
fputs($file,$contents_new);
fclose($file);
$contents_old=$contents_new;
}
}
}
}

echo "<center><table border=1 cellspacing=0 cellpadding=5 style=\"border-collapse:collapse\" bordercolor=#000000>\n";
echo "<FORM name=pesan METHOD=\"post\" ACTION=\"".$PHP_SELF."\">\n";
echo "<tr><td>Name* :<td><input name=\"fname\"></tr>\n";
echo "<tr><td>Email :<td><input name=\"femail\" width=10> \n";
echo "<input type=\"checkbox\" name=\"femail_show\" value=\"y\" checked><small>show my email</tr>\n";
echo "<tr><td>Homepage :<td><input name=\"fhomepage\" size=30 value=\"http://\"></tr>\n";
echo "<tr><td>Comment* :<td><textarea max=\"$machar\" name=\"fcomment\" rows=5 cols=40 ";
echo " onKeyup='jumlahKata(document.pesan);' RAP";
echo "></textarea><small><br>Max $maxchar chars.";
echo "Chars left : <input type=\"text\" size=3 name=sisa maxlength=3 value=\"$maxchar\">";
echo "</tr>\n";
echo "<tr><td colspan=2><div>*: <small>Required field</small></div><div align=center><input type=\"submit\" name=\"btpost\" value=\"Post\"> <input type=\"Reset\" value=\"Reset\"></div></tr>\n";
echo "</FORM>";
echo "</table><br><br></center>";



$contents_old=conv_asc2html($contents_old,2);
$ar_row=explode("|line|",$contents_old);

$recperpage=10;
$row_first=1;
$row_last=count($ar_row)-1;
if (empty($row_start)){ $row_start=$row_first; }
$row_end=$row_start+$recperpage-1;
if ($row_end>$row_last){ $row_end=$row_last; }

if ($row_last>$recperpage){
echo "Page : ";
for ($p=1; $p<=ceil($row_last / $recperpage); $p++){
if ($p>1){ $start=((($p-1)*$recperpage)+1);
} else { $start=1; }
if ($p==ceil($row_start/$recperpage)){ $tdcol="#666666"; } else { $tdcol="#CCCCCC"; }
echo "<font style=\"background-color:$tdcol\">[<a href=\"$PHP_SELF?row_start=$start\">$p</a>]</font> ";
}
}

echo"HEYHEY THIS GB IS BROKEN";
echo "first:$row_first|start:$row_start|end:$row_end|last:$row_last";

echo "&nbsp;<table bgcolor=#666666 border=1 cellspacing=0 cellpadding=5 style=\"border-collapse:collapse\" bordercolor=#FFFFFF>\n";
for ($r=$row_start; $r<=$row_end; $r++){
$ar_field=explode("|#|",$ar_row[$r]);
$tanggal=$ar_field[0];
$name=$ar_field[1];
$email=$ar_field[2];
$email_show=$ar_field[3];
if ($email_show=="y"){
$email="(<a href=\"mailto:$email\">$email</a>)";
} else {
$email="(<strike><font color=#666666>hidden</font></strike>)";
}
$homepage=$ar_field[4];
$homepage="<a href=\"$homepage\" target=\"_blank\">$homepage</a>\n";
$comment=$ar_field[5];
echo "<tr><td rowspan=2>$r <td><small>$tanggal<td><small>$name $email<td><small>$homepage</tr>\n";
echo "<tr><td bgcolor=#999999 colspan=3><font color=white>$comment</font></tr>\n";
}
echo "</table>\n";

?>
</body>
</html>

arne2
05-12-2007, 10:13 AM
anyone?