Added files - test
git-svn-id: https://svn.pioder.pl/uf-svn/uF@11 72ec579a-5ced-4fa4-82f3-afba5d98df2f
This commit is contained in:
197
admin/check_script.php
Normal file
197
admin/check_script.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* @package µForum
|
||||
* @file admin/check_script.php
|
||||
* @version 1.0.x, 16-05-2008, 20:25
|
||||
* @copyright 2008(c) PioDer <pioder@wp.pl>
|
||||
* @link http://pioder.gim2przemysl.int.pl/dsf.html
|
||||
* @license GNU GPL v3
|
||||
**/
|
||||
define('IN_uF', true);
|
||||
//include files
|
||||
include('./../config.php');
|
||||
include('./../includes/constants.php');
|
||||
include('./../includes/class_db.php');
|
||||
include('./../includes/class_error.php');
|
||||
//connect to database
|
||||
DataBase::db_connect();
|
||||
include('./../includes/sessions.php');
|
||||
include('./../includes/class_user.php');
|
||||
include('./../common.php');
|
||||
include('./../includes/admin/class_main.php');
|
||||
include('./../includes/class_forum.php');
|
||||
include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
|
||||
include('./../admin/check_script_data.php');
|
||||
sess_del_invalid($_SESSION['uid']);
|
||||
sess_register($_SESSION['uid']);
|
||||
sess_delete_old();
|
||||
|
||||
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 = mysql_fetch_array(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 = @mysql_fetch_array($query))
|
||||
{
|
||||
$db_size += $result['Index_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.' MB';
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_size = round($db_size,2);
|
||||
$db_size = $db_size.' 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.' MB';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_size = round($forum_size,2);
|
||||
$forum_size = $forum_size.' 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()>='4.3.10') ? '<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');
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user