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

File size: 7.85Kb
<?php
 include './lite/header.inc.php';
 include 'funct.php';
 include 'read.php';
 include 'constant.php';
 @$folder = strip_tags(trim($_GET['a'])); @$n = strip_tags(trim($_GET['n'])); 
 if($_GET['a'] == '/') exit(ERROR_MESAGE);
  if($_GET['a'] == '\\') exit(ERROR_MESAGE);
if(strstr($_GET['a'],'/.')) exit(ERROR_MESAGE);
if(strstr($_GET['a'],'\.')) exit(ERROR_MESAGE);
if($_GET['a'] == 'comm') exit(ERROR_MESAGE);
if($_GET['a'] == 'ck') exit(ERROR_MESAGE);
if($_GET['a'] == 'ds') exit(ERROR_MESAGE);
if($_GET['a'] == 'lite') exit(ERROR_MESAGE);
if($_GET['a'] == 'small') exit(ERROR_MESAGE);
if($_GET['a'] == 'scr') exit(ERROR_MESAGE);
if($_GET['a'] == 'about') exit(ERROR_MESAGE);
 if($folder == './' or empty($folder)) {
   if($fraza == 'on') {
      include_once './resources/fraza/index.php';
	  echo '<br />';
    }
 }
if($_GET["np"]) {
if(!preg_match("/[0-9]/i",$_GET["np"])) exit("Sorry");
$n = $_GET["np"]*FILES_ON_PAGE;
}
if($n) {
if(!preg_match("/[0-9]/i",$n)) exit("Sorry");
}
if($n == '') {
     $n=0; 
    }
