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.

77 line
1.6 KiB

4 年之前
  1. <?php
  2. /**
  3. * 判断语言
  4. */
  5. function lang(){
  6. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  7. if ($lang == 'zh-CN') {
  8. $lang = "zh";
  9. }
  10. return include("lang.".$lang.".php");
  11. }
  12. function L($field){
  13. if (!isset($GLOBALS['lang'])) {
  14. $GLOBALS['lang'] = lang();
  15. }
  16. return $GLOBALS['lang'][$field] ;
  17. }
  18. /**
  19. * 判断 文件/目录 是否可写(取代系统自带的 is_writeable 函数)
  20. *
  21. * @param string $file 文件/目录
  22. * @return boolean
  23. */
  24. function new_is_writeable($file) {
  25. if (is_dir($file)){
  26. $dir = $file;
  27. if ($fp = @fopen("$dir/test.txt", 'w')) {
  28. @fclose($fp);
  29. @unlink("$dir/test.txt");
  30. $writeable = 1;
  31. } else {
  32. $writeable = 0;
  33. }
  34. } else {
  35. if ($fp = @fopen($file, 'a+')) {
  36. @fclose($fp);
  37. $writeable = 1;
  38. } else {
  39. $writeable = 0;
  40. }
  41. }
  42. return $writeable;
  43. }
  44. function clear_runtime($path = "../server/Application/Runtime"){
  45. //给定的目录不是一个文件夹
  46. if(!is_dir($path)){
  47. return null;
  48. }
  49. $fh = opendir($path);
  50. while(($row = readdir($fh)) !== false){
  51. //过滤掉虚拟目录
  52. if($row == '.' || $row == '..'|| $row == 'index.html'){
  53. continue;
  54. }
  55. if(!is_dir($path.'/'.$row)){
  56. unlink($path.'/'.$row);
  57. }
  58. clear_runtime($path.'/'.$row);
  59. }
  60. //关闭目录句柄,否则出Permission denied
  61. closedir($fh);
  62. return true;
  63. }
  64. function ajax_out($message,$error_code = 0){
  65. echo json_encode(array("error_code"=>$error_code,"message"=>$message));
  66. exit();
  67. }