| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
// units/engine/library.php |
|---|
| 4 |
// units/engine/function_init.php |
|---|
| 5 |
|
|---|
| 6 |
// Plug-in engine intialisation routines |
|---|
| 7 |
|
|---|
| 8 |
// Global variables |
|---|
| 9 |
global $log; |
|---|
| 10 |
global $errorlog; |
|---|
| 11 |
global $actionlog; |
|---|
| 12 |
$log = array(); |
|---|
| 13 |
$errorlog = array(); |
|---|
| 14 |
$actionlog = array(); |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
global $messages; |
|---|
| 18 |
if (empty($messages)) { |
|---|
| 19 |
$messages = array(); |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
global $metatags; |
|---|
| 24 |
$metatags .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n"; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
// Initialise array of functions |
|---|
| 28 |
global $function; |
|---|
| 29 |
$function = array(); |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
global $data; |
|---|
| 33 |
$data = array(); |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
global $menu; |
|---|
| 37 |
$menu = array(); |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
function run($context, $parameter = array()) { |
|---|
| 41 |
global $function; |
|---|
| 42 |
global $log; |
|---|
| 43 |
global $actionlog; |
|---|
| 44 |
global $errorlog; |
|---|
| 45 |
global $messages; |
|---|
| 46 |
global $data; |
|---|
| 47 |
global $CFG; |
|---|
| 48 |
|
|---|
| 49 |
global $run_context; |
|---|
| 50 |
|
|---|
| 51 |
static $code_cache; |
|---|
| 52 |
static $use_cache; |
|---|
| 53 |
|
|---|
| 54 |
if (!isset($use_cache)) $use_cache = ($CFG->debug > 7) ? false : true; |
|---|
| 55 |
if ($use_cache && !isset($code_cache)) $code_cache = array(); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
$run_result = false; |
|---|
| 59 |
|
|---|
| 60 |
if (isset($function[$context])) { |
|---|
| 61 |
if (isset($_REQUEST['debug'])) { |
|---|
| 62 |
echo "<small>\{$context}</small>"; |
|---|
| 63 |
} |
|---|
| 64 |
foreach($function[$context] as $include) { |
|---|
| 65 |
if (!is_readable($include)) { |
|---|
| 66 |
trigger_error(__FUNCTION__.": can not load elgg function $include", E_USER_ERROR); |
|---|
| 67 |
} else { |
|---|
| 68 |
if ($use_cache) { |
|---|
| 69 |
if (isset($code_cache[$context][$include])) { |
|---|
| 70 |
eval('?>'.$code_cache[$context][$include]); |
|---|
| 71 |
|
|---|
| 72 |
} else { |
|---|
| 73 |
$code = @file_get_contents($include); |
|---|
| 74 |
|
|---|
| 75 |
eval('?>'.$code); |
|---|
| 76 |
|
|---|
| 77 |
if (!isset($code_cache[$context])) $code_cache[$context] = array(); |
|---|
| 78 |
|
|---|
| 79 |
$code_cache[$context][$include] = $code; |
|---|
| 80 |
} |
|---|
| 81 |
} else { |
|---|
| 82 |
include($include); |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
} |
|---|
| 86 |
} else if (isset($_REQUEST['debug'])) { |
|---|
| 87 |
echo "{<b>$context not found</b>}"; |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
return $run_result; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
function timer($finish = false){ |
|---|
| 95 |
static $start_frac_sec, $start_sec, $end_frac_sec, $end_sec; |
|---|
| 96 |
if($finish){ |
|---|
| 97 |
list($end_frac_sec,$end_sec) = explode(" ", microtime()); |
|---|
| 98 |
echo '<p style="font-size: smaller">This page took about ' . |
|---|
| 99 |
round( |
|---|
| 100 |
( |
|---|
| 101 |
($end_sec - $start_sec) |
|---|
| 102 |
+ ($end_frac_sec - $start_frac_sec) |
|---|
| 103 |
), |
|---|
| 104 |
4) . " seconds to generate.</p>\n"; |
|---|
| 105 |
}else{ |
|---|
| 106 |
list($start_frac_sec,$start_sec) = explode(" ", microtime()); |
|---|
| 107 |
} |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
timer(); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
@ini_set("default_charset","UTF-8"); |
|---|
| 114 |
header("Content-Type: text/html; charset=utf-8"); |
|---|
| 115 |
|
|---|
| 116 |
?> |
|---|
| 117 |
|
|---|