0

我将我的站点从根目录移动到了一个名为 /portal 的子目录。但是,所有链接、css 脚本和图像都在链接,就好像该站点仍在根目录中一样。

我的网站是http://thespartaninstitute.com/portal

脚本开发者说这可以在 globals.php 部分进行编辑。虽然我不知道 PHP。你们能帮我看看我应该编辑什么吗?谢谢!以下是我认为 PHP 文件中的相关行。

<?php
session_start();
ini_set("display_errors",1);
error_reporting(E_ALL & ~E_NOTICE);
define('REAL_PUBLIC_PATH',dirname(realpath(__FILE__)));#getcwd()); // e.g. /home/user/public_html
define("PHP_DIR",REAL_PUBLIC_PATH."/../../ClixScript_PHP_DOCS/"); // DEFINE THE PATH TO your ClixScript_PHP_DOCS folder here...
define('STORAGE_DIR',PHP_DIR.'storage/');
define("PHP_ERRORS_DIR",@constant("STORAGE_DIR")."err/PHP_errors.log");
define("START_MICROTIME",microtime(true));
define('REAL_PUBLIC_DIR',basename(getcwd())); // e.g public_html
define('RUN_HOOK',PHP_DIR.'runHook.php');
define('ASSET_POINTS',0);
define('ASSET_CASH',1); // USD
define('ASSET_TE_CREDITS',250); // Traffic Exchange Credits
define('CONTROLLER_DIR',constant("PHP_DIR").'controller/');

#define('PLUGIN_DIR',constant("PHP_DIR").'plugins/');


@set_magic_quotes_runtime(0);
// DO NOT USE MAGIC QUOTES, this method will deal with those who still use it, but it's faster to just turn it off
if (get_magic_quotes_gpc()) {
    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = &$process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}
/** Includes : */
if(defined('INCLUDES') AND INCLUDES === TRUE)
{
// Create array of all classes, their path and filenames (only to be used in __autoload later).
$classes = getDirectory(PHP_DIR.'classes');

foreach ($classes as $path=>$v)
{
    foreach($v as $file)
    {
        $files[] = $file;
        $paths[] = $path;
    }
}
// We need global variables to use in __autoload later...
$GLOBALS['classes_file_names'] = &$classes_file_names; 
$classes_file_names = $files;
$GLOBALS['classes_paths'] = &$classes_paths;
$classes_paths = $paths;

function __autoload($class_name)
{

    $classes_paths = $GLOBALS['classes_paths'];
    $classes_file_names = $GLOBALS['classes_file_names'];

    $filename = strtolower('class.'.$class_name.'.php');

    if(($key = array_search($filename,$classes_file_names)) !== false)
    {
        require_once $classes_paths[$key]."/".$filename;
    }
    else
    {
        return false;
    }    
}


require_once PHP_DIR."config/config.php";

define('CUSTOM_CONTROLLER_DIR',constant("REAL_PUBLIC_PATH").DIRECTORY_SEPARATOR.'portal/view/theme/'.trim(Vars::$conf->site->template).'/ctr/');

$time_zone = Vars::$conf->site->time_zone;
// if time zone has been specified:
if(!empty($time_zone) and strpos($time_zone,'/') !== false)
{
    // set default to it:
    date_default_timezone_set($time_zone);
}

}

