Use most recent version of CPHP
parent
bec21e4adc
commit
00bd67bb0b
@ -0,0 +1,36 @@
|
||||
{
|
||||
"database": {
|
||||
"driver": "mysql",
|
||||
"pdo": "true",
|
||||
"hostname": "localhost",
|
||||
"username": "root",
|
||||
"password": "",
|
||||
"database": "cvm"
|
||||
},
|
||||
"locale": {
|
||||
"path": "locales",
|
||||
"extension": "lng",
|
||||
"default_locale": "english",
|
||||
"default_timezone": "Europe/Amsterdam"
|
||||
},
|
||||
"memcache": {
|
||||
"enabled": true,
|
||||
"compressed": true,
|
||||
"hostname": "localhost",
|
||||
"port": 11211
|
||||
},
|
||||
"class_map": {
|
||||
"user": "User",
|
||||
"node": "Node",
|
||||
"container": "Container",
|
||||
"template": "Template"
|
||||
},
|
||||
"components": [
|
||||
"router",
|
||||
"errorhandler"
|
||||
],
|
||||
"authentication": {
|
||||
"salt": "abcdef",
|
||||
"session_length": 2592000
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
../../cphp
|
@ -1 +0,0 @@
|
||||
config.mysql.php
|
@ -1,14 +0,0 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
require("include.constants.php");
|
||||
|
||||
require("cphp/config.php");
|
||||
|
||||
require("include.dependencies.php");
|
||||
require("include.exceptions.php");
|
||||
require("include.datetime.php");
|
||||
require("include.misc.php");
|
||||
|
||||
require("include.memcache.php");
|
||||
require("include.mysql.php");
|
||||
require("include.session.php");
|
||||
|
||||
require("class.templater.php");
|
||||
require("class.localizer.php");
|
||||
|
||||
$locale = new Localizer();
|
||||
$locale->Load($cphp_locale_name);
|
||||
|
||||
setlocale(LC_ALL, $locale->locale);
|
||||
|
||||
require("class.base.php");
|
||||
require("class.databaserecord.php");
|
||||
|
||||
foreach($cphp_components as $component)
|
||||
{
|
||||
require("components/component.{$component}.php");
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
class CPHPBaseClass
|
||||
{
|
||||
public $render_template = "";
|
||||
|
||||
public function RenderTimeAgo($template, $property)
|
||||
{
|
||||
global $locale;
|
||||
|
||||
$variable_name = "s{$property}";
|
||||
|
||||
if(isset($this->$variable_name) && is_numeric($this->$variable_name))
|
||||
{
|
||||
$timestamp = $this->$variable_name;
|
||||
|
||||
if($timestamp > time())
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-future'];
|
||||
}
|
||||
elseif($timestamp == time())
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-now'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$date1 = new DateTime("@{$timestamp}", new DateTimeZone("GMT"));
|
||||
$date2 = new DateTime("now", new DateTimeZone("GMT"));
|
||||
|
||||
$interval = $date1->diff($date2);
|
||||
$years = (int)$interval->format("%G");
|
||||
$months = (int)$interval->format("%m");
|
||||
$weeks = (int)$interval->format("%U");
|
||||
$days = (int)$interval->format("%d");
|
||||
$hours = (int)$interval->format("%H");
|
||||
$minutes = (int)$interval->format("%i");
|
||||
$seconds = (int)$interval->format("%S");
|
||||
|
||||
if($years > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-years-ago'], $years);
|
||||
}
|
||||
elseif($years == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1year-ago'];
|
||||
}
|
||||
elseif($months > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-months-ago'], $months);
|
||||
}
|
||||
elseif($months == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1month-ago'];
|
||||
}
|
||||
elseif($weeks > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-weeks-ago'], $weeks);
|
||||
}
|
||||
elseif($weeks == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1week-ago'];
|
||||
}
|
||||
elseif($days > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-days-ago'], $days);
|
||||
}
|
||||
elseif($days == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1day-ago'];
|
||||
}
|
||||
elseif($hours > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-hours-ago'], $hours);
|
||||
}
|
||||
elseif($hours == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1hour-ago'];
|
||||
}
|
||||
elseif($minutes > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-minutes-ago'], $minutes);
|
||||
}
|
||||
elseif($minutes == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1minute-ago'];
|
||||
}
|
||||
elseif($seconds > 1)
|
||||
{
|
||||
$sTimeAgo = sprintf($locale->strings['event-seconds-ago'], $seconds);
|
||||
}
|
||||
elseif($seconds == 1)
|
||||
{
|
||||
$sTimeAgo = $locale->strings['event-1second-ago'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If you see this, there's probably something wrong.
|
||||
$sTimeAgo = $locale->strings['event-past'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sDate = local_from_unix($timestamp, $locale->datetime_long);
|
||||
|
||||
return $this->RenderTemplateExternal($template, array(
|
||||
'local-time' => $sDate,
|
||||
'time-ago' => $sTimeAgo,
|
||||
'timestamp' => $timestamp
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Property {$classname}.{$property} does not exist or is not of a valid format.");
|
||||
}
|
||||
}
|
||||
|
||||
public function RenderTemplateExternal($template, $strings)
|
||||
{
|
||||
return $this->DoRenderTemplate($template, $strings);
|
||||
}
|
||||
|
||||
public function DoRenderTemplate($template, $strings)
|
||||
{
|
||||
global $locale;
|
||||
|
||||
try
|
||||
{
|
||||
$tpl = new Templater();
|
||||
$tpl->Load($template);
|
||||
$tpl->Localize($locale->strings);
|
||||
$tpl->Compile($strings);
|
||||
return $tpl->Render();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Failed to render template {$classname}.{$template}.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,442 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
|
||||
{
|
||||
public $fill_query = "";
|
||||
public $verify_query = "";
|
||||
public $table_name = "";
|
||||
public $query_cache = 60;
|
||||
public $id_field = "Id";
|
||||
|
||||
public $prototype = array();
|
||||
public $prototype_render = array();
|
||||
public $prototype_export = array();
|
||||
public $uData = array();
|
||||
|
||||
public $sId = 0;
|
||||
|
||||
public function __construct($uDataSource)
|
||||
{
|
||||
$this->ConstructDataset($uDataSource);
|
||||
$this->EventConstructed();
|
||||
}
|
||||
|
||||
public function RefreshData()
|
||||
{
|
||||
$this->PurgeCache();
|
||||
$this->ConstructDataset($this->sId);
|
||||
}
|
||||
|
||||
public function ConstructDataset($uDataSource, $uCommunityId = 0)
|
||||
{
|
||||
$bind_datasets = true;
|
||||
|
||||
if(is_numeric($uDataSource))
|
||||
{
|
||||
if($uDataSource != 0)
|
||||
{
|
||||
if(!empty($this->fill_query))
|
||||
{
|
||||
$this->sId = (is_numeric($uDataSource)) ? $uDataSource : 0;
|
||||
|
||||
$query = sprintf($this->fill_query, $uDataSource);
|
||||
if($result = mysql_query_cached($query, $this->query_cache))
|
||||
{
|
||||
$uDataSource = $result->data[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new NotFoundException("Could not locate {$classname} {$uDataSource} in database.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new PrototypeException("No fill query defined for {$classname} class.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bind_datasets = false;
|
||||
}
|
||||
}
|
||||
elseif(is_object($uDataSource))
|
||||
{
|
||||
if(isset($uDataSource->data[0]))
|
||||
{
|
||||
$uDataSource = $uDataSource->data[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotFoundException("No result set present in object.");
|
||||
}
|
||||
}
|
||||
elseif(is_array($uDataSource))
|
||||
{
|
||||
if(isset($uDataSource[0]))
|
||||
{
|
||||
$uDataSource = $uDataSource[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new ConstructorException("Invalid type passed on to constructor for object of type {$classname}.");
|
||||
}
|
||||
|
||||
if($bind_datasets === true)
|
||||
{
|
||||
$this->sId = (is_numeric($uDataSource[$this->id_field])) ? $uDataSource[$this->id_field] : 0;
|
||||
|
||||
$this->uData = $uDataSource;
|
||||
|
||||
foreach($this->prototype as $type => $dataset)
|
||||
{
|
||||
$this->BindDataset($type, $dataset);
|
||||
}
|
||||
|
||||
$this->sFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sFound = false;
|
||||
}
|
||||
|
||||
if(!empty($uCommunityId) && !empty($this->sCommunityId))
|
||||
{
|
||||
$sCommunityId = (is_numeric($uCommunityId)) ? $uCommunityId : 0;
|
||||
|
||||
if($sCommunityId != $this->sCommunity->sId)
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new OwnershipException("{$classname} {$this->sId} does not belong to Community {$sCommunityId}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function BindDataset($type, $dataset)
|
||||
{
|
||||
global $cphp_class_map;
|
||||
|
||||
if(is_array($dataset))
|
||||
{
|
||||
foreach($dataset as $variable_name => $column_name)
|
||||
{
|
||||
$original_value = $this->uData[$column_name];
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case "string":
|
||||
$value = htmlspecialchars(stripslashes($original_value));
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "html":
|
||||
$value = filter_html(stripslashes($original_value));
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "simplehtml":
|
||||
$value = filter_html_strict(stripslashes($original_value));
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "nl2br":
|
||||
$value = nl2br(htmlspecialchars(stripslashes($original_value)), false);
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "numeric":
|
||||
$value = (is_numeric($original_value)) ? $original_value : 0;
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "timestamp":
|
||||
$value = unix_from_mysql($original_value);
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "boolean":
|
||||
$value = (empty($original_value)) ? false : true;
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "user":
|
||||
$value = new User($original_value);
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
break;
|
||||
case "none":
|
||||
$value = $original_value;
|
||||
$variable_type = CPHP_VARIABLE_UNSAFE;
|
||||
break;
|
||||
default:
|
||||
$found = false;
|
||||
foreach($cphp_class_map as $class_type => $class_name)
|
||||
{
|
||||
if($type == $class_type)
|
||||
{
|
||||
$value = new $class_name($original_value);
|
||||
$variable_type = CPHP_VARIABLE_SAFE;
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($found == false)
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Cannot determine type of dataset ({$type}) passed on to {$classname}.BindDataset.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($variable_type == CPHP_VARIABLE_SAFE)
|
||||
{
|
||||
$variable_name_safe = "s" . $variable_name;
|
||||
$this->$variable_name_safe = $value;
|
||||
}
|
||||
|
||||
$variable_name_unsafe = "u" . $variable_name;
|
||||
$this->$variable_name_unsafe = $original_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Invalid dataset passed on to {$classname}.BindDataset.");
|
||||
}
|
||||
}
|
||||
|
||||
public function DoRenderInternalTemplate()
|
||||
{
|
||||
if(!empty($this->render_template))
|
||||
{
|
||||
$strings = array();
|
||||
foreach($this->prototype_render as $template_var => $object_var)
|
||||
{
|
||||
$variable_name = "s" . $object_var;
|
||||
$strings[$template_var] = $this->$variable_name;
|
||||
}
|
||||
return $this->DoRenderTemplate($this->render_template, $strings);
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Cannot render template: no template defined for {$classname} class.");
|
||||
}
|
||||
}
|
||||
|
||||
public function InsertIntoDatabase()
|
||||
{
|
||||
if(!empty($this->verify_query))
|
||||
{
|
||||
if($this->sId == 0)
|
||||
{
|
||||
$insert_mode = CPHP_INSERTMODE_INSERT;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = sprintf($this->verify_query, $this->sId);
|
||||
if($result = mysql_query_cached($query))
|
||||
{
|
||||
$insert_mode = CPHP_INSERTMODE_UPDATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert_mode = CPHP_INSERTMODE_INSERT;
|
||||
}
|
||||
}
|
||||
|
||||
$element_list = array();
|
||||
|
||||
foreach($this->prototype as $type_key => $type_value)
|
||||
{
|
||||
foreach($type_value as $element_key => $element_value)
|
||||
{
|
||||
switch($type_key)
|
||||
{
|
||||
case "none":
|
||||
case "numeric":
|
||||
case "boolean":
|
||||
case "timestamp":
|
||||
case "string":
|
||||
$element_list[$element_value] = array(
|
||||
'key' => $element_key,
|
||||
'type' => $type_key
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sKeyList = array();
|
||||
$sValueList = array();
|
||||
|
||||
foreach($element_list as $sKey => $value)
|
||||
{
|
||||
$variable_name_safe = "s" . $value['key'];
|
||||
$variable_name_unsafe = "u" . $value['key'];
|
||||
|
||||
if(isset($this->$variable_name_safe) || isset($this->$variable_name_unsafe))
|
||||
{
|
||||
switch($value['type'])
|
||||
{
|
||||
case "none":
|
||||
$sFinalValue = mysql_real_escape_string($this->$variable_name_unsafe);
|
||||
break;
|
||||
case "numeric":
|
||||
$number = (isset($this->$variable_name_unsafe)) ? $this->$variable_name_unsafe : $this->$variable_name_safe;
|
||||
$sFinalValue = (is_numeric($number)) ? $number : 0;
|
||||
break;
|
||||
case "boolean":
|
||||
$bool = (isset($this->$variable_name_unsafe)) ? $this->$variable_name_unsafe : $this->$variable_name_safe;
|
||||
$sFinalValue = ($bool) ? "1" : "0";
|
||||
break;
|
||||
case "timestamp":
|
||||
$sFinalValue = (isset($this->$variable_name_safe)) ? mysql_from_unix($this->$variable_name_safe) : mysql_from_unix(unix_from_local($this->$variable_name_unsafe));
|
||||
break;
|
||||
case "string":
|
||||
$sFinalValue = (isset($this->$variable_name_unsafe)) ? mysql_real_escape_string($this->$variable_name_unsafe) : mysql_real_escape_string($this->$variable_name_safe);
|
||||
break;
|
||||
case "default":
|
||||
$sFinalValue = mysql_real_escape_string($this->$variable_name_unsafe);
|
||||
break;
|
||||
}
|
||||
|
||||
$sFinalValue = "'{$sFinalValue}'";
|
||||
$sKey = "`{$sKey}`";
|
||||
|
||||
$sKeyList[] = $sKey;
|
||||
$sValueList[] = $sFinalValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("Database insertion failed: prototype property {$value['key']} not found in object of type {$classname}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($insert_mode == CPHP_INSERTMODE_INSERT)
|
||||
{
|
||||
$sQueryKeys = implode(", ", $sKeyList);
|
||||
$sQueryValues = implode(", ", $sValueList);
|
||||
$query = "INSERT INTO {$this->table_name} ({$sQueryKeys}) VALUES ({$sQueryValues})";
|
||||
}
|
||||
elseif($insert_mode == CPHP_INSERTMODE_UPDATE)
|
||||
{
|
||||
$sKeyValueList = array();
|
||||
|
||||
for($i = 0; $i < count($sKeyList); $i++)
|
||||
{
|
||||
$sKey = $sKeyList[$i];
|
||||
$sValue = $sValueList[$i];
|
||||
$sKeyValueList[] = "{$sKey} = {$sValue}";
|
||||
}
|
||||
|
||||
$sQueryKeysValues = implode(", ", $sKeyValueList);
|
||||
$query = "UPDATE {$this->table_name} SET {$sQueryKeysValues} WHERE `{$this->id_field}` = '{$this->sId}'";
|
||||
}
|
||||
|
||||
if($result = mysql_query($query))
|
||||
{
|
||||
if($insert_mode == CPHP_INSERTMODE_INSERT)
|
||||
{
|
||||
$this->sId = mysql_insert_id();
|
||||
}
|
||||
|
||||
$this->RefreshData();
|
||||
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new DatabaseException("Database insertion query failed in object of type {$classname}. Error message: " . mysql_error());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new Exception("No verification query defined for {$classname} class.");
|
||||
}
|
||||
}
|
||||
|
||||
public function RetrieveChildren($type, $field)
|
||||
{
|
||||
// Not done yet!
|
||||
|
||||
if(!isset($cphp_class_map[$type]))
|
||||
{
|
||||
$classname = get_class($this);
|
||||
throw new NotFoundException("Non-existent 'type' argument passed on to {$classname}.RetrieveChildren function.");
|
||||
}
|
||||
|
||||
$parent_type = get_parent_class($cphp_class_map[$type]);
|
||||
if($parent_type !== "CPHPDatabaseRecordClass")
|
||||
{
|
||||
$parent_type = ($parent_type === false) ? "NONE" : $parent_type;
|
||||
$classname = get_class($this);
|
||||
throw new TypeException("{$classname}.RetrieveChildren expected 'type' argument of parent-type CPHPDatabaseRecordClass, but got {$parent_type} instead.");
|
||||
}
|
||||
|
||||
$query = "";
|
||||
}
|
||||
|
||||
public function PurgeCache()
|
||||
{
|
||||
$query = sprintf($this->fill_query, $this->sId);
|
||||
$key = md5($query) . md5($query . "x");
|
||||
mc_delete($key);
|
||||
}
|
||||
|
||||
public function RenderTemplate($template = "")
|
||||
{
|
||||
if(!empty($template))
|
||||
{
|
||||
$this->render_template = $template;
|
||||
}
|
||||
|
||||
return $this->DoRenderInternalTemplate();
|
||||
}
|
||||
|
||||
public function Export()
|
||||
{
|
||||
// Exports the object as a nested array. Observes the export prototype.
|
||||
$export_array = array();
|
||||
|
||||
foreach($this->prototype_export as $field)
|
||||
{
|
||||
$variable_name = "s{$field}";
|
||||
if(is_object($this->$variable_name))
|
||||
{
|
||||
if(!empty($this->$variable_name->sId))
|
||||
{
|
||||
$export_array[$field] = $this->$variable_name->Export();
|
||||
}
|
||||
else
|
||||
{
|
||||
$export_array[$field] = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$export_array[$field] = $this->$variable_name;
|
||||
}
|
||||
}
|
||||
|
||||
return $export_array;
|
||||
}
|
||||
|
||||
// Define events
|
||||
|
||||
protected function EventConstructed() { }
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
class Localizer
|
||||
{
|
||||
public $strings = array();
|
||||
public $locale = "";
|
||||
public $datetime_short = "";
|
||||
public $datetime_long = "";
|
||||
public $date_short = "";
|
||||
public $date_long = "";
|
||||
public $time = "";
|
||||
|
||||
public function Load($locale)
|
||||
{
|
||||
$this->strings = array();
|
||||
$this->LoadInternal("english");
|
||||
$this->LoadInternal($locale);
|
||||
}
|
||||
|
||||
public function LoadInternal($locale)
|
||||
{
|
||||
global $cphp_locale_path, $cphp_locale_ext;
|
||||
$lng_contents = file_get_contents("{$cphp_locale_path}/{$locale}.{$cphp_locale_ext}");
|
||||
if($lng_contents !== false)
|
||||
{
|
||||
$lines = explode("\n", $lng_contents);
|
||||
foreach($lines as $line)
|
||||
{
|
||||
$line = str_replace("\r", "", $line);
|
||||
if(preg_match("/(.+?[^\\\]);(.+)/", $line, $matches))
|
||||
{
|
||||
$key = trim(str_replace("\;", ";", $matches[1]));
|
||||
$value = trim(str_replace("\;", ";", $matches[2]));
|
||||
switch($key)
|
||||
{
|
||||
case "_locale":
|
||||
$this->locale = explode(",", $value);
|
||||
break;
|
||||
case "_datetime_short":
|
||||
$this->datetime_short = $value;
|
||||
break;
|
||||
case "_datetime_long":
|
||||
$this->datetime_long = $value;
|
||||
break;
|
||||
case "_date_short":
|
||||
$this->date_short = $value;
|
||||
break;
|
||||
case "_date_long":
|
||||
$this->date_long = $value;
|
||||
break;
|
||||
case "_time":
|
||||
$this->time = $value;
|
||||
break;
|
||||
default:
|
||||
$this->strings[$key] = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("Failed to load locale {$locale}.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,691 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
$template_cache = array();
|
||||
$template_global_vars = array();
|
||||
|
||||
define("CPHP_TEMPLATER_SWITCH_NONE", 1);
|
||||
define("CPHP_TEMPLATER_SWITCH_TAG_OPEN", 2);
|
||||
define("CPHP_TEMPLATER_SWITCH_TAG_SYNTAX", 3);
|
||||
define("CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER", 4);
|
||||
define("CPHP_TEMPLATER_SWITCH_TAG_STATEMENT", 5);
|
||||
define("CPHP_TEMPLATER_SWITCH_TAG_VARNAME", 6);
|
||||
define("CPHP_TEMPLATER_TYPE_TAG_NONE", 10);
|
||||
define("CPHP_TEMPLATER_TYPE_TAG_OPEN", 11);
|
||||
define("CPHP_TEMPLATER_TYPE_TAG_CLOSE", 12);
|
||||
|
||||
class Templater
|
||||
{
|
||||
public $basedir = "templates/";
|
||||
public $extension = ".tpl";
|
||||
private $tpl = NULL;
|
||||
private $tpl_rendered = NULL;
|
||||
public $templatename = "";
|
||||
public $root = null;
|
||||
public $debug_tree = array();
|
||||
|
||||
public function Load($template)
|
||||
{
|
||||
global $template_cache;
|
||||
|
||||
if(isset($template_cache[$template]))
|
||||
{
|
||||
$tpl_contents = $template_cache[$template];
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl_contents = file_get_contents($this->basedir . $template . $this->extension);
|
||||
$template_cache[$template] = $tpl_contents;
|
||||
}
|
||||
|
||||
if($tpl_contents !== false)
|
||||
{
|
||||
$this->tpl = $tpl_contents;
|
||||
$this->tpl_rendered = $tpl_contents;
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("Failed to load template {$template}.");
|
||||
}
|
||||
}
|
||||
|
||||
public function Reset()
|
||||
{
|
||||
if(!is_null($this->tpl))
|
||||
{
|
||||
$this->tpl_rendered = $this->tpl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("No template loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
public function Localize($strings)
|
||||
{
|
||||
if(!is_null($this->tpl))
|
||||
{
|
||||
foreach($strings as $key => $str)
|
||||
{
|
||||
$this->tpl_rendered = str_replace("<%!{$key}>", $str, $this->tpl_rendered);
|
||||
$this->tpl_rendered = str_replace("{%!{$key}}", $str, $this->tpl_rendered);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("No template loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Legacy parser code */
|
||||
|
||||
public function Compile($strings)
|
||||
{
|
||||
global $template_global_vars;
|
||||
|
||||
if(!is_null($this->tpl))
|
||||
{
|
||||
$strings = array_merge($strings, $template_global_vars);
|
||||
|
||||
$this->tpl_rendered = $this->ParseForEach($this->tpl_rendered, $strings);
|
||||
$this->tpl_rendered = $this->ParseIf($this->tpl_rendered, $strings);
|
||||
|
||||
preg_match_all("/<%\?([a-zA-Z0-9_-]+)>/", $this->tpl_rendered, $strlist);
|
||||
foreach($strlist[1] as $str)
|
||||
{
|
||||
if(isset($strings[$str]))
|
||||
{
|
||||
$this->tpl_rendered = str_replace("<%?{$str}>", $strings[$str], $this->tpl_rendered);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("No template loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
public function ParseForEach($source, $data)
|
||||
{
|
||||
$templater = $this;
|
||||
|
||||
return preg_replace_callback("/<%foreach ([a-z0-9_-]+) in ([a-z0-9_-]+)>(.*?)<%\/foreach>/si", function($matches) use($data, $templater) {
|
||||
$variable_name = $matches[1];
|
||||
$array_name = $matches[2];
|
||||
$template = $matches[3];
|
||||
$returnvalue = "";
|
||||
|
||||
if(isset($data[$array_name]))
|
||||
{
|
||||
foreach($data[$array_name] as $item)
|
||||
{
|
||||
$rendered = $template;
|
||||
|
||||
$rendered = $templater->ParseIf($rendered, $data, $item, $variable_name);
|
||||
|
||||
foreach($item as $key => $value)
|
||||
{
|
||||
$rendered = str_replace("<%?{$variable_name}[{$key}]>", $value, $rendered);
|
||||
}
|
||||
|
||||
$returnvalue .= $rendered;
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, $source);
|
||||
}
|
||||
|
||||
public function ParseIf($source, $data, $context = null, $identifier = "")
|
||||
{
|
||||
return preg_replace_callback("/<%if ([][a-z0-9_-]+) (=|==|>|<|>=|<=|!=) ([^>]+)>(.*?)<%\/if>/si", function($matches) use($data, $context, $identifier) {
|
||||
$variable_name = $matches[1];
|
||||
$operator = $matches[2];
|
||||
$value = $matches[3];
|
||||
$template = $matches[4];
|
||||
|
||||
if(!empty($identifier))
|
||||
{
|
||||
if(preg_match("/{$identifier}\[([a-z0-9_-]+)\]/i", $variable_name, $submatches))
|
||||
{
|
||||
// Local variable.
|
||||
$name = $submatches[1];
|
||||
|
||||
if(isset($context[$name]))
|
||||
{
|
||||
$variable = $context[$name];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif(preg_match("/[a-z0-9_-]+\[[a-z0-9_-]+\]/i", $variable_name))
|
||||
{
|
||||
// Not the right scope.
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Global variable.
|
||||
if(isset($data[$variable_name]))
|
||||
{
|
||||
$variable = $data[$variable_name];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($data[$variable_name]))
|
||||
{
|
||||
$variable = $data[$variable_name];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($variable === "true") { $variable = true; }
|
||||
if($variable === "false") { $variable = false; }
|
||||
if(is_numeric($variable)) { $variable = (int)$variable; }
|
||||
if($value === "true") { $value = true; }
|
||||
if($value === "false") { $value = false; }
|
||||
if(is_numeric($value)) { $value = (int)$value; }
|
||||
|
||||
switch($operator)
|
||||
{
|
||||
case "=":
|
||||
case "==":
|
||||
$display = ($variable == $value);
|
||||
break;
|
||||
case ">":
|
||||
$display = ($variable > $value);
|
||||
break;
|
||||
case "<":
|
||||
$display = ($variable < $value);
|
||||
break;
|
||||
case ">=":
|
||||
$display = ($variable >= $value);
|
||||
break;
|
||||
case "<=":
|
||||
$display = ($variable <= $value);
|
||||
break;
|
||||
case "!=":
|
||||
$display = ($variable != $value);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if($display === true)
|
||||
{
|
||||
return $template;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return false;
|
||||
}, $source);
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
if(!is_null($this->tpl))
|
||||
{
|
||||
return $this->tpl_rendered;
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("No template loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
public function Output()
|
||||
{
|
||||
if(!is_null($this->tpl))
|
||||
{
|
||||
echo($this->tpl_rendered);
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw new Exception("No template loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
public static function InlineRender($templatename, $localize = array(), $compile = array())
|
||||
{
|
||||
$template = new Templater();
|
||||
$template->Load($templatename);
|
||||
$template->Localize($localize);
|
||||
$template->Compile($compile);
|
||||
return $template->Render();
|
||||
}
|
||||
|
||||
/* New parser code */
|
||||
|
||||
public static function AdvancedParse($templatename, $localize = array(), $compile = array())
|
||||
{
|
||||
$template = new Templater();
|
||||
$template->templatename = $template->basedir . $templatename . $template->extension;;
|
||||
$template->Load($templatename);
|
||||
$template->Localize($localize);
|
||||
return $template->Parse($compile);
|
||||
}
|
||||
|
||||
public function Parse($data)
|
||||
{
|
||||
global $template_global_vars;
|
||||
|
||||
$tree = $this->BuildSyntaxTree();
|
||||
$data = array_merge($data, $template_global_vars);
|
||||
return $this->root->Evaluate($data);
|
||||
}
|
||||
|
||||
public function BuildSyntaxTree()
|
||||
{
|
||||
$content = $this->tpl_rendered;
|
||||
$length = strlen($content);
|
||||
$offset = 0;
|
||||
$depth = 1;
|
||||
$current_tag = array();
|
||||
$current_element = array();
|
||||
$current_text_element = null;
|
||||
$debug_tree = array();
|
||||
$root = array();
|
||||
$tag_start = 0;
|
||||
$tag_end = 0;
|
||||
$text_block = "";
|
||||
|
||||
$switch = CPHP_TEMPLATER_SWITCH_NONE;
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_NONE;
|
||||
|
||||
$current_element[0] = new TemplateRootElement();
|
||||
|
||||
while($offset < $length)
|
||||
{
|
||||
$char = $content[$offset];
|
||||
|
||||
if($char == "{" && $switch == CPHP_TEMPLATER_SWITCH_NONE)
|
||||
{
|
||||
$switch = CPHP_TEMPLATER_SWITCH_TAG_OPEN;
|
||||
$tag_start = $offset;
|
||||
}
|
||||
elseif($char == "%" && $switch == CPHP_TEMPLATER_SWITCH_TAG_OPEN)
|
||||
{
|
||||
if($text_block != "")
|
||||
{
|
||||
$current_text_element->text = $text_block;
|
||||
$text_block = "";
|
||||
|
||||
$current_element[$depth - 1]->children[] = $current_text_element;
|
||||
}
|
||||
|
||||
// Look ahead to see whether this is going to be a variable or a logic element
|
||||
if($content[$offset + 1] == "?")
|
||||
{
|
||||
$switch = CPHP_TEMPLATER_SWITCH_TAG_VARNAME;
|
||||
$name = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$switch = CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER;
|
||||
$identifier = "";
|
||||
}
|
||||
}
|
||||
elseif($char != "%" && $switch == CPHP_TEMPLATER_SWITCH_TAG_OPEN)
|
||||
{
|
||||
// Not a templater tag, abort.
|
||||
$switch = CPHP_TEMPLATER_SWITCH_NONE;
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_NONE;
|
||||
$text_block .= "{";
|
||||
}
|
||||
elseif($switch == CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER && $type == CPHP_TEMPLATER_TYPE_TAG_NONE)
|
||||
{
|
||||
if($char == "/")
|
||||
{
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_CLOSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_OPEN;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(($char != " " && $switch == CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER && $type == CPHP_TEMPLATER_TYPE_TAG_OPEN) ||
|
||||
($char != "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER && $type == CPHP_TEMPLATER_TYPE_TAG_CLOSE))
|
||||
{
|
||||
$identifier .= $char;
|
||||
}
|
||||
elseif($char != "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_VARNAME)
|
||||
{
|
||||
if($char != "?" || $name != "")
|
||||
$name .= $char;
|
||||
}
|
||||
elseif($char == " " && $switch == CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER && $type == CPHP_TEMPLATER_TYPE_TAG_OPEN)
|
||||
{
|
||||
$switch = CPHP_TEMPLATER_SWITCH_TAG_STATEMENT;
|
||||
$statement = "";
|
||||
}
|
||||
elseif($char != "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_STATEMENT)
|
||||
{
|
||||
$statement .= $char;
|
||||
}
|
||||
elseif(($char == "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_STATEMENT && $type == CPHP_TEMPLATER_TYPE_TAG_OPEN) ||
|
||||
($char == "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_IDENTIFIER && $type == CPHP_TEMPLATER_TYPE_TAG_CLOSE))
|
||||
{
|
||||
$tag_end = $offset + 1;
|
||||
|
||||
if($type == CPHP_TEMPLATER_TYPE_TAG_OPEN)
|
||||
{
|
||||
// This was an opening tag.
|
||||
$debug_tree[] = "[{$depth}]" . str_repeat(" ", $depth) . "{$identifier} {$statement}";
|
||||
$child = $this->CreateSyntaxElement($identifier, $statement, $offset + 1);
|
||||
$current_element[$depth] = $child;
|
||||
|
||||
if(isset($current_element[$depth - 1]) && !is_null($current_element[$depth - 1]))
|
||||
{
|
||||
$child->parent = $current_element[$depth - 1];
|
||||
$child->parent->children[] = $current_element[$depth];
|
||||
}
|
||||
|
||||
$current_tag[$depth] = $identifier;
|
||||
|
||||
$depth += 1;
|
||||
}
|
||||
elseif($type == CPHP_TEMPLATER_TYPE_TAG_CLOSE)
|
||||
{
|
||||
// This was a closing tag.
|
||||
$depth -= 1;
|
||||
|
||||
if($identifier == $current_tag[$depth])
|
||||
{
|
||||
$debug_tree[] = "[{$depth}]" . str_repeat(" ", $depth) . "/{$identifier}";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TemplateSyntaxException("Closing tag does not match opening tag (".$current_tag[$depth]." vs. {$identifier}) at position {$tag_start}.", $this->templatename, $tag_start, $tag_end);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TemplateParsingException("The type of tag could not be determined.", $this->templatename, $tag_start, $tag_end);
|
||||
}
|
||||
|
||||
$switch = CPHP_TEMPLATER_SWITCH_NONE;
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_NONE;
|
||||
$identifier = "";
|
||||
$statement = "";
|
||||
}
|
||||
elseif($char == "}" && $switch == CPHP_TEMPLATER_SWITCH_TAG_VARNAME)
|
||||
{
|
||||
$debug_tree[] = "[{$depth}]" . str_repeat(" ", $depth) . "var {$name}";
|
||||
|
||||
$child = $this->CreateSyntaxElement("variable", $name);
|
||||
|
||||
if(isset($current_element[$depth - 1]) && !is_null($current_element[$depth - 1]))
|
||||
{
|
||||
$child->parent = $current_element[$depth - 1];
|
||||
$child->parent->children[] = $child;
|
||||
}
|
||||
|
||||
$switch = CPHP_TEMPLATER_SWITCH_NONE;
|
||||
$type = CPHP_TEMPLATER_TYPE_TAG_NONE;
|
||||
$name = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if($text_block == "")
|
||||
{
|
||||
$current_text_element = $this->CreateSyntaxElement("text", "", $offset);
|
||||
}
|
||||
|
||||
$text_block .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
$offset += 1;
|
||||
}
|
||||
|
||||
if($text_block != "")
|
||||
{
|
||||
$current_text_element->text = $text_block;
|
||||
$text_block = "";
|
||||
|
||||
$current_element[0]->children[] = $current_text_element;
|
||||
}
|
||||
|
||||
$this->root = $current_element[0];
|
||||
$this->debug_tree = $debug_tree;
|
||||
}
|
||||
|
||||
function CreateSyntaxElement($identifier, $statement)
|
||||
{
|
||||
if($identifier == "if")
|
||||
{
|
||||
$element = new TemplateIfElement;
|
||||
}
|
||||
elseif($identifier == "foreach")
|
||||
{
|
||||
$element = new TemplateForEachElement;
|
||||
}
|
||||
elseif($identifier == "text")
|
||||
{
|
||||
$element = new TemplateTextElement;
|
||||
}
|
||||
elseif($identifier == "variable")
|
||||
{
|
||||
$element = new TemplateVariableElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
$element = new TemplateRootElement;
|
||||
}
|
||||
|
||||
if($identifier == "if" || $identifier == "foreach")
|
||||
{
|
||||
$element->statement = $statement;
|
||||
}
|
||||
|
||||
if($identifier == "if")
|
||||
{
|
||||
$statement_parts = explode(" ", $statement, 3);
|
||||
$element->left = $statement_parts[0];
|
||||
$element->operator = $statement_parts[1];
|
||||
$element->right = $statement_parts[2];
|
||||
}
|
||||
|
||||
if($identifier == "foreach")
|
||||
{
|
||||
$statement_parts = explode(" ", $statement, 3);
|
||||
$element->varname = $statement_parts[0];
|
||||
$element->source = $statement_parts[2];
|
||||
}
|
||||
|
||||
if($identifier == "variable")
|
||||
{
|
||||
$element->variable = $statement;
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
/* Syntax element definitions */
|
||||
|
||||
class TemplateSyntaxElement
|
||||
{
|
||||
public $parent = null;
|
||||
public $children = array();
|
||||
public $data = array();
|
||||
|
||||
public function Evaluate($data)
|
||||
{
|
||||
$result = "";
|
||||
|
||||
foreach($this->children as $child)
|
||||
{
|
||||
$result .= $child->Evaluate($data);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function FetchVariable($name, $data)
|
||||
{
|
||||
if(strpos($name, "[") === false)
|
||||
{
|
||||
return $data[$name];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Variable refers to a subset of the data, traverse up the tree to find the matching dataset
|
||||
$open_brace = strpos($name, "[");
|
||||
$closing_brace = strpos($name, "]");
|
||||
|
||||
$source = substr($name, 0, $open_brace);
|
||||
$item = substr($name, $open_brace + 1, ($closing_brace - $open_brace - 1));
|
||||
|
||||
$current_element = $this;
|
||||
|
||||
while(!is_null($current_element))
|
||||
{
|
||||
$current_element = $current_element->parent;
|
||||
|
||||
if(isset($current_element->varname))
|
||||
{
|
||||
if($current_element->varname == $source)
|
||||
{
|
||||
if(isset($current_element->data[$item]))
|
||||
{
|
||||
return $current_element->data[$item];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateRootElement extends TemplateSyntaxElement {}
|
||||
|
||||
class TemplateVariableElement extends TemplateSyntaxElement
|
||||
{
|
||||
public $variable = "";
|
||||
|
||||
public function Evaluate($data)
|
||||
{
|
||||
return $this->FetchVariable($this->variable, $data);
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateTextElement extends TemplateSyntaxElement
|
||||
{
|
||||
public $text = "";
|
||||
|
||||
public function Evaluate($data)
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateIfElement extends TemplateSyntaxElement
|
||||
{
|
||||
public $statement = "";
|
||||
public $left = "";
|
||||
public $right = "";
|
||||
public $operator = "";
|
||||
|
||||
public function Evaluate($data)
|
||||
{
|
||||
$a = $this->FetchVariable($this->left, $data);
|
||||
$b = $this->right;
|
||||
|
||||
switch($this->operator)
|
||||
{
|
||||
case "=":
|
||||
case "==":
|
||||
$result = ($a == $b);
|
||||
break;
|
||||
case ">":
|
||||
$result = ($a > $b);
|
||||
break;
|
||||
case "<":
|
||||
$result = ($a < $b);
|
||||
break;
|
||||
case ">=":
|
||||
$result = ($a >= $b);
|
||||
break;
|
||||
case "<=":
|
||||
$result = ($a <= $b);
|
||||
break;
|
||||
case "!=":
|
||||
$result = ($a != $b);
|
||||
break;
|
||||
default:
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if($result == true)
|
||||
{
|
||||
return parent::Evaluate($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateForEachElement extends TemplateSyntaxElement
|
||||
{
|
||||
public $statement = "";
|
||||
public $source = "";
|
||||
public $varname = "";
|
||||
public $block = "";
|
||||
public $data = array();
|
||||
|
||||
public function Evaluate($data)
|
||||
{
|
||||
$target = $this->FetchVariable($this->source, $data);
|
||||
|
||||
$result = "";
|
||||
|
||||
foreach($target as $iteration)
|
||||
{
|
||||
$this->data = $iteration;
|
||||
|
||||
foreach($this->children as $child)
|
||||
{
|
||||
$result .= $child->Evaluate($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
cphp_dependency_provides("cphp_errorhandler", "0.1");
|
||||
|
||||
define("CPHP_ERRORHANDLER_TYPE_ERROR", 90001 );
|
||||
define("CPHP_ERRORHANDLER_TYPE_INFO", 90002 );
|
||||
define("CPHP_ERRORHANDLER_TYPE_WARNING", 90003 );
|
||||
define("CPHP_ERRORHANDLER_TYPE_SUCCESS", 90004 );
|
||||
|
||||
class CPHPErrorHandler
|
||||
{
|
||||
public $sErrorType = CPHP_ERRORHANDLER_TYPE_ERROR;
|
||||
public $sLogError = true;
|
||||
public $sTitle = "";
|
||||
public $sMessage = "";
|
||||
|
||||
public function __construct($type, $title, $message, $log = true)
|
||||
{
|
||||
$this->sErrorType = $type;
|
||||
$this->sLogError = $log;
|
||||
$this->sTitle = $title;
|
||||
$this->sMessage = $message;
|
||||
}
|
||||
|
||||
public function LogError($context, $message)
|
||||
{
|
||||
// FIXME placeholder function, error logging has not been implemented yet
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
global $locale;
|
||||
|
||||
switch($this->sErrorType)
|
||||
{
|
||||
case CPHP_ERRORHANDLER_TYPE_ERROR:
|
||||
$template = "errorhandler.error";
|
||||
break;
|
||||
case CPHP_ERRORHANDLER_TYPE_INFO:
|
||||
$template = "errorhandler.info";
|
||||
break;
|
||||
case CPHP_ERRORHANDLER_TYPE_WARNING:
|
||||
$template = "errorhandler.warning";
|
||||
break;
|
||||
case CPHP_ERRORHANDLER_TYPE_SUCCESS:
|
||||
$template = "errorhandler.success";
|
||||
break;
|
||||
}
|
||||
|
||||
return Templater::AdvancedParse($template, $locale->strings, array(
|
||||
'title' => $this->sTitle,
|
||||
'message' => $this->sMessage
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,319 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
cphp_dependency_provides("cphp_formbuilder", "1.0");
|
||||
|
||||
$cphp_formbuilder_increment = 0;
|
||||
|
||||
abstract class CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $parameters = array();
|
||||
|
||||
public function AddParameter($key, $value)
|
||||
{
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
|
||||
public function RenderParameters($parameters)
|
||||
{
|
||||
if(empty($parameters))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$rendered = array();
|
||||
|
||||
foreach($parameters as $key => $value)
|
||||
{
|
||||
$value = utf8entities($value);
|
||||
$rendered[] = "{$key}=\"{$value}\"";
|
||||
}
|
||||
|
||||
return " " . implode(" ", $rendered);
|
||||
}
|
||||
|
||||
public function RenderNote()
|
||||
{
|
||||
if(!empty($this->note))
|
||||
{
|
||||
return "<div class=\"cphp_fbd_note\">{$this->note}</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CPHPFormBuilderContainer extends CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $elements = array();
|
||||
|
||||
public function AddElement($element)
|
||||
{
|
||||
$this->elements[] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormBuilder extends CPHPFormBuilderContainer
|
||||
{
|
||||
public $method = "";
|
||||
public $action = "";
|
||||
|
||||
public function __construct($method, $target)
|
||||
{
|
||||
$this->method = strtolower($method);
|
||||
$this->action = $target;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
$this->AddParameter("method", $this->method);
|
||||
$this->AddParameter("action", $this->action);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
|
||||
return "<form{$rendered_parameters}>{$rendered_elements}</form>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormSection extends CPHPFormBuilderContainer
|
||||
{
|
||||
public $label = "";
|
||||
public $fieldset = true;
|
||||
public $classname = "";
|
||||
|
||||
public function __construct($fieldset = true, $label = "")
|
||||
{
|
||||
if(!empty($label))
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
$this->fieldset = $fieldset;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
if(!empty($this->label))
|
||||
{
|
||||
$legend = "<legend>{$this->label}</legend>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$legend = "";
|
||||
}
|
||||
|
||||
if($this->fieldset === true)
|
||||
{
|
||||
$this->classname = trim("{$this->classname} cphp_fbd_fieldset");
|
||||
}
|
||||
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
if($this->fieldset === true)
|
||||
{
|
||||
$this->AddParameter("class", $this->classname);
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
return "<fieldset{$rendered_parameters}>{$legend}<div class=\"cphp_fbd_form\">{$rendered_elements}</div></fieldset>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<div class=\"cphp_fbd_form\"{$rendered_parameters}>{$rendered_elements}</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CPHPFormInputElement extends CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $id = "";
|
||||
public $name = "";
|
||||
public $value = "";
|
||||
public $label = "";
|
||||
|
||||
public function __construct($label, $name, $value = "", $note = "", $id = "")
|
||||
{
|
||||
global $cphp_formbuilder_increment;
|
||||
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
$this->label = $label;
|
||||
$this->note = $note;
|
||||
|
||||
if(empty($id))
|
||||
{
|
||||
$this->id = "cphp_fbd_{$cphp_formbuilder_increment}";
|
||||
$cphp_formbuilder_increment += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class CPHPFormInput extends CPHPFormInputElement
|
||||
{
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("id", $this->id);
|
||||
$this->AddParameter("type", $this->type);
|
||||
$this->AddParameter("name", $this->name);
|
||||
$this->AddParameter("value", $this->value);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
$rendered_note = $this->RenderNote();
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\">{$this->label}{$rendered_note}</div><div class=\"cphp_fbd_field\"><input{$rendered_parameters}></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormTextInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "text";
|
||||
}
|
||||
|
||||
class CPHPFormPasswordInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "password";
|
||||
}
|
||||
|
||||
class CPHPFormDateInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "date";
|
||||
}
|
||||
|
||||
class CPHPFormTimeInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "time";
|
||||
}
|
||||
|
||||
class CPHPFormEmailInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "email";
|
||||
}
|
||||
|
||||
class CPHPFormUrlInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "url";
|
||||
}
|
||||
|
||||
class CPHPFormRangeInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "range";
|
||||
}
|
||||
|
||||
class CPHPFormColorInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "color";
|
||||
}
|
||||
|
||||
class CPHPFormSearchInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "search";
|
||||
}
|
||||
|
||||
class CPHPFormCheckboxGroup extends CPHPFormBuilderContainer
|
||||
{
|
||||
public function __construct($label, $note = "")
|
||||
{
|
||||
global $cphp_formbuilder_increment;
|
||||
|
||||
$this->label = $label;
|
||||
$this->note = $note;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$rendered_note = $this->RenderNote();
|
||||
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\">{$this->label}{$rendered_note}</div><div class=\"cphp_fbd_field\">{$rendered_elements}</div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormCheckbox extends CPHPFormInputElement
|
||||
{
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("id", $this->id);
|
||||
$this->AddParameter("type", "checkbox");
|
||||
$this->AddParameter("name", $this->name);
|
||||
|
||||
if($this->value === true)
|
||||
{
|
||||
$this->AddParameter("checked", "");
|
||||
}
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
$rendered_note = $this->RenderNote();
|
||||
return "<div class=\"cphp_fbd_cblabel\"><input{$rendered_parameters}><label for=\"{$this->id}\">{$this->label}{$rendered_note}</label></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormRadioButton extends CPHPFormInput
|
||||
{
|
||||
public $type = "radio";
|
||||
}
|
||||
|
||||
class CPHPFormButton extends CPHPFormInputElement
|
||||
{
|
||||
public $type = "button";
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("type", $this->type);
|
||||
$this->AddParameter("name", $this->name);
|
||||
$this->AddParameter("value", $this->value);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\"></div><div class=\"cphp_fbd_field\"><button{$rendered_parameters}>{$this->label}</button></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormSubmitButton extends CPHPFormButton
|
||||
{
|
||||
public $type = "submit";
|
||||
}
|
||||
|
||||
class CPHPFormResetButton extends CPHPFormButton
|
||||
{
|
||||
public $type = "reset";
|
||||
}
|
||||
|
||||
class CPHPFormSelect extends CPHPFormInputElement
|
||||
{
|
||||
public $options = array();
|
||||
}
|
||||
?>
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
cphp_dependency_provides("cphp_router", "1.1");
|
||||
|
||||
class CPHPRouter extends CPHPBaseClass
|
||||
{
|
||||
public $routes = array();
|
||||
public $parameters = array();
|
||||
public $custom_query = "";
|
||||
public $allow_slash = false;
|
||||
public $ignore_query = false;
|
||||
|
||||
public function RouteRequest()
|
||||
{
|
||||
eval(extract_globals()); // hack hackity hack hack
|
||||
|
||||
if(!empty($this->custom_query))
|
||||
{
|
||||
$requestpath = $this->custom_query;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!empty($_SERVER['REQUEST_URI']))
|
||||
{
|
||||
$requestpath = trim($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$requestpath = "/";
|
||||
}
|
||||
}
|
||||
|
||||
if($this->ignore_query === true)
|
||||
{
|
||||
if(strpos($requestpath, "?") !== false)
|
||||
{
|
||||
list($requestpath, $bogus) = explode("?", $requestpath, 2);
|
||||
}
|
||||
}
|
||||
|
||||
$found = false; // Workaround because a break after an include apparently doesn't work in PHP.
|
||||
|
||||
foreach($this->routes as $priority)
|
||||
{
|
||||
foreach($priority as $route_regex => $route_destination)
|
||||
{
|
||||
if($found === false)
|
||||
{
|
||||
if($this->allow_slash === true)
|
||||
{
|
||||
$route_regex = "{$route_regex}/?";
|
||||
}
|
||||
|
||||
$regex = str_replace("/", "\/", $route_regex);
|
||||
if(preg_match("/{$regex}/i", $requestpath, $matches))
|
||||
{
|
||||
$this->uParameters = $matches;
|
||||
include($route_destination);
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
$cphp_class_map = array(
|
||||
'user' => "User",
|
||||
'node' => "Node",
|
||||
'container' => "Container",
|
||||
'template' => "Template"
|
||||
);
|
||||
|
||||
$cphp_locale_name = "english";
|
||||
$cphp_locale_path = "locales";
|
||||
$cphp_locale_ext = "lng";
|
||||
|
||||
$cphp_usersettings[CPHP_SETTING_TIMEZONE] = "Europe/Amsterdam";
|
||||
|
||||
/* These are the memcache settings. You will need to have memcache set
|
||||
* up on your server to use these. Compression requires zlib. */
|
||||
$cphp_memcache_enabled = true; // Whether to user memcache.
|
||||
$cphp_memcache_server = "localhost"; // The hostname of the memcached
|
||||
$cphp_memcache_port = 11211; // The port number of memcached
|
||||
$cphp_memcache_compressed = true; // Whether to compress memcache objects
|
||||
|
||||
$cphp_mysql_enabled = true;
|
||||
|
||||
require("config.mysql.php");
|
||||
|
||||
/* Please create a new file in this directory named config.mysql.php
|
||||
* that holds the following contents (modified to the correct settings):
|
||||
|
||||
$cphp_mysql_host = "localhost";
|
||||
$cphp_mysql_user = "username";
|
||||
$cphp_mysql_pass = "password";
|
||||
$cphp_mysql_db = "database";
|
||||
|
||||
*/
|
||||
|
||||
$cphp_components = array(
|
||||
"router",
|
||||
"errorhandler"
|
||||
);
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
define("CPHP_SETTING_TIMEZONE", 1100 );
|
||||
|
||||
define("CPHP_VARIABLE_SAFE", 1260 );
|
||||
define("CPHP_VARIABLE_UNSAFE", 1261 );
|
||||
|
||||
define("CPHP_INSERTMODE_INSERT", 1270 );
|
||||
define("CPHP_INSERTMODE_UPDATE", 1271 );
|
||||
|
||||
define("CPHP_REGEX_EMAIL", "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i");
|
@ -1,180 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
$timezones = array(
|
||||
'Pacific/Kwajalein' => '(GMT-12:00) International Date Line West',
|
||||
'Pacific/Midway' => '(GMT-11:00) Midway Island',
|
||||
'Pacific/Samoa' => '(GMT-11:00) Samoa',
|
||||
'Pacific/Honolulu' => '(GMT-10:00) Hawaii',
|
||||
'America/Anchorage' => '(GMT-09:00) Alaska',
|
||||
'America/Los_Angeles' => '(GMT-08:00) Pacific Time (US & Canada)',
|
||||
'America/Tijuana' => '(GMT-08:00) Tijuana, Baja California',
|
||||
'America/Denver' => '(GMT-07:00) Mountain Time (US & Canada)',
|
||||
'America/Chihuahua' => '(GMT-07:00) Chihuahua',
|
||||
'America/Mazatlan' => '(GMT-07:00) Mazatlan',
|
||||
'America/Phoenix' => '(GMT-07:00) Arizona',
|
||||
'America/Regina' => '(GMT-06:00) Saskatchewan',
|
||||
'America/Tegucigalpa' => '(GMT-06:00) Central America',
|
||||
'America/Chicago' => '(GMT-06:00) Central Time (US & Canada)',
|
||||
'America/Mexico_City' => '(GMT-06:00) Mexico City',
|
||||
'America/Monterrey' => '(GMT-06:00) Monterrey',
|
||||
'America/New_York' => '(GMT-05:00) Eastern Time (US & Canada)',
|
||||
'America/Bogota' => '(GMT-05:00) Bogota',
|
||||
'America/Lima' => '(GMT-05:00) Lima',
|
||||
'America/Rio_Branco' => '(GMT-05:00) Rio Branco',
|
||||
'America/Indiana/Indianapolis' => '(GMT-05:00) Indiana (East)',
|
||||
'America/Caracas' => '(GMT-04:30) Caracas',
|
||||
'America/Halifax' => '(GMT-04:00) Atlantic Time (Canada)',
|
||||
'America/Manaus' => '(GMT-04:00) Manaus',
|
||||
'America/Santiago' => '(GMT-04:00) Santiago',
|
||||
'America/La_Paz' => '(GMT-04:00) La Paz',
|
||||
'America/St_Johns' => '(GMT-03:30) Newfoundland',
|
||||
'America/Argentina/Buenos_Aires' => '(GMT-03:00) Georgetown',
|
||||
'America/Sao_Paulo' => '(GMT-03:00) Brasilia',
|
||||
'America/Godthab' => '(GMT-03:00) Greenland',
|
||||
'America/Montevideo' => '(GMT-03:00) Montevideo',
|
||||
'Atlantic/South_Georgia' => '(GMT-02:00) Mid-Atlantic',
|
||||
'Atlantic/Azores' => '(GMT-01:00) Azores',
|
||||
'Atlantic/Cape_Verde' => '(GMT-01:00) Cape Verde Is.',
|
||||
'Europe/Dublin' => '(GMT) Dublin',
|
||||
'Europe/Lisbon' => '(GMT) Lisbon',
|
||||
'Europe/London' => '(GMT) London',
|
||||
'Africa/Monrovia' => '(GMT) Monrovia',
|
||||
'Atlantic/Reykjavik' => '(GMT) Reykjavik',
|
||||
'Africa/Casablanca' => '(GMT) Casablanca',
|
||||
'Europe/Belgrade' => '(GMT+01:00) Belgrade',
|
||||
'Europe/Bratislava' => '(GMT+01:00) Bratislava',
|
||||
'Europe/Budapest' => '(GMT+01:00) Budapest',
|
||||
'Europe/Ljubljana' => '(GMT+01:00) Ljubljana',
|
||||
'Europe/Prague' => '(GMT+01:00) Prague',
|
||||
'Europe/Sarajevo' => '(GMT+01:00) Sarajevo',
|
||||
'Europe/Skopje' => '(GMT+01:00) Skopje',
|
||||
'Europe/Warsaw' => '(GMT+01:00) Warsaw',
|
||||
'Europe/Zagreb' => '(GMT+01:00) Zagreb',
|
||||
'Europe/Brussels' => '(GMT+01:00) Brussels',
|
||||
'Europe/Copenhagen' => '(GMT+01:00) Copenhagen',
|
||||
'Europe/Madrid' => '(GMT+01:00) Madrid',
|
||||
'Europe/Paris' => '(GMT+01:00) Paris',
|
||||
'Africa/Algiers' => '(GMT+01:00) West Central Africa',
|
||||
'Europe/Amsterdam' => '(GMT+01:00) Amsterdam',
|
||||
'Europe/Berlin' => '(GMT+01:00) Berlin',
|
||||
'Europe/Rome' => '(GMT+01:00) Rome',
|
||||
'Europe/Stockholm' => '(GMT+01:00) Stockholm',
|
||||
'Europe/Vienna' => '(GMT+01:00) Vienna',
|
||||
'Europe/Minsk' => '(GMT+02:00) Minsk',
|
||||
'Africa/Cairo' => '(GMT+02:00) Cairo',
|
||||
'Europe/Helsinki' => '(GMT+02:00) Helsinki',
|
||||
'Europe/Riga' => '(GMT+02:00) Riga',
|
||||
'Europe/Sofia' => '(GMT+02:00) Sofia',
|
||||
'Europe/Tallinn' => '(GMT+02:00) Tallinn',
|
||||
'Europe/Vilnius' => '(GMT+02:00) Vilnius',
|
||||
'Europe/Athens' => '(GMT+02:00) Athens',
|
||||
'Europe/Bucharest' => '(GMT+02:00) Bucharest',
|
||||
'Europe/Istanbul' => '(GMT+02:00) Istanbul',
|
||||
'Asia/Jerusalem' => '(GMT+02:00) Jerusalem',
|
||||
'Asia/Amman' => '(GMT+02:00) Amman',
|
||||
'Asia/Beirut' => '(GMT+02:00) Beirut',
|
||||
'Africa/Windhoek' => '(GMT+02:00) Windhoek',
|
||||
'Africa/Harare' => '(GMT+02:00) Harare',
|
||||
'Asia/Kuwait' => '(GMT+03:00) Kuwait',
|
||||
'Asia/Riyadh' => '(GMT+03:00) Riyadh',
|
||||
'Asia/Baghdad' => '(GMT+03:00) Baghdad',
|
||||
'Africa/Nairobi' => '(GMT+03:00) Nairobi',
|
||||
'Asia/Tbilisi' => '(GMT+03:00) Tbilisi',
|
||||
'Europe/Moscow' => '(GMT+03:00) Moscow',
|
||||
'Europe/Volgograd' => '(GMT+03:00) Volgograd',
|
||||
'Asia/Tehran' => '(GMT+03:30) Tehran',
|
||||
'Asia/Muscat' => '(GMT+04:00) Muscat',
|
||||
'Asia/Baku' => '(GMT+04:00) Baku',
|
||||
'Asia/Yerevan' => '(GMT+04:00) Yerevan',
|
||||
'Asia/Yekaterinburg' => '(GMT+05:00) Ekaterinburg',
|
||||
'Asia/Karachi' => '(GMT+05:00) Karachi',
|
||||
'Asia/Tashkent' => '(GMT+05:00) Tashkent',
|
||||
'Asia/Kolkata' => '(GMT+05:30) Calcutta',
|
||||
'Asia/Colombo' => '(GMT+05:30) Sri Jayawardenepura',
|
||||
'Asia/Katmandu' => '(GMT+05:45) Kathmandu',
|
||||
'Asia/Dhaka' => '(GMT+06:00) Dhaka',
|
||||
'Asia/Almaty' => '(GMT+06:00) Almaty',
|
||||
'Asia/Novosibirsk' => '(GMT+06:00) Novosibirsk',
|
||||
'Asia/Rangoon' => '(GMT+06:30) Yangon (Rangoon)',
|
||||
'Asia/Krasnoyarsk' => '(GMT+07:00) Krasnoyarsk',
|
||||
'Asia/Bangkok' => '(GMT+07:00) Bangkok',
|
||||
'Asia/Jakarta' => '(GMT+07:00) Jakarta',
|
||||
'Asia/Brunei' => '(GMT+08:00) Beijing',
|
||||
'Asia/Chongqing' => '(GMT+08:00) Chongqing',
|
||||
'Asia/Hong_Kong' => '(GMT+08:00) Hong Kong',
|
||||
'Asia/Urumqi' => '(GMT+08:00) Urumqi',
|
||||
'Asia/Irkutsk' => '(GMT+08:00) Irkutsk',
|
||||
'Asia/Ulaanbaatar' => '(GMT+08:00) Ulaan Bataar',
|
||||
'Asia/Kuala_Lumpur' => '(GMT+08:00) Kuala Lumpur',
|
||||
'Asia/Singapore' => '(GMT+08:00) Singapore',
|
||||
'Asia/Taipei' => '(GMT+08:00) Taipei',
|
||||
'Australia/Perth' => '(GMT+08:00) Perth',
|
||||
'Asia/Seoul' => '(GMT+09:00) Seoul',
|
||||
'Asia/Tokyo' => '(GMT+09:00) Tokyo',
|
||||
'Asia/Yakutsk' => '(GMT+09:00) Yakutsk',
|
||||
'Australia/Darwin' => '(GMT+09:30) Darwin',
|
||||
'Australia/Adelaide' => '(GMT+09:30) Adelaide',
|
||||
'Australia/Canberra' => '(GMT+10:00) Canberra',
|
||||
'Australia/Melbourne' => '(GMT+10:00) Melbourne',
|
||||
'Australia/Sydney' => '(GMT+10:00) Sydney',
|
||||
'Australia/Brisbane' => '(GMT+10:00) Brisbane',
|
||||
'Australia/Hobart' => '(GMT+10:00) Hobart',
|
||||
'Asia/Vladivostok' => '(GMT+10:00) Vladivostok',
|
||||
'Pacific/Guam' => '(GMT+10:00) Guam',
|
||||
'Pacific/Port_Moresby' => '(GMT+10:00) Port Moresby',
|
||||
'Asia/Magadan' => '(GMT+11:00) Magadan',
|
||||
'Pacific/Fiji' => '(GMT+12:00) Fiji',
|
||||
'Asia/Kamchatka' => '(GMT+12:00) Kamchatka',
|
||||
'Pacific/Auckland' => '(GMT+12:00) Auckland',
|
||||
'Pacific/Tongatapu' => '(GMT+13:00) Nukualofa'
|
||||
);
|
||||
|
||||
function unix_from_local($timestamp)
|
||||
{
|
||||
global $user_preferences;
|
||||
date_default_timezone_set($user_preferences[CPHP_SETTING_TIMEZONE]);
|
||||
return strtotime($timestamp);
|
||||
}
|
||||
|
||||
function unix_from_mysql($timestamp)
|
||||
{
|
||||
date_default_timezone_set("GMT");
|
||||
return strtotime($timestamp);
|
||||
}
|
||||
|
||||
function local_from_unix($timestamp, $format)
|
||||
{
|
||||
global $user_preferences;
|
||||
date_default_timezone_set($user_preferences[CPHP_SETTING_TIMEZONE]);
|
||||
return strftime($format, $timestamp);
|
||||
}
|
||||
|
||||
function gmt_from_unix($timestamp, $format)
|
||||
{
|
||||
date_default_timezone_set("GMT");
|
||||
return strftime($format, $timestamp);
|
||||
}
|
||||
|
||||
function mysql_from_unix($timestamp)
|
||||
{
|
||||
date_default_timezone_set("GMT");
|
||||
return date("Y-m-d H:i:s", $timestamp);
|
||||
}
|
||||
|
||||
function floor_to_day($timestamp)
|
||||
{
|
||||
return floor($timestamp / (60 * 60 * 24)) * (60 * 60 * 24);
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
$cphp_dependencies = array();
|
||||
$cphp_last_dependency = "";
|
||||
|
||||
function cphp_dependency_provides($component, $version)
|
||||
{
|
||||
global $cphp_dependencies, $cphp_last_dependency;
|
||||
$cphp_dependencies[$component] = $version;
|
||||
$cphp_last_dependency = $component;
|
||||
}
|
||||
|
||||
function cphp_dependency_requires($component, $version)
|
||||
{
|
||||
global $cphp_dependencies, $cphp_last_dependency;
|
||||
|
||||
if(!isset($cphp_dependencies[$component]))
|
||||
{
|
||||
die("The {$cphp_last_dependency} component requires the {$component} component to be loaded, but this is not the case.");
|
||||
}
|
||||
|
||||
$current_version = $cphp_dependencies[$component];
|
||||
|
||||
if(!cphp_dependency_match($current_version, $version))
|
||||
{
|
||||
die("The {$cphp_last_dependency} component requires the {$component} component with version {$version} to be loaded, but an incompatible version ({$current_version}) was found.");
|
||||
}
|
||||
}
|
||||
|
||||
function cphp_dependency_match($available, $required)
|
||||
{
|
||||
if(strpos($required, ",") !== false)
|
||||
{
|
||||
$ranges = explode(",", $required);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ranges[] = $version;
|
||||
}
|
||||
|
||||
foreach($ranges as $range)
|
||||
{
|
||||
if(strpos($required, "|") !== false)
|
||||
{
|
||||
list($min, $max) = explode("|", $range);
|
||||
|
||||
$f_min = (float) $min;
|
||||
$f_max = (float) $max;
|
||||
$f_cur = (float) $available;
|
||||
|
||||
if(empty($min) && empty($max))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
elseif(empty($min))
|
||||
{
|
||||
if($f_cur < $f_max)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif(empty($max))
|
||||
{
|
||||
if($f_cur > $f_min)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($f_cur > $f_min && $f_cur < $f_max)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
class OwnershipException extends Exception {}
|
||||
class UserAccessException extends Exception {}
|
||||
class NotFoundException extends Exception {}
|
||||
class PrototypeException extends Exception {}
|
||||
class ConstructorException extends Exception {}
|
||||
class MissingDataException extends Exception {}
|
||||
class DatabaseException extends Exception {}
|
||||
class TypeException extends Exception {}
|
||||
|
||||
class TemplateException extends Exception
|
||||
{
|
||||
public $message = "";
|
||||
public $file = "";
|
||||
public $startpos = 0;
|
||||
public $endpos = 0;
|
||||
public $code = 0;
|
||||
|
||||
public function __construct($message, $file, $startpos, $endpos, $code)
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->file = $file;
|
||||
$this->startpos = $startpos;
|
||||
$this->endpos = $endpos;
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateSyntaxException extends TemplateException {}
|
||||
class TemplateParsingException extends TemplateException {}
|
@ -1,156 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
if($cphp_memcache_enabled)
|
||||
{
|
||||
$memcache = new Memcache;
|
||||
$cphp_memcache_established = $memcache->connect($cphp_memcache_server, $cphp_memcache_port);
|
||||
|
||||
if($cphp_memcache_established !== false)
|
||||
{
|
||||
$cphp_memcache_connected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cphp_memcache_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
function mc_get($key)
|
||||
{
|
||||
global $cphp_memcache_enabled, $cphp_memcache_connected, $memcache;
|
||||
|
||||
if($cphp_memcache_enabled === false || $cphp_memcache_connected === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$get_result = $memcache->get($key);
|
||||
if($get_result !== false)
|
||||
{
|
||||
return $get_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mc_set($key, $value, $expiry)
|
||||
{
|
||||
global $cphp_memcache_enabled, $cphp_memcache_connected, $cphp_memcache_compressed, $memcache;
|
||||
|
||||
if($cphp_memcache_enabled === false || $cphp_memcache_connected === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($cphp_memcache_compressed === true)
|
||||
{
|
||||
$flag = MEMCACHE_COMPRESSED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$flag = false;
|
||||
}
|
||||
|
||||
$set_result = $memcache->set($key, $value, $flag, $expiry);
|
||||
return $set_result;
|
||||
}
|
||||
}
|
||||
|
||||
function mc_delete($key)
|
||||
{
|
||||
global $cphp_memcache_enabled, $cphp_memcache_connected, $memcache;
|
||||
|
||||
if($cphp_memcache_enabled === false || $cphp_memcache_connected === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $memcache->delete($key);
|
||||
}
|
||||
}
|
||||
|
||||
function mysql_query_cached($query, $expiry = 60, $key = "")
|
||||
{
|
||||
if($key == "")
|
||||
{
|
||||
$key = md5($query) . md5($query . "x");
|
||||
}
|
||||
|
||||
if($res = mc_get($key))
|
||||
{
|
||||
$return_object->source = "memcache";
|
||||
$return_object->data = $res;
|
||||
return $return_object;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($res = mysql_query($query))
|
||||
{
|
||||
$found = false;
|
||||
|
||||
while($row = mysql_fetch_assoc($res))
|
||||
{
|
||||
$return_object->data[] = $row;
|
||||
$found = true;
|
||||
}
|
||||
|
||||
if($found === true)
|
||||
{
|
||||
$return_object->source = "database";
|
||||
mc_set($key, $return_object->data, $expiry);
|
||||
return $return_object;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function file_get_contents_cached($path, $expiry = 3600)
|
||||
{
|
||||
if($res = mc_get(md5($path) . md5($path . "x")))
|
||||
{
|
||||
$return_object->source = "memcache";
|
||||
$return_object->data = $res;
|
||||
return $return_object;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($result = file_get_contents($path))
|
||||
{
|
||||
$return_object->source = "disk";
|
||||
$return_object->data = $result;
|
||||
mc_set(md5($path) . md5($path . "x"), $return_object->data, $expiry);
|
||||
return $return_object;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
function random_string($length)
|
||||
{
|
||||
$output = "";
|
||||
for ($i = 0; $i < $length; $i++)
|
||||
{
|
||||
$output .= substr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", mt_rand(0, 61), 1);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function extract_globals()
|
||||
{
|
||||
$vars = array();
|
||||
|
||||
foreach($GLOBALS as $key => $value){
|
||||
$vars[] = "$".$key;
|
||||
}
|
||||
|
||||
return "global " . join(",", $vars) . ";";
|
||||
}
|
||||
|
||||
function utf8entities($utf8)
|
||||
{
|
||||
// Credits to silverbeat@gmx.at (http://www.php.net/manual/en/function.htmlentities.php#96648)
|
||||
$encodeTags = true;
|
||||
$result = '';
|
||||
for ($i = 0; $i < strlen($utf8); $i++)
|
||||
{
|
||||
$char = $utf8[$i];
|
||||
$ascii = ord($char);
|
||||
if ($ascii < 128)
|
||||
{
|
||||
$result .= ($encodeTags) ? htmlentities($char) : $char;
|
||||
}
|
||||
else if ($ascii < 192)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
else if ($ascii < 224)
|
||||
{
|
||||
$result .= htmlentities(substr($utf8, $i, 2), ENT_QUOTES, 'UTF-8');
|
||||
$i++;
|
||||
}
|
||||
else if ($ascii < 240)
|
||||
{
|
||||
$ascii1 = ord($utf8[$i+1]);
|
||||
$ascii2 = ord($utf8[$i+2]);
|
||||
$unicode = (15 & $ascii) * 4096 +
|
||||
(63 & $ascii1) * 64 +
|
||||
(63 & $ascii2);
|
||||
$result .= "&#$unicode;";
|
||||
$i += 2;
|
||||
}
|
||||
else if ($ascii < 248)
|
||||
{
|
||||
$ascii1 = ord($utf8[$i+1]);
|
||||
$ascii2 = ord($utf8[$i+2]);
|
||||
$ascii3 = ord($utf8[$i+3]);
|
||||
$unicode = (15 & $ascii) * 262144 +
|
||||
(63 & $ascii1) * 4096 +
|
||||
(63 & $ascii2) * 64 +
|
||||
(63 & $ascii3);
|
||||
$result .= "&#$unicode;";
|
||||
$i += 3;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function clean_array($arr)
|
||||
{
|
||||
$result = array();
|
||||
foreach($arr as $key => $value)
|
||||
{
|
||||
if(!empty($value))
|
||||
{
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function pretty_dump($input)
|
||||
{
|
||||
ob_start();
|
||||
|
||||
var_dump($input);
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
while(preg_match("/^[ ]*[ ]/m", $output) == 1)
|
||||
{
|
||||
$output = preg_replace("/^([ ]*)[ ]/m", "$1 ", $output);
|
||||
}
|
||||
|
||||
$output = nl2br($output);
|
||||
|
||||
echo($output);
|
||||
}
|
||||
|
||||
/*function is_empty($variable)
|
||||
{
|
||||
return (trim($variable) == "");
|
||||
}*/
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
$cphp_mysql_connected = false;
|
||||
|
||||
if($cphp_mysql_enabled === true)
|
||||
{
|
||||
if(mysql_connect($cphp_mysql_host, $cphp_mysql_user, $cphp_mysql_pass))
|
||||
{
|
||||
if(mysql_select_db($cphp_mysql_db))
|
||||
{
|
||||
$cphp_mysql_connected = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
session_start();
|
Loading…
Reference in New Issue