Hi all, i really need help here...i've had someone flooding a script on my site for a few weeks now by calling the action part in an iframe (
http://plugboard.org/pboard/plug.php....gif&plugged=0).
I've tried numerous things to stop them but my PHP knowledge is very limited, so it takes me a week to do a simple thing and then it doesn't end up working any way, rawr.
I've come up with something i think will work though, at the moment once someone has entered a Button Url and site URL it prints it to the board and returns to the index page...instead of it doing that i'd like to add in an extra step so that they can no longer flood it automatically at least...so after 'plugging' it will go to a confirm.php page where the plug they just entered will be shown and they will be asked if that is correct, if not they will click no and be taken back...if they click yes it will print the plug and take them back to the board.
I so don't know how to do this though, i've got as far as making it redirect to confirm.php after hitting plug, but by then its already printed to the board anyway and i don't know how to make it display what the plug WILL look like.
I'm terribly sorry if that doesnt make sense, hopefully someone will be able to understand enough to help me out though
Feel free to test out the script here:
http://plugboard.org/pboard/index.php
don't worry about making a 'mess' of it, that's just where i'm testing things any way.
And this is the plug.php code:
PHP Code:
<?
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='confirm.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.plugboard.org/click/click.php?id=37" target="_blank"><img src="http://www.musegravity.net/images/gravity2.gif" border="0" title="Sticky button #1
Gravity MB
Expires April 6th"></a> <a href="http://www.plugboard.org/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.plugboard.org/click/click.php?id=36" target="_blank"><img src="http://www.plugboard.org/files/rox.gif" border="0" title="Sticky button #3
Roxanna.nu
Expires March 31st"></a> <a href="http://www.plugboard.org/stickybutton.php" target="_blank"><img src="http://img.photobucket.com/albums/v311/swaymyway/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: crosshair; 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: crosshair; }
</style>
</head>
<body bgcolor="<? echo "$bgcolor"; ?>" topmargin="0" leftmargin="0">
Any help would be appreciated, if i don't work out how to stop this (if anyone has any simpler ideas im open to them) i will have to shut down the site! Go easy on me though, im a total PHP n00b!
Thanks.