global management

This commit is contained in:
Shish 2015-08-02 19:29:25 +01:00
parent c6cf4fa339
commit e2b6f2c2dd
5 changed files with 18 additions and 12 deletions

View file

@ -4,6 +4,8 @@
* actually do anything as far as the app is concerned
*/
global $config, $database, $user, $page;
require_once "core/sys_config.inc.php";
require_once "core/util.inc.php";
require_once "lib/context.php";
@ -23,6 +25,8 @@ foreach($files as $filename) {
require_once $filename;
}
}
unset($files);
unset($filename);
ctx_log_endok();
// connect to the database
@ -36,6 +40,7 @@ ctx_log_start("Loading themelets");
foreach(_get_themelet_files(get_theme()) as $themelet) {
require_once $themelet;
}
unset($themelet);
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
ctx_log_endok();

View file

@ -23,7 +23,6 @@
* Classes *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
$tag_n = 0; // temp hack
$_flexihash = null;
$_fh_last_opts = null;
$order_sql = null; // this feels ugly
@ -40,6 +39,8 @@ require_once "lib/flexihash.php";
* other supported upload type.
*/
class Image {
private static $tag_n = 0; // temp hack
/** @var null|int */
public $id = null;
@ -967,13 +968,10 @@ class Image {
$sql = "0";
$terms = array();
foreach($tag_querylets as $tq) {
global $tag_n;
$sign = $tq->positive ? "+" : "-";
//$sql .= " $sign (tag LIKE :tag$tag_n)";
$sql .= ' '.$sign.' (tag LIKE :tag'.$tag_n.')';
//$terms["tag$tag_n"] = $tq->tag;
$terms['tag'.$tag_n] = $tq->tag;
$tag_n++;
$sql .= ' '.$sign.' (tag LIKE :tag'.Image::$tag_n.')';
$terms['tag'.Image::$tag_n] = $tq->tag;
Image::$tag_n++;
if($sign === "+") $positive_tag_count++;
else $negative_tag_count++;
@ -1084,7 +1082,7 @@ class Image {
WHERE 1=0
");
}
$tag_n = 0;
Image::$tag_n = 0;
return $query;
}
}

View file

@ -2,6 +2,7 @@
/**
* @global UserClass[] $_user_classes
*/
global $_user_classes;
$_user_classes = array();
/**

View file

@ -1052,7 +1052,6 @@ function findHeader ($headers, $name) {
return $header;
}
$_included = array();
/**
* Get the active contents of a .php file
*
@ -1060,13 +1059,13 @@ $_included = array();
* @return string|null
*/
function manual_include($fname) {
global $_included;
static $included = array();
if(!file_exists($fname)) return null;
if(in_array($fname, $_included)) return null;
if(in_array($fname, $included)) return null;
$_included[] = $fname;
$included[] = $fname;
print "$fname\n";
@ -1380,6 +1379,7 @@ function path_to_tags($path) {
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** @private */
global $_event_listeners;
$_event_listeners = array();
/**
@ -1401,6 +1401,7 @@ function add_event_listener(Extension $extension, $pos=50, $events=array()) {
}
/** @private */
global $_event_count;
$_event_count = 0;
/**

View file

@ -9,6 +9,7 @@ if(preg_match('/\/_(images|thumbs)\/([0-9a-f]{32}).*$/', $_SERVER["REQUEST_URI"]
print(file_get_contents(warehouse_path($matches[1], $matches[2])));
return true;
}
unset($matches);
// use the default handler (serve static files, interpret php files)
if(preg_match('/\.(?:png|jpg|jpeg|gif|css|js|php)(\?.*)?$/', $_SERVER["REQUEST_URI"])) {