// Write text to standard output header("Content-type: text/plain"); echo "Error in creating template\n"; } } 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 Blog template variables $blogdata = db_read_blogdata($blogid); $BLOGID = $blogid; $BLOGNAME = $blogdata['name']; $BLOGPATH = $blogdata['blog_path']; $BLOGUSER = $blogdata['user']; $BLOGURL = $blogdata['url']; // 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
function blogdata_view($blogid = '', $tplid = '') { debug_msg("FUNCTION: " . __FUNCTION__, 3); // Create navigation form // Read template data to create selection list $result = db_multirec_read_all_templates(); debug_msg("Query Result: {$result}", 5); $num_records = count($result); debug_msg("Number of records: {$num_records}", 4); if ($num_records > 0) { $tplselect = ''; foreach ($result as $row) { if ($row['id'] == $tplid) { $tplselect = $tplselect . '<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>'; } else { $tplselect = $tplselect . '<option value="' . $row['id'] . '">' . $row['name'] . '</option>'; } } } $navform = '<form action="blogdata.php" method="post"><select name="tplid">' . $tplselect . '</select><br /><br /><input type="hidden" name="uid" value="' . $blogid . '" /><button name="action" value="view" type="submit">View Template Output</button><br /><br /><button name="action" value="viewall" type="submit">Process all blogs with template</button><br /><br /><button name="action" value="back" type="submit">Back to Blog Data</button></form>'; // 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 Blog template variables $blogdata = db_read_blogdata($blogid); $BLOGID = $blogid; $BLOGNAME = $blogdata['name']; $BLOGPATH = $blogdata['blog_path']; $BLOGUSER = $blogdata['user']; $BLOGURL = $blogdata['url']; // 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 blog template variables $template_contents = str_replace('{BLOGID}', $BLOGID, $template_contents); $template_contents = str_replace('{BLOGNAME}', $BLOGNAME, $template_contents); $template_contents = str_replace('{BLOGPATH}', $BLOGPATH, $template_contents); $template_contents = str_replace('{BLOGUSER}', $BLOGUSER, $template_contents); $template_contents = str_replace('{BLOGURL}', $BLOGURL, $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); html_header("S9Y_Conf Output of the template '{$TEMPLATE_DESCRIPTION}' for Blog '{$BLOGNAME}'"); echo $navform . "<br />"; echo "Output of the template '" . $TEMPLATE_NAME . "' for blog '" . $BLOGNAME . "'<br />"; echo "<br />"; echo "Click <a href=\"tplfile.php?blogid={$blogid}&tplid={$tplid}\" onmouseover=\"window.status='Click to download template contents';return true\" onmouseout=\"window.status='';return true\">here</a> to download"; echo '<hr /><div class="left">'; echo nl2br(htmlentities($template_contents, ENT_COMPAT, LANG_CHARSET)); echo "</div><hr />"; echo "Click <a href=\"tplfile.php?blogid={$blogid}&tplid={$tplid}\" onmouseover=\"window.status='Click to download template contents';return true\" onmouseout=\"window.status='';return true\">here</a> to download"; echo "<br />"; echo "<br />" . $navform . "<br />"; html_footer(); }