function main() { parent::main(); //$smarty = $this->smarty; // parameters for the list // start offset and count (now defaults to 8...) $this->smarty->assign('categories_all', entry_categories_get('defs')); $this->smarty->assign('saved_flags', entry_flags_get()); $defcount = 8; // <-- no magic numbers! todo: add config option? global $fpdb; if (!empty($_REQUEST['entry'])) { utils_redirect('admin.php?p=entry&action=write&entry=' . $_REQUEST['entry']); } isset($_REQUEST['m']) ? $params['m'] = $_REQUEST['m'] : null; isset($_REQUEST['y']) ? $params['y'] = $_REQUEST['y'] : null; // $params['start'] = isset($_REQUEST['start'])? $_REQUEST['start'] : 0; $params['count'] = isset($_REQUEST['count']) ? $_REQUEST['count'] : $defcount; $params['page'] = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; isset($_REQUEST['category']) ? $params['category'] = $_REQUEST['category'] : ($params['category'] = 'all'); $params['fullparse'] = false; $params['comments'] = true; $fpdb->query($params); return 0; }
function main() { global $lang, $smarty; if (user_loggedin()) { if (isset($_GET['do']) && $_GET['do'] == 'logout') { user_logout(); function myredirect() { login_redirect('index.php'); } add_filter('wp_head', 'myredirect'); $content = SHARED_TPLS . 'login_success.tpl'; } elseif (user_loggedin()) { function myredirect() { login_redirect('index.php'); } add_filter('wp_head', 'myredirect'); $content = SHARED_TPLS . 'login_success.tpl'; } else { utils_redirect(); } } elseif (sess_remove('logout_done')) { function myredirect() { login_redirect('index.php'); } add_filter('wp_head', 'myredirect'); $content = SHARED_TPLS . 'login_success.tpl'; } elseif (empty($_POST)) { $content = SHARED_TPLS . 'login.tpl'; } else { // validate after a POST if (login_validate()) { utils_redirect('login.php'); } else { $smarty->assign($_POST); $content = SHARED_TPLS . 'login.tpl'; } } // Set page title and content // first parameter is Title, second is content. // Content can be both a shared tpl or raw html content; in this last case // you have to set the third optional parameter to true $smarty->assign('subject', $lang['login']['head']); $smarty->assign('content', $content); }
function index_staticpage($page, $explicit_req, &$params, &$module) { global $smarty, $title; if (static_exists($page)) { $arr = static_parse($page); $title = $arr['subject']; if ($explicit_req) { add_filter('wp_title', 'index_gentitle', 1, 2); } $smarty->assign('static_id', $page); $smarty->assign('static_page', $arr); return $module = 'static.tpl'; } if (user_loggedin()) { utils_redirect('admin.php?p=static&action=write&page=' . $page); } else { $module = index_404error(); } return $module; }
function contact_form() { global $smarty, $lang, $fp_config; if (empty($_POST)) { $smarty->assign('success', system_geterr('contact')); $smarty->assign_by_ref('panelstrings', $lang['contact']); // new form, we (re)set the session data SmartyValidate::connect($smarty, true); // register our validators SmartyValidate::register_validator('name', 'name', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('email', 'email', 'isEmail', true, false, 'trim'); SmartyValidate::register_validator('www', 'url', 'isURL', true, false, 'trim'); SmartyValidate::register_validator('content', 'content', 'notEmpty', false, false); } else { utils_nocache_headers(); // validate after a POST SmartyValidate::connect($smarty); if (!empty($_POST['url']) && strpos($_POST['url'], 'http://') === false) { $_POST['url'] = 'http://' . $_POST['url']; } // custom hook here!! // we'll use comment actions, anyway if (SmartyValidate::is_valid($_POST) && ($arr = contact_form_validate())) { $msg = "Name: \n{$arr['name']} \n\n"; if (isset($arr['email'])) { $msg .= "Email: {$arr['email']}\n\n"; } if (isset($arr['url'])) { $msg .= "WWW: {$arr['url']}\n\n"; } $msg .= "Content:\n{$arr['content']}\n"; $success = @utils_mail(isset($arr['email']) ? $arr['email'] : $fp_config['general']['email'], "Contact sent through {$fp_config['general']['title']} ", $msg); system_seterr('contact', $success ? 1 : -1); utils_redirect(basename(__FILE__)); } else { $smarty->assign('values', $_POST); } } }
<?php // Example of use require_once 'defaults.php'; require_once INCLUDES_DIR . 'includes.php'; /* backward compatibility */ if (!@$_GET['entry']) { @utils_redirect('?' . $_SERVER['QUERY_STRING']); } else { @utils_status_header(301); @utils_redirect(str_replace('&', '&', get_permalink($_GET['entry'])), true); }
<?php include 'defaults.php'; include INCLUDES_DIR . 'includes.php'; /* backward compatibility */ if (!@$_GET['page']) { @utils_redirect(); } else { @utils_status_header(301); @utils_redirect(str_replace('&', '&', theme_staticlink($_GET['page'])), true); }
function main() { // general setup global $panel, $action, $lang, $smarty, $fp_admin, $fp_admin_action; $panels = admin_getpanels(); $panel = isset($_GET['p']) ? $_GET['p'] : $panels[0]; define('ADMIN_PANEL', $panel); $smarty->assign('panel', $panel); if (!admin_panelexists($panel)) { trigger_error('Requested panel does not exists!', E_USER_ERROR); } $panelprefix = "admin.{$panel}"; $panelpath = ADMIN_DIR . "panels/{$panel}/{$panelprefix}.php"; $fp_admin = null; if (file_exists($panelpath)) { include $panelpath; $panelclass = "admin_{$panel}"; if (!class_exists($panelclass)) { trigger_error("No class defined for requested panel", E_USER_ERROR); } $fp_admin = new $panelclass($smarty); } /* check if user is loggedin */ if (!user_loggedin()) { utils_redirect("login.php"); die; } $action = isset($_GET['action']) ? $_GET['action'] : 'default'; if (!$fp_admin) { return; } $fp_admin_action = $fp_admin->get_action($action); define('ADMIN_PANEL_ACTION', $action); $smarty->assign('action', $action); $panel_url = BLOG_BASEURL . "admin.php?p={$panel}"; $action_url = $panel_url . "&action={$action}"; $smarty->assign('panel_url', $panel_url); $smarty->assign('action_url', $action_url); if (!empty($_POST)) { check_admin_referer("admin_{$panel}_{$action}"); } $smarty->assign('success', sess_remove("success_{$panel}")); $retval = $fp_admin_action->exec(); if ($retval > 0) { // if has REDIRECT option // clear postdata by a redirect sess_add("success_{$panel}", $smarty->get_template_vars('success')); $smarty->get_template_vars('success'); $to_action = $retval > 1 ? '&action=' . $action : ''; $with_mod = isset($_GET['mod']) ? '&mod=' . $_GET['mod'] : ''; $with_arguments = ''; if ($retval == PANEL_REDIRECT_CURRENT) { foreach ($fp_admin_action->args as $mandatory_argument) { $with_arguments .= '&' . $mandatory_argument . '=' . $_REQUEST[$mandatory_argument]; } } $url = "admin.php?p={$panel}{$to_action}{$with_mod}{$with_arguments}"; utils_redirect($url); } $smarty->register_modifier('action_link', 'admin_filter_action'); $smarty->register_modifier('cmd_link', 'admin_filter_command'); }
<?php // Example of use require_once 'defaults.php'; require_once INCLUDES_DIR . 'includes.php'; /* backward compatibility */ @utils_status_header(301); @utils_redirect(str_replace('&', '&', theme_feed_link()) . '&' . $_SERVER['QUERY_STRING'], true);
function commentform() { global $smarty, $lang, $fpdb, $fp_params; $comment_formid = 'fp-comments'; $smarty->assign('comment_formid', $comment_formid); if (!empty($_POST)) { # utils_nocache_headers(); // add http to url if (!empty($_POST['url']) && strpos($_POST['url'], 'http://') === false) { $_POST['url'] = 'http://' . $_POST['url']; } // custom hook here!! if ($arr = comment_validate()) { global $fp_config; $id = comment_save($fp_params['entry'], $arr); do_action('comment_post', $fp_params['entry'], array($id, $arr)); $q = new FPDB_Query(array('id' => $fp_params['entry'], 'fullparse' => false), null); list($entryid, $e) = $q->getEntry(); if ($fp_config['general']['notify'] && !user_loggedin()) { global $post; $comm_mail = isset($arr['email']) ? "<{$arr['email']}>" : ''; $from_mail = $fp_config['general']['email']; $post = $e; // plugin such as prettyurls might need this... $lang = lang_load('comments'); $mail = str_replace(array('%toname%', '%fromname%', '%frommail%', '%entrytitle%', '%commentlink%', '%content%', '%blogtitle%'), array($fp_config['general']['author'], $arr['name'], $comm_mail, $e['subject'], get_comments_link($entryid) . '#' . $id, $arr['content'], $fp_config['general']['title']), $lang['comments']['mail']); @utils_mail($from_mail, "New comment on {$fp_config['general']['title']}", $mail); } // if comment is valid, this redirect will clean the postdata $location = str_replace('&', '&', get_comments_link($entryid)) . '#' . $id; utils_redirect($location, true); exit; } else { $smarty->assign('values', $_POST); } } // Cookies $smarty->assign('cookie', array('name' => @$_COOKIE['comment_author_' . COOKIEHASH], 'email' => @$_COOKIE['comment_author_email_' . COOKIEHASH], 'url' => @$_COOKIE['comment_author_url_' . COOKIEHASH])); }
function system_sanitizequery() { $err = false; foreach ($_GET as $k => $v) { if (preg_match('![<>]|://!', $v)) { $err = true; break; } } if ($err) { // @todo add log handler utils_redirect(); } }