10-20-2000, 04:37 AM
I was experimenting with reading template from disk instead of the database. Following is my instructions on how to do this if you want to try it on your forum and see if it helps or makes it worse. Let me know if you try it, it does work as it is running on my forum at the moment but I can't say if it helped as my forum is small.
first
Make a directory called templates under your forums directory. If you don't have access to write files from php you will need to do this also:
chmod 777 templates
Next place this code in a file, temp.php and run it from your browser. It will take your templates and place them in files in the templates directory. Make sure to run it from your forums directory
<?
$tempdir = "templates/";
require ("global.php");
$query = $DB_site->query("SELECT title, template FROM template");
while ($q = $DB_site->fetch_array($query))
{
$template = $tempdir . $q[title] . ".inc.php";
$fp = fopen($template, "w");
if ($fp)
{
fwrite($fp, $q[template]);
echo "Created $q[title].inc.php<br>";
}
else
{
echo "Error opening $q[title].inc.php<br>";
}
}
NEXT
Edit global.php
Look for ###################### Start gettemplate #######################
Remove everything between that line and this line
###################### Start verifyid #######################
In between those two lines place in :
function gettemplate($templatename,$escape=1) {
// gets a template from the db or from the local cache
global $templatecache,$DB_site;
if (!$templatecache[$templatename])
{
$template = "templates/" . $templatename . ".inc.php";
$x = error_reporting();
error_reporting (0);
$file = fopen($template, "r");
$rf = fread($file, filesize ($template));
if(!$rf)
{
$template = "Error Opening Template $templatename.inc.php";
}
else
{
$template = $rf;
fclose($file);
}
error_reporting ($x);
if ($escape==1) {
$template=str_replace("\"","\\\"",$template);
}
$templatecache["$templatename"]=$template;
}
else
{
$template = $templatecache[$templatename];
}
return $template;
}
NEXT
Look for
// ###################### Start templates #######################
//prepare default templates **********************
$temps=$DB_site->query("SELECT template,title FROM template WHERE title='cssinclude' OR title='header' OR title='footer' OR title='fivelinks' OR title='jumpforumbit' OR title='forumjump'");
while ($temp=$DB_site->fetch_array($temps)) {
$templatecache["$temp[title]"]=$temp[template];
}
Remove it or comment it all out.
Let me know!
first
Make a directory called templates under your forums directory. If you don't have access to write files from php you will need to do this also:
chmod 777 templates
Next place this code in a file, temp.php and run it from your browser. It will take your templates and place them in files in the templates directory. Make sure to run it from your forums directory
<?
$tempdir = "templates/";
require ("global.php");
$query = $DB_site->query("SELECT title, template FROM template");
while ($q = $DB_site->fetch_array($query))
{
$template = $tempdir . $q[title] . ".inc.php";
$fp = fopen($template, "w");
if ($fp)
{
fwrite($fp, $q[template]);
echo "Created $q[title].inc.php<br>";
}
else
{
echo "Error opening $q[title].inc.php<br>";
}
}
NEXT
Edit global.php
Look for ###################### Start gettemplate #######################
Remove everything between that line and this line
###################### Start verifyid #######################
In between those two lines place in :
function gettemplate($templatename,$escape=1) {
// gets a template from the db or from the local cache
global $templatecache,$DB_site;
if (!$templatecache[$templatename])
{
$template = "templates/" . $templatename . ".inc.php";
$x = error_reporting();
error_reporting (0);
$file = fopen($template, "r");
$rf = fread($file, filesize ($template));
if(!$rf)
{
$template = "Error Opening Template $templatename.inc.php";
}
else
{
$template = $rf;
fclose($file);
}
error_reporting ($x);
if ($escape==1) {
$template=str_replace("\"","\\\"",$template);
}
$templatecache["$templatename"]=$template;
}
else
{
$template = $templatecache[$templatename];
}
return $template;
}
NEXT
Look for
// ###################### Start templates #######################
//prepare default templates **********************
$temps=$DB_site->query("SELECT template,title FROM template WHERE title='cssinclude' OR title='header' OR title='footer' OR title='fivelinks' OR title='jumpforumbit' OR title='forumjump'");
while ($temp=$DB_site->fetch_array($temps)) {
$templatecache["$temp[title]"]=$temp[template];
}
Remove it or comment it all out.
Let me know!