private function __construct() { // Get list of files matching the defined format $files = $this->getFiles(Pfc_Config::profileOutputFormat(), Pfc_Config::profileDir() . '/'); // Sort by mtime uasort($files, array($this, 'mtimeCmp')); $this->files = $files; }
function pfc_ajax_get_history_profiles($dataFile) { $result = array(); $matchs = array(); preg_match(Pfc_Config::profileOutputFormat(), $dataFile, $matchs); $urlname = $matchs[3]; $timestamp = $matchs[2]; $realPath = Pfc_Config::profileDir() . '/' . $urlname; if (file_exists($realPath)) { $files = preg_grep(Pfc_Config::profileOutputFormat(), scandir($realPath)); foreach ($files as $file) { $result[] = array('filename' => $file, 'mtime' => date("Y-m-d H:i:s", substr($file, 8, 10))); } } return json_encode($result); }
<?php require './config.php'; require './library/FileHandler.php'; $filename = $_GET['file']; if ($filename == '0') { $files = Pfc_FileHandler::getInstance()->getTraceList(); $filename = $files[0]['filename']; } $format = Pfc_Config::profileOutputFormat(); $matchs = array(); preg_match($format, $filename, $matchs); $urlname = $matchs[3]; $tsvFileName = $urlname . '.tsv'; $dataDir = Pfc_Config::tsvdir(); $realFile = $dataDir . $tsvFileName; $data = file_get_contents($realFile); echo $data;