/** * constructor * */ function __construct() { //check if the session folder read and writable $dir = new file(); if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH)) { if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH)) { die('Unable to create session folder.'); } } if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable."); } if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable."); } $this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH)); $this->lifeTime = get_cfg_var("session.gc_maxlifetime"); $this->gcCounterFile = $this->dir . $this->gcCounterFileName; $this->gcLogFile = $this->dir . $this->gcLogFileName; $this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR); $this->init(); }
protected function getFiles($dir) { $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/{$dir}"; $dir = "{$this->config['uploadDir']}/{$dir}"; $return = array(); $files = dir::content($dir, array('types' => "file")); if ($files === false) { return $return; } foreach ($files as $file) { $size = @getimagesize($file); if (is_array($size) && count($size)) { $thumb_file = "{$thumbDir}/" . basename($file); if (!is_file($thumb_file)) { $this->makeThumb($file, false); } $smallThumb = $size[0] <= $this->config['thumbWidth'] && $size[1] <= $this->config['thumbHeight'] && in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG)); } else { $smallThumb = false; } $stat = stat($file); if ($stat === false) { continue; } $name = basename($file); $ext = file::getExtension($file); $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/{$ext}.png"); $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/{$ext}.png"); $thumb = file_exists("{$thumbDir}/{$name}"); $return[] = array('name' => stripcslashes($name), 'size' => $stat['size'], 'mtime' => $stat['mtime'], 'date' => @strftime($this->dateTimeSmall, $stat['mtime']), 'readable' => is_readable($file), 'writable' => file::isWritable($file), 'bigIcon' => $bigIcon, 'smallIcon' => $smallIcon, 'thumb' => $thumb, 'smallThumb' => $smallThumb); } return $return; }
protected function getFiles($dir) { $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/{$dir}"; $dir = "{$this->config['uploadDir']}/{$dir}"; $return = array(); $files = dir::content($dir, array('types' => "file")); if ($files === false) { return $return; } foreach ($files as $file) { $this->makeThumb($file, false); $image = new gd($file); $image = !$image->init_error && $image->get_width() <= $this->config['thumbWidth'] && $image->get_height() <= $this->config['thumbHeight']; $stat = stat($file); if ($stat === false) { continue; } $name = basename($file); $ext = file::getExtension($file); $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/{$ext}.png"); $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/{$ext}.png"); $thumb = file_exists("{$thumbDir}/{$name}"); $return[] = array('name' => stripcslashes($name), 'size' => $stat['size'], 'mtime' => $stat['mtime'], 'date' => @strftime($this->dateTimeSmall, $stat['mtime']), 'readable' => is_readable($file), 'writable' => file::isWritable($file), 'bigIcon' => $bigIcon, 'smallIcon' => $smallIcon, 'thumb' => $thumb, 'smallThumb' => $image); } return $return; }
protected function getFiles($dir) { $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/{$dir}"; $dir = "{$this->config['uploadDir']}/{$dir}"; $return = array(); $files = dir::content($dir, array('types' => "file")); if ($files === false) { return $return; } foreach ($files as $file) { $img = new fastImage($file); $type = $img->getType(); if ($type !== false) { $size = $img->getSize($file); if (is_array($size) && count($size)) { $thumb_file = "{$thumbDir}/" . basename($file); if (!is_file($thumb_file)) { $this->makeThumb($file, false); } $smallThumb = $size[0] <= $this->config['thumbWidth'] && $size[1] <= $this->config['thumbHeight'] && in_array($type, array("gif", "jpeg", "png")); } else { $smallThumb = false; } } else { $smallThumb = false; } $img->close(); $stat = stat($file); if ($stat === false) { continue; } $name = basename($file); $ext = file::getExtension($file); $types = $this->config['types']; $types = explode(' ', $types['images'] . ' ' . $types['image']); if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) { continue; } if ($this->type == 'images' && !in_array(strtolower($ext), $types)) { continue; } $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/{$ext}.png"); $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/{$ext}.png"); $thumb = file_exists("{$thumbDir}/{$name}"); $return[] = array('name' => stripcslashes($name), 'size' => $stat['size'], 'mtime' => $stat['mtime'], 'date' => @strftime($this->dateTimeSmall, $stat['mtime']), 'readable' => is_readable($file), 'writable' => file::isWritable($file), 'bigIcon' => $bigIcon, 'smallIcon' => $smallIcon, 'thumb' => $thumb, 'smallThumb' => $smallThumb); } return $return; }
protected function act_mv_cbd() { $dir = $this->postDir(); if (!$this->config['access']['files']['move'] || !isset($_POST['dir']) || !is_dir($dir) || !is_readable($dir) || !dir::isWritable($dir) || !isset($_POST['files']) || !is_array($_POST['files']) || !count($_POST['files'])) { $this->errorMsg("Unknown error."); } $error = array(); foreach ($_POST['files'] as $file) { $file = path::normalize($file); if (substr($file, 0, 1) == ".") { continue; } $type = explode("/", $file); $type = $type[0]; if ($type != $this->type) { continue; } $path = "{$this->config['uploadDir']}/{$file}"; if (!$this->checkFilePath($path)) { continue; } $base = basename($file); $replace = array('file' => $this->htmlData($base)); $ext = file::getExtension($base); if (!file_exists($path)) { $error[] = $this->label("The file '{file}' does not exist.", $replace); } elseif (substr($base, 0, 1) == ".") { $error[] = $this->htmlData($base) . ": " . $this->label("File name shouldn't begins with '.'"); } elseif (!$this->validateExtension($ext, $type)) { $error[] = $this->htmlData($base) . ": " . $this->label("Denied file extension."); } elseif (file_exists("{$dir}/{$base}")) { $error[] = $this->htmlData($base) . ": " . $this->label("A file or folder with that name already exists."); } elseif (!is_readable($path) || !is_file($path)) { $error[] = $this->label("Cannot read '{file}'.", $replace); } elseif (!file::isWritable($path) || !@rename($path, "{$dir}/{$base}")) { $error[] = $this->label("Cannot move '{file}'.", $replace); } else { if (function_exists("chmod")) { @chmod("{$dir}/{$base}", $this->config['filePerms']); } $fromThumb = "{$this->thumbsDir}/{$file}"; if (is_file($fromThumb) && is_readable($fromThumb)) { $toThumb = "{$this->thumbsTypeDir}/{$_POST['dir']}"; if (!is_dir($toThumb)) { @mkdir($toThumb, $this->config['dirPerms'], true); } $toThumb .= "/{$base}"; @rename($fromThumb, $toThumb); } } } if (count($error)) { return json_encode(array('error' => $error)); } return true; }
protected function getFiles($dir) { $thumbDir = "{$this->config['uploadDir']}/{$this->config['thumbsDir']}/{$dir}"; $dir = "{$this->config['uploadDir']}/{$dir}"; $return = array(); $files = dir::content($dir, array('types' => "file")); if ($files === false) { return $return; } foreach ($files as $file) { $size = @getimagesize($file); if (is_array($size) && count($size)) { $thumb_file = "{$thumbDir}/" . basename($file); if (!is_file($thumb_file)) { $this->makeThumb($file, false); } $smallThumb = $size[0] <= $this->config['thumbWidth'] && $size[1] <= $this->config['thumbHeight'] && in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG)); } else { $smallThumb = false; } $stat = stat($file); if ($stat === false) { continue; } $filename = basename($file); if ('WIN' == substr(PHP_OS, 0, 3)) { setlocale(LC_CTYPE, ''); // Resets the codepage to the system codepage so it can be properly retrieved $codepage = 'Windows-' . trim(strstr(setlocale(LC_CTYPE, 0), '.'), '.'); if (function_exists('iconv')) { $filename = iconv($codepage, 'UTF-8', $filename); } elseif (function_exists('mb_convert_encoding')) { $filename = mb_convert_encoding($filename, $codepage, 'UTF-8'); } } $name = $filename; $ext = file::getExtension($file); $bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/{$ext}.png"); $smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/{$ext}.png"); $thumb = file_exists("{$thumbDir}/{$name}"); $return[] = array('name' => stripcslashes($name), 'size' => $stat['size'], 'mtime' => $stat['mtime'], 'date' => @strftime($this->dateTimeSmall, $stat['mtime']), 'readable' => is_readable($file), 'writable' => file::isWritable($file), 'bigIcon' => $bigIcon, 'smallIcon' => $smallIcon, 'thumb' => $thumb, 'smallThumb' => $smallThumb); } return $return; }