isLoggedIn()){
if($user->canViewACP($user->data()->id)){
if($user->isAdmLoggedIn()){
// Can view
} else {
Redirect::to('/admin');
die();
}
} else {
Redirect::to('/');
die();
}
} else {
Redirect::to('/');
die();
}
$adm_page = "custom_pages"; // For admin sidebar
require('core/includes/htmlpurifier/HTMLPurifier.standalone.php'); // HTML Purifier
if(!isset($_GET['action'])){
// Deal with input for editing pages only
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'url' => array(
'required' => true,
'min' => 1,
'max' => 20
),
'title' => array(
'required' => true,
'min' => 1,
'max' => 30
),
'content' => array(
'required' => true,
'min' => 5,
'max' => 20480
),
'link_location' => array(
'required' => true
)
));
if($validation->passed()){
try {
$queries->update("custom_pages", $_GET["page"], array(
"url" => htmlspecialchars(Input::get('url')),
"title" => htmlspecialchars(Input::get('title')),
"content" => htmlspecialchars(Input::get('content')),
"link_location" => Input::get('link_location')
));
} catch(Exception $e){
die($e->getMessage());
}
Session::flash('custom-pages', '
' . $admin_language['page_successfully_edited'] . '
');
echo '';
die();
} else {
$error = '' . $admin_language['unable_to_edit_page'] . '
' . $admin_language['create_page_error'] . '
';
}
} else {
$error = '' . $admin_language['invalid_token'] . '
';
}
}
} else if(isset($_GET['action']) && $_GET['action'] == 'new'){
// Deal with input for creating new pages
if(Input::exists()){
if(Token::check(Input::get('token'))){
// Valid token
$validate = new Validate();
$validation = $validate->check($_POST, array(
'url' => array(
'required' => true,
'min' => 1,
'max' => 20
),
'title' => array(
'required' => true,
'min' => 1,
'max' => 30
),
'content' => array(
'required' => true,
'min' => 5,
'max' => 20480
),
'link_location' => array(
'required' => true
)
));
if($validation->passed()){
// Go ahead and input the page data
try {
$queries->create("custom_pages", array(
"url" => htmlspecialchars(Input::get('url')),
"title" => htmlspecialchars(Input::get('title')),
"content" => htmlspecialchars(Input::get('content')),
"link_location" => Input::get('link_location')
));
} catch(Exception $e){
die($e->getMessage());
}
Session::flash('custom-pages', '' . $admin_language['page_successfully_created'] . '
');
echo '';
die();
} else {
$error = '' . $admin_language['unable_to_create_page'] . '
' . $admin_language['create_page_error'] . '
';
}
} else {
// Invalid token
$error = '' . $admin_language['invalid_token'] . '
';
}
}
}
$token = Token::generate(); // generate token
?>
•
display('styles/templates/' . $template . '/navbar.tpl');
?>
getAll("custom_pages", array("id", "<>", "0"));
foreach($pages as $page){
?>
title); ?>
getWhere("custom_pages", array("id", "=", $_GET["page"]));
if(!count($page)){
echo '';
die();
}
?>
title); ?>
http://url); ?>
window.location.replace(\'/admin/pages\');';
die();
}
// Try to delete it
try {
$queries->delete("custom_pages", array('id', '=', $_GET['pid']));
} catch(Exception $e){
die($e->getMessage());
}
Session::flash('custom-pages', '
' . $admin_language['page_deleted_successfully'] . '
');
echo '';
die();
}
}
?>
display('styles/templates/' . $template . '/footer.tpl');
// Scripts
require('core/includes/template/scripts.php');
?>