$ss = 0; $con = 0; $sok = 0;
  if($folder) {
   if(strstr($folder,'..')) exit(ERROR_MESAGE);
   $dir = @opendir('./'.$folder);
  } else {
     $dir = @opendir('./');
    } 
            while($file = @readdir($dir)) {
 if($file != '.' && $file != '..' && $file != '.htaccess' && $file != 'jad.php' && $file != 'lite' && $file != 'index.php' && $file != 'dl.php' && $file != 'file.png' && $file != 'folder.png' && $file != 'comm.php' && $file != 'comm' && $file != 'admin.php' && $file != 'user.png' && $file != 'funct.php' && $file != 'about.php' && $file != 'about' && $file != 'scr' && $file != 'read.php' && $file != 'pre.php' && $file != 'small' && $file != 'prew.php' && $file != 'cpre.php' && $file != 'ck' && $file != 'constant.php' && $file != 'd.php' && $file != 'ds' && $file != 'admin.php' && $file != 'config.php' && $file != 'in.html' && $file != '1.txt' && $file != 'kl.php' && $file != 'pr.php' && $file != 'help.html' && $file != 'screen.jpg' && $file != 'style.css' && $file != 'resources' && $file != 'ocen.php' && $file != 'ocenf.php' && $file != 'n.n' && $file != 'vvv.php' && $file != 'gs' && $file != 'zip.php' && $file != 'ic.php') {
    if($con < $n) {
	  $con++; 
      continue;
	}
  if($sok < FILES_ON_PAGE) {
			 $name = $file;
			  $name = str_replace('_',' ',$name);
			  $er = strrchr($name,'.');
			  if(file_exists($folder.'/in.html')) require_once($folder.'/in.html');
			  if(file_exists($folder.'/1.txt')) require_once($folder.'/1.txt');
 if($folder) {
     $sz = filesize($folder.'/'.$file);
     $file = $folder.'/'.$file;
    }   else  {
	   $sz = filesize($file);
	}
 $fsize = round($sz/1024,1);
    if(is_file($file)) {
	 		if(time() - filectime($file) < IS_NEW_FILE) {
   if(!preg_match("[\.txt]",$name)) {			
  echo '<small>'.NEW_FILE_MESSAGE.' </small>'; 
  }
  }
     if($er == ".txt") {
           if(!preg_match("[\.n\.d\.txt]",$name)) {
             $name = strtok($name,'.'); 
                 echo '<small><img src="file.png" alt=""/> <b><a href="?read='.$file.'&br='.$folder.'">'.trans($name,TRANSLATE_TXT).'</a></b></small><br/>'; 
            } elseif(preg_match("[\.n\.d\.txt]",$name)) {
              $name = strtok($name,'.');
                 echo '<small><img src="file.png" alt=""/> <b><a href="?read='.$file.'&br='.$folder.'">'.trans($name,TRANSLATE_NDTXT).'</a></b></small><br/>'; 
            } 
		} elseif($er == '.png' or $er == '.gif' or $er == '.jpg' or $er == '.bmp' or $er == '.JPG' or $er == '.PNG' or $er == '.GIF') {
		       $fname = strtok($name,'.');
			   $name = str_replace(' ','_',$name);
                 echo '<small><img src="pr.php?img='.$file.'"/><br /> <b><a href="'.$file.'">'.trans($name,TRANSLATE_PICTURE).'</a> ['.$fsize.' kb] [<a href="prew.php?img='.$file.'&nm='.$name.'&br='.$folder.'"><b>>></b></a>]</b></small><br/>'; 
        } elseif($er == '.sdt') {
		$name = str_replace(' ','_',$name); 
                 echo '<small>';
				 if(file_exists($folder.'/screen.jpg')) {
				 echo '<img src="'.$folder.'/screen.jpg" alt=""/><br />'; 
				 }
				 echo '<b><a href="d.php?file='.$file.'&cf='.$name.'">'.trans($name,TRANSLATE_FILE).'</a> ['.$fsize.' kb] [<a href="about.php?cf='.$name.'&lf='.$file.'&br='.$folder.'"><b>info</b></a>]</b></small><br/>'; 
        } elseif(!preg_match("[\.html]",$name)) {
		$name = str_replace(' ','_',$name); 
                 echo '<small><img src="file.png" alt=""/> <b><a href="d.php?file='.$file.'&cf='.$name.'">'.trans($name,TRANSLATE_FILE).'</a> ['.$fsize.' kb] [<a href="about.php?cf='.$name.'&lf='.$file.'&br='.$folder.'"><b>info</b></a>]</b></small><br/>'; 
        } else {	
		     $name = strtok($name,'.');
		     $name = str_replace(' ','_',$name);
                 echo '<small><img src="folder.png" alt=""/> <b><a href="'.$file.'">'.trans($name,TRANSLATE_HTML).'</a> [<a href="about.php?cf='.$name.'&lf='.$file.'&br='.$folder.'"><b>info</b></a>]</b></small><br/>'; 
		}
    $sok++;
    $ss = $ss + $con;
    } else {
	   if(FILES_DIR_COUNT == 1){
   $jf = files($file);
    if(empty($jf)) $jf = 0;
   $clf = ' <small>['.$jf.']</small>';
   } else $clf = '';
		if(!preg_match("[HTML]",$name) && !preg_match("[CSS]",$name) && !preg_match("[NTRLS]",$name)) {
		if(file_exists($file.'/n.n')) {
		$np = @file_get_contents($file.'/n.n');
		} else $np = trans($name,TRANSLATE_FOLDER);
                 echo '<small><img src="folder.png" alt=""/> <b><a href="?a='.$file.'">'.$np.'</a></b></small>'.$clf.'<br/>';
          $sok++; 
		} elseif(preg_match("[HTML]",$name) or preg_match("[CSS]",$name) or preg_match("[NTRLS]",$name)) {
		      $name = substr($name,0,strpos($name,'NTRLS'));
                 echo '<small><img src="folder.png" alt=""/> <b><a href="?a='.$file.'">'.trans($name,TRANSLATE_HTML_FOLDER).'</a></b></small>'.$clf.'<br/>';
          $sok++; 
		}
    }
    }
   $con++;
    }
    }
   @closedir($dir);
      if(empty($con)) echo '<small>Раздел пока пуст.</small>';
   if($folder == '.' or empty($folder)) {
     if(OBSHEE == 'on') {
	   echo '<hr>';
	  include_once 'kl.php';
	 }
   }
     if($n != 0) {
	 echo '<a href="?a='.$folder.'&n=0"><small><b><<< </b></small></a>|';
		echo '<a href="index.php?a='.$folder.'&n='.($n - FILES_ON_PAGE).'"><small><b><<Назад</b></small></a>|';
	}   
	if(!$sok < FILES_ON_PAGE && $sok + $n != $con) {
		echo '<a href="?a='.$folder.'&n='.($sok + $n).'"><small><b>Далее>></b></small></a>';
		echo '|<a href="?a='.$folder.'&n='.(abs($con - FILES_ON_PAGE)).'"><small><b> >>></b></small></a>';
	}
     $ss = round($ss/1024,1);
     $pag = round($con/10);
      if(($con - $pag * 10) > 0) {
  			$pag++;
		}
		echo '<br /><small>Стр.:'.round($ss*FILES_ON_PAGE+1,1).' из '.$pag.'</small><br />';
		if($pag>1){
		echo '<a href="?a='.$folder.'&n=0"><small><b>1</b></small></a>,';
		for($i=round($ss*FILES_ON_PAGE+1,1);$i<=$pag;$i++){
		 echo '<a href="?a='.$folder.'&n='.($i*FILES_ON_PAGE).'"><small><b>'.($i+1).'</b></small></a>,';
		  if($i>round($ss*FILES_ON_PAGE+1,1)+3) break;
		}
		for($i=round($ss*FILES_ON_PAGE+1,1)+30;$i<=$pag;$i++){
		echo '<a href="?a='.$folder.'&n='.($i*10).'"><small><b>'.($i+1).'</b></small></a>,';
		  if($i>round($ss*FILES_ON_PAGE+1,1)+33) break;
		}
		echo '<a href="?a='.$folder.'&n='.(($pag-1)*FILES_ON_PAGE).'"><small><b>'.$pag.'</b></small></a>';
		}
		echo '<br />
		      <form action="index.php" method="GET">
		      <input type="text" name="np" size="3" value="'.round($ss*FILES_ON_PAGE+1,1).'">
			  <input type="hidden" name="a" value="'.$folder.'">
			  <input type="submit" value="GO">
			  <br />';
		$knc = strtok($folder,'/');
		$ob = strrchr($folder,'/');
		$back = str_replace($ob,'',$folder);
			if($folder != '') echo '<hr> <a href="index.php?a='.$back.'"><small>Назад</small></a><br />
			<a href="index.php?a='.$knc.'"><small>К началу</small></a>';
include('./lite/footer.inc.php');
?>