This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* the purpose I added this class is to make the file system much flexible
|
||||
* for customization.
|
||||
* Actually, this is a kind of interface and you should modify it to fit your system
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 4/August/2007
|
||||
*/
|
||||
class Auth
|
||||
{
|
||||
var $__loginIndexInSession = 'ajax_user';
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function Auth()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
/**
|
||||
* check if the user has logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isLoggedIn()
|
||||
{
|
||||
return (!empty($_SESSION[$this->__loginIndexInSession])?true:false);
|
||||
}
|
||||
/**
|
||||
* validate the username & password
|
||||
* @return boolean
|
||||
*
|
||||
*/
|
||||
function login()
|
||||
{
|
||||
if($_POST['username'] == CONFIG_LOGIN_USERNAME && $_POST['password'] == CONFIG_LOGIN_PASSWORD)
|
||||
{
|
||||
$_SESSION[$this->__loginIndexInSession] = true;
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,436 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* file modification
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/April/2007
|
||||
*
|
||||
*/
|
||||
class file
|
||||
{
|
||||
var $fileInfo = "";
|
||||
var $filePath = "";
|
||||
var $fileStat = "";
|
||||
var $mask = '0775';
|
||||
var $debug = false;
|
||||
var $errors = array();
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $path the path to a file or folder
|
||||
*/
|
||||
function __construct($path = null)
|
||||
{
|
||||
if(!is_null($path))
|
||||
{
|
||||
if(file_exists($path))
|
||||
{
|
||||
$this->filePath = $path;
|
||||
if(is_file($this->filePath))
|
||||
{
|
||||
$this->fileStat = @stat($path);
|
||||
$this->fileInfo['size'] = $this->fileStat[7];
|
||||
$this->fileInfo['atime'] = $this->fileStat[8];
|
||||
$this->fileInfo['ctime'] = $this->fileStat[10];
|
||||
$this->fileInfo['mtime'] = $this->fileStat[9];
|
||||
$this->fileInfo['path'] = $path;
|
||||
$this->fileInfo['name'] = basename($path);
|
||||
$this->fileInfo['is_writable'] = $this->isWritable();
|
||||
$this->fileInfo['is_readable'] = $this->isReadable();
|
||||
}elseif(is_dir($this->filePath))
|
||||
{
|
||||
$this->fileStat = @stat($path);
|
||||
$this->fileInfo['name'] = basename($path);
|
||||
$this->fileInfo['path'] = $path;
|
||||
$this->fileInfo['atime'] = $this->fileStat[8];
|
||||
$this->fileInfo['ctime'] = $this->fileStat[10];
|
||||
$this->fileInfo['mtime'] = $this->fileStat[9];
|
||||
$this->fileInfo['is_writable'] = $this->isWritable();
|
||||
$this->fileInfo['is_readable'] = $this->isReadable();
|
||||
}
|
||||
}else
|
||||
{
|
||||
trigger_error('No such file exists. ' . $path, E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* contructor
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
function file($path=null)
|
||||
{
|
||||
$this->__construct($path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if a file or folder writable
|
||||
*
|
||||
* @param file path $path
|
||||
* @return boolean
|
||||
*/
|
||||
function isWritable($path=null)
|
||||
{
|
||||
$path = (is_null($path)?$this->filePath:$path);
|
||||
if (DIRECTORY_SEPARATOR == "\\")
|
||||
{
|
||||
$path = slashToBackslash($path);
|
||||
if(is_file($path))
|
||||
{
|
||||
$fp = @fopen($path,'ab');
|
||||
if($fp)
|
||||
{
|
||||
@fclose($fp);
|
||||
return true;
|
||||
}
|
||||
}elseif(is_dir($path))
|
||||
{
|
||||
$path = addTrailingSlash($path);
|
||||
$tmp = uniqid(time());
|
||||
if (@touch($path . $tmp))
|
||||
{
|
||||
@unlink($path . $tmp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
return @is_writable(slashToBackslash($path));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Returns true if the files is readable.
|
||||
*
|
||||
* @return boolean true if the files is readable.
|
||||
*/
|
||||
function isReadable($path =null)
|
||||
{
|
||||
$path = is_null($path)?$this->filePath:$path;
|
||||
return @is_readable(slashToBackslash($path));
|
||||
}
|
||||
/**
|
||||
* change the modified time
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $time
|
||||
* @return boolean
|
||||
*/
|
||||
function setLastModified($path=null, $time)
|
||||
{
|
||||
$path = is_null($path)?$this->filePath:$path;
|
||||
$time = is_null($time)?time():$time;
|
||||
return @touch(slashToBackslash($path), $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new folder
|
||||
*
|
||||
* @path the path for the new folder
|
||||
* @mask
|
||||
* @dirOwner
|
||||
* @return boolean
|
||||
*/
|
||||
function mkdir($path = null, $mask=null, $dirOwner='')
|
||||
{
|
||||
$path = is_null($path)?$this->filePath:$path;
|
||||
if(!file_exists($path))
|
||||
{
|
||||
$mask = is_null($mask)?$this->mask:$mask;
|
||||
$status = @mkdir(slashToBackslash($path));
|
||||
if ($mask)
|
||||
{
|
||||
@chmod(slashToBackslash($path), intval($mask, 8));
|
||||
}
|
||||
if($dirOwner)
|
||||
{
|
||||
$this->chown(slashToBackslash($path), $dirOwner);
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
/**
|
||||
* change the own of a file or folder
|
||||
*
|
||||
* @param the file path $path
|
||||
* @param $owner
|
||||
*/
|
||||
function chown($path, $owner)
|
||||
{
|
||||
if(!empty($owner))
|
||||
{
|
||||
$owners = explode(":", $owner);
|
||||
if(!empty($owners[0]))
|
||||
@chown($path, $owners[0]);
|
||||
if(!empty($owners[1]))
|
||||
@chgrp($path, $owner[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file, or recursively copy a folder and its contents
|
||||
* @author Aidan Lister <aidan@php.net>
|
||||
* @author Paul Scott
|
||||
* @version 1.0.1
|
||||
* @param string $source Source path
|
||||
* @param string $dest Destination path
|
||||
* @return bool Returns TRUE on success, FALSE on failure
|
||||
*/
|
||||
function copyTo($source, $dest)
|
||||
{
|
||||
$source = removeTrailingSlash(backslashToSlash($source));
|
||||
$dest = removeTrailingSlash(backslashToSlash($dest));
|
||||
if(!file_exists($dest) || !is_dir($dest))
|
||||
{
|
||||
if(!$this->mkdir($dest))
|
||||
{
|
||||
$this->_debug('Unable to create folder (' . $dest . ")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Copy in to your self?
|
||||
if (getAbsPath($source) == getAbsPath($dest))
|
||||
{
|
||||
$this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest));
|
||||
return false;
|
||||
}
|
||||
// Simple copy for a file
|
||||
if (is_file($source))
|
||||
{
|
||||
$dest = addTrailingSlash($dest) . (basename($source));
|
||||
if(file_exists($dest))
|
||||
{
|
||||
return false;
|
||||
}else {
|
||||
|
||||
return copy($source, $dest);
|
||||
}
|
||||
|
||||
|
||||
}elseif(is_dir($source))
|
||||
{
|
||||
// Loop through the folder
|
||||
if(file_exists(addTrailingSlash($dest) . basename($source)))
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source)))
|
||||
{
|
||||
if(!$this->mkdir(addTrailingSlash($dest) . basename($source)))
|
||||
{
|
||||
$this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$handle = opendir($source);
|
||||
while(false !== ($readdir = readdir($handle)))
|
||||
{
|
||||
if($readdir != '.' && $readdir != '..')
|
||||
{
|
||||
$path = addTrailingSlash($source).'/'.$readdir;
|
||||
$this->copyTo($path, addTrailingSlash($dest) . basename($source));
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* get next available file name
|
||||
*
|
||||
* @param string $fileToMove the path of the file will be moved to
|
||||
* @param string $destFolder the path of destination folder
|
||||
* @return string
|
||||
*/
|
||||
function getNextAvailableFileName($fileToMove, $destFolder)
|
||||
{
|
||||
|
||||
$folderPath = addslashes(backslashToSlash(getParentPath($fileToMove)));
|
||||
$destFolder = addslashes(backslashToSlash(getParentPath($destFolder)));
|
||||
$finalPath = $destFolder . basename($fileToMove);
|
||||
if(file_exists($fileToMove))
|
||||
{
|
||||
if(is_file())
|
||||
{
|
||||
$fileExt = getFileExt($fileToMove);
|
||||
$fileBaseName = basename($fileToMove, '.' . $fileExt);
|
||||
$count = 1;
|
||||
while(file_exists($destFolder . $fileBaseName . $count . "." . $fileExt))
|
||||
{
|
||||
$count++;
|
||||
}
|
||||
$filePath = $destFolder . $fileBaseName . $count . "." . $fileExt;
|
||||
}elseif(is_dir())
|
||||
{
|
||||
$folderName = basename($fileToMove);
|
||||
$count = 1;
|
||||
while(file_exists($destFolder . $folderName . $count))
|
||||
{
|
||||
$count++;
|
||||
}
|
||||
$filePath = $destFolder . $fileBaseName . $count;
|
||||
}
|
||||
|
||||
}
|
||||
return $finalPath;
|
||||
}
|
||||
/**
|
||||
* get file information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getFileInfo()
|
||||
{
|
||||
return $this->fileInfo;
|
||||
}
|
||||
/**
|
||||
* close
|
||||
*
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$this->fileInfo = null;
|
||||
$this->fileStat = null;
|
||||
}
|
||||
/**
|
||||
* delete a file or a folder and all contents within that folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean
|
||||
*/
|
||||
function delete($path = null)
|
||||
{
|
||||
$path = is_null($path)?$this->filePath:$path;
|
||||
if(file_exists($path))
|
||||
{
|
||||
if(is_file($path))
|
||||
{
|
||||
return @unlink($path);
|
||||
}elseif(is_dir($path))
|
||||
{
|
||||
return $this->__recursive_remove_directory($path);
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* empty a folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean
|
||||
*/
|
||||
function emptyFolder($path)
|
||||
{
|
||||
$path = is_null($path)?$this->filePath:"";
|
||||
if(file_exists($path) && is_dir($path))
|
||||
{
|
||||
return $this->__recursive_remove_directory($path, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _debug($info)
|
||||
{
|
||||
if($this->debug)
|
||||
{
|
||||
echo $info . "<br>\n";
|
||||
}else
|
||||
{
|
||||
$this->errors[] = $info;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* recursive_remove_directory( directory to delete, empty )
|
||||
* expects path to directory and optional TRUE / FALSE to empty
|
||||
* of course PHP has to have the rights to delete the directory
|
||||
* you specify and all files and folders inside the directory
|
||||
*
|
||||
* to use this function to totally remove a directory, write:
|
||||
* recursive_remove_directory('path/to/directory/to/delete');
|
||||
* to use this function to empty a directory, write:
|
||||
* recursive_remove_directory('path/to/full_directory',TRUE);
|
||||
* @param string $directory
|
||||
* @param boolean $empty
|
||||
* @return boolean
|
||||
*/
|
||||
function __recursive_remove_directory($directory, $empty=FALSE)
|
||||
{
|
||||
// if the path has a slash at the end we remove it here
|
||||
if(substr($directory,-1) == '/')
|
||||
{
|
||||
$directory = substr($directory,0,-1);
|
||||
}
|
||||
|
||||
// if the path is not valid or is not a directory ...
|
||||
if(!file_exists($directory) || !is_dir($directory))
|
||||
{
|
||||
// ... we return false and exit the function
|
||||
return FALSE;
|
||||
|
||||
// ... if the path is not readable
|
||||
}elseif(!is_readable($directory))
|
||||
{
|
||||
// ... we return false and exit the function
|
||||
return FALSE;
|
||||
|
||||
// ... else if the path is readable
|
||||
}else{
|
||||
|
||||
// we open the directory
|
||||
$handle = @opendir($directory);
|
||||
|
||||
// and scan through the items inside
|
||||
while (FALSE !== ($item = @readdir($handle)))
|
||||
{
|
||||
// if the filepointer is not the current directory
|
||||
// or the parent directory
|
||||
if($item != '.' && $item != '..')
|
||||
{
|
||||
// we build the new path to delete
|
||||
$path = $directory.'/'.$item;
|
||||
|
||||
// if the new path is a directory
|
||||
if(is_dir($path)) {
|
||||
// we call this function with the new path
|
||||
$this->__recursive_remove_directory($path);
|
||||
|
||||
// if the new path is a file
|
||||
}else{
|
||||
// we remove the file
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
// close the directory
|
||||
@closedir($handle);
|
||||
|
||||
// if the option to empty is not set to true
|
||||
if($empty == FALSE)
|
||||
{
|
||||
// try to delete the now empty directory
|
||||
if(!@rmdir($directory))
|
||||
{
|
||||
// return false if not possible
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// return success
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* class history
|
||||
* this class used to keep records of any changed to uploaded images under a session
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/May/2007
|
||||
*
|
||||
*/
|
||||
class History
|
||||
{
|
||||
var $history = array(); //keep all changes
|
||||
var $path = ''; //path to the iamge
|
||||
var $session = null;
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $path the path to the image
|
||||
* @param object $session an instance of session class
|
||||
*/
|
||||
function __construct($path, &$session)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->session = &$session;
|
||||
if(!isset($_SESSION[$this->path]))
|
||||
{
|
||||
$_SESSION[$this->path] = array();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $path the path to the image
|
||||
* @param object $session an instance of session class
|
||||
*/
|
||||
function History($path, &$session)
|
||||
{
|
||||
$this->__construct($path, $session);
|
||||
}
|
||||
|
||||
/**
|
||||
* keep tracks of each changes made to an image
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $info array('name', 'restorable', 'is_original')
|
||||
*/
|
||||
function add($info)
|
||||
{
|
||||
$_SESSION[$this->path][] = $info;
|
||||
}
|
||||
/**
|
||||
* get the lastest changes for restore
|
||||
*
|
||||
* @return array array('name', 'restorable', 'is_original')
|
||||
*/
|
||||
function getNumRestorable()
|
||||
{
|
||||
$output = 0;
|
||||
if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
|
||||
{
|
||||
foreach($_SESSION[$this->path] as $k=>$v)
|
||||
{
|
||||
if(!empty($v['restorable']) && empty($v['is_original']))
|
||||
{
|
||||
if(file_exists($this->session->getSessionDir() . $v['name']))
|
||||
{
|
||||
$output++;
|
||||
}else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the path of image which keep the lastest changes
|
||||
*
|
||||
* @return return empty array when failed
|
||||
*/
|
||||
function getLastestRestorable()
|
||||
{
|
||||
if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
|
||||
{
|
||||
$sessionImages = array_reverse($_SESSION[$this->path], true);
|
||||
$lastestKey = '';
|
||||
foreach($sessionImages as $k=>$v)
|
||||
{
|
||||
if($v['restorable'] && empty($v['is_original']) && file_exists($this->session->getSessionDir() . $v['name']))
|
||||
{
|
||||
return $sessionImages[$k];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return array();
|
||||
|
||||
}
|
||||
/**
|
||||
* get the original image which is kept in the session folder
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getOriginalImage()
|
||||
{
|
||||
$outputs = array();
|
||||
if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
|
||||
{
|
||||
$sessionImages = array_reverse($_SESSION[$this->path], true);
|
||||
foreach($sessionImages as $k=>$v)
|
||||
{
|
||||
if(!empty($v['is_original']))
|
||||
{
|
||||
if(file_exists($this->session->getSessionDir() . $v['name']))
|
||||
{
|
||||
return array('info'=>$_SESSION[$this->path][$k], 'key'=>$k);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return $outputs;
|
||||
|
||||
}
|
||||
/**
|
||||
* remove the lastest restorable state
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function restore()
|
||||
{
|
||||
if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
|
||||
{
|
||||
$sessionImages = array_reverse($_SESSION[$this->path], true);
|
||||
$lastestKey = '';
|
||||
foreach($sessionImages as $k=>$v)
|
||||
{
|
||||
if($v['restorable'] && empty($v['is_original']))
|
||||
{
|
||||
unset($_SESSION[$k]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,789 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* this class provide functions to edit an image, e.g. resize, rotate, flip, crop
|
||||
* @author Logan Cai cailongqun [at] yahoo [dot] com [dot] cn
|
||||
* @link www.phpletter.com
|
||||
* @version 0.9
|
||||
* @since 14/May/2007
|
||||
* @name Image
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
class Image
|
||||
{
|
||||
var $_debug = false;
|
||||
var $_errors = array();
|
||||
var $gdInfo = array(); //keep all information of GD extension
|
||||
var $_imgOrig = null; //the hanlder of original image
|
||||
var $_imgFinal = null; //the handler of final image
|
||||
var $imageFile = null;
|
||||
var $transparentColorRed = null;
|
||||
var $transparentColorGreen = null;
|
||||
var $transparentColorBlue = null;
|
||||
var $chmod = 0755;
|
||||
var $_imgInfoOrig = array(
|
||||
'name'=>'',
|
||||
'ext'=>'',
|
||||
'size'=>'',
|
||||
'width'=>'',
|
||||
'height'=>'',
|
||||
'type'=>'',
|
||||
'path'=>'',
|
||||
);
|
||||
var $_imgInfoFinal = array(
|
||||
'name'=>'',
|
||||
'ext'=>'',
|
||||
'size'=>'',
|
||||
'width'=>'',
|
||||
'height'=>'',
|
||||
'type'=>'',
|
||||
'path'=>'',
|
||||
);
|
||||
var $_imgQuality = 90;
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param boolean $debug
|
||||
* @return Image
|
||||
*/
|
||||
|
||||
function __construct($debug = false)
|
||||
{
|
||||
$this->enableDebug($debug);
|
||||
$this->gdInfo = $this->getGDInfo();
|
||||
}
|
||||
function Image($debug = false)
|
||||
{
|
||||
$this->__construct($debug);
|
||||
}
|
||||
/**
|
||||
* enable to debug
|
||||
*
|
||||
* @param boolean $value
|
||||
*/
|
||||
function enableDebug($value)
|
||||
{
|
||||
$this->_debug = ($value?true:false);
|
||||
}
|
||||
/**
|
||||
* check if debug enable
|
||||
* @return boolean
|
||||
*/
|
||||
function _isDebugEnable()
|
||||
{
|
||||
return $this->_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* append to errors array and shown the each error when the debug turned on
|
||||
*
|
||||
* @param string $string
|
||||
* @return void
|
||||
* @access private
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function _debug($value)
|
||||
{
|
||||
$this->_errors[] = $value;
|
||||
if ($this->_debug)
|
||||
{
|
||||
echo $value . "<br />\n";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* show erros
|
||||
*
|
||||
*/
|
||||
function showErrors()
|
||||
{
|
||||
if(sizeof($this->_errors))
|
||||
{
|
||||
foreach($this->_errors as $error)
|
||||
{
|
||||
echo $error . "<br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load an image from the file system.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return bool
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function loadImage($filename)
|
||||
{
|
||||
$ext = strtolower($this->_getExtension($filename));
|
||||
$func = 'imagecreatefrom' . ($ext == 'jpg' ? 'jpeg' : $ext);
|
||||
if (!$this->_isSupported($filename, $ext, $func, false)) {
|
||||
return false;
|
||||
}
|
||||
if($ext == "gif")
|
||||
{
|
||||
// the following part gets the transparency color for a gif file
|
||||
// this code is from the PHP manual and is written by
|
||||
// fred at webblake dot net and webmaster at webnetwizard dotco dotuk, thanks!
|
||||
$fp = @fopen($filename, "rb");
|
||||
$result = @fread($fp, 13);
|
||||
$colorFlag = ord(substr($result,10,1)) >> 7;
|
||||
$background = ord(substr($result,11));
|
||||
if ($colorFlag) {
|
||||
$tableSizeNeeded = ($background + 1) * 3;
|
||||
$result = @fread($fp, $tableSizeNeeded);
|
||||
$this->transparentColorRed = ord(substr($result, $background * 3, 1));
|
||||
$this->transparentColorGreen = ord(substr($result, $background * 3 + 1, 1));
|
||||
$this->transparentColorBlue = ord(substr($result, $background * 3 + 2, 1));
|
||||
}
|
||||
fclose($fp);
|
||||
// -- here ends the code related to transparency handling
|
||||
}
|
||||
$this->_imgOrig = @$func($filename);
|
||||
if ($this->_imgOrig == null) {
|
||||
$this->_debug("The image could not be created from the '$filename' file using the '$func' function.");
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
$this->imageFile = $filename;
|
||||
$this->_imgInfoOrig = array(
|
||||
'name'=>basename($filename),
|
||||
'ext'=>$ext,
|
||||
'size'=>filesize($filename),
|
||||
'path'=>$filename,
|
||||
);
|
||||
$imgInfo = $this->_getImageInfo($filename);
|
||||
if(sizeof($imgInfo))
|
||||
{
|
||||
foreach($imgInfo as $k=>$v)
|
||||
{
|
||||
$this->_imgInfoOrig[$k] = $v;
|
||||
$this->_imgInfoFinal[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an image from a string (eg. from a database table)
|
||||
*
|
||||
* @param string $string
|
||||
* @return bool
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function loadImageFromString($string)
|
||||
{
|
||||
$this->imageFile = $filename;
|
||||
$this->_imgOrig = imagecreatefromstring($string);
|
||||
if (!$this->_imgOrig) {
|
||||
$this->_debug('The image (supplied as a string) could not be created.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the modified image
|
||||
*
|
||||
* @param string $filename
|
||||
* @param int $quality
|
||||
* @param string $forcetype
|
||||
* @return bool
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function saveImage($filename, $quality = 90, $forcetype = '')
|
||||
{
|
||||
if ($this->_imgFinal == null) {
|
||||
$this->_debug('No changes intend to be made.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$ext = ($forcetype == '') ? $this->_getExtension($filename) : strtolower($forcetype);
|
||||
$func = 'image' . ($ext == 'jpg' ? 'jpeg' : $ext);
|
||||
if (!$this->_isSupported($filename, $ext, $func, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$saved = false;
|
||||
switch($ext)
|
||||
{
|
||||
case 'gif':
|
||||
if ($this->gdInfo['Truecolor Support'] && imageistruecolor($this->_imgFinal))
|
||||
{
|
||||
imagetruecolortopalette($this->_imgFinal, false, 255);
|
||||
}
|
||||
case 'png':
|
||||
$saved = $func($this->_imgFinal, $filename);
|
||||
break;
|
||||
case 'jpg':
|
||||
$saved = $func($this->_imgFinal, $filename, $quality);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($saved === false)
|
||||
{
|
||||
$this->_debug("The image could not be saved to the '$filename' file as the file type '$ext' using the '$func' function.");
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
$this->_imgInfoFinal['size'] = @filesize($filename);
|
||||
@chmod($filename, intval($this->chmod, 8));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Shows the masked image without any saving
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $quality
|
||||
* @return bool
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function showImage($type = '', $quality = '')
|
||||
{
|
||||
if ($this->_imgFinal == null) {
|
||||
$this->_debug('There is no cropped image to show.');
|
||||
return false;
|
||||
}
|
||||
$type = (!empty($type)?$type:$this->_imgInfoOrig['ext']);
|
||||
$quality = (!empty($quality)?$quality:$this->_imgQuality);
|
||||
|
||||
$type = strtolower($type);
|
||||
$func = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
|
||||
$head = 'image/' . ($type == 'jpg' ? 'jpeg' : $type);
|
||||
|
||||
if (!$this->_isSupported('[showing file]', $type, $func, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
header("Content-type: $head");
|
||||
switch($type)
|
||||
{
|
||||
case 'gif':
|
||||
if ($this->gdInfo['Truecolor Support'] && imageistruecolor($this->_imgFinal))
|
||||
{
|
||||
@imagetruecolortopalette($this->_imgFinal, false, 255);
|
||||
}
|
||||
case 'png':
|
||||
$func($this->_imgFinal);
|
||||
break;
|
||||
case 'jpg':
|
||||
$func($this->_imgFinal, '', $quality);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for cropping image
|
||||
*
|
||||
* @param int $dst_x
|
||||
* @param int $dst_y
|
||||
* @param int $dst_w
|
||||
* @param int $dst_h
|
||||
* @return bool
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function crop($dst_x, $dst_y, $dst_w, $dst_h)
|
||||
{
|
||||
if ($this->_imgOrig == null) {
|
||||
$this->_debug('The original image has not been loaded.');
|
||||
return false;
|
||||
}
|
||||
if (($dst_w <= 0) || ($dst_h <= 0)) {
|
||||
$this->_debug('The image could not be cropped because the size given is not valid.');
|
||||
return false;
|
||||
}
|
||||
if (($dst_w > imagesx($this->_imgOrig)) || ($dst_h > imagesy($this->_imgOrig))) {
|
||||
$this->_debug('The image could not be cropped because the size given is larger than the original image.');
|
||||
return false;
|
||||
}
|
||||
$this->_createFinalImageHandler($dst_w, $dst_h);
|
||||
if ($this->gdInfo['Truecolor Support'])
|
||||
{
|
||||
if(!@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
|
||||
{
|
||||
$this->_debug('Unable crop the image.');
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(!@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
|
||||
{
|
||||
$this->_debug('Unable crop the image.');
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
$this->_imgInfoFinal['width'] = $dst_w;
|
||||
$this->_imgInfoFinal['height'] = $dst_h;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize the Image in the X and/or Y direction
|
||||
* If either is 0 it will be scaled proportionally
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param mixed $new_x
|
||||
* @param mixed $new_y
|
||||
* @param boolean $constraint keep to resize the image proportionally
|
||||
* @param boolean $unchangeIfsmaller keep the orignial size if the orignial smaller than the new size
|
||||
*
|
||||
*
|
||||
* @return mixed none or PEAR_error
|
||||
*/
|
||||
function resize( $new_x, $new_y, $constraint= false, $unchangeIfsmaller=false)
|
||||
{
|
||||
if(!$this->_imgOrig)
|
||||
{
|
||||
$this->_debug('No image fould.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_x = (int)($new_x);
|
||||
$new_y = (int)($new_y);
|
||||
if($new_x <=0 || $new_y <= 0)
|
||||
{
|
||||
$this->_debug('either of new width or height can be zeor or less.');
|
||||
}else
|
||||
{
|
||||
|
||||
if($constraint)
|
||||
{
|
||||
if($new_x < 1 && $new_y < 1)
|
||||
{
|
||||
$new_x = $this->_imgInfoOrig['width'];
|
||||
$new_y = $this->_imgInfoOrig['height'];
|
||||
}elseif($new_x < 1)
|
||||
{
|
||||
$new_x = floor($new_y / $this->_imgInfoOrig['height'] * $this->_imgInfoOrig['width']);
|
||||
|
||||
}elseif($new_y < 1)
|
||||
{
|
||||
$new_y = floor($new_x / $this->_imgInfoOrig['width'] * $this->_imgInfoOrig['height']);
|
||||
}else
|
||||
{
|
||||
$scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']) ;
|
||||
$new_x = floor($scale*$this->_imgInfoOrig['width']);
|
||||
$new_y = floor($scale*$this->_imgInfoOrig['height']);
|
||||
}
|
||||
}
|
||||
if($unchangeIfsmaller)
|
||||
{
|
||||
if($this->_imgInfoOrig['width'] < $new_x && $this->_imgInfoOrig['height'] < $new_y )
|
||||
{
|
||||
$new_x = $this->_imgInfoOrig['width'];
|
||||
$new_y = $this->_imgInfoOrig['height'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(is_null($this->_imgOrig))
|
||||
{
|
||||
$this->loadImage($filePath);
|
||||
}
|
||||
if(sizeof($this->_errors) == 0)
|
||||
{
|
||||
return $this->_resize($new_x, $new_y);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // End resize
|
||||
/**
|
||||
* resize the image and return the thumbnail image details array("width"=>, "height"=>, "name")
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param int $new_x the thumbnail width
|
||||
* @param int $new_y the thumbnail height
|
||||
* @param string $mode can be save, view and both
|
||||
* @return unknown
|
||||
*/
|
||||
function _resize( $new_x, $new_y)
|
||||
{
|
||||
$this->_createFinalImageHandler($new_x, $new_y);
|
||||
// hacks fot transparency of png24 files
|
||||
if ($this->_imgInfoOrig['type'] == 'png')
|
||||
{
|
||||
@imagealphablending($this->_imgFinal, false);
|
||||
if(function_exists('ImageCopyResampled'))
|
||||
{
|
||||
@ImageCopyResampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
|
||||
} else {
|
||||
@ImageCopyResized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
|
||||
}
|
||||
@imagesavealpha($this->_imgFinal, true);
|
||||
|
||||
}else
|
||||
{//for the rest image
|
||||
if(function_exists('ImageCopyResampled'))
|
||||
{
|
||||
@ImageCopyResampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
|
||||
} else {
|
||||
@ImageCopyResized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->_imgInfoFinal['width'] = $new_x;
|
||||
$this->_imgInfoFinal['height'] = $new_y;
|
||||
$this->_imgInfoFinal['name'] = basename($this->_imgInfoOrig['name']);
|
||||
$this->_imgInfoFinal['path'] = $this->_imgInfoOrig['path'];
|
||||
if($this->_imgFinal)
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
$this->_debug('Unable to resize the image on the fly.');
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Get the extension of a file name
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function _getExtension($file)
|
||||
{
|
||||
$ext = '';
|
||||
if (strrpos($file, '.')) {
|
||||
$ext = strtolower(substr($file, (strrpos($file, '.') ? strrpos($file, '.') + 1 : strlen($file)), strlen($file)));
|
||||
}
|
||||
return $ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate whether image reading/writing routines are valid.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $extension
|
||||
* @param string $function
|
||||
* @param bool $write
|
||||
* @return bool
|
||||
* @access private
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function _isSupported($filename, $extension, $function, $write = false)
|
||||
{
|
||||
|
||||
$giftype = ($write) ? ' Create Support' : ' Read Support';
|
||||
$support = strtoupper($extension) . ($extension == 'gif' ? $giftype : ' Support');
|
||||
|
||||
if (!isset($this->gdInfo[$support]) || $this->gdInfo[$support] == false) {
|
||||
$request = ($write) ? 'saving' : 'reading';
|
||||
$this->_debug("Support for $request the file type '$extension' cannot be found.");
|
||||
return false;
|
||||
}
|
||||
if (!function_exists($function)) {
|
||||
$request = ($write) ? 'save' : 'read';
|
||||
$this->_debug("The '$function' function required to $request the '$filename' file cannot be found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* flip image horizotally or vertically
|
||||
*
|
||||
* @param string $direction
|
||||
* @return boolean
|
||||
*/
|
||||
function flip($direction="horizontal")
|
||||
{
|
||||
$this->_createFinalImageHandler($this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
|
||||
if($direction != "vertical")
|
||||
{
|
||||
$dst_x = 0;
|
||||
$dst_y = 0;
|
||||
$src_x = $this->_imgInfoOrig['width'] -1;
|
||||
$src_y = 0;
|
||||
$dst_w = $this->_imgInfoOrig['width'];
|
||||
$dst_h = $this->_imgInfoOrig['height'];
|
||||
$src_w = 0 - $this->_imgInfoOrig['width'];
|
||||
$src_h = $this->_imgInfoOrig['height'];
|
||||
|
||||
}else
|
||||
{
|
||||
$dst_x = 0;
|
||||
$dst_y = 0;
|
||||
$src_x = 0;
|
||||
$src_y = $this->_imgInfoOrig['height'] - 1;
|
||||
$dst_w = $this->_imgInfoOrig['width'];
|
||||
$dst_h = $this->_imgInfoOrig['height'];
|
||||
$src_w = $this->_imgInfoOrig['width'];
|
||||
$src_h = 0 - $this->_imgInfoOrig['height'];
|
||||
}
|
||||
if(function_exists('ImageCopyResampled')){
|
||||
ImageCopyResampled($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||
} else {
|
||||
ImageCopyResized($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||
}
|
||||
$this->_imgInfoFinal['width'] = $dst_w;
|
||||
$this->_imgInfoFinal['height'] = $dst_h;
|
||||
$this->_imgInfoFinal['name'] = basename($this->imageFile);
|
||||
$this->_imgInfoFinal['path'] = $this->imageFile;
|
||||
if($this->_imgFinal)
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
$this->_debug('Unable to resize the image on the fly.');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* flip vertically
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function flipVertical()
|
||||
{
|
||||
return $this->flip('vertical');
|
||||
}
|
||||
/**
|
||||
* flip horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function flipHorizontal()
|
||||
{
|
||||
return $this->flip('horizontal');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the GD version information
|
||||
*
|
||||
* @param bool $versionOnly
|
||||
* @return array
|
||||
* @access private
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function getGDInfo($versionOnly = false)
|
||||
{
|
||||
$outputs = array();
|
||||
if (function_exists('gd_info'))
|
||||
{
|
||||
$outputs = gd_info();
|
||||
} else
|
||||
{
|
||||
$gd = array(
|
||||
'GD Version' => '',
|
||||
'GIF Read Support' => false,
|
||||
'GIF Create Support' => false,
|
||||
'JPG Support' => false,
|
||||
'PNG Support' => false,
|
||||
'FreeType Support' => false,
|
||||
'FreeType Linkage' => '',
|
||||
'T1Lib Support' => false,
|
||||
'WBMP Support' => false,
|
||||
'XBM Support' => false
|
||||
);
|
||||
ob_start();
|
||||
phpinfo();
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
foreach (explode("\n", $buffer) as $line) {
|
||||
$line = array_map('trim', (explode('|', strip_tags(str_replace('</td>', '|', $line)))));
|
||||
if (isset($gd[$line[0]])) {
|
||||
if (strtolower($line[1]) == 'enabled') {
|
||||
$gd[$line[0]] = true;
|
||||
} else {
|
||||
$gd[$line[0]] = $line[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
$outputs = $gd;
|
||||
}
|
||||
|
||||
if (isset($outputs['JIS-mapped Japanese Font Support'])) {
|
||||
unset($outputs['JIS-mapped Japanese Font Support']);
|
||||
}
|
||||
if (function_exists('imagecreatefromgd')) {
|
||||
$outputs['GD Support'] = true;
|
||||
}
|
||||
if (function_exists('imagecreatefromgd2')) {
|
||||
$outputs['GD2 Support'] = true;
|
||||
}
|
||||
if (preg_match('/^(bundled|2)/', $outputs['GD Version'])) {
|
||||
$outputs['Truecolor Support'] = true;
|
||||
} else {
|
||||
$outputs['Truecolor Support'] = false;
|
||||
}
|
||||
if ($outputs['GD Version'] != '') {
|
||||
$match = array();
|
||||
if (preg_match('/([0-9\.]+)/', $outputs['GD Version'], $match)) {
|
||||
$foo = explode('.', $match[0]);
|
||||
$outputs['Version'] = array('major' => isset($foo[0])?$foo[0]:'', 'minor' => isset($foo[1])?$foo[1]:'', 'patch' => isset($foo[2])?$foo:"");
|
||||
}
|
||||
}
|
||||
|
||||
return ($versionOnly) ? $outputs['Version'] : $outputs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the resources used by the images.
|
||||
*
|
||||
* @param bool $original
|
||||
* @return void
|
||||
* @access public
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function DestroyImages($original = true)
|
||||
{
|
||||
if(!is_null($this->_imgFinal))
|
||||
{
|
||||
@imagedestroy($this->_imgFinal);
|
||||
}
|
||||
$this->_imgFinal = null;
|
||||
if ($original && !is_null($this->_imgOrig)) {
|
||||
@imagedestroy($this->_imgOrig);
|
||||
$this->_imgOrig = null;
|
||||
}
|
||||
}
|
||||
|
||||
function getImageInfo($imagePath)
|
||||
{
|
||||
return $this->_getImageInfo($imagePath);
|
||||
}
|
||||
/**
|
||||
* get image information, e.g. width, height, type
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function _getImageInfo($imagePath)
|
||||
{
|
||||
$outputs = array();
|
||||
$imageInfo = @GetImageSize($imagePath);
|
||||
if ($imageInfo && is_array($imageInfo))
|
||||
{
|
||||
switch($imageInfo[2]){
|
||||
case 1:
|
||||
$type = 'gif';
|
||||
break;
|
||||
case 2:
|
||||
$type = 'jpeg';
|
||||
break;
|
||||
case 3:
|
||||
$type = 'png';
|
||||
break;
|
||||
case 4:
|
||||
$type = 'swf';
|
||||
break;
|
||||
case 5:
|
||||
$type = 'psd';
|
||||
case 6:
|
||||
$type = 'bmp';
|
||||
case 7:
|
||||
case 8:
|
||||
$type = 'tiff';
|
||||
default:
|
||||
$type = '';
|
||||
}
|
||||
$outputs['width'] = $imageInfo[0];
|
||||
$outputs['height'] = $imageInfo[1];
|
||||
$outputs['type'] = $type;
|
||||
$outputs['ext'] = $this->_getExtension($imagePath);
|
||||
} else {
|
||||
$this->_debug('Unable locate the image or read images information.');
|
||||
}
|
||||
return $outputs;
|
||||
|
||||
}
|
||||
function rotate($angle, $bgColor=0)
|
||||
{
|
||||
$angle = (int)($angle) -360;
|
||||
while($angle <0)
|
||||
{
|
||||
$angle += 360;
|
||||
}
|
||||
|
||||
|
||||
if($this->_imgFinal = imagerotate($this->_imgOrig, $angle))
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* get the original image info
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getOriginalImageInfo()
|
||||
{
|
||||
return $this->_imgInfoOrig;
|
||||
}
|
||||
/**
|
||||
* return the final image info
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getFinalImageInfo()
|
||||
{
|
||||
if($this->_imgInfoFinal['width'] == '')
|
||||
{
|
||||
if(is_null($this->_imgFinal))
|
||||
{
|
||||
$this->_imgInfoFinal = $this->_imgInfoOrig;
|
||||
}else
|
||||
{
|
||||
$this->_imgInfoFinal['width'] = @imagesx($this->_imgFinal);
|
||||
$this->_imgInfoFinal['height'] = @imagesy($this->_imgFinal);
|
||||
}
|
||||
}
|
||||
return $this->_imgInfoFinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* create final image handler
|
||||
*
|
||||
* @access private
|
||||
* @param $dst_w width
|
||||
* @param $dst_h height
|
||||
* @return boolean
|
||||
* @copyright original from noname at nivelzero dot ro
|
||||
*/
|
||||
function _createFinalImageHandler($dst_w, $dst_h)
|
||||
{
|
||||
if(function_exists('ImageCreateTrueColor'))
|
||||
{
|
||||
$this->_imgFinal = @ImageCreateTrueColor($dst_w,$dst_h);
|
||||
} else {
|
||||
$this->_imgFinal = @ImageCreate($dst_w,$dst_h);
|
||||
}
|
||||
if (!is_null($this->transparentColorRed) && !is_null($this->transparentColorGreen) && !is_null($this->transparentColorBlue)) {
|
||||
|
||||
$transparent = @imagecolorallocate($targetImageIdentifier, $this->transparentColorRed, $this->transparentColorGreen, $this->transparentColorBlue);
|
||||
@imagefilledrectangle($this->_imgFinal, 0, 0, $dst_w, $dst_h, $transparent);
|
||||
@imagecolortransparent($this->_imgFinal, $transparent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,373 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* file listing
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/April/2007
|
||||
*
|
||||
*/
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
|
||||
class manager
|
||||
{
|
||||
var $currentFolderPath;
|
||||
var $sessionAction = null; //object to session action
|
||||
var $flags = array('no'=>'noFlag', 'cut'=>'cutFlag', 'copy'=>'copyFlag');
|
||||
var $forceFolderOnTop = false; //forced to have folder shown on the top of the list
|
||||
var $currentFolderInfo = array(
|
||||
'name'=>'',
|
||||
'subdir'=>0,
|
||||
'file'=>0,
|
||||
'ctime'=>'',
|
||||
'mtime'=>'',
|
||||
'is_readable'=>'',
|
||||
'is_writable'=>'',
|
||||
'size'=>0,
|
||||
'path'=>'',
|
||||
'type'=>'folder',
|
||||
'flag'=>'noFlag',
|
||||
'friendly_path'=>'',
|
||||
);
|
||||
|
||||
var $lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
|
||||
var $folderPathIndex = "path";
|
||||
var $calculateSubdir = true;
|
||||
var $fileTypes = array(
|
||||
array(array("exe", "com"), "fileExe", SEARCH_TYPE_EXE, 0),
|
||||
array(array("gif", "jpg", "png", "bmp", "tif"), "filePicture", SEARCH_TYPE_IMG, 1),
|
||||
array(array("zip", "sit", "rar", "gz", "tar"), "fileZip", SEARCH_TYPE_ARCHIVE, 0),
|
||||
array(array("htm", "html", "php", "jsp", "asp", 'js', 'css'), "fileCode", SEARCH_TYPE_HTML, 1),
|
||||
array(array("mov", "ram", "rm", "asx", "dcr", "wmv"), "fileVideo", SEARCH_TYPE_VIDEO, 1),
|
||||
array(array("mpg", "avi", "asf", "mpeg"), "fileVideo", SEARCH_TYPE_MOVIE, 1),
|
||||
array(array("aif", "aiff", "wav", "mp3", "wma"), "fileMusic", SEARCH_TYPE_MUSIC, 1),
|
||||
array(array("swf", 'flv'), "fileFlash", SEARCH_TYPE_FLASH, 1),
|
||||
array(array("ppt"), "filePPT", SEARCH_TYPE_PPT, 0),
|
||||
array(array("rtf"), "fileRTF", SEARCH_TYPE_DOC, 0),
|
||||
array(array("doc"), "fileWord", SEARCH_TYPE_WORD, 0),
|
||||
array(array("pdf"), "fileAcrobat", SEARCH_TYPE_PDF, 0),
|
||||
array(array("xls", "csv"), "fileExcel", SEARCH_TYPE_EXCEL, 0),
|
||||
array(array("txt"), "fileText", SEARCH_TYPE_TEXT, 1),
|
||||
array(array("xml", "xsl", "dtd"), "fileXml", SEARCH_TYPE_XML, 1)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @path the path to a folder
|
||||
* @calculateSubdir force to get the subdirectories information
|
||||
*/
|
||||
function __construct($path = null, $calculateSubdir=true)
|
||||
{
|
||||
|
||||
$this->calculateSubdir = $calculateSubdir;
|
||||
if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP'))
|
||||
{
|
||||
$this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
|
||||
}
|
||||
if(!is_null($path))
|
||||
{
|
||||
$this->currentFolderPath = $path;
|
||||
|
||||
}elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
|
||||
{
|
||||
$this->currentFolderPath = $_GET[$this->folderPathIndex];
|
||||
}
|
||||
elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
|
||||
{
|
||||
$this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
|
||||
}else
|
||||
{
|
||||
$this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
|
||||
}
|
||||
|
||||
$this->currentFolderPath = (isUnderRoot($this->currentFolderPath)?backslashToSlash((addTrailingSlash($this->currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
|
||||
|
||||
if($this->calculateSubdir)
|
||||
{// keep track of this folder path in session
|
||||
$_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
|
||||
}
|
||||
if(is_dir($this->currentFolderPath))
|
||||
{
|
||||
$file = new file($this->currentFolderPath);
|
||||
$folderInfo = $file->getFileInfo();
|
||||
if(sizeof($folderInfo))
|
||||
{
|
||||
$this->currentFolderInfo['name']=basename($this->currentFolderPath);
|
||||
$this->currentFolderInfo['subdir']=0;
|
||||
$this->currentFolderInfo['file']=0;
|
||||
$this->currentFolderInfo['ctime']=$folderInfo['ctime'];
|
||||
$this->currentFolderInfo['mtime']=$folderInfo['mtime'];
|
||||
$this->currentFolderInfo['is_readable']=$folderInfo['is_readable'];
|
||||
$this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];
|
||||
$this->currentFolderInfo['path'] = $this->currentFolderPath;
|
||||
$this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath);
|
||||
$this->currentFolderInfo['type'] = "folder";
|
||||
$this->currentFolderInfo['cssClass']='folder';
|
||||
|
||||
//$this->currentFolderInfo['flag'] = $folderInfo['flag'];
|
||||
}
|
||||
}
|
||||
if($calculateSubdir && !file_exists($this->currentFolderPath))
|
||||
{
|
||||
die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setSessionAction(&$session)
|
||||
{
|
||||
$this->sessionAction = $session;
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
function manager($path = null, $calculateSubdir=true)
|
||||
{
|
||||
$this->__construct($path, $calculateSubdir);
|
||||
}
|
||||
/**
|
||||
* get current folder path
|
||||
* @return string
|
||||
*/
|
||||
function getCurrentFolderPath()
|
||||
{
|
||||
return $this->currentFolderPath;
|
||||
}
|
||||
/**
|
||||
* get the list of files and folders under this current fold
|
||||
* @return array
|
||||
*/
|
||||
function getFileList()
|
||||
{
|
||||
$outputs = array();
|
||||
$files = array();
|
||||
$folders = array();
|
||||
$tem = array();
|
||||
$dirHandler = @opendir($this->currentFolderPath);
|
||||
if($dirHandler)
|
||||
{
|
||||
while(false !== ($file = readdir($dirHandler)))
|
||||
{
|
||||
if($file != '.' && $file != '..')
|
||||
{
|
||||
$flag = $this->flags['no'];
|
||||
|
||||
if($this->sessionAction->getFolder() == $this->currentFolderPath)
|
||||
{//check if any flag associated with this folder or file
|
||||
$folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
|
||||
if(in_array($folder . $file, $this->sessionAction->get()))
|
||||
{
|
||||
if($this->sessionAction->getAction() == "copy")
|
||||
{
|
||||
$flag = $this->flags['copy'];
|
||||
}else
|
||||
{
|
||||
$flag = $this->flags['cut'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$path=$this->currentFolderPath.$file;
|
||||
if(is_dir($path) && isListingDocument($path) )
|
||||
{
|
||||
$this->currentFolderInfo['subdir']++;
|
||||
if(!$this->calculateSubdir)
|
||||
{
|
||||
}else
|
||||
{
|
||||
|
||||
$folder = $this->getFolderInfo($path);
|
||||
$folder['flag'] = $flag;
|
||||
$folders[$file] = $folder;
|
||||
$outputs[$file] = $folders[$file];
|
||||
}
|
||||
|
||||
|
||||
}elseif(is_file($path) && isListingDocument($path))
|
||||
{
|
||||
|
||||
$obj = new file($path);
|
||||
$tem = $obj->getFileInfo();
|
||||
if(sizeof($tem))
|
||||
{
|
||||
$fileType = $this->getFileType($file);
|
||||
foreach($fileType as $k=>$v)
|
||||
{
|
||||
$tem[$k] = $v;
|
||||
}
|
||||
$this->currentFolderInfo['size'] += $tem['size'];
|
||||
$this->currentFolderInfo['file']++;
|
||||
$tem['path'] = backslashToSlash($path);
|
||||
$tem['type'] = "file";
|
||||
$tem['flag'] = $flag;
|
||||
$files[$file] = $tem;
|
||||
$outputs[$file] = $tem;
|
||||
$tem = array();
|
||||
$obj->close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if($this->forceFolderOnTop)
|
||||
{
|
||||
uksort($folders, "strnatcasecmp");
|
||||
uksort($files, "strnatcasecmp");
|
||||
$outputs = array();
|
||||
foreach($folders as $v)
|
||||
{
|
||||
$outputs[] = $v;
|
||||
}
|
||||
foreach ($files as $v)
|
||||
{
|
||||
$outputs[] = $v;
|
||||
}
|
||||
}else
|
||||
{
|
||||
uksort($outputs, "strnatcasecmp");
|
||||
}
|
||||
|
||||
@closedir($dirHandler);
|
||||
}else
|
||||
{
|
||||
trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
|
||||
}
|
||||
return $outputs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get current or the specified dir information
|
||||
*
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
function getFolderInfo($path=null)
|
||||
{
|
||||
if(is_null($path))
|
||||
{
|
||||
return $this->currentFolderInfo;
|
||||
}else
|
||||
{
|
||||
$obj = new manager($path, false);
|
||||
$obj->setSessionAction($this->sessionAction);
|
||||
$obj->getFileList();
|
||||
return $obj->getFolderInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* return the file type of a file.
|
||||
*
|
||||
* @param string file name
|
||||
* @return array
|
||||
*/
|
||||
function getFileType($fileName, $checkIfDir = false)
|
||||
{
|
||||
|
||||
$ext = strtolower($this->_getExtension($fileName, $checkIfDir));
|
||||
|
||||
foreach ($this->fileTypes as $fileType)
|
||||
{
|
||||
if(in_array($ext, $fileType[0]))
|
||||
{
|
||||
return array("cssClass" => $fileType[1], "fileType" => $fileType[2], "preview" => $fileType[3], 'test'=>5);
|
||||
}
|
||||
}
|
||||
if(!empty($fileName))
|
||||
{//this is folder
|
||||
if(empty($ext))
|
||||
{
|
||||
if(is_dir($fileName))
|
||||
{
|
||||
|
||||
return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName)?'folderEmpty':"folder") , "fileType" => "Folder", "preview" => 0, 'test'=>1);
|
||||
}else
|
||||
{
|
||||
return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>2);
|
||||
}
|
||||
}else
|
||||
{
|
||||
return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext , 'filename'=>$fileName);
|
||||
}
|
||||
|
||||
}else
|
||||
{//this is unknown file
|
||||
return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>4);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* return the predefined file types
|
||||
*
|
||||
* @return arrray
|
||||
*/
|
||||
function getFileTypes()
|
||||
{
|
||||
return $this->fileTypes;
|
||||
}
|
||||
/**
|
||||
* print out the file types
|
||||
*
|
||||
*/
|
||||
function printFileTypes()
|
||||
{
|
||||
foreach($fileTypes as $fileType)
|
||||
{
|
||||
if(isset($fileType[0]) && is_array($fileType[0]))
|
||||
{
|
||||
foreach($fileType[0] as $type)
|
||||
{
|
||||
echo $type. ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extension of a file name
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
* @copyright this function originally come from Andy's php
|
||||
*/
|
||||
function _getExtension($file, $checkIfDir = false)
|
||||
{
|
||||
if($checkIfDir && file_exists($file) && is_dir($file))
|
||||
{
|
||||
return '';
|
||||
}else
|
||||
{
|
||||
return @substr(@strrchr($file, "."), 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function isDirEmpty($path)
|
||||
{
|
||||
$dirHandler = @opendir($path);
|
||||
if($dirHandler)
|
||||
{
|
||||
while(false !== ($file = readdir($dirHandler)))
|
||||
{
|
||||
if($file != '.' && $file != '..')
|
||||
{
|
||||
@closedir($dirHandler);
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@closedir($dirHandler);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,584 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Pagination Class
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @since 27/Nov/20006
|
||||
*
|
||||
*/
|
||||
class pagination
|
||||
{
|
||||
var $totalItems = 0;
|
||||
var $itemsPerPage = 30;
|
||||
var $currentPage = 1;
|
||||
var $friendlyUrl = false;
|
||||
var $baseUrl = "";
|
||||
var $pageIndex = "page";
|
||||
var $groupLimit = 5;
|
||||
var $excludedQueryStrings = array();
|
||||
var $totalPages = 0;
|
||||
var $url = "";
|
||||
var $previousText = "Previous";
|
||||
var $nextText = "Next";
|
||||
var $lastText = "Last";
|
||||
var $firstText = "First";
|
||||
var $limitIndex ='limit';
|
||||
var $limits = array(5, 10, 20, 30, 50, 80, 150, 999);
|
||||
|
||||
|
||||
/**
|
||||
* Contructor
|
||||
*
|
||||
* @param boolean $friendlyUrl set the returned url
|
||||
* as search engine friendly or Normal Url
|
||||
*/
|
||||
function pagination($friendlyUrl=false)
|
||||
{
|
||||
$this->friendlyUrl = $friendlyUrl;
|
||||
$this->__resetCurrentPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* set maximum number of items per page
|
||||
*
|
||||
* @param integer $value maximum number of items per page
|
||||
*/
|
||||
function setLimit($value)
|
||||
{
|
||||
$this->itemsPerPage = (int)($value);
|
||||
}
|
||||
/**
|
||||
* get maximum number of items per page
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getLimit()
|
||||
{
|
||||
return $this->itemsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the total number of items
|
||||
*
|
||||
* @param integer $value the total number of items
|
||||
*/
|
||||
function setTotal($value)
|
||||
{
|
||||
$this->totalItems = (int)($value);
|
||||
}
|
||||
/**
|
||||
* get the total number of items
|
||||
*
|
||||
* @return integer total number of items
|
||||
*/
|
||||
function getTotal()
|
||||
{
|
||||
return $this->totalItems;
|
||||
}
|
||||
/**
|
||||
* get total pages will be used to display all records
|
||||
*
|
||||
*/
|
||||
function getTotalPages()
|
||||
{
|
||||
|
||||
$output = floor(($this->totalItems / $this->itemsPerPage ));
|
||||
if($this->totalItems % $this->itemsPerPage)
|
||||
{
|
||||
$output++;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index of URL Query String
|
||||
*
|
||||
* @param string $value e.g. page
|
||||
*/
|
||||
function setPageIndex($value)
|
||||
{
|
||||
$this->pageIndex = $value;
|
||||
$this->__resetCurrentPage();
|
||||
}
|
||||
|
||||
|
||||
function getPageIndex()
|
||||
{
|
||||
return $this->pageIndex;
|
||||
}
|
||||
/**
|
||||
* initiate or reset the current page number
|
||||
*
|
||||
*/
|
||||
function __resetCurrentPage()
|
||||
{
|
||||
$this->currentPage = ((isset($_GET[$this->pageIndex]) && (int)($_GET[$this->pageIndex]) > 0)?(int)($_GET[$this->pageIndex]):1);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the base url used in the links, default is $PHP_SELF
|
||||
*
|
||||
* @param string $value the base url
|
||||
*/
|
||||
function setUrl($value="")
|
||||
{
|
||||
if(empty($value))
|
||||
{
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$this->url = "http://" . $_SERVER['HTTP_HOST'] . "/";
|
||||
}else
|
||||
{
|
||||
$this->url = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
}else
|
||||
{
|
||||
$this->url = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get the base url variable
|
||||
*
|
||||
* @return string the base url
|
||||
*/
|
||||
function getUrl()
|
||||
{
|
||||
|
||||
if(empty($this->url))
|
||||
{
|
||||
$this->setUrl();
|
||||
|
||||
}
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* set base url for pagination links after exculed those keys
|
||||
* identified on excluded query strings
|
||||
*/
|
||||
function __setBaseUrl()
|
||||
{
|
||||
|
||||
if(empty($this->url))
|
||||
{
|
||||
$this->getUrl();
|
||||
}
|
||||
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$this->baseUrl = $this->getUrl();
|
||||
}else
|
||||
{
|
||||
|
||||
$appendingQueryStrings = array();
|
||||
$this->excludedQueryStrings[$this->pageIndex] =$this->pageIndex;
|
||||
foreach($_GET as $k=>$v)
|
||||
{
|
||||
if((array_search($k, $this->excludedQueryStrings) === false ))
|
||||
{
|
||||
$appendingQueryStrings[$k] = $k . "=" . $v;
|
||||
}
|
||||
}
|
||||
if(sizeof($appendingQueryStrings))
|
||||
{
|
||||
$this->baseUrl = $this->__appendQueryString($this->url, implode("&", $appendingQueryStrings));
|
||||
}else
|
||||
{
|
||||
$this->baseUrl = $this->getUrl();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* get base url for pagination links aftr excluded those key
|
||||
* identified on excluded query strings
|
||||
*
|
||||
*/
|
||||
function __getBaseUrl()
|
||||
{
|
||||
|
||||
if(empty($this->baseUrl))
|
||||
{
|
||||
|
||||
$this->__setBaseUrl();
|
||||
}
|
||||
return $this->baseUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the first item number
|
||||
*
|
||||
* @return interger the first item number displayed within current page
|
||||
*/
|
||||
function getFirstItem()
|
||||
{
|
||||
$output = 0;
|
||||
$temStartItemNumber = (($this->currentPage - 1) * $this->itemsPerPage + 1);
|
||||
if($this->totalItems && $temStartItemNumber <= $this->totalItems )
|
||||
{
|
||||
|
||||
$output = $temStartItemNumber;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* get the last item number displayed within current page
|
||||
*
|
||||
* @return interger the last item number
|
||||
*/
|
||||
function getLastItem()
|
||||
{
|
||||
$output = 0;
|
||||
$temEndItemNumber = (($this->currentPage) * $this->itemsPerPage);
|
||||
if($this->totalItems)
|
||||
{
|
||||
if($temEndItemNumber <= $this->totalItems)
|
||||
{
|
||||
$output = $temEndItemNumber;
|
||||
}else
|
||||
{
|
||||
$output = $this->totalItems;
|
||||
}
|
||||
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* set page groupings limit
|
||||
* used for previous 1 2 3 4 5 next
|
||||
*
|
||||
* @param unknown_type $value
|
||||
*/
|
||||
function setGroupLimit($value)
|
||||
{
|
||||
$this->groupLimit = (int)($value);
|
||||
}
|
||||
/**
|
||||
* get page grouping limit
|
||||
*
|
||||
* @return integer the page grouping limit
|
||||
*/
|
||||
function getGroupLimit()
|
||||
{
|
||||
return $this->groupLimit;
|
||||
}
|
||||
/**
|
||||
* get the page offset number
|
||||
* used for Query . e.g SELECT SQL_CALC_FOUND_ROWS *
|
||||
* FROM mytable LIMIT getPageOffset(), getItemsPerPage()
|
||||
*
|
||||
* @return iner
|
||||
*/
|
||||
function getPageOffset()
|
||||
{
|
||||
return (($this->currentPage - 1) * $this->itemsPerPage);
|
||||
}
|
||||
/**
|
||||
* get the last url if any
|
||||
* @return string the last url
|
||||
*/
|
||||
function getLastUrl()
|
||||
{
|
||||
|
||||
$url = "";
|
||||
$totalPages = $this->getTotalPages();
|
||||
if($this->currentPage < $totalPages)
|
||||
{
|
||||
$url = $this->__getBaseUrl();
|
||||
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$url .= $this->pageIndex . $totalPages . "/";
|
||||
}else
|
||||
{
|
||||
$url = $this->__appendQueryString($url, $this->pageIndex . "=" . $totalPages);
|
||||
}
|
||||
$url = sprintf('<a href="%s" class="pagination_last"><span>%s</span></a>',
|
||||
$url,
|
||||
$this->lastText);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get the first url if any
|
||||
* @return string the first url
|
||||
*/
|
||||
|
||||
function getFirstUrl()
|
||||
{
|
||||
$url = "";
|
||||
if($this->currentPage > 1)
|
||||
{
|
||||
$url = $this->__getBaseUrl();
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$url .= $this->pageIndex . "1/";
|
||||
}else
|
||||
{
|
||||
$url = $this->__appendQueryString($url, $this->pageIndex . "=1");
|
||||
}
|
||||
$url = sprintf('<a href="%s" class="pagination_first"><span>%s</span></a>',
|
||||
$url,
|
||||
$this->firstText);
|
||||
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the previous page url if anywhere
|
||||
*
|
||||
* @param array $excludedQueryStrings excluded the value from $_GET
|
||||
* @return string the previous page url
|
||||
*/
|
||||
function getPreviousUrl()
|
||||
{
|
||||
$url = "";
|
||||
if($this->currentPage > 1 && $this->totalItems > 0 )
|
||||
{
|
||||
$url = $this->__getBaseUrl();
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$url .= $this->pageIndex . ($this->currentPage - 1) . "/";
|
||||
}else
|
||||
{
|
||||
$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage -1));
|
||||
}
|
||||
$url = sprintf('<a href="%s" class="pagination_previous"><span>%s</span></a>',
|
||||
$url,
|
||||
$this->previousText);
|
||||
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
/**
|
||||
* get the next page url if anywhere
|
||||
*
|
||||
* @param array $excludedQueryStrings excluded the value from $_GET
|
||||
* @return string the next page url
|
||||
*/
|
||||
function getNextUrl()
|
||||
{
|
||||
$url = "";
|
||||
if($this->totalItems > ($this->currentPage * $this->itemsPerPage))
|
||||
{
|
||||
$url = $this->__getBaseUrl();
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$url .= $this->pageIndex . ($this->currentPage + 1) . "/";
|
||||
}else
|
||||
{
|
||||
$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage + 1));
|
||||
}
|
||||
$url = sprintf('<a href="%s" class="pagination_next"><span>%s</span></a>',
|
||||
$url,
|
||||
$this->nextText);
|
||||
}
|
||||
return $url;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get the group page links e.g. 1,2,3,4,5
|
||||
* return format
|
||||
* <a class="pagination_group" href='yoururl'>1</a>
|
||||
* <a class="pagination_group active" href='#'>2</a>
|
||||
* <a class="pagination_group" href='yoururl'>3</a>
|
||||
*/
|
||||
function getGroupUrls()
|
||||
{
|
||||
$output = "";
|
||||
if($this->totalItems > 0)
|
||||
{
|
||||
$displayedPages = 0;
|
||||
$url = $this->__getBaseUrl();
|
||||
$totalPages = $this->getTotalPages();
|
||||
// find halfway point
|
||||
$groupLimitHalf = floor($this->groupLimit / 2);
|
||||
// determine what item/page we start with
|
||||
$itemStart = $this->currentPage - $groupLimitHalf;
|
||||
$itemStart = ($itemStart > 0 && $itemStart <= $totalPages)?$itemStart:1;
|
||||
$itemEnd = $itemStart;
|
||||
|
||||
while($itemEnd < ($itemStart + $this->groupLimit - 1) && $itemEnd < $totalPages)
|
||||
{
|
||||
$itemEnd++;
|
||||
}
|
||||
|
||||
|
||||
if($totalPages > ($itemEnd - $itemStart))
|
||||
{
|
||||
for($i = $itemStart; $i > 1 && ($itemEnd - $itemStart + 1) < $this->groupLimit; $i--)
|
||||
{
|
||||
$itemStart--;
|
||||
}
|
||||
}
|
||||
|
||||
for($item = $itemStart; $item <= $itemEnd; $item++)
|
||||
{
|
||||
if($item != $this->currentPage)
|
||||
{//it is not the active link
|
||||
if($this->friendlyUrl)
|
||||
{
|
||||
$temUrl = $url . $this->pageIndex . $item . "/";
|
||||
}else
|
||||
{
|
||||
$temUrl = $this->__appendQueryString($url, $this->pageIndex . "=" . $item);
|
||||
}
|
||||
$output .= sprintf(' <a class="pagination_group" href="%s"><span>%d</span></a> ', $temUrl, $item);
|
||||
}else
|
||||
{//active link
|
||||
$output .= sprintf(' <a class="pagination_group pagination_active" href="#"><span>%d</span></a> ', $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* set the text of previous page link
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
function setPreviousText($value)
|
||||
{
|
||||
$this->previousText = $value;
|
||||
}
|
||||
/**
|
||||
* set the text of first page link
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
function setFirstText($value)
|
||||
{
|
||||
$this->firstText = $value;
|
||||
}
|
||||
/**
|
||||
* set the text of next page link
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
|
||||
function setNextText($value)
|
||||
{
|
||||
$this->nextText = $value;
|
||||
}
|
||||
/**
|
||||
* set the text of last page link
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
function setLastText($value)
|
||||
{
|
||||
$this->lastText = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the excluded query string from $_GET;
|
||||
*
|
||||
* @param array the lists of the query string keys
|
||||
*/
|
||||
|
||||
function setExcludedQueryString($values = array())
|
||||
{
|
||||
$this->excludedQueryStrings = $values;
|
||||
}
|
||||
|
||||
function getExcludedQueryString()
|
||||
{
|
||||
return $this->excludedQueryStrings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add extra query stiring to a url
|
||||
* @param string $baseUrl
|
||||
* @param string $extra the query string added to the base url
|
||||
*/
|
||||
function __appendQueryString($baseUrl, $extra)
|
||||
{
|
||||
$output = trim($baseUrl);
|
||||
if(strpos($baseUrl, "?") !== false)
|
||||
{
|
||||
$output .= "&" . $extra;
|
||||
}else
|
||||
{
|
||||
$output .= "?" . $extra;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* return the html
|
||||
*
|
||||
* @param integer $type
|
||||
*/
|
||||
function getPaginationHTML($type=1, $cssClass="pagination")
|
||||
{
|
||||
$output = '';
|
||||
$output .= "<div class=\"pagination_content\"><p class=\"$cssClass\">\n";
|
||||
switch($type)
|
||||
{
|
||||
case "2":
|
||||
$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . " to " . $this->getLastItem() . " of " . $this->getTotal() . " results.</span> ";
|
||||
if($previousUrl = $this->getPreviousUrl())
|
||||
{
|
||||
$output .= " " . $previousUrl;
|
||||
}
|
||||
|
||||
if($nextUrl = $this->getNextUrl())
|
||||
{
|
||||
$output .= " " . $nextUrl;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
//get full summary pagination
|
||||
default:
|
||||
$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . "/" . $this->getLastItem() . " (" . $this->getTotal() . ")</span> ";
|
||||
if($firstUrl = $this->getFirstUrl())
|
||||
{
|
||||
$output .= " " . $firstUrl;
|
||||
}
|
||||
if($previousUrl = $this->getPreviousUrl())
|
||||
{
|
||||
$output .= " " . $previousUrl;
|
||||
}
|
||||
|
||||
if($groupUrls = $this->getGroupUrls())
|
||||
{
|
||||
$output .= " " . $groupUrls;
|
||||
}
|
||||
if($nextUrl = $this->getNextUrl())
|
||||
{
|
||||
$output .= " " . $nextUrl;
|
||||
}
|
||||
if($lastUrl = $this->getLastUrl())
|
||||
{
|
||||
$output .= " " . $lastUrl;
|
||||
}
|
||||
$itemPerPage = '';
|
||||
$itemPerPage .= "<select name=\"" . $this->limitIndex . "\" id=\"limit\" class=\"input inputLimit\" onchange=\"changePaginationLimit();\">\n";
|
||||
foreach ($this->limits as $v)
|
||||
{
|
||||
$itemPerPage .= "<option value=\"" . $v . "\" " . ($v==$this->itemsPerPage?'selected="selected"':'') . ">" . $v . "</option>\n";
|
||||
}
|
||||
$itemPerPage .= "</select>\n";
|
||||
$output .= "<span class=\"pagination_items_per_page\">";
|
||||
$output .= sprintf(PAGINATION_ITEMS_PER_PAGE, $itemPerPage);
|
||||
$output .= "</span>";
|
||||
$output .= "<span class=\"pagination_parent\"><a href=\"#\" onclick=\"goParentFolder();\" id=\"pagination_parent_link\" title=\"" . PAGINATION_GO_PARENT . "\"> </a></span>";
|
||||
}
|
||||
|
||||
$output .= "</p></div>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
include_once(CLASS_FILE);
|
||||
require_once(CLASS_SESSION_ACTION);
|
||||
require_once(CLASS_MANAGER);
|
||||
class Search
|
||||
{
|
||||
var $rootFolder = '';
|
||||
var $files = array();
|
||||
var $rootFolderInfo = array();
|
||||
var $searchkeywords = array(
|
||||
'mtime_from'=>'',
|
||||
'mtime_to'=>'',
|
||||
'name'=>'',
|
||||
'size_from'=>'',
|
||||
'size_to'=>'',
|
||||
'recursive'=>'0',
|
||||
|
||||
);
|
||||
var $sessionAction = null;
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $rootFolder
|
||||
*/
|
||||
function __construct($rootFolder)
|
||||
{
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->sessionAction = new SessionAction();
|
||||
$objRootFolder = new file($this->rootFolder);
|
||||
$tem = $objRootFolder->getFileInfo();
|
||||
$obj = new manager($this->rootFolder, false);
|
||||
$obj->setSessionAction($this->sessionAction);
|
||||
$selectedDocuments = $this->sessionAction->get();
|
||||
$fileType = $obj->getFolderInfo($this->rootFolder);
|
||||
|
||||
foreach($fileType as $k=>$v)
|
||||
{
|
||||
$tem[$k] = $v;
|
||||
}
|
||||
|
||||
$tem['path'] = backslashToSlash($this->rootFolder);
|
||||
$tem['type'] = (is_dir($this->rootFolder)?'folder':'file');
|
||||
$tem['size'] = (is_dir($this->rootFolder)?'':transformFileSize(@filesize($this->rootFolder)));
|
||||
//$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
|
||||
//$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
|
||||
$tem['flag'] = (array_search($tem['path'], $selectedDocuments) !== false?($this->sessionAction->getAction() == "copy"?'copyFlag':'cutFlag'):'noFlag');
|
||||
$tem['url'] = getFileUrl($this->rootFolder);
|
||||
$tem['friendly_path'] = transformFilePath($this->rootFolder);
|
||||
$tem['file'] = 0;
|
||||
$tem['subdir'] = 0;
|
||||
$manager = null;
|
||||
$this->rootFolderInfo = $tem;
|
||||
$tem = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param string $rootFolder
|
||||
*/
|
||||
function Search($rootFolder)
|
||||
{
|
||||
$this->__construct($rootFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the search keyword individually
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
function addSearchKeyword($key, $value)
|
||||
{
|
||||
$this->searchkeywords[$key] = $value;
|
||||
}
|
||||
/**
|
||||
* change the search keywords
|
||||
*
|
||||
* @param array $keywords
|
||||
*/
|
||||
function addSearchKeywords($keywords)
|
||||
{
|
||||
foreach($this->searchkeywords as $k=>$v)
|
||||
{
|
||||
if(array_key_exists($k, $keywords) !== false)
|
||||
{
|
||||
$this->searchkeywords[$k] = $keywords[$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get the file according to the search keywords
|
||||
*
|
||||
*/
|
||||
function doSearch($baseFolderPath = null)
|
||||
{
|
||||
|
||||
$baseFolderPath = addTrailingSlash(backslashToSlash((is_null($baseFolderPath)?$this->rootFolder:$baseFolderPath)));
|
||||
|
||||
$dirHandler = @opendir($baseFolderPath);
|
||||
if($dirHandler)
|
||||
{
|
||||
while(false !== ($file = readdir($dirHandler)))
|
||||
{
|
||||
if($file != '.' && $file != '..')
|
||||
{
|
||||
$path = $baseFolderPath . $file;
|
||||
if(is_file($path))
|
||||
{
|
||||
$isValid = true;
|
||||
|
||||
$fileTime = @filemtime($path);
|
||||
$fileSize = @filesize($path);
|
||||
if($this->searchkeywords['name'] !== '' && @eregi($this->searchkeywords['name'], $file) === false)
|
||||
{
|
||||
$isValid = false;
|
||||
}
|
||||
if($this->searchkeywords['mtime_from'] != '' && $fileTime < @strtotime($this->searchkeywords['mtime_from']))
|
||||
{
|
||||
$isValid = false;
|
||||
}
|
||||
if($this->searchkeywords['mtime_to'] != '' && $fileTime > @strtotime($this->searchkeywords['mtime_to']))
|
||||
{
|
||||
$isValid = false;
|
||||
}
|
||||
if($this->searchkeywords['size_from'] != '' && $fileSize < @strtotime($this->searchkeywords['size_from']))
|
||||
{
|
||||
$isValid = false;
|
||||
}
|
||||
if($this->searchkeywords['size_to'] != '' && $fileSize > @strtotime($this->searchkeywords['size_to']))
|
||||
{
|
||||
$isValid = false;
|
||||
}
|
||||
if($isValid && isListingDocument($path))
|
||||
{
|
||||
$finalPath = $path;
|
||||
$objFile = new file($finalPath);
|
||||
$tem = $objFile->getFileInfo();
|
||||
$obj = new manager($finalPath, false);
|
||||
$obj->setSessionAction($this->sessionAction);
|
||||
$selectedDocuments = $this->sessionAction->get();
|
||||
$fileType = $obj->getFileType($finalPath);
|
||||
|
||||
foreach($fileType as $k=>$v)
|
||||
{
|
||||
$tem[$k] = $v;
|
||||
}
|
||||
|
||||
$tem['path'] = backslashToSlash($finalPath);
|
||||
$tem['type'] = (is_dir($finalPath)?'folder':'file');
|
||||
$tem['size'] = transformFileSize($tem['size']);
|
||||
$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
|
||||
$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
|
||||
$tem['flag'] = (array_search($tem['path'], $selectedDocuments) !== false?($this->sessionAction->getAction() == "copy"?'copyFlag':'cutFlag'):'noFlag');
|
||||
$tem['url'] = getFileUrl($tem['path']);
|
||||
$this->rootFolderInfo['file']++;
|
||||
$manager = null;
|
||||
$this->files[] = $tem;
|
||||
$tem = null;
|
||||
}
|
||||
}elseif(is_dir($path) && $this->searchkeywords['recursive'])
|
||||
{
|
||||
$this->Search($baseFolderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dirHandler);
|
||||
}
|
||||
|
||||
function getFoundFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
function getRootFolderInfo()
|
||||
{
|
||||
|
||||
return $this->rootFolderInfo;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,228 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* this class provide a function like session handling engine
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/May/2007
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
|
||||
class Session
|
||||
{
|
||||
var $lifeTime;
|
||||
var $fp = null;
|
||||
var $dir = null;
|
||||
var $mTime = null;
|
||||
var $sessionDir = null;
|
||||
var $sessionFile = null;
|
||||
var $ext = '.txt';
|
||||
var $gcCounter = 5; //call gc to delete expired session each ten request
|
||||
var $gcCounterFileName = 'gc_counter.ajax.php';
|
||||
var $gcCounterFile = null;
|
||||
var $gcLogFileName = 'gc_log.ajax.php';
|
||||
var $gcLogFile = null;
|
||||
var $debug = true; //turn it on when you want to see gc log
|
||||
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*/
|
||||
function Session()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
/**
|
||||
* session init
|
||||
* @return boolean
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function gc()
|
||||
{
|
||||
//init the counter file
|
||||
$fp = @fopen($this->gcCounterFile, 'a+');
|
||||
if($fp)
|
||||
{
|
||||
$count = (int)(fgets($fp, 999999)) + 1;
|
||||
if($count > $this->gcCounter || rand(0, 23) == date('h'))
|
||||
{
|
||||
$this->_gc();
|
||||
$count = 0;
|
||||
}
|
||||
@ftruncate($fp, 0);
|
||||
if(!@fputs($fp, $count))
|
||||
{
|
||||
die(SESSION_COUNTER_FILE_WRITE_FAILED);
|
||||
}
|
||||
@fclose($fp);
|
||||
}else
|
||||
{
|
||||
die(SESSION_COUNTER_FILE_CREATE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _gc()
|
||||
{
|
||||
//remove expired file from session folder
|
||||
$dirHandler = @opendir($this->dir);
|
||||
$output = '';
|
||||
$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
|
||||
$fo = new file();
|
||||
if($dirHandler)
|
||||
{
|
||||
while(false !== ($file = readdir($dirHandler)))
|
||||
{
|
||||
if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
|
||||
{
|
||||
$path=$this->dir.$file;
|
||||
$output .= $path ;
|
||||
//check if this is a expired session file
|
||||
if(filemtime($path) + $this->lifeTime < time())
|
||||
{
|
||||
if($fo->delete($path))
|
||||
{
|
||||
$output .= ' Deleted at ' . date('d/M/Y H:i:s');
|
||||
}else
|
||||
{
|
||||
$output .= " Failed at " . date('d/M/Y H:i:s');
|
||||
}
|
||||
}
|
||||
$output .= "\n";
|
||||
|
||||
}
|
||||
}
|
||||
if($this->debug)
|
||||
{
|
||||
$this->_log($output);
|
||||
}
|
||||
|
||||
@closedir($dirHandler);
|
||||
|
||||
}
|
||||
if(CONFIG_SYS_DEMO_ENABLE)
|
||||
{
|
||||
//remove expired files from uploaded folder
|
||||
$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
|
||||
$output = '';
|
||||
$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
|
||||
$fo = new file();
|
||||
if($dirHandler)
|
||||
{
|
||||
while(false !== ($file = readdir($dirHandler)))
|
||||
{
|
||||
if($file != '.' && $file != '..')
|
||||
{
|
||||
$path=CONFIG_SYS_ROOT_PATH.$file;
|
||||
$output .= $path ;
|
||||
//check if this is a expired session file
|
||||
if(filemtime($path) + $this->lifeTime < time())
|
||||
{
|
||||
if($fo->delete($path))
|
||||
{
|
||||
$output .= ' Deleted at ' . date('d/M/Y H:i:s');
|
||||
}else
|
||||
{
|
||||
$output .= " Failed at " . date('d/M/Y H:i:s');
|
||||
}
|
||||
}
|
||||
$output .= "\n";
|
||||
|
||||
}
|
||||
}
|
||||
if($this->debug)
|
||||
{
|
||||
$this->_log($output);
|
||||
}
|
||||
|
||||
@closedir($dirHandler);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* log action taken by the gc
|
||||
*
|
||||
* @param unknown_type $msg
|
||||
*/
|
||||
function _log($msg)
|
||||
{
|
||||
$msg = "<?php die(); ?>\n" . $msg;
|
||||
$fp = @fopen($this->gcLogFile, 'w+');
|
||||
if($fp)
|
||||
{
|
||||
@ftruncate($fp, 0);
|
||||
!@fputs($fp, $msg);
|
||||
@fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current session directory
|
||||
*
|
||||
* @return string return empty if failed
|
||||
*/
|
||||
function getSessionDir()
|
||||
{
|
||||
if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
|
||||
{
|
||||
$dir = new file();
|
||||
if(!$dir->mkdir($this->sessionDir))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(!@is_dir($this->sessionDir))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return $this->sessionDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*Session Action Class
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/May/2007
|
||||
*
|
||||
*/
|
||||
class SessionAction
|
||||
{
|
||||
var $actionIndex = 'ajax_file_action';
|
||||
var $selectedDocIndex = 'ajax_selected_doc';
|
||||
var $fromFolderIndex = 'ajax_from_folder';
|
||||
function __construct()
|
||||
{
|
||||
if(!isset($_SESSION[$this->actionIndex]))
|
||||
{
|
||||
$_SESSION[$this->actionIndex] = '';
|
||||
}
|
||||
if(!isset($_SESSION[$this->selectedDocIndex]) || !is_array($_SESSION[$this->selectedDocIndex]))
|
||||
{
|
||||
$_SESSION[$this->selectedDocIndex] = array();
|
||||
}
|
||||
if(!isset($_SESSION[$this->fromFolderIndex]))
|
||||
{
|
||||
$_SESSION[$this->fromFolderIndex] = '';
|
||||
}
|
||||
}
|
||||
|
||||
function SessionAction()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
/**
|
||||
* count the number of selected documents
|
||||
*
|
||||
*/
|
||||
function count()
|
||||
{
|
||||
return (isset($_SESSION[$this->selectedDocIndex])?sizeof($_SESSION[$this->selectedDocIndex]):0);
|
||||
}
|
||||
/**
|
||||
* assign the selected documents
|
||||
*
|
||||
* @param array $selectedDocuments
|
||||
*/
|
||||
function set($selectedDocuments)
|
||||
{
|
||||
$_SESSION[$this->selectedDocIndex] = $selectedDocuments;
|
||||
|
||||
}
|
||||
/**
|
||||
* get the selected documents
|
||||
* @return array
|
||||
*/
|
||||
function get()
|
||||
{
|
||||
return (isset($_SESSION[$this->selectedDocIndex])?$_SESSION[$this->selectedDocIndex]:array());
|
||||
}
|
||||
|
||||
function setAction($action)
|
||||
{
|
||||
$_SESSION[$this->actionIndex] = $action;
|
||||
}
|
||||
/**
|
||||
* get the action
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
function getAction()
|
||||
{
|
||||
return (isset($_SESSION[$this->actionIndex])?$_SESSION[$this->actionIndex]:'');
|
||||
}
|
||||
/**
|
||||
* set the folder
|
||||
*
|
||||
* @param string $folder
|
||||
*/
|
||||
function setFolder($folder)
|
||||
{
|
||||
$_SESSION[$this->fromFolderIndex] = $folder;
|
||||
}
|
||||
/**
|
||||
* get the folder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFolder()
|
||||
{
|
||||
return (isset($_SESSION[$this->fromFolderIndex])?$_SESSION[$this->fromFolderIndex]:'');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,589 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This class provide all file upload functionalities
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 22/April/2007
|
||||
*
|
||||
*/
|
||||
class Upload
|
||||
{
|
||||
var $fileType = ""; //the file type
|
||||
var $originalFileName = "";
|
||||
var $fileName = ""; //the file final name
|
||||
var $fileExtension = "";
|
||||
var $img_x = 0;
|
||||
var $img_y = 0;
|
||||
var $img_new_x = 0;
|
||||
var $img_new_y = 0;
|
||||
var $imgHandler = null;
|
||||
var $fileBaseName = ""; //file name without the file extension and .
|
||||
var $filePath = ""; //the file path which the file uploaded to
|
||||
var $fileSize = 0;
|
||||
var $validImageExts = array("gif", "jpg", "png");
|
||||
var $errors = array();
|
||||
var $_value = null; //an array holding the uploaded file details
|
||||
var $dirPath = "";
|
||||
var $invalidFileExt = array(); //var $invalidFileExt = array('php,inc,asp,aspx');
|
||||
var $errCode = "";
|
||||
var $safeMode;
|
||||
var $uploadFileMode = 0755;
|
||||
var $errorCodes = array(
|
||||
0=>'the file uploaded with success',
|
||||
1=>'The uploaded file exceeds the upload_max_filesize directive in php.ini',
|
||||
2=>'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
|
||||
3=>'The uploaded file was only partially uploaded',
|
||||
4=>'No file was uploaded.',
|
||||
6=>'Missing a temporary folder',
|
||||
7=>'Failed to write file to disk',
|
||||
8=>'File upload stopped by extension',
|
||||
999=>'No error code avaiable',
|
||||
);
|
||||
|
||||
|
||||
function Upload()
|
||||
{
|
||||
//doing nothing
|
||||
}
|
||||
|
||||
function isFileUploaded($indexInPost="file")
|
||||
{
|
||||
|
||||
$this->errCode = isset($_FILES[$indexInPost]['error'])?$_FILES[$indexInPost]['error']:999;
|
||||
if((isset($_FILES[$indexInPost]['error']) && $_FILES[$indexInPost] == 0) ||
|
||||
(!empty($_FILES[$indexInPost]['tmp_name']) && $_FILES[$indexInPost]['tmp_name'] != 'none')
|
||||
)
|
||||
{
|
||||
$this->_value = $_FILES[$indexInPost];
|
||||
$this->fileSize = @filesize($this->_value['tmp_name']);
|
||||
$this->originalFileName = $this->_value['name'];
|
||||
$this->fileType = $this->_value['type'];
|
||||
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
|
||||
array_push($this->errors, 'Unable to upload file');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorCodeMsg()
|
||||
{
|
||||
return (isset($this->errorCodes[$this->errCode])?$this->errorCodes[$this->errCode]:"");
|
||||
}
|
||||
/**
|
||||
* check if the uploaded file extension is allowed against the validFile Extension
|
||||
* or against the invalid extension list when the list of valid file extension is not set
|
||||
*
|
||||
* @param array $validFileExt
|
||||
* @return boolean
|
||||
*/
|
||||
function isPermittedFileExt($validFileExt = array())
|
||||
{
|
||||
$tem = array();
|
||||
|
||||
if(sizeof($validFileExt))
|
||||
{
|
||||
foreach($validFileExt as $k=>$v)
|
||||
{
|
||||
$tem[$k] = strtolower(trim($v));
|
||||
}
|
||||
}
|
||||
$validFileExt = $tem;
|
||||
|
||||
if(sizeof($validFileExt) && sizeof($this->invalidFileExt))
|
||||
{
|
||||
foreach($validFileExt as $k=>$ext)
|
||||
{
|
||||
if(array_search(strtolower($ext), $this->invalidFileExt) !== false)
|
||||
{
|
||||
unset($validFileExt[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(sizeof($validFileExt))
|
||||
{
|
||||
if(array_search(strtolower($this->getFileExt()), $validFileExt) !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$this->deleteUploadedFile();
|
||||
return false;
|
||||
|
||||
}
|
||||
/**
|
||||
* check if the uploaded file size is too big
|
||||
*
|
||||
* @param integer $maxSize
|
||||
*/
|
||||
function isSizeTooBig($maxSize="")
|
||||
{
|
||||
if($this->fileSize > $maxSize)
|
||||
{
|
||||
$this->deleteUploadedFile();
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* set the invali file extensions
|
||||
*
|
||||
* @param array $invalidFileExt
|
||||
*/
|
||||
function setInvalidFileExt($invalidFileExt=array())
|
||||
{
|
||||
$tem = array();
|
||||
if(sizeof($invalidFileExt))
|
||||
{
|
||||
foreach($invalidFileExt as $k=>$v)
|
||||
{
|
||||
$tem[$k]= strtolower(trim($v));
|
||||
}
|
||||
}
|
||||
|
||||
$this->invalidFileExt = $tem;
|
||||
}
|
||||
/**
|
||||
* get file type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFileType()
|
||||
{
|
||||
return $this->fileType;
|
||||
}
|
||||
/**
|
||||
* get a file extension
|
||||
*
|
||||
* @param string $fileName the path to a file or just the file name
|
||||
*/
|
||||
function getFileExt()
|
||||
{
|
||||
//return strtolower(substr(strrchr($this->fileName, "."), 1));
|
||||
return substr(strrchr($this->originalFileName, "."), 1);
|
||||
}
|
||||
/**
|
||||
* move the uploaded file to a specific location
|
||||
*
|
||||
* @param string $dest the path to the directory which the uploaded file will be moved to
|
||||
* @param string $fileBaseName the base name which the uploaded file will be renamed to
|
||||
* @param unknown_type $overwrite
|
||||
* @return unknown
|
||||
*/
|
||||
function moveUploadedFile($dest, $fileBaseName = '', $overwrite=false)
|
||||
{
|
||||
|
||||
//ensure the directory path ending with /
|
||||
if ($dest != '' && substr($dest, -1) != '/') {
|
||||
$dest .= '/';
|
||||
}
|
||||
$this->dirPath = $dest;
|
||||
$fileName = basename($this->_value['name']);
|
||||
|
||||
$dotIndex = strrpos($fileName, '.');
|
||||
$this->fileExtension = '';
|
||||
if(is_int($dotIndex))
|
||||
{
|
||||
$this->fileExtension = substr($fileName, $dotIndex);
|
||||
$this->fileBaseName = substr($fileName, 0, $dotIndex);
|
||||
}
|
||||
if(!empty($fileBaseName))
|
||||
{
|
||||
$this->fileBaseName = $fileBaseName;
|
||||
}
|
||||
$fileName = $this->fileBaseName . $this->fileExtension;
|
||||
$filePath = $dest . $fileName;
|
||||
|
||||
if(!$overwrite && file_exists($filePath) && is_file($filePath))
|
||||
{//rename
|
||||
|
||||
$counter = 0;
|
||||
while(file_exists($dest.$fileName) && is_file($dest .$fileName))
|
||||
{
|
||||
$counter++;
|
||||
$fileName = $this->fileBaseName.'_'.$counter.$this->fileExtension;
|
||||
}
|
||||
$this->fileBaseName .= "_" . $counter;
|
||||
|
||||
}
|
||||
if (@move_uploaded_file($this->_value['tmp_name'], $dest . $fileName)) {
|
||||
@chmod($dest . $fileName, $this->uploadFileMode);
|
||||
$this->fileName = $fileName;
|
||||
$this->filePath = $dest . $fileName;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if the uploaded is permitted to upload
|
||||
*
|
||||
* @param mixed $invalidImageExts invalid image extension
|
||||
* @param bool $delete force to delete the uploaded file
|
||||
*/
|
||||
function isImage($invalidImageExts = array(), $delete = true)
|
||||
{
|
||||
if(!is_array($invalidImageExts) && !empty($invalidImageExts))
|
||||
{
|
||||
$invalidImageExts = explode(",", $invalidImageExts);
|
||||
}
|
||||
foreach ($invalidImageExts as $k=>$v)
|
||||
{
|
||||
$invalidImageExts[$k] = strtolower(trim($v));
|
||||
}
|
||||
foreach ($this->validImageExts as $k=>$v)
|
||||
{
|
||||
$ValidImageExts[$k] = strtolower(trim($v));
|
||||
}
|
||||
if(sizeof($invalidImageExts))
|
||||
{
|
||||
foreach ($ValidImageExts as $k=>$v)
|
||||
{
|
||||
if(array_search(strtolower($v), $invalidImageExts) !== false)
|
||||
{
|
||||
unset($ValidImageExts[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array_search(strtolower($this->getFileExt()), $ValidImageExts)!==false)
|
||||
{
|
||||
$this->_get_image_details($this->filePath);
|
||||
if(!empty($this->fileType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
if($delete)
|
||||
{
|
||||
$this->deleteUploadedFile();
|
||||
}
|
||||
}
|
||||
|
||||
array($this->errors, "This file is not a image type file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the Image in the X and/or Y direction
|
||||
* If either is 0 it will be scaled proportionally
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param mixed $new_x
|
||||
* @param mixed $new_y
|
||||
* @param string $thumb_suffix
|
||||
*
|
||||
* @return mixed none or PEAR_error
|
||||
*/
|
||||
function resize($filePath, $thumb_suffix="", $new_x = 0, $new_y = 0)
|
||||
{
|
||||
|
||||
if(empty($filePath))
|
||||
{
|
||||
$filePath = $this->dirPath . $this->fileBaseName . $thumb_suffix . $this->fileExtension;
|
||||
}
|
||||
// 0 means keep original size
|
||||
if ($this->img_x > $this->img_y)
|
||||
$new_y = (int)($new_y/$this->img_x*$this->img_y);
|
||||
else if ($this->img_y > $this->img_x)
|
||||
$new_x = (int)($new_x/$this->img_y*$this->img_x);
|
||||
// Now do the library specific resizing.
|
||||
return $this->_resize($filePath,$new_x, $new_y);
|
||||
} // End resize
|
||||
|
||||
/**
|
||||
* resize the image and return the thumbnail image details array("width"=>, "height"=>, "name")
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param int $new_x the thumbnail width
|
||||
* @param int $new_y the thumbnail height
|
||||
* @return unknown
|
||||
*/
|
||||
function _resize($fileName, $new_x, $new_y) {
|
||||
$functionName = 'ImageCreateFrom' . $this->fileType;
|
||||
|
||||
|
||||
if(function_exists($functionName))
|
||||
{
|
||||
$this->imgHandler = $functionName($this->filePath);
|
||||
}else
|
||||
{
|
||||
array_push($this->errors, $functionName . " function is unavailable");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(function_exists('ImageCreateTrueColor')){
|
||||
$new_img =ImageCreateTrueColor($new_x,$new_y);
|
||||
} else {
|
||||
$new_img =ImageCreate($new_x,$new_y);
|
||||
}
|
||||
if(function_exists('ImageCopyResampled')){
|
||||
ImageCopyResampled($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
|
||||
} else {
|
||||
ImageCopyResized($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
|
||||
}
|
||||
if($this->_imageSave($new_img, $fileName, 80))
|
||||
{
|
||||
return array("width"=>$new_x, "height"=>$new_y, "name"=>basename($fileName));
|
||||
}else
|
||||
{
|
||||
|
||||
array_push($this->errors, "Unable to resize the image");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* save the thumbnail file and destroy the opened image
|
||||
*
|
||||
* @param resource $newImageHandler
|
||||
* @param string $fileName
|
||||
* @param int $quality
|
||||
* @return boolean
|
||||
*/
|
||||
function _imageSave($newImageHandler, $fileName, $quality = 90)
|
||||
{
|
||||
$functionName = 'image' . $this->fileType;
|
||||
if($functionName($newImageHandler, $fileName, $quality))
|
||||
{
|
||||
imagedestroy($newImageHandler);
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
imagedestroy($newImageHandler);
|
||||
array_push($this->errors, "Unable to save the thumbnail file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function _get_image_details($image)
|
||||
{
|
||||
|
||||
//echo $image;
|
||||
$data = @GetImageSize($image);
|
||||
#1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order,
|
||||
# 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC
|
||||
if (is_array($data)){
|
||||
switch($data[2]){
|
||||
case 1:
|
||||
$type = 'gif';
|
||||
break;
|
||||
case 2:
|
||||
$type = 'jpeg';
|
||||
break;
|
||||
case 3:
|
||||
$type = 'png';
|
||||
break;
|
||||
case 4:
|
||||
$type = 'swf';
|
||||
break;
|
||||
case 5:
|
||||
$type = 'psd';
|
||||
case 6:
|
||||
$type = 'bmp';
|
||||
case 7:
|
||||
case 8:
|
||||
$type = 'tiff';
|
||||
default:
|
||||
array_push($this->errors, "We do not recognize this image format");
|
||||
|
||||
}
|
||||
$this->img_x = $data[0];
|
||||
$this->img_y = $data[1];
|
||||
$this->fileType = $type;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
array_push($this->errors, "Cannot fetch image or images details.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* caculate the thumbnail details from the original image file
|
||||
*
|
||||
* @param string $originalImageName
|
||||
* @param int $originaleImageWidth
|
||||
* @param int $originalImageHeight
|
||||
* @param string $thumbnailSuffix
|
||||
* @param int $thumbnailWidth
|
||||
* @param int $thumbnailHeight
|
||||
* @return array array("name"=>"image name", "width"=>"image width", "height"=>"image height")
|
||||
*/
|
||||
function getThumbInfo($originalImageName, $originaleImageWidth, $originalImageHeight, $thumbnailSuffix, $thumbnailWidth, $thumbnailHeight)
|
||||
{
|
||||
$outputs = array("name"=>"", "width"=>0, "height"=>0);
|
||||
$thumbnailWidth = (int)($thumbnailWidth);
|
||||
$thumbnailHeight = (int)($thumbnailHeight);
|
||||
if(!empty($originalImageName) && !empty($originaleImageWidth) && !empty($originalImageHeight))
|
||||
{
|
||||
$dotIndex = strrpos($originalImageName, '.');
|
||||
//begin to get the thumbnail image name
|
||||
$fileExtension = '';
|
||||
$fileBaseName = '';
|
||||
if(is_int($dotIndex))
|
||||
{
|
||||
$fileExtension = substr($originalImageName, $dotIndex);
|
||||
$fileBaseName = substr($originalImageName, 0, $dotIndex);
|
||||
}
|
||||
$outputs['name'] = $fileBaseName . $thumbnailSuffix . $fileExtension;
|
||||
//start to get the thumbnail width & height
|
||||
if($thumbnailWidth < 1 && $thumbnailHeight < 1)
|
||||
{
|
||||
$thumbnailWidth =$originaleImageWidth;
|
||||
$thumbnailHeight = $originalImageHeight;
|
||||
}elseif($thumbnailWidth < 1)
|
||||
{
|
||||
$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
|
||||
|
||||
}elseif($thumbnailHeight < 1)
|
||||
{
|
||||
$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
|
||||
}else
|
||||
{
|
||||
$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
|
||||
$thumbnailWidth = floor($scale*$originaleImageWidth);
|
||||
$thumbnailHeight = floor($scale*$originalImageHeight);
|
||||
}
|
||||
$outputs['width'] = $thumbnailWidth;
|
||||
$outputs['height'] = $thumbnailHeight;
|
||||
}
|
||||
return $outputs;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the uploaded file
|
||||
*/
|
||||
function deleteUploadedFile()
|
||||
{
|
||||
@unlink($this->filePath);
|
||||
}
|
||||
/**
|
||||
* destroy the tmp file
|
||||
*
|
||||
*/
|
||||
function finish()
|
||||
{
|
||||
@unlink($this->_value['tmp_name']);
|
||||
}
|
||||
|
||||
function displayError()
|
||||
{
|
||||
if(sizeof($this->errors))
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($this->errors);
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get the path which the file uploaded to
|
||||
*
|
||||
*/
|
||||
function getFilePath()
|
||||
{
|
||||
return $this->filePath;
|
||||
}
|
||||
/**
|
||||
* return the directory path witch the file uploaded to
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
function getDirPath()
|
||||
{
|
||||
return $this->dirPath;
|
||||
}
|
||||
|
||||
function getFileBaseName()
|
||||
{
|
||||
return $this->fileBaseName;
|
||||
}
|
||||
|
||||
function getFileName()
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
/**
|
||||
* get image width
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getImageWidth()
|
||||
{
|
||||
return $this->img_x;
|
||||
}
|
||||
/**
|
||||
* get image height
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getImageHeight()
|
||||
{
|
||||
return $this->img_y;
|
||||
}
|
||||
/**
|
||||
* get uploaded file size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFileSize()
|
||||
{
|
||||
return $this->fileSize;
|
||||
}
|
||||
/**
|
||||
* delete the uploaded image file & associated thumnails
|
||||
*
|
||||
* @param string $dirPath
|
||||
* @param string $originalImageName
|
||||
* @param string $arrayThumbnailSuffix
|
||||
*/
|
||||
function deleteFileAndThumbs($dirPath, $originalImageName, $arrayThumbnailSuffix)
|
||||
{
|
||||
//ensure the directory path ending with /
|
||||
if ($dirPath != '' && substr($dirPath, -1) != '/') {
|
||||
$dirPath .= '/';
|
||||
}
|
||||
if(!empty($originalImageName) && file_exists($dirPath . $originalImageName) && is_file($dirPath . $originalImageName))
|
||||
{
|
||||
@unlink($dirPath . $originalImageName);
|
||||
foreach($arrayThumbnailSuffix as $v)
|
||||
{
|
||||
$dotIndex = strrpos($originalImageName, '.');
|
||||
//begin to get the thumbnail image name
|
||||
$fileExtension = '';
|
||||
$fileBaseName = '';
|
||||
if(is_int($dotIndex))
|
||||
{
|
||||
$fileExtension = substr($originalImageName, $dotIndex);
|
||||
$fileBaseName = substr($originalImageName, 0, $dotIndex);
|
||||
}
|
||||
@unlink($dirPath . $fileBaseName . $v . $fileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysem base config setting
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 1/August/2007
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
//error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
|
||||
|
||||
//Access Control Setting
|
||||
/**
|
||||
* turn off => false
|
||||
* by session => true
|
||||
*/
|
||||
define('CONFIG_ACCESS_CONTROL_MODE', false);
|
||||
define("CONFIG_LOGIN_USERNAME", 'sdfgdfgdfgdgfdgsdfsdfg3454dsfb5e');
|
||||
define('CONFIG_LOGIN_PASSWORD', 'ASDF@#%JHGSDFGasdkjfh3812764ksdjfbhkjxcf');
|
||||
define('CONFIG_LOGIN_PAGE', 'ajax_login.php'); //the url to the login page
|
||||
|
||||
|
||||
//SYSTEM MODE CONFIG
|
||||
/**
|
||||
* turn it on when you have this system for demo purpose
|
||||
* that means changes made to each image is not physically applied to it
|
||||
* and all uploaded files/created folders will be removed automatically
|
||||
*/
|
||||
define('CONFIG_SYS_DEMO_ENABLE', false);
|
||||
define('CONFIG_SYS_VIEW_ONLY', false); //diabled the system, view only
|
||||
define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false
|
||||
|
||||
//User Permissions
|
||||
define('CONFIG_OPTIONS_DELETE', true);
|
||||
define('CONFIG_OPTIONS_CUT', true);
|
||||
define('CONFIG_OPTIONS_COPY', true);
|
||||
define('CONFIG_OPTIONS_NEWFOLDER', true);
|
||||
define('CONFIG_OPTIONS_RENAME', true);
|
||||
define('CONFIG_OPTIONS_UPLOAD', true); //
|
||||
define('CONFIG_OPTIONS_EDITABLE', true); //disable image editor and text editor
|
||||
//FILESYSTEM CONFIG
|
||||
/*
|
||||
* CONFIG_SYS_DEFAULT_PATH is the default folder where the files would be uploaded to
|
||||
and it must be a folder under the CONFIG_SYS_ROOT_PATH or the same folder
|
||||
these two paths accept relative path only, don't use absolute path
|
||||
*/
|
||||
//check if folder exist
|
||||
if (!is_dir('../../img/cms'))
|
||||
mkdir('../../img/cms');
|
||||
|
||||
define('CONFIG_SYS_DEFAULT_PATH', '../../img/cms'); //accept relative path only
|
||||
define('CONFIG_SYS_ROOT_PATH', '../../img/cms'); //accept relative path only
|
||||
define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name
|
||||
define("CONFIG_SYS_DIR_SESSION_PATH", 'session/');
|
||||
define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns
|
||||
/**
|
||||
* reg => regulare expression
|
||||
* csv => a list of comma separated file/folder name, (exactly match the specified file/folders)
|
||||
* list => a list of comma spearated vague file/folder name (partially match the specified file/folders)
|
||||
*
|
||||
*/
|
||||
//more details about regular expression please visit http://nz.php.net/manual/en/function.eregi.php
|
||||
define('CONFIG_SYS_INC_DIR_PATTERN', ''); //force listing of folders with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_EXC_DIR_PATTERN', 'CVS'); //will prevent listing of folders with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_INC_FILE_PATTERN', ''); //force listing of fiels with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_EXC_FILE_PATTERN', ''); //will prevent listing of files with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1
|
||||
|
||||
//UPLOAD OPTIONS CONFIG
|
||||
define('CONFIG_UPLOAD_MAXSIZE', 5000 * 1024 ); //by bytes
|
||||
//define('CONFIG_UPLOAD_MAXSIZE', 2048); //by bytes
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'txt');//
|
||||
|
||||
define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html,xml,js,css'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid
|
||||
|
||||
define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png');// //
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf,ppt,rtf,doc,pdf,xls,txt,xml,xsl,dtd');//
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,jpg,png');
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
define('CONFIG_UPLOAD_INVALID_EXTS', '');
|
||||
|
||||
//Preview
|
||||
define('CONFIG_IMG_THUMBNAIL_MAX_X', 100);
|
||||
define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100);
|
||||
define('CONFIG_THICKBOX_MAX_WIDTH', 700);
|
||||
define('CONFIG_THICKBOX_MAX_HEIGHT', 430);
|
||||
|
||||
|
||||
/**
|
||||
* CONFIG_URL_PREVIEW_ROOT was replaced by CONFIG_WEBSITE_DOCUMENT_ROOT since v0.8
|
||||
* Normally, you don't need to bother with CONFIG_WEBSITE_DOCUMENT_ROOT
|
||||
* Howerver, some Web Hosts do not have standard php.ini setting
|
||||
* which you will find the file manager can not locate your files correctly
|
||||
* if you do have such issue, please change it to fit your system.
|
||||
* so what should you to do get it
|
||||
* 1. create a php script file (let's call it document_root.php)
|
||||
* 2. add the following codes in in
|
||||
* <?php
|
||||
* echo dirname(__FILE__);
|
||||
* ?>
|
||||
* 3. upload document_root.php to you website root folder which will only be reached when you visit http://www.domain-name.com or http://localhost/ at localhost computer
|
||||
* 4. run it via http://www.domain-name.com/document_root.php or http://localhost/docuent_root.php if localhost computer, the url has to be exactly like that
|
||||
* 5. the value shown on the screen is CONFIG_WEBSITE_DOCUMENT_ROOT should be
|
||||
* 6. enjoy it
|
||||
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
define('CONFIG_WEBSITE_DOCUMENT_ROOT', '');
|
||||
//theme related setting
|
||||
/*
|
||||
* options avaialbe for CONFIG_EDITOR_NAME are:
|
||||
stand_alone
|
||||
tinymce
|
||||
fckeditor
|
||||
*/
|
||||
//CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8
|
||||
define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'tinymce'));
|
||||
define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default')); //change the theme to your custom theme rather than default
|
||||
define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'detail':'detail')); //thumnail or detail
|
||||
define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10);
|
||||
define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client
|
||||
|
||||
//General Option Declarations
|
||||
//LANGAUGAE DECLARATIONNS
|
||||
define('CONFIG_LANG_INDEX', 'language'); //the index in the session
|
||||
define('CONFIG_LANG_DEFAULT', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['language']) && file_exists(DIR_LANG . secureFileName($_GET['language']) . '.php')?secureFileName($_GET['language']):'en')); //change it to be your language file base name, such en
|
||||
?>
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysem config setting
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @version 1.0
|
||||
* @since 22/April/2007
|
||||
*
|
||||
*/
|
||||
|
||||
//FILESYSTEM CONFIG <br>
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.auth.php");
|
||||
define('CONFIG_QUERY_STRING_ENABLE', true); //Enable passed query string to setting the system configuration
|
||||
if(!isset($_SESSION))
|
||||
{
|
||||
session_start();
|
||||
}
|
||||
if(!headers_sent())
|
||||
{
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* secure file name which retrieve from query string
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function secureFileName($input)
|
||||
{
|
||||
return preg_replace('/[^a-zA-Z0-9\-_]/', '', $input);
|
||||
}
|
||||
//Directories Declarations
|
||||
|
||||
define('DIR_AJAX_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR) ; // the path to ajax file manager
|
||||
define('DIR_AJAX_INC', DIR_AJAX_ROOT . "inc" . DIRECTORY_SEPARATOR);
|
||||
define('DIR_AJAX_CLASSES', DIR_AJAX_ROOT . "classes" . DIRECTORY_SEPARATOR);
|
||||
define("DIR_AJAX_LANGS", DIR_AJAX_ROOT . "langs" . DIRECTORY_SEPARATOR);
|
||||
define('DIR_AJAX_JS', DIR_AJAX_ROOT . 'jscripts' . DIRECTORY_SEPARATOR);
|
||||
define('DIR_AJAX_EDIT_AREA', DIR_AJAX_JS . 'edit_area' . DIRECTORY_SEPARATOR);
|
||||
define('DIR_LANG', DIR_AJAX_ROOT . 'langs' . DIRECTORY_SEPARATOR);
|
||||
|
||||
|
||||
//Class Declarations
|
||||
define('CLASS_FILE', DIR_AJAX_INC .'class.file.php');
|
||||
define("CLASS_UPLOAD", DIR_AJAX_INC . 'class.upload.php');
|
||||
define('CLASS_MANAGER', DIR_AJAX_INC . 'class.manager.php');
|
||||
define('CLASS_IMAGE', DIR_AJAX_INC . "class.image.php");
|
||||
define('CLASS_HISTORY', DIR_AJAX_INC . "class.history.php");
|
||||
define('CLASS_SESSION_ACTION', DIR_AJAX_INC . "class.sessionaction.php");
|
||||
define('CLASS_PAGINATION', DIR_AJAX_INC . 'class.pagination.php');
|
||||
define('CLASS_SEARCH', DIR_AJAX_INC . "class.search.php");
|
||||
//SCRIPT FILES declarations
|
||||
define('SPT_FUNCTION_BASE', DIR_AJAX_INC . 'function.base.php');
|
||||
//include different config base file according to query string "config"
|
||||
$configBaseFileName = 'config.base.php';
|
||||
|
||||
if(CONFIG_QUERY_STRING_ENABLE && !empty($_GET['config']) && file_exists(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'config.' . secureFileName($_GET['config']) . ".php")
|
||||
{
|
||||
$configBaseFileName = 'config.' . secureFileName($_GET['config']) . ".php";
|
||||
}
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . $configBaseFileName);
|
||||
|
||||
|
||||
require_once(DIR_AJAX_LANGS . CONFIG_LANG_DEFAULT . ".php");
|
||||
require_once(DIR_AJAX_INC . "function.base.php");
|
||||
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.session.php");
|
||||
$session = new Session();
|
||||
$auth = new Auth();
|
||||
|
||||
if(CONFIG_ACCESS_CONTROL_MODE == 1)
|
||||
{//access control enabled
|
||||
if(!$auth->isLoggedIn() && strtolower(basename($_SERVER['PHP_SELF']) != strtolower(basename(CONFIG_LOGIN_PAGE))))
|
||||
{//
|
||||
header('Location: ' . appendQueryString(CONFIG_LOGIN_PAGE, makeQueryString()));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
addNoCacheHeaders();
|
||||
//URL Declartions
|
||||
define('CONFIG_URL_IMAGE_PREVIEW', 'ajax_image_preview.php');
|
||||
define('CONFIG_URL_CREATE_FOLDER', 'ajax_create_folder.php');
|
||||
define('CONFIG_URL_DELETE', 'ajax_delete_file.php');
|
||||
define('CONFIG_URL_HOME', 'ajaxfilemanager.php');
|
||||
define("CONFIG_URL_UPLOAD", 'ajax_file_upload.php');
|
||||
define('CONFIG_URL_PREVIEW', 'ajax_preview.php');
|
||||
define('CONFIG_URL_SAVE_NAME', 'ajax_save_name.php');
|
||||
define('CONFIG_URL_IMAGE_EDITOR', 'ajax_image_editor.php');
|
||||
define('CONFIG_URL_IMAGE_SAVE', 'ajax_image_save.php');
|
||||
define('CONFIG_URL_IMAGE_RESET', 'ajax_editor_reset.php');
|
||||
define('CONFIG_URL_IMAGE_UNDO', 'ajax_image_undo.php');
|
||||
define('CONFIG_URL_CUT', 'ajax_file_cut.php');
|
||||
define('CONFIG_URL_COPY', 'ajax_file_copy.php');
|
||||
define('CONFIG_URL_LOAD_FOLDERS', '_ajax_load_folders.php');
|
||||
|
||||
define('CONFIG_URL_DOWNLOAD', 'ajax_download.php');
|
||||
define('CONFIG_URL_TEXT_EDITOR', 'ajax_text_editor.php');
|
||||
define('CONFIG_URL_GET_FOLDER_LIST', 'ajax_get_folder_listing.php');
|
||||
define('CONFIG_URL_SAVE_TEXT', 'ajax_save_text.php');
|
||||
define('CONFIG_URL_LIST_LISTING', 'ajax_get_file_listing.php');
|
||||
define('CONFIG_URL_IMG_THUMBNAIL', 'ajax_image_thumbnail.php');
|
||||
define('CONFIG_URL_FILEnIMAGE_MANAGER', 'ajaxfilemanager.php');
|
||||
define('CONFIG_URL_FILE_PASTE', 'ajax_file_paste.php');
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysem base config setting
|
||||
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
|
||||
* @link www.phpletter.com
|
||||
* @since 1/August/2007
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
error_reporting(E_ALL);
|
||||
//error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
|
||||
|
||||
//Access Control Setting
|
||||
/**
|
||||
* turn off => false
|
||||
* by session => true
|
||||
*/
|
||||
define('CONFIG_ACCESS_CONTROL_MODE', false);
|
||||
define("CONFIG_LOGIN_USERNAME", 'ajax');
|
||||
define('CONFIG_LOGIN_PASSWORD', '123456');
|
||||
define('CONFIG_LOGIN_PAGE', 'ajax_login.php'); //the url to the login page
|
||||
|
||||
//SYSTEM MODE CONFIG
|
||||
/**
|
||||
* turn it on when you have this system for demo purpose
|
||||
* that means changes made to each image is not physically applied to it
|
||||
* and all uploaded files/created folders will be removed automatically
|
||||
*/
|
||||
define('CONFIG_SYS_DEMO_ENABLE', false);
|
||||
define('CONFIG_SYS_VIEW_ONLY', false); //diabled the system, view only
|
||||
define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false
|
||||
|
||||
//User Permissions
|
||||
define('CONFIG_OPTIONS_DELETE', true);
|
||||
define('CONFIG_OPTIONS_CUT', true);
|
||||
define('CONFIG_OPTIONS_COPY', true);
|
||||
define('CONFIG_OPTIONS_NEWFOLDER', true);
|
||||
define('CONFIG_OPTIONS_RENAME', true);
|
||||
define('CONFIG_OPTIONS_UPLOAD', true); //
|
||||
define('CONFIG_OPTIONS_EDITABLE', true); //disable image editor and text editor
|
||||
//FILESYSTEM CONFIG
|
||||
/*
|
||||
* CONFIG_SYS_DEFAULT_PATH is the default folder where the files would be uploaded to
|
||||
and it must be a folder under the CONFIG_SYS_ROOT_PATH or the same folder
|
||||
these two paths accept relative path only, don't use absolute path
|
||||
*/
|
||||
|
||||
define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only
|
||||
define('CONFIG_SYS_ROOT_PATH', '../uploaded/'); //accept relative path only
|
||||
define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name
|
||||
define("CONFIG_SYS_DIR_SESSION_PATH", 'session/');
|
||||
define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns
|
||||
/**
|
||||
* reg => regulare expression
|
||||
* csv => a list of comma separated file/folder name, (exactly match the specified file/folders)
|
||||
* list => a list of comma spearated vague file/folder name (partially match the specified file/folders)
|
||||
*
|
||||
*/
|
||||
//more details about regular expression please visit http://nz.php.net/manual/en/function.eregi.php
|
||||
define('CONFIG_SYS_INC_DIR_PATTERN', ''); //force listing of folders with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_EXC_DIR_PATTERN', ''); //will prevent listing of folders with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_INC_FILE_PATTERN', ''); //force listing of fiels with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_EXC_FILE_PATTERN', ''); //will prevent listing of files with such pattern(s). separated by , if multiple
|
||||
define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1
|
||||
|
||||
//UPLOAD OPTIONS CONFIG
|
||||
define('CONFIG_UPLOAD_MAXSIZE', 5000 * 1024 ); //by bytes
|
||||
//define('CONFIG_UPLOAD_MAXSIZE', 2048); //by bytes
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'txt');//
|
||||
|
||||
define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html,xml,js,css'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid
|
||||
|
||||
define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf,ppt,rtf,doc,pdf,xls,txt,xml,xsl,dtd');//
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,png,tif,html,htm,js,css,xml,xsl,dtd,mp3,wav,wmv,wma,rm,rmvb,mov,swf');
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
define('CONFIG_UPLOAD_INVALID_EXTS', '');
|
||||
|
||||
//Preview
|
||||
define('CONFIG_IMG_THUMBNAIL_MAX_X', 100);
|
||||
define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100);
|
||||
define('CONFIG_THICKBOX_MAX_WIDTH', 700);
|
||||
define('CONFIG_THICKBOX_MAX_HEIGHT', 430);
|
||||
|
||||
|
||||
/**
|
||||
* CONFIG_URL_PREVIEW_ROOT was replaced by CONFIG_WEBSITE_DOCUMENT_ROOT since v0.8
|
||||
* Normally, you don't need to bother with CONFIG_WEBSITE_DOCUMENT_ROOT
|
||||
* Howerver, some Web Hosts do not have standard php.ini setting
|
||||
* which you will find the file manager can not locate your files correctly
|
||||
* if you do have such issue, please change it to fit your system.
|
||||
* so what should you to do get it
|
||||
* 1. create a php script file (let's call it document_root.php)
|
||||
* 2. add the following codes in in
|
||||
* <?php
|
||||
* echo dirname(__FILE__);
|
||||
* ?>
|
||||
* 3. upload document_root.php to you website root folder which will only be reached when you visit http://www.domain-name.com or http://localhost/ at localhost computer
|
||||
* 4. run it via http://www.domain-name.com/document_root.php or http://localhost/docuent_root.php if localhost computer, the url has to be exactly like that
|
||||
* 5. the value shown on the screen is CONFIG_WEBSITE_DOCUMENT_ROOT should be
|
||||
* 6. enjoy it
|
||||
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
define('CONFIG_WEBSITE_DOCUMENT_ROOT', '');
|
||||
//theme related setting
|
||||
/*
|
||||
* options avaialbe for CONFIG_EDITOR_NAME are:
|
||||
stand_alone
|
||||
tinymce
|
||||
fckeditor
|
||||
*/
|
||||
//CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8
|
||||
define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'stand_alone'));
|
||||
define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default')); //change the theme to your custom theme rather than default
|
||||
define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'detail':'detail')); //thumnail or detail
|
||||
define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10);
|
||||
define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client
|
||||
|
||||
//General Option Declarations
|
||||
//LANGAUGAE DECLARATIONNS
|
||||
define('CONFIG_LANG_INDEX', 'language'); //the index in the session
|
||||
define('CONFIG_LANG_DEFAULT', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['language']) && file_exists(DIR_LANG . secureFileName($_GET['language'] . '.php'))?secureFileName($_GET['language']):'en')); //change it to be your language file base name, such en
|
||||
?>
|
||||
@@ -1,8 +0,0 @@
|
||||
<pre>Array
|
||||
(
|
||||
[currentFolderPath] => ../uploaded/
|
||||
[new_folder] => Test
|
||||
)
|
||||
</pre>
|
||||
|
||||
22/Sep/2008 13:17:12
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user