<?php
$time_start = microtime(TRUE);
define('IN_HBS',TRUE);
include("../inc/include.php");
?>
<?php include("password_protect.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HBS Administrative Control Panel</title>
<script type="text/JavaScript">
function getTempInfo(temp)
{
var template = temp.options[temp.selectedIndex].value;
window.location = 'themechoice.php?temp='+template;
}
</script>
</head>
<?php include ("default_style.css"); ?>
<body>
<div align="center"><img src="images/header.png" />
</div>
<table id="table" align="center">
<tr>
<td id="menu">
<?php include ("navigation.php"); ?>
</td>
<td id="content">
<table width="100%">
<tr>
<td style="background-color:#FFFFD9; border: #FFFFB7 1px solid;">
<table align="center">
<tr>
<td>Analyse template:</td>
<td><select name="templates" onChange="getTempInfo(this)">
<?php
function get_templates()
{
$temp_dir = (defined(BASE_DIR)) ? BASE_DIR.'templates/' : './../templates/';
$my_dir = opendir($temp_dir);
while (false !== ($file = readdir($my_dir)))
{
if ($file != '.' && $file != '..')
{
if (is_dir($temp_dir.$file.'/'))
{
$templates[] = $file;
}
}
}
closedir($my_dir);
return $templates;
}
function get_template_info($template)
{
$temp_dir = (defined(BASE_DIR)) ? BASE_DIR.'templates/'.$template.'/' : './../templates/'.$template.'/';
if (!is_dir($temp_dir))
return FALSE;
$directories = 0;
$res = count_files($temp_dir);
$temp['name'] = $template;
$temp['files'] = $res['files'];
$temp['dirs'] = $res['dirs'];
if (file_exists($temp_dir.'info.php'))
{
include $temp_dir.'info.php';
$temp['author'] = $author;
$temp['descr'] = $description;
}
if (file_exists($temp_dir.'screenshot.png'))
$temp['screenshot'] = '/templates/'.$template.'/screenshot.png';
else
$temp['screenshot'] = FALSE;
if (count($res['missing']) > 0)
{
$temp['missing'] = TRUE;
$temp['f_missing'] = $res['missing'];
}
return $temp;
}
function count_files($dir)
{
$file_array = array('_header.php','_footer.php','_error.php','_index.php','_archive.php','_calendar.php','_comment.php','_post.php','_process_comment.php','_search.php');
$files = 0;
$directories = 0;
if (!is_dir($dir))
return FALSE;
$my_dir = opendir($dir);
while (false !== ($list = readdir($my_dir)))
{
if ($list != '.' && $list != '..')
{
if (is_dir($dir.$list.'/'))
{
$directories++;
$res = count_files($dir.$list.'/');
$files += $res['files'];
$directories += $res['dirs'];
}
else
{
$list = explode('_',$list,2);
$temp_files[] = '_'.$list[1];
$files++;
}
}
}
closedir($my_dir);
$temp_files = (is_array($temp_files)) ? $temp_files : array();
foreach ($file_array as $file)
{
if (!(in_array($file,$temp_files)))
{
$missing[] = $file;
}
}
$result['missing'] = $missing;
$result['files'] = $files;
$result['dirs'] = $directories;
return $result;
}
db();
$temps = get_templates();
if (isset($_GET['changeto']) && in_array($_GET['changeto'],$temps))
{
$sql = "UPDATE `" . $mysql["db_prefix"] . "config` SET `template` = '".$_GET['changeto']."' WHERE `id` = 1 LIMIT 1";
mysql_query($sql) or print("Couldn't change template configuration to ".$_GET['changeto']);
}
$conf = getConfig();
$_GET['temp'] = (empty($_GET['temp'])) ? 'default' : $_GET['temp'];
if (in_array($_GET['temp'],$temps))
$temp = $_GET['temp'];
else
$temp = 'default';
foreach ($temps as $template)
{
$selected = '';
if ($template == $temp)
$selected = 'selected="selected" ';
echo "<option value=\"$template\" $selected>$template</option>";
}
echo '</select></td></tr>';
$spec_info = get_template_info($temp);
echo '<tr><th colspan="2">Template Specific Data</th></tr>'."\n";
if (isset($spec_info['author']))
{
$author = $spec_info['author'];
$descr = $spec_info['descr'];
}
else
{
$author = 'Unknown';
$descr = 'Not available';
}
if ($spec_info['screenshot'] !== FALSE)
{
$screenshot = '<a href="'.$spec_info['screenshot'].'"><img src="'.$spec_info['screenshot'].'" height="80" width="80"/></a>';
}
else
{
$screenshot = 'Not available';
}
$print = <<<DOC
<tr><td style="background-color:#D6F5F0;">Template Name:</td><td style="background-color:#ADEBE0;">{$spec_info['name']}</td></tr>
<tr><td style="background-color:#D6F5F0;">Template Author:</td><td style="background-color:#ADEBE0;">$author</td></tr>
<tr><td style="background-color:#D6F5F0;">Template Files:</td><td style="background-color:#ADEBE0;">{$spec_info['files']}</td></tr>
<tr><td style="background-color:#D6F5F0;">Template Directories:</td><td style="background-color:#ADEBE0;">{$spec_info['dirs']}</td></tr>
<tr><td style="background-color:#D6F5F0;">Template Description:</td><td style="background-color:#ADEBE0;">$descr</td></tr>
<tr><td style="background-color:#D6F5F0;">Template Screenshot:</td><td style="background-color:#ADEBE0;">$screenshot</td></tr>
DOC;
echo $print;
if ($spec_info['missing'] === TRUE)
{
$miss = "<ul>";
foreach ($spec_info['f_missing'] as $file)
{
$miss .= '<li><font color="red">'.$file.'</font></li>';
}
$miss .= '</ul>';
echo '<tr><td>Warning: Those files are missing from this template<br /> HBS will use the default ones when they are requested</td><td>'.$miss.'</td></tr>';
}
$choose_temp = ($conf['template'] == $temp) ? 'You are using this template' : '<a href="themechoice.php?changeto='.$temp.'">Use this template</a>' ;
echo '<tr><td colspan="2" align="center">'.$choose_temp.'</td></table>';
?>
</td>
</tr>
</table>
</td>
</table>
<?php include("footer.php");?>
</body>
</html>