A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

203 lines
5.4 KiB

<?php
/**
* @package uForum
* @file admin/check_script.php
* @version $Id$
* @copyright 2007-2010 (c) PioDer <[email protected]>
* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
define('IN_uF', true);
//include files
include('./../config.php');
include('./../includes/constants.php');
include('./../includes/db.php');
include('./../includes/errors.php');
//connect to database
DataBase::db_connect();
include('./../includes/sessions.php');
include('./../includes/classes/class_user.php');
include('./../common.php');
include('./../includes/admin/class_main.php');
include('./../includes/classes/class_forum.php');
include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
include('./../admin/check_script_data.php');
SessDelInvalid();
SessRegister();
SessDeleteOld();
if (User::UserInformation($_SESSION['uid'],'rank')!=2)
{
admin_message_forum($lng['yournotadmin'],'../index.php');
}
$ERROR = './template/blank.tpl';
//functions .. in this script
function check_size_md5($file)
{
if ( file_exists($file) )
{
$result = @filesize($file);
return md5($result);
}
else
{
return false;
}
}
function mysqlversion()
{
$temp = '';
$result = DataBase::fetch(DataBase::sql_query("SELECT VERSION() AS mysql_version",GENERAL,'Could not read mysql version.'));
$result = $result['mysql_version'];
for($i=0;$i<5;$i++)
{
$temp .= $result[$i];
}
$result = $temp;
unset($temp);
return($result);
}
function db_size()
{
$sql = "SHOW TABLE STATUS";
$db_size = 0;
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain database size');
while ($result = DataBase::fetch($query))
{
$db_size += $result['Index_length'];
$db_size += $result['Data_length'];
}
$db_size = $db_size / 1024;
if ($db_size >=1024)
{
$db_size = $db_size / 1024;
$db_size = round($db_size,2);
$db_size = $db_size.'&nbsp;MB';
}
else
{
$db_size = round($db_size,2);
$db_size = $db_size.'&nbsp;KB';
}
return $db_size;
}
function forum_size($path = './../')
{
$size = 0;
if (is_dir($path))
{
if ($dh = opendir($path))
{
while (($file = readdir($dh)) !== false)
{
if ($file != '.' && $file != '..')
{
if (is_dir($path.$file))
{
$size+= forum_size($path.$file.'/');
}
else
{
$size+= filesize($path.$file);
}
}
}
closedir($dh);
}
return $size;
}
else
{
return filesize($path);
}
}
$forum_size = forum_size();
$forum_size = $forum_size / 1024;
if ($forum_size >=1024)
{
$forum_size = $forum_size / 1024;
$forum_size = round($forum_size,2);
$forum_size = $forum_size.'&nbsp;MB';
}
else
{
$forum_size = round($forum_size,2);
$forum_size = $forum_size.'&nbsp;KB';
}
$count =0;
for($i=0; $i<count($script_files);$i++)
{
$actual = check_size_md5($script_files[$i]);
$rule = $size_md5[$script_files[$i]];
if ($actual!=$rule)
{
$count +=1;
}
}
$sql_version = mysqlversion();
$skin=array(
'main_beam'=>$lng['scriptstat'],
'L.name'=>$lng['name'],
'L.value'=>$lng['value'],
//php version
'L.php_version'=>$lng['php_version'],
'PHP.version'=>phpversion(),
'PHP.value' => (phpversion()>='5.0.7') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
//extension MySQLi loaded?
'L.mySQLi_loaded'=>$lng['mysqli_loaded'],
'mySQLi_loaded'=>(extension_loaded('mysqli')) ? $lng['yes'] : $lng['no'],
'mySQLi_loaded.value'=> (extension_loaded('mysqli')) ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
//mysql version
'mySQL.version'=>$sql_version,
'L.mySQL_version'=>$lng['mysql_version'],
'mySQL.value'=>($sql_version>='4.1') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
//database size
'L.db_size' => $lng['db_size'],
'db_size' => db_size(),
//forum size
'L.forum_size' => $lng['forum_size'],
'forum_size' => $forum_size,
//catalogs writable
'L.cat_name'=>$lng['catalog'],
'cat1.name'=> $folders[0],
'cat1.value'=> (@is_writable($folders[0])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
'cat2.name'=> $folders[1],
'cat2.value'=> (@is_writable($folders[1])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
'cat3.name'=> $folders[2],
'cat3.value'=> (!@is_writable($folders[2])) ? '<font color="green">'.$lng['not_writable'].' - OK</font>' : '<font color="red">'.$lng['is_writable'].' Error - No OK</font>',
'successfully' => ($count <1) ? '<font color="green">'.$lng['files_is_good'].' ('.count($script_files).')</font>' : '<font color="red">'.$lng['files_not_good'].$count.'</font>'
);
Admin_Over::GenerateHeader();
include('./template/check_script.tpl');
for($i=0; $i<count($script_files);$i++)
{
$actual = check_size_md5($script_files[$i]);
$rule = $size_md5[$script_files[$i]];
if (file_exists($script_files[$i]))
{
if ($actual!=$rule)
{
$skin=array(
'L.sum_rule'=>$lng['original_sum'],
'L.sum_actual'=>$lng['actual_sum'],
'sum_rule'=>$rule,
'sum_actual'=>$actual,
'L.invalid_md5sum'=>$lng['invalid_md5sum'].' ('.substr($script_files[$i], strrpos($script_files[$i], '/') + 1, strlen($script_files[$i])).')'
);
include('./template/invalidfile_body.tpl');
}
}
}
include('./template/overall_footer.tpl');
?>