| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Apr 2004 Location: IL
Posts: 348
![]() | PHP template script I come up with this after getting really tired of updating multiple files when ever I wanted to make a site wide layout change. It does require use of PHP, which means your pages have to be .php instead of .htm, .html Its is a bit of code that allows you to create one layout file and load all of your content into that layout. Code: <?php
$config["path"] = "LOCATION OF YOUR CONTENT TO LOAD";
$config["ext"] = EXTENSION OF THE CONTENT FILES EX. .php, .htm, .txt";
if (!isset($_REQUEST["page"])){
$page = "main";
} else {
$page = $_REQUEST["page"];
$page = urldecode($page);
$page = trim($page);
$page = strip_tags($page);
if (substr_count($page,"..") > 0 || substr_count($page,"~") > 0){
$page = "main";
}
}
$full = $config["path"] . $page . $config["ext"];
if (!is_file($full) || is_dir($full) || !file_exists($full)){
die ("Sorry, the page you are looking for is gone. Please email the webmaster with the URL currently in your address bar so that it can be corrected. Thanks!");
} else {
require_once($full);
}
?> ????: NamePros.com http://www.namepros.com/code/120978-php-template-script.html Now your links will look like this: Code: <a href="index.php?page=filename>Content</a> |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Mar 2005 Location: Newport, UK
Posts: 930
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | its not working for me, this is what ive got Code: <?php
$config["path"] = "http://barkus.f2s.com/sbnew";
$config["ext"] = ".php";
if (!isset($_REQUEST["page"])){
$page = "main";
} else {
$page = $_REQUEST["page"];
$page = urldecode($page);
$page = trim($page);
$page = strip_tags($page);
if (substr_count($page,"..") > 0 || substr_count($page,"~") > 0){
$page = "main";
}
}
$full = $config["path"] . $page . $config["ext"];
if (!is_file($full) || is_dir($full) || !file_exists($full)){
die ("Sorry, the page you are looking for is gone. Please email the webmaster with the URL currently in your address bar so that it can be corrected. Thanks!");
} else {
require_once($full);
}
?>
__________________ |
| |
| | THREAD STARTER #5 (permalink) | ||||
| NamePros Regular Join Date: Apr 2004 Location: IL
Posts: 348
![]() |
| ||||
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 09:09 AM |
| Ultimate templates Domain 48 hr. Auction | SlashRoot.Com | Domains For Sale - Auctions | 15 | 09-01-2003 04:48 PM |
| Unlimited Templates $1 Auction, No Reserve | SlashRoot.Com | Domains For Sale - Auctions | 10 | 08-23-2003 02:14 PM |