}); '; $Template->loadJavascript('FURASTA_ADMIN_SETTINGS_TEMPLATE', $javascript); $content = ' <span class="header-img" id="header-Template"> </span><h1 class="image-left">Template</h1></span> <br/> <ul id="template"> '; $templates = scan_dir(HOME . '_www'); $validated = array(); foreach ($templates as $template) { $loc = HOME . '_www/' . $template . '/'; if (!file_exists($loc . 'index.html') || !file_exists($loc . 'style.css')) { continue; } $array = parse_template_file($loc . 'style.css'); if ($array == false) { continue; } if (!isset($array['Name'])) { continue; } $array['slug'] = $template; if ($template == basename(TEMPLATE_DIR)) { array_unshift($validated, $array); continue; } array_push($validated, $array); } $i = 0; foreach ($validated as $array) {
} $Template = Template::getInstance(); $content = ''; /** * switch * * switches between the possible values of * $overview_item and echos the content of the * associated item. the default switch checks * plugins and if it exists in a plugin it also * echos the content. */ switch ($overview_item) { case 'website-overview': require_once HOME . '_inc/function/admin.php'; $template = parse_template_file(TEMPLATE_DIR . 'style.css'); $content .= ' <table class="row-color"> <tr><td>' . $Template->e('pages') . ':</td><td>' . single('select count(id) from ' . DB_PAGES, 'count(id)') . '</td></tr> <tr><td>' . $Template->e('trash') . ':</td><td>' . single('select count(id) from ' . DB_TRASH, 'count(id)') . '</td></tr> <tr><td>' . $Template->e('users') . ':</td><td>' . single('select count(id) from ' . DB_USERS, 'count(id)') . '</td></tr> <tr><td>' . $Template->e('groups') . ':</td><td>' . single('select count(id) from ' . DB_GROUPS, 'count(id)') . '</td></tr> <tr><td>' . $Template->e('template') . ':</td><td>' . $template['Name'] . '</td></tr> <tr><td>Furasta.Org ' . $Template->e('version') . ':</td><td>' . VERSION . '</td></tr> </table>'; break; case 'recently-edited': $content .= '<table class="row-color">'; $pages = rows('select id,name,content,edited,perm from ' . DB_PAGES . ' order by edited desc limit 5'); if (count($pages) == 0) { $content .= '<p><i>No items recently edited!</i></p>';
function template_file($data, $filename) { return fill_template($data, parse_template_file($filename)); }
function run_php($dest = false) { if ($dest) { # if it has a : it must be a full URL, redirect if (strpos($dest, ':')) { redirect($dest); exit; } # if it starts with './' then it's a relative URL, redirect if (substr($dest, 0, 2) == './') { redirect(ereg_replace('/[^/]*$', substr($dest, 1), this_url())); exit; } # otherwise, it's a normal basename, display that content $basename = $dest; } else { # no dest arg $basename = $_SERVER['REDIRECT_URL']; $basename = ereg_replace('.*/', '', $basename); $basename = ereg_replace('\\.html$', '', $basename); if ($basename == '') { $basename = 'index'; } } $html_file = "{$basename}.html"; $php_file = "{$basename}.php"; $html_exists = file_exists($html_file); $php_exists = file_exists($php_file); # cms_get can return one of: # 1) false to indicate that there's no cms content for this basename # 2) a string to request a soft/full redirect just like foo_main() # 3) a hash of key/value pairs to be added to the template if (function_exists('cms_get')) { $cms_content = cms_get($basename); if (is_string($cms_content)) { run_php($cms_content); return; } } if ($php_exists) { # files can return a basename or URL of a page to be run/displayed $other = file_run($php_file); if ($other) { run_php($other); return; } } elseif ($html_exists) { readfile($html_file); exit; } elseif (!$cms_content) { header('HTTP/1.0 404 File Not Found'); if (file_exists('404.php') || file_exists('404.html')) { run_php('404'); return; } else { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>'; } } $data =& $GLOBALS['wfpl_template']; $data['basename'] = $basename; if ($cms_content) { foreach ($cms_content as $name => $value) { $data[$name] .= $value; } } if (file_exists("{$basename}.css")) { $data['css_link'] = "{$basename}.css"; } if (file_exists("template.html")) { $template = parse_template_file("template.html"); if ($html_exists) { $subs = parse_template_file($html_file); $template = merge_templates($template, $subs); } } elseif ($html_exists) { $template = parse_template_file("{$html_file}"); } if ($template) { print fill_template($data, $template); } }