0

WordPressで実行しているWebサイトがあります。このサイトのドキュメント ルートには、WordPress のインストールとは関係のない PHP スクリプトをテストするディレクトリがあります。実際に存在するファイルを要求またはインクルードすると、404 が返されることに気付きました。require ステートメントをコメントアウトすれば、すべて問題ありません。最初は、これは構文エラーが原因でした。しかし、それをクリーンアップしたところ、error_log ファイルに何も記録されなくなりました。何を与える?

編集:私のメイン error_log: でこれを見つけましたmalformed header from script. Bad header=X-UA-Compatible: ide.php。他のApacheサーバーでこれに問題があったことはありません.

以下は、問題のあるスクリプトです。

ide.php

<?php

require_once 'config.php';

if (isset($_SESSION['username'])) {
    if (isset($_POST['command'])) {
        if ($_POST['session'] == '@') {
            session_destroy();
            header('Location: /area51/ide.php');
        } else {
            echo 'None';
        }
    } else {
        $smarty->assign('version', shell_exec("/home1/tylercro/local/python3/bin/python3 -c \"import sys;print('Python', sys.version)\""));
        $smarty->display('ide.tpl');
    }
} else {
    if (isset($_POST['username']) && isset($_POST['password'])) {
        if ($_POST['username'] == 'user' && $_POST['password'] == 'password') {
            $_SESSION['username'] = $_POST['username'];
        }
        header('Location: /area51/ide.php');
    } else {
        $smarty->display('ide-login.tpl');
    }
}

?>

config.php

<?php

error_reporting(E_ALL);

session_start();

if (!headers_sent()) {
    header('X-UA-Compatible: chrome=1');
    header('Content-Type: text/html; charset=UTF-8');
}

require_once 'Smarty-3.1.8/Smarty.class.php';

$smarty = new Smarty();
$smarty->setTemplateDir('Smarty-3.1.8/templates/');
$smarty->setCompileDir('Smarty-3.1.8/templates_c/');
$smarty->setCacheDir('Smarty-3.1.8/cache/');
$smarty->setConfigDir('Smarty-3.1.8/configs/');

?>
4

1 に答える 1

0

ヘッダーの問題でした。送信したヘッダーにいくつかの構文エラーがありました。

于 2012-05-24T21:37:56.607 に答える