2014-03-31 51 views
0

首先,對於長標題抱歉,我從未預料到這個錯誤,所以我不知道如何描述它。警告:file_exists()[function.file-exists]:open_basedir限制有效。文件(/ usr/local/apache/bin/apachectl)

我得到這個錯誤:

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/local/apache/bin/apachectl) is not within the allowed path(s): (/home/:/backup/:/tmp/) in /home/xxxxx/public_html/plugins/system/jch_optimize/jchoptimize/helper.php on line 176 

莫非有什麼東西在tmp目錄中已被使用或缺少的東西?

我迷失在這裏,我從哪裏開始?

這裏是helper.php:

<?php 
use JchOptimize\JSMinRegex; 
/** 
* JCH Optimize - Joomla! plugin to aggregate and minify external resources for 
* optmized downloads 
* @author Samuel Marshall <[email protected]> 
* @copyright Copyright (c) 2010 Samuel Marshall 
* @license GNU/GPLv3, See LICENSE file 
* This program is free software: you can redistribute it and/or modify 
* it under the terms of the GNU General Public License as published by 
* the Free Software Foundation, either version 3 of the License, or 
* (at your option) any later version. 
* 
* This program is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
* GNU General Public License for more details. 
* 
* If LICENSE file missing, see <http://www.gnu.org/licenses/>. 
* 
* This plugin, inspired by CssJsCompress <http://www.joomlatags.org>, was 
* created in March 2010 and includes other copyrighted works. See individual 
* files for details. 
*/ 
defined('_JEXEC') or die('Restricted access'); 
/** 
* Some helper functions 
* 
*/ 
class JchOptimizeHelper 
{ 
     /** 
     * Checks if file (can be external) exists 
     * 
     * @param type $sPath 
     * @return boolean 
     */ 
     public static function fileExists($sPath) 
     { 
       //global $_PROFILER; 
       //JCH_DEBUG ? $_PROFILER->mark('beforeFileExists - ' . $sPath . ' plgSystem (JCH Optimize)') : null; 
       $bExists = (file_exists($sPath) || @fopen($sPath, "r") != FALSE); 
       //JCH_DEBUG ? $_PROFILER->mark('afterFileExists - ' . $sPath . ' plgSystem (JCH Optimize)') : null; 
       return $bExists; 
     } 
     /** 
     * Get local path of file from the url if internal 
     * If external or php file, the url is returned 
     * 
     * @param string $sUrl Url of file 
     * @return string  File path 
     */ 
     public static function getFilePath($sUrl) 
     { 
       // global $_PROFILER; 
       //JCH_DEBUG ? $_PROFILER->mark('beforeGetFilePath - ' . $sUrl . ' plgSystem (JCH Optimize)') : null; 
       $sUriBase = str_replace('/administrator/', '', JUri::base()); 
       $sUriPath = str_replace('/administrator', '', JUri::base(TRUE)); 
       $oUri = clone JUri::getInstance($sUriBase); 
       if (JchOptimizeHelper::isInternal($sUrl) && !preg_match('#\.php#i', $sUrl)) 
       { 
         $sUrl = preg_replace(
           array(
           '#^' . preg_quote($sUriBase, '#') . '#', 
           '#^' . preg_quote($sUriPath, '#') . '/#', 
           '#\?.*?$#' 
           ), '', $sUrl); 
         //JCH_DEBUG ? $_PROFILER->mark('afterGetFilePath - ' . $sUrl . ' plgSystem (JCH Optimize)') : null; 
         return JPATH_ROOT . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $sUrl); 
       } 
       else 
       { 
         switch (TRUE) 
         { 
           case preg_match('#://#', $sUrl): 
             break; 
           case (substr($sUrl, 0, 2) == '//'): 
             $sUrl = $oUri->toString(array('scheme')) . substr($sUrl, 2); 
             break; 
           case (substr($sUrl, 0, 1) == '/'): 
             $sUrl = $oUri->toString(array('scheme', 'host')) . $sUrl; 
             break; 
           default: 
             $sUrl = $sUriBase . $sUrl; 
             break; 
         } 
         //JCH_DEBUG ? $_PROFILER->mark('afterGetFilePath - ' . $sUrl . ' plgSystem (JCH Optimize)') : null; 
         return html_entity_decode($sUrl); 
       } 
     } 
     /** 
     * Gets the name of the current Editor 
     * 
     * @staticvar string $sEditor 
     * @return string 
     */ 
     public static function getEditorName() 
     { 
       static $sEditor; 
       if (!isset($sEditor)) 
       { 
         $sEditor = JFactory::getUser()->getParam('editor'); 
         $sEditor = !isset($sEditor) ? JFactory::getConfig()->get('editor') : $sEditor; 
       } 
       return $sEditor; 
     } 
     /** 
     * Determines if file is internal 
     * 
     * @param string $sUrl Url of file 
     * @return boolean 
     */ 
     public static function isInternal($sUrl) 
     { 
       $oUrl = JUri::getInstance($sUrl); 
       //trying to resolve bug in php with parse_url before 5.4.7 
       if (preg_match('#^//([^/]+)(/.*)$#i', $oUrl->getPath(), $aMatches)) 
       { 
         if (!empty($aMatches)) 
         { 
           $oUrl->setHost($aMatches[1]); 
           $oUrl->setPath($aMatches[2]); 
         } 
       } 
       $sBase = $oUrl->toString(array('scheme', 'host', 'port', 'path')); 
     $sHost = $oUrl->toString(array('scheme', 'host', 'port')); 
     if (stripos($sBase, JUri::base()) !== 0 && !empty($sHost)) 
     { 
      return FALSE; 
     } 
     return TRUE; 
     } 
     /** 
     * 
     * @staticvar string $sContents 
     * @return boolean 
     */ 
     public static function modRewriteEnabled() 
     { 
       if (function_exists('apache_get_modules')) 
       { 
         return (in_array('mod_rewrite', apache_get_modules())); 
       } 
       elseif (file_exists('/usr/local/apache/bin/apachectl')) 
       { 
         return (strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false); 
       } 
       else 
       { 
         static $sContents = ''; 
         if ($sContents == '') 
         { 
           $oFileRetriever = JchOptimizeFileRetriever::getInstance($GLOBALS['oParams']); 
           $sJbase   = JUri::base(true); 
           $sBaseFolder = $sJbase == '/' ? $sJbase : $sJbase . '/'; 
           $sUrl  = JUri::base() . 'plugins/system/jch_optimize/assets' . $sBaseFolder . 'test_mod_rewrite'; 
           if (!$oFileRetriever->isUrlFOpenAllowed()) 
           { 
             return FALSE; 
           } 
           $sContents = $oFileRetriever->getFileContents($sUrl); 
         } 
         if ($sContents == 'TRUE') 
         { 
           return TRUE; 
         } 
         else 
         { 
           return FALSE; 
         } 
       } 
     } 
     /** 
     * 
     * @param type $aArray 
     * @param type $sString 
     * @return boolean 
     */ 
     public static function findExcludes($aArray, $sString, $bScript=FALSE) 
     { 
       foreach ($aArray as $sValue) 
       { 
         if($bScript) 
         { 
           $sString = JSMinRegex::minify($sString); 
         } 
         if ($sValue && strpos($sString, $sValue) !== FALSE) 
         { 
           return TRUE; 
         } 
       } 
       return FALSE; 
     } 
} 

