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.

197 lines
5.1 KiB

  1. <?php
  2. /**
  3. * @package µForum
  4. * @file admin/check_script.php
  5. * @version 1.0.x, 16-05-2008, 20:25
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  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/class_db.php');
  15. include('./../includes/class_error.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./../includes/sessions.php');
  19. include('./../includes/class_user.php');
  20. include('./../common.php');
  21. include('./../includes/admin/class_main.php');
  22. include('./../includes/class_forum.php');
  23. include('./../lngs/'.Admin_Over::DefaultLang().'/admin.php');
  24. include('./../admin/check_script_data.php');
  25. sess_del_invalid($_SESSION['uid']);
  26. sess_register($_SESSION['uid']);
  27. sess_delete_old();
  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 = mysql_fetch_array(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 = @mysql_fetch_array($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()>='4.3.10') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  144. //mysql version
  145. 'mySQL.version'=>$sql_version,
  146. 'L.mySQL_version'=>$lng['mysql_version'],
  147. 'mySQL.value'=>($sql_version>='4.1') ? '<font color="green">OK</font>' : ' <font color="red">Error - No OK</font>',
  148. //database size
  149. 'L.db_size' => $lng['db_size'],
  150. 'db_size' => db_size(),
  151. //forum size
  152. 'L.forum_size' => $lng['forum_size'],
  153. 'forum_size' => $forum_size,
  154. //catalogs writable
  155. 'L.cat_name'=>$lng['catalog'],
  156. 'cat1.name'=> $folders[0],
  157. 'cat1.value'=> (@is_writable($folders[0])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  158. 'cat2.name'=> $folders[1],
  159. 'cat2.value'=> (@is_writable($folders[1])) ? '<font color="green">'.$lng['is_writable'].' - OK</font>' : '<font color="red">'.$lng['not_writable'].' Error - No OK</font>',
  160. 'cat3.name'=> $folders[2],
  161. 'cat3.value'=> (!@is_writable($folders[2])) ? '<font color="green">'.$lng['not_writable'].' - OK</font>' : '<font color="red">'.$lng['is_writable'].' Error - No OK</font>',
  162. 'successfully' => ($count <1) ? '<font color="green">'.$lng['files_is_good'].' ('.count($script_files).')</font>' : '<font color="red">'.$lng['files_not_good'].$count.'</font>'
  163. );
  164. Admin_Over::GenerateHeader();
  165. include('./template/check_script.tpl');
  166. for($i=0; $i<count($script_files);$i++)
  167. {
  168. $actual = check_size_md5($script_files[$i]);
  169. $rule = $size_md5[$script_files[$i]];
  170. if (file_exists($script_files[$i]))
  171. {
  172. if ($actual!=$rule)
  173. {
  174. $skin=array(
  175. 'L.sum_rule'=>$lng['original_sum'],
  176. 'L.sum_actual'=>$lng['actual_sum'],
  177. 'sum_rule'=>$rule,
  178. 'sum_actual'=>$actual,
  179. 'L.invalid_md5sum'=>$lng['invalid_md5sum'].' ('.substr($script_files[$i], strrpos($script_files[$i], '/') + 1, strlen($script_files[$i])).')'
  180. );
  181. include('./template/invalidfile_body.tpl');
  182. }
  183. }
  184. }
  185. include('./template/overall_footer.tpl');
  186. ?>