From 7dcf93cc2d67c49ae4eecad76e98e908c1d455b1 Mon Sep 17 00:00:00 2001 From: mattpass Date: Fri, 8 May 2020 09:46:32 +0100 Subject: [PATCH] indexer.php tidy --- lib/indexer.php | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/indexer.php b/lib/indexer.php index 1d83bbb..b565a22 100644 --- a/lib/indexer.php +++ b/lib/indexer.php @@ -1,6 +1,6 @@ ", "", $prevIndexData); $prevIndexData = unserialize($prevIndexData); @@ -32,24 +32,24 @@ function phpGrep($path, $base) { $fp = opendir($path); global $ICEcoder, $serverType, $docRoot, $ICEcoderDir; - if (!isset($ret)) {$ret="";}; - $slash = $serverType == strpos($path,"\\")>-1 ? "\\" : "/"; + if (!isset($ret)) {$ret = "";}; + $slash = $serverType == -1 < strpos($path, "\\") ? "\\" : "/"; while($f = readdir($fp)) { // Ignore . and .. paths - if ($f == "." || $f == "..") continue; - $filePath = $path.$slash.$f; + if ("." === $f || ".." === $f) continue; + $filePath = $path . $slash . $f; $filePathExt = pathinfo($filePath, PATHINFO_EXTENSION); // Exclude the folder ICEcoder is running from - $rootPrefix = '/'.str_replace("/","\/",preg_quote(str_replace("\\","/",$docRoot))).'/'; + $rootPrefix = '/' . str_replace("/", "\/", preg_quote(str_replace("\\", "/", $docRoot))) . '/'; $localPath = preg_replace($rootPrefix, '', $filePath, 1); - if (strpos($localPath, $ICEcoderDir)===0) { + if (0 === strpos($localPath, $ICEcoderDir)) { continue; } - if(is_dir($filePath)) { + if (is_dir($filePath)) { $ret .= phpGrep($filePath, $base); } else { // Check if we should scan within this file, by only considering files that may contain functions & classes - if (in_array($filePathExt, $indexableFileExts) === false) { + if (false === in_array($filePathExt, $indexableFileExts)) { continue; } // Check if file appears to be the same (same size and mtime), if so, continue as we'll assume it's not changed @@ -69,14 +69,14 @@ function phpGrep($path, $base) { } $bFile = false; // Exclude banned files - for ($i=0;$i", "", $gitDiffData); @@ -218,9 +218,9 @@ if (!isset($_GET['timestamp']) || !isset($prevIndexData["timestamps"]) || $_GET[ } // If we have a data/git-content.php file - if (file_exists($docRoot.$ICEcoderDir."/data/git-content.php")) { + if (file_exists($docRoot . $ICEcoderDir . "/data/git-content.php")) { // Get serialized array back out of PHP file inside a comment block as git data for git content usage - $gitContent = file_get_contents($docRoot.$ICEcoderDir."/data/git-content.php"); + $gitContent = file_get_contents($docRoot . $ICEcoderDir . "/data/git-content.php"); if (strpos($gitContent, "", "", $gitContent); @@ -230,7 +230,7 @@ if (!isset($_GET['timestamp']) || !isset($prevIndexData["timestamps"]) || $_GET[ } // Store the serialized array in PHP comment block for next time - file_put_contents($docRoot.$ICEcoderDir."/data/index.php", ""); + file_put_contents($docRoot . $ICEcoderDir . "/data/index.php", ""); // Output what we have in our index... } else { $output = $prevIndexData; @@ -243,7 +243,7 @@ if (!isset($_GET['timestamp']) || !isset($prevIndexData["timestamps"]) || $_GET[ "browser" => (int) $_GET['timestamp'], "changed" => false ] - ]; + ]; } // Output the JSON