Просмотр файла includes/wap/builder/dir.php

Размер файла: 5.61Kb
  1. <?php
  2. $buildpath=$wappath."builder/";
  3.  
  4. $tmp=explode('/',str_replace($userpath,'',realpath($userpath.$currentdir)));
  5. $_dir=$tmp[sizeof($tmp)-1];
  6.  
  7. if (($query1=='new')||($query1==''))
  8. {
  9. $cntsubdir=0;
  10. $d=dir($userpath.$currentdir);
  11. while ($entry=$d->read())
  12. {
  13. if (($entry=='_BUFER_')||($entry=='_DAT_')||($entry=='.')||($entry=='..')) continue;
  14. if (filetype($userpath.$currentdir.'/'.$entry)=='dir') $cntsubdir++;
  15. }
  16. $d->close();
  17. }
  18.  
  19. if ($query1=='up') {$query1='cd'; $query3=$query2; $query2='..';}
  20. if (($query1=='cd')&& is_dir($_new_current_dir=realpath($userpath.$currentdir.'/'.$query2)))
  21. {
  22. if ($query3!='') $nocache_=$query3+0;
  23. $fp = @fopen ($userpath."opeation.cache", "r");$testcache = trim(@fgets($fp, 10));@fclose ($fp);
  24. if ($nocache_!=$testcache)
  25. {
  26. $currentdir=str_replace('.','',str_replace('/.','',str_replace($userpath,'',$_new_current_dir.'/.')));
  27. $f=@fopen($userpath.'currentdir.dat','w+');
  28. @fwrite($f,trim($currentdir));
  29. @fclose($f);
  30. $f=@fopen($userpath.'currentdir.dat','r+');
  31. $currentdir=trim(@fread($f,128));
  32. @fclose($f);
  33. if (!is_subdir($userpath,$userpath.$currentdir)) $currentdir='.';
  34. if ($currentdir=='') $currentdir='.';
  35. $fp = fopen ($userpath."opeation.cache", "w+");fwrite ($fp, $nocache_);fclose ($fp);
  36. }
  37. }
  38. if (($query1=='new')&&(sizeof(explode('/',$currentdir))<3)&&($cntsubdir<16)) include($buildpath.'dir_new.php');
  39. if ($query1=='bufer') include($buildpath.'dir_bufer.php');
  40. if ($query1=='input') include($buildpath.'dir_bufer2dir.php');
  41. if ($query1=='output') include($buildpath.'dir_files2bufer.php');
  42. if ($query1=='rename') include($buildpath.'dir_rename.php');
  43. if ($query1=='delete') include($buildpath.'dir_delete.php');
  44. if ($query1=='purgebufer') dir_delete($userpath.'_BUFER_/');
  45.  
  46. print $head.cyr2utf('<card id="main" title="Папки">');
  47. print '<do name="x" type="options" label="xPanel"><go href="http://wap.kmx.ru/?'.$id.'"/></do>';
  48. print cyr2utf('<do name="pm" type="options" label="Страницы"><go href="http://wap.kmx.ru/?'.$id.'/pm"/></do>');
  49. print cyr2utf('<do name="fm" type="options" label="Файлы"><go href="http://wap.kmx.ru/?'.$id.'/fm"/></do>');
  50. if ((sizeof(explode('/',$currentdir))<3)&&($cntsubdir<16)) print cyr2utf('<do name="n" type="options" label="Создать"><go href="http://wap.kmx.ru/?'.$id.'/dm'.$dmpage.$mpage.'/new"/></do>');
  51. print '<p>';
  52. if ($currentdir!='.') print cyr2utf('<b>Папка: /'.$currentdir.'/</b> <br/><small>- - -</small> <br/>');
  53. else print cyr2utf('<b>Папка: /</b> <br/><small>- - -</small> <br/>');
  54.  
  55. if ($currentdir!='.') print cyr2utf('<a href="#rename">Преименовать</a> <br/>');
  56. if ($currentdir!='.') print cyr2utf('<a href="#delete">Удалить</a> <br/> ');
  57. if (!is_dir($userpath.'_BUFER_')) print cyr2utf('<a href="http://wap.kmx.ru/?'.$id.'/dm'.$dmpage.$mpage.'/output">Файлы в портфель</a> <br/> ');
  58. else print cyr2utf('<a href="/?'.$id.'/dm'.$dmpage.$mpage.'/input">Файлы из портфеля</a> <br/> ');
  59.  
  60. print '<small>- - -</small> <br/>';
  61.  
  62. unset($dirs);
  63.  
  64. $d=dir($userpath.$currentdir);
  65. $found=false;
  66. $cntfile=$cntpages=0;
  67.  
  68. while ($entry=$d->read())
  69. {
  70. if (($entry=='_DAT_')||($entry=='.')||(($entry=='..')&&($currentdir=='.'))) continue;
  71. if (substr($entry,-4)=='.wml') $cntpages++;
  72. elseif (allow_ext(substr($entry,-4)) || allow_ext(substr($entry,-5))) $cntfile++;
  73. if (filetype($userpath.$currentdir.'/'.$entry)=='dir') { $dirs[]=$entry; $found=true; }
  74. }
  75. $d->close();
  76.  
  77. @sort($dirs, SORT_STRING);
  78.  
  79. if (($mpage+0)>1) $tmpage=$mpage+0;
  80. else $tmpage=1;
  81.  
  82. if ($tmpage<2) $dmpage=$mpage='';
  83. else {$dmpage='-';$mpage=$mpage+0;}
  84.  
  85. if ($tmpage>1) print cyr2utf('<a href="/?'.$id.'/dm-'.($tmpage-1).'">&lt;&lt;&lt;</a><br/>');
  86.  
  87. $i=0;
  88. if ($found)
  89. {
  90. while ($_dir=@each($dirs))
  91. {
  92. if ($i<($tmpage*20)-20) {$i++;continue;}
  93. $_dir=$_dir[1];
  94. $found=false;
  95. if ($_dir=='..')
  96. {
  97. print cyr2utf('<b><a href="/?'.$id.'/dm'.$dmpage.$mpage.'/up/'.$nocache.'">вверх</a></b> <br/>');
  98. }
  99. elseif ($_dir=='_BUFER_')
  100. {
  101. print cyr2utf('<b><a href="/?'.$id.'/dm'.$dmpage.$mpage.'/bufer">-портфель-</a></b> <br/>');
  102. }
  103. elseif ($_dir!='_DAT_')
  104. {
  105. print '<a href="/?'.$id.'/dm'.$dmpage.$mpage.'/cd/'.$_dir.'/'.$nocache.'">'.$_dir.'</a> <br/>';
  106. $found=true;
  107. }
  108. $i++;
  109. if ($i>=($tmpage*20)) break;
  110. }
  111. }
  112. if (!$found) print cyr2utf('<small>Вложенных папок нет...</small>');
  113.  
  114. if ($i>=($tmpage*20)) print cyr2utf('<a href="http://wap.kmx.ru/?'.$id.'/dm-'.($tmpage+1).'">&gt;&gt;&gt;</a>');
  115.  
  116. if (($cntpages+$cntfile)>0) print ' <br/><small>';
  117. if ($cntpages>0) print cyr2utf('Страниц: '.$cntpages);
  118. if (($cntfile>0)&&($cntpages>0)) print ', ';
  119. if ($cntfile>0) print cyr2utf('Файлов: '.$cntfile);
  120. if (($cntpages+$cntfile)>0) print '</small>';
  121.  
  122. print '</p></card>';
  123. print cyr2utf('<card id="delete" title="Удаление">');
  124. print cyr2utf('<p><b>Вы действительно хотите удалить /'.str_replace($userpath,'',realpath($userpath.$currentdir)).' со всеми вложенными файлами и подпапками без возможности восстановления?</b> <br/>');
  125. print cyr2utf('<a href="/?'.$id.'/dm'.$dmpage.$mpage.'/delete/'.$nocache.'">Удалить</a> <br/>');
  126. print cyr2utf('<a href="#main">Отмена</a>');
  127.  
  128. print '</p></card>';
  129. for ($i=1;is_dir($userpath.$currentdir.'/../dir'.$i);$i++);
  130. print cyr2utf('<card id="rename" title="Переименовать"><p>');
  131. print cyr2utf('<b>Новое имя папки:</b><br/>');
  132. print cyr2utf('<input name="dir'.$nocache.'" type="text" title="Имя папки" value="dir'.$i.'" maxlength="8"/><br/>');
  133. print cyr2utf('<a href="?'.$id.'/dm'.$dmpage.$mpage.'/rename/$(dir'.$nocache.')/'.$nocache.'">Далее</a> <br/>');
  134. print cyr2utf('<a href="#main">Отмена</a>');
  135.  
  136. print '</p></card></wml>';
  137. exit;
  138. ?>