Rev 84 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/hosting.php");
// The file has JSON type.
header('Content-Type: application/json');
// Prepare the file name from the query string.
if (!preg_match("#^[a-zA-Z0-9_]+$#", $_GET['file'])) {
die;
}
$file = TMP_DIR . "pb_" . $_GET['file'] . ".txt";
// Make sure the file is exist.
if (file_exists($file)) {
// Get the content and echo it.
$text = file_get_contents($file);
echo $text;
// Convert to JSON to read the status.
$obj = json_decode($text);
// If the process is finished, delete the file.
if ($obj->percent >= 100) {
@unlink($file);
}
}
else {
echo json_encode(array(
"percent" => null,
"message" => "File Not Found"
));
}