Просмотр файла dl/zip.php

Размер файла: 6.46Kb
<?php
#********************************** AgS MOD DOWNLOAD CENTR SEA *************************************#
#***************************************************************************************************#
#  /||||||||||||||| *********************  /||||||||||||||| *********************  /||||||||||||||| #
# | ||||||||||||||| ********************* | ||||||||||||||| ********************* | ||||||||||||||| #
# | |||||/////||||| ********************* | |||||/////////  ********************* | |||||/////////  #
# | |||||   | ||||| ****** E-MAIL ******* | |||||           ****** WAP/WEB ****** | |||||           #
# | |||||   | ||||| *** [email protected] *** | |||||           * http://ags.h2m.ru * | ||||||||||||||| #
# | |||||   | ||||| ********************* | ||||||||||||||| ********************* | ||||||||||||||| #
# | |||||   | ||||| ********************* | |||||/////||||| ********************* |///////////||||| #
# | ||||||||||||||| ****** SKYPE ******** | |||||   | ||||| ***** MOD AUTHOR ****           | ||||| #
# | |||||////|||||| ***** agrizz15 ****** | |||||   | ||||| ***** Agris Cišs ****  /||||||||||||||| #
# | |||||   | ||||| ********************* | ||||||||||||||| ********************* | ||||||||||||||| #
# |/////    |/////  ********************* |///////////////  ********************* |///////////////  #
#***************************************************************************************************#
#********************************* MOD by AgS in 2010 @ LATVIA *************************************#


require_once"system/start.php";
require_once"system/config.php";
require_once"system/db.php";
require_once"system/head.php";
require_once"lng/$setup[lng]/lng.php";
require_once"system/functions.php";
require_once"system/cookies.php";
require_once"system/counter.php";
include_once"thm/$setup[thm]/index.php";
include_once"system/msg.php";


require_once'system/lib.pclzip.php';


/* Datu apstrade */
$onpage = iegut_sesiju('onpage');
ir_numurs($onpage,'onpage');
$id = intval($_GET['id']);
$backid = $_GET['backid'];
$page = intval($_GET['page']);
$start = intval($_GET['start']);

/* Uz lapas */
if($onpage < 1){
$onpage = $setup['onpage'];}

