View Full Version : parse error


starlet
03-23-2005, 02:21 AM
This is the error i'm getting

Warning: Cannot modify header information - headers already sent by (output started at /home/starlet/public_html/plugboard/board/index.php:2) in /home/starlet/public_html/plugboard/board/plug.php on line 9

I know this usually means theres white space after the ?> but i swear i've checked 100 times and there isn't. this is the site....
http://www.``````````````

and this is the full code...
<?
// what is added to get rid of external users - assuming the button to click on is in index.php
$referer = $_SERVER['HTTP_REFERER'];
$valid_url1 = "http://www.``````````````/board/index.php";
$valid_url2 = "http:/``````````````/board/index.php";

if (($referer != $valid_url1) and ($referer != $valid_url2)) {
$error_page = "error-page.html";
header( "Location: $error_page" );
}

// now it's back to the the regular script

include "config.php";
include "banned.php";
if($action == "plug")

{

// Check if they entered a Button URL.
if ($button == 'Button URL' || strlen($button) == 0) {
echo "<center><body bgcolor=$bgcolor><font face=$font_error size=$font_error_size color=$font_error_color>You forgot to enter a Button URL!<br>Redirecting you now. <meta http-equiv='refresh' content='4; URL=index.php'></center></font>";
exit();
}

// Check if they entered a URL.
if ($url == 'http://' || strlen($url) == 0) {
echo "<body bgcolor=$bgcolor><font face=$font_error size=$font_error_size color=$font_error_color><center>You didn't enter a your sites URL! <br>Redirecting you now. <meta http-equiv='refresh' content='4; URL=index.php'></font></center>";
exit();
}

// Check if they already plugged.
if($plugged == 2){
echo "<body bgcolor=$bgcolor><font face=$font_error size=$font_error_size color=$font_error_color><center>You can only plug twice a minute.<br>Redirecting you now. <meta http-equiv='refresh' content='4; URL=index.php'></center></font>";
exit();
}
else{ $num = $plugged + 1;
setcookie("plugged","$num",time()+60);
}


//Save the Plug.
if(in_array($url, $blocked))
{die("<body bgcolor=$bgcolor><font face=$font_error size=$font_error_size color=$font_error_color><center>Domain has been banned.</center></font>");}
$savefile = "plug.db.php";
if (!file_exists($savefile))
{
$newfile = fopen($savefile,"w+");
fclose($newfile);
}
$ip = gethostbyname($REMOTE_ADDR);
$url = htmlentities(strip_tags($url));
$url = str_replace(array("\r", "\n"), '', $url);
$button = htmlentities(strip_tags($button));
$button = str_replace(array("\r", "\n"), '', $button);
$lines = file("$savefile");
$add = "<?die ('Access unempowered')?>|$url|$button|$ip|";
$openfile = fopen("$savefile","w");
fwrite($openfile, "$add\n");
for ($i = 0; $i < $maxdata; $i++)
{
@fwrite($openfile, "$lines[$i]");
}
fclose($openfile);
echo "<script language=\"JavaScript\">window.location='index.php'</script>";
}
else
{
//SHOW PLUGS
echo
<<<HTML
<table width=$tablewidth cellspacing=0 cellpadding=0 style="border: none #$bordercolor; background-color: #$bgcolor;" >
<td align="center">
<a href="http://www.``````````````/click/click.php?id=30" target="_blank"><img src="http://www.``````````````/files/heavenly.jpg" border="0" title="Sticky button #1
Heavenly Reviews
Expires March 27th"></a> <a href="http://www.``````````````/click/click.php?id=35" target="_blank"><img src="http://www.busy-girl.net/button07.gif" border="0" title="Sticky button #2
Busy Girl
Expires April 19th"></a> <a href="http://www.``````````````/stickybutton.php" target="_blank"><img src="http://img.photobucket.com/albums/v311/`````````/sb2.gif" border="0" title="Sticky button #3
Available
Rent now!"></a> <a href="http://www.``````````````/stickybutton.php" target="_blank"><img src="http://img.photobucket.com/albums/v311/`````````/2wk2.gif" border="0" title="Sticky button #4
Available
Rent now!"></a>
HTML;
$openfile = file("plug.db.php");
$total = count($openfile);
for ($i=0; $i<$total; $i++):
list($UNEMPOWERED,$url,$button,$ip) = explode('|',chop($openfile[$i]));
$url = str_replace("http://","",$url);
$button = str_replace("=","",$button);
echo "<a href=http://$url target=_blank title=$url><img src=$button border=0 width=88 height=31></a>\n";
endfor;
echo
<<<HTML
<form method='post' action='plug.php?action=plug' name='plug'><input maxlength='$maxchars' value='Button URL' type='text' name='button' size='20' style='font-family: $font; color: #$fontcolor; font-size: 7pt; background-color: #E9F9F2; font-weight: none; border: 1px dashed #$bordercolor'>
<input value='http://' type='text' name='url' size='20' style='font-family: $font; color: #$fontcolor; font-size: 7pt; background-color: #E9F9F2; font-weight: none; border: 1px dashed #$bordercolor'>
<input type='submit' size='30' value='plug' style='background-color: #E9F9F2; font-family: $font; color: #$fontcolor; font-size: 7pt; border: 1px dashed #$bordercolor'></form></td><tr></tr>
<td align="center" style="border-top: 1px dashed #$bordercolor"></td></table>
HTML;
}
?>
<head>
<style>
a:link { color: <? echo "$link"; ?>; text-decoration: none; cursor: default; text-align: justify; }
a:visited { color: <? echo "$vlink"; ?>; text-decoration: none; cursor: default; text-align: justify; }
a:active { color: <? echo "$alink"; ?>; text-decoration: none; cursor: default; }
a:hover { color: <? echo "$hlink"; ?>; text-decoration: none; cursor: default; }