if(defined('INCLUDE_PLUGINS') AND INCLUDE_PLUGINS === TRUE)
{

    define('PLUGIN_DIR',constant("REAL_PUBLIC_PATH").'/plugins/');
    define('PLUGIN_URL',Router::getHost().'plugins/');
/**
 * Load plugins (START)
 */ 
$plugins = Plugins::getAllPluginNames();

$classes = array();

foreach($plugins as $plugin)
{
    $path = PLUGIN_DIR.$plugin.'/classes';

    $res = getDirectory($path);
    if(!empty($res))
    {
        $classes[$path] = $res[$path];    
    }
}

foreach ($classes as $path=>$v)
{
    foreach($v as $file)
    {
        $files[] = $file;
        $paths[] = $path;
    }
}

// We need global variables to use in __autoload later...
$classes_file_names = array_merge($classes_file_names,$files);
$classes_paths = array_merge($classes_paths,$paths);


// Load Kohana Classes, start
define('SYSPATH',true);

include PHP_DIR.'classes/kohana/kohana/Exception.php';
include PHP_DIR.'classes/kohana/Exception.php';

include PHP_DIR.'classes/kohana/kohana/Arr.php';
include PHP_DIR.'classes/kohana/Arr.php';

include PHP_DIR.'classes/kohana/kohana/pagination.php';
include PHP_DIR.'classes/kohana/pagination.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/DB.php';
include PHP_DIR.'classes/kohana/database/classes/Kohana/Database.php';
include PHP_DIR.'classes/kohana/database/classes/DB.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Result.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Result.php';
include PHP_DIR.'classes/kohana/database/classes/Database.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Exception.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Exception.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/MySQL/Result.php';
include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/MySQL.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Where.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Where.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Delete.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Delete.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Insert.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Insert.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Join.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Join.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Select.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Select.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Query/Builder/Update.php';
include PHP_DIR.'classes/kohana/database/classes/Database/Query/Builder/Update.php';

include PHP_DIR.'classes/kohana/database/classes/Kohana/Database/Expression.php';

include PHP_DIR.'classes/kohana/database/classes/Database/MySQL.php';
include PHP_DIR.'classes/kohana/database/classes/Database/MySQL/Result.php';

include PHP_DIR.'classes/kohana/database/classes/Database/Expression.php';

// Load Kohana Classes, end

// Load vendors:
include PHP_DIR.'vendor/facebook/base_facebook.php';
include PHP_DIR.'vendor/facebook/facebook.php';
include PHP_DIR.'vendor/phpQuery/phpQuery-onefile.php';

// Load plugins
Plugins::load();
// Set routes for all plugins (will not overwrite these already specified in config)
Plugins::runMethod('routes');


/**
 * Load plugins (END)
 */ 
 }
 else
 {
  #  exit;
 }

Config::$language = 'us';
// If user has chosen language, set it:
if(isset($_COOKIE['language_code']))
{
    if(in_array($_COOKIE['language_code'],array_keys(Config::$valid_languages)))
    {
        Config::$language = $_COOKIE['language_code'];
    }
}
// If user has not set language, detect country of user and choose language based on that:
if(!isset($_COOKIE['language_code']))
{
    $ip2c = new Ip2Country;
    $ip2c->load(User::getRealIP());
    $country = strtolower($ip2c->countryCode);

    if(in_array($country,array_keys(Config::$valid_languages)))
    {
        $expire=60*60*24*365*10;    
        setcookie('language_code',$country,(time()+$expire),'/');
        Config::$language = $country;
    }
}
#$GLOBALS['sidebar_menu'] = $sidebar_menu;
if(!defined('ONLY_GLOBALS'))
{
    include PHP_DIR.'config/variables.php';
}
/**
 * Functions:
 */ 

function getDirectory($path = '.', $ignore = null) {

    $default_ignore = array('.htaccess', 'error_log', 'cgi-bin', 'php.ini', '.ftpquota');
    if($ignore === null) $ignore = $default_ignore;
    else $ignore = array_merge($default_ignore,$ignore);

    $dirTree = array ();
    $dirTreeTemp = array ();
    $ignore[] = '.';
    $ignore[] = '..';

    $dh = @opendir($path);

    if($dh !== false)
    {
        while (false !== ($file = readdir($dh))) {

            if (!in_array($file, $ignore)) {
                if (!is_dir("$path/$file")) {

                    $dirTree["$path"][] = $file;

                } else {

                    $dirTreeTemp = getDirectory("$path/$file", $ignore);
                    if (is_array($dirTreeTemp))$dirTree = array_merge($dirTree, $dirTreeTemp);
                }
            }
        }
        closedir($dh);
    }

    return $dirTree;
}



