ERROR!';
echo '
The main configuration file does NOT exist!
';
echo 'Click ';
html_link('./install/index.php', $text = 'here', $status = 'Install S9Y_Conf', $target = '');
echo 'to installS9Y_Conf.
';
}
exit;
}
// Installed
if(!defined('S9YCONF_INSTALLED')) {
// If no headers are sent, send one
if (!headers_sent()) {
header("Location: http://" . $_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/install");
}else{
echo 'ERROR!
';
echo 'The main configuration file does NOT exist!
';
echo 'Click ';
html_link('./install/index.php', $text = 'here', $status = 'Install S9Y_Conf', $target = '');
echo 'to installS9Y_Conf.
';
}
exit;
}
// Include template functions
include_once S9YCONF_INC_PATH.'templates.functions.inc.php';
debug_msg ("FILE: ".__FILE__,3);
$referrer['host'] = '';
if (isset($_SERVER['HTTP_REFERER'])) {
$referrer = parse_url($_SERVER['HTTP_REFERER']);
}
if ($referrer['host'] != $_SERVER['SERVER_NAME']) {
header("HTTP/1.0 403 Forbidden");
echo "Access Forbidden!
\n\nThe website you came from doesn't have permission to link to the requested object.\n\nError 403
\n\n";
exit();
}
db_connect();
// Read blogid and tplid passed to us
if (isset($_GET['tplid'])) {
$tplid = $_GET['tplid'];
}else{
// Write text to standard output
header("Content-type: text/plain");
echo "Error in creating template\n";
}
// Set System template variables
$NOW = date('r');
$S9YCONF = S9YCONF_PROGRAM_NAME.' v'.S9YCONF_VERSION;
// Set template variables
$templatevars = db_multirec_read_all_templatevars();
// Set specific template variables
$templatedata = db_read_templates($tplid);
$TEMPLATE_ID = $templatedata['id'];
$TEMPLATE_NAME = $templatedata['name'];
$TEMPLATE_DESCRIPTION = $templatedata['description'];
// Template contents
$template_contents = html_entity_decode($templatedata['template'], ENT_COMPAT, LANG_CHARSET);
// Expand the template variables recursively
$templatevars = expand_templatevars($templatevars);
// Insert system template variables
$template_contents = str_replace('{NOW}', $NOW, $template_contents);
$template_contents = str_replace('{S9YCONF}', $S9YCONF, $template_contents);
/*
$template_contents = str_replace('{SUDO}', $SUDO, $template_contents);
$template_contents = str_replace('{LIBDIR}', $LIBDIR, $template_contents);
$template_contents = str_replace('{S9YDIR}', $S9YDIR, $template_contents);
$template_contents = str_replace('{WWWGROUP}', $WWWGROUP, $template_contents);
$template_contents = str_replace('{WWWUSER}', $WWWUSER, $template_contents);
*/
foreach ($templatevars as $tplvar) {
$template_contents = str_replace('{'.$tplvar['name'].'}', html_entity_decode($tplvar['value'], ENT_COMPAT, LANG_CHARSET), $template_contents);
}
// Insert specific template template variables
$template_contents = str_replace('{TPLID}', $TEMPLATE_ID, $template_contents);
$template_contents = str_replace('{TPLNAME}', $TEMPLATE_NAME, $template_contents);
$template_contents = str_replace('{TPLDESC}', $TEMPLATE_DESCRIPTION, $template_contents);
$template_output = '';
$result = db_select_all_blogdata();
while($row = mysql_fetch_assoc($result)) {
$template_temp = $template_contents;
// Set specific Blog template variables
$BLOGID = $row['uid'];
$BLOGNAME = $row['name'];
$BLOGPATH = $row['blog_path'];
$BLOGUSER = $row['user'];
$BLOGURL = $row['url'];
// Insert specific blog template variables
$template_temp = str_replace('{BLOGID}', $BLOGID, $template_temp);
$template_temp = str_replace('{BLOGNAME}', $BLOGNAME, $template_temp);
$template_temp = str_replace('{BLOGPATH}', $BLOGPATH, $template_temp);
$template_temp = str_replace('{BLOGUSER}', $BLOGUSER, $template_temp);
$template_temp = str_replace('{BLOGURL}', $BLOGURL, $template_temp);
$template_output = $template_output.$template_temp."\r\n\r\n";
}
// Remove \r from line endings for Unix/Linux
$template_output = str_replace("\r\n", "\n", $template_output);
// Write text to standard output
header("Content-type: text/plain");
echo $template_output."\n";
?>