Location: PHPKode > scripts > Joomla Site Monitor > com_sitemonitor16/site/models/files.php
<?php
defined('_JEXEC') or die( 'Restricted access' );

class smcModelFiles extends JModel {
	function loadList() {
        ini_set('memory_limit', '512M');
		$result = array();
		jimport('joomla.filesystem.folder');
		$files = JFolder :: files(JPATH_SITE, '.', $recurse = true, $fullpath = true);
		natcasesort($files);
		$ignore_paths = explode(',', JRequest :: getString('ignore_paths'));
		if ($ignore_paths) foreach ($ignore_paths as $i=>$path) $ignore_paths[$i] = str_replace('/', DS, trim($path, "\x0B\0\r\n\t /\\")).DS;
		if ($files) foreach ($files as $file) {
			$is_skip = false;
			if ($ignore_paths) foreach ($ignore_paths as $path) {
				if (strpos($file, JPATH_SITE.DS.$path) === 0) {
					$is_skip = true;
					break;
				}
			}
			if ($is_skip) continue;

			$row = new stdclass;
			$row->path = str_replace('\\', '/', str_replace(JPATH_SITE.DS, '', $file));
			$row->size = filesize($file);
			$row->md5 = md5_file($file);
			$row->sha1 = sha1_file($file);

			$result[] = $row;
		}
		return $result;
	}
	function loadFiles() {
		if ($paths = explode("\n", JRequest :: getString('paths'))) {
			set_time_limit(0);
			ini_set('memory_limit', '1024M');
			$files = array();
			jimport('joomla.filesystem.file');
			foreach ($paths as $path) if ($path) {
				$fullname = JPATH_SITE.'/'.$path;
				if (file_exists($fullname)) {
					$files[] = array(
						'name' => $fullname,
						'name2' => $path,
						'type' => @is_link($fullname)? 2 : 0,
						'ext' => JFile :: getExt(basename($path)),
						'stat' => stat($fullname)
					);
				}
			}
			if ($files) {
				include_once(JPATH_SITE.'/components/com_sitemonitor/helpers/archive.php');
				$filename = JPATH_SITE.'/tmp/'.rand().'.tgz';
				$archive = new gzip_file($filename);
				$archive->files = $files;
				if ($archive->archive = @fopen("$filename.tmp", "wb+")) {
					$archive->create_tar();
					$archive->create_gzip();
					fclose($archive->archive);
					JFile :: delete($filename.'.tmp');
					if (file_exists($filename)) {
						if ($fh = fopen($filename, 'r')) {
							fpassthru($fh);
							fclose($fh);
						}
						unlink($filename);
					}
				}
			}
		}
	}
	function loadFile() {
		$path = JRequest :: getString('path');
		if ($path and file_exists(JPATH_SITE.'/'.$path)) return file_get_contents(JPATH_SITE.'/'.$path);
	}
}
?>
Return current item: Joomla Site Monitor