class ErrorHandling
{
    public function __construct()
    {
        $this->doer();
    }

    public function doer()
    {
        ob_start(array(&$this, 'fatalErrorHandler'));
        set_error_handler(array(&$this, 'errorHandler'));
    }

    public function logError($str)
    {
        $errpath = constant("PHP_ERRORS_DIR");
        $handle = fopen($errpath,"a+");
        fwrite($handle,$str."\r\n");
        fclose($handle);
    }

    public function fatalErrorHandler($buffer)
    {
      if(ereg("(error</b>:)(.+)(<br)", $buffer, $regs))
        {
        $err = preg_replace("/<.*?>/","",$regs[2]);
            $time = "[".Time::unixReadable()."]";
            $this->logError($time.' Fatal Error:'.$err.' [SCRIPT TERMINATED]');
            return "Fatal error occured, execution halted";
      }
      return $buffer;
    }

    public function errorHandler($errno, $errstr, $errfile, $errline)
    {
        $time = "[".Time::unixReadable()."]";
        if($errno != 2048 && $errno != 0)
        {
            switch($errno)
            {
                case 256:
                    $str = $time.' E_USER_ERROR ['.$errno.'] '.$errstr.' in file '.$errfile.'('.$errline.') [SCRIPT TERMINATED]';
                    break;
                case 512:
                    $str = $time.' E_USER_WARNING ['.$errno.'] '.$errstr.' in file '.$errfile.'('.$errline.')';
                break;
                case 8:
                    $str = $time.' E_USER_NOTICE ['.$errno.'] '.$errstr.' in file '.$errfile.'('.$errline.')';
                break;
                default:
                    $str = $time.' Unknown error type ['.$errno.'] '.$errstr.' in file '.$errfile.'('.$errline.')';
                break;
            }
            $this->logError($str);
        }
        elseif($errno == "FATAL" || $errno == "ERROR")
        {
            $this->logError($time.' Fatal Error ['.$errno.'] '.$errstr.' in file '.$errfile.'('.$errline.') [SCRIPT TERMINATED]');
            ob_end_flush();
        }
    }
}

?>
4

1 回答 1

0

/portal在您的文件夹中搜索包含/生成HTML 页面部分的PHP 文件<HEAD>,因为您的包含在那里。
我可以看到您的 HTML 源代码,包含 5-6 个 CSS 和 JavaScript。例如:

<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/view/theme/thespartaninstitute/css/layout.css" />
<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/view/theme/thespartaninstitute/css/jquery.qtip.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/view/theme/thespartaninstitute/css/niceforms-default.css" media="all" />

这些应该是:

<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/portal/view/theme/thespartaninstitute/css/layout.css" />
<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/portal/view/theme/thespartaninstitute/css/jquery.qtip.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://thespartaninstitute.com/portal/view/theme/thespartaninstitute/css/niceforms-default.css" media="all" />

您应该/portal/在每个包含路径的域名之后添加。
如果这些包含在纯 HTML 中,而不仅仅是/portal/在您的域之后键入。

如果有一个 PHP 变量或定义的常量,那么您必须更改它,或者正如我之前提到的,只需/portal/在您的域名后面写。
例如,如果您看到如下内容:

echo SITE_ROOT.'view/theme/thespartaninstitute/css/layout.css';

然后将其更改为:

echo SITE_ROOT.'/portal/view/theme/thespartaninstitute/css/layout.css';

或搜索defineofSITE_ROOT并添加/portal/到它的末尾。在这种情况下,我会建议第一个解决方案。

如果有一个变量或常量包含的不仅仅是站点根目录,如下所示:

echo THEME_INCLUDE_PATH.'css/layout.css';

然后在您的域中找到THEME_INCLUDE_PATH并在您的域之后globals.php添加。/portal/

于 2013-06-04T10:56:34.513 回答