</style>
</head>
<body bgcolor="<? echo "$bgcolor"; ?>" topmargin="0" leftmargin="0">

bejayel
03-23-2005, 03:30 AM
i did notice a few small errors
<? //<--you have a few spaces after this, shoudlent matter though...
// what is added to get rid of external users - assuming the button to click on is in index.php
$referer = $_SERVER['HTTP_REFERER'];
$valid_url1 = "http://www.``````````````/board/index.php";
$valid_url2 = "http://``````````````/board/index.php"; //should be http:// not http:/

if (($referer != $valid_url1) && ($referer != $valid_url2)) { //good practice to use && instead of and, also why not || (for or)
$error_page = "error-page.html";
header( "Location: $error_page" );

also, you should be using for() { } for proper syntax. the other way works, but isnt proper.outside of that, i cant see why this would not be working.
}

bejayel
03-23-2005, 03:43 AM
sorry i missed the edit time (that should be infinite, but w/e). Umm i cant test yoru script because i have a windows server, not a linux server, and i use Apache, not IIS. (or is this possible? if it is can someone tell me how) Anyway I did a test on what i figured was causing the problem, and it works fine. So i have no idea, i will try to get write permission on this server and see if i can test it further and see what happens. You can merge this if you like, your call. i will keep testing things to see whats up.

Yuki H.
03-23-2005, 06:22 AM
http://www.spoono.com/php/tutorials/tutorial.php?url=error I hope that link kinda helps...

bejayel
03-23-2005, 06:28 AM
Ok here is the major problem. HTTP_REFERER only works in situations where your page is actually linked to from an outside page. So yoru top code wont work, theoretically. even if you include it from anotehr page in an iframe or something...not going to work because when you hit the plug button the referrer changes.

Ok, i got everything to work fairly well on my server.
Apache 2.0.53 (i think)
PHP 5.0.3 register_globals = Off //my script is actually a bit differant

Now, you can tell me if this is what you wanted or not. But i had to add a few extra valid_urls in order for it to work inside the frame. I oncluded the source that i used on the page. I am terrible sorry, but i modified it a heck of a lot. But i think it is for the better. Especially the register globals part, it is a must have and i think you should add it immediatly. Hee is a link to the page i tested it on. I am sorry if it is in violation of terms, but it is for the sole purpose of helping. My web site is still in its early early production stages anyway. havent even got the news script running yet...lol.

http://pcsask.hopto.org/plugboard/plugger.php

also sorry for the whole bunch of posts i will pm you the address in case someone decides to remove it.

