1
|
|
|
<?php |
2
|
|
|
// amountToOutput |
3
|
|
View Code Duplication |
if (!function_exists('amountToOutput')) { |
4
|
|
|
/** |
5
|
|
|
* This function is dynamically redefinable. |
6
|
|
|
* @see $GLOBALS['_global_function_callback_e'] |
7
|
|
|
*/ |
8
|
|
|
function amountToOutput($args) |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
$args = func_get_args(); |
11
|
|
|
return call_user_func_array($GLOBALS['_global_function_callback_amountToOutput'], $args); |
12
|
|
|
} |
13
|
|
|
if (!isset($GLOBALS['_global_function_callback_amountToOutput'])) { |
14
|
|
|
$GLOBALS['_global_function_callback_amountToOutput'] = null; |
15
|
|
|
} |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
$GLOBALS['_global_function_callback_amountToOutput'] = 'intraface_AmountToOutput'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Outputs country specific notation |
22
|
|
|
* @todo Add information about the country |
23
|
|
|
*/ |
24
|
|
|
function amountToOutput($amount) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
return number_format($amount, 2, ',', '.'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// amountToForm |
30
|
|
View Code Duplication |
if (!function_exists('amountToForm')) { |
31
|
|
|
/** |
32
|
|
|
* This function is dynamically redefinable. |
33
|
|
|
* @see $GLOBALS['_global_function_callback_e'] |
34
|
|
|
*/ |
35
|
|
|
function amountToForm($args) |
|
|
|
|
36
|
|
|
{ |
37
|
2 |
|
$args = func_get_args(); |
38
|
2 |
|
return call_user_func_array($GLOBALS['_global_function_callback_amountToForm'], $args); |
39
|
|
|
} |
40
|
|
|
if (!isset($GLOBALS['_global_function_callback_amountToForm'])) { |
41
|
|
|
$GLOBALS['_global_function_callback_amountToForm'] = null; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$GLOBALS['_global_function_callback_amountToForm'] = 'intraface_AmountToForm'; |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Outputs country specific amounts in the forms |
50
|
|
|
*/ |
51
|
|
|
function intraface_amountToForm($amount) |
52
|
|
|
{ |
53
|
2 |
|
return number_format($amount, 2, ',', ''); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
// autoop() |
57
|
|
View Code Duplication |
if (!function_exists('autoop')) { |
58
|
|
|
/** |
59
|
|
|
* This function is dynamically redefinable. |
60
|
|
|
* @see $GLOBALS['_global_function_callback_email'] |
61
|
|
|
*/ |
62
|
|
|
function autoop($args) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
$args = func_get_args(); |
65
|
|
|
return call_user_func_array($GLOBALS['_global_function_callback_autoop'], $args); |
66
|
|
|
} |
67
|
|
|
if (!isset($GLOBALS['_global_function_callback_autoop'])) { |
68
|
|
|
$GLOBALS['_global_function_callback_autoop'] = null; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
function intraface_autoop($text) |
73
|
|
|
{ |
74
|
|
|
require_once 'markdown.php'; |
75
|
|
|
require_once 'smartypants.php'; |
76
|
|
|
|
77
|
|
|
$text = MarkDown($text); |
78
|
|
|
$text = SmartyPants($text); |
79
|
|
|
return $text; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$GLOBALS['_global_function_callback_autoop'] = 'intraface_autoop'; |
83
|
|
|
|
84
|
|
|
// autoop() |
85
|
|
View Code Duplication |
if (!function_exists('autohtml')) { |
86
|
|
|
/** |
87
|
|
|
* This function is dynamically redefinable. |
88
|
|
|
* @see $GLOBALS['_global_function_callback_email'] |
89
|
|
|
*/ |
90
|
|
|
function autohtml($args) |
|
|
|
|
91
|
|
|
{ |
92
|
|
|
$args = func_get_args(); |
93
|
|
|
return call_user_func_array($GLOBALS['_global_function_callback_autohtml'], $args); |
94
|
|
|
} |
95
|
|
|
if (!isset($GLOBALS['_global_function_callback_autohtml'])) { |
96
|
|
|
$GLOBALS['_global_function_callback_autohtml'] = null; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
function intraface_autohtml($text) |
101
|
|
|
{ |
102
|
|
|
require_once 'markdown.php'; |
103
|
|
|
require_once 'smartypants.php'; |
104
|
|
|
|
105
|
|
|
$text = nl2br($text); |
106
|
|
|
$text = MarkDown($text); |
107
|
|
|
$text = SmartyPants($text); |
108
|
|
|
echo $text; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$GLOBALS['_global_function_callback_autohtml'] = 'intraface_autohtml'; |
112
|
|
|
|
113
|
|
|
// Dynamic global functions |
114
|
|
View Code Duplication |
if (!function_exists('safeToDb')) { |
115
|
|
|
/** |
116
|
|
|
* This function is dynamically redefinable. |
117
|
|
|
* @see $GLOBALS['_global_function_callback_e'] |
118
|
|
|
*/ |
119
|
|
|
function safeToDb($args) |
|
|
|
|
120
|
|
|
{ |
121
|
226 |
|
$args = func_get_args(); |
122
|
226 |
|
return call_user_func_array($GLOBALS['_global_function_callback_safetodb'], $args); |
123
|
|
|
} |
124
|
|
|
if (!isset($GLOBALS['_global_function_callback_safetodb'])) { |
125
|
|
|
$GLOBALS['_global_function_callback_safetodb'] = null; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
$GLOBALS['_global_function_callback_safetodb'] = 'intraface_safetodb'; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Function to be called before putting data in the database |
132
|
|
|
* |
133
|
|
|
* @author Lars Olesen <[email protected]> |
134
|
|
|
*/ |
135
|
|
|
function intraface_safetodb($data) |
136
|
|
|
{ |
137
|
226 |
|
if (is_object($data)) { |
138
|
6 |
|
return $data; |
139
|
|
|
} |
140
|
|
|
|
141
|
226 |
|
if (is_array($data)) { |
142
|
197 |
|
return array_map('safeToDb', $data); |
143
|
|
|
} |
144
|
|
|
|
145
|
224 |
|
if (get_magic_quotes_gpc()) { |
146
|
|
|
$data = stripslashes($data); |
147
|
|
|
} |
148
|
|
|
|
149
|
224 |
|
return mysql_escape_string($data); |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
//Dynamic global functions |
153
|
|
View Code Duplication |
if (!function_exists('filesize_readable')) { |
154
|
|
|
/** |
155
|
|
|
* This function is dynamically redefinable. |
156
|
|
|
* @see $GLOBALS['_global_function_callback_e'] |
157
|
|
|
*/ |
158
|
|
|
function filesize_readable($args) |
|
|
|
|
159
|
|
|
{ |
160
|
|
|
$args = func_get_args(); |
161
|
|
|
return call_user_func_array($GLOBALS['_global_function_callback_filesize_readable'], $args); |
162
|
|
|
} |
163
|
|
|
if (!isset($GLOBALS['_global_function_callback_filesize_readable'])) { |
164
|
|
|
$GLOBALS['_global_function_callback_filesize_readable'] = null; |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
$GLOBALS['_global_function_callback_filesize_readable'] = 'intraface_filesize_readable'; |
168
|
|
|
|
169
|
|
|
/* |
170
|
|
|
* Function to convert filesize to readable sizes. |
171
|
|
|
* from: http://us3.php.net/filesize |
172
|
|
|
*/ |
173
|
|
|
function intraface_filesize_readable($size, $retstring = null) |
174
|
|
|
{ |
175
|
|
|
// adapted from code at http://aidanlister.com/repos/v/function.size_readable.php |
176
|
|
|
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
177
|
|
|
if ($retstring === null) { |
178
|
|
|
$retstring = '%01.2f %s'; |
179
|
|
|
} |
180
|
|
|
$lastsizestring = end($sizes); |
181
|
|
|
foreach ($sizes as $sizestring) { |
182
|
|
|
if ($size < 1024) { |
183
|
|
|
break; |
184
|
|
|
} |
185
|
|
|
if ($sizestring != $lastsizestring) { |
186
|
|
|
$size /= 1024; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
if ($sizestring == $sizes[0]) { |
|
|
|
|
190
|
|
|
// Bytes aren't normally fractional |
191
|
|
|
$retstring = '%01d %s'; |
192
|
|
|
} |
193
|
|
|
return sprintf($retstring, $size, $sizestring); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
function intrafaceBackendErrorhandler($errno, $errstr, $errfile, $errline, $errcontext) |
197
|
|
|
{ |
198
|
|
|
if (!defined('ERROR_LOG')) { |
199
|
|
|
define('ERROR_LOG', dirname(__FILE__) . '/../log/error.log'); |
200
|
|
|
} |
201
|
|
|
$errorhandler = new ErrorHandler; |
202
|
|
|
if (!defined('ERROR_LEVEL_CONTINUE_SCRIPT')) { |
203
|
|
|
define('ERROR_LEVEL_CONTINUE_SCRIPT', E_ALL); |
204
|
|
|
} |
205
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG)); |
206
|
|
|
// From php.net "~ $a: Bits that are set in $a are not set, and vice versa." That means the observer is used on everything but ERROR_LEVEL_CONTINUE_SCRIPT |
207
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_Echo, ~ ERROR_LEVEL_CONTINUE_SCRIPT); |
208
|
|
|
return $errorhandler->handleError($errno, $errstr, $errfile, $errline, $errcontext); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
function intrafaceBackendExceptionhandler($e) |
212
|
|
|
{ |
213
|
|
|
$errorhandler = new ErrorHandler; |
214
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG)); |
215
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_Echo); |
216
|
|
|
return $errorhandler->handleException($e); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
function intrafaceFrontendErrorhandler($errno, $errstr, $errfile, $errline, $errcontext) |
220
|
|
|
{ |
221
|
|
|
$errorhandler = new ErrorHandler; |
222
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG)); |
223
|
|
|
if (defined('SERVER_STATUS') && SERVER_STATUS == 'TEST') { |
224
|
|
|
// From php.net "~ $a: Bits that are set in $a are not set, and vice versa." That means the observer is used on everything but ERROR_LEVEL_CONTINUE_SCRIPT |
225
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_BlueScreen, ~ ERROR_LEVEL_CONTINUE_SCRIPT); |
226
|
|
|
} else { |
227
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_User, ~ ERROR_LEVEL_CONTINUE_SCRIPT); // See description of ~ above |
228
|
|
|
} |
229
|
|
|
return $errorhandler->handleError($errno, $errstr, $errfile, $errline, $errcontext); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
function intrafaceFrontendExceptionhandler($e) |
233
|
|
|
{ |
234
|
|
|
$errorhandler = new ErrorHandler; |
235
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG)); |
236
|
|
|
if (defined('SERVER_STATUS') && SERVER_STATUS == 'TEST') { |
237
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_BlueScreen); |
238
|
|
|
} else { |
239
|
|
|
$errorhandler->addObserver(new ErrorHandler_Observer_User); |
240
|
|
|
} |
241
|
|
|
return $errorhandler->handleException($e); |
242
|
|
|
} |
243
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.