Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -78,6 +78,30 @@ |
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
| 82 | +function qp_debug() { |
| 83 | + $args = func_get_args(); |
| 84 | + if ( count( $args ) < 2 ) { |
| 85 | + return; |
| 86 | + } |
| 87 | + list( $var_name, $var_value ) = $args; |
| 88 | + $debug = true; |
| 89 | + if ( count( $args ) > 2 ) { |
| 90 | + $debug = $args[2]; |
| 91 | + } |
| 92 | + if ( $debug === true) { |
| 93 | + ob_start(); |
| 94 | + var_dump( $var_value ); |
| 95 | + $var_value = ob_get_contents(); |
| 96 | + ob_end_clean(); |
| 97 | + wfDebugLog( 'qpoll', "{$var_name} = {$var_value}\n" ); |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +function qp_lc( $text ) { |
| 102 | + global $wgContLang; |
| 103 | + return $wgContLang->lc( $text ); |
| 104 | +} |
| 105 | + |
82 | 106 | /** |
83 | 107 | * Extension's global settings and initializiers |
84 | 108 | * should be purely static and preferrably have no constructor |
— | — | @@ -184,6 +208,7 @@ |
185 | 209 | global $wgHooks; |
186 | 210 | global $wgExtraNamespaces, $wgNamespaceProtection; |
187 | 211 | global $wgGroupPermissions; |
| 212 | + global $wgDebugLogGroups; |
188 | 213 | |
189 | 214 | # core check and local / remote path |
190 | 215 | self::coreRequirements(); |
— | — | @@ -280,6 +305,8 @@ |
281 | 306 | # into the source of interpretation scripts |
282 | 307 | $wgGroupPermissions['sysop']['editinterpretation'] = true; |
283 | 308 | $wgGroupPermissions['bureaucrat']['editinterpretation'] = true; |
| 309 | + |
| 310 | + $wgDebugLogGroups['qpoll'] = 'qpoll_debug_log.txt'; |
284 | 311 | } |
285 | 312 | |
286 | 313 | static function mediaWikiVersionCompare( $version, $operator = '<' ) { |
Index: trunk/extensions/QPoll/qp_eval.php |
— | — | @@ -114,9 +114,11 @@ |
115 | 115 | # math |
116 | 116 | 'round', 'trunc', 'ceil', 'floor', |
117 | 117 | # arrays |
118 | | - 'is_array', 'array_search', |
| 118 | + 'is_array', 'array_search', 'count', |
119 | 119 | # strings |
120 | | - 'preg_match', 'preg_split' |
| 120 | + 'trim', 'preg_match', 'preg_match_all', 'preg_split', 'qp_lc', |
| 121 | + # debug |
| 122 | + 'qp_debug' |
121 | 123 | ); |
122 | 124 | |
123 | 125 | # disallowed superglobals |
— | — | @@ -222,6 +224,12 @@ |
223 | 225 | * @return |
224 | 226 | */ |
225 | 227 | static function selfCheck() { |
| 228 | + # remove unavailable functions from allowed calls list |
| 229 | + foreach ( self::$allowedCalls as $key => $fname ) { |
| 230 | + if ( !function_exists( $fname ) ) { |
| 231 | + self::$allowedCalls[$key] = null; |
| 232 | + } |
| 233 | + } |
226 | 234 | # the following var is used to check access to extension's locals |
227 | 235 | # in the eval scope |
228 | 236 | $selfCheck = 1; |