View file mch-db_dv3.1/dl/zip.php

File size: 3.03Kb
<?php
include('./lite/header.inc.php');
include_once('vvv.php');
include 'constant.php';
	  @$file = $_GET["lf"];
	  @$br = $_GET["br"];
 @$cf = $_GET["cf"];
	     if(preg_match("[http]",$lf)) exit(ERROR_MESAGE);
     if(preg_match("[\.\.]",$lf)) exit(ERROR_MESAGE);
	    if(preg_match("[http]",$cf)) exit(ERROR_MESAGE);
     if(preg_match("[\.\.]",$cf)) exit(ERROR_MESAGE);
 $cf = str_replace('http://','',$_GET["cf"]);
 $lf = str_replace('http://','',$_GET["lf"]);
  $lf = str_replace('http','',$_GET["lf"]);
 $cf = str_replace('http','',$_GET["cf"]);
  $cf = str_replace('..','',$cf);
 $cf = str_replace('/','',$cf);
  if(!$_GET["if"]){
  $zip = new PclZip($file);
     if (($list = $zip->listContent()) == 0) {
        die("Sorry");
     }
	 $start = $_GET["start"];
	 if(empty($start)) $start = 0;
	 $fin = $start + FILES_ON_PAGE;
     for ($i=$start; $i<$fin; $i++) {
	 if(!empty($list[$i]["filename"])) {
            echo '<img src="file.png" alt=""/> <small><a href="?if='.$list[$i]["filename"].'&cfl='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'&lf='.$file.'">'.$list[$i]["filename"].'</a> ['.round($list[$i]["size"]/1024,2).' kb]</small><br>';
			}
     }
	 if(!empty($start) and $fin > FILES_ON_PAGE) {
	 	 echo '<small><a href="zip.php?lf='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'&start='.($start-FILES_ON_PAGE).'"><<Назад</a></small>|';

	 }
	 if(sizeof($list) > FILES_ON_PAGE and $fin < sizeof($list)) {
	 echo '<small><a href="zip.php?lf='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'&start='.($start+FILES_ON_PAGE).'">Далее>></a></small>';
	 }
    } elseif($_GET["if"]) {
	$fl = $_GET["if"];
	    $archive = new PclZip($_GET["cfl"]);
    $list = $archive->extract(PCLZIP_OPT_BY_NAME, "$fl",
                              PCLZIP_OPT_EXTRACT_AS_STRING);
    if ($list == 0) {
      echo "ERROR : ".$archive->errorInfo(true);
      exit;
    }
	 $eco = explode("\n",$list[0]['content']);
	 $st = $_GET["st"];
	 $fn = $st + READ_COUNT;
	 if(empty($st)) $st = 0;
	 for($i=$st;$i<$fn;$i++) {
    echo '<small>'.htmlspecialchars($eco[$i]).'</small>';
	}
	echo '<br />';
		 if(!empty($st) and $fn > READ_COUNT) {
	 	 echo '<small><a href="zip.php?lf='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'&st='.($st-READ_COUNT).'&cfl='.$_GET["cfl"].'&if='.$_GET["if"].'"><<Назад</a></small>|';

	 }
	 if(sizeof($eco) > READ_COUNT and $fn < sizeof($eco)) {
	 echo '<small><a href="zip.php?lf='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'&st='.($st+READ_COUNT).'&cfl='.$_GET["cfl"].'&if='.$_GET["if"].'">Далее>></a></small>';
	 }
	 		 echo '<hr>
			 <small><a href="zip.php?lf='.$_GET["cfl"].'&cf='.$cf.'&br='.str_replace('..','',$br).'">К просмотру архива</a></small><br />';
	}
		 echo '<hr>';
		 echo '<small>
		       <a href="about.php?lf='.$file.'&cf='.$cf.'&br='.str_replace('..','',$br).'">К описанию</a>
			   <br />
			   <a href="index.php?a='.str_replace('..','',$br).'">К разделам</a></small>';
include('./lite/footer.inc.php');
?>