@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | if(! function_exists('__')){ |
28 | 28 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | 25 | */ |
26 | 26 | |
27 | - if(! function_exists('__')){ |
|
27 | + if (!function_exists('__')) { |
|
28 | 28 | /** |
29 | 29 | * function for the shortcut to Lang::get() |
30 | 30 | * @param string $key the language key to retrieve |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | * for the given key |
33 | 33 | * @return string the language value |
34 | 34 | */ |
35 | - function __($key, $default = 'LANGUAGE_ERROR'){ |
|
35 | + function __($key, $default = 'LANGUAGE_ERROR') { |
|
36 | 36 | return get_instance()->lang->get($key, $default); |
37 | 37 | } |
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | - if(! function_exists('get_languages')){ |
|
42 | + if (!function_exists('get_languages')) { |
|
43 | 43 | /** |
44 | 44 | * function for the shortcut to Lang::getSupported() |
45 | 45 | * |
46 | 46 | * @return array all the supported languages |
47 | 47 | */ |
48 | - function get_languages(){ |
|
48 | + function get_languages() { |
|
49 | 49 | return get_instance()->lang->getSupported(); |
50 | 50 | } |
51 | 51 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -55,17 +55,13 @@ |
||
55 | 55 | |
56 | 56 | if (isset($_SERVER["HTTP_CLIENT_IP"])) { |
57 | 57 | $ip = $_SERVER["HTTP_CLIENT_IP"]; |
58 | - } |
|
59 | - else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { |
|
58 | + } else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { |
|
60 | 59 | $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; |
61 | - } |
|
62 | - else if (isset($_SERVER["HTTP_X_FORWARDED"])) { |
|
60 | + } else if (isset($_SERVER["HTTP_X_FORWARDED"])) { |
|
63 | 61 | $ip = $_SERVER["HTTP_X_FORWARDED"]; |
64 | - } |
|
65 | - else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) { |
|
62 | + } else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) { |
|
66 | 63 | $ip = $_SERVER["HTTP_FORWARDED_FOR"]; |
67 | - } |
|
68 | - else if (isset($_SERVER["HTTP_FORWARDED"])) { |
|
64 | + } else if (isset($_SERVER["HTTP_FORWARDED"])) { |
|
69 | 65 | $ip = $_SERVER["HTTP_FORWARDED"]; |
70 | 66 | } |
71 | 67 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | |
43 | 43 | |
44 | - if(! function_exists('get_ip')){ |
|
44 | + if (!function_exists('get_ip')) { |
|
45 | 45 | /** |
46 | 46 | * Retrieves the user's IP address |
47 | 47 | * |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string the IP address. |
52 | 52 | */ |
53 | - function get_ip(){ |
|
53 | + function get_ip() { |
|
54 | 54 | $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; |
55 | 55 | |
56 | 56 | if (isset($_SERVER["HTTP_CLIENT_IP"])) { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @file function_string.php |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @filesource |
40 | 40 | */ |
41 | 41 | |
42 | - if(! function_exists('get_random_string')){ |
|
42 | + if (!function_exists('get_random_string')) { |
|
43 | 43 | /** |
44 | 44 | * Generate a random string |
45 | 45 | * @param string $type the type of generation. It can take the values: "alpha" for alphabetic characters, |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param boolean $lower if we return the generated string in lowercase (true). By default it's false. |
50 | 50 | * @return string the generated string. |
51 | 51 | */ |
52 | - function get_random_string($type = 'alnum', $length = 10, $lower = false){ |
|
52 | + function get_random_string($type = 'alnum', $length = 10, $lower = false) { |
|
53 | 53 | $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; |
54 | - switch($type){ |
|
54 | + switch ($type) { |
|
55 | 55 | case 'alpha': |
56 | 56 | $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
57 | 57 | break; |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | break; |
64 | 64 | } |
65 | 65 | $random = null; |
66 | - for($i = 0; $i < $length; $i++){ |
|
66 | + for ($i = 0; $i < $length; $i++) { |
|
67 | 67 | $random .= $str[mt_rand() % strlen($str)]; |
68 | 68 | } |
69 | - if($lower){ |
|
69 | + if ($lower) { |
|
70 | 70 | $random = strtolower($random); |
71 | 71 | } |
72 | 72 | return $random; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
7 | 7 | <meta name="description" content=""> |
8 | 8 | <meta name="author" content="Tony NGUEREZA"> |
9 | - <title><?php echo $title;?></title> |
|
9 | + <title><?php echo $title; ?></title> |
|
10 | 10 | <style type = 'text/css'> |
11 | 11 | /* reset */ |
12 | 12 | *{ |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | <body> |
65 | 65 | <div class="container"> |
66 | 66 | <div class = "title"> |
67 | - <h2><?php echo $title;?></h2> |
|
67 | + <h2><?php echo $title; ?></h2> |
|
68 | 68 | </div> |
69 | 69 | <div class = "body"> |
70 | - <p><?php echo $error;?></p> |
|
70 | + <p><?php echo $error; ?></p> |
|
71 | 71 | </div> |
72 | 72 | </div> <!-- ./container--> |
73 | 73 | </body> |
@@ -1,24 +1,24 @@ |
||
1 | 1 | <?php |
2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
3 | 3 | /** |
4 | 4 | * Form validation language message (English) |
5 | 5 | */ |
6 | 6 | $lang['fv_required'] = 'Field %1 is required.'; |
7 | - $lang['fv_min_length'] = 'Field %1 must contain at least %2 characters.'; |
|
8 | - $lang['fv_max_length'] = 'Field %1 must contain at most %2 characters.'; |
|
9 | - $lang['fv_exact_length'] = 'Field %1 must contain exactly %2 characters.'; |
|
10 | - $lang['fv_less_than'] = 'Field %1 must less than %2.'; |
|
11 | - $lang['fv_greater_than'] = 'Field %1 must greater than %2.'; |
|
12 | - $lang['fv_matches'] = 'Field %1 must be identical to field %2.'; |
|
13 | - $lang['fv_valid_email'] = 'Field %1 must contain a valid E-mail address.'; |
|
14 | - $lang['fv_not_equal_post_key'] = 'Field %1 must not be the same as field %2.'; |
|
15 | - $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
|
16 | - $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
|
7 | + $lang['fv_min_length'] = 'Field %1 must contain at least %2 characters.'; |
|
8 | + $lang['fv_max_length'] = 'Field %1 must contain at most %2 characters.'; |
|
9 | + $lang['fv_exact_length'] = 'Field %1 must contain exactly %2 characters.'; |
|
10 | + $lang['fv_less_than'] = 'Field %1 must less than %2.'; |
|
11 | + $lang['fv_greater_than'] = 'Field %1 must greater than %2.'; |
|
12 | + $lang['fv_matches'] = 'Field %1 must be identical to field %2.'; |
|
13 | + $lang['fv_valid_email'] = 'Field %1 must contain a valid E-mail address.'; |
|
14 | + $lang['fv_not_equal_post_key'] = 'Field %1 must not be the same as field %2.'; |
|
15 | + $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
|
16 | + $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
|
17 | 17 | $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
18 | 18 | $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
19 | - $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
|
20 | - $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
21 | - $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |
|
22 | - $lang['fv_numeric'] = 'The value of field %1 must be a number.'; |
|
23 | - $lang['fv_callback'] = 'The value of field %1 is not valid.'; |
|
19 | + $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
|
20 | + $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
21 | + $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |
|
22 | + $lang['fv_numeric'] = 'The value of field %1 must be a number.'; |
|
23 | + $lang['fv_callback'] = 'The value of field %1 is not valid.'; |
|
24 | 24 |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Form validation language message (English) |
5 | 5 | */ |
6 | - $lang['fv_required'] = 'Field %1 is required.'; |
|
6 | + $lang['fv_required'] = 'Field %1 is required.'; |
|
7 | 7 | $lang['fv_min_length'] = 'Field %1 must contain at least %2 characters.'; |
8 | 8 | $lang['fv_max_length'] = 'Field %1 must contain at most %2 characters.'; |
9 | 9 | $lang['fv_exact_length'] = 'Field %1 must contain exactly %2 characters.'; |
10 | - $lang['fv_less_than'] = 'Field %1 must less than %2.'; |
|
10 | + $lang['fv_less_than'] = 'Field %1 must less than %2.'; |
|
11 | 11 | $lang['fv_greater_than'] = 'Field %1 must greater than %2.'; |
12 | 12 | $lang['fv_matches'] = 'Field %1 must be identical to field %2.'; |
13 | 13 | $lang['fv_valid_email'] = 'Field %1 must contain a valid E-mail address.'; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
17 | 17 | $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
18 | 18 | $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
19 | - $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
|
19 | + $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
|
20 | 20 | $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
21 | 21 | $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |
22 | 22 | $lang['fv_numeric'] = 'The value of field %1 must be a number.'; |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
3 | 3 | /** |
4 | 4 | * File upload language messages (English) |
5 | 5 | */ |
6 | 6 | $lang['fu_upload_err_ini_size'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
7 | - $lang['fu_upload_err_form_size'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'; |
|
8 | - $lang['fu_upload_err_partial'] = 'The uploaded file was only partially uploaded.'; |
|
9 | - $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
|
10 | - $lang['fu_upload_err_no_tmp_dir'] = 'Missing a temporary folder.'; |
|
11 | - $lang['fu_upload_err_cant_write'] = 'Failed to write file to disk.'; |
|
12 | - $lang['fu_upload_err_extension'] = 'A PHP extension stopped the file upload.'; |
|
13 | - $lang['fu_accept_file_types'] = 'Filetype not allowed'; |
|
14 | - $lang['fu_file_uploads_disabled'] = 'File uploading option is disabled in php.ini'; |
|
15 | - $lang['fu_max_file_size'] = 'The uploaded file size is too big max size is %s'; |
|
16 | - $lang['fu_overwritten_not_allowed'] = 'You don\'t allow overwriting existing file'; |
|
7 | + $lang['fu_upload_err_form_size'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'; |
|
8 | + $lang['fu_upload_err_partial'] = 'The uploaded file was only partially uploaded.'; |
|
9 | + $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
|
10 | + $lang['fu_upload_err_no_tmp_dir'] = 'Missing a temporary folder.'; |
|
11 | + $lang['fu_upload_err_cant_write'] = 'Failed to write file to disk.'; |
|
12 | + $lang['fu_upload_err_extension'] = 'A PHP extension stopped the file upload.'; |
|
13 | + $lang['fu_accept_file_types'] = 'Filetype not allowed'; |
|
14 | + $lang['fu_file_uploads_disabled'] = 'File uploading option is disabled in php.ini'; |
|
15 | + $lang['fu_max_file_size'] = 'The uploaded file size is too big max size is %s'; |
|
16 | + $lang['fu_overwritten_not_allowed'] = 'You don\'t allow overwriting existing file'; |
|
17 | 17 |
@@ -6,11 +6,11 @@ |
||
6 | 6 | $lang['fu_upload_err_ini_size'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
7 | 7 | $lang['fu_upload_err_form_size'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'; |
8 | 8 | $lang['fu_upload_err_partial'] = 'The uploaded file was only partially uploaded.'; |
9 | - $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
|
9 | + $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
|
10 | 10 | $lang['fu_upload_err_no_tmp_dir'] = 'Missing a temporary folder.'; |
11 | - $lang['fu_upload_err_cant_write'] = 'Failed to write file to disk.'; |
|
11 | + $lang['fu_upload_err_cant_write'] = 'Failed to write file to disk.'; |
|
12 | 12 | $lang['fu_upload_err_extension'] = 'A PHP extension stopped the file upload.'; |
13 | - $lang['fu_accept_file_types'] = 'Filetype not allowed'; |
|
13 | + $lang['fu_accept_file_types'] = 'Filetype not allowed'; |
|
14 | 14 | $lang['fu_file_uploads_disabled'] = 'File uploading option is disabled in php.ini'; |
15 | 15 | $lang['fu_max_file_size'] = 'The uploaded file size is too big max size is %s'; |
16 | 16 | $lang['fu_overwritten_not_allowed'] = 'You don\'t allow overwriting existing file'; |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @file constants.php |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | |
28 | 28 | function & class_loader($class, $dir = 'libraries', $params = null){ |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | - * @test |
|
96 | - */ |
|
95 | + * @test |
|
96 | + */ |
|
97 | 97 | function get_config($key, $default = null){ |
98 | 98 | static $cfg; |
99 | 99 | if(empty($cfg)){ |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | - * @test |
|
125 | - */ |
|
124 | + * @test |
|
125 | + */ |
|
126 | 126 | function is_url($url){ |
127 | 127 | return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
128 | 128 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
145 | - * @test |
|
146 | - */ |
|
145 | + * @test |
|
146 | + */ |
|
147 | 147 | function attributes_to_string(array $attributes){ |
148 | 148 | $str = ' '; |
149 | 149 | //we check that the array passed as an argument is not empty. |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @test |
|
177 | - */ |
|
176 | + * @test |
|
177 | + */ |
|
178 | 178 | function clean_input($str){ |
179 | 179 | if(is_array($str)){ |
180 | 180 | $str = array_map('clean_input', $str); |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * @test |
|
197 | - */ |
|
196 | + * @test |
|
197 | + */ |
|
198 | 198 | function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
199 | 199 | //get the string length |
200 | 200 | $len = strlen($str); |
@@ -178,15 +178,13 @@ |
||
178 | 178 | function clean_input($str){ |
179 | 179 | if(is_array($str)){ |
180 | 180 | $str = array_map('clean_input', $str); |
181 | - } |
|
182 | - else if(is_object($str)){ |
|
181 | + } else if(is_object($str)){ |
|
183 | 182 | $obj = $str; |
184 | 183 | foreach ($str as $var => $value) { |
185 | 184 | $obj->$var = clean_input($value); |
186 | 185 | } |
187 | 186 | $str = $obj; |
188 | - } |
|
189 | - else{ |
|
187 | + } else{ |
|
190 | 188 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
191 | 189 | } |
192 | 190 | return $str; |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | //put the first letter of class to upper case |
30 | 30 | $class = ucfirst($class); |
31 | 31 | static $classes = array(); |
32 | - if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
32 | + if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') { |
|
33 | 33 | return $classes[$class]; |
34 | 34 | } |
35 | 35 | $found = false; |
36 | 36 | foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
37 | 37 | $file = $path . $dir . '/' . $class . '.php'; |
38 | - if(file_exists($file)){ |
|
39 | - if(class_exists($class, false) === false){ |
|
38 | + if (file_exists($file)) { |
|
39 | + if (class_exists($class, false) === false) { |
|
40 | 40 | require_once $file; |
41 | 41 | } |
42 | 42 | //already found |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | break; |
45 | 45 | } |
46 | 46 | } |
47 | - if(! $found){ |
|
47 | + if (!$found) { |
|
48 | 48 | //can't use show_error() at this time because some dependencies not yet loaded |
49 | 49 | set_http_status_header(503); |
50 | 50 | echo 'Cannot find the class [' . $class . ']'; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /* |
55 | 55 | TODO use the best method to get the Log instance |
56 | 56 | */ |
57 | - if($class == 'Log'){ |
|
57 | + if ($class == 'Log') { |
|
58 | 58 | //can't use the instruction like "return new Log()" |
59 | 59 | //because we need return the reference instance of the loaded class. |
60 | 60 | $log = new Log(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | function & class_loaded($class = null){ |
74 | 74 | static $list = array(); |
75 | - if($class != null){ |
|
75 | + if ($class != null) { |
|
76 | 76 | $list[strtolower($class)] = $class; |
77 | 77 | } |
78 | 78 | return $list; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | function & load_configurations(array $overwrite_values = array()){ |
82 | 82 | static $config; |
83 | - if(empty($config)){ |
|
83 | + if (empty($config)) { |
|
84 | 84 | $file = CONFIG_PATH . 'config.php'; |
85 | 85 | require_once $file; |
86 | 86 | |
@@ -94,53 +94,53 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @test |
96 | 96 | */ |
97 | - function get_config($key, $default = null){ |
|
97 | + function get_config($key, $default = null) { |
|
98 | 98 | static $cfg; |
99 | - if(empty($cfg)){ |
|
99 | + if (empty($cfg)) { |
|
100 | 100 | $cfg[0] = & load_configurations(); |
101 | 101 | } |
102 | 102 | return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
103 | 103 | } |
104 | 104 | |
105 | - function save_to_log($level, $message, $logger = null){ |
|
106 | - echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n"; |
|
105 | + function save_to_log($level, $message, $logger = null) { |
|
106 | + echo 'save_to_log(' . $level . ',' . $message . ',' . $logger . ")\n"; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | - function set_http_status_header($code = 200, $text = null){ |
|
110 | + function set_http_status_header($code = 200, $text = null) { |
|
111 | 111 | echo 'header(' . $code . ', ' . $text . ')'; |
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - function show_error($msg, $title = 'error', $logging = true){ |
|
116 | + function show_error($msg, $title = 'error', $logging = true) { |
|
117 | 117 | //show only and continue to help track of some error occured |
118 | 118 | echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n"; |
119 | 119 | } |
120 | 120 | |
121 | - function is_https(){ |
|
121 | + function is_https() { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @test |
127 | 127 | */ |
128 | - function is_url($url){ |
|
128 | + function is_url($url) { |
|
129 | 129 | return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
130 | 130 | } |
131 | 131 | |
132 | - function php_exception_handler($ex){ |
|
132 | + function php_exception_handler($ex) { |
|
133 | 133 | //show only and continue to help track of some error occured |
134 | - echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n"; |
|
134 | + echo 'php_exception_handler(' . $ex->getMessage() . ', ' . $ex->getFile() . ', ' . $ex->getLine() . ")\n"; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | - function php_error_handler($errno , $errstr, $errfile , $errline){ |
|
138 | + function php_error_handler($errno, $errstr, $errfile, $errline) { |
|
139 | 139 | //show only and continue to help track of some error occured |
140 | - echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n"; |
|
140 | + echo 'php_error_handler(' . $errno . ', ' . $errstr . ', ' . $errfile . ', ' . $errline . ")\n"; |
|
141 | 141 | } |
142 | 142 | |
143 | - function php_shudown_handler(){ |
|
143 | + function php_shudown_handler() { |
|
144 | 144 | return true; |
145 | 145 | } |
146 | 146 | |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * @test |
150 | 150 | */ |
151 | - function attributes_to_string(array $attributes){ |
|
151 | + function attributes_to_string(array $attributes) { |
|
152 | 152 | $str = ' '; |
153 | 153 | //we check that the array passed as an argument is not empty. |
154 | - if(! empty($attributes)){ |
|
155 | - foreach($attributes as $key => $value){ |
|
154 | + if (!empty($attributes)) { |
|
155 | + foreach ($attributes as $key => $value) { |
|
156 | 156 | $key = trim(htmlspecialchars($key)); |
157 | 157 | $value = trim(htmlspecialchars($value)); |
158 | 158 | /* |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | * $attr = array('placeholder' => 'I am a "puple"') |
163 | 163 | * $str = attributes_to_string($attr); => placeholder = "I am a \"puple\"" |
164 | 164 | */ |
165 | - if($value && strpos('"', $value) !== false){ |
|
165 | + if ($value && strpos('"', $value) !== false) { |
|
166 | 166 | $value = addslashes($value); |
167 | 167 | } |
168 | - $str .= $key.' = "'.$value.'" '; |
|
168 | + $str .= $key . ' = "' . $value . '" '; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | //remove the space after using rtrim() |
172 | 172 | return rtrim($str); |
173 | 173 | } |
174 | 174 | |
175 | - function stringfy_vars($var){ |
|
175 | + function stringfy_vars($var) { |
|
176 | 176 | return print_r($var, true); |
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @test |
181 | 181 | */ |
182 | - function clean_input($str){ |
|
183 | - if(is_array($str)){ |
|
182 | + function clean_input($str) { |
|
183 | + if (is_array($str)) { |
|
184 | 184 | $str = array_map('clean_input', $str); |
185 | 185 | } |
186 | - else if(is_object($str)){ |
|
186 | + else if (is_object($str)) { |
|
187 | 187 | $obj = $str; |
188 | 188 | foreach ($str as $var => $value) { |
189 | 189 | $obj->$var = clean_input($value); |
190 | 190 | } |
191 | 191 | $str = $obj; |
192 | 192 | } |
193 | - else{ |
|
193 | + else { |
|
194 | 194 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
195 | 195 | } |
196 | 196 | return $str; |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | /** |
200 | 200 | * @test |
201 | 201 | */ |
202 | - function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
202 | + function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') { |
|
203 | 203 | //get the string length |
204 | 204 | $len = strlen($str); |
205 | 205 | //if str is empty |
206 | - if($len <= 0){ |
|
206 | + if ($len <= 0) { |
|
207 | 207 | return str_repeat($hiddenChar, 6); |
208 | 208 | } |
209 | 209 | //if the length is less than startCount and endCount |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | //or startCount is negative or endCount is negative |
212 | 212 | //return the full string hidden |
213 | 213 | |
214 | - if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
214 | + if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) { |
|
215 | 215 | return str_repeat($hiddenChar, $len); |
216 | 216 | } |
217 | 217 | //the start non hidden string |
218 | 218 | $startNonHiddenStr = substr($str, 0, $startCount); |
219 | 219 | //the end non hidden string |
220 | 220 | $endNonHiddenStr = null; |
221 | - if($endCount > 0){ |
|
221 | + if ($endCount > 0) { |
|
222 | 222 | $endNonHiddenStr = substr($str, - $endCount); |
223 | 223 | } |
224 | 224 | //the hidden string |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr; |
228 | 228 | } |
229 | 229 | |
230 | - function set_session_config(){ |
|
230 | + function set_session_config() { |
|
231 | 231 | return true; |
232 | 232 | } |
233 | 233 | |
234 | 234 | function & get_instance(){ |
235 | - if(! Controller::get_instance()){ |
|
235 | + if (!Controller::get_instance()) { |
|
236 | 236 | $c = new Controller(); |
237 | 237 | return $c; |
238 | 238 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** |
4 | - * Function to test private & protected method |
|
5 | - */ |
|
4 | + * Function to test private & protected method |
|
5 | + */ |
|
6 | 6 | function runPrivateOrProtectedMethod($object, $method, array $args = array()){ |
7 | 7 | $r = new ReflectionClass(get_class($object)); |
8 | 8 | $m = $r->getMethod($method); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | /** |
4 | 4 | * Function to test private & protected method |
5 | 5 | */ |
6 | - function runPrivateOrProtectedMethod($object, $method, array $args = array()){ |
|
6 | + function runPrivateOrProtectedMethod($object, $method, array $args = array()) { |
|
7 | 7 | $r = new ReflectionClass(get_class($object)); |
8 | 8 | $m = $r->getMethod($method); |
9 | 9 | $m->setAccessible(true); |