bom.ctrl.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. set_time_limit(0);
  8. load()->func('file');
  9. if (checksubmit('submit')) {
  10. $path = IA_ROOT;
  11. $trees = file_tree($path);
  12. $bomtree = array();
  13. foreach ($trees as $tree) {
  14. $tree = str_replace($path, '', $tree);
  15. $tree = str_replace('\\', '/', $tree);
  16. if (strexists($tree, '.php')) {
  17. $fname = $path . $tree;
  18. $fp = fopen($fname, 'r');
  19. if (!empty($fp)) {
  20. $bom = fread($fp, 3);
  21. fclose($fp);
  22. if ($bom == "\xEF\xBB\xBF") {
  23. $bomtree[] = $tree;
  24. }
  25. }
  26. }
  27. }
  28. cache_write(cache_system_key('bomtree'), $bomtree);
  29. }
  30. if (checksubmit('dispose')) {
  31. $trees = cache_load(cache_system_key('bomtree'));
  32. $path = IA_ROOT;
  33. if (is_array($trees)) {
  34. foreach ($trees as $tree) {
  35. $fname = $path . $tree;
  36. $string = file_get_contents($fname);
  37. $string = substr($string, 3);
  38. file_put_contents($fname, $string);
  39. @fclose($fp);
  40. }
  41. }
  42. cache_delete(cache_system_key('bomtree'));
  43. }
  44. template('system/bom');