diff --git a/coverage.php b/adminer/coverage.inc.php similarity index 60% rename from coverage.php rename to adminer/coverage.inc.php index 055261f3..dc0bbf4e 100644 --- a/coverage.php +++ b/adminer/coverage.inc.php @@ -1,11 +1,4 @@ Xdebug has to be enabled.

\n"; -} +page_header("Coverage", (extension_loaded("xdebug") ? "" : "Xdebug has to be enabled.")); -if ($_GET["start"]) { - unset($_SESSION["coverage"]); - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - $_SESSION["coverage"] = array(); - include "./adminer/index.php"; - header("Location: ."); - exit; -} -if (preg_match('~^(include/)?[-_.a-z0-9]+$~i', $_GET["filename"])) { +if ($_GET["coverage"] === "0") { + unset($_SESSION["coverage"]); // disable coverage if it is not available + if (extension_loaded("xdebug")) { + $_SESSION["coverage"] = array(); + echo "

Coverage started.

\n"; + } +} elseif (preg_match('~^(include/)?[-_.a-z0-9]+$~i', $_GET["coverage"])) { // highlight single file - $filename = "adminer/$_GET[filename]"; + $filename = $_GET["coverage"]; $cov = $_SESSION["coverage"][realpath($filename)]; $file = explode("
", highlight_file($filename, true)); unset($prev_color); @@ -64,17 +53,18 @@ if (preg_match('~^(include/)?[-_.a-z0-9]+$~i', $_GET["filename"])) { } } else { // display list of files - echo "\n"; - foreach (array_merge(glob("adminer/*.php"), glob("adminer/include/*.php")) as $filename) { + echo "
\n"; + foreach (array_merge(glob("*.php"), glob("include/*.php")) as $filename) { $cov = $_SESSION["coverage"][realpath($filename)]; - $filename = substr($filename, 8); $ratio = 0; if (isset($cov)) { $values = array_count_values($cov); $ratio = round(100 - 100 * $values[-1] / count($cov)); } - echo "\n"; + echo "\n"; } echo "
$ratio%$filename
$ratio%$filename
\n"; - echo "

Start new coverage (requires Xdebug)

\n"; + echo '

Start new coverage

' . "\n"; } +page_footer("auth"); +exit; diff --git a/adminer/index.php b/adminer/index.php index 23e1e1de..04f28c8d 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -26,10 +26,6 @@ if (isset($_SESSION["coverage"])) { } xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); register_shutdown_function('save_coverage'); - if ($_GET["start"]) { - // included from ../coverage.php - return; - } } // disable magic quotes to be able to use database escaping function if (get_magic_quotes_gpc()) { @@ -55,6 +51,9 @@ include "./include/functions.inc.php"; include "./include/lang.inc.php"; include "./lang/$LANG.inc.php"; include "./include/design.inc.php"; +if (isset($_GET["coverage"])) { + include "./coverage.inc.php"; +} include "./include/pdo.inc.php"; include "./include/mysql.inc.php"; include "./include/auth.inc.php"; diff --git a/compile.php b/compile.php index 3f2ce468..36624937 100644 --- a/compile.php +++ b/compile.php @@ -171,6 +171,7 @@ if ($_SERVER["argc"] > 1) { $filename = "adminer" . ($_COOKIE["adminer_lang"] ? "-$_COOKIE[adminer_lang]" : "") . ".php"; $file = file_get_contents(dirname(__FILE__) . "/adminer/index.php"); +$file = preg_replace('(' . str_replace(' ', '\\s*', preg_quote(' if (isset($_GET["coverage"])) { include "./coverage.inc.php"; }')) . ')', '', $file); $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); $file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file); if ($_COOKIE["adminer_lang"]) { diff --git a/tests/0-login.html b/tests/0-login.html index aac7c98a..d1fe3c71 100644 --- a/tests/0-login.html +++ b/tests/0-login.html @@ -13,7 +13,7 @@ open - /adminer/coverage.php?start=1 + /adminer/adminer/?coverage=0 diff --git a/tests/logout.html b/tests/logout.html index 1e1480cd..d3358b14 100644 --- a/tests/logout.html +++ b/tests/logout.html @@ -38,7 +38,7 @@ open - /adminer/coverage.php + /adminer/adminer/?coverage=