OSDN Git Service

A little cleanup:
authorhenoheno <henoheno>
Tue, 3 Oct 2006 14:16:31 +0000 (23:16 +0900)
committerumorigu <umorigu@gmail.com>
Sun, 1 Jun 2014 21:20:29 +0000 (06:20 +0900)
* Remove unused variable
* Use intval() to say why it's safe without htmlspecialchars() clearly
* BugTrack2/182: With php.ini: allow_call_time_pass_reference = Off
 'Warning: Call-time pass-by-reference has been deprecated'
 with array_walk (Patched by Ratbeta)

plugin/pcomment.inc.php

index e826f04..e56ee8b 100644 (file)
@@ -67,8 +67,6 @@ function plugin_pcomment_convert()
        global $vars;
        global $_pcmt_messages;
 
-       $ret = '';
-
        $params = array(
                'noname'=>FALSE,
                'nodate'=>FALSE,
@@ -78,16 +76,14 @@ function plugin_pcomment_convert()
                '_args' =>array()
        );
 
-       // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
-       $args = func_get_args(); // with array_walk()
-       array_walk($args, 'plugin_pcomment_check_arg', & $params);
+       foreach(func_get_args() as $arg)
+               plugin_pcomment_check_arg($arg, $params);
 
        $vars_page = isset($vars['page']) ? $vars['page'] : '';
        $page  = (isset($params['_args'][0]) && $params['_args'][0] != '') ? $params['_args'][0] :
                sprintf(PLUGIN_PCOMMENT_PAGE, strip_bracket($vars_page));
-       $count = (isset($params['_args'][1]) && $params['_args'][1] != '') ? $params['_args'][1] : 0;
-       if ($count == 0 && $count !== '0')
-               $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
+       $count = isset($params['_args'][1]) ? intval($params['_args'][1]) : 0;
+       if ($count == 0) $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
 
        $_page = get_fullname(strip_bracket($page), $vars_page);
        if (!is_pagename($_page))
@@ -171,8 +167,7 @@ EOD;
 
 function plugin_pcomment_insert()
 {
-       global $script, $vars, $now;
-       global $_title_updated, $_no_name, $_pcmt_messages;
+       global $vars, $now, $_title_updated, $_no_name, $_pcmt_messages;
 
        $refer = isset($vars['refer']) ? $vars['refer'] : '';
        $page  = isset($vars['page'])  ? $vars['page']  : '';
@@ -303,7 +298,7 @@ function plugin_pcomment_auto_log($page, $dir, $count, & $postdata)
 }
 
 // Check arguments
-function plugin_pcomment_check_arg($val, $key, & $params)
+function plugin_pcomment_check_arg($val, & $params)
 {
        if ($val != '') {
                $l_val = strtolower($val);