PDA

View Full Version : Website Help - PHP Trouble



Bonxy
10-09-2009, 04:33 PM
Hi there. Didnt want to use iframes on this layout so i tried to you the (include) command.

I have set it up here: http://74.81.64.58/~slwot/new_layout.php (http://74.81.64.58/%7Eslwot/new_layout.php)

The links in the top right work, they open in the include box, but as you will probably be able to see, there is a few errors in the middle.

Just wondering how to get rid of these errors if possible, or have i done it the wrong way.

Thanks, Sam!

Invent
10-09-2009, 04:36 PM
Isn't that Tumblr's (old) design?

Bonxy
10-09-2009, 04:41 PM
Yep it tis

BoyBetterKnow
10-09-2009, 05:17 PM
You are trying to open nothing. All you have is pages/.php

?

Invent
10-09-2009, 05:26 PM
I recommend that you add a bit of security to the file includer...http://74.81.64.58/~slwot/new_layout.php?get=../new_layout (http://74.81.64.58/%7Eslwot/new_layout.php?get=../new_layout)

Bonxy
10-09-2009, 05:32 PM
Lol.. I dont know :(

Alls i want is for the links to open in that space, like they do when you click one of them, but i dont want any of them errors to be there if thats possible.

Is there a different way i do it to make the pages open by using

Http://www.bonxy.net/index.php?page=help

Thanks, samĀ¬

BoyBetterKnow
10-09-2009, 05:44 PM
I recommend that you add a bit of security to the file includer...http://74.81.64.58/~slwot/new_layout.php?get=../new_layout (http://74.81.64.58/%7Eslwot/new_layout.php?get=../new_layout)

Lmao bare jokes. umm just make sure u check if the page exists on your server or something.

Tomm
10-09-2009, 06:40 PM
Apart from it does, it includes the same file over which results in a infinite loop.


Lmao bare jokes. umm just make sure u check if the page exists on your server or something.

BoyBetterKnow
10-09-2009, 06:57 PM
Apart from it does, it includes the same file over which results in a infinite loop.

Yeh I mean like a page that is allowed in his system.

Sorry I was tired earlier. @threadstarter, I'll explain what I mean.

If you're doing the pages from db then check database if the page exists.

If not then do like



<?php

$page = $security->secureString($_GET['page']);

if ($page == 'home.php'){

echo 'homepage';

}else if ($page == 'about.php'){

echo 'about.php';

}



etc. Secure the $page like i did if you're using it with db..

Blob
11-09-2009, 02:33 PM
Make sure your website has PHP5.

<?php
// File include by Blob off of HabboxForum
$config = array("default" => "home.php", // Default Page (with trailing .php)
"directory" => "pages/", // Directory where files are held (with trailing slash)
"restricted" => array( "index" ), // Restricted pages
"404" => "404.php" // Error Page (with trailing .php)
);
$page = str_replace("/", "", ( ( ( in_array( $_GET["page"], $config["restricted"] ) ) !== false ) ? "home" : $_GET["page"] ) );
( file_exists( $config["directory"] . $page . ".php" ) !== false ) ? include( $config["directory"] . $page . ".php" ) : include( $config["directory"] . $config["404"] );
?>

Pages Directory
Replace "pages/" with the directory where the pages are contained from the index.php (so if your viewing the folder with index.php and theres a folder in there called hello with the pages in there, change it to "hello/")

404 Page
Replace "404.php" with your 404 page WITHIN the folder that you have said it your pages directory (make sure it has .php on the end) (it can be the same as your default page)

Default Page
Replace "home.php" with the default page you want to show when someone tries to access a restricted page or when no page is specified (make sure it has .php on the end)

Restricted Pages

"restricted" => array( "index" ), // Restricted pages
With the restricted pages, within the array( "index" ) put your extra restricted pages in that array, so if I don't want someone to access index.php and lol.php WITHIN the pages directory I would put:

"restricted" => array( "index", "lol" ), // Restricted pages
(Only putting index is only useful when your default directory is where index.php is, to stop an infinite loop).

Want to hide these adverts? Register an account for free!