@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class StringHash{ |
|
| 27 | + class StringHash { |
|
| 28 | 28 | |
| 29 | 29 | //blowfish |
| 30 | 30 | private static $algo = '$2a'; |
@@ -1,65 +1,65 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - class StringHash{ |
|
| 27 | + class StringHash{ |
|
| 28 | 28 | |
| 29 | - //blowfish |
|
| 30 | - private static $algo = '$2a'; |
|
| 29 | + //blowfish |
|
| 30 | + private static $algo = '$2a'; |
|
| 31 | 31 | |
| 32 | - //cost parameter |
|
| 33 | - private static $cost = '$10'; |
|
| 32 | + //cost parameter |
|
| 33 | + private static $cost = '$10'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Get the unique salt for the string hash |
|
| 37 | - * @return string the unique generated salt |
|
| 38 | - */ |
|
| 39 | - private static function uniqueSalt() { |
|
| 40 | - return substr(sha1(mt_rand()), 0, 22); |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * Get the unique salt for the string hash |
|
| 37 | + * @return string the unique generated salt |
|
| 38 | + */ |
|
| 39 | + private static function uniqueSalt() { |
|
| 40 | + return substr(sha1(mt_rand()), 0, 22); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Hash the given string |
|
| 45 | - * @param string $value the plain string text to be hashed |
|
| 46 | - * @return string the hashed string |
|
| 47 | - */ |
|
| 48 | - public static function hash($value) { |
|
| 49 | - return crypt($value, self::$algo . |
|
| 50 | - self::$cost . |
|
| 51 | - '$' . self::uniqueSalt()); |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * Hash the given string |
|
| 45 | + * @param string $value the plain string text to be hashed |
|
| 46 | + * @return string the hashed string |
|
| 47 | + */ |
|
| 48 | + public static function hash($value) { |
|
| 49 | + return crypt($value, self::$algo . |
|
| 50 | + self::$cost . |
|
| 51 | + '$' . self::uniqueSalt()); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Check if the hash and plain string is valid |
|
| 56 | - * @param string $hash the hashed string |
|
| 57 | - * @param string $plain the plain text |
|
| 58 | - * @return boolean true if is valid or false if not |
|
| 59 | - */ |
|
| 60 | - public static function check($hash, $plain) { |
|
| 61 | - $full_salt = substr($hash, 0, 29); |
|
| 62 | - $new_hash = crypt($plain, $full_salt); |
|
| 63 | - return ($hash === $new_hash); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | 54 | \ No newline at end of file |
| 55 | + /** |
|
| 56 | + * Check if the hash and plain string is valid |
|
| 57 | + * @param string $hash the hashed string |
|
| 58 | + * @param string $plain the plain text |
|
| 59 | + * @return boolean true if is valid or false if not |
|
| 60 | + */ |
|
| 61 | + public static function check($hash, $plain) { |
|
| 62 | + $full_salt = substr($hash, 0, 29); |
|
| 63 | + $new_hash = crypt($plain, $full_salt); |
|
| 64 | + return ($hash === $new_hash); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | \ No newline at end of file |
@@ -222,8 +222,7 @@ |
||
| 222 | 222 | } |
| 223 | 223 | $str .= '</tr>'; |
| 224 | 224 | $str .= '</thead>'; |
| 225 | - } |
|
| 226 | - else{ |
|
| 225 | + } else{ |
|
| 227 | 226 | //no need check for footer |
| 228 | 227 | $use_footer = false; |
| 229 | 228 | } |
@@ -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 | - class Html{ |
|
| 27 | + class Html { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Generate the html anchor link |
@@ -35,21 +35,21 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return string|void the anchor link generated html if $return is true or display it if not |
| 37 | 37 | */ |
| 38 | - public static function a($link = '', $anchor = null, array $attributes = array(), $return = true){ |
|
| 39 | - if(! is_url($link)){ |
|
| 38 | + public static function a($link = '', $anchor = null, array $attributes = array(), $return = true) { |
|
| 39 | + if (!is_url($link)) { |
|
| 40 | 40 | $link = Url::site_url($link); |
| 41 | 41 | } |
| 42 | - if(! $anchor){ |
|
| 42 | + if (!$anchor) { |
|
| 43 | 43 | $anchor = $link; |
| 44 | 44 | } |
| 45 | 45 | $str = null; |
| 46 | - $str .= '<a href = "'.$link.'"'; |
|
| 46 | + $str .= '<a href = "' . $link . '"'; |
|
| 47 | 47 | $str .= attributes_to_string($attributes); |
| 48 | 48 | $str .= '>'; |
| 49 | 49 | $str .= $anchor; |
| 50 | 50 | $str .= '</a>'; |
| 51 | 51 | |
| 52 | - if($return){ |
|
| 52 | + if ($return) { |
|
| 53 | 53 | return $str; |
| 54 | 54 | } |
| 55 | 55 | echo $str; |
@@ -64,18 +64,18 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string|void the generated html for mailto link if $return is true or display it if not |
| 66 | 66 | */ |
| 67 | - public static function mailto($link, $anchor = null, array $attributes = array(), $return = true){ |
|
| 68 | - if(! $anchor){ |
|
| 67 | + public static function mailto($link, $anchor = null, array $attributes = array(), $return = true) { |
|
| 68 | + if (!$anchor) { |
|
| 69 | 69 | $anchor = $link; |
| 70 | 70 | } |
| 71 | 71 | $str = null; |
| 72 | - $str .= '<a href = "mailto:'.$link.'"'; |
|
| 72 | + $str .= '<a href = "mailto:' . $link . '"'; |
|
| 73 | 73 | $str .= attributes_to_string($attributes); |
| 74 | 74 | $str .= '>'; |
| 75 | 75 | $str .= $anchor; |
| 76 | 76 | $str .= '</a>'; |
| 77 | 77 | |
| 78 | - if($return){ |
|
| 78 | + if ($return) { |
|
| 79 | 79 | return $str; |
| 80 | 80 | } |
| 81 | 81 | echo $str; |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string|void the generated "br" html if $return is true or display it if not |
| 90 | 90 | */ |
| 91 | - public static function br($nb = 1, $return = true){ |
|
| 91 | + public static function br($nb = 1, $return = true) { |
|
| 92 | 92 | $nb = (int) $nb; |
| 93 | 93 | $str = null; |
| 94 | 94 | for ($i = 1; $i <= $nb; $i++) { |
| 95 | 95 | $str .= '<br />'; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($return){ |
|
| 98 | + if ($return) { |
|
| 99 | 99 | return $str; |
| 100 | 100 | } |
| 101 | 101 | echo $str; |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return string|void the generated "hr" html if $return is true or display it if not. |
| 111 | 111 | */ |
| 112 | - public static function hr($nb = 1, array $attributes = array(), $return = true){ |
|
| 112 | + public static function hr($nb = 1, array $attributes = array(), $return = true) { |
|
| 113 | 113 | $nb = (int) $nb; |
| 114 | 114 | $str = null; |
| 115 | 115 | for ($i = 1; $i <= $nb; $i++) { |
| 116 | - $str .= '<hr' .attributes_to_string($attributes). ' />'; |
|
| 116 | + $str .= '<hr' . attributes_to_string($attributes) . ' />'; |
|
| 117 | 117 | } |
| 118 | - if($return){ |
|
| 118 | + if ($return) { |
|
| 119 | 119 | return $str; |
| 120 | 120 | } |
| 121 | 121 | echo $str; |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return string|void the generated header html if $return is true or display it if not. |
| 133 | 133 | */ |
| 134 | - public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true){ |
|
| 134 | + public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true) { |
|
| 135 | 135 | $nb = (int) $nb; |
| 136 | 136 | $type = (int) $type; |
| 137 | - if($type <= 0 || $type > 6){ |
|
| 137 | + if ($type <= 0 || $type > 6) { |
|
| 138 | 138 | $type = 1; |
| 139 | 139 | } |
| 140 | 140 | $str = null; |
| 141 | 141 | for ($i = 1; $i <= $nb; $i++) { |
| 142 | - $str .= '<h' . $type . attributes_to_string($attributes). '>' .$text. '</h' . $type . '>'; |
|
| 142 | + $str .= '<h' . $type . attributes_to_string($attributes) . '>' . $text . '</h' . $type . '>'; |
|
| 143 | 143 | } |
| 144 | - if($return){ |
|
| 144 | + if ($return) { |
|
| 145 | 145 | return $str; |
| 146 | 146 | } |
| 147 | 147 | echo $str; |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @return string|void the generated "ul" html if $return is true or display it if not. |
| 158 | 158 | */ |
| 159 | - public static function ul($data = array(), $attributes = array(), $return = true){ |
|
| 159 | + public static function ul($data = array(), $attributes = array(), $return = true) { |
|
| 160 | 160 | $data = (array) $data; |
| 161 | 161 | $str = null; |
| 162 | - $str .= '<ul' . (! empty($attributes['ul']) ? attributes_to_string($attributes['ul']):'') . '>'; |
|
| 162 | + $str .= '<ul' . (!empty($attributes['ul']) ? attributes_to_string($attributes['ul']) : '') . '>'; |
|
| 163 | 163 | foreach ($data as $row) { |
| 164 | - $str .= '<li' . (! empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 164 | + $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>'; |
|
| 165 | 165 | } |
| 166 | 166 | $str .= '</ul>'; |
| 167 | - if($return){ |
|
| 167 | + if ($return) { |
|
| 168 | 168 | return $str; |
| 169 | 169 | } |
| 170 | 170 | echo $str; |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | * @param boolean $return whether need return the generated html or just display it directly |
| 179 | 179 | * @return string|void the generated "ol" html if $return is true or display it if not. |
| 180 | 180 | */ |
| 181 | - public static function ol($data = array(), $attributes = array(), $return = true){ |
|
| 181 | + public static function ol($data = array(), $attributes = array(), $return = true) { |
|
| 182 | 182 | $data = (array) $data; |
| 183 | 183 | $str = null; |
| 184 | - $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']):'') . '>'; |
|
| 184 | + $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']) : '') . '>'; |
|
| 185 | 185 | foreach ($data as $row) { |
| 186 | - $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 186 | + $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>'; |
|
| 187 | 187 | } |
| 188 | 188 | $str .= '</ol>'; |
| 189 | - if($return){ |
|
| 189 | + if ($return) { |
|
| 190 | 190 | return $str; |
| 191 | 191 | } |
| 192 | 192 | echo $str; |
@@ -204,46 +204,46 @@ discard block |
||
| 204 | 204 | * @param boolean $return whether need return the generated html or just display it directly |
| 205 | 205 | * @return string|void the generated "table" html if $return is true or display it if not. |
| 206 | 206 | */ |
| 207 | - public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true){ |
|
| 207 | + public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true) { |
|
| 208 | 208 | $headers = (array) $headers; |
| 209 | 209 | $body = (array) $body; |
| 210 | 210 | $str = null; |
| 211 | - $str .= '<table' . (! empty($attributes['table']) ? attributes_to_string($attributes['table']):'') . '>'; |
|
| 212 | - if(! empty($headers)){ |
|
| 213 | - $str .= '<thead' . (! empty($attributes['thead']) ? attributes_to_string($attributes['thead']):'') .'>'; |
|
| 214 | - $str .= '<tr' . (! empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']):'') .'>'; |
|
| 211 | + $str .= '<table' . (!empty($attributes['table']) ? attributes_to_string($attributes['table']) : '') . '>'; |
|
| 212 | + if (!empty($headers)) { |
|
| 213 | + $str .= '<thead' . (!empty($attributes['thead']) ? attributes_to_string($attributes['thead']) : '') . '>'; |
|
| 214 | + $str .= '<tr' . (!empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']) : '') . '>'; |
|
| 215 | 215 | foreach ($headers as $value) { |
| 216 | - $str .= '<th' . (! empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']):'') .'>' .$value. '</th>'; |
|
| 216 | + $str .= '<th' . (!empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']) : '') . '>' . $value . '</th>'; |
|
| 217 | 217 | } |
| 218 | 218 | $str .= '</tr>'; |
| 219 | 219 | $str .= '</thead>'; |
| 220 | 220 | } |
| 221 | - else{ |
|
| 221 | + else { |
|
| 222 | 222 | //no need check for footer |
| 223 | 223 | $use_footer = false; |
| 224 | 224 | } |
| 225 | - $str .= '<tbody' . (! empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']):'') .'>'; |
|
| 225 | + $str .= '<tbody' . (!empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']) : '') . '>'; |
|
| 226 | 226 | foreach ($body as $row) { |
| 227 | - if(is_array($row)){ |
|
| 228 | - $str .= '<tr' . (! empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']):'') .'>'; |
|
| 227 | + if (is_array($row)) { |
|
| 228 | + $str .= '<tr' . (!empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']) : '') . '>'; |
|
| 229 | 229 | foreach ($row as $value) { |
| 230 | - $str .= '<td' . (! empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']):'') .'>' .$value. '</td>'; |
|
| 230 | + $str .= '<td' . (!empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']) : '') . '>' . $value . '</td>'; |
|
| 231 | 231 | } |
| 232 | 232 | $str .= '</tr>'; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | $str .= '</tbody>'; |
| 236 | - if($use_footer){ |
|
| 237 | - $str .= '<tfoot' . (! empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']):'') .'>'; |
|
| 238 | - $str .= '<tr' . (! empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']):'') .'>'; |
|
| 236 | + if ($use_footer) { |
|
| 237 | + $str .= '<tfoot' . (!empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']) : '') . '>'; |
|
| 238 | + $str .= '<tr' . (!empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']) : '') . '>'; |
|
| 239 | 239 | foreach ($headers as $value) { |
| 240 | - $str .= '<th' . (! empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']):'') .'>' .$value. '</th>'; |
|
| 240 | + $str .= '<th' . (!empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']) : '') . '>' . $value . '</th>'; |
|
| 241 | 241 | } |
| 242 | 242 | $str .= '</tr>'; |
| 243 | 243 | $str .= '</tfoot>'; |
| 244 | 244 | } |
| 245 | 245 | $str .= '</table>'; |
| 246 | - if($return){ |
|
| 246 | + if ($return) { |
|
| 247 | 247 | return $str; |
| 248 | 248 | } |
| 249 | 249 | echo $str; |
@@ -1,251 +1,251 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - class Html{ |
|
| 27 | + class Html{ |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Generate the html anchor link |
|
| 31 | - * @param string $link the href attribute value |
|
| 32 | - * @param string $anchor the displayed anchor |
|
| 33 | - * @param array $attributes the additional attributes to be added |
|
| 34 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 35 | - * |
|
| 36 | - * @return string|void the anchor link generated html if $return is true or display it if not |
|
| 37 | - */ |
|
| 38 | - public static function a($link = '', $anchor = null, array $attributes = array(), $return = true){ |
|
| 39 | - if(! is_url($link)){ |
|
| 40 | - $link = Url::site_url($link); |
|
| 41 | - } |
|
| 42 | - if(! $anchor){ |
|
| 43 | - $anchor = $link; |
|
| 44 | - } |
|
| 45 | - $str = null; |
|
| 46 | - $str .= '<a href = "'.$link.'"'; |
|
| 47 | - $str .= attributes_to_string($attributes); |
|
| 48 | - $str .= '>'; |
|
| 49 | - $str .= $anchor; |
|
| 50 | - $str .= '</a>'; |
|
| 29 | + /** |
|
| 30 | + * Generate the html anchor link |
|
| 31 | + * @param string $link the href attribute value |
|
| 32 | + * @param string $anchor the displayed anchor |
|
| 33 | + * @param array $attributes the additional attributes to be added |
|
| 34 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 35 | + * |
|
| 36 | + * @return string|void the anchor link generated html if $return is true or display it if not |
|
| 37 | + */ |
|
| 38 | + public static function a($link = '', $anchor = null, array $attributes = array(), $return = true){ |
|
| 39 | + if(! is_url($link)){ |
|
| 40 | + $link = Url::site_url($link); |
|
| 41 | + } |
|
| 42 | + if(! $anchor){ |
|
| 43 | + $anchor = $link; |
|
| 44 | + } |
|
| 45 | + $str = null; |
|
| 46 | + $str .= '<a href = "'.$link.'"'; |
|
| 47 | + $str .= attributes_to_string($attributes); |
|
| 48 | + $str .= '>'; |
|
| 49 | + $str .= $anchor; |
|
| 50 | + $str .= '</a>'; |
|
| 51 | 51 | |
| 52 | - if($return){ |
|
| 53 | - return $str; |
|
| 54 | - } |
|
| 55 | - echo $str; |
|
| 56 | - } |
|
| 52 | + if($return){ |
|
| 53 | + return $str; |
|
| 54 | + } |
|
| 55 | + echo $str; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Generate an mailto anchor link |
|
| 60 | - * @param string $link the email address |
|
| 61 | - * @param string $anchor the displayed value of the link |
|
| 62 | - * @param array $attributes the additional attributes to be added |
|
| 63 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 64 | - * |
|
| 65 | - * @return string|void the generated html for mailto link if $return is true or display it if not |
|
| 66 | - */ |
|
| 67 | - public static function mailto($link, $anchor = null, array $attributes = array(), $return = true){ |
|
| 68 | - if(! $anchor){ |
|
| 69 | - $anchor = $link; |
|
| 70 | - } |
|
| 71 | - $str = null; |
|
| 72 | - $str .= '<a href = "mailto:'.$link.'"'; |
|
| 73 | - $str .= attributes_to_string($attributes); |
|
| 74 | - $str .= '>'; |
|
| 75 | - $str .= $anchor; |
|
| 76 | - $str .= '</a>'; |
|
| 58 | + /** |
|
| 59 | + * Generate an mailto anchor link |
|
| 60 | + * @param string $link the email address |
|
| 61 | + * @param string $anchor the displayed value of the link |
|
| 62 | + * @param array $attributes the additional attributes to be added |
|
| 63 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 64 | + * |
|
| 65 | + * @return string|void the generated html for mailto link if $return is true or display it if not |
|
| 66 | + */ |
|
| 67 | + public static function mailto($link, $anchor = null, array $attributes = array(), $return = true){ |
|
| 68 | + if(! $anchor){ |
|
| 69 | + $anchor = $link; |
|
| 70 | + } |
|
| 71 | + $str = null; |
|
| 72 | + $str .= '<a href = "mailto:'.$link.'"'; |
|
| 73 | + $str .= attributes_to_string($attributes); |
|
| 74 | + $str .= '>'; |
|
| 75 | + $str .= $anchor; |
|
| 76 | + $str .= '</a>'; |
|
| 77 | 77 | |
| 78 | - if($return){ |
|
| 79 | - return $str; |
|
| 80 | - } |
|
| 81 | - echo $str; |
|
| 82 | - } |
|
| 78 | + if($return){ |
|
| 79 | + return $str; |
|
| 80 | + } |
|
| 81 | + echo $str; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Generate the html "br" tag |
|
| 86 | - * @param integer $nb the number of generated "<br />" tag |
|
| 87 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 88 | - * |
|
| 89 | - * @return string|void the generated "br" html if $return is true or display it if not |
|
| 90 | - */ |
|
| 91 | - public static function br($nb = 1, $return = true){ |
|
| 92 | - $nb = (int) $nb; |
|
| 93 | - $str = null; |
|
| 94 | - for ($i = 1; $i <= $nb; $i++) { |
|
| 95 | - $str .= '<br />'; |
|
| 96 | - } |
|
| 84 | + /** |
|
| 85 | + * Generate the html "br" tag |
|
| 86 | + * @param integer $nb the number of generated "<br />" tag |
|
| 87 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 88 | + * |
|
| 89 | + * @return string|void the generated "br" html if $return is true or display it if not |
|
| 90 | + */ |
|
| 91 | + public static function br($nb = 1, $return = true){ |
|
| 92 | + $nb = (int) $nb; |
|
| 93 | + $str = null; |
|
| 94 | + for ($i = 1; $i <= $nb; $i++) { |
|
| 95 | + $str .= '<br />'; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - if($return){ |
|
| 99 | - return $str; |
|
| 100 | - } |
|
| 101 | - echo $str; |
|
| 102 | - } |
|
| 98 | + if($return){ |
|
| 99 | + return $str; |
|
| 100 | + } |
|
| 101 | + echo $str; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Generate the html content for tag "hr" |
|
| 106 | - * @param integer $nb the number of generated "<hr />" tag |
|
| 107 | - * @param array $attributes the tag attributes |
|
| 108 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 109 | - * |
|
| 110 | - * @return string|void the generated "hr" html if $return is true or display it if not. |
|
| 111 | - */ |
|
| 112 | - public static function hr($nb = 1, array $attributes = array(), $return = true){ |
|
| 113 | - $nb = (int) $nb; |
|
| 114 | - $str = null; |
|
| 115 | - for ($i = 1; $i <= $nb; $i++) { |
|
| 116 | - $str .= '<hr' .attributes_to_string($attributes). ' />'; |
|
| 117 | - } |
|
| 118 | - if($return){ |
|
| 119 | - return $str; |
|
| 120 | - } |
|
| 121 | - echo $str; |
|
| 122 | - } |
|
| 104 | + /** |
|
| 105 | + * Generate the html content for tag "hr" |
|
| 106 | + * @param integer $nb the number of generated "<hr />" tag |
|
| 107 | + * @param array $attributes the tag attributes |
|
| 108 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 109 | + * |
|
| 110 | + * @return string|void the generated "hr" html if $return is true or display it if not. |
|
| 111 | + */ |
|
| 112 | + public static function hr($nb = 1, array $attributes = array(), $return = true){ |
|
| 113 | + $nb = (int) $nb; |
|
| 114 | + $str = null; |
|
| 115 | + for ($i = 1; $i <= $nb; $i++) { |
|
| 116 | + $str .= '<hr' .attributes_to_string($attributes). ' />'; |
|
| 117 | + } |
|
| 118 | + if($return){ |
|
| 119 | + return $str; |
|
| 120 | + } |
|
| 121 | + echo $str; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Generate the html content for tag like h1, h2, h3, h4, h5 and h6 |
|
| 126 | - * @param integer $type the tag type 1 mean h1, 2 h2, etc, |
|
| 127 | - * @param string $text the display text |
|
| 128 | - * @param integer $nb the number of generated "<h{1,2,3,4,5,6}>" |
|
| 129 | - * @param array $attributes the tag attributes |
|
| 130 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 131 | - * |
|
| 132 | - * @return string|void the generated header html if $return is true or display it if not. |
|
| 133 | - */ |
|
| 134 | - public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true){ |
|
| 135 | - $nb = (int) $nb; |
|
| 136 | - $type = (int) $type; |
|
| 137 | - if($type <= 0 || $type > 6){ |
|
| 138 | - $type = 1; |
|
| 139 | - } |
|
| 140 | - $str = null; |
|
| 141 | - for ($i = 1; $i <= $nb; $i++) { |
|
| 142 | - $str .= '<h' . $type . attributes_to_string($attributes). '>' .$text. '</h' . $type . '>'; |
|
| 143 | - } |
|
| 144 | - if($return){ |
|
| 145 | - return $str; |
|
| 146 | - } |
|
| 147 | - echo $str; |
|
| 148 | - } |
|
| 124 | + /** |
|
| 125 | + * Generate the html content for tag like h1, h2, h3, h4, h5 and h6 |
|
| 126 | + * @param integer $type the tag type 1 mean h1, 2 h2, etc, |
|
| 127 | + * @param string $text the display text |
|
| 128 | + * @param integer $nb the number of generated "<h{1,2,3,4,5,6}>" |
|
| 129 | + * @param array $attributes the tag attributes |
|
| 130 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 131 | + * |
|
| 132 | + * @return string|void the generated header html if $return is true or display it if not. |
|
| 133 | + */ |
|
| 134 | + public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true){ |
|
| 135 | + $nb = (int) $nb; |
|
| 136 | + $type = (int) $type; |
|
| 137 | + if($type <= 0 || $type > 6){ |
|
| 138 | + $type = 1; |
|
| 139 | + } |
|
| 140 | + $str = null; |
|
| 141 | + for ($i = 1; $i <= $nb; $i++) { |
|
| 142 | + $str .= '<h' . $type . attributes_to_string($attributes). '>' .$text. '</h' . $type . '>'; |
|
| 143 | + } |
|
| 144 | + if($return){ |
|
| 145 | + return $str; |
|
| 146 | + } |
|
| 147 | + echo $str; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Generate the html "ul" tag |
|
| 152 | - * @param array $data the data to use for each "li" tag |
|
| 153 | - * @param array $attributes the "ul" properties attribute use the array index below for each tag: |
|
| 154 | - * for ul "ul", for li "li". |
|
| 155 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 156 | - * |
|
| 157 | - * @return string|void the generated "ul" html if $return is true or display it if not. |
|
| 158 | - */ |
|
| 159 | - public static function ul($data = array(), $attributes = array(), $return = true){ |
|
| 160 | - $data = (array) $data; |
|
| 161 | - $str = null; |
|
| 162 | - $str .= '<ul' . (! empty($attributes['ul']) ? attributes_to_string($attributes['ul']):'') . '>'; |
|
| 163 | - foreach ($data as $row) { |
|
| 164 | - $str .= '<li' . (! empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 165 | - } |
|
| 166 | - $str .= '</ul>'; |
|
| 167 | - if($return){ |
|
| 168 | - return $str; |
|
| 169 | - } |
|
| 170 | - echo $str; |
|
| 171 | - } |
|
| 150 | + /** |
|
| 151 | + * Generate the html "ul" tag |
|
| 152 | + * @param array $data the data to use for each "li" tag |
|
| 153 | + * @param array $attributes the "ul" properties attribute use the array index below for each tag: |
|
| 154 | + * for ul "ul", for li "li". |
|
| 155 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 156 | + * |
|
| 157 | + * @return string|void the generated "ul" html if $return is true or display it if not. |
|
| 158 | + */ |
|
| 159 | + public static function ul($data = array(), $attributes = array(), $return = true){ |
|
| 160 | + $data = (array) $data; |
|
| 161 | + $str = null; |
|
| 162 | + $str .= '<ul' . (! empty($attributes['ul']) ? attributes_to_string($attributes['ul']):'') . '>'; |
|
| 163 | + foreach ($data as $row) { |
|
| 164 | + $str .= '<li' . (! empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 165 | + } |
|
| 166 | + $str .= '</ul>'; |
|
| 167 | + if($return){ |
|
| 168 | + return $str; |
|
| 169 | + } |
|
| 170 | + echo $str; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Generate the html "ol" tag |
|
| 175 | - * @param array $data the data to use for each "li" tag |
|
| 176 | - * @param array $attributes the "ol" properties attribute use the array index below for each tag: |
|
| 177 | - * for ol "ol", for li "li". |
|
| 178 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 179 | - * @return string|void the generated "ol" html if $return is true or display it if not. |
|
| 180 | - */ |
|
| 181 | - public static function ol($data = array(), $attributes = array(), $return = true){ |
|
| 182 | - $data = (array) $data; |
|
| 183 | - $str = null; |
|
| 184 | - $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']):'') . '>'; |
|
| 185 | - foreach ($data as $row) { |
|
| 186 | - $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 187 | - } |
|
| 188 | - $str .= '</ol>'; |
|
| 189 | - if($return){ |
|
| 190 | - return $str; |
|
| 191 | - } |
|
| 192 | - echo $str; |
|
| 193 | - } |
|
| 173 | + /** |
|
| 174 | + * Generate the html "ol" tag |
|
| 175 | + * @param array $data the data to use for each "li" tag |
|
| 176 | + * @param array $attributes the "ol" properties attribute use the array index below for each tag: |
|
| 177 | + * for ol "ol", for li "li". |
|
| 178 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 179 | + * @return string|void the generated "ol" html if $return is true or display it if not. |
|
| 180 | + */ |
|
| 181 | + public static function ol($data = array(), $attributes = array(), $return = true){ |
|
| 182 | + $data = (array) $data; |
|
| 183 | + $str = null; |
|
| 184 | + $str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']):'') . '>'; |
|
| 185 | + foreach ($data as $row) { |
|
| 186 | + $str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>'; |
|
| 187 | + } |
|
| 188 | + $str .= '</ol>'; |
|
| 189 | + if($return){ |
|
| 190 | + return $str; |
|
| 191 | + } |
|
| 192 | + echo $str; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Generate the html "table" tag |
|
| 197 | - * @param array $headers the table headers to use between (<thead>) |
|
| 198 | - * @param array $body the table body values between (<tbody>) |
|
| 199 | - * @param array $attributes the table properties attribute use the array index below for each tag: |
|
| 200 | - * for table "table", for thead "thead", for thead tr "thead_tr", |
|
| 201 | - * for thead th "thead_th", for tbody "tbody", for tbody tr "tbody_tr", for tbody td "tbody_td", for tfoot "tfoot", |
|
| 202 | - * for tfoot tr "tfoot_tr", for tfoot th "tfoot_th". |
|
| 203 | - * @param boolean $use_footer whether need to generate table footer (<tfoot>) use the $headers values |
|
| 204 | - * @param boolean $return whether need return the generated html or just display it directly |
|
| 205 | - * @return string|void the generated "table" html if $return is true or display it if not. |
|
| 206 | - */ |
|
| 207 | - public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true){ |
|
| 208 | - $headers = (array) $headers; |
|
| 209 | - $body = (array) $body; |
|
| 210 | - $str = null; |
|
| 211 | - $str .= '<table' . (! empty($attributes['table']) ? attributes_to_string($attributes['table']):'') . '>'; |
|
| 212 | - if(! empty($headers)){ |
|
| 213 | - $str .= '<thead' . (! empty($attributes['thead']) ? attributes_to_string($attributes['thead']):'') .'>'; |
|
| 214 | - $str .= '<tr' . (! empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']):'') .'>'; |
|
| 215 | - foreach ($headers as $value) { |
|
| 216 | - $str .= '<th' . (! empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']):'') .'>' .$value. '</th>'; |
|
| 217 | - } |
|
| 218 | - $str .= '</tr>'; |
|
| 219 | - $str .= '</thead>'; |
|
| 220 | - } |
|
| 221 | - else{ |
|
| 222 | - //no need check for footer |
|
| 223 | - $use_footer = false; |
|
| 224 | - } |
|
| 225 | - $str .= '<tbody' . (! empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']):'') .'>'; |
|
| 226 | - foreach ($body as $row) { |
|
| 227 | - if(is_array($row)){ |
|
| 228 | - $str .= '<tr' . (! empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']):'') .'>'; |
|
| 229 | - foreach ($row as $value) { |
|
| 230 | - $str .= '<td' . (! empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']):'') .'>' .$value. '</td>'; |
|
| 231 | - } |
|
| 232 | - $str .= '</tr>'; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - $str .= '</tbody>'; |
|
| 236 | - if($use_footer){ |
|
| 237 | - $str .= '<tfoot' . (! empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']):'') .'>'; |
|
| 238 | - $str .= '<tr' . (! empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']):'') .'>'; |
|
| 239 | - foreach ($headers as $value) { |
|
| 240 | - $str .= '<th' . (! empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']):'') .'>' .$value. '</th>'; |
|
| 241 | - } |
|
| 242 | - $str .= '</tr>'; |
|
| 243 | - $str .= '</tfoot>'; |
|
| 244 | - } |
|
| 245 | - $str .= '</table>'; |
|
| 246 | - if($return){ |
|
| 247 | - return $str; |
|
| 248 | - } |
|
| 249 | - echo $str; |
|
| 250 | - } |
|
| 251 | - } |
|
| 195 | + /** |
|
| 196 | + * Generate the html "table" tag |
|
| 197 | + * @param array $headers the table headers to use between (<thead>) |
|
| 198 | + * @param array $body the table body values between (<tbody>) |
|
| 199 | + * @param array $attributes the table properties attribute use the array index below for each tag: |
|
| 200 | + * for table "table", for thead "thead", for thead tr "thead_tr", |
|
| 201 | + * for thead th "thead_th", for tbody "tbody", for tbody tr "tbody_tr", for tbody td "tbody_td", for tfoot "tfoot", |
|
| 202 | + * for tfoot tr "tfoot_tr", for tfoot th "tfoot_th". |
|
| 203 | + * @param boolean $use_footer whether need to generate table footer (<tfoot>) use the $headers values |
|
| 204 | + * @param boolean $return whether need return the generated html or just display it directly |
|
| 205 | + * @return string|void the generated "table" html if $return is true or display it if not. |
|
| 206 | + */ |
|
| 207 | + public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true){ |
|
| 208 | + $headers = (array) $headers; |
|
| 209 | + $body = (array) $body; |
|
| 210 | + $str = null; |
|
| 211 | + $str .= '<table' . (! empty($attributes['table']) ? attributes_to_string($attributes['table']):'') . '>'; |
|
| 212 | + if(! empty($headers)){ |
|
| 213 | + $str .= '<thead' . (! empty($attributes['thead']) ? attributes_to_string($attributes['thead']):'') .'>'; |
|
| 214 | + $str .= '<tr' . (! empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']):'') .'>'; |
|
| 215 | + foreach ($headers as $value) { |
|
| 216 | + $str .= '<th' . (! empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']):'') .'>' .$value. '</th>'; |
|
| 217 | + } |
|
| 218 | + $str .= '</tr>'; |
|
| 219 | + $str .= '</thead>'; |
|
| 220 | + } |
|
| 221 | + else{ |
|
| 222 | + //no need check for footer |
|
| 223 | + $use_footer = false; |
|
| 224 | + } |
|
| 225 | + $str .= '<tbody' . (! empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']):'') .'>'; |
|
| 226 | + foreach ($body as $row) { |
|
| 227 | + if(is_array($row)){ |
|
| 228 | + $str .= '<tr' . (! empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']):'') .'>'; |
|
| 229 | + foreach ($row as $value) { |
|
| 230 | + $str .= '<td' . (! empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']):'') .'>' .$value. '</td>'; |
|
| 231 | + } |
|
| 232 | + $str .= '</tr>'; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + $str .= '</tbody>'; |
|
| 236 | + if($use_footer){ |
|
| 237 | + $str .= '<tfoot' . (! empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']):'') .'>'; |
|
| 238 | + $str .= '<tr' . (! empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']):'') .'>'; |
|
| 239 | + foreach ($headers as $value) { |
|
| 240 | + $str .= '<th' . (! empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']):'') .'>' .$value. '</th>'; |
|
| 241 | + } |
|
| 242 | + $str .= '</tr>'; |
|
| 243 | + $str .= '</tfoot>'; |
|
| 244 | + } |
|
| 245 | + $str .= '</table>'; |
|
| 246 | + if($return){ |
|
| 247 | + return $str; |
|
| 248 | + } |
|
| 249 | + echo $str; |
|
| 250 | + } |
|
| 251 | + } |
|
@@ -921,20 +921,15 @@ |
||
| 921 | 921 | if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){ |
| 922 | 922 | if($aresult[1] == '3.1'){ |
| 923 | 923 | $this->setVersion('7.0'); |
| 924 | - } |
|
| 925 | - else if($aresult[1] == '4.0'){ |
|
| 924 | + } else if($aresult[1] == '4.0'){ |
|
| 926 | 925 | $this->setVersion('8.0'); |
| 927 | - } |
|
| 928 | - else if($aresult[1] == '5.0'){ |
|
| 926 | + } else if($aresult[1] == '5.0'){ |
|
| 929 | 927 | $this->setVersion('9.0'); |
| 930 | - } |
|
| 931 | - else if($aresult[1] == '6.0'){ |
|
| 928 | + } else if($aresult[1] == '6.0'){ |
|
| 932 | 929 | $this->setVersion('10.0'); |
| 933 | - } |
|
| 934 | - else if($aresult[1] == '7.0'){ |
|
| 930 | + } else if($aresult[1] == '7.0'){ |
|
| 935 | 931 | $this->setVersion('11.0'); |
| 936 | - } |
|
| 937 | - else if($aresult[1] == '8.0'){ |
|
| 932 | + } else if($aresult[1] == '8.0'){ |
|
| 938 | 933 | $this->setVersion('11.0'); |
| 939 | 934 | } |
| 940 | 935 | } |
@@ -1669,34 +1669,34 @@ |
||
| 1669 | 1669 | protected function checkPlatform() |
| 1670 | 1670 | { |
| 1671 | 1671 | $platformMaps = array( |
| 1672 | - 'windows' => self::PLATFORM_WINDOWS, |
|
| 1673 | - 'iPad' => self::PLATFORM_IPAD, |
|
| 1674 | - 'iPod' => self::PLATFORM_IPOD, |
|
| 1675 | - 'iPhone' => self::PLATFORM_IPHONE, |
|
| 1676 | - 'mac' => self::PLATFORM_APPLE, |
|
| 1677 | - 'android' => self::PLATFORM_ANDROID, |
|
| 1678 | - 'Silk' => self::PLATFORM_FIRE_OS, |
|
| 1679 | - 'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV, |
|
| 1680 | - 'linux' => self::PLATFORM_LINUX, |
|
| 1681 | - 'Nokia' => self::PLATFORM_NOKIA, |
|
| 1682 | - 'BlackBerry' => self::PLATFORM_BLACKBERRY, |
|
| 1683 | - 'FreeBSD' => self::PLATFORM_FREEBSD, |
|
| 1684 | - 'OpenBSD' => self::PLATFORM_OPENBSD, |
|
| 1685 | - 'NetBSD' => self::PLATFORM_NETBSD, |
|
| 1686 | - 'OpenSolaris' => self::PLATFORM_OPENSOLARIS, |
|
| 1687 | - 'SunOS' => self::PLATFORM_SUNOS, |
|
| 1688 | - 'OS\/2' => self::PLATFORM_OS2, |
|
| 1689 | - 'BeOS' => self::PLATFORM_BEOS, |
|
| 1690 | - 'win' => self::PLATFORM_WINDOWS, |
|
| 1691 | - 'Playstation' => self::PLATFORM_PLAYSTATION, |
|
| 1692 | - 'Roku' => self::PLATFORM_ROKU, |
|
| 1693 | - 'iOS' => self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD, |
|
| 1694 | - 'tvOS' => self::PLATFORM_APPLE_TV, |
|
| 1695 | - 'curl' => self::PLATFORM_TERMINAL, |
|
| 1696 | - 'CrOS' => self::PLATFORM_CHROME_OS, |
|
| 1697 | - 'okhttp' => self::PLATFORM_JAVA_ANDROID, |
|
| 1698 | - 'PostmanRuntime' => self::PLATFORM_POSTMAN, |
|
| 1699 | - 'Iframely' => self::PLATFORM_I_FRAME |
|
| 1672 | + 'windows' => self::PLATFORM_WINDOWS, |
|
| 1673 | + 'iPad' => self::PLATFORM_IPAD, |
|
| 1674 | + 'iPod' => self::PLATFORM_IPOD, |
|
| 1675 | + 'iPhone' => self::PLATFORM_IPHONE, |
|
| 1676 | + 'mac' => self::PLATFORM_APPLE, |
|
| 1677 | + 'android' => self::PLATFORM_ANDROID, |
|
| 1678 | + 'Silk' => self::PLATFORM_FIRE_OS, |
|
| 1679 | + 'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV, |
|
| 1680 | + 'linux' => self::PLATFORM_LINUX, |
|
| 1681 | + 'Nokia' => self::PLATFORM_NOKIA, |
|
| 1682 | + 'BlackBerry' => self::PLATFORM_BLACKBERRY, |
|
| 1683 | + 'FreeBSD' => self::PLATFORM_FREEBSD, |
|
| 1684 | + 'OpenBSD' => self::PLATFORM_OPENBSD, |
|
| 1685 | + 'NetBSD' => self::PLATFORM_NETBSD, |
|
| 1686 | + 'OpenSolaris' => self::PLATFORM_OPENSOLARIS, |
|
| 1687 | + 'SunOS' => self::PLATFORM_SUNOS, |
|
| 1688 | + 'OS\/2' => self::PLATFORM_OS2, |
|
| 1689 | + 'BeOS' => self::PLATFORM_BEOS, |
|
| 1690 | + 'win' => self::PLATFORM_WINDOWS, |
|
| 1691 | + 'Playstation' => self::PLATFORM_PLAYSTATION, |
|
| 1692 | + 'Roku' => self::PLATFORM_ROKU, |
|
| 1693 | + 'iOS' => self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD, |
|
| 1694 | + 'tvOS' => self::PLATFORM_APPLE_TV, |
|
| 1695 | + 'curl' => self::PLATFORM_TERMINAL, |
|
| 1696 | + 'CrOS' => self::PLATFORM_CHROME_OS, |
|
| 1697 | + 'okhttp' => self::PLATFORM_JAVA_ANDROID, |
|
| 1698 | + 'PostmanRuntime' => self::PLATFORM_POSTMAN, |
|
| 1699 | + 'Iframely' => self::PLATFORM_I_FRAME |
|
| 1700 | 1700 | ); |
| 1701 | 1701 | |
| 1702 | 1702 | foreach ($platformMaps as $name => $value) { |
@@ -916,27 +916,27 @@ discard block |
||
| 916 | 916 | if (isset($aresult[1])) { |
| 917 | 917 | $this->setBrowser(self::BROWSER_IE); |
| 918 | 918 | $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
| 919 | - if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){ |
|
| 920 | - if($aresult[1] == '3.1'){ |
|
| 919 | + if (preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)) { |
|
| 920 | + if ($aresult[1] == '3.1') { |
|
| 921 | 921 | $this->setVersion('7.0'); |
| 922 | 922 | } |
| 923 | - else if($aresult[1] == '4.0'){ |
|
| 923 | + else if ($aresult[1] == '4.0') { |
|
| 924 | 924 | $this->setVersion('8.0'); |
| 925 | 925 | } |
| 926 | - else if($aresult[1] == '5.0'){ |
|
| 926 | + else if ($aresult[1] == '5.0') { |
|
| 927 | 927 | $this->setVersion('9.0'); |
| 928 | 928 | } |
| 929 | - else if($aresult[1] == '6.0'){ |
|
| 929 | + else if ($aresult[1] == '6.0') { |
|
| 930 | 930 | $this->setVersion('10.0'); |
| 931 | 931 | } |
| 932 | - else if($aresult[1] == '7.0'){ |
|
| 932 | + else if ($aresult[1] == '7.0') { |
|
| 933 | 933 | $this->setVersion('11.0'); |
| 934 | 934 | } |
| 935 | - else if($aresult[1] == '8.0'){ |
|
| 935 | + else if ($aresult[1] == '8.0') { |
|
| 936 | 936 | $this->setVersion('11.0'); |
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | - if(stripos($this->_agent, 'IEMobile') !== false) { |
|
| 939 | + if (stripos($this->_agent, 'IEMobile') !== false) { |
|
| 940 | 940 | $this->setBrowser(self::BROWSER_POCKET_IE); |
| 941 | 941 | $this->setMobile(true); |
| 942 | 942 | } |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | 'mac' => self::PLATFORM_APPLE, |
| 1677 | 1677 | 'android' => self::PLATFORM_ANDROID, |
| 1678 | 1678 | 'Silk' => self::PLATFORM_FIRE_OS, |
| 1679 | - 'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV, |
|
| 1679 | + 'linux_smarttv' => self::PLATFORM_LINUX . '/' . self::PLATFORM_SMART_TV, |
|
| 1680 | 1680 | 'linux' => self::PLATFORM_LINUX, |
| 1681 | 1681 | 'Nokia' => self::PLATFORM_NOKIA, |
| 1682 | 1682 | 'BlackBerry' => self::PLATFORM_BLACKBERRY, |
@@ -1700,9 +1700,9 @@ discard block |
||
| 1700 | 1700 | ); |
| 1701 | 1701 | |
| 1702 | 1702 | foreach ($platformMaps as $name => $value) { |
| 1703 | - if($name == 'linux_smarttv' |
|
| 1703 | + if ($name == 'linux_smarttv' |
|
| 1704 | 1704 | && stripos($this->_agent, 'linux') !== false |
| 1705 | - && stripos($this->_agent, 'SMART-TV') !== false ){ |
|
| 1705 | + && stripos($this->_agent, 'SMART-TV') !== false) { |
|
| 1706 | 1706 | $this->_platform = $value; |
| 1707 | 1707 | break; |
| 1708 | 1708 | } elseif (stripos($this->_agent, $name) !== false) { |
@@ -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 | |
@@ -1,52 +1,52 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | - if(! function_exists('__')){ |
|
| 28 | - /** |
|
| 29 | - * function for the shortcut to Lang::get() |
|
| 30 | - * @param string $key the language key to retrieve |
|
| 31 | - * @param mixed $default the default value to return if can not find the value |
|
| 32 | - * for the given key |
|
| 33 | - * @return string the language value |
|
| 34 | - */ |
|
| 35 | - function __($key, $default = 'LANGUAGE_ERROR'){ |
|
| 36 | - return get_instance()->lang->get($key, $default); |
|
| 37 | - } |
|
| 27 | + if(! function_exists('__')){ |
|
| 28 | + /** |
|
| 29 | + * function for the shortcut to Lang::get() |
|
| 30 | + * @param string $key the language key to retrieve |
|
| 31 | + * @param mixed $default the default value to return if can not find the value |
|
| 32 | + * for the given key |
|
| 33 | + * @return string the language value |
|
| 34 | + */ |
|
| 35 | + function __($key, $default = 'LANGUAGE_ERROR'){ |
|
| 36 | + return get_instance()->lang->get($key, $default); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - if(! function_exists('get_languages')){ |
|
| 43 | - /** |
|
| 44 | - * function for the shortcut to Lang::getSupported() |
|
| 45 | - * |
|
| 46 | - * @return array all the supported languages |
|
| 47 | - */ |
|
| 48 | - function get_languages(){ |
|
| 49 | - return get_instance()->lang->getSupported(); |
|
| 50 | - } |
|
| 42 | + if(! function_exists('get_languages')){ |
|
| 43 | + /** |
|
| 44 | + * function for the shortcut to Lang::getSupported() |
|
| 45 | + * |
|
| 46 | + * @return array all the supported languages |
|
| 47 | + */ |
|
| 48 | + function get_languages(){ |
|
| 49 | + return get_instance()->lang->getSupported(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - } |
|
| 53 | 52 | \ No newline at end of file |
| 53 | + } |
|
| 54 | 54 | \ No newline at end of file |
@@ -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> |
@@ -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,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
| 3 | - /** |
|
| 4 | - * Form validation language message (English) |
|
| 5 | - */ |
|
| 6 | - $lang['fv_required'] = 'Field %1 is required.'; |
|
| 3 | + /** |
|
| 4 | + * Form validation language message (English) |
|
| 5 | + */ |
|
| 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.'; |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | $lang['fv_not_equal_post_key'] = 'Field %1 must not be the same as field %2.'; |
| 15 | 15 | $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
| 16 | 16 | $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
| 17 | - $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
|
| 18 | - $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
| 17 | + $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
|
| 18 | + $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
| 19 | 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).'; |
@@ -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'; |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
| 3 | - /** |
|
| 4 | - * File upload language messages (English) |
|
| 5 | - */ |
|
| 6 | - $lang['fu_upload_err_ini_size'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
|
| 3 | + /** |
|
| 4 | + * File upload language messages (English) |
|
| 5 | + */ |
|
| 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 | 9 | $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
@@ -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,240 +1,240 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - function & class_loader($class, $dir = 'libraries', $params = null){ |
|
| 29 | - //put the first letter of class to upper case |
|
| 30 | - $class = ucfirst($class); |
|
| 31 | - static $classes = array(); |
|
| 32 | - if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
| 33 | - return $classes[$class]; |
|
| 34 | - } |
|
| 35 | - $found = false; |
|
| 36 | - foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
|
| 37 | - $file = $path . $dir . '/' . $class . '.php'; |
|
| 38 | - if(file_exists($file)){ |
|
| 39 | - if(class_exists($class, false) === false){ |
|
| 40 | - require_once $file; |
|
| 41 | - } |
|
| 42 | - //already found |
|
| 43 | - $found = true; |
|
| 44 | - break; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - if(! $found){ |
|
| 48 | - //can't use show_error() at this time because some dependencies not yet loaded |
|
| 49 | - set_http_status_header(503); |
|
| 50 | - echo 'Cannot find the class [' . $class . ']'; |
|
| 51 | - die(); |
|
| 52 | - } |
|
| 28 | + function & class_loader($class, $dir = 'libraries', $params = null){ |
|
| 29 | + //put the first letter of class to upper case |
|
| 30 | + $class = ucfirst($class); |
|
| 31 | + static $classes = array(); |
|
| 32 | + if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
| 33 | + return $classes[$class]; |
|
| 34 | + } |
|
| 35 | + $found = false; |
|
| 36 | + foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
|
| 37 | + $file = $path . $dir . '/' . $class . '.php'; |
|
| 38 | + if(file_exists($file)){ |
|
| 39 | + if(class_exists($class, false) === false){ |
|
| 40 | + require_once $file; |
|
| 41 | + } |
|
| 42 | + //already found |
|
| 43 | + $found = true; |
|
| 44 | + break; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + if(! $found){ |
|
| 48 | + //can't use show_error() at this time because some dependencies not yet loaded |
|
| 49 | + set_http_status_header(503); |
|
| 50 | + echo 'Cannot find the class [' . $class . ']'; |
|
| 51 | + die(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /* |
|
| 54 | + /* |
|
| 55 | 55 | TODO use the best method to get the Log instance |
| 56 | 56 | */ |
| 57 | - if($class == 'Log'){ |
|
| 58 | - //can't use the instruction like "return new Log()" |
|
| 59 | - //because we need return the reference instance of the loaded class. |
|
| 60 | - $log = new Log(); |
|
| 61 | - return $log; |
|
| 62 | - } |
|
| 63 | - //track of loaded classes |
|
| 64 | - class_loaded($class); |
|
| 57 | + if($class == 'Log'){ |
|
| 58 | + //can't use the instruction like "return new Log()" |
|
| 59 | + //because we need return the reference instance of the loaded class. |
|
| 60 | + $log = new Log(); |
|
| 61 | + return $log; |
|
| 62 | + } |
|
| 63 | + //track of loaded classes |
|
| 64 | + class_loaded($class); |
|
| 65 | 65 | |
| 66 | - //record the class instance |
|
| 67 | - $classes[$class] = isset($params) ? new $class($params) : new $class(); |
|
| 66 | + //record the class instance |
|
| 67 | + $classes[$class] = isset($params) ? new $class($params) : new $class(); |
|
| 68 | 68 | |
| 69 | - return $classes[$class]; |
|
| 70 | - } |
|
| 69 | + return $classes[$class]; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - function & class_loaded($class = null){ |
|
| 74 | - static $list = array(); |
|
| 75 | - if($class != null){ |
|
| 76 | - $list[strtolower($class)] = $class; |
|
| 77 | - } |
|
| 78 | - return $list; |
|
| 79 | - } |
|
| 73 | + function & class_loaded($class = null){ |
|
| 74 | + static $list = array(); |
|
| 75 | + if($class != null){ |
|
| 76 | + $list[strtolower($class)] = $class; |
|
| 77 | + } |
|
| 78 | + return $list; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - function & load_configurations(array $overwrite_values = array()){ |
|
| 82 | - static $config; |
|
| 83 | - if(empty($config)){ |
|
| 84 | - $file = CONFIG_PATH . 'config.php'; |
|
| 85 | - require_once $file; |
|
| 81 | + function & load_configurations(array $overwrite_values = array()){ |
|
| 82 | + static $config; |
|
| 83 | + if(empty($config)){ |
|
| 84 | + $file = CONFIG_PATH . 'config.php'; |
|
| 85 | + require_once $file; |
|
| 86 | 86 | |
| 87 | - foreach ($overwrite_values as $key => $value) { |
|
| 88 | - $config[$key] = $value; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - return $config; |
|
| 92 | - } |
|
| 87 | + foreach ($overwrite_values as $key => $value) { |
|
| 88 | + $config[$key] = $value; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + return $config; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @test |
|
| 96 | - */ |
|
| 97 | - function get_config($key, $default = null){ |
|
| 98 | - static $cfg; |
|
| 99 | - if(empty($cfg)){ |
|
| 100 | - $cfg[0] = & load_configurations(); |
|
| 101 | - } |
|
| 102 | - return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
|
| 103 | - } |
|
| 94 | + /** |
|
| 95 | + * @test |
|
| 96 | + */ |
|
| 97 | + function get_config($key, $default = null){ |
|
| 98 | + static $cfg; |
|
| 99 | + if(empty($cfg)){ |
|
| 100 | + $cfg[0] = & load_configurations(); |
|
| 101 | + } |
|
| 102 | + return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - function save_to_log($level, $message, $logger = null){ |
|
| 106 | - echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n"; |
|
| 107 | - } |
|
| 105 | + function save_to_log($level, $message, $logger = null){ |
|
| 106 | + echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n"; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | - function set_http_status_header($code = 200, $text = null){ |
|
| 111 | - echo 'header(' . $code . ', ' . $text . ')'; |
|
| 112 | - return true; |
|
| 113 | - } |
|
| 110 | + function set_http_status_header($code = 200, $text = null){ |
|
| 111 | + echo 'header(' . $code . ', ' . $text . ')'; |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - function show_error($msg, $title = 'error', $logging = true){ |
|
| 117 | - //show only and continue to help track of some error occured |
|
| 118 | - echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n"; |
|
| 119 | - } |
|
| 116 | + function show_error($msg, $title = 'error', $logging = true){ |
|
| 117 | + //show only and continue to help track of some error occured |
|
| 118 | + echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n"; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - function is_https(){ |
|
| 122 | - return false; |
|
| 123 | - } |
|
| 121 | + function is_https(){ |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * @test |
|
| 127 | - */ |
|
| 128 | - function is_url($url){ |
|
| 129 | - return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
|
| 130 | - } |
|
| 125 | + /** |
|
| 126 | + * @test |
|
| 127 | + */ |
|
| 128 | + function is_url($url){ |
|
| 129 | + return preg_match('/^(http|https|ftp):\/\/(.*)/', $url); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - function php_exception_handler($ex){ |
|
| 133 | - //show only and continue to help track of some error occured |
|
| 134 | - echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n"; |
|
| 135 | - } |
|
| 132 | + function php_exception_handler($ex){ |
|
| 133 | + //show only and continue to help track of some error occured |
|
| 134 | + echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n"; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | - function php_error_handler($errno , $errstr, $errfile , $errline){ |
|
| 139 | - //show only and continue to help track of some error occured |
|
| 140 | - echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n"; |
|
| 141 | - } |
|
| 138 | + function php_error_handler($errno , $errstr, $errfile , $errline){ |
|
| 139 | + //show only and continue to help track of some error occured |
|
| 140 | + echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n"; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - function php_shudown_handler(){ |
|
| 144 | - return true; |
|
| 145 | - } |
|
| 143 | + function php_shudown_handler(){ |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * @test |
|
| 150 | - */ |
|
| 151 | - function attributes_to_string(array $attributes){ |
|
| 152 | - $str = ' '; |
|
| 153 | - //we check that the array passed as an argument is not empty. |
|
| 154 | - if(! empty($attributes)){ |
|
| 155 | - foreach($attributes as $key => $value){ |
|
| 156 | - $key = trim(htmlspecialchars($key)); |
|
| 157 | - $value = trim(htmlspecialchars($value)); |
|
| 158 | - /* |
|
| 148 | + /** |
|
| 149 | + * @test |
|
| 150 | + */ |
|
| 151 | + function attributes_to_string(array $attributes){ |
|
| 152 | + $str = ' '; |
|
| 153 | + //we check that the array passed as an argument is not empty. |
|
| 154 | + if(! empty($attributes)){ |
|
| 155 | + foreach($attributes as $key => $value){ |
|
| 156 | + $key = trim(htmlspecialchars($key)); |
|
| 157 | + $value = trim(htmlspecialchars($value)); |
|
| 158 | + /* |
|
| 159 | 159 | * To predict the case where the string to convert contains the character " |
| 160 | 160 | * we check if this is the case we add a slash to solve this problem. |
| 161 | 161 | * For example: |
| 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){ |
|
| 166 | - $value = addslashes($value); |
|
| 167 | - } |
|
| 168 | - $str .= $key.' = "'.$value.'" '; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - //remove the space after using rtrim() |
|
| 172 | - return rtrim($str); |
|
| 173 | - } |
|
| 165 | + if($value && strpos('"', $value) !== false){ |
|
| 166 | + $value = addslashes($value); |
|
| 167 | + } |
|
| 168 | + $str .= $key.' = "'.$value.'" '; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + //remove the space after using rtrim() |
|
| 172 | + return rtrim($str); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - function stringfy_vars($var){ |
|
| 176 | - return print_r($var, true); |
|
| 177 | - } |
|
| 175 | + function stringfy_vars($var){ |
|
| 176 | + return print_r($var, true); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * @test |
|
| 181 | - */ |
|
| 182 | - function clean_input($str){ |
|
| 183 | - if(is_array($str)){ |
|
| 184 | - $str = array_map('clean_input', $str); |
|
| 185 | - } |
|
| 186 | - else if(is_object($str)){ |
|
| 187 | - $obj = $str; |
|
| 188 | - foreach ($str as $var => $value) { |
|
| 189 | - $obj->$var = clean_input($value); |
|
| 190 | - } |
|
| 191 | - $str = $obj; |
|
| 192 | - } |
|
| 193 | - else{ |
|
| 194 | - $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
|
| 195 | - } |
|
| 196 | - return $str; |
|
| 197 | - } |
|
| 179 | + /** |
|
| 180 | + * @test |
|
| 181 | + */ |
|
| 182 | + function clean_input($str){ |
|
| 183 | + if(is_array($str)){ |
|
| 184 | + $str = array_map('clean_input', $str); |
|
| 185 | + } |
|
| 186 | + else if(is_object($str)){ |
|
| 187 | + $obj = $str; |
|
| 188 | + foreach ($str as $var => $value) { |
|
| 189 | + $obj->$var = clean_input($value); |
|
| 190 | + } |
|
| 191 | + $str = $obj; |
|
| 192 | + } |
|
| 193 | + else{ |
|
| 194 | + $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
|
| 195 | + } |
|
| 196 | + return $str; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * @test |
|
| 201 | - */ |
|
| 202 | - function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
| 203 | - //get the string length |
|
| 204 | - $len = strlen($str); |
|
| 205 | - //if str is empty |
|
| 206 | - if($len <= 0){ |
|
| 207 | - return str_repeat($hiddenChar, 6); |
|
| 208 | - } |
|
| 209 | - //if the length is less than startCount and endCount |
|
| 210 | - //or the startCount and endCount length is 0 |
|
| 211 | - //or startCount is negative or endCount is negative |
|
| 212 | - //return the full string hidden |
|
| 199 | + /** |
|
| 200 | + * @test |
|
| 201 | + */ |
|
| 202 | + function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
| 203 | + //get the string length |
|
| 204 | + $len = strlen($str); |
|
| 205 | + //if str is empty |
|
| 206 | + if($len <= 0){ |
|
| 207 | + return str_repeat($hiddenChar, 6); |
|
| 208 | + } |
|
| 209 | + //if the length is less than startCount and endCount |
|
| 210 | + //or the startCount and endCount length is 0 |
|
| 211 | + //or startCount is negative or endCount is negative |
|
| 212 | + //return the full string hidden |
|
| 213 | 213 | |
| 214 | - if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
| 215 | - return str_repeat($hiddenChar, $len); |
|
| 216 | - } |
|
| 217 | - //the start non hidden string |
|
| 218 | - $startNonHiddenStr = substr($str, 0, $startCount); |
|
| 219 | - //the end non hidden string |
|
| 220 | - $endNonHiddenStr = null; |
|
| 221 | - if($endCount > 0){ |
|
| 222 | - $endNonHiddenStr = substr($str, - $endCount); |
|
| 223 | - } |
|
| 224 | - //the hidden string |
|
| 225 | - $hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount)); |
|
| 214 | + if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
| 215 | + return str_repeat($hiddenChar, $len); |
|
| 216 | + } |
|
| 217 | + //the start non hidden string |
|
| 218 | + $startNonHiddenStr = substr($str, 0, $startCount); |
|
| 219 | + //the end non hidden string |
|
| 220 | + $endNonHiddenStr = null; |
|
| 221 | + if($endCount > 0){ |
|
| 222 | + $endNonHiddenStr = substr($str, - $endCount); |
|
| 223 | + } |
|
| 224 | + //the hidden string |
|
| 225 | + $hiddenStr = str_repeat($hiddenChar, $len - ($startCount + $endCount)); |
|
| 226 | 226 | |
| 227 | - return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr; |
|
| 228 | - } |
|
| 227 | + return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - function set_session_config(){ |
|
| 231 | - return true; |
|
| 232 | - } |
|
| 230 | + function set_session_config(){ |
|
| 231 | + return true; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - function & get_instance(){ |
|
| 235 | - if(! Controller::get_instance()){ |
|
| 236 | - $c = new Controller(); |
|
| 237 | - return $c; |
|
| 238 | - } |
|
| 239 | - return Controller::get_instance(); |
|
| 240 | - } |
|
| 234 | + function & get_instance(){ |
|
| 235 | + if(! Controller::get_instance()){ |
|
| 236 | + $c = new Controller(); |
|
| 237 | + return $c; |
|
| 238 | + } |
|
| 239 | + return Controller::get_instance(); |
|
| 240 | + } |
|
@@ -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); |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - /** |
|
| 4 | - * Function to test private & protected method |
|
| 5 | - */ |
|
| 6 | - function runPrivateOrProtectedMethod($object, $method, array $args = array()){ |
|
| 7 | - $r = new ReflectionClass(get_class($object)); |
|
| 8 | - $m = $r->getMethod($method); |
|
| 9 | - $m->setAccessible(true); |
|
| 10 | - return $m->invokeArgs($object, $args); |
|
| 11 | - } |
|
| 12 | 3 | \ No newline at end of file |
| 4 | + /** |
|
| 5 | + * Function to test private & protected method |
|
| 6 | + */ |
|
| 7 | + function runPrivateOrProtectedMethod($object, $method, array $args = array()){ |
|
| 8 | + $r = new ReflectionClass(get_class($object)); |
|
| 9 | + $m = $r->getMethod($method); |
|
| 10 | + $m->setAccessible(true); |
|
| 11 | + return $m->invokeArgs($object, $args); |
|
| 12 | + } |
|
| 13 | 13 | \ No newline at end of file |