View Full Version : Please Help With A Php Command
thickandthin
07-02-2003, 11:36 PM
ok people can go to mysite.com/index.php?page=index.php and it can slow down the server and use my bandwidth how do i prevent this? PLEASE ASAP
Nightfire
07-02-2003, 11:41 PM
How's it slow the server down and use more bandwidth?
thickandthin
07-02-2003, 11:43 PM
because its looping index.php!
Nightfire
07-02-2003, 11:52 PM
It's not a good idea to use ?page=pagename.php to get files/pages anyway. For better security, you'd be better off just using something like this
// url :: http://domain.com/index.php?page=index
if(file_exists("includes/".$_GET['page'].".php"){
include("includes/".$_GET['page'].".php");
}else{
echo "You're havin a larf";
}
Throw all your included files into a directory called includes, that way your index page won't be in a loop
thickandthin
07-02-2003, 11:59 PM
how do i put that in where? i dont know php i just use it for that
Nightfire
07-03-2003, 12:03 AM
Put it in your index.php page wherever you want the pages to be added. The query string in the url looks for files in the includes directory and if that file doesn't exist, it'll show an error on the page.
It is hard to say how to do it as I've not seen the source of your page, so I'm just grabbing straws here
thickandthin
07-03-2003, 12:04 AM
<?php if($page == "") { include("news.html"); } else { include("$page"); } ?> what do i do to that
Nightfire
07-03-2003, 12:09 AM
delete it and change it for this - move news.html into your includes directory
<?php
if(empty($_GET['page'])){
include("includes/news.html");
}else{
if(file_exists("includes/".$_GET['page'].".html")){
include("includes/".$_GET['page'].".html");
}else{
echo "You're havin a larf";
}
}
?>
thickandthin
07-03-2003, 12:14 AM
it doesnt work i get
Parse error: parse error, unexpected '{' in /home/vcsource/public_html/index.php on line 198
do i actually make an includes folder? and move it there?
Nightfire
07-03-2003, 12:17 AM
Sorry, missed a closing bracket off, the code above should work now. You make an includes folder and put all the files you want to be used by the ?page=whatever in there
thickandthin
07-03-2003, 12:20 AM
WOW THANKS FOR THIS I REALLY APRRECIATE IT
thickandthin
07-03-2003, 12:25 AM
will i have to change all the links to includes/whatever?
Nightfire
07-03-2003, 12:28 AM
no, all you'll need to do is just use the same as before, except without the file extension on the end, so instead of youdomain.com/index.php?page=index.php you'll just use yourdomain.com/index.php?page=index This will automatically search for a file called index.html in the includes folder
thickandthin
07-03-2003, 12:34 AM
THANKS SO MUCH AND MY FREIND SAYS THANKS TO
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.