Ejemplo n.º 1
0
<?php

spl_autoload_register(function ($class) {
    include 'classes/' . $class . '.class.php';
});
$path = !isset($_REQUEST['path']) ? '\\\\NDLS018\\CaptureSV\\Logs' : $_REQUEST['path'];
$logfile = new logfile($path);
$latestFilename = $logfile->getFilesInPath();
$logfile->setCurrentFilename(end($latestFilename));
$logfile->readAndParseLog();
$subset = $logfile->getLogEntriesByPDFDate(date("Y/m/d", strtotime("yesterday")));
$handle = fopen(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR . "reports" . DIRECTORY_SEPARATOR . "Output Log " . date("Y-m-d", strtotime("yesterday")) . ".csv", "x+");
fwrite($handle, implode(',', array_keys($subset[0]->getVars())) . PHP_EOL);
foreach ($subset as $obj) {
    $line = array();
    foreach ($obj->getVars() as $key => $value) {
        $line[] = $value;
    }
    fwrite($handle, implode(',', $line) . PHP_EOL);
}
fclose($handle);
Ejemplo n.º 2
0
//Set defaults for any missing querystring parameters
$path = !isset($_REQUEST['path']) ? '\\\\NDLS018\\CaptureSV\\Logs' : $_REQUEST['path'];
$filename = !isset($_REQUEST['filename']) ? "" : $_REQUEST['filename'];
$action = !isset($_REQUEST['action']) ? 'listfiles' : $_REQUEST['action'];
//debugging parameters
/*$action = 'getlog';
  $filename = 'log_1408_ext.txt';
  $path = '\\\\NDLS018\\CaptureSV\\Logs';*/
if ($filename == "") {
    $logfile = new logfile($path);
} else {
    $logfile = new logfile($path, $filename);
}
switch ($action) {
    case "listfiles":
        $json_response = array_reverse($logfile->getFilesInPath());
        break;
    case "getpath":
        $string_response = $logfile->getPath();
        break;
    case "getlog":
        try {
            $logfile->readAndParseLog();
            $json_response = $logfile->getLogEntries();
        } catch (Exception $e) {
            $string_response = $e->getMessage();
        }
        break;
    default:
        $string_response = "Unknown Action Specified";
}