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

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/check_script.php
  5. * @version $Id$
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. require('./../config.php');
  13. require('./../includes/constants.php');
  14. require('./../includes/db.php');
  15. require('./../includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. require('./../includes/sessions.php');
  19. require('./../includes/classes/class_user.php');
  20. require('./../common.php');
  21. require('./../includes/admin/class_main.php');
  22. require('./../includes/classes/class_forum.php');
  23. require('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  24. require('./../admin/check_script_data.php');
  25. SessDelInvalid();
  26. SessRegister();
  27. SessDeleteOld();
  28. if (User::UserInformation($_SESSION['uid'],'rank')!=2)
  29. {
  30. admin_message_forum($lng['yournotadmin'],'../index.php');
  31. }
  32. $ERROR = './template/blank.tpl';
  33. //functions .. in this script
  34. function check_size_md5($file)
  35. {
  36. if ( file_exists($file) )
  37. {
  38. $result = @filesize($file);
  39. return md5($result);
  40. }
  41. else
  42. {
  43. return false;
  44. }
  45. }
  46. function mysqlversion()
  47. {
  48. $temp = '';
  49. $result = DataBase::fetch(DataBase::sql_query("SELECT VERSION() AS mysql_version",GENERAL,'Could not read mysql version.'));
  50. $result = $result['mysql_version'];
  51. for($i=0;$i<5;$i++)
  52. {
  53. $temp .= $result[$i];
  54. }
  55. $result = $temp;
  56. unset($temp);
  57. return($result);
  58. }
  59. function db_size()
  60. {
  61. $sql = "SHOW TABLE STATUS";
  62. $db_size = 0;
  63. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain database size');
  64. while ($result = DataBase::fetch($query))
  65. {
  66. $db_size += $result['Index_length'];
  67. $db_size += $result['Data_length'];
  68. }
  69. $db_size = $db_size / 1024;
  70. if ($db_size >=1024)
  71. {
  72. $db_size = $db_size / 1024;
  73. $db_size = round($db_size,2);
  74. $db_size = $db_size.'&nbsp;MB';
  75. }
  76. else
  77. {
  78. $db_size = round($db_size,2);
  79. $db_size = $db_size.'&nbsp;KB';
  80. }
  81. return $db_size;
  82. }
  83. function forum_size($path = './../')
  84. {
  85. $size = 0;
  86. if (is_dir($path))
  87. {
  88. if ($dh = opendir($path))
  89. {
  90. while (($file = readdir($dh)) !== false)
  91. {
  92. if ($file != '.' && $file != '..')
  93. {
  94. if (is_dir($path.$file))
  95. {
  96. $size+= forum_size($path.$file.'/');
  97. }
  98. else
  99. {
  100. $size+= filesize($path.$file);
  101. }
  102. }
  103. }
  104. closedir($dh);
  105. }
  106. return $size;
  107. }
  108. else
  109. {
  110. return filesize($path);
  111. }
  112. }
  113. $forum_size = forum_size();
  114. $forum_size = $forum_size / 1024;
  115. if ($forum_size >=1024)
  116. {
  117. $forum_size = $forum_size / 1024;
  118. $forum_size = round($forum_size,2);
  119. $forum_size = $forum_size.'&nbsp;MB';
  120. }
  121. else
  122. {
  123. $forum_size = round($forum_size,2);
  124. $forum_size = $forum_size.'&nbsp;KB';
  125. }
  126. $count =0;
  127. for($i=0; $i<count($script_files);$i++)
  128. {
  129. $actual = check_size_md5($script_files[$i]);
  130. $rule = $size_md5[$script_files[$i]];
  131. if ($actual!=$rule)
  132. {
  133. $count +=1;
  134. }
  135. }
  136. $sql_version = mysqlversion();
  137. $skin=array(
  138. 'main_beam'=>$lng['scriptstat'],
  139. 'L.name'=>$lng['name'],
  140. 'L.value'=>$lng['value'],
  141. //php version
  142. 'L.php_version'=>$lng['php_version'],
  143. 'PHP.version'=>phpversion(),
  144. 'PHP.value' => (phpversion()>='5.0.7') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  145. //extension MySQLi loaded?
  146. 'L.mySQLi_loaded'=>$lng['mysqli_loaded'],
  147. 'mySQLi_loaded'=>(extension_loaded('mysqli')) ? $lng['yes'] : $lng['no'],
  148. 'mySQLi_loaded.value'=> (extension_loaded('mysqli')) ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  149. //mysql version
  150. 'mySQL.version'=>$sql_version,
  151. 'L.mySQL_version'=>$lng['mysql_version'],
  152. 'mySQL.value'=>($sql_version>='4.1') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  153. //database size
  154. 'L.db_size' => $lng['db_size'],
  155. 'db_size' => db_size(),
  156. //forum size
  157. 'L.forum_size' => $lng['forum_size'],
  158. 'forum_size' => $forum_size,
  159. //catalogs writable
  160. 'L.cat_name'=>$lng['catalog'],
  161. 'cat1.name'=> $folders[0],
  162. 'cat1.value'=> (@is_writable($folders[0])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  163. 'cat2.name'=> $folders[1],
  164. 'cat2.value'=> (@is_writable($folders[1])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  165. 'cat3.name'=> $folders[2],
  166. 'cat3.value'=> (!@is_writable($folders[2])) ? '<font color="green">'.$lng['not_writable'].' - OK</font>' : '<font color="red">'.$lng['is_writable'].' Error - No OK</font>',
  167. 'successfully' => ($count <1) ? '<font color="green">'.$lng['files_is_good'].' ('.count($script_files).')</font>' : '<font color="red">'.$lng['files_not_good'].$count.'</font>'
  168. );
  169. Admin_Over::GenerateHeader();
  170. require('./template/check_script.tpl');
  171. for($i=0; $i<count($script_files);$i++)
  172. {
  173. $actual = check_size_md5($script_files[$i]);
  174. $rule = $size_md5[$script_files[$i]];
  175. if (file_exists($script_files[$i]))
  176. {
  177. if ($actual!=$rule)
  178. {
  179. $skin=array(
  180. 'L.sum_rule'=>$lng['original_sum'],
  181. 'L.sum_actual'=>$lng['actual_sum'],
  182. 'sum_rule'=>$rule,
  183. 'sum_actual'=>$actual,
  184. 'L.invalid_md5sum'=>$lng['invalid_md5sum'].' ('.substr($script_files[$i], strrpos($script_files[$i], '/') + 1, strlen($script_files[$i])).')'
  185. );
  186. require('./template/invalidfile_body.tpl');
  187. }
  188. }
  189. }
  190. require('./template/overall_footer.tpl');
  191. ?>