getQuery(); list($id, $e) = @$q->peekEntry(); if ($e) return "$val {$sep} {$e['subject']}"; else return $val; } function index_gentitle($val, $sep) { global $title; return "$val $sep $title"; } function index_404error() { global $smarty, $lang; @utils_status_header(404); $module='default.tpl'; $smarty->assign('subject', $lang['404error']['subject']); $smarty->assign('content', $lang['404error']['content']); $smarty->assign('rawcontent', true); return $module; } function index_singlepost(&$params, &$module) { global $fpdb, $theme, $fp_params; $params['id'] = $fp_params['entry']; $params['fullparse']=true; $fpdb->query($params); if (@$theme['hassingle']) $module='single.tpl'; add_filter('wp_title', 'index_permatitle', 10, 2); if (isset($fp_params['comments'])) { $module = 'comments.tpl'; $params['comments'] = true; include('comments.php'); } } 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 index_showposts(&$params, &$module) { global $fp_params; if (isset($fp_params['d']) && $fp_params['d']) $params['d'] = $fp_params['d']; if (isset($fp_params['m']) && $fp_params['m']) $params['m'] = $fp_params['m']; if (isset($fp_params['y']) && $fp_params['y']) $params['y'] = $fp_params['y']; if (isset($fp_params['start']) && $fp_params['start']) $params['start'] = intval($fp_params['start']); if (isset($fp_params['count']) && $fp_params['count']) $params['count'] = intval($fp_params['count']); if (isset($fp_params['category']) && is_numeric($fp_params['category'])) $params['category'] = intval($fp_params['category']); if (isset($fp_params['cat']) && is_numeric($fp_params['cat'])) $params['category'] = intval($fp_params['cat']); if (isset($fp_params['random'])) { if (empty($fp_params['random'])) $params['random'] = 1; elseif (is_numeric($fp_params['random'])) $params['random'] = intval($fp_params['random']); } if ((isset($fp_params['paged'])) && is_numeric($fp_params['paged']) && $fp_params['paged']>0) $params['page']=$fp_params['paged']; else $params['page'] = 1; } $fp_uri_handlers = array(); function register_uri_param($handler, $function, $priority = 10) { global $fp_uri_handlers; if (is_callable($function)) $fp_uri_handlers[$priority][$handler][] = $function; } function unregister_uri_param($handler, $function) { global $fp_uri_handlers; foreach($fp_uri_handlers as $priority => $handler) { if ($i = array_search($function, $hand)) { unset($fp_uri_handlers[$priority][$handler][$i]); } } } function handle_uri_params() { global $fp_uri_handlers, $fp_params; $params = array(); $module = 'default'; ksort($fp_uri_handlers); foreach($fp_uri_handlers as $priority => $handler_group) { foreach($handler_group as $handle_id => $func_group) { if (empty($fp_params[$handle_id])) continue; foreach($func_group as $func) { $continue = call_user_func_array($func, array(&$params, &$module)); if (!$continue) break; } } } return $module; } register_uri_param('entry', 'handle_entry'); register_uri_param('comments', 'handle_comments'); function handle_entry(&$params, &$module/*&$handle*/) { global $fpdb, $theme, $fp_params; $params['id'] = $fp_params['entry']; $params['fullparse']=true; $fpdb->query($params); if (@$theme['hassingle']) $module='single.tpl'; add_filter('wp_title', 'index_permatitle', 10, 2); $module = 'index'; return true; } function handle_comments(&$params, &$module) { global $fpdb, $theme, $fp_params; $module = 'comments'; $params['comments'] = true; include('comments.php'); return false; } function index_main() { global $fpdb, $smarty, $fp_config, $fp_params; $params = array(); $module = 'index.tpl' ; $can404 = true; if (!empty($fp_params['entry'])) { index_singlepost($params, $module); } elseif ( ($explicit_req = $page = @$fp_params['page']) || (empty($fp_params) && $page = @$fp_config['general']['startpage']) ) { index_staticpage($page, $explicit_req, $params, $module); } elseif (!empty($_GET['q'])) { include('search.php'); $module = search_main(); } else { if (!empty($fp_params['feed'])){ $can404=false; switch($fp_params['feed']) { case 'atom': header('Content-type: application/atom+xml'); $module = SHARED_TPLS . 'atom.tpl'; break; case 'rss2': default: header('Content-type: application/rss+xml'); $module = SHARED_TPLS . 'rss.tpl'; } } index_showposts($params, $module); } $params['fullparse'] = true; $fpdb->query($params); $q =& $fpdb->getQuery(); list($id, $e) = $q->peekEntry(); /* no entry found : 404 */ if (!$e && $can404) $module = index_404error(); return $module; } function index_display() { global $smarty; $module = handle_uri_params(); //$module = index_main(); theme_init($smarty); $smarty->display($module.'.tpl'); unset($smarty); do_action('shutdown'); } system_init(); index_display(); ?>