fpassthru() alternative

I'm using 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?


你可以使用:

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);            
    }
}

echo stream_get_contents($fp);

(而不是fpassthru线)做同样的事情,只有更多的内存消耗(并且比fpassthru更少优化)。

链接地址: http://www.djcxy.com/p/61200.html

上一篇: 新的Wordpress媒体上传工具,精选图片和插件交互

下一篇: fpassthru()替代