private function __construct() { // Get list of files matching the defined format $files = $this->getFiles(Webgrind_Config::xdebugOutputFormat(), Webgrind_Config::xdebugOutputDir()); // Get list of preprocessed files $prepFiles = $this->getPrepFiles('/\\' . Webgrind_Config::$preprocessedSuffix . '$/', Webgrind_Config::storageDir()); // Loop over the preprocessed files. foreach ($prepFiles as $fileName => $prepFile) { $fileName = str_replace(Webgrind_Config::$preprocessedSuffix, '', $fileName); // If it is older than its corrosponding original: delete it. // If it's original does not exist: delete it if (!isset($files[$fileName]) || $files[$fileName]['mtime'] > $prepFile['mtime']) { unlink($prepFile['absoluteFilename']); } else { $files[$fileName]['preprocessed'] = true; } } // Sort by mtime uasort($files, array($this, 'mtimeCmp')); $this->files = $files; }
break; case 'version_info': $response = @file_get_contents('http://jokke.dk/webgrindupdate.json?version='.Webgrind_Config::$webgrindVersion); echo $response; break; default: $welcome = ''; if (!file_exists(Webgrind_Config::storageDir()) || !is_writable(Webgrind_Config::storageDir())) { $welcome .= 'Webgrind $storageDir does not exist or is not writeable: <code>'.Webgrind_Config::storageDir().'</code><br>'; } if (!file_exists(Webgrind_Config::xdebugOutputDir()) || !is_readable(Webgrind_Config::xdebugOutputDir())) { $welcome .= 'Webgrind $profilerDir does not exist or is not readable: <code>'.Webgrind_Config::xdebugOutputDir().'</code><br>'; } if ($welcome == '') { $welcome = 'Select a cachegrind file above<br>(looking in <code>'.Webgrind_Config::xdebugOutputDir().'</code> for files matching <code>'.Webgrind_Config::xdebugOutputFormat().'</code>)'; } require 'templates/index.phtml'; } } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage().'<br>'.$e->getFile().', line '.$e->getLine())); return; } function get($param, $default=false){ return (isset($_GET[$param])? $_GET[$param] : $default); } function costCmp($a, $b){ $a = $a['summedSelfCost']; $b = $b['summedSelfCost'];