file_manage.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. define('CURSCRIPT', 'file_manage');
  4. require_once dirname(__FILE__) . '/global.php';
  5. require_once MYMPS_DATA . '/config.inc.php';
  6. require_once MYMPS_INC . '/db.class.php';
  7. $part = $part ? $part : 'template';
  8. if ($downfile) {
  9. !is_file($downfile) && write_msg('您要下载的文件不存在!');
  10. FileExt($downfile) == 'php' && write_msg('该文件不允许下载!');
  11. $filename = basename($downfile);
  12. $filename_info = explode('.', $filename);
  13. $fileext = $filename_info[count($filename_info) - 1];
  14. header('Content-type: application/x-' . $fileext);
  15. header('Content-Disposition: attachment; filename=' . $filename);
  16. header('Content-Description: PHP3 Generated Data');
  17. readfile($downfile);
  18. exit;
  19. }
  20. if ($delfile != '') {
  21. $part == 'template' && write_msg('模板文件不能删除,请手动在FTP目录中将其删除!');
  22. (FileExt($delfile) == 'php' || FileExt($delfile) == 'css' || FileExt($delfile) == 'js' || FileExt($delfile) == 'html') && write_msg('该文件不允许删除,请在FTP目录中手动删除!');
  23. if (file_exists($delfile)) {
  24. @unlink($delfile);
  25. $msgs[] = '成功删除文件<br /><br />' . $delfile;
  26. $msgs[] = '<a href="' . $url . '">点此返回 &raquo;</a>';
  27. show_msg($msgs);
  28. } else {
  29. write_msg('文件已不存在!');
  30. }
  31. exit;
  32. }
  33. $cfg_if_tpledit = $mymps_mymps['cfg_if_tpledit'] == 0 ? '<font color=green>已关闭</font>' : '<font color=red>已开启</font>';
  34. switch ($part) {
  35. case 'template':
  36. chk_admin_purview('purview_模板管理');
  37. $here = '模板在线管理';
  38. $mulu = 'Mymps模板目录';
  39. $showdir = MYMPS_TPL . '/default';
  40. if ($editfile && $do == 'update') {
  41. if ($mymps_mymps['cfg_if_tpledit'] == '0') {
  42. write_msg('操作失败!系统管理员关闭了在线编辑风格的功能!<br /><br />您可以修改/dat/config.inc.php来开启它');
  43. }
  44. $content = str_replace('&amp;', '&', trim($content));
  45. $content = str_replace('&quot;', '"', trim($content));
  46. $nowfile = trim($editfile);
  47. if (!is_file($nowfile)) {
  48. write_msg('对不起,该文件不存在!');
  49. }
  50. $norootfile = str_replace(MYMPS_ROOT . '/template', '', $nowfile);
  51. if ($db->getOne('SELECT content FROM `' . $db_mymps . 'template` WHERE filepath LIKE \'' . $norootfile . '\'')) {
  52. $update_sql = $db->query('UPDATE `' . $db_mymps . 'template` SET content = \'' . $content . '\' WHERE filepath = \'' . $norootfile . '\'');
  53. } else {
  54. $db->query('INSERT INTO `' . $db_mymps . 'template` (filepath,content) VALUES (\'' . $norootfile . '\',\'' . $content . '\')');
  55. }
  56. $row = $db->getRow('SELECT filepath,content FROM `' . $db_mymps . 'template` WHERE filepath = \'' . $norootfile . '\'');
  57. if (!$row) {
  58. write_msg('操作失败!');
  59. exit;
  60. }
  61. $create_c = createfile($nowfile, $row[content]);
  62. if ($create_c) {
  63. write_msg('模板文件' . $nowfile . '<br /><br />修改成功', $url, 'MyMps');
  64. } else {
  65. write_msg('模板文件' . $nowfile . '无法修改<br /><br />请检查template目录的操作权限!');
  66. }
  67. } else {
  68. if ($editfile && empty($do)) {
  69. $ext = FileExt($editfile);
  70. if ($ext != 'html' && $ext != 'css' && $ext != 'htm' && $ext != 'js') {
  71. write_msg('该文件不能在线编辑!');
  72. }
  73. if (!($edit = file_get_contents($editfile))) {
  74. write_msg('该文件不可读,请检查该文件的操作权限');
  75. }
  76. $path = str_replace('/' . end(explode('/', $editfile)), '', $editfile);
  77. $edit = htmlspecialchars($edit);
  78. $acontent = '<textarea name="content" cols="110" rows="25">' . $edit . '</textarea>';
  79. include mymps_tpl('template_edit');
  80. exit;
  81. }
  82. }
  83. break;
  84. case 'upload':
  85. chk_admin_purview('purview_附件管理');
  86. $here = '系统上传附件管理';
  87. $mulu = '系统附件目录';
  88. $showdir = MYMPS_UPLOAD;
  89. break;
  90. }
  91. $path = trim($path) ? trim($path) : $showdir;
  92. $path2 = explode('/', $path);
  93. $path2 = '/' . end($path2);
  94. $LastPath = str_replace($path2, '', $path);
  95. $con = explode($showdir, $CurrentPath);
  96. include mymps_tpl(CURSCRIPT);
  97. is_object($db) && $db->Close();
  98. $db = $mymps_global = $part = $action = $here = NULL;