Просмотр файла libraries/calc_dir.php

Размер файла: 1.36Kb
<?php

/*=========================================================================*/
/*
/* 	Имя скрипта: /libraries/calc_dir.php
/*	Назначение: подсчет файлов в папке
/*  Дата создания: 17.09.2009
/*  Дата последней модификации: 17.09.2009
/*
/*  Разработчик: Ant0ha
/*	Визитка: http://ant0ha.ru
/* 	ICQ: 144-144-2
/*  Mail: [email protected]
/*
/*=========================================================================*/

class calc_dir {
	var $a_fname=array();
	var $a_fsize=array();
	var $a_fdir =array();
	var $cofiles;

	function init() {
		$this->cofiles=0;
	}

	function calc_files($in_dir) {
	#Так можно отсечь нежелательные имена файлов
	#if (preg_match("/_vti[.]*/i",$in_dir)){return;}
		if ($dir_handle = @opendir($in_dir)) {
			while($file = readdir($dir_handle)) {
				//Рекурсивный проход по директориям
				if ($file!=".." && $file!="." && is_dir($file)) {
					$this->calc_files($in_dir."/".$file);
				}

				//Проход по файлам
				if (is_file($in_dir."/".$file) && $file!=".." && $file!=".") {
					$this->a_fname[$this->cofiles]=$file;
					$this->a_fsize[$this->cofiles]=filesize ($in_dir."/".$file);
					$this->a_fdir [$this->cofiles]=$in_dir;
					$this->cofiles++;
				}
			}
		}
	}
}//end class

?>