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.

202 lines
5.4 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file admin/check_script.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. include('./../config.php');
  13. include('./../includes/constants.php');
  14. include('./../includes/db.php');
  15. include('./../includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./../includes/sessions.php');
  19. include('./../includes/classes/class_user.php');
  20. include('./../common.php');
  21. include('./../includes/admin/class_main.php');
  22. include('./../includes/classes/class_forum.php');
  23. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  24. include('./../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. }
  68. $db_size = $db_size / 1024;
  69. if ($db_size >=1024)
  70. {
  71. $db_size = $db_size / 1024;
  72. $db_size = round($db_size,2);
  73. $db_size = $db_size.'&nbsp;MB';
  74. }
  75. else
  76. {
  77. $db_size = round($db_size,2);
  78. $db_size = $db_size.'&nbsp;KB';
  79. }
  80. return $db_size;
  81. }
  82. function forum_size($path = './../')
  83. {
  84. $size = 0;
  85. if (is_dir($path))
  86. {
  87. if ($dh = opendir($path))
  88. {
  89. while (($file = readdir($dh)) !== false)
  90. {
  91. if ($file != '.' && $file != '..')
  92. {
  93. if (is_dir($path.$file))
  94. {
  95. $size+= forum_size($path.$file.'/');
  96. }
  97. else
  98. {
  99. $size+= filesize($path.$file);
  100. }
  101. }
  102. }
  103. closedir($dh);
  104. }
  105. return $size;
  106. }
  107. else
  108. {
  109. return filesize($path);
  110. }
  111. }
  112. $forum_size = forum_size();
  113. $forum_size = $forum_size / 1024;
  114. if ($forum_size >=1024)
  115. {
  116. $forum_size = $forum_size / 1024;
  117. $forum_size = round($forum_size,2);
  118. $forum_size = $forum_size.'&nbsp;MB';
  119. }
  120. else
  121. {
  122. $forum_size = round($forum_size,2);
  123. $forum_size = $forum_size.'&nbsp;KB';
  124. }
  125. $count =0;
  126. for($i=0; $i<count($script_files);$i++)
  127. {
  128. $actual = check_size_md5($script_files[$i]);
  129. $rule = $size_md5[$script_files[$i]];
  130. if ($actual!=$rule)
  131. {
  132. $count +=1;
  133. }
  134. }
  135. $sql_version = mysqlversion();
  136. $skin=array(
  137. 'main_beam'=>$lng['scriptstat'],
  138. 'L.name'=>$lng['name'],
  139. 'L.value'=>$lng['value'],
  140. //php version
  141. 'L.php_version'=>$lng['php_version'],
  142. 'PHP.version'=>phpversion(),
  143. 'PHP.value' => (phpversion()>='5.0.7') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  144. //extension MySQLi loaded?
  145. 'L.mySQLi_loaded'=>$lng['mysqli_loaded'],
  146. 'mySQLi_loaded'=>(extension_loaded('mysqli')) ? $lng['yes'] : $lng['no'],
  147. 'mySQLi_loaded.value'=> (extension_loaded('mysqli')) ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  148. //mysql version
  149. 'mySQL.version'=>$sql_version,
  150. 'L.mySQL_version'=>$lng['mysql_version'],
  151. 'mySQL.value'=>($sql_version>='4.1') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  152. //database size
  153. 'L.db_size' => $lng['db_size'],
  154. 'db_size' => db_size(),
  155. //forum size
  156. 'L.forum_size' => $lng['forum_size'],
  157. 'forum_size' => $forum_size,
  158. //catalogs writable
  159. 'L.cat_name'=>$lng['catalog'],
  160. 'cat1.name'=> $folders[0],
  161. 'cat1.value'=> (@is_writable($folders[0])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  162. 'cat2.name'=> $folders[1],
  163. 'cat2.value'=> (@is_writable($folders[1])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  164. 'cat3.name'=> $folders[2],
  165. 'cat3.value'=> (!@is_writable($folders[2])) ? '<font color="green">'.$lng['not_writable'].' - OK</font>' : '<font color="red">'.$lng['is_writable'].' Error - No OK</font>',
  166. 'successfully' => ($count <1) ? '<font color="green">'.$lng['files_is_good'].' ('.count($script_files).')</font>' : '<font color="red">'.$lng['files_not_good'].$count.'</font>'
  167. );
  168. Admin_Over::GenerateHeader();
  169. include('./template/check_script.tpl');
  170. for($i=0; $i<count($script_files);$i++)
  171. {
  172. $actual = check_size_md5($script_files[$i]);
  173. $rule = $size_md5[$script_files[$i]];
  174. if (file_exists($script_files[$i]))
  175. {
  176. if ($actual!=$rule)
  177. {
  178. $skin=array(
  179. 'L.sum_rule'=>$lng['original_sum'],
  180. 'L.sum_actual'=>$lng['actual_sum'],
  181. 'sum_rule'=>$rule,
  182. 'sum_actual'=>$actual,
  183. 'L.invalid_md5sum'=>$lng['invalid_md5sum'].' ('.substr($script_files[$i], strrpos($script_files[$i], '/') + 1, strlen($script_files[$i])).')'
  184. );
  185. include('./template/invalidfile_body.tpl');
  186. }
  187. }
  188. }
  189. include('./template/overall_footer.tpl');
  190. ?>