@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | * @param string $vars =null multiple values to replace the placeholders |
24 | 24 | * @return string translated message with placeholders replaced |
25 | 25 | */ |
26 | -function try_lang($key,$vars=null) |
|
26 | +function try_lang($key, $vars = null) |
|
27 | 27 | { |
28 | - static $varnames = array('%1','%2','%3','%4'); |
|
28 | + static $varnames = array('%1', '%2', '%3', '%4'); |
|
29 | 29 | |
30 | - if(!is_array($vars)) |
|
30 | + if (!is_array($vars)) |
|
31 | 31 | { |
32 | 32 | $vars = func_get_args(); |
33 | - array_shift($vars); // remove $key |
|
33 | + array_shift($vars); // remove $key |
|
34 | 34 | } |
35 | - return class_exists('EGroupware\Api\Translations',false) ? Api\Translation::translate($key,$vars) : str_replace($varnames,$vars,$key); |
|
35 | + return class_exists('EGroupware\Api\Translations', false) ? Api\Translation::translate($key, $vars) : str_replace($varnames, $vars, $key); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param Exception|Error $e |
42 | 42 | * @param string &$headline |
43 | 43 | */ |
44 | -function _egw_log_exception($e,&$headline=null) |
|
44 | +function _egw_log_exception($e, &$headline = null) |
|
45 | 45 | { |
46 | 46 | $trace = explode("\n", $e->getTraceAsString()); |
47 | 47 | if ($e instanceof Api\Exception\NoPermission) |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | elseif ($e instanceof Api\Exception\WrongUserinput) |
56 | 56 | { |
57 | - $headline = ''; // message contains the whole message, it's usually no real error but some input validation |
|
57 | + $headline = ''; // message contains the whole message, it's usually no real error but some input validation |
|
58 | 58 | } |
59 | 59 | elseif ($e instanceof egw_exception_warning) |
60 | 60 | { |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | } |
68 | 68 | // log exception to error log, if not running as cli, |
69 | 69 | // which outputs the error_log to stderr and therefore output it twice to the user |
70 | - if(isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli') |
|
70 | + if (isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli') |
|
71 | 71 | { |
72 | 72 | error_log($headline.($e instanceof egw_exception_warning ? ': ' : ' ('.get_class($e).'): ').$e->getMessage()); |
73 | - foreach($trace as $line) |
|
73 | + foreach ($trace as $line) |
|
74 | 74 | { |
75 | 75 | error_log($line); |
76 | 76 | } |
77 | 77 | error_log('# Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']. |
78 | - ', Request='.$_SERVER['REQUEST_METHOD'].' '.($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']. |
|
78 | + ', Request='.$_SERVER['REQUEST_METHOD'].' '.($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']. |
|
79 | 79 | ', User-agent='.$_SERVER['HTTP_USER_AGENT']); |
80 | 80 | } |
81 | 81 | } |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | } |
97 | 97 | // logging all exceptions to the error_log (if not cli) and get headline |
98 | 98 | $headline = null; |
99 | - _egw_log_exception($e,$headline); |
|
99 | + _egw_log_exception($e, $headline); |
|
100 | 100 | |
101 | 101 | // exception handler for cli (command line interface) clients, no html, no logging |
102 | - if(!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli') |
|
102 | + if (!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli') |
|
103 | 103 | { |
104 | 104 | echo ($headline ? $headline.': ' : '').$e->getMessage()."\n"; |
105 | 105 | if ($GLOBALS['egw_info']['server']['exception_show_trace']) |
106 | 106 | { |
107 | 107 | echo $e->getTraceAsString()."\n"; |
108 | 108 | } |
109 | - exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code |
|
109 | + exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code |
|
110 | 110 | } |
111 | 111 | // regular GUI exception |
112 | 112 | if (!isset($GLOBALS['egw_info']['flags']['no_exception_handler'])) |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | $message .= "</pre>\n"; |
124 | 124 | if (is_a($e, 'EGroupware\Api\Db\Exception\Setup')) |
125 | 125 | { |
126 | - $setup_dir = str_replace(array('home/index.php','index.php'),'setup/',$_SERVER['PHP_SELF']); |
|
126 | + $setup_dir = str_replace(array('home/index.php', 'index.php'), 'setup/', $_SERVER['PHP_SELF']); |
|
127 | 127 | $message .= '<a href="'.$setup_dir.'">Run setup to install or configure EGroupware.</a>'; |
128 | 128 | } |
129 | - elseif (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->session) && method_exists($GLOBALS['egw'],'link')) |
|
129 | + elseif (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->session) && method_exists($GLOBALS['egw'], 'link')) |
|
130 | 130 | { |
131 | 131 | $message .= '<p><a href="'.$GLOBALS['egw']->link('/index.php').'">'.try_lang('Click here to resume your eGroupWare Session.').'</a></p>'; |
132 | 132 | } |
133 | 133 | if (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->framework)) |
134 | 134 | { |
135 | - $GLOBALS['egw']->framework->render($message,$headline); |
|
135 | + $GLOBALS['egw']->framework->render($message, $headline); |
|
136 | 136 | } |
137 | 137 | else |
138 | 138 | { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | // exception handler sending message back to the client as basic auth message |
143 | - elseif($GLOBALS['egw_info']['flags']['no_exception_handler'] == 'basic_auth') |
|
143 | + elseif ($GLOBALS['egw_info']['flags']['no_exception_handler'] == 'basic_auth') |
|
144 | 144 | { |
145 | 145 | $error = str_replace(array("\r", "\n"), array('', ' | '), $e->getMessage()); |
146 | 146 | header('WWW-Authenticate: Basic realm="'.$headline.' '.$error.'"'); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @link http://www.php.net/manual/en/function.set-error-handler.php |
166 | 166 | * @throws ErrorException |
167 | 167 | */ |
168 | -function egw_error_handler ($errno, $errstr, $errfile, $errline) |
|
168 | +function egw_error_handler($errno, $errstr, $errfile, $errline) |
|
169 | 169 | { |
170 | 170 | switch ($errno) |
171 | 171 | { |
@@ -188,7 +188,9 @@ |
||
188 | 188 | /** |
189 | 189 | * Used internally to trace warnings |
190 | 190 | */ |
191 | -class egw_exception_warning extends Exception {} |
|
191 | +class egw_exception_warning extends Exception |
|
192 | +{ |
|
193 | +} |
|
192 | 194 | |
193 | 195 | // install our error-handler only for catchable fatal errors and warnings |
194 | 196 | // following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @param array &$var reference of array to check |
21 | 21 | * @param string $name ='' name of the array |
22 | 22 | */ |
23 | -function _check_script_tag(&$var,$name='') |
|
23 | +function _check_script_tag(&$var, $name = '') |
|
24 | 24 | { |
25 | - static $preg=null; |
|
25 | + static $preg = null; |
|
26 | 26 | //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; |
27 | 27 | if (!isset($preg)) $preg = |
28 | 28 | // forbidden tags like iframe or script |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | '<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i'; |
36 | 36 | if (is_array($var)) |
37 | 37 | { |
38 | - foreach($var as $key => $val) |
|
38 | + foreach ($var as $key => $val) |
|
39 | 39 | { |
40 | 40 | if (is_array($val)) |
41 | 41 | { |
42 | - _check_script_tag($var[$key],$name.'['.$key.']'); |
|
42 | + _check_script_tag($var[$key], $name.'['.$key.']'); |
|
43 | 43 | } |
44 | - elseif(strpos($val, '<') !== false) // speedup: ignore everything without < |
|
44 | + elseif (strpos($val, '<') !== false) // speedup: ignore everything without < |
|
45 | 45 | { |
46 | - if (preg_match($preg,$val)) |
|
46 | + if (preg_match($preg, $val)) |
|
47 | 47 | { |
48 | 48 | // special handling for $_POST[json_data], to decend into it's decoded content, fixing json direct might break json syntax |
49 | 49 | if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true))) |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // attempt to clean the thing |
58 | 58 | $var[$key] = $val = Api\Html\HtmLawed::purify($val); |
59 | 59 | // check if we succeeded, if not drop the var anyway, keep the egw_unset_var in any case |
60 | - if (preg_match($preg,$val)) |
|
60 | + if (preg_match($preg, $val)) |
|
61 | 61 | { |
62 | 62 | error_log("*** _check_script_tag($name): unset(${name}[$key]) with value $val***"); |
63 | 63 | unset($var[$key]); |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | die("<p style='color: ".($num_failed?'red':'black')."'>Tests finished: $num_failed / $total failed</p>"); |
170 | 170 | }*/ |
171 | 171 | |
172 | -foreach(array('_GET','_POST','_REQUEST','HTTP_GET_VARS','HTTP_POST_VARS') as $n => $where) |
|
172 | +foreach (array('_GET', '_POST', '_REQUEST', 'HTTP_GET_VARS', 'HTTP_POST_VARS') as $n => $where) |
|
173 | 173 | { |
174 | 174 | $pregs = array( |
175 | 175 | 'order' => '/^[a-zA-Z0-9_,]*$/', |
176 | 176 | 'sort' => '/^(ASC|DESC|asc|desc|0|1|2|3|4|5|6|7){0,1}$/', |
177 | 177 | ); |
178 | - foreach(array('order','sort') as $name) |
|
178 | + foreach (array('order', 'sort') as $name) |
|
179 | 179 | { |
180 | - if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name],$GLOBALS[$where][$name])) |
|
180 | + if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name], $GLOBALS[$where][$name])) |
|
181 | 181 | { |
182 | 182 | $GLOBALS[$where][$name] = ''; |
183 | 183 | } |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | // speeds up the execusion a bit |
187 | 187 | if (isset($GLOBALS[$where]) && is_array($GLOBALS[$where]) && ($n < 2 || isset($GLOBALS['egw_unset_vars']))) |
188 | 188 | { |
189 | - _check_script_tag($GLOBALS[$where],$where); |
|
189 | + _check_script_tag($GLOBALS[$where], $where); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | //if (is_array($GLOBALS['egw_unset_vars'])) { echo "egw_unset_vars=<pre>".htmlspecialchars(print_r($GLOBALS['egw_unset_vars'],true))."</pre>"; exit; } |
193 | 193 | |
194 | 194 | // $GLOBALS[egw_info][flags][currentapp] and die if it contains something nasty or unexpected |
195 | 195 | if (isset($GLOBALS['egw_info']) && isset($GLOBALS['egw_info']['flags']) && |
196 | - isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/',$GLOBALS['egw_info']['flags']['currentapp'])) |
|
196 | + isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/', $GLOBALS['egw_info']['flags']['currentapp'])) |
|
197 | 197 | { |
198 | 198 | error_log(__FILE__.': '.__LINE__.' Invalid $GLOBALS[egw_info][flags][currentapp]='.array2string($GLOBALS['egw_info']['flags']['currentapp']).', $_SERVER[REQUEST_URI]='.array2string($_SERVER[REQUEST_URI])); |
199 | 199 | die('Invalid $GLOBALS[egw_info][flags][currentapp]!'); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | die('GLOBALS overwrite detected!!!'); |
212 | 212 | } |
213 | 213 | // unregister all globals |
214 | - $noUnset = array('GLOBALS','_GET','_POST','_COOKIE','_SERVER','_ENV','_FILES','xajax'); |
|
215 | - foreach(array_unique(array_merge( |
|
216 | - array_keys($_GET),array_keys($_POST),array_keys($_COOKIE),array_keys($_SERVER),array_keys($_ENV),array_keys($_FILES), |
|
214 | + $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_SERVER', '_ENV', '_FILES', 'xajax'); |
|
215 | + foreach (array_unique(array_merge( |
|
216 | + array_keys($_GET), array_keys($_POST), array_keys($_COOKIE), array_keys($_SERVER), array_keys($_ENV), array_keys($_FILES), |
|
217 | 217 | isset($_SESSION) && is_array($_SESSION) ? array_keys($_SESSION) : array())) as $k) |
218 | 218 | { |
219 | - if (!in_array($k,$noUnset) && isset($GLOBALS[$k])) |
|
219 | + if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) |
|
220 | 220 | { |
221 | 221 | unset($GLOBALS[$k]); |
222 | 222 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | preg_match('/(^|;|{)[OC]:\d+:"/', $str)) |
247 | 247 | { |
248 | 248 | error_log(__METHOD__."('$str') contains objects --> return NULL"); |
249 | - return null; // null, not false, to not trigger behavior of returning string itself to app code |
|
249 | + return null; // null, not false, to not trigger behavior of returning string itself to app code |
|
250 | 250 | } |
251 | 251 | return unserialize($str); |
252 | 252 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param boolean $allow_not_serialized =false true: return $str as is, if it is no serialized array |
318 | 318 | * @return array|str|false |
319 | 319 | */ |
320 | -function json_php_unserialize($str, $allow_not_serialized=false) |
|
320 | +function json_php_unserialize($str, $allow_not_serialized = false) |
|
321 | 321 | { |
322 | 322 | if ((in_array($str[0], array('a', 'i', 's', 'b', 'O', 'C')) && $str[1] == ':' || $str === 'N;') && |
323 | 323 | ($arr = php_safe_unserialize($str)) !== false || $str === 'b:0;') |
@@ -24,7 +24,9 @@ discard block |
||
24 | 24 | { |
25 | 25 | static $preg=null; |
26 | 26 | //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; |
27 | - if (!isset($preg)) $preg = |
|
27 | + if (!isset($preg)) |
|
28 | + { |
|
29 | + $preg = |
|
28 | 30 | // forbidden tags like iframe or script |
29 | 31 | '/(<(\s*\/)?\s*(iframe|script|object|embed|math|meta)[^a-z0-9]|'. |
30 | 32 | // on* attributes |
@@ -33,6 +35,7 @@ discard block |
||
33 | 35 | '<[^>]+(href|src|dynsrc|lowsrc|background|style|poster|action)\s*=\s*("|\')?[^"\']*javascript|'. |
34 | 36 | // benavior:url and expression in style attribute |
35 | 37 | '<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i'; |
38 | + } |
|
36 | 39 | if (is_array($var)) |
37 | 40 | { |
38 | 41 | foreach($var as $key => $val) |
@@ -41,7 +44,9 @@ discard block |
||
41 | 44 | { |
42 | 45 | _check_script_tag($var[$key],$name.'['.$key.']'); |
43 | 46 | } |
44 | - elseif(strpos($val, '<') !== false) // speedup: ignore everything without < |
|
47 | + elseif(strpos($val, '<') !== false) |
|
48 | + { |
|
49 | + // speedup: ignore everything without < |
|
45 | 50 | { |
46 | 51 | if (preg_match($preg,$val)) |
47 | 52 | { |
@@ -49,6 +54,7 @@ discard block |
||
49 | 54 | if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true))) |
50 | 55 | { |
51 | 56 | _check_script_tag($json_data, $name.'[json_data]'); |
57 | + } |
|
52 | 58 | $_REQUEST[$key] = $var[$key] = json_encode($json_data); |
53 | 59 | continue; |
54 | 60 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * @param Base $storage |
47 | 47 | * @param \Traversable $rs |
48 | 48 | */ |
49 | - public function __construct(Base $storage, \Traversable $rs=null) |
|
49 | + public function __construct(Base $storage, \Traversable $rs = null) |
|
50 | 50 | { |
51 | 51 | $this->storage = $storage; |
52 | 52 | |
53 | 53 | $this->total = $storage->total; |
54 | 54 | |
55 | - if (is_a($rs,'IteratorAggregate')) |
|
55 | + if (is_a($rs, 'IteratorAggregate')) |
|
56 | 56 | { |
57 | 57 | $this->rs = $rs->getIterator(); |
58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function current() |
71 | 71 | { |
72 | - if (is_a($this->rs,'iterator')) |
|
72 | + if (is_a($this->rs, 'iterator')) |
|
73 | 73 | { |
74 | 74 | $data = $this->rs->current(); |
75 | 75 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function key() |
87 | 87 | { |
88 | - if (is_a($this->rs,'iterator')) |
|
88 | + if (is_a($this->rs, 'iterator')) |
|
89 | 89 | { |
90 | 90 | return $this->rs->key(); |
91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function next() |
99 | 99 | { |
100 | - if (is_a($this->rs,'iterator')) |
|
100 | + if (is_a($this->rs, 'iterator')) |
|
101 | 101 | { |
102 | 102 | return $this->rs->next(); |
103 | 103 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function rewind() |
110 | 110 | { |
111 | - if (is_a($this->rs,'iterator')) |
|
111 | + if (is_a($this->rs, 'iterator')) |
|
112 | 112 | { |
113 | 113 | return $this->rs->rewind(); |
114 | 114 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return boolean |
121 | 121 | */ |
122 | - public function valid () |
|
122 | + public function valid() |
|
123 | 123 | { |
124 | - if (is_a($this->rs,'iterator')) |
|
124 | + if (is_a($this->rs, 'iterator')) |
|
125 | 125 | { |
126 | 126 | return $this->rs->valid(); |
127 | 127 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return so_sql2 |
55 | 55 | */ |
56 | - function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false) |
|
56 | + function __construct($app = '', $table = '', Api\Db $db = null, $column_prefix = '', $no_clone = false) |
|
57 | 57 | { |
58 | - parent::__construct($app,$table,$db,$column_prefix,$no_clone); |
|
58 | + parent::__construct($app, $table, $db, $column_prefix, $no_clone); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function __get($property) |
70 | 70 | { |
71 | - switch($property) |
|
71 | + switch ($property) |
|
72 | 72 | { |
73 | 73 | case 'id': |
74 | 74 | $property = $this->autoinc_id; |
75 | 75 | break; |
76 | 76 | } |
77 | - if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols)) |
|
77 | + if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols)) |
|
78 | 78 | { |
79 | 79 | return $this->data[$property]; |
80 | 80 | } |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * @param string $property |
89 | 89 | * @param mixed $value |
90 | 90 | */ |
91 | - function __set($property,$value) |
|
91 | + function __set($property, $value) |
|
92 | 92 | { |
93 | - switch($property) |
|
93 | + switch ($property) |
|
94 | 94 | { |
95 | 95 | case 'id': |
96 | 96 | $property = $this->autoinc_id; |
97 | 97 | break; |
98 | 98 | } |
99 | - if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols)) |
|
99 | + if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols)) |
|
100 | 100 | { |
101 | 101 | $this->data[$property] = $value; |
102 | 102 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class App extends Exception\NoPermission |
23 | 23 | { |
24 | - function __construct($msg=null,$code=101) |
|
24 | + function __construct($msg = null, $code = 101) |
|
25 | 25 | { |
26 | 26 | if (isset($GLOBALS['egw_info']['apps'][$msg])) |
27 | 27 | { |
@@ -39,6 +39,6 @@ discard block |
||
39 | 39 | '"'.$app.'"'); |
40 | 40 | } |
41 | 41 | } |
42 | - parent::__construct($msg,$code); |
|
42 | + parent::__construct($msg, $code); |
|
43 | 43 | } |
44 | 44 | } |
@@ -26,10 +26,10 @@ |
||
26 | 26 | * @param string $msg =null message, default "Entry not found!" |
27 | 27 | * @param int $code =99 numerical code, default 2 |
28 | 28 | */ |
29 | - function __construct($msg=null,$code=2) |
|
29 | + function __construct($msg = null, $code = 2) |
|
30 | 30 | { |
31 | 31 | if (is_null($msg)) $msg = lang('Entry not found!'); |
32 | 32 | |
33 | - parent::__construct($msg,$code); |
|
33 | + parent::__construct($msg, $code); |
|
34 | 34 | } |
35 | 35 | } |
@@ -28,7 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | function __construct($msg=null,$code=2) |
30 | 30 | { |
31 | - if (is_null($msg)) $msg = lang('Entry not found!'); |
|
31 | + if (is_null($msg)) |
|
32 | + { |
|
33 | + $msg = lang('Entry not found!'); |
|
34 | + } |
|
32 | 35 | |
33 | 36 | parent::__construct($msg,$code); |
34 | 37 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param string $msg |
34 | 34 | * @param int $code |
35 | 35 | */ |
36 | - function __construct($url,$app=null,$msg=null,$code=301) |
|
36 | + function __construct($url, $app = null, $msg = null, $code = 301) |
|
37 | 37 | { |
38 | 38 | $this->url = $url; |
39 | 39 | $this->app = $app; |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | // Only variables should be assigned by reference, eg. soetemplate::tree_walk() |
25 | 25 | // Declaration of <extended method> should be compatible with <parent method>, varios places where method parameters change |
26 | 26 | // --> switching it off for now, as it makes error-log unusable |
27 | -error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); |
|
27 | +error_reporting(E_ALL&~E_NOTICE&~E_STRICT); |
|
28 | 28 | if (function_exists('get_magic_quotes_runtime') && get_magic_quotes_runtime()) |
29 | 29 | { |
30 | 30 | set_magic_quotes_runtime(false); |
31 | 31 | } |
32 | 32 | |
33 | 33 | $egw_min_php_version = '5.4'; |
34 | -if (!function_exists('version_compare') || version_compare(PHP_VERSION,$egw_min_php_version) < 0) |
|
34 | +if (!function_exists('version_compare') || version_compare(PHP_VERSION, $egw_min_php_version) < 0) |
|
35 | 35 | { |
36 | 36 | die("EGroupware requires PHP $egw_min_php_version or greater.<br />Please contact your System Administrator to upgrade PHP!"); |
37 | 37 | } |
38 | 38 | |
39 | -if (!defined('EGW_API_INC')) define('EGW_API_INC',PHPGW_API_INC); // this is to support the header upgrade |
|
39 | +if (!defined('EGW_API_INC')) define('EGW_API_INC', PHPGW_API_INC); // this is to support the header upgrade |
|
40 | 40 | |
41 | 41 | /* Make sure the header.inc.php is current. */ |
42 | 42 | if (!isset($GLOBALS['egw_domain']) || $GLOBALS['egw_info']['server']['versions']['header'] < $GLOBALS['egw_info']['server']['versions']['current_header']) |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $GLOBALS['egw_info']['flags']['restored_from_session'] = true; |
68 | 68 | |
69 | 69 | // restoring the egw_info-array |
70 | - $GLOBALS['egw_info'] = array_merge($_SESSION[Session::EGW_INFO_CACHE],array('flags' => $GLOBALS['egw_info']['flags'])); |
|
70 | + $GLOBALS['egw_info'] = array_merge($_SESSION[Session::EGW_INFO_CACHE], array('flags' => $GLOBALS['egw_info']['flags'])); |
|
71 | 71 | |
72 | 72 | // include required class-definitions |
73 | 73 | if (is_array($_SESSION[Session::EGW_REQUIRED_FILES])) // all classes, which can not be autoloaded |
74 | 74 | { |
75 | - foreach($_SESSION[Session::EGW_REQUIRED_FILES] as $file) |
|
75 | + foreach ($_SESSION[Session::EGW_REQUIRED_FILES] as $file) |
|
76 | 76 | { |
77 | 77 | require_once($file); |
78 | 78 | } |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | |
82 | 82 | if (is_object($GLOBALS['egw']) && ($GLOBALS['egw'] instanceof Egw)) // only egw object has wakeup2, setups egw_minimal eg. has not! |
83 | 83 | { |
84 | - $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) |
|
84 | + $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) |
|
85 | 85 | |
86 | 86 | $GLOBALS['egw_info']['flags']['session_restore_time'] = microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']; |
87 | - if (is_object($GLOBALS['egw']->translation)) return; // exit this file, as the rest of the file creates a new egw-object and -enviroment |
|
87 | + if (is_object($GLOBALS['egw']->translation)) return; // exit this file, as the rest of the file creates a new egw-object and -enviroment |
|
88 | 88 | } |
89 | 89 | // egw object could NOT be restored from the session, create a new one |
90 | 90 | unset($GLOBALS['egw']); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | $GLOBALS['egw_info']['user']['domain'] = Session::search_instance( |
111 | 111 | isset($_POST['login']) ? $_POST['login'] : (isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : $_SERVER['REMOTE_USER']), |
112 | - Session::get_request('domain'),$GLOBALS['egw_info']['server']['default_domain'], |
|
113 | - array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']),$GLOBALS['egw_domain']); |
|
112 | + Session::get_request('domain'), $GLOBALS['egw_info']['server']['default_domain'], |
|
113 | + array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']), $GLOBALS['egw_domain']); |
|
114 | 114 | |
115 | 115 | $GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_host']; |
116 | 116 | $GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_port']; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | // store domain config user&pw as a hash (originals get unset) |
126 | 126 | $GLOBALS['egw_info']['server']['config_hash'] = Session::user_pw_hash($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['config_user'], |
127 | - $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['config_passwd'],true); |
|
127 | + $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['config_passwd'], true); |
|
128 | 128 | |
129 | 129 | if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && !$GLOBALS['egw_info']['server']['show_domain_selectbox']) |
130 | 130 | { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login') |
138 | 138 | { |
139 | 139 | $_SESSION[Session::EGW_INFO_CACHE] = $GLOBALS['egw_info']; |
140 | - unset($_SESSION[Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
140 | + unset($_SESSION[Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request |
|
141 | 141 | |
142 | 142 | $_SESSION[Session::EGW_OBJECT_CACHE] = serialize($GLOBALS['egw']); |
143 | 143 | } |
@@ -36,7 +36,11 @@ discard block |
||
36 | 36 | die("EGroupware requires PHP $egw_min_php_version or greater.<br />Please contact your System Administrator to upgrade PHP!"); |
37 | 37 | } |
38 | 38 | |
39 | -if (!defined('EGW_API_INC')) define('EGW_API_INC',PHPGW_API_INC); // this is to support the header upgrade |
|
39 | +if (!defined('EGW_API_INC')) |
|
40 | +{ |
|
41 | + define('EGW_API_INC',PHPGW_API_INC); |
|
42 | +} |
|
43 | +// this is to support the header upgrade |
|
40 | 44 | |
41 | 45 | /* Make sure the header.inc.php is current. */ |
42 | 46 | if (!isset($GLOBALS['egw_domain']) || $GLOBALS['egw_info']['server']['versions']['header'] < $GLOBALS['egw_info']['server']['versions']['current_header']) |
@@ -70,21 +74,32 @@ discard block |
||
70 | 74 | $GLOBALS['egw_info'] = array_merge($_SESSION[Session::EGW_INFO_CACHE],array('flags' => $GLOBALS['egw_info']['flags'])); |
71 | 75 | |
72 | 76 | // include required class-definitions |
73 | - if (is_array($_SESSION[Session::EGW_REQUIRED_FILES])) // all classes, which can not be autoloaded |
|
77 | + if (is_array($_SESSION[Session::EGW_REQUIRED_FILES])) |
|
78 | + { |
|
79 | + // all classes, which can not be autoloaded |
|
74 | 80 | { |
75 | 81 | foreach($_SESSION[Session::EGW_REQUIRED_FILES] as $file) |
76 | 82 | { |
77 | 83 | require_once($file); |
84 | + } |
|
78 | 85 | } |
79 | 86 | } |
80 | 87 | $GLOBALS['egw'] = unserialize($_SESSION[Session::EGW_OBJECT_CACHE]); |
81 | 88 | |
82 | - if (is_object($GLOBALS['egw']) && ($GLOBALS['egw'] instanceof Egw)) // only egw object has wakeup2, setups egw_minimal eg. has not! |
|
89 | + if (is_object($GLOBALS['egw']) && ($GLOBALS['egw'] instanceof Egw)) |
|
83 | 90 | { |
84 | - $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) |
|
91 | + // only egw object has wakeup2, setups egw_minimal eg. has not! |
|
92 | + { |
|
93 | + $GLOBALS['egw']->wakeup2(); |
|
94 | + } |
|
95 | + // adapt the restored egw-object/enviroment to this request (eg. changed current app) |
|
85 | 96 | |
86 | 97 | $GLOBALS['egw_info']['flags']['session_restore_time'] = microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']; |
87 | - if (is_object($GLOBALS['egw']->translation)) return; // exit this file, as the rest of the file creates a new egw-object and -enviroment |
|
98 | + if (is_object($GLOBALS['egw']->translation)) |
|
99 | + { |
|
100 | + return; |
|
101 | + } |
|
102 | + // exit this file, as the rest of the file creates a new egw-object and -enviroment |
|
88 | 103 | } |
89 | 104 | // egw object could NOT be restored from the session, create a new one |
90 | 105 | unset($GLOBALS['egw']); |
@@ -27,10 +27,10 @@ |
||
27 | 27 | * @param string $msg =null message, default "Database error!" |
28 | 28 | * @param int $code =100 |
29 | 29 | */ |
30 | - function __construct($msg=null,$code=100) |
|
30 | + function __construct($msg = null, $code = 100) |
|
31 | 31 | { |
32 | 32 | if (is_null($msg)) $msg = lang('Database error!'); |
33 | 33 | |
34 | - parent::__construct($msg,$code); |
|
34 | + parent::__construct($msg, $code); |
|
35 | 35 | } |
36 | 36 | } |
@@ -29,7 +29,10 @@ |
||
29 | 29 | */ |
30 | 30 | function __construct($msg=null,$code=100) |
31 | 31 | { |
32 | - if (is_null($msg)) $msg = lang('Database error!'); |
|
32 | + if (is_null($msg)) |
|
33 | + { |
|
34 | + $msg = lang('Database error!'); |
|
35 | + } |
|
33 | 36 | |
34 | 37 | parent::__construct($msg,$code); |
35 | 38 | } |