root/devel/lib/engine.php

Revision 1540, 3.4 kB (checked in by renato, 10 months ago)

Setting prop svn:eol-style in another lot of files.

  • Property svn:eol-style set to native
Line 
1 <?php
2     // units/engine/main.php
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     // Message arrays
17     global $messages;
18     if (empty($messages)) { // might be set up already...
19         $messages = array();
20     }
21
22     // Add the site root to the metatags
23     global $metatags;
24     $metatags .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
25     // $metatags .= "     <base href=\"".url."\" />";
26
27     // Initialise array of functions
28     global $function;
29     $function = array();
30     
31     // Array of useful data
32     global $data;
33     $data = array();
34     
35     // Plug-in library functions
36     function run($context, $parameter = array()) {
37         global $function;
38         global $log;
39         global $actionlog;
40         global $errorlog;
41         global $messages;
42         global $data;
43         global $CFG;
44         
45         global $run_context;
46
47         static $code_cache;
48         static $use_cache;
49
50         if (!isset($use_cache)) $use_cache = ($CFG->debug > 7) ? false : true;
51         if ($use_cache && !isset($code_cache)) $code_cache = array();
52         //$code_cache=null; //turn off cache
53         
54         $run_result = false;
55         
56         if (isset($function[$context])) {
57             if (isset($_REQUEST['debug'])) {
58                 echo "<small>\{$context}</small>";
59             }
60             foreach($function[$context] as $include) {
61                 if (!is_readable($include)) {
62                     trigger_error(__FUNCTION__.": can not load elgg function $include", E_USER_ERROR);
63                 } else {
64                     if ($use_cache) {
65                         if (isset($code_cache[$context][$include])) {
66                             eval('?>'.$code_cache[$context][$include]);
67                             //echo "cache: run('$context')<br/>";
68                         } else {
69                             $code = @file_get_contents($include);
70                             // run code
71                             eval('?>'.$code);
72
73                             if (!isset($code_cache[$context])) $code_cache[$context] = array();
74                             // cache code
75                             $code_cache[$context][$include] = $code;
76                         }
77                     } else {
78                         include($include);
79                     }
80                 }
81             }
82         } else if (isset($_REQUEST['debug'])) {
83             echo "{<b>$context not found</b>}";
84         }
85
86         return $run_result;
87     }
88
89     // Time page execution
90     function timer($finish = false){
91         static $start_frac_sec, $start_sec, $end_frac_sec, $end_sec;
92         if($finish){
93             list($end_frac_sec,$end_sec) = explode(" ", microtime());
94             echo '<p style="font-size: smaller">This page took about ' .
95                 round(
96                     (
97                         ($end_sec - $start_sec)
98                         + ($end_frac_sec - $start_frac_sec)
99                     ),
100                 4) . " seconds to generate.</p>\n";
101         }else{
102             list($start_frac_sec,$start_sec) = explode(" ", microtime());
103         }
104     }
105     
106     timer();
107         
108     // Set default charset to UTF-8
109     @ini_set("default_charset","UTF-8");
110     header("Content-Type: text/html; charset=utf-8");
111
112 ?>
113
Note: See TracBrowser for help on using the browser.