Просмотр файла read.php

Размер файла: 1.49Kb
  1. <?php
  2. require('require/configuration.php');
  3. require('require/head.php');
  4. if(!empty($_GET['txt'])){
  5. $path=base64_decode($_GET['txt']);
  6. }
  7. if(!is_file($path)||strpos($path,'..')!==FALSE||$path{0}=='/'||strtolower(substr($path,strrpos($path,'.')+1))!='txt'){
  8. echo'
  9. <div class="mid_menu"></div>
  10. <div class="contents"><span class="b">Помилка відкриття файла</span>
  11. </div>
  12. <div class="mid_menufoot"></div>';
  13. require('require/foot.php');
  14. exit;}
  15. if(!empty($_GET['p'])){
  16. $p=intval(abs($_GET['p']));
  17. }else{
  18. $p=1;
  19. }
  20. define('PATH',$path);
  21. require('require/functions.php');
  22. $file=file(PATH);
  23. $name=$file[0];
  24. unset($file[0]);
  25. $file=explode('. ',implode(NULL,$file));
  26. $c=count($file);
  27. $file=array_slice($file, ($p-1)*$rec, $rec);
  28. file_lib_path($name);
  29. echo'<div class="mid_menu"></div>
  30. <div class="contents">'.my_filter(implode('. ',$file)).'</div>
  31. <div class="mid_menufoot"></div>
  32. ';
  33. if(ceil($c/$rec)>1){
  34. echo'<div class="foot_menu"></div>
  35. <div class="contents">Сторінки: ';
  36. $prev=$p-2;
  37. $next=$p+3;
  38. $stall=ceil($c/$rec);
  39. if($prev<$c&&$prev>1){echo'<a href="read.php?p=1&amp;txt='.$_GET['txt'].'">1</a> ... ';}
  40.  
  41. for($i=$prev;$i<$next;)
  42. {
  43. if($i<=$stall&&$i>=1){
  44. if($p==$i){echo'<span class="b">['.$i.']</span>';}else{echo' <a href="read.php?p='.($i).'&amp;txt='.$_GET['txt'].'">'.$i.'</a> ';}
  45. }
  46. $i++;}
  47. if($next<=$stall){echo ' ... <a href="read.php?p='.$stall.'&amp;txt='.$_GET['txt'].'">'.$stall.'</a>';}
  48. echo'</div>
  49. <div class="foot_menufoot"></div>';
  50. }
  51. require('require/foot.php');
  52. ?>