diff --git a/adminer/coverage.inc.php b/adminer/coverage.inc.php deleted file mode 100644 index 47f5cf1d..00000000 --- a/adminer/coverage.inc.php +++ /dev/null @@ -1,72 +0,0 @@ -]+)~', $s, $matches); - foreach ($matches[1] as $val) { - if ($val{0} == "/") { - array_pop($return); - } elseif (substr($val, -1) != "/") { - $return[] = $val; - } - } - return $return; -} - -page_header("Coverage", (extension_loaded("xdebug") ? "" : "Xdebug has to be enabled.")); - -if ($_GET["coverage"] === "0") { - unset($_SESSION["coverage"]); // disable coverage if it is not available - if (extension_loaded("xdebug")) { - $_SESSION["coverage"] = array(); - echo "
$ratio% | $filename\n"; - } - echo " |
---|
Start new coverage' . "\n"; -} -page_footer("auth"); -exit; diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 5d07e803..d042fe5a 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -1,6 +1,8 @@ $lines) { - foreach ($lines as $l => $val) { - if (!$_SESSION["coverage"][$filename][$l] || $val > 0) { - $_SESSION["coverage"][$filename][$l] = $val; - } - } - } - } - xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - register_shutdown_function('save_coverage'); -} - // disable magic quotes to be able to use database escaping function if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE); @@ -86,9 +73,6 @@ include "../adminer/include/lang.inc.php"; include "../adminer/lang/$LANG.inc.php"; include "./include/adminer.inc.php"; include "../adminer/include/design.inc.php"; -if (isset($_GET["coverage"])) { - include "../adminer/coverage.inc.php"; -} include "../adminer/include/pdo.inc.php"; include "../adminer/include/mysql.inc.php"; include "../adminer/include/auth.inc.php"; diff --git a/adminer/include/coverage.inc.php b/adminer/include/coverage.inc.php new file mode 100644 index 00000000..1883c66a --- /dev/null +++ b/adminer/include/coverage.inc.php @@ -0,0 +1,25 @@ + $lines) { + foreach ($lines as $l => $val) { + if (!$coverage[$filename][$l] || $val > 0) { + $coverage[$filename][$l] = $val; + } + } + mysql_query(" + REPLACE adminer_test.coverage (filename, coverage_serialize) + VALUES ('" . mysql_real_escape_string($filename) . "', '" . mysql_real_escape_string(serialize($coverage[$filename])) . "') + "); + } + } + xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); + register_shutdown_function('save_coverage'); +} diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index c627b110..0174d1b7 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -46,7 +46,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { if (strlen($_GET["db"]) && $databases && !in_array($_GET["db"], $databases, true)) { $databases = null; } - if (isset($databases) && !isset($_GET["sql"]) && !isset($_SESSION["coverage"])) { + if (isset($databases) && !isset($_GET["sql"])) { // improves concurrency if a user opens several pages at once session_write_close(); } diff --git a/compile.php b/compile.php index 2515dfee..a2a670f8 100644 --- a/compile.php +++ b/compile.php @@ -192,9 +192,8 @@ if (isset($_SERVER["argv"][1])) { $file = file_get_contents(dirname(__FILE__) . "/$project/index.php"); $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); -$file = preg_replace('(' . str_replace(' ', '\\s*', preg_quote(' if (isset($_GET["coverage"])) { include "../adminer/coverage.inc.php"; }')) . ')', '', $file); +$file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file); $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php -$file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file); $file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file); $file = preg_replace_callback('~\\b(include|require) "([^"]*\\$LANG.inc.php)";~', 'put_file_lang', $file); if ($_COOKIE["adminer_lang"]) { diff --git a/coverage.php b/coverage.php new file mode 100644 index 00000000..794946df --- /dev/null +++ b/coverage.php @@ -0,0 +1,92 @@ + + +
+ +Xdebug has to be enabled.
\n"; +} elseif ($_GET["coverage"] === "0") { + mysql_query("DROP TABLE IF EXISTS adminer_test.coverage"); + mysql_query("CREATE TABLE adminer_test.coverage ( + filename varchar(100) NOT NULL, + coverage_serialize mediumtext NOT NULL, + PRIMARY KEY (filename) + )"); + echo " \n"; +} elseif (preg_match('~^(adminer|editor)/(include/)?[-_.a-z0-9]+$~i', $_GET["coverage"])) { + // highlight single file + $filename = $_GET["coverage"]; + $row = mysql_fetch_row(mysql_query("SELECT coverage_serialize FROM adminer_test.coverage WHERE filename = '" . mysql_real_escape_string(realpath($filename)) . "'")); + $cov = ($row ? unserialize($row[0]) : array()); + $file = explode("$ratio% | $filename |