Yabadoo
21st July 2008, 23:10
The following php code is used in a part of an index.php file which is a part of my website.
if ($config['webmessage_DBstatus'] == 1) {
$query = mysql_query("SELECT * FROM newsgroups LIMIT 1");
$result = mysql_fetch_array($query);
echo '<br>';
echo '<br>';
echo 'Database Size: '. showdbsize(). '<br>';
echo 'Current Retention: '. avgRetention() . ' days<br>';
echo 'Amount of Files in database: '. GetFileCount().'<br>';
echo 'Amount of headers in database: '. GetHeaderCount().'<br>';
}
Because this takes to much cpu load i want to do this in a seperate php file which i can run in cron job once every 2 hours.
So i want to write the result of this file tot a .cache file.
I use the 2 php file's listed below.
hour.cron.php
<?
include_once "../inc/functions.inc.php";
GetConfig(1);
include_once "other.functions.php";
cache_dbstatuse();
?>
other.functions.php
<?
if(!function_exists('file_put_contents'))
{
function file_put_contents ($filename, $data)
{
if($fp = fopen($filename, 'w'))
{
fwrite($fp, $data);
fclose($fp);
return true;
}else{
return false;
}
}
}
function cache_dbstatus()
{
$content = $config['web_title'];
file_put_contents ('../cache/dbstatus.cache', $content);
}
?>
I don't now how to program the above listed code from my index file to write it to the file ..cache/webtitle.cache...
Any help is welkom!
Thanks in advance.
if ($config['webmessage_DBstatus'] == 1) {
$query = mysql_query("SELECT * FROM newsgroups LIMIT 1");
$result = mysql_fetch_array($query);
echo '<br>';
echo '<br>';
echo 'Database Size: '. showdbsize(). '<br>';
echo 'Current Retention: '. avgRetention() . ' days<br>';
echo 'Amount of Files in database: '. GetFileCount().'<br>';
echo 'Amount of headers in database: '. GetHeaderCount().'<br>';
}
Because this takes to much cpu load i want to do this in a seperate php file which i can run in cron job once every 2 hours.
So i want to write the result of this file tot a .cache file.
I use the 2 php file's listed below.
hour.cron.php
<?
include_once "../inc/functions.inc.php";
GetConfig(1);
include_once "other.functions.php";
cache_dbstatuse();
?>
other.functions.php
<?
if(!function_exists('file_put_contents'))
{
function file_put_contents ($filename, $data)
{
if($fp = fopen($filename, 'w'))
{
fwrite($fp, $data);
fclose($fp);
return true;
}else{
return false;
}
}
}
function cache_dbstatus()
{
$content = $config['web_title'];
file_put_contents ('../cache/dbstatus.cache', $content);
}
?>
I don't now how to program the above listed code from my index file to write it to the file ..cache/webtitle.cache...
Any help is welkom!
Thanks in advance.