/* Pārbaudam faila esamību */
$d = mysql_fetch_array(mysql_query('SELECT * FROM `'.$MY_pre.'faili` WHERE `id` = '.$id));
if(file_exists($d['path'])){

/* Iegūstam datus */
$filename = pathinfo($d['path']);//vards
$ext = strtolower($filename['extension']);//formats

/* Pārbaudam vai zip */
if($ext='zip'){

/* Nosaukums */
echo '<img src="pic/icons/zip.gif" alt=""> <b>'.basename($d['path']).'</b><br><br>';

/*Failu saraksts */
if(!$_GET['action']){

/* Iegūstam sarakstu */
$zip = new PclZip($d['path']);
if(!$list = $zip->listContent()){ die(zip_000.': '.$zip->errorInfo(true));}

for($i=0; $i<sizeof($list); $i++){
for(reset($list[$i]); $key = key($list[$i]); next($list[$i])){
$zfilesize = strstr($listcontent,'--size');
$zfilesize = str_replace('--size:','',$zfilesize);
$zfilesize = str_replace($zfilesize,$zfilesize.'|',$zfilesize);
$sizelist .= $zfilesize;
$listcontent = "[$i]--$key:".$list[$i][$key];
$zfile = strstr($listcontent,'--filename');
$zfile = str_replace('--filename:','',$zfile);
$zfile = str_replace($zfile,$zfile.'|',$zfile);
$savelist .= $zfile;
}}

$sizefiles2 = explode('|',$sizelist);
$sizelist2=array_sum($sizefiles2);
$preview=$savelist;
$preview = explode('|',$preview);
$count = count($preview)-1;
echo '<b>'.sys_allfil.':</b> '.$count.'<br><b>'.zip_002.':</b> '.izmers($sizelist2).'<br><br>';

if (!isset($page)) $page=1;
$n = 0;
$pages = ceil($count/$onpage);
if(!$pages){ $pages = 1;}
if ($page){ $n = ($onpage*$page)-$onpage;}
if ($count == 0){ echo zip_003;}
$sizefiles = explode('|',$sizelist);
$selectfile = explode('|',$savelist);

for ($i = 1; $i<=$onpage; $i++){
if (empty($selectfile[$n])){
$n++;
continue;
}

$path = $selectfile[$n];
$fname = ereg_replace(".*[\\/]",'',$path);
$formatname = ereg_replace(".*[\\.]",'',$fname);
$zdir = ereg_replace("[\\/]?[^\\/]*$",'',$path);

if(!empty($formatname)){
if(file_exists('pic/icons/'.$formatname.'.gif')){ 
$ico = '<img src="pic/icons/'.$formatname.'.gif" alt="">';
}else{ 
$ico = '<img src="pic/icons/other.gif" alt="">';}
}else{
$ico = '<img src="pic/main/dir_zip.gif" alt="">';}


echo $ico.$zdir.'/<a href="'.$_SERVER['PHP_SELF'].'?action=preview&amp;id='.$id.'&amp;backid='.$backid.'&amp;open='.$path.'&amp;page='.$page.'">'.$fname.'</a>';



if($sizefiles[$n]!='0'){ echo ' ['.izmers($sizefiles[$n]).']';}
echo'<br>';
$n++;
}

/* Lapu izvade */
echo '<br>'.sys_pages.': ';
$asd= $page - 2;
$asd2= $page + 3;
if($asd<$count && $asd>0 && $page>3) echo '<a href="zip.php?id='.$id.'&amp;backid='.$backid.'&amp;page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++){
if($i<$count && $i>0){
if ($i > $pages ) break;
if ($page==$i) {
echo '<b>['.$i.']</b> ';}else {
echo '<a href="zip.php?id='.$id.'&amp;backid='.$backid.'&amp;page='.$i.'">'.$i.'</a> ';}}}
if ($i <= $pages){
if($asd2<$count) {
echo ' ... <a href="zip.php?id='.$id.'&amp;backid='.$backid.'&amp;page='.$pages.'">'.$pages.'</a>';}}
echo '<br><br>';
}


/* TEksta failu apskate */
if($_GET['action']=='preview'){


$zip=new PclZip($d['path']);
$content = $zip->extract(PCLZIP_OPT_BY_NAME, $_GET['open'],PCLZIP_OPT_EXTRACT_AS_STRING);
$content = $content[0]['content'];
$preview = explode("\n",$content);
$count = count($preview);
$ext = strtolower(substr($_GET['open'], strrpos($_GET['open'], '.') + 1));


if(file_exists('pic/icons/'.$ext.'.gif')){ 
$ico = '<img src="pic/icons/'.$ext.'.gif" alt=""> ';
}else{ 
$ico = '<img src="pic/icons/other.gif" alt=""> ';}

echo '<b>'.$ico.$_GET['open'].'</b><br><br>';

echo '<b>'.zip_012.':</b> '.$count.'<br><br>';

if(ir_utf($content)){
echo highlight_kods($content);}else{
echo highlight_kods(win_to_utf_ru($content));}
echo '<br><img src="pic/main/dot.gif" alt="">
 <a href="zip.php?id='.$id.'&amp;backid='.$backid.'&amp;page='.$page.'">'.zip_004.'</a><br>';

}
}else{ echo zip_005.'<br>';}
}else{ echo zip_006.'<br>';}


/* Beigas */
echo '<img src="pic/main/dot.gif" alt=""> <a href="about.php?id='.$id.'">'.sys_abouts.'</a><br>';
echo '<img src="pic/main/dot.gif" alt=""> <a href="index.php?id='.$backid.'">'.sys_category.'</a><br>';
echo '<img src="pic/main/dot.gif" alt=""> <a href="index.php">'.sys_dl.'</a><br>';
echo '<img src="pic/main/home.gif" alt=""> <a href="'.$setup['home'].'">'.sys_home.'</a><br>';

include_once"thm/$setup[thm]/foot.php";
?>