/**
* @class PL_Base
* @brief Base class for database tables
* @author Stephan K�nig (tb@octoplex.org)
*
*/
class PL_Base
{
function PL_Base($rs = "")
{
}
function load($id, $field_id="id")
{
return $this->loadDatabase($id, $field_id);
}
function loadDatabase()
{
}
function save($debug=false)
{
return $this->saveDatabase($debug);
}
function saveDatabase()
{
}
function delete($id=false, $field_id="id")
{
return $this->deleteDatabase($id, $field_id);
}
function deleteDatabase()
{
}
}
/**
* @class PL_Dir
* @brief Provides simple filesystem functions
* @author Reza Esmaili (me@dfox.info)
*
* This class provides simple filesystem functions like directory listings or file-deletion. All of the methods can
* process directories recursively. An array with exclude-conditions is specified (and can be overwritten) to protect
* needed files from processing (e.g. the CVS subdirectory)
*/
class PL_Dir
{
var $excludes = array(
'/^\.$/',
'/^\.\.$/',
'/^\._/',
'/^CVS/',
'/^.svn/',
'/^_thumbs/',
'/^\.#.*/',
'/^\.cvsignore/'
);
var $files = array();
var $dirs = array();
/**
* This method checks all incoming file and/or directory names for excludes. If any of the exclude-conditions are met,
* the file and/or directory will not be processed (listed/deleted...)
*
* @param $entry A file or directory name
* @return true if none of the exclude-conditions are met, false if one of them are
* @author Reza Esmaili (me@dfox.info)
*/
function checkExcludes($entry)
{
foreach ($this->excludes as $exclude) {
// check with regular expression
if (preg_match($exclude, $entry))
return false;
}
return true;
}
/**
* Wrapper method to fetch all entries from a given directory
*
* @param $path Path to be scanned
* @param $recursive true or false
* @param $only process only "files" or "dirs". Default "both"
* @param $assoc return an associative array of files/dirs
* @param $entries The current array of already processed entries (needed for recursion)
* @return array of files/directories with full path
* @author Reza Esmaili (me@dfox.info)
*/
function _getEntries($path, $recursive, $only=false, $assoc=false, $entries=array())
{
$dir = opendir($path);
$files = array();
if (!is_resource($dir)) {
return $entries;
}
while (false !== ($entryName = readdir($dir))){
$entry = $path."/".$entryName;
$valid = $this->checkExcludes($entryName);
if ($valid === true) {
switch ($only) {
case "dirs":
if (is_dir($entry))
array_push($entries, htmlentities($entry));
break;
case "files":
if (is_file($entry))
array_push($files, htmlentities($entry));
break;
default:
if (is_file($entry))
array_push($files, htmlentities($entry));
if (is_dir($entry))
array_push($entries, htmlentities($entry));
}
if (is_dir($entry) && $recursive === true)
$entries = array_merge($entries, $this->_getEntries($entry, $recursive, $only, $assoc));
}
}
$entries = array_merge($files,$entries);
closedir($dir);
return $entries;
}
/**
* Creates a directory with optional permissions
*
* @param $path The path to the directory to be created
* @param $rights Optional.
* @author Reza Esmaili (me@dfox.info)
*/
function createDir($path, $rights=0775)
{
if (!file_exists($path))
mkdir($path, $rights);
}
/**
* Alias for the method createDir
*
* @param $path The path to the directory to be created
* @param $rights Optional.
* @author Reza Esmaili (me@dfox.info)
*/
function create($path, $rights=0755)
{
$this->createDir($path, $rights);
}
/**
* Fetches a list of all directories inside a given path
*
* @param $path The path to the directory to be scanned
* @param $recursive Optional.
* @param $assoc Optional.
* @author Reza Esmaili (me@dfox.info)
*/
function getDirs($path, $recursive=false, $assoc=false)
{
return $this->_getEntries($path, $recursive, "dirs", $assoc);
}
/**
* Fetches a list of all files inside a given path
*
* @param $path The path to the directory to be scanned
* @param $recursive Optional.
* @param $assoc Optional.
* @author Reza Esmaili (me@dfox.info)
*/
function getFiles($path, $recursive=false, $assoc=false)
{
return $this->_getEntries($path, $recursive, "files", $assoc);
}
/**
* Deletes a file from the filesystem
*
* @param $path The path to the file to be deleted
* @author Reza Esmaili (me@dfox.info)
*/
function remove($path)
{
if (file_exists($path))
unlink($path);
}
/**
* Deletes as files from a given directory
*
* @param $path The path to the file to be deleted
* @param $recursive
* @author Reza Esmaili (me@dfox.info)
*/
function emptyDir($path, $recursive=false)
{
$this->_removeDir($path, $recursive, false);
}
/**
* Deletes as files from a given directory (recursive)
*
* @param $path The path to the file to be deleted
* @param $recursive
* @author Reza Esmaili (me@dfox.info)
*/
function removeDir($path)
{
$this->_removeDir($path, true, true);
}
/**
* Wrapper method to delete all files from a given directory
*
* @param $path The path to the file to be deleted
* @param $recursive
* @param $removeLast Removes the given directory itself upon completion
* @param $level current Level of recursion
* @author Reza Esmaili (me@dfox.info)
*/
function _removeDir($path, $recursive=false, $removeLast=false, $level=0)
{
$dir = opendir($path);
while($entryName = readdir($dir)){
$entry = $path."/".$entryName;
$valid = $this->checkExcludes($entryName);
if ($valid === true) {
if (is_dir($entry) && $recursive === true)
$this->_removeDir($entry, $recursive, $removeLast, $level++);
elseif (is_file($entry))
$this->remove($entry);
}
}
closedir($dir);
if (($level == 0 && $removeLast === true) || $level > 0)
@rmdir($path);
}
}
/**
* @class PL_Date
* @brief Provides simple date functions
* @author Reza Esmaili (me@dfox.info)
*
* This class provides simple date functions like converting a date according to a given date_format
*/
class PL_Date
{
/**
* Converts a standard date (e.g. 2006-07-11 12:00:45) to a date defined by the date-format (e.g. 11.07.2006 12:00:45)
*
* @param $date The date string (or timestamp) to be converted
* @param $hours Optional.
* @param $dateFormat Optional.
* @author Reza Esmaili (me@dfox.info)
*/
function convert($date, $hours=false, $long=false, $dateFormat=false)
{
global $__currentLocale;
$date = PL_Date::convertToTimestamp($date);
if ($dateFormat === false) {
if ($hours === false && $long === false)
$dateFormat = plGetConfig("language", "date_format", $__currentLocale);
elseif ($hours === false && $long === true)
$dateFormat = plGetConfig("language", "date_format_long", $__currentLocale);
elseif ($hours === true && $long === false)
$dateFormat = plGetConfig("language", "date_time_format", $__currentLocale);
elseif ($hours === true && $long === true)
$dateFormat = plGetConfig("language", "date_time_format_long", $__currentLocale);
}
return strftime($dateFormat, $date);
}
/**
* Converts a standard date (e.g. 2006-07-11 12:00:45) to a timestamp
*
* @param $date The date string to be converted
* @author Reza Esmaili (me@dfox.info)
*/
function convertToTimestamp($date)
{
if (!is_numeric($date)) {
if (count(explode("-", $date)) >= 3) {
$date = strtotime($date);
} elseif (count(explode(".", $date)) >= 3) {
$day = substr($date, 0, 2);
$month = substr($date, 3, 2);
$year = substr($date, 6, 4);
$hours = substr($date, 11);
$date = strtotime($year."-".$month."-".$day." ".$hours);
}
}
return $date;
}
function convertToJSCalendar($dateFormat=false)
{
// format to something like this: d + "." + m + "." + y;
global $__currentLocale;
if ($dateFormat === false)
$dateFormat = plGetConfig("language", "date_format", $__currentLocale);
$dateFormat = strtolower($dateFormat);
$divider = substr($dateFormat, 2, 1);
$dateFormat = str_replace("%", "", $dateFormat);
$dateFormatArray = explode($divider, $dateFormat);
$jScript = implode(" + \".\" + ", $dateFormatArray);
return $jScript;
}
}
Fatal error: 'break' not in the 'loop' or 'switch' context in /home/dualgdps213/public_html/explosive-party26/_system/image.class.php on line 871