This repository has been archived by the owner on Jan 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file is used in the ajax call that runs every second while a job is running to retrieve the last line of progress.info which is then broken into an array and used to display status information
- Loading branch information
Matthew Stone
committed
Sep 19, 2013
1 parent
e60a8d0
commit 6afe1fb
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
$line = ''; | ||
|
||
$f = fopen('/etc/osid/system/progress.info', 'r'); | ||
$cursor = -1; | ||
|
||
fseek($f, $cursor, SEEK_END); | ||
$char = fgetc($f); | ||
|
||
/** | ||
* Trim trailing newline chars of the file | ||
*/ | ||
while ($char === "\n" || $char === "\r") { | ||
fseek($f, $cursor--, SEEK_END); | ||
$char = fgetc($f); | ||
} | ||
|
||
/** | ||
* Read until the start of file or first newline char | ||
*/ | ||
while ($char !== false && $char !== "\n" && $char !== "\r") { | ||
/** | ||
* Prepend the new char | ||
*/ | ||
$line = $char . $line; | ||
fseek($f, $cursor--, SEEK_END); | ||
$char = fgetc($f); | ||
} | ||
|
||
//explode returned line into array | ||
$LineArray = explode(" ", $line); | ||
|
||
//create percentage integer | ||
$PercentCompleted = str_replace("[", "", $LineArray[0]); | ||
$PercentCompleted = str_replace("%", "", $PercentCompleted); | ||
|
||
//create total file size | ||
$TotalFileSize = str_replace("Mb]", "", $LineArray[2]); | ||
|
||
//create file size written | ||
$FileSizeWritten = str_replace("(", "", $LineArray[5]); | ||
$FileSizeWritten = str_replace("Mb)", "", $FileSizeWritten); | ||
|
||
//create time remaining | ||
$TimeRemaining = $LineArray[7]; | ||
|
||
//output delimited string | ||
echo $PercentCompleted . "|" . $TotalFileSize . "|" . $FileSizeWritten . "|" . $TimeRemaining; | ||
?> |