Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
7ed7f4bbb8
@ -30,7 +30,32 @@ class PageRequestEvent extends Event {
|
|||||||
var $arg_count;
|
var $arg_count;
|
||||||
var $part_count;
|
var $part_count;
|
||||||
|
|
||||||
public function __construct($args) {
|
public function __construct($path) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// trim starting slashes
|
||||||
|
while(strlen($path) > 0 && $path[0] == '/') {
|
||||||
|
$path = substr($path, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if path is not specified, use the default front page
|
||||||
|
if(strlen($path) === 0) {
|
||||||
|
$path = $config->get_string('front_page');
|
||||||
|
}
|
||||||
|
|
||||||
|
// break the path into parts
|
||||||
|
$args = explode('/', $path);
|
||||||
|
|
||||||
|
// voodoo so that an arg can contain a slash; is
|
||||||
|
// this still needed?
|
||||||
|
if(strpos($path, "^") !== FALSE) {
|
||||||
|
$unescaped = array();
|
||||||
|
foreach($parts as $part) {
|
||||||
|
$unescaped[] = _decaret($part);
|
||||||
|
}
|
||||||
|
$args = $unescaped;
|
||||||
|
}
|
||||||
|
|
||||||
$this->args = $args;
|
$this->args = $args;
|
||||||
$this->arg_count = count($args);
|
$this->arg_count = count($args);
|
||||||
}
|
}
|
||||||
@ -110,6 +135,62 @@ class PageRequestEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent when index.php is called from the command line
|
||||||
|
*/
|
||||||
|
class CommandEvent extends Event {
|
||||||
|
public $cmd = "help";
|
||||||
|
public $args = array();
|
||||||
|
|
||||||
|
public function __construct(/*array(string)*/ $args) {
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$opts = array();
|
||||||
|
$log_level = SCORE_LOG_WARNING;
|
||||||
|
for($i=1; $i<count($args); $i++) {
|
||||||
|
switch($args[$i]) {
|
||||||
|
case '-u':
|
||||||
|
$user = User::by_name($args[++$i]);
|
||||||
|
if(is_null($user)) {
|
||||||
|
die("Unknown user");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '-q':
|
||||||
|
$log_level += 10;
|
||||||
|
break;
|
||||||
|
case '-v':
|
||||||
|
$log_level -= 10;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$opts[] = $args[$i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define("CLI_LOG_LEVEL", $log_level);
|
||||||
|
|
||||||
|
if(count($opts) > 0) {
|
||||||
|
$this->cmd = $opts[0];
|
||||||
|
$this->args = array_slice($opts, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "\n";
|
||||||
|
print "Usage: php {$args[0]} [flags] [command]\n";
|
||||||
|
print "\n";
|
||||||
|
print "Flags:\n";
|
||||||
|
print " -u [username]\n";
|
||||||
|
print " Log in as the specified user\n";
|
||||||
|
print " -q / -v\n";
|
||||||
|
print " Be quieter / more verbose\n";
|
||||||
|
print " Scale is debug - info - warning - error - critical\n";
|
||||||
|
print " Default is to show warnings and above\n";
|
||||||
|
print " \n";
|
||||||
|
print "Currently known commands:\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A signal that some text needs formatting, the event carries
|
* A signal that some text needs formatting, the event carries
|
||||||
* both the text and the result
|
* both the text and the result
|
||||||
|
@ -25,8 +25,6 @@ _d("DEBUG", false); // boolean print various debugging details
|
|||||||
_d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log
|
_d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log
|
||||||
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
||||||
_d("CONTEXT", null); // string file to log performance data into
|
_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("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("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("SPEED_HAX", false); // boolean do some questionable things in the name of performance
|
||||||
|
@ -155,7 +155,5 @@ new UserClass("admin", "base", array(
|
|||||||
"protected" => True,
|
"protected" => True,
|
||||||
));
|
));
|
||||||
|
|
||||||
if(file_exists("data/config/user-classes.conf.php")) {
|
@include_once "data/config/user-classes.conf.php";
|
||||||
require_once("data/config/user-classes.conf.php");
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
@ -285,7 +285,7 @@ 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("/".basename($_SERVER["SCRIPT_FILENAME"]), "", $full);
|
$base = str_replace(basename($_SERVER["SCRIPT_FILENAME"]), "", $full);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$base = "./".basename($_SERVER["SCRIPT_FILENAME"])."?q=";
|
$base = "./".basename($_SERVER["SCRIPT_FILENAME"])."?q=";
|
||||||
@ -386,6 +386,13 @@ function mtimefile($file) {
|
|||||||
return "$data_href/$file?$mtime";
|
return "$data_href/$file?$mtime";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_theme() {
|
||||||
|
global $config;
|
||||||
|
$theme = $config->get_string("theme", "default");
|
||||||
|
if(!file_exists("themes/$theme")) $theme = "default";
|
||||||
|
return $theme;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* like glob, with support for matching very long patterns with braces
|
* like glob, with support for matching very long patterns with braces
|
||||||
*/
|
*/
|
||||||
@ -541,12 +548,8 @@ date and you should plan on moving elsewhere.
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function check_cli() {
|
function is_cli() {
|
||||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
return (PHP_SAPI === 'cli');
|
||||||
print "This script is to be run from the command line only.";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -812,6 +815,41 @@ function transload($url, $mfile) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$_included = array();
|
||||||
|
/**
|
||||||
|
* Get the active contents of a .php file
|
||||||
|
*/
|
||||||
|
function manual_include($fname) {
|
||||||
|
if(!file_exists($fname)) return;
|
||||||
|
|
||||||
|
global $_included;
|
||||||
|
if(in_array($fname, $_included)) return;
|
||||||
|
$_included[] = $fname;
|
||||||
|
|
||||||
|
print "$fname\n";
|
||||||
|
|
||||||
|
$text = file_get_contents($fname);
|
||||||
|
|
||||||
|
// we want one continuous file
|
||||||
|
$text = str_replace('<'.'?php', '', $text);
|
||||||
|
$text = str_replace('?'.'>', '', $text);
|
||||||
|
|
||||||
|
// most requires are built-in, but we want /lib separately
|
||||||
|
$text = str_replace('require_', '// require_', $text);
|
||||||
|
$text = str_replace('// require_once "lib', 'require_once "lib', $text);
|
||||||
|
|
||||||
|
// @include_once is used for user-creatable config files
|
||||||
|
$text = preg_replace('/@include_once "(.*)";/e', "manual_include('$1')", $text);
|
||||||
|
|
||||||
|
// wibble the defines for HipHop's sake
|
||||||
|
$text = str_replace('function _d(', '// function _messed_d(', $text);
|
||||||
|
$text = preg_replace('/_d\("(.*)", (.*)\);/', 'if(!defined("$1")) define("$1", $2);', $text);
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||||
* Logging convenience *
|
* Logging convenience *
|
||||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
@ -836,6 +874,9 @@ define("SCORE_LOG_NOTSET", 0);
|
|||||||
*/
|
*/
|
||||||
function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null) {
|
function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message, $flash=null) {
|
||||||
send_event(new LogEvent($section, $priority, $message));
|
send_event(new LogEvent($section, $priority, $message));
|
||||||
|
if(is_cli() && ($priority >= CLI_LOG_LEVEL)) {
|
||||||
|
print date("c")." $section: $message\n";
|
||||||
|
}
|
||||||
if($flash === True) {
|
if($flash === True) {
|
||||||
flash_message($message);
|
flash_message($message);
|
||||||
}
|
}
|
||||||
@ -1120,13 +1161,12 @@ function _sanitise_environment() {
|
|||||||
$_COOKIE = _stripslashes_r($_COOKIE);
|
$_COOKIE = _stripslashes_r($_COOKIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(php_sapi_name() === "cli") {
|
if(is_cli()) {
|
||||||
global $argc, $argv;
|
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||||
|
die("CLI with remote addr? Confused, not taking the risk.");
|
||||||
|
}
|
||||||
$_SERVER['REMOTE_ADDR'] = "0.0.0.0";
|
$_SERVER['REMOTE_ADDR'] = "0.0.0.0";
|
||||||
$_SERVER['HTTP_HOST'] = "<cli command>";
|
$_SERVER['HTTP_HOST'] = "<cli command>";
|
||||||
if($argc > 1) {
|
|
||||||
$_GET['q'] = $argv[1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,46 +1289,6 @@ function _decaret($str) {
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _get_query_parts() {
|
|
||||||
if(isset($_GET["q"])) {
|
|
||||||
$path = $_GET["q"];
|
|
||||||
}
|
|
||||||
else if(isset($_SERVER["PATH_INFO"])) {
|
|
||||||
$path = $_SERVER["PATH_INFO"];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$path = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
while(strlen($path) > 0 && $path[0] == '/') {
|
|
||||||
$path = substr($path, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$parts = explode('/', $path);
|
|
||||||
|
|
||||||
if(strpos($path, "^") === FALSE) {
|
|
||||||
return $parts;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$unescaped = array();
|
|
||||||
foreach($parts as $part) {
|
|
||||||
$unescaped[] = _decaret($part);
|
|
||||||
}
|
|
||||||
return $unescaped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _get_page_request() {
|
|
||||||
global $config;
|
|
||||||
$args = _get_query_parts();
|
|
||||||
|
|
||||||
if(empty($args) || strlen($args[0]) === 0) {
|
|
||||||
$args = explode('/', $config->get_string('front_page'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PageRequestEvent($args);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _get_user() {
|
function _get_user() {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
$user = null;
|
$user = null;
|
||||||
@ -1307,100 +1307,6 @@ function _get_user() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$_cache_memcache = false;
|
|
||||||
$_cache_key = null;
|
|
||||||
$_cache_filename = null;
|
|
||||||
|
|
||||||
function _cache_active() {
|
|
||||||
return (
|
|
||||||
(CACHE_MEMCACHE || CACHE_DIR) &&
|
|
||||||
$_SERVER["REQUEST_METHOD"] == "GET" &&
|
|
||||||
!get_prefixed_cookie("session") &&
|
|
||||||
!get_prefixed_cookie("nocache")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _cache_log($text) {
|
|
||||||
$fp = @fopen("data/cache.log", "a");
|
|
||||||
if($fp) {
|
|
||||||
fputs($fp, $text);
|
|
||||||
fclose($fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _start_cache() {
|
|
||||||
global $_cache_memcache, $_cache_key, $_cache_filename;
|
|
||||||
|
|
||||||
if(_cache_active()) {
|
|
||||||
if(CACHE_MEMCACHE) {
|
|
||||||
$_cache_memcache = new Memcache;
|
|
||||||
$_cache_memcache->pconnect('localhost', 11211);
|
|
||||||
$_cache_key = "uri:".$_SERVER["REQUEST_URI"];
|
|
||||||
$data = $_cache_memcache->get($_cache_key);
|
|
||||||
if(DEBUG) {
|
|
||||||
$stat = $zdata ? "hit" : "miss";
|
|
||||||
_cache_log(time() . " " . sprintf(" %-4s ", $stat) . $_cache_key . "\n");
|
|
||||||
}
|
|
||||||
if($data) {
|
|
||||||
header("Content-type: text/html");
|
|
||||||
print $data;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(CACHE_DIR) {
|
|
||||||
$_cache_hash = md5($_SERVER["QUERY_STRING"]);
|
|
||||||
$ab = substr($_cache_hash, 0, 2);
|
|
||||||
$cd = substr($_cache_hash, 2, 2);
|
|
||||||
$_cache_filename = data_path("http_cache/$ab/$cd/$_cache_hash");
|
|
||||||
@chmod(data_path('http_cache'), 750);
|
|
||||||
|
|
||||||
if(file_exists($_cache_filename) && (filemtime($_cache_filename) > time() - 3600)) {
|
|
||||||
$gmdate_mod = gmdate('D, d M Y H:i:s', filemtime($_cache_filename)) . ' GMT';
|
|
||||||
|
|
||||||
if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
|
|
||||||
$if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]);
|
|
||||||
|
|
||||||
if($if_modified_since == $gmdate_mod) {
|
|
||||||
header("HTTP/1.0 304 Not Modified");
|
|
||||||
header("Content-type: text/html");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
header("Content-type: text/html");
|
|
||||||
header('Last-Modified: '.$gmdate_mod);
|
|
||||||
$zdata = @file_get_contents($_cache_filename);
|
|
||||||
if(CACHE_MEMCACHE) {
|
|
||||||
$_cache_memcache->set($_cache_hash, $zdata, 0, 600);
|
|
||||||
}
|
|
||||||
$data = @gzuncompress($zdata);
|
|
||||||
if($data) {
|
|
||||||
print $data;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ob_start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _end_cache() {
|
|
||||||
global $_cache_memcache, $_cache_key, $_cache_filename;
|
|
||||||
|
|
||||||
if(_cache_active()) {
|
|
||||||
$data = ob_get_contents();
|
|
||||||
if(CACHE_MEMCACHE) {
|
|
||||||
$_cache_memcache->set($_cache_key, $data, 0, 600);
|
|
||||||
}
|
|
||||||
if(CACHE_DIR) {
|
|
||||||
$zdata = gzcompress($data, 2);
|
|
||||||
file_put_contents($_cache_filename, $zdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||||
* Code coverage *
|
* Code coverage *
|
||||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
@ -69,6 +69,18 @@ class AdminPage extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCommand(CommandEvent $event) {
|
||||||
|
if($event->cmd == "help") {
|
||||||
|
print " get-page [query string]\n";
|
||||||
|
print " eg 'get-page post/list'\n\n";
|
||||||
|
}
|
||||||
|
if($event->cmd == "get-page") {
|
||||||
|
global $page;
|
||||||
|
send_event(new PageRequestEvent($event->args[0]));
|
||||||
|
$page->display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function onAdminBuilding(AdminBuildingEvent $event) {
|
public function onAdminBuilding(AdminBuildingEvent $event) {
|
||||||
$this->theme->display_page();
|
$this->theme->display_page();
|
||||||
$this->theme->display_form();
|
$this->theme->display_form();
|
||||||
|
@ -27,6 +27,18 @@ class BulkAdd extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCommand(CommandEvent $event) {
|
||||||
|
if($event->cmd == "help") {
|
||||||
|
print " bulk-add [directory]\n";
|
||||||
|
print " Import this directory\n\n";
|
||||||
|
}
|
||||||
|
if($event->cmd == "bulk-add") {
|
||||||
|
if(count($event->args) == 1) {
|
||||||
|
$this->add_dir($event->args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function onAdminBuilding(AdminBuildingEvent $event) {
|
public function onAdminBuilding(AdminBuildingEvent $event) {
|
||||||
$this->theme->display_admin_block();
|
$this->theme->display_admin_block();
|
||||||
}
|
}
|
||||||
@ -75,10 +87,16 @@ class BulkAdd extends Extension {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$pathinfo = pathinfo($fullpath);
|
$pathinfo = pathinfo($fullpath);
|
||||||
$tags = $subdir;
|
$matches = array();
|
||||||
$tags = str_replace("/", " ", $tags);
|
if(preg_match("/\d+ - (.*)\.([a-zA-Z]+)/", $pathinfo["basename"], $matches)) {
|
||||||
$tags = str_replace("__", " ", $tags);
|
$tags = $matches[1];
|
||||||
$tags = trim($tags);
|
}
|
||||||
|
else {
|
||||||
|
$tags = $subdir;
|
||||||
|
$tags = str_replace("/", " ", $tags);
|
||||||
|
$tags = str_replace("__", " ", $tags);
|
||||||
|
$tags = trim($tags);
|
||||||
|
}
|
||||||
$list .= "<br>".html_escape("$shortpath (".str_replace(" ", ", ", $tags).")... ");
|
$list .= "<br>".html_escape("$shortpath (".str_replace(" ", ", ", $tags).")... ");
|
||||||
try{
|
try{
|
||||||
$this->add_image($fullpath, $pathinfo["basename"], $tags);
|
$this->add_image($fullpath, $pathinfo["basename"], $tags);
|
||||||
|
@ -128,6 +128,17 @@ class ExtManager extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCommand(CommandEvent $event) {
|
||||||
|
if($event->cmd == "help") {
|
||||||
|
print " disable-all-ext\n";
|
||||||
|
print " disable all extensions\n\n";
|
||||||
|
}
|
||||||
|
if($event->cmd == "disable-all-ext") {
|
||||||
|
$this->write_config(array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||||
global $user;
|
global $user;
|
||||||
if($user->can("manage_extension_list")) {
|
if($user->can("manage_extension_list")) {
|
||||||
@ -167,12 +178,23 @@ class ExtManager extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->write_config($extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function write_config($extras) {
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
"data/config/extensions.conf.php",
|
"data/config/extensions.conf.php",
|
||||||
'<'.'?php'."\n".
|
'<'.'?php'."\n".
|
||||||
'define("EXTRA_EXTS", "'.implode(",", $extras).'");'."\n".
|
'define("EXTRA_EXTS", "'.implode(",", $extras).'");'."\n".
|
||||||
'?'.">"
|
'?'.">"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// when the list of active extensions changes, we can be
|
||||||
|
// pretty sure that the list of who reacts to what will
|
||||||
|
// change too
|
||||||
|
if(file_exists("data/cache/event_listeners.php")) {
|
||||||
|
unlink("data/cache/event_listeners.php");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -221,7 +221,7 @@ class IPBan extends Extension {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_error("ipban", "block() called but no bans matched");
|
log_error("ipban", "block($remote) called but no bans matched");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
@ -261,8 +261,8 @@ class IPBan extends Extension {
|
|||||||
if($cached) return $cached;
|
if($cached) return $cached;
|
||||||
|
|
||||||
$bans = $this->get_active_bans();
|
$bans = $this->get_active_bans();
|
||||||
$ips = array("0.0.0.0" => false);
|
$ips = array(); # "0.0.0.0" => false);
|
||||||
$nets = array("0.0.0.0/32" => false);
|
$nets = array(); # "0.0.0.0/32" => false);
|
||||||
foreach($bans as $row) {
|
foreach($bans as $row) {
|
||||||
if(strstr($row['ip'], '/')) {
|
if(strstr($row['ip'], '/')) {
|
||||||
$nets[$row['ip']] = true;
|
$nets[$row['ip']] = true;
|
||||||
|
17
index.php
17
index.php
@ -62,7 +62,6 @@ if(COVERAGE) {
|
|||||||
}
|
}
|
||||||
_version_check();
|
_version_check();
|
||||||
_sanitise_environment();
|
_sanitise_environment();
|
||||||
_start_cache();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// load base files
|
// load base files
|
||||||
@ -82,9 +81,7 @@ try {
|
|||||||
|
|
||||||
// load the theme parts
|
// load the theme parts
|
||||||
ctx_log_start("Loading themelets");
|
ctx_log_start("Loading themelets");
|
||||||
$_theme = $config->get_string("theme", "default");
|
foreach(_get_themelet_files(get_theme()) as $themelet) {
|
||||||
if(!file_exists("themes/$_theme")) $_theme = "default";
|
|
||||||
foreach(_get_themelet_files($_theme) as $themelet) {
|
|
||||||
require_once $themelet;
|
require_once $themelet;
|
||||||
}
|
}
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
@ -95,13 +92,17 @@ try {
|
|||||||
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
||||||
$user = _get_user();
|
$user = _get_user();
|
||||||
send_event(new InitExtEvent());
|
send_event(new InitExtEvent());
|
||||||
send_event(_get_page_request());
|
if(!is_cli()) { // web request
|
||||||
$page->display();
|
send_event(new PageRequestEvent(@$_GET["q"]));
|
||||||
|
$page->display();
|
||||||
|
}
|
||||||
|
else { // command line request
|
||||||
|
send_event(new CommandEvent($argv));
|
||||||
|
}
|
||||||
|
|
||||||
$database->db->commit();
|
|
||||||
// saving cache data and profiling data to disk can happen later
|
// saving cache data and profiling data to disk can happen later
|
||||||
if(function_exists("fastcgi_finish_request")) fastcgi_finish_request();
|
if(function_exists("fastcgi_finish_request")) fastcgi_finish_request();
|
||||||
_end_cache();
|
$database->db->commit();
|
||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
|
@ -40,7 +40,7 @@ $(document).ready(function() {
|
|||||||
try {
|
try {
|
||||||
var sidebar_hidden = ($.cookie("ui-sidebar-hidden") || $.cookie("sidebar-hidden") || "").split("|");
|
var sidebar_hidden = ($.cookie("ui-sidebar-hidden") || $.cookie("sidebar-hidden") || "").split("|");
|
||||||
for(var i in sidebar_hidden) {
|
for(var i in sidebar_hidden) {
|
||||||
if(sidebar_hidden[i].length > 0) {
|
if(sidebar_hidden.hasOwnProperty(i) && sidebar_hidden[i].length > 0) {
|
||||||
$(sidebar_hidden[i]+" .blockbody").hide();
|
$(sidebar_hidden[i]+" .blockbody").hide();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user