Просмотр файла admin_list/file.php

Размер файла: 2.81Kb
  1. <?PHP
  2. define('SHCMS', true);
  3. include_once'../system/inc/basic_settings.php';
  4. $shcmsengine['title'] = 'SHCMS Engine - Управление файлами';
  5. include_once'../template/head.php';
  6. registrat();
  7. $adminka->admin();
  8.  
  9. if($_POST['submit'])
  10. {
  11. if($_POST['filename']) {
  12. $data = $_POST['fileentry'];
  13. $data = get_magic_quotes_gpc() ? stripslashes($data) : $data;
  14. $fp = fopen($_POST['filename'], 'w');
  15. fwrite($fp, $data);
  16. fclose($fp);
  17. messag('Настройки файла '.$_POST['filename'].'');
  18. }
  19. }
  20. switch($act):
  21. case '':
  22.  
  23. if($_GET['path']) {
  24. $path=$_GET['path'];
  25. }
  26. else {
  27. $path=$_GET['path']='../template/designs/';
  28. }
  29. if(strlen($_SERVER['DOCUMENT_ROOT'])<strlen($path))
  30. {
  31. echo '<p class="posts"><a href="?path='.substr($path, 0, strrpos($path, '/')).'"><strong>../ назад</strong></a></p>';
  32. }
  33. foreach(glob($path.'/*') as $obj) {
  34. $filename=substr($obj, strlen($path)+1, strlen($obj)-strlen($path));
  35. if(is_dir($obj)) {
  36. echo '<p class="posts"><img src="../template/icon/dir.png"> <a href="?path='.$obj.'">'.$filename.'/</a></p>';
  37. }
  38. else {
  39. if($_GET['path']) {
  40. echo '<p class="posts"><img src="../template/icon/edit.png"> <a href="?act=edit&path='.$_GET['path'].'&file='.$obj.'">'.$filename.'</a></p>';
  41. }
  42. else{
  43. echo '<p class="posts"><a href="?file='.$obj.'"></a></p>';
  44. }
  45. }
  46. }
  47. break;
  48. case 'edit':
  49. if($_GET['path']){
  50. echo '<form action="?act=edit&path='.$_GET['path'].'&file='.$_GET['file'].'" method=post>';
  51. }
  52. else {
  53. echo '<form action="?" method="post">';
  54. }
  55. if($_GET['file']) {
  56. $filename=$_GET['file'];
  57. echo '<div class="posts">Путь файла: <b>'.$filename.'</b><br/>';
  58. echo 'Для поиска по шаблону используйте горячие клавиши: Ctrl-F начать поиск, Ctrl-G продолжить поиск.</div>';
  59. echo '<input type=hidden name=filename value="'.$filename.'">';
  60. }
  61. else {
  62. echo 'Ничего не выбрано';
  63. }
  64. echo '<textarea rows=40; style="width:98%; height:300px;font-size:14px;" name=fileentry>';
  65. if($_GET['file']) {
  66. $filerows=file($filename);
  67. foreach($filerows as $value) {
  68. echo htmlspecialchars($value);
  69. }
  70. }
  71. echo '</textarea>';
  72. echo '<input type=submit value="Сохранить" name="submit" style="margin-top:10px;">';
  73. echo '</form>';
  74. break;
  75.  
  76. endswitch;
  77.  
  78.  
  79.  
  80.  
  81.  
  82. include_once'../template/foot.php';
  83. ?>