Example #1
0
        // Dis'll hold all the log file's names.
        foreach ($contents as $i) {
            // So yeah, f**k anything that isn't XML.
            if (strtolower(end(explode(".", $i))) == "xml") {
                array_push($logs, $i);
            }
        }
        // Uhhh da bueaty json.
        return json_encode($logs);
    }
    // Dis the shitty function.
    public function getLog($log)
    {
        $xml = simplexml_load_string(file_get_contents($this->dir . "/" . $log));
        return json_encode($xml);
    }
}
header('Content-Type: application/json');
$post = json_decode(file_get_contents("php://input"));
// Do the actual thing, finally.
$w = new Worker();
switch ($post->request) {
    case "logList":
        echo $w->logList();
        break;
    case "getLog":
        echo $w->getLog($post->logFile);
        break;
    default:
        echo 'Sorry pal';
}