回答

1

這個腳本要開 '的/ usr /本地/ Apache /斌/的apachectl',但不是由您的服務器託管商不允許的。

看行176:

elseif (file_exists('/usr/local/apache/bin/apachectl')) 

看起來它是安全的刪除線。

+0

好的,先生,我會做到這一點,讓你知道,如果事情的工作,:) – 023023

+0

我這樣做: '/ * ELSEIF(file_exists( '的/ usr /本地/ Apache /斌/的apachectl')) {stripe(shell_exec('/ usr/local/apache/bin/apachectl -l'),'mod_rewrite')!== false); } 其他 * /' 是否確定? – 023023

+0

這確實沒關係。 –

5

open_basedir是一種服務器配置安全措施,用於禁止(通常情況下)webroot以外的文件訪問。

這可以防止腳本讀取服務器上的隨機文件。如果您的服務器已經被入侵,open_basedir可以幫助減少妥協的影響。

總的來說這是一件好事,但你似乎想做些有點腥的事情。

看看你的php.inihttpd.conf你可以在那裏禁用它。


它看起來像這個腳本想要檢查某個插件的文件夾。這是不好的做法,使用apache_get_modules是正確的。您可以簡單地刪除有問題的代碼。

該腳本甚至嘗試shell_exec,這就是爲什麼你必須非常小心你在互聯網上找到的隨機代碼。在這種情況下,它不是惡意的,而是簡單的奇怪。

+0

嘿,thx爲偉大的解釋和提示,但是,這是沒有隨機代碼,我得到了Joomla擴展目錄的插件。你是對的,這是一個安全功能,我也認爲它不應該被禁用,所以我的解決方法就是刪除那個jreuab建議的那一行。 – 023023

+0

是的,該行和後面的代碼塊(用'shell_exec') – Halcyon

相關問題