0

我在 Ubuntu 12 上安装 PMA 4.0.7:

wget http://www.sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.7/phpMyAdmin-4.0.7-all-languages.tar.bz2

tar -jxf phpMyAdmin-4.0.7-all-languages.tar.bz2

但无法在浏览器中打开它,Chrome 显示空白页 .. 控制台出现错误:

Uncaught SyntaxError: Unexpected token ILLEGAL get_scripts.js.php:13876

CodeMirror.defineMIME("text/x-mysql", "mysql");
;

�  // <- unreadible character goes there

有人可以帮助我吗?

谢谢!

4

3 回答 3

2

我也有这个问题。事实证明,该文件是作为 HTTP 1.1 发送的,b/c 它没有 Content-Length 标头,以分块编码的形式出现。额外的字符是由于不完整的块。我将 get_scripts.js.php 文件修改为此,现在它适用于我:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Concatenates reveral js files to reduce the number of
 * http requests sent to the server
 *
 * @package PhpMyAdmin
 */
chdir('..');

// Send correct type
header('Content-Type: text/javascript; charset=UTF-8');
// Enable browser cache for 1 hour
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');

if (! empty($_GET['scripts']) && is_array($_GET['scripts'])) {
    $total_length = 0;
    foreach ($_GET['scripts'] as $script) {
        // Sanitise filename
        $script_name = 'js';
        $path = explode("/", $script);
        foreach ($path as $index => $filename) {
            if (! preg_match("@^\.+$@", $filename)
                && preg_match("@^[\w\.-]+$@", $filename)
            ) {
                // Disallow "." and ".." alone
                // Allow alphanumeric, "." and "-" chars only
                $script_name .= DIRECTORY_SEPARATOR . $filename;
            }
        }
        // Count file size
        if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
            $total_length += filesize($script_name) + 3;
        }
    }
    header('Content-Length: '.$total_length);
    foreach ($_GET['scripts'] as $script) {
      // Sanitise filename
      $script_name = 'js';
      $path = explode("/", $script);
      foreach ($path as $index => $filename) {
        if (! preg_match("@^\.+$@", $filename)
            && preg_match("@^[\w\.-]+$@", $filename)
        ) {
          // Disallow "." and ".." alone
          // Allow alphanumeric, "." and "-" chars only
          $script_name .= DIRECTORY_SEPARATOR . $filename;
        }
      }
      // Output file contents
      if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
          readfile($script_name);
          echo ";\n\n";
      }
    }
}
?>
于 2013-11-11T04:18:37.850 回答
0

我无法在 Chrome 下重现您的问题。尝试再次下载,可能是 .tar.gz 文件。

于 2013-10-02T15:00:06.857 回答
0

禁用/删除/更正 Tidy HTML PHP 扩展的设置。

我有一个运行 CentOS 6.6 的 VM 开发盒,在安装和配置 x-debug 时遇到了这个问题。当我安装 xdebug 扩展时,我看到了 Tidy HTML,并认为这将是使我生成的 HTML 更清晰、更易于阅读的好方法。

一切都很顺利,直到几天后我尝试访问 phpMyAdmin 并在 Chrome 中看到一个空白页面和 5 条 Unexpected Token 错误消息。经过大量研究、设置调整、重新安装 phpMyAdmin,并尝试按照 Jeremy Miller 的建议添加 Content-Length 标头,我最终决定重置整个服务器配置。

首先我恢复了我的 phpMyAdmin 配置,然后是我的 Apache 配置。没运气。然后我删除了我所有的 PHP 扩展。突然,我收到一条错误消息而不是空白页!进步!我重新添加了 phpMyAdmin 所需的扩展:mbstring.ini、json.ini 和 mysqli.ini,并显示了 phpMyAdmin 登录。

由于我的 Linux 技能较弱,经过艰苦的消除过程,我发现 Tidy HTML 扩展导致了问题。

我希望这可以帮助那些不假思索地冲动安装扩展的人。

于 2015-12-15T16:25:11.527 回答