Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
4e1300631b
@ -131,10 +131,8 @@ class AdminPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function dbdump($page) {
|
private function dbdump($page) {
|
||||||
include "config.php";
|
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match("#(\w+)://(\w+):(\w+)@([\w\.\-]+)/([\w_]+)(\?.*)?#", $database_dsn, $matches);
|
preg_match("#(\w+)://(\w+):(\w+)@([\w\.\-]+)/([\w_]+)(\?.*)?#", DATABASE_DSN, $matches);
|
||||||
$software = $matches[1];
|
$software = $matches[1];
|
||||||
$username = $matches[2];
|
$username = $matches[2];
|
||||||
$password = $matches[3];
|
$password = $matches[3];
|
||||||
|
@ -23,7 +23,6 @@ class Emoticons extends FormatterExtension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new Emoticons());
|
|
||||||
|
|
||||||
class EmoticonList extends SimpleExtension {
|
class EmoticonList extends SimpleExtension {
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest($event) {
|
||||||
|
@ -41,6 +41,7 @@ class ET extends SimpleExtension {
|
|||||||
$info['sys_shimmie'] = VERSION;
|
$info['sys_shimmie'] = VERSION;
|
||||||
$info['sys_schema'] = $config->get_string("db_version");
|
$info['sys_schema'] = $config->get_string("db_version");
|
||||||
$info['sys_php'] = phpversion();
|
$info['sys_php'] = phpversion();
|
||||||
|
$info['sys_db'] = $database->db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||||
$info['sys_os'] = php_uname();
|
$info['sys_os'] = php_uname();
|
||||||
$info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " .
|
$info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " .
|
||||||
to_shorthand_int(disk_total_space("./"));
|
to_shorthand_int(disk_total_space("./"));
|
||||||
@ -56,8 +57,14 @@ class ET extends SimpleExtension {
|
|||||||
$info['stat_image_tags'] = $database->get_one("SELECT COUNT(*) FROM image_tags");
|
$info['stat_image_tags'] = $database->get_one("SELECT COUNT(*) FROM image_tags");
|
||||||
|
|
||||||
$els = array();
|
$els = array();
|
||||||
foreach($_event_listeners as $el) {
|
foreach(get_declared_classes() as $class) {
|
||||||
$els[] = get_class($el);
|
$rclass = new ReflectionClass($class);
|
||||||
|
if($rclass->isAbstract()) {
|
||||||
|
// don't do anything
|
||||||
|
}
|
||||||
|
elseif(is_subclass_of($class, "Extension")) {
|
||||||
|
$els[] = $class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$info['sys_extensions'] = join(', ', $els);
|
$info['sys_extensions'] = join(', ', $els);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ Shimmie: {$info['sys_shimmie']}
|
|||||||
Schema: {$info['sys_schema']}
|
Schema: {$info['sys_schema']}
|
||||||
PHP: {$info['sys_php']}
|
PHP: {$info['sys_php']}
|
||||||
OS: {$info['sys_os']}
|
OS: {$info['sys_os']}
|
||||||
|
Database: {$info['sys_db']}
|
||||||
Server: {$info['sys_server']}
|
Server: {$info['sys_server']}
|
||||||
Disk use: {$info['sys_disk']}
|
Disk use: {$info['sys_disk']}
|
||||||
|
|
||||||
|
@ -251,6 +251,18 @@ class Tag_History extends SimpleExtension {
|
|||||||
return ($row ? $row : array());
|
return ($row ? $row : array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This doesn't actually get _ALL_ IPs as it limits to 1000. */
|
||||||
|
public function get_all_user_ips()
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
$row = $database->get_all("
|
||||||
|
SELECT DISTINCT user_ip
|
||||||
|
FROM tag_histories
|
||||||
|
ORDER BY tag_histories.user_ip DESC
|
||||||
|
LIMIT 1000");
|
||||||
|
return ($row ? $row : array());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,7 @@ class Block {
|
|||||||
*/
|
*/
|
||||||
var $position;
|
var $position;
|
||||||
|
|
||||||
public function __construct($header, $body, $section="main", $position=50) {
|
public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50) {
|
||||||
$this->header = $header;
|
$this->header = $header;
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
$this->section = $section;
|
$this->section = $section;
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Functions which are only in some versions of PHP,
|
|
||||||
* or only implemented on some platforms
|
|
||||||
*
|
|
||||||
* \privatesection
|
|
||||||
*/
|
|
||||||
|
|
||||||
# (PHP 5 >= 5.2.1)
|
|
||||||
# Based on http://www.phpit.net/
|
|
||||||
# article/creating-zip-tar-archives-dynamically-php/2/
|
|
||||||
if(!function_exists('sys_get_temp_dir')) {
|
|
||||||
function sys_get_temp_dir() {
|
|
||||||
// Try to get from environment variable
|
|
||||||
if(!empty($_ENV['TMP'])) {
|
|
||||||
return realpath($_ENV['TMP']);
|
|
||||||
}
|
|
||||||
else if(!empty($_ENV['TMPDIR'])) {
|
|
||||||
return realpath($_ENV['TMPDIR']);
|
|
||||||
}
|
|
||||||
else if(!empty($_ENV['TEMP'])) {
|
|
||||||
return realpath($_ENV['TEMP']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect by creating a temporary file
|
|
||||||
else {
|
|
||||||
// Try to use system's temporary directory
|
|
||||||
// as random name shouldn't exist
|
|
||||||
$temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
|
|
||||||
if($temp_file) {
|
|
||||||
$temp_dir = realpath(dirname($temp_file));
|
|
||||||
unlink($temp_file);
|
|
||||||
return $temp_dir;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# (PHP >= 5.1)
|
|
||||||
# from http://www.php.net/inet_pton
|
|
||||||
if(!function_exists('inet_pton')) {
|
|
||||||
function inet_pton($ip) {
|
|
||||||
# ipv4
|
|
||||||
if(strpos($ip, '.') !== FALSE) {
|
|
||||||
$ip = pack('N',ip2long($ip));
|
|
||||||
}
|
|
||||||
# ipv6
|
|
||||||
else if(strpos($ip, ':') !== FALSE) {
|
|
||||||
$ip = explode(':', $ip);
|
|
||||||
$res = str_pad('', (4*(8-count($ip))), '0000', STR_PAD_LEFT);
|
|
||||||
foreach($ip as $seg) {
|
|
||||||
$res .= str_pad($seg, 4, '0', STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
$ip = pack('H'.strlen($res), $res);
|
|
||||||
}
|
|
||||||
return $ip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# (PHP >= 5.1)
|
|
||||||
# from http://www.php.net/inet_ntop
|
|
||||||
if(!function_exists('inet_ntop')) {
|
|
||||||
function inet_ntop($ip) {
|
|
||||||
if (strlen($ip)==4) {
|
|
||||||
// ipv4
|
|
||||||
list(,$ip)=unpack('N',$ip);
|
|
||||||
$ip=long2ip($ip);
|
|
||||||
} elseif(strlen($ip)==16) {
|
|
||||||
// ipv6
|
|
||||||
$ip=bin2hex($ip);
|
|
||||||
$ip=substr(chunk_split($ip,4,':'),0,-1);
|
|
||||||
$ip=explode(':',$ip);
|
|
||||||
$res='';
|
|
||||||
foreach($ip as $seg) {
|
|
||||||
while($seg{0}=='0') $seg=substr($seg,1);
|
|
||||||
if ($seg!='') {
|
|
||||||
$res.=($res==''?'':':').$seg;
|
|
||||||
} else {
|
|
||||||
if (strpos($res,'::')===false) {
|
|
||||||
if (substr($res,-1)==':') continue;
|
|
||||||
$res.=':';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$res.=($res==''?'':':').'0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$ip=$res;
|
|
||||||
}
|
|
||||||
return $ip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,6 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "compat.inc.php";
|
|
||||||
|
|
||||||
/** @privatesection */
|
/** @privatesection */
|
||||||
// Querylet {{{
|
// Querylet {{{
|
||||||
class Querylet {
|
class Querylet {
|
||||||
@ -290,10 +288,12 @@ class Database {
|
|||||||
if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1];
|
if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1];
|
||||||
if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1];
|
if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1];
|
||||||
|
|
||||||
$this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, array(
|
$db_params = array(
|
||||||
PDO::ATTR_PERSISTENT => true,
|
PDO::ATTR_PERSISTENT => true,
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
));
|
);
|
||||||
|
if(defined("HIPHOP")) $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass);
|
||||||
|
else $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, $db_params);
|
||||||
|
|
||||||
$db_proto = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
$db_proto = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||||
if($db_proto === "mysql") {
|
if($db_proto === "mysql") {
|
||||||
|
21
core/default_config.inc.php
Normal file
21
core/default_config.inc.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
// to change these system-level settings, do define("FOO", 123); in config.php
|
||||||
|
function _d($name, $value) {if(!defined($name)) define($name, $value);}
|
||||||
|
_d("DATABASE_DSN", null); // string PDO database connection details
|
||||||
|
_d("CACHE_DSN", null); // string cache connection details
|
||||||
|
_d("DEBUG", false); // boolean print various debugging details
|
||||||
|
_d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log
|
||||||
|
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
||||||
|
_d("CONTEXT", null); // string file to log performance data into
|
||||||
|
_d("CACHE_MEMCACHE", false); // boolean store complete rendered pages in memcache
|
||||||
|
_d("CACHE_DIR", false); // boolean store complete rendered pages on disk
|
||||||
|
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
||||||
|
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
||||||
|
_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance
|
||||||
|
_d("COMPILE_ELS", false); // boolean pre-build the list of event listeners
|
||||||
|
_d("NICE_URLS", false); // boolean force niceurl mode
|
||||||
|
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
||||||
|
_d("VERSION", 'trunk'); // string shimmie version
|
||||||
|
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
|
||||||
|
_d("TIMEZONE", null); // string timezone
|
||||||
|
?>
|
@ -40,7 +40,7 @@ class PageRequestEvent extends Event {
|
|||||||
*
|
*
|
||||||
* If it matches, store the remaining path elements in $args
|
* If it matches, store the remaining path elements in $args
|
||||||
*/
|
*/
|
||||||
public function page_matches($name) {
|
public function page_matches(/*string*/ $name) {
|
||||||
$parts = explode("/", $name);
|
$parts = explode("/", $name);
|
||||||
$this->part_count = count($parts);
|
$this->part_count = count($parts);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class PageRequestEvent extends Event {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_arg($n) {
|
public function get_arg(/*int*/ $n) {
|
||||||
$offset = $this->part_count + $n;
|
$offset = $this->part_count + $n;
|
||||||
if($offset >= 0 && $offset < $this->arg_count) {
|
if($offset >= 0 && $offset < $this->arg_count) {
|
||||||
return $this->args[$offset];
|
return $this->args[$offset];
|
||||||
@ -120,7 +120,7 @@ class TextFormattingEvent extends Event {
|
|||||||
*/
|
*/
|
||||||
var $stripped;
|
var $stripped;
|
||||||
|
|
||||||
public function __construct($text) {
|
public function __construct(/*string*/ $text) {
|
||||||
$h_text = html_escape(trim($text));
|
$h_text = html_escape(trim($text));
|
||||||
$this->original = $h_text;
|
$this->original = $h_text;
|
||||||
$this->formatted = $h_text;
|
$this->formatted = $h_text;
|
||||||
|
@ -92,7 +92,10 @@ abstract class SimpleExtension implements Extension {
|
|||||||
var $theme;
|
var $theme;
|
||||||
var $_child;
|
var $_child;
|
||||||
|
|
||||||
public function i_am($child) {
|
// in PHP5.3, late static bindings can take care of this; __CLASS__
|
||||||
|
// used here will refer to the subclass
|
||||||
|
// http://php.net/manual/en/language.oop5.late-static-bindings.php
|
||||||
|
public function i_am(Extension $child) {
|
||||||
$this->_child = $child;
|
$this->_child = $child;
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($child, false);
|
if(is_null($this->theme)) $this->theme = get_theme_object($child, false);
|
||||||
}
|
}
|
||||||
@ -115,13 +118,13 @@ abstract class SimpleExtension implements Extension {
|
|||||||
* Several extensions have this in common, make a common API
|
* Several extensions have this in common, make a common API
|
||||||
*/
|
*/
|
||||||
abstract class FormatterExtension extends SimpleExtension {
|
abstract class FormatterExtension extends SimpleExtension {
|
||||||
public function onTextFormatting($event) {
|
public function onTextFormatting(TextFormattingEvent $event) {
|
||||||
$event->formatted = $this->format($event->formatted);
|
$event->formatted = $this->format($event->formatted);
|
||||||
$event->stripped = $this->strip($event->stripped);
|
$event->stripped = $this->strip($event->stripped);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function format($text);
|
abstract public function format(/*string*/ $text);
|
||||||
abstract public function strip($text);
|
abstract public function strip(/*string*/ $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +132,7 @@ abstract class FormatterExtension extends SimpleExtension {
|
|||||||
* so we have a base class to extend from
|
* so we have a base class to extend from
|
||||||
*/
|
*/
|
||||||
abstract class DataHandlerExtension extends SimpleExtension {
|
abstract class DataHandlerExtension extends SimpleExtension {
|
||||||
public function onDataUpload($event) {
|
public function onDataUpload(DataUploadEvent $event) {
|
||||||
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
if(!move_upload_to_archive($event)) return;
|
if(!move_upload_to_archive($event)) return;
|
||||||
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
||||||
@ -188,7 +191,7 @@ abstract class DataHandlerExtension extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onThumbnailGeneration($event) {
|
public function onThumnbnailGeneration(ThumbnailGenerationEvent $event) {
|
||||||
if($this->supported_ext($event->type)) {
|
if($this->supported_ext($event->type)) {
|
||||||
if (method_exists($this, 'create_thumb_force') && $event->force == true) {
|
if (method_exists($this, 'create_thumb_force') && $event->force == true) {
|
||||||
$this->create_thumb_force($event->hash);
|
$this->create_thumb_force($event->hash);
|
||||||
@ -199,14 +202,14 @@ abstract class DataHandlerExtension extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDisplayingImage($event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
global $page;
|
global $page;
|
||||||
if($this->supported_ext($event->image->ext)) {
|
if($this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($page, $event->image);
|
$this->theme->display_image($page, $event->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = $this->setup();
|
$sb = $this->setup();
|
||||||
if($sb) $event->panel->add_block($sb);
|
if($sb) $event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ $tag_n = 0; // temp hack
|
|||||||
$_flexihash = null;
|
$_flexihash = null;
|
||||||
$_fh_last_opts = null;
|
$_fh_last_opts = null;
|
||||||
|
|
||||||
|
require_once "lib/flexihash.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object representing an entry in the images table. As of 2.2, this no
|
* An object representing an entry in the images table. As of 2.2, this no
|
||||||
* longer necessarily represents an image per se, but could be a video,
|
* longer necessarily represents an image per se, but could be a video,
|
||||||
@ -66,7 +68,7 @@ class Image {
|
|||||||
*
|
*
|
||||||
* @retval Image
|
* @retval Image
|
||||||
*/
|
*/
|
||||||
public static function by_id($id) {
|
public static function by_id(/*int*/ $id) {
|
||||||
assert(is_numeric($id));
|
assert(is_numeric($id));
|
||||||
global $database;
|
global $database;
|
||||||
$image = null;
|
$image = null;
|
||||||
@ -79,7 +81,7 @@ class Image {
|
|||||||
*
|
*
|
||||||
* @retval Image
|
* @retval Image
|
||||||
*/
|
*/
|
||||||
public static function by_hash($hash) {
|
public static function by_hash(/*string*/ $hash) {
|
||||||
assert(is_string($hash));
|
assert(is_string($hash));
|
||||||
global $database;
|
global $database;
|
||||||
$image = null;
|
$image = null;
|
||||||
@ -540,7 +542,6 @@ class Image {
|
|||||||
|
|
||||||
if($opts != $_fh_last_opts) {
|
if($opts != $_fh_last_opts) {
|
||||||
$_fh_last_opts = $opts;
|
$_fh_last_opts = $opts;
|
||||||
require_once("lib/flexihash.php");
|
|
||||||
$_flexihash = new Flexihash();
|
$_flexihash = new Flexihash();
|
||||||
foreach(explode(",", $opts) as $opt) {
|
foreach(explode(",", $opts) as $opt) {
|
||||||
$parts = explode("=", $opt);
|
$parts = explode("=", $opt);
|
||||||
@ -1031,7 +1032,7 @@ class Tag {
|
|||||||
* Move a file from PHP's temporary area into shimmie's image storage
|
* Move a file from PHP's temporary area into shimmie's image storage
|
||||||
* heirachy, or throw an exception trying
|
* heirachy, or throw an exception trying
|
||||||
*/
|
*/
|
||||||
function move_upload_to_archive($event) {
|
function move_upload_to_archive(DataUploadEvent $event) {
|
||||||
$target = warehouse_path("images", $event->hash);
|
$target = warehouse_path("images", $event->hash);
|
||||||
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
||||||
if(!@copy($event->tmpname, $target)) {
|
if(!@copy($event->tmpname, $target)) {
|
||||||
@ -1046,7 +1047,7 @@ function move_upload_to_archive($event) {
|
|||||||
* Given a full size pair of dimentions, return a pair scaled down to fit
|
* Given a full size pair of dimentions, return a pair scaled down to fit
|
||||||
* into the configured thumbnail square, with ratio intact
|
* into the configured thumbnail square, with ratio intact
|
||||||
*/
|
*/
|
||||||
function get_thumbnail_size($orig_width, $orig_height) {
|
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if($orig_width == 0) $orig_width = 192;
|
if($orig_width == 0) $orig_width = 192;
|
||||||
|
@ -38,7 +38,7 @@ class User {
|
|||||||
$this->passhash = $row['pass'];
|
$this->passhash = $row['pass'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_session($name, $session) {
|
public static function by_session(/*string*/ $name, /*string*/ $session) {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
if($database->engine->name === "mysql") {
|
if($database->engine->name === "mysql") {
|
||||||
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
||||||
@ -50,7 +50,7 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_id($id) {
|
public static function by_id(/*int*/ $id) {
|
||||||
assert(is_numeric($id));
|
assert(is_numeric($id));
|
||||||
global $database;
|
global $database;
|
||||||
if($id === 1) {
|
if($id === 1) {
|
||||||
@ -62,14 +62,14 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_name($name) {
|
public static function by_name(/*string*/ $name) {
|
||||||
assert(is_string($name));
|
assert(is_string($name));
|
||||||
global $database;
|
global $database;
|
||||||
$row = $database->get_row("SELECT * FROM users WHERE name = :name", array("name"=>$name));
|
$row = $database->get_row("SELECT * FROM users WHERE name = :name", array("name"=>$name));
|
||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_name_and_hash($name, $hash) {
|
public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) {
|
||||||
assert(is_string($name));
|
assert(is_string($name));
|
||||||
assert(is_string($hash));
|
assert(is_string($hash));
|
||||||
assert(strlen($hash) == 32);
|
assert(strlen($hash) == 32);
|
||||||
@ -78,7 +78,7 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_list($offset, $limit=50) {
|
public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
|
||||||
assert(is_numeric($offset));
|
assert(is_numeric($offset));
|
||||||
assert(is_numeric($limit));
|
assert(is_numeric($limit));
|
||||||
global $database;
|
global $database;
|
||||||
@ -120,7 +120,7 @@ class User {
|
|||||||
return $this->admin;
|
return $this->admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_admin($admin) {
|
public function set_admin(/*bool*/ $admin) {
|
||||||
assert(is_bool($admin));
|
assert(is_bool($admin));
|
||||||
global $database;
|
global $database;
|
||||||
$yn = $admin ? 'Y' : 'N';
|
$yn = $admin ? 'Y' : 'N';
|
||||||
@ -128,14 +128,14 @@ class User {
|
|||||||
log_info("core-user", 'Made '.$this->name.' admin='.$yn);
|
log_info("core-user", 'Made '.$this->name.' admin='.$yn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_password($password) {
|
public function set_password(/*string*/ $password) {
|
||||||
global $database;
|
global $database;
|
||||||
$hash = md5(strtolower($this->name) . $password);
|
$hash = md5(strtolower($this->name) . $password);
|
||||||
$database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id));
|
$database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id));
|
||||||
log_info("core-user", 'Set password for '.$this->name);
|
log_info("core-user", 'Set password for '.$this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_email($address) {
|
public function set_email(/*string*/ $address) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id));
|
$database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id));
|
||||||
log_info("core-user", 'Set email for '.$this->name);
|
log_info("core-user", 'Set email for '.$this->name);
|
||||||
@ -173,7 +173,7 @@ class User {
|
|||||||
*/
|
*/
|
||||||
public function get_auth_token() {
|
public function get_auth_token() {
|
||||||
global $config;
|
global $config;
|
||||||
$salt = file_get_contents("config.php");
|
$salt = DATABASE_DSN;
|
||||||
$addr = get_session_ip($config);
|
$addr = get_session_ip($config);
|
||||||
return md5(md5($this->passhash . $addr) . "salty-csrf-" . $salt);
|
return md5(md5($this->passhash . $addr) . "salty-csrf-" . $salt);
|
||||||
}
|
}
|
||||||
|
@ -222,10 +222,10 @@ function make_link($page=null, $query=null) {
|
|||||||
if(NICE_URLS || $config->get_bool('nice_urls', false)) {
|
if(NICE_URLS || $config->get_bool('nice_urls', false)) {
|
||||||
#$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
#$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
||||||
$full = $_SERVER["PHP_SELF"];
|
$full = $_SERVER["PHP_SELF"];
|
||||||
$base = str_replace("/index.php", "", $full);
|
$base = str_replace("/".basename($_SERVER["SCRIPT_FILENAME"]), "", $full);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$base = "./index.php?q=";
|
$base = "./".basename($_SERVER["SCRIPT_FILENAME"])."?q=";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($query)) {
|
if(is_null($query)) {
|
||||||
@ -291,7 +291,7 @@ function modify_url($url, $changes) {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function make_http($link) {
|
function make_http(/*string*/ $link) {
|
||||||
if(strpos($link, "ttp://") > 0) return $link;
|
if(strpos($link, "ttp://") > 0) return $link;
|
||||||
if(strlen($link) > 0 && $link[0] != '/') $link = get_base_href().'/'.$link;
|
if(strlen($link) > 0 && $link[0] != '/') $link = get_base_href().'/'.$link;
|
||||||
$link = "http://".$_SERVER["HTTP_HOST"].$link;
|
$link = "http://".$_SERVER["HTTP_HOST"].$link;
|
||||||
@ -396,11 +396,11 @@ function captcha_check() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _version_check() {
|
function _version_check() {
|
||||||
if(version_compare(PHP_VERSION, "5.0.0") == -1) {
|
if(version_compare(PHP_VERSION, "5.2.6") == -1) {
|
||||||
print "
|
print "
|
||||||
Currently SCore Engine doesn't support versions of PHP lower than 5.0.0 --
|
Currently SCore Engine doesn't support versions of PHP lower than 5.2.6 --
|
||||||
PHP4 and earlier are officially dead according to their creators,
|
if your web host is running an older version, they are dangerously out of
|
||||||
please tell your host to upgrade.
|
date and you should plan on moving elsewhere.
|
||||||
";
|
";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ function get_memory_limit() {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function get_session_ip($config) {
|
function get_session_ip(Config $config) {
|
||||||
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
||||||
$addr = $_SERVER['REMOTE_ADDR'];
|
$addr = $_SERVER['REMOTE_ADDR'];
|
||||||
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
||||||
@ -531,7 +531,7 @@ function get_session_ip($config) {
|
|||||||
* prefix prepended to it, eg username -> shm_username, to prevent
|
* prefix prepended to it, eg username -> shm_username, to prevent
|
||||||
* conflicts from multiple installs within one domain.
|
* conflicts from multiple installs within one domain.
|
||||||
*/
|
*/
|
||||||
function get_prefixed_cookie($name) {
|
function get_prefixed_cookie(/*string*/ $name) {
|
||||||
global $config;
|
global $config;
|
||||||
$full_name = COOKIE_PREFIX."_".$name;
|
$full_name = COOKIE_PREFIX."_".$name;
|
||||||
if(isset($_COOKIE[$full_name])) {
|
if(isset($_COOKIE[$full_name])) {
|
||||||
@ -584,13 +584,13 @@ function get_base_href() {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function format_text($string) {
|
function format_text(/*string*/ $string) {
|
||||||
$tfe = new TextFormattingEvent($string);
|
$tfe = new TextFormattingEvent($string);
|
||||||
send_event($tfe);
|
send_event($tfe);
|
||||||
return $tfe->formatted;
|
return $tfe->formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function warehouse_path($base, $hash, $create=true) {
|
function warehouse_path(/*string*/ $base, /*string*/ $hash, /*bool*/ $create=true) {
|
||||||
$ab = substr($hash, 0, 2);
|
$ab = substr($hash, 0, 2);
|
||||||
$cd = substr($hash, 2, 2);
|
$cd = substr($hash, 2, 2);
|
||||||
if(WH_SPLITS == 2) {
|
if(WH_SPLITS == 2) {
|
||||||
@ -935,6 +935,10 @@ function _stripslashes_r($arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _sanitise_environment() {
|
function _sanitise_environment() {
|
||||||
|
if(TIMEZONE) {
|
||||||
|
date_default_timezone_set(TIMEZONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(DEBUG) {
|
if(DEBUG) {
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
}
|
}
|
||||||
@ -951,6 +955,120 @@ function _sanitise_environment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _get_themelet_files($_theme) {
|
||||||
|
$themelets = array();
|
||||||
|
|
||||||
|
if(file_exists('themes/'.$_theme.'/custompage.class.php')) $themelets[] = 'themes/'.$_theme.'/custompage.class.php';
|
||||||
|
$themelets[] = 'themes/'.$_theme.'/layout.class.php';
|
||||||
|
$themelets[] = 'themes/'.$_theme.'/themelet.class.php';
|
||||||
|
|
||||||
|
$themelet_files = glob("ext/*/theme.php");
|
||||||
|
foreach($themelet_files as $filename) {
|
||||||
|
$themelets[] = $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
$custom_themelets = glob('themes/'.$_theme.'/*.theme.php');
|
||||||
|
if($custom_themelets) {
|
||||||
|
$m = array();
|
||||||
|
foreach($custom_themelets as $filename) {
|
||||||
|
if(preg_match('/themes\/'.$_theme.'\/(.*)\.theme\.php/',$filename,$m)
|
||||||
|
&& in_array('ext/'.$m[1].'/theme.php', $themelets)) {
|
||||||
|
$themelets[] = $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $themelets;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _load_extensions() {
|
||||||
|
global $_event_listeners;
|
||||||
|
|
||||||
|
ctx_log_start("Loading extensions");
|
||||||
|
|
||||||
|
if(COMPILE_ELS && file_exists("data/event_listeners.php")) {
|
||||||
|
require_once("data/event_listeners.php");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$all_events = array();
|
||||||
|
foreach(get_declared_classes() as $class) {
|
||||||
|
if(is_subclass_of($class, "Event")) {
|
||||||
|
$all_events[] = $class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach(get_declared_classes() as $class) {
|
||||||
|
$rclass = new ReflectionClass($class);
|
||||||
|
if($rclass->isAbstract()) {
|
||||||
|
// don't do anything
|
||||||
|
}
|
||||||
|
elseif(is_subclass_of($class, "SimpleExtension")) {
|
||||||
|
$c = new $class();
|
||||||
|
$c->i_am($c);
|
||||||
|
$my_events = array();
|
||||||
|
foreach(get_class_methods($c) as $method) {
|
||||||
|
if(substr($method, 0, 2) == "on") {
|
||||||
|
$my_events[] = substr($method, 2) . "Event";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_event_listener($c, $c->get_priority(), $my_events);
|
||||||
|
}
|
||||||
|
elseif(is_subclass_of($class, "Extension")) {
|
||||||
|
$c = new $class();
|
||||||
|
add_event_listener($c, $c->get_priority(), $all_events);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(COMPILE_ELS) {
|
||||||
|
$p = "<"."?php\n";
|
||||||
|
|
||||||
|
foreach(get_declared_classes() as $class) {
|
||||||
|
$rclass = new ReflectionClass($class);
|
||||||
|
if($rclass->isAbstract()) {}
|
||||||
|
elseif(is_subclass_of($class, "SimpleExtension")) {
|
||||||
|
$p .= "\$$class = new $class(); ";
|
||||||
|
$p .= "\${$class}->i_am(\$$class);\n";
|
||||||
|
}
|
||||||
|
elseif(is_subclass_of($class, "Extension")) {
|
||||||
|
$p .= "\$$class = new $class();\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$p .= "\$_event_listeners = array(\n";
|
||||||
|
foreach($_event_listeners as $event => $listeners) {
|
||||||
|
$p .= "\t'$event' => array(\n";
|
||||||
|
foreach($listeners as $id => $listener) {
|
||||||
|
$p .= "\t\t$id => \$".get_class($listener).",\n";
|
||||||
|
}
|
||||||
|
$p .= "\t),\n";
|
||||||
|
}
|
||||||
|
$p .= ");\n";
|
||||||
|
|
||||||
|
$p .= "?".">";
|
||||||
|
file_put_contents("data/event_listeners.php", $p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx_log_endok();
|
||||||
|
}
|
||||||
|
|
||||||
|
function _fatal_error(Exception $e) {
|
||||||
|
$version = VERSION;
|
||||||
|
$message = $e->getMessage();
|
||||||
|
//$trace = var_dump($e->getTrace());
|
||||||
|
header("HTTP/1.0 500 Internal Error");
|
||||||
|
echo '
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Internal error - SCore-'.$version.'</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Internal Error</h1>
|
||||||
|
<p>'.$message.'
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn ^^ into ^ and ^s into /
|
* Turn ^^ into ^ and ^s into /
|
||||||
*
|
*
|
||||||
|
@ -120,7 +120,7 @@ class AliasEditor extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_alias_csv($database) {
|
private function get_alias_csv(Database $database) {
|
||||||
$csv = "";
|
$csv = "";
|
||||||
$aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases");
|
$aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases");
|
||||||
foreach($aliases as $old => $new) {
|
foreach($aliases as $old => $new) {
|
||||||
@ -129,7 +129,7 @@ class AliasEditor extends SimpleExtension {
|
|||||||
return $csv;
|
return $csv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_alias_csv($database, $csv) {
|
private function add_alias_csv(Database $database, /*string*/ $csv) {
|
||||||
$csv = str_replace("\r", "\n", $csv);
|
$csv = str_replace("\r", "\n", $csv);
|
||||||
foreach(explode("\n", $csv) as $line) {
|
foreach(explode("\n", $csv) as $line) {
|
||||||
$parts = explode(",", $line);
|
$parts = explode(",", $line);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class BBCode extends FormatterExtension {
|
class BBCode extends FormatterExtension {
|
||||||
public function format($text) {
|
public function format(/*string*/ $text) {
|
||||||
global $config;
|
global $config;
|
||||||
if($config->get_bool("word_wrap", true)) {
|
if($config->get_bool("word_wrap", true)) {
|
||||||
$text = wordwrap($text, 80, " ", true);
|
$text = wordwrap($text, 80, " ", true);
|
||||||
@ -73,7 +73,7 @@ class BBCode extends FormatterExtension {
|
|||||||
return str_replace(' ', '', $matches[1]);
|
return str_replace(' ', '', $matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function strip($text) {
|
public function strip(/*string*/ $text) {
|
||||||
global $config;
|
global $config;
|
||||||
if($config->get_bool("word_wrap", true)) {
|
if($config->get_bool("word_wrap", true)) {
|
||||||
$text = wordwrap($text, 80, " ", true);
|
$text = wordwrap($text, 80, " ", true);
|
||||||
@ -103,14 +103,14 @@ class BBCode extends FormatterExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function filter_spoiler($text) {
|
private function filter_spoiler(/*string*/ $text) {
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array("[spoiler]","[/spoiler]"),
|
array("[spoiler]","[/spoiler]"),
|
||||||
array("<span style=\"background-color:#000; color:#000;\">","</span>"),
|
array("<span style=\"background-color:#000; color:#000;\">","</span>"),
|
||||||
$text);
|
$text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function strip_spoiler($text) {
|
private function strip_spoiler(/*string*/ $text) {
|
||||||
$l1 = strlen("[spoiler]");
|
$l1 = strlen("[spoiler]");
|
||||||
$l2 = strlen("[/spoiler]");
|
$l2 = strlen("[/spoiler]");
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -129,7 +129,7 @@ class BBCode extends FormatterExtension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function extract_code($text) {
|
private function extract_code(/*string*/ $text) {
|
||||||
# at the end of this function, the only code! blocks should be
|
# at the end of this function, the only code! blocks should be
|
||||||
# the ones we've added -- others may contain malicious content,
|
# the ones we've added -- others may contain malicious content,
|
||||||
# which would only appear after decoding
|
# which would only appear after decoding
|
||||||
@ -154,7 +154,7 @@ class BBCode extends FormatterExtension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function insert_code($text) {
|
private function insert_code(/*string*/ $text) {
|
||||||
$l1 = strlen("[code!]");
|
$l1 = strlen("[code!]");
|
||||||
$l2 = strlen("[/code!]");
|
$l2 = strlen("[/code!]");
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -173,5 +173,4 @@ class BBCode extends FormatterExtension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new BBCode());
|
|
||||||
?>
|
?>
|
||||||
|
@ -61,7 +61,7 @@ class Comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CommentList extends SimpleExtension {
|
class CommentList extends SimpleExtension {
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
$config->set_default_bool('comment_anon', true);
|
$config->set_default_bool('comment_anon', true);
|
||||||
$config->set_default_int('comment_window', 5);
|
$config->set_default_int('comment_window', 5);
|
||||||
@ -194,7 +194,7 @@ class CommentList extends SimpleExtension {
|
|||||||
|
|
||||||
// TODO: split akismet into a separate class, which can veto the event
|
// TODO: split akismet into a separate class, which can veto the event
|
||||||
public function onCommentPosting(CommentPostingEvent $event) {
|
public function onCommentPosting(CommentPostingEvent $event) {
|
||||||
$this->add_comment_wrapper($event->image_id, $event->user, $event->comment, $event);
|
$this->add_comment_wrapper($event->image_id, $event->user, $event->comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCommentDeletion(CommentDeletionEvent $event) {
|
public function onCommentDeletion(CommentDeletionEvent $event) {
|
||||||
@ -247,7 +247,7 @@ class CommentList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// page building {{{
|
// page building {{{
|
||||||
private function build_page($current_page) {
|
private function build_page(/*int*/ $current_page) {
|
||||||
global $page;
|
global $page;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -296,7 +296,7 @@ class CommentList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// get comments {{{
|
// get comments {{{
|
||||||
private function get_recent_comments() {
|
private function get_recent_comments($count) {
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
$rows = $database->get_all("
|
$rows = $database->get_all("
|
||||||
@ -309,7 +309,7 @@ class CommentList extends SimpleExtension {
|
|||||||
LEFT JOIN users ON comments.owner_id=users.id
|
LEFT JOIN users ON comments.owner_id=users.id
|
||||||
ORDER BY comments.id DESC
|
ORDER BY comments.id DESC
|
||||||
LIMIT :limit
|
LIMIT :limit
|
||||||
", array("limit"=>$config->get_int('comment_count')));
|
", array("limit"=>$count));
|
||||||
$comments = array();
|
$comments = array();
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
$comments[] = new Comment($row);
|
$comments[] = new Comment($row);
|
||||||
@ -317,7 +317,7 @@ class CommentList extends SimpleExtension {
|
|||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_user_recent_comments($user_id, $count) {
|
private function get_user_recent_comments(/*int*/ $user_id, /*int*/ $count) {
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
$rows = $database->get_all("
|
$rows = $database->get_all("
|
||||||
@ -339,7 +339,7 @@ class CommentList extends SimpleExtension {
|
|||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_comments($image_id) {
|
private function get_comments(/*int*/ $image_id) {
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
$i_image_id = int_escape($image_id);
|
$i_image_id = int_escape($image_id);
|
||||||
@ -399,7 +399,7 @@ class CommentList extends SimpleExtension {
|
|||||||
return md5($_SERVER['REMOTE_ADDR'] . date("%Y%m%d"));
|
return md5($_SERVER['REMOTE_ADDR'] . date("%Y%m%d"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_spam_akismet($text) {
|
private function is_spam_akismet(/*string*/ $text) {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
if(strlen($config->get_string('comment_wordpress_key')) > 0) {
|
if(strlen($config->get_string('comment_wordpress_key')) > 0) {
|
||||||
$comment = array(
|
$comment = array(
|
||||||
@ -443,12 +443,12 @@ class CommentList extends SimpleExtension {
|
|||||||
return ($config->get_bool('comment_anon') || !$user->is_anonymous());
|
return ($config->get_bool('comment_anon') || !$user->is_anonymous());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_dupe($image_id, $comment) {
|
private function is_dupe(/*int*/ $image_id, /*string*/ $comment) {
|
||||||
global $database;
|
global $database;
|
||||||
return ($database->get_row("SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment", array("image_id"=>$image_id, "comment"=>$comment)));
|
return ($database->get_row("SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment", array("image_id"=>$image_id, "comment"=>$comment)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_comment_wrapper($image_id, $user, $comment, $event) {
|
private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $comment) {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class ExtensionInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_enabled($fname) {
|
private function is_enabled(/*string*/ $fname) {
|
||||||
if(file_exists("ext/$fname") && file_exists("contrib/$fname")) return true; // both
|
if(file_exists("ext/$fname") && file_exists("contrib/$fname")) return true; // both
|
||||||
if(file_exists("contrib/$fname")) return false; // only disabled (optional)
|
if(file_exists("contrib/$fname")) return false; // only disabled (optional)
|
||||||
return null; // only active (core)
|
return null; // only active (core)
|
||||||
@ -139,7 +139,7 @@ class ExtManager extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_extensions($all) {
|
private function get_extensions(/*bool*/ $all) {
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
if($all) {
|
if($all) {
|
||||||
$exts = glob("ext/*/main.php");
|
$exts = glob("ext/*/main.php");
|
||||||
@ -170,7 +170,7 @@ class ExtManager extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_enabled($fname, $enabled) {
|
private function set_enabled(/*string*/ $fname, /*bool*/ $enabled) {
|
||||||
if($enabled) {
|
if($enabled) {
|
||||||
// enable if currently disabled
|
// enable if currently disabled
|
||||||
if(!file_exists("ext/$fname")) {
|
if(!file_exists("ext/$fname")) {
|
||||||
|
@ -176,5 +176,4 @@ class PixelFileHandler extends DataHandlerExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
add_event_listener(new PixelFileHandler());
|
|
||||||
?>
|
?>
|
||||||
|
@ -130,7 +130,7 @@ class ParseLinkTemplateEvent extends Event {
|
|||||||
* A class to handle adding / getting / removing image files from the disk.
|
* A class to handle adding / getting / removing image files from the disk.
|
||||||
*/
|
*/
|
||||||
class ImageIO extends SimpleExtension {
|
class ImageIO extends SimpleExtension {
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int('thumb_width', 192);
|
$config->set_default_int('thumb_width', 192);
|
||||||
$config->set_default_int('thumb_height', 192);
|
$config->set_default_int('thumb_height', 192);
|
||||||
@ -147,7 +147,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
$config->set_default_int('image_expires', (60*60*24*365) ); // defaults to one year
|
$config->set_default_int('image_expires', (60*60*24*365) ); // defaults to one year
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
$num = $event->get_arg(0);
|
$num = $event->get_arg(0);
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
|
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
|
||||||
@ -186,7 +186,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageAdminBlockBuilding($event) {
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageAddition($event) {
|
public function onImageAddition(ImageAdditionEvent $event) {
|
||||||
try {
|
try {
|
||||||
$this->add_image($event->image);
|
$this->add_image($event->image);
|
||||||
}
|
}
|
||||||
@ -208,11 +208,11 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageDeletion($event) {
|
public function onImageDeletion(ImageDeletionEvent $event) {
|
||||||
$event->image->delete();
|
$event->image->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageReplace($event) {
|
public function onImageReplace(ImageReplaceEvent $event) {
|
||||||
try {
|
try {
|
||||||
$this->replace_image($event->id, $event->image);
|
$this->replace_image($event->id, $event->image);
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserPageBuilding($event) {
|
public function onUserPageBuilding(UserPageBuildingEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
$event->add_stats("<a href='$images_link'>Images uploaded</a>: $i_image_count, $h_image_rate per day");
|
$event->add_stats("<a href='$images_link'>Images uploaded</a>: $i_image_count, $h_image_rate per day");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Image Options");
|
$sb = new SetupBlock("Image Options");
|
||||||
$sb->position = 30;
|
$sb->position = 30;
|
||||||
// advanced only
|
// advanced only
|
||||||
|
@ -129,14 +129,14 @@ class PostListBuildingEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Index extends SimpleExtension {
|
class Index extends SimpleExtension {
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int("index_width", 3);
|
$config->set_default_int("index_width", 3);
|
||||||
$config->set_default_int("index_height", 4);
|
$config->set_default_int("index_height", 4);
|
||||||
$config->set_default_bool("index_tips", true);
|
$config->set_default_bool("index_tips", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $database, $page, $user;
|
global $config, $database, $page, $user;
|
||||||
if($event->page_matches("post/list")) {
|
if($event->page_matches("post/list")) {
|
||||||
if(isset($_GET['search'])) {
|
if(isset($_GET['search'])) {
|
||||||
@ -182,7 +182,7 @@ class Index extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Index Options");
|
$sb = new SetupBlock("Index Options");
|
||||||
$sb->position = 20;
|
$sb->position = 20;
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ class Index extends SimpleExtension {
|
|||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSearchTermParse($event) {
|
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
// check for tags first as tag based searches are more common.
|
// check for tags first as tag based searches are more common.
|
||||||
if(preg_match("/tags(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
|
if(preg_match("/tags(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
|
||||||
|
@ -8,8 +8,8 @@ class IndexTheme extends Themelet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function display_intro(Page $page) {
|
public function display_intro(Page $page) {
|
||||||
$text = <<<EOD
|
$text = "
|
||||||
<div style="text-align: left;">
|
<div style='text-align: left;'>
|
||||||
<p>The first thing you'll probably want to do is create a new account; note
|
<p>The first thing you'll probably want to do is create a new account; note
|
||||||
that the first account you create will by default be marked as the board's
|
that the first account you create will by default be marked as the board's
|
||||||
administrator, and any further accounts will be regular users.
|
administrator, and any further accounts will be regular users.
|
||||||
@ -19,7 +19,7 @@ and of course start organising your images :-)
|
|||||||
|
|
||||||
<p>This message will go away once your first image is uploaded~
|
<p>This message will go away once your first image is uploaded~
|
||||||
</div>
|
</div>
|
||||||
EOD;
|
";
|
||||||
$page->set_title("Welcome to Shimmie ".VERSION);
|
$page->set_title("Welcome to Shimmie ".VERSION);
|
||||||
$page->set_heading("Welcome to Shimmie");
|
$page->set_heading("Welcome to Shimmie");
|
||||||
$page->add_block(new Block("Installation Succeeded!", $text, "main", 0));
|
$page->add_block(new Block("Installation Succeeded!", $text, "main", 0));
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class Mail extends SimpleExtension {
|
class Mail extends SimpleExtension {
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Mailing Options");
|
$sb = new SetupBlock("Mailing Options");
|
||||||
$sb->add_text_option("mail_sub", "<br>Subject prefix: ");
|
$sb->add_text_option("mail_sub", "<br>Subject prefix: ");
|
||||||
$sb->add_text_option("mail_img", "<br>Banner Image URL: ");
|
$sb->add_text_option("mail_img", "<br>Banner Image URL: ");
|
||||||
@ -18,7 +18,7 @@ class Mail extends SimpleExtension {
|
|||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_string("mail_sub", $config->get_string("site_title")." - ");
|
$config->set_default_string("mail_sub", $config->get_string("site_title")." - ");
|
||||||
$config->set_default_string("mail_img", make_http("ext/mail/banner.png"));
|
$config->set_default_string("mail_img", make_http("ext/mail/banner.png"));
|
||||||
@ -27,7 +27,7 @@ class Mail extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class MailTest extends SimpleExtension {
|
class MailTest extends SimpleExtension {
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
if($event->page_matches("mail/test")) {
|
if($event->page_matches("mail/test")) {
|
||||||
global $page;
|
global $page;
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
class ConfigSaveEvent extends Event {
|
class ConfigSaveEvent extends Event {
|
||||||
var $config;
|
var $config;
|
||||||
|
|
||||||
public function ConfigSaveEvent($config) {
|
public function ConfigSaveEvent(Config $config) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ class ConfigSaveEvent extends Event {
|
|||||||
class SetupBuildingEvent extends Event {
|
class SetupBuildingEvent extends Event {
|
||||||
var $panel;
|
var $panel;
|
||||||
|
|
||||||
public function SetupBuildingEvent($panel) {
|
public function SetupBuildingEvent(SetupPanel $panel) {
|
||||||
$this->panel = $panel;
|
$this->panel = $panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class SetupBuildingEvent extends Event {
|
|||||||
class SetupPanel {
|
class SetupPanel {
|
||||||
var $blocks = array();
|
var $blocks = array();
|
||||||
|
|
||||||
public function add_block($block) {
|
public function add_block(SetupBlock $block) {
|
||||||
$this->blocks[] = $block;
|
$this->blocks[] = $block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ class SetupBlock extends Block {
|
|||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
class Setup extends SimpleExtension {
|
class Setup extends SimpleExtension {
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_string("title", "Shimmie");
|
$config->set_default_string("title", "Shimmie");
|
||||||
$config->set_default_string("front_page", "post/list");
|
$config->set_default_string("front_page", "post/list");
|
||||||
@ -178,7 +178,7 @@ class Setup extends SimpleExtension {
|
|||||||
$config->set_default_bool("autocache_min_js", false);
|
$config->set_default_bool("autocache_min_js", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
|
|
||||||
if($event->page_matches("nicetest")) {
|
if($event->page_matches("nicetest")) {
|
||||||
@ -210,7 +210,7 @@ class Setup extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$themes = array();
|
$themes = array();
|
||||||
foreach(glob("themes/*") as $theme_dirname) {
|
foreach(glob("themes/*") as $theme_dirname) {
|
||||||
$name = str_replace("themes/", "", $theme_dirname);
|
$name = str_replace("themes/", "", $theme_dirname);
|
||||||
@ -309,7 +309,7 @@ class Setup extends SimpleExtension {
|
|||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onConfigSave($event) {
|
public function onConfigSave(ConfigSaveEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
foreach($_POST as $_name => $junk) {
|
foreach($_POST as $_name => $junk) {
|
||||||
if(substr($_name, 0, 6) == "_type_") {
|
if(substr($_name, 0, 6) == "_type_") {
|
||||||
@ -327,7 +327,7 @@ class Setup extends SimpleExtension {
|
|||||||
log_warning("setup", "Configuration updated");
|
log_warning("setup", "Configuration updated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserBlockBuilding($event) {
|
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
$event->add_link("Board Config", make_link("setup"));
|
$event->add_link("Board Config", make_link("setup"));
|
||||||
|
@ -56,7 +56,7 @@ class LockSetEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TagEdit extends SimpleExtension {
|
class TagEdit extends SimpleExtension {
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $user, $page;
|
global $user, $page;
|
||||||
if($event->page_matches("tag_edit")) {
|
if($event->page_matches("tag_edit")) {
|
||||||
if($event->get_arg(0) == "replace") {
|
if($event->get_arg(0) == "replace") {
|
||||||
@ -71,8 +71,8 @@ class TagEdit extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageInfoSet($event) {
|
public function onImageInfoSet(ImageInfoSetEvent $event) {
|
||||||
global $user;
|
global $user, $page;
|
||||||
if($this->can_tag($event->image)) {
|
if($this->can_tag($event->image)) {
|
||||||
send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
|
send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
|
||||||
if($this->can_source($event->image)) {
|
if($this->can_source($event->image)) {
|
||||||
@ -88,41 +88,41 @@ class TagEdit extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onTagSet($event) {
|
public function onTagSet(TagSetEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin() || !$event->image->is_locked()) {
|
if($user->is_admin() || !$event->image->is_locked()) {
|
||||||
$event->image->set_tags($event->tags);
|
$event->image->set_tags($event->tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSourceSet($event) {
|
public function onSourceSet(SourceSetEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin() || !$event->image->is_locked()) {
|
if($user->is_admin() || !$event->image->is_locked()) {
|
||||||
$event->image->set_source($event->source);
|
$event->image->set_source($event->source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onLockSet($event) {
|
public function onLockSet(LockSetEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
$event->image->set_locked($event->locked);
|
$event->image->set_locked($event->locked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageDeletion($event) {
|
public function onImageDeletion(ImageDeletionEvent $event) {
|
||||||
$event->image->delete_tags_from_image();
|
$event->image->delete_tags_from_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAdminBuilding($event) {
|
public function onAdminBuilding(AdminBuildingEvent $event) {
|
||||||
$this->theme->display_mass_editor();
|
$this->theme->display_mass_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// When an alias is added, oldtag becomes inaccessable
|
// When an alias is added, oldtag becomes inaccessable
|
||||||
public function onAddAlias($event) {
|
public function onAddAlias(AddAliasEvent $event) {
|
||||||
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageInfoBoxBuilding($event) {
|
public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($this->can_tag($event->image)) {
|
if($this->can_tag($event->image)) {
|
||||||
$event->add_part($this->theme->get_tag_editor_html($event->image), 40);
|
$event->add_part($this->theme->get_tag_editor_html($event->image), 40);
|
||||||
@ -135,7 +135,7 @@ class TagEdit extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Tag Editing");
|
$sb = new SetupBlock("Tag Editing");
|
||||||
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
|
$sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
|
||||||
$sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
|
$sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
|
||||||
@ -143,7 +143,7 @@ class TagEdit extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function can_tag($image) {
|
private function can_tag(Image $image) {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
return (
|
return (
|
||||||
($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) &&
|
($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) &&
|
||||||
@ -151,7 +151,7 @@ class TagEdit extends SimpleExtension {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function can_source($image) {
|
private function can_source(Image $image) {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
return (
|
return (
|
||||||
($config->get_bool("source_edit_anon") || !$user->is_anonymous()) &&
|
($config->get_bool("source_edit_anon") || !$user->is_anonymous()) &&
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class TagList extends SimpleExtension {
|
class TagList extends SimpleExtension {
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int("tag_list_length", 15);
|
$config->set_default_int("tag_list_length", 15);
|
||||||
$config->set_default_int("popular_tag_list_length", 15);
|
$config->set_default_int("popular_tag_list_length", 15);
|
||||||
@ -16,7 +16,7 @@ class TagList extends SimpleExtension {
|
|||||||
$config->set_default_bool("tag_list_pages", false);
|
$config->set_default_bool("tag_list_pages", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $page, $database;
|
global $page, $database;
|
||||||
|
|
||||||
if($event->page_matches("tags")) {
|
if($event->page_matches("tags")) {
|
||||||
@ -59,7 +59,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPostListBuilding($event) {
|
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||||
global $config, $page;
|
global $config, $page;
|
||||||
if($config->get_int('tag_list_length') > 0) {
|
if($config->get_int('tag_list_length') > 0) {
|
||||||
if(!empty($event->search_terms)) {
|
if(!empty($event->search_terms)) {
|
||||||
@ -71,7 +71,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDisplayingImage($event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
global $config, $page;
|
global $config, $page;
|
||||||
if($config->get_int('tag_list_length') > 0) {
|
if($config->get_int('tag_list_length') > 0) {
|
||||||
if($config->get_string('tag_list_image_type') == 'related') {
|
if($config->get_string('tag_list_image_type') == 'related') {
|
||||||
@ -83,7 +83,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = new SetupBlock("Tag Map Options");
|
$sb = new SetupBlock("Tag Map Options");
|
||||||
$sb->add_int_option("tags_min", "Only show tags used at least "); $sb->add_label(" times");
|
$sb->add_int_option("tags_min", "Only show tags used at least "); $sb->add_label(" times");
|
||||||
$sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: ");
|
$sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: ");
|
||||||
@ -102,7 +102,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// misc {{{
|
// misc {{{
|
||||||
private function tag_link($tag) {
|
private function tag_link(/*string*/ $tag) {
|
||||||
$u_tag = url_escape($tag);
|
$u_tag = url_escape($tag);
|
||||||
return make_link("post/list/$u_tag/1");
|
return make_link("post/list/$u_tag/1");
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// blocks {{{
|
// blocks {{{
|
||||||
private function add_related_block($page, $image) {
|
private function add_related_block(Page $page, Image $image) {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_tags_block($page, $image) {
|
private function add_tags_block(Page $page, Image $image) {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_popular_block($page) {
|
private function add_popular_block(Page $page) {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ class TagList extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_refine_block($page, $search) {
|
private function add_refine_block(Page $page, /*string*/ $search) {
|
||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class Upload extends SimpleExtension {
|
|||||||
// early, so it can stop the DataUploadEvent before any data handlers see it
|
// early, so it can stop the DataUploadEvent before any data handlers see it
|
||||||
public function get_priority() {return 40;}
|
public function get_priority() {return 40;}
|
||||||
|
|
||||||
public function onInitExt($event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int('upload_count', 3);
|
$config->set_default_int('upload_count', 3);
|
||||||
$config->set_default_int('upload_size', '1MB');
|
$config->set_default_int('upload_size', '1MB');
|
||||||
@ -63,7 +63,7 @@ class Upload extends SimpleExtension {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPostListBuilding($event) {
|
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||||
global $user, $page;
|
global $user, $page;
|
||||||
if($this->can_upload($user)) {
|
if($this->can_upload($user)) {
|
||||||
if($this->is_full) {
|
if($this->is_full) {
|
||||||
@ -75,7 +75,7 @@ class Upload extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$tes = array();
|
$tes = array();
|
||||||
$tes["Disabled"] = "none";
|
$tes["Disabled"] = "none";
|
||||||
if(function_exists("curl_init")) {
|
if(function_exists("curl_init")) {
|
||||||
@ -97,7 +97,7 @@ class Upload extends SimpleExtension {
|
|||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDataUpload($event) {
|
public function onDataUpload(DataUploadEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
if($this->is_full) {
|
if($this->is_full) {
|
||||||
throw new UploadException("Upload failed; disk nearly full");
|
throw new UploadException("Upload failed; disk nearly full");
|
||||||
@ -218,7 +218,7 @@ class Upload extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// do things {{{
|
// do things {{{
|
||||||
private function can_upload($user) {
|
private function can_upload(User $user) {
|
||||||
global $config;
|
global $config;
|
||||||
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
|
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class UserCreationEvent extends Event {
|
|||||||
class UserCreationException extends SCoreException {}
|
class UserCreationException extends SCoreException {}
|
||||||
|
|
||||||
class UserPage extends SimpleExtension {
|
class UserPage extends SimpleExtension {
|
||||||
public function onInitExt(Event $event) {
|
public function onInitExt(InitExtEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_bool("login_signup_enabled", true);
|
$config->set_default_bool("login_signup_enabled", true);
|
||||||
$config->set_default_int("login_memory", 365);
|
$config->set_default_int("login_memory", 365);
|
||||||
@ -54,7 +54,7 @@ class UserPage extends SimpleExtension {
|
|||||||
$config->set_default_bool("login_tac_bbcode", true);
|
$config->set_default_bool("login_tac_bbcode", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest(Event $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $database, $page, $user;
|
global $config, $database, $page, $user;
|
||||||
|
|
||||||
// user info is shown on all pages
|
// user info is shown on all pages
|
||||||
@ -152,7 +152,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
|
if($event->page_matches("user")) {
|
||||||
$display_user = ($event->count_args() == 0) ? $user : User::by_name($event->get_arg(0));
|
$display_user = ($event->count_args() == 0) ? $user : User::by_name($event->get_arg(0));
|
||||||
if($event->count_args() == 0 && $user->is_anonymous()) {
|
if($event->count_args() == 0 && $user->is_anonymous()) {
|
||||||
$this->theme->display_error($page, "Not Logged In",
|
$this->theme->display_error($page, "Not Logged In",
|
||||||
@ -169,7 +169,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserPageBuilding(Event $event) {
|
public function onUserPageBuilding(UserPageBuildingEvent $event) {
|
||||||
global $page, $user, $config;
|
global $page, $user, $config;
|
||||||
|
|
||||||
$h_join_date = autodate($event->display_user->join_date);
|
$h_join_date = autodate($event->display_user->join_date);
|
||||||
@ -197,7 +197,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding(Event $event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$hosts = array(
|
$hosts = array(
|
||||||
@ -228,17 +228,17 @@ class UserPage extends SimpleExtension {
|
|||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserBlockBuilding(Event $event) {
|
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||||
$event->add_link("My Profile", make_link("user"));
|
$event->add_link("My Profile", make_link("user"));
|
||||||
$event->add_link("Log Out", make_link("user_admin/logout"), 99);
|
$event->add_link("Log Out", make_link("user_admin/logout"), 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserCreation(Event $event) {
|
public function onUserCreation(UserCreationEvent $event) {
|
||||||
$this->check_user_creation($event);
|
$this->check_user_creation($event);
|
||||||
$this->create_user($event);
|
$this->create_user($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSearchTermParse(Event $event) {
|
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
@ -263,7 +263,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// Things done *with* the user {{{
|
// Things done *with* the user {{{
|
||||||
private function login($page) {
|
private function login(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$name = $_POST['user'];
|
$name = $_POST['user'];
|
||||||
@ -289,7 +289,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function check_user_creation($event) {
|
private function check_user_creation($event) { // FIXME type
|
||||||
$name = $event->username;
|
$name = $event->username;
|
||||||
$pass = $event->password;
|
$pass = $event->password;
|
||||||
$email = $event->email;
|
$email = $event->email;
|
||||||
@ -309,7 +309,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function create_user($event) {
|
private function create_user($event) { // FIXME type
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$hash = md5(strtolower($event->username) . $event->password);
|
$hash = md5(strtolower($event->username) . $event->password);
|
||||||
@ -326,7 +326,7 @@ class UserPage extends SimpleExtension {
|
|||||||
log_info("user", "Created User #$uid ({$event->username})");
|
log_info("user", "Created User #$uid ({$event->username})");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_login_cookie($name, $pass) {
|
private function set_login_cookie(/*string*/ $name, /*string*/ $pass) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$addr = get_session_ip($config);
|
$addr = get_session_ip($config);
|
||||||
@ -339,7 +339,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
//}}}
|
//}}}
|
||||||
// Things done *to* the user {{{
|
// Things done *to* the user {{{
|
||||||
private function change_password_wrapper($page) {
|
private function change_password_wrapper(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -378,7 +378,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function change_email_wrapper($page) {
|
private function change_email_wrapper(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -411,7 +411,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_more_wrapper($page) {
|
private function set_more_wrapper(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -443,7 +443,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// ips {{{
|
// ips {{{
|
||||||
private function count_upload_ips($duser) {
|
private function count_upload_ips(User $duser) {
|
||||||
global $database;
|
global $database;
|
||||||
$rows = $database->get_pairs("
|
$rows = $database->get_pairs("
|
||||||
SELECT
|
SELECT
|
||||||
@ -456,7 +456,7 @@ class UserPage extends SimpleExtension {
|
|||||||
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
private function count_comment_ips($duser) {
|
private function count_comment_ips(User $duser) {
|
||||||
global $database;
|
global $database;
|
||||||
$rows = $database->get_pairs("
|
$rows = $database->get_pairs("
|
||||||
SELECT
|
SELECT
|
||||||
@ -470,7 +470,7 @@ class UserPage extends SimpleExtension {
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete_user($page) {
|
private function delete_user(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -501,7 +501,7 @@ class UserPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete_user_with_images($page) {
|
private function delete_user_with_images(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
@ -537,5 +537,4 @@ class UserPage extends SimpleExtension {
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
add_event_listener(new UserPage());
|
|
||||||
?>
|
?>
|
||||||
|
@ -60,7 +60,7 @@ class ImageAdminBlockBuildingEvent extends Event {
|
|||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_part($html, $position=50) {
|
public function add_part(/*string*/ $html, /*int*/ $position=50) {
|
||||||
while(isset($this->parts[$position])) $position++;
|
while(isset($this->parts[$position])) $position++;
|
||||||
$this->parts[$position] = $html;
|
$this->parts[$position] = $html;
|
||||||
}
|
}
|
||||||
|
139
index.php
139
index.php
@ -55,32 +55,11 @@ if(empty($database_dsn) && !file_exists("config.php")) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
|
require_once "core/default_config.inc.php";
|
||||||
// to change these system-level settings, do define("FOO", 123); in config.php
|
|
||||||
function _d($name, $value) {if(!defined($name)) define($name, $value);}
|
|
||||||
_d("DATABASE_DSN", null); // string PDO database connection details
|
|
||||||
_d("CACHE_DSN", null); // string cache connection details
|
|
||||||
_d("DEBUG", false); // boolean print various debugging details
|
|
||||||
_d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log
|
|
||||||
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
|
||||||
_d("CONTEXT", null); // string file to log performance data into
|
|
||||||
_d("CACHE_MEMCACHE", false); // boolean store complete rendered pages in memcache
|
|
||||||
_d("CACHE_DIR", false); // boolean store complete rendered pages on disk
|
|
||||||
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
|
||||||
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
|
||||||
_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance
|
|
||||||
_d("COMPILE_ELS", false); // boolean pre-build the list of event listeners
|
|
||||||
_d("NICE_URLS", false); // boolean force niceurl mode
|
|
||||||
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
|
||||||
_d("VERSION", 'trunk'); // string shimmie version
|
|
||||||
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
|
|
||||||
_d("TIMEZONE", 'UTC'); // string timezone
|
|
||||||
|
|
||||||
// set up and purify the environment
|
|
||||||
date_default_timezone_set(TIMEZONE);
|
|
||||||
|
|
||||||
require_once "core/util.inc.php";
|
require_once "core/util.inc.php";
|
||||||
require_once "lib/context.php";
|
require_once "lib/context.php";
|
||||||
|
|
||||||
|
// set up and purify the environment
|
||||||
if(CONTEXT) {
|
if(CONTEXT) {
|
||||||
ctx_set_log(CONTEXT);
|
ctx_set_log(CONTEXT);
|
||||||
}
|
}
|
||||||
@ -103,7 +82,6 @@ try {
|
|||||||
}
|
}
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
|
|
||||||
|
|
||||||
ctx_log_start("Connecting to DB");
|
ctx_log_start("Connecting to DB");
|
||||||
// connect to the database
|
// connect to the database
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
@ -111,105 +89,22 @@ try {
|
|||||||
$config = new DatabaseConfig($database);
|
$config = new DatabaseConfig($database);
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
|
|
||||||
|
|
||||||
ctx_log_start("Loading themelets");
|
|
||||||
// load the theme parts
|
// load the theme parts
|
||||||
|
ctx_log_start("Loading themelets");
|
||||||
$_theme = $config->get_string("theme", "default");
|
$_theme = $config->get_string("theme", "default");
|
||||||
if(!file_exists('themes/'.$_theme)) $_theme = "default";
|
if(!file_exists("themes/$_theme")) $_theme = "default";
|
||||||
if(file_exists('themes/'.$_theme.'/custompage.class.php')) require_once 'themes/'.$_theme.'/custompage.class.php';
|
foreach(_get_themelet_files($_theme) as $themelet) {
|
||||||
require_once 'themes/'.$_theme.'/layout.class.php';
|
require_once $themelet;
|
||||||
require_once 'themes/'.$_theme.'/themelet.class.php';
|
|
||||||
|
|
||||||
$themelets = glob("ext/*/theme.php");
|
|
||||||
foreach($themelets as $filename) {
|
|
||||||
require_once $filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
$custom_themelets = glob('themes/'.$_theme.'/*.theme.php');
|
|
||||||
if($custom_themelets) {
|
|
||||||
$m = array();
|
|
||||||
foreach($custom_themelets as $filename) {
|
|
||||||
if(preg_match('/themes\/'.$_theme.'\/(.*)\.theme\.php/',$filename,$m)
|
|
||||||
&& in_array('ext/'.$m[1].'/theme.php', $themelets)) {
|
|
||||||
require_once $filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
|
|
||||||
|
_load_extensions();
|
||||||
ctx_log_start("Loading extensions");
|
|
||||||
// initialise the extensions
|
|
||||||
global $_event_listeners;
|
|
||||||
if(COMPILE_ELS && file_exists("data/event_listeners.php")) {
|
|
||||||
require_once("data/event_listeners.php");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$all_events = array();
|
|
||||||
foreach(get_declared_classes() as $class) {
|
|
||||||
if(is_subclass_of($class, "Event")) {
|
|
||||||
$all_events[] = $class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach(get_declared_classes() as $class) {
|
|
||||||
$rclass = new ReflectionClass($class);
|
|
||||||
if($rclass->isAbstract()) {
|
|
||||||
// don't do anything
|
|
||||||
}
|
|
||||||
elseif(is_subclass_of($class, "SimpleExtension")) {
|
|
||||||
$c = new $class();
|
|
||||||
$c->i_am($c);
|
|
||||||
$my_events = array();
|
|
||||||
foreach(get_class_methods($c) as $method) {
|
|
||||||
if(substr($method, 0, 2) == "on") {
|
|
||||||
$my_events[] = substr($method, 2) . "Event";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_event_listener($c, $c->get_priority(), $my_events);
|
|
||||||
}
|
|
||||||
elseif(is_subclass_of($class, "Extension")) {
|
|
||||||
$c = new $class();
|
|
||||||
add_event_listener($c, $c->get_priority(), $all_events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(COMPILE_ELS) {
|
|
||||||
$p = "<"."?php\n";
|
|
||||||
|
|
||||||
foreach(get_declared_classes() as $class) {
|
|
||||||
$rclass = new ReflectionClass($class);
|
|
||||||
if($rclass->isAbstract()) {}
|
|
||||||
elseif(is_subclass_of($class, "SimpleExtension")) {
|
|
||||||
$p .= "\$$class = new $class(); ";
|
|
||||||
$p .= "\${$class}->i_am(\$$class);\n";
|
|
||||||
}
|
|
||||||
elseif(is_subclass_of($class, "Extension")) {
|
|
||||||
$p .= "\$$class = new $class();\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$p .= "\$_event_listeners = array(\n";
|
|
||||||
foreach($_event_listeners as $event => $listeners) {
|
|
||||||
$p .= "\t'$event' => array(\n";
|
|
||||||
foreach($listeners as $id => $listener) {
|
|
||||||
$p .= "\t\t$id => \$".get_class($listener).",\n";
|
|
||||||
}
|
|
||||||
$p .= "\t),\n";
|
|
||||||
}
|
|
||||||
$p .= ");\n";
|
|
||||||
|
|
||||||
$p .= "?".">";
|
|
||||||
file_put_contents("data/event_listeners.php", $p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx_log_endok();
|
|
||||||
ctx_log_endok("Initialisation");
|
ctx_log_endok("Initialisation");
|
||||||
|
|
||||||
|
|
||||||
ctx_log_start("Page generation");
|
ctx_log_start("Page generation");
|
||||||
// start the page generation waterfall
|
// start the page generation waterfall
|
||||||
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
||||||
$user = _get_user($config, $database);
|
$user = _get_user();
|
||||||
send_event(new InitExtEvent());
|
send_event(new InitExtEvent());
|
||||||
send_event(_get_page_request());
|
send_event(_get_page_request());
|
||||||
$page->display();
|
$page->display();
|
||||||
@ -220,22 +115,8 @@ try {
|
|||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
$version = VERSION;
|
|
||||||
$message = $e->getMessage();
|
|
||||||
//$trace = var_dump($e->getTrace());
|
|
||||||
header("HTTP/1.0 500 Internal Error");
|
|
||||||
echo '
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Internal error - SCore-'.$version.'</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Internal Error</h1>
|
|
||||||
<p>'.$message.'
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
';
|
|
||||||
if($database && $database->db) $database->db->rollback();
|
if($database && $database->db) $database->db->rollback();
|
||||||
|
_fatal_error($e);
|
||||||
ctx_log_ender();
|
ctx_log_ender();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user