• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[PHP] Pages

I personally find ruby so diffrent from everything else

class Book < ActiveRecord::Base
belongs_to :subject
validates_presence_of :title
validates_numericality_of :price, :message=>"Error Message"
end

Doesn't make much sence for people who never have used Ruby before :p
 
He asked after for a Smarty version on Polish board, the thread was deleted, but I recovered my code, someone might need it maybe.

PHP:
ob_start();
require_once('Smarty.class.php');
include(((file_exists('pages/'.$_GET['page'].'.php')) ? 'pages/'.$_GET['page'].'.php'  : 'pages/404.php'));
$smarty = new Smarty;
$smarty->assign('content', ob_get_contents());
ob_end_clean();
$smarty->display('index.tpl');

Never tested it, wrote it within this small box :p
 
It is still a crappy method to make a page system...

Yeah, I always do like this..
PHP:
<?PHP
$default_site = 'index';
if(isset($_GET['page'])) {
	if(file_exists('/pages/'.$_GET['page'].'.php')) {
		include_once('/pages/'.$_GET['page'].'.php');
		$title = ucfirst($_GET['page']);
	}
	else {
		header('Location: ?page='.$default_site);
	}
}
?>
 
PHP:
<?php
$page = ((isset($_GET['page']) && $_GET['page'] != '') ? $_GET['page'] : 'home');
$page=(preg_match('/(\.\.|\/)/i',$page)?'home':$page);
$page = preg_replace('/[^a-zA-Z0-9 \._-]/','',$page);
$page = (file_exists('./pages/'.$page.'.php') ? $page : 'error');
include('./pages/'.$page.'.php');
?>

This works. Is the code good anyway? The safety?
 
Code:
?page=/etc/shadow%00

<_<

Or not, won't bypass:
Code:
$page = (file_exists('./pages/'.$page.'.php') ? $page : 'error');

:p
 
Ye, sorry, '.php' was a typo, but the point is that it will be ./pages anyway :)
 
Back
Top