bejayel
03-23-2005, 08:28 AM
AHHH posting again. Starlet. i highly suggest you check out the link i provided. I managed to get it to check if the button has all ready been entered. So far i got it to work for the buttons, but it wont work for the URLs. So again. i highly suggest you check it out.Sorry for posting so much in a row. i jsut post every time i find out somethign new. sorry again. ahh heck, here is my plug.php


<?
// what is added to get rid of external users - assuming the button to click on is in index.php
/* i have these commented because it sucks, you can uncomment them.
but make sure to check every possible URL that will be passed.

$referer = $_SERVER['HTTP_REFERER'];
$valid_url1 = "http://www.pcsask.hopto.org/plugboard/plugger.php";
$valid_url2 = "http://pcsask.hopto.org/plugboard/plugger.php";

if (($referer != $valid_url1) && ($referer != $valid_url2))
{
$error_page = "error-page.html";
header( "Location: $error_page" );
}
*/
//STARLET COMMENT THIS LINE, IT IS MERLY FOR TESTING
echo $referer;

/************************************************** ***************************
Uncomment the following variables if you server has register_globals turned off
If your plugger:
-isnt plugging
-Is giving you an error about missing variables
-or is always saying that you entered empty or invalid information

Chances are, register_globals is turned off and you need to replace

//$action = $_GET['action'];
//$plugged = $_POST['plugged'];
//$button = $_POST['button'];
//$url = $_POST['url'];

with

$action = $_GET['action'];
$plugged = $_POST['plugged'];
$button = $_POST['button'];
$url = $_POST['url'];

If you uncomment these variables when register_globals is turned on, you may
or may not get an error. It is reccomended that these variable remain
commented unless register_globals is turned off.
************************************************** **************************/


// now it's back to the the regular script

//$action = $_GET['action'];
//$plugged = $_POST['plugged'];
//$button = $_POST['button'];
//$url = $_POST['url'];

include "config.php";
include "banned.php";
if($action == "plug")

