开发者

fpassthru() alternative

开发者 https://www.devze.com 2023-03-07 10:47 出处:网络
I\'m u开发者_StackOverflowsing WP-MINIFY plugin on my Wordpress blog but because of my server\'s security configurations, fpassthru() function is disable. So, i have to find an alternative way, so i c

I'm u开发者_StackOverflowsing WP-MINIFY plugin on my Wordpress blog but because of my server's security configurations, fpassthru() function is disable. So, i have to find an alternative way, so i can edit plugin.

I'm getting this error on minified files :

Warning: fpassthru() has been disabled for security reasons in /home/blablabla/public_html/wp-content/plugins/wp-minify/min/lib/Minify/Cache/File.php on line 84

This is the function which using fpassthru :

/**
 * Send the cached content to output
 *
 * @param string $id cache id (e.g. a filename)
 */
public function display($id)
{
    if ($this->_locking) {
        $fp = fopen($this->_path . '/' . $id, 'rb');
        flock($fp, LOCK_SH);
        fpassthru($fp);
        flock($fp, LOCK_UN);
        fclose($fp);
    } else {
        readfile($this->_path . '/' . $id);            
    }
}

Do you have any idea?


echo stream_get_contents($fp);

(instead of the fpassthru line) does the same thing, only with more memory consumption (and less optimized than fpassthru).


You could use:

public function display($id)
{
    $filename=$this->_path . '/' . $id;
    if ($this->_locking) {
        $fp = fopen($filename, 'rb');
        flock($fp, LOCK_SH);
        //fpassthru($fp);
        $out=fread($fp,filesize($filename));
        echo $out;
        flock($fp, LOCK_UN);
        fclose($fp);
    } else {
        readfile($filename);            
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号