{

// Check if they entered a Button URL.
if ($button == 'Button URL' || strlen($button) == 0) {
?>
<center><body bgcolor="<? echo $bgcolor; ?>"><font face=$font_error size="<? echo $font_error_size; ?>" color="<? echo $font_error_color; ?>">You forgot to enter a Button URL!<br>Redirecting you now. <meta http-equiv="refresh" content="4; URL=index.php"></center></font>
<?
exit();
}

// Check if they entered a URL.
if ($url == 'http://' || strlen($url) == 0) {
?>
<center><body bgcolor="<? echo $bgcolor; ?>"><font face=$font_error size="<? echo $font_error_size; ?>" color="<? echo $font_error_color; ?>">You didn't enter a your sites URL! <br>Redirecting you now. <meta http-equiv="refresh" content="4; URL=index.php"></center></font>
<?
exit();
}

// Check if they already plugged.
if($plugged == 2){
?>
<center><body bgcolor="<? echo $bgcolor; ?>"><font face=$font_error size="<? echo $font_error_size; ?>" color="<? echo $font_error_color; ?>">You can only plug twice a minute.<br>Redirecting you now. <meta http-equiv="refresh" content="4; URL=index.php"></center></font>
<?
exit();
}
else{ $num = $plugged + 1;
setcookie("plugged","$num",time()+60);
}

//Check if the plug has been entered all ready
//only works for buttons, NOT URL for some reason???
$check_openfile = file("plug.db.php");
$check_total = count($check_openfile);
for ($i=0; $i<$check_total; $i++)
{
list($check_UNEMPOWERED, $check_url, $check_button, $check_ip) = explode('|',chop($check_openfile[$i]));
$check_url = str_replace("http://","",$check_url);
$check_button = str_replace("=","",$check_button);

if(($check_url == $url) || ($check_button == $button))
{
die("This button or URL has all ready been entered");
}
}



//Save the Plug.
if(in_array($url, $blocked))
{die("<body bgcolor=$bgcolor><font face=$font_error size=$font_error_size color=$font_error_color><center>Domain has been banned.</center></font>");}
$savefile = "plug.db.php";
if (!file_exists($savefile))
{
$newfile = fopen($savefile,"w+");
fclose($newfile);
}
$ip = GetHostByName($REMOTE_ADDR);
$url = htmlentities(strip_tags($url));
$url = str_replace(array("\r", "\n"), '', $url);
$button = htmlentities(strip_tags($button));
$button = str_replace(array("\r", "\n"), '', $button);
$lines = file("$savefile");
$add = "<?die ('Access unempowered')?>|$url|$button|$ip|";
$openfile = fopen("$savefile","w");
fwrite($openfile, "$add\n");
for ($i = 0; $i < $maxdata; $i++)
{
@fwrite($openfile, "$lines[$i]");
}
fclose($openfile);
?>
<script language="JavaScript">
window.location="index.php";
</script>
<?
}
else
{
//SHOW PLUGS
?>
<table width="<? echo $tablewidth; ?>" cellspacing="0" cellpadding="0" style="border: none <? echo $bordercolor; ?>; background-color: <? echo $bgcolor; ?>;">
<td align="center">
<a href="http://www.``````````````/click/click.php?id=30" target="_blank"><img src="http://www.``````````````/files/heavenly.jpg" border="0" title="Sticky button #1 Heavenly Reviews Expires March 27th"></a>
<a href="http://www.``````````````/click/click.php?id=35" target="_blank"><img src="http://www.busy-girl.net/button07.gif" border="0" title="Sticky button #2 Busy Girl Expires April 19th"></a>
<a href="http://www.``````````````/stickybutton.php" target="_blank"><img src="http://img.photobucket.com/albums/v311/`````````/sb2.gif" border="0" title="Sticky button #3 Available Rent now!"></a>
<a href="http://www.``````````````/stickybutton.php" target="_blank"><img src="http://img.photobucket.com/albums/v311/`````````/2wk2.gif" border="0" title="Sticky button #4 Available Rent now!"></a>

<?
$openfile = file("plug.db.php");
$total = count($openfile);
for ($i=0; $i<$total; $i++)
{
list($UNEMPOWERED,$url,$button,$ip) = explode('|',chop($openfile[$i]));
$url = str_replace("http://","",$url);
$button = str_replace("=","",$button);
?>
<a href="http://<? echo $url; ?>" target="_blank" title="<? echo $url; ?>"><img src="<? echo $button; ?>" border="0" width="88" height="31"></a><br>
<? } ?>
<form method="post" action="plug.php?action=plug" name="plug"><input maxlength="<? echo $maxchars; ?>" value="Button URL" type="text" name="button" size="20" style="font-family: <? echo $font; ?>; color: <? echo $fontcolor; ?>; font-size: 7pt; background-color: #E9F9F2; font-weight: none; border: 1px dashed <? echo $bordercolor; ?>">
<input value="http://" type='text' name="url" size="20" style="font-family: <? echo $font; ?>; color: <? echo $fontcolor; ?>; font-size: 7pt; background-color: #E9F9F2; font-weight: none; border: 1px dashed <? echo $bordercolor; ?>">
<input type="submit" size="30" value="plug" style="background-color: #E9F9F2; font-family: <? echo $font; ?>; color: <? echo $fontcolor; ?>; font-size: 7pt; border: 1px dashed <? echo $bordercolor; ?>"></form></td><tr></tr>
<td align="center" style="border-top: 1px dashed <? echo $bordercolor; ?>"></td></table>
<? } ?>

<head>
<style>
a:link { color: <? echo $link; ?>; text-decoration: none; cursor: default; text-align: justify; }
a:visited { color: <? echo $vlink; ?>; text-decoration: none; cursor: default; text-align: justify; }
a:active { color: <? echo $alink; ?>; text-decoration: none; cursor: default; }
a:hover { color: <? echo $hlink; ?>; text-decoration: none; cursor: default; }

</style>
</head>
<body bgcolor="<? echo $bgcolor; ?>" topmargin="0" leftmargin="0">

starlet
03-25-2005, 04:56 PM
Argh sorry, i havn't been online for a few days...the page is a 404 now.
I don't have time for all this right now but i'll look into it a bit later, thanks so much...looks like you have gone to a lot of trouble :)

bejayel
03-27-2005, 11:02 PM
sorry about the 404, i was gone for the easter break and we unplug everythign when we leave, so my computer wasnt on, so the web page wasnt on. it should be active for the next week or so now.