X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fsirius%2Fsirius_func.php;h=a75fc20a5ce7c5317a5649cc1dd1328a144f4dd5;hb=697e97edba1f53dfdbce4bd96f33fd6fb4190a82;hp=3d9a161be8d5c8c03622481706ea3c17e13698ed;hpb=0cb2c76e7edefb470f85482b548c313614008da4;p=plewww.git diff --git a/planetlab/sirius/sirius_func.php b/planetlab/sirius/sirius_func.php index 3d9a161..a75fc20 100644 --- a/planetlab/sirius/sirius_func.php +++ b/planetlab/sirius/sirius_func.php @@ -1,26 +1,26 @@ GetSlices( Null, array( "name", "slice_id" ) ); - + foreach ( $result AS $slice ) { if ( $slice["name"] == $sn ) return 1; - + } - + return 0; - + } //can a request be satisfied? Currently, answer is yes unless //either this time is taken or you asked for more than one unit -//probably will need to change this. +//probably will need to change this. function validateRequest ($units, $timesOccupied, $requestedTime, $currentTime) { if ($units != 1) return TOO_MANY_UNITS; @@ -39,7 +39,7 @@ function validateRequest ($units, $timesOccupied, $requestedTime, $currentTime) //can a request be satisfied? Currently, answer is yes unless //either this time is taken or you asked for more than one unit -//probably will need to change this. +//probably will need to change this. function validateAndMarkRequest ($units, &$timesOccupied, $requestedTime, $currentTime, $sn, $jobArray) { // buffer so we aren't too close to deadline, if your request is late // OR if it's within 1 minute of deadline, it's too late @@ -71,7 +71,7 @@ function findNextFreeSlot($units, $timesOccupied) { $currMonth = gmdate("m"); $currDate = gmdate("d"); $currHour = gmdate("H") + 1; - $currentTime = gmmktime(); + $currentTime = time(); $reqTime = gmmktime($currHour, 0, 0, $currMonth, $currDate, $currYear); $retVal = 1; while ($retVal != SUCCESS) { @@ -93,7 +93,7 @@ function dumpToFile($fileName, $buffer, $which, $timesOccupied) { //lock in case of concurrent accesses flock($fileHandle, LOCK_EX); - + if ($which == "schedule") { // need to write timestamp in this case $s = gettimeofday(); fwrite($fileHandle, $s['sec']); @@ -103,8 +103,8 @@ function dumpToFile($fileName, $buffer, $which, $timesOccupied) { //do the dump here foreach ($buffer as $value) { $t = ""; - if ($which == "schedule") { - if (strcmp($value["timestamp"], mktime()) > 0) { + if ($which == "schedule") { + if (strcmp($value["timestamp"], time()) > 0) { $numReps = $value["reps"]; $ts = $value["timestamp"]; $t = $value["sliceName"]." ".$value["id"]." ".$value["timestamp"]." ".$value["units"]." ".$value["reps"]." \n"; @@ -138,13 +138,13 @@ function updateSliceFile($name, $units) { $sliceFile = fopen("slices.txt", "rw"); if (!$sliceFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($sliceFile, LOCK_EX); - //we'll construct a new list here, will be current slice file except + //we'll construct a new list here, will be current slice file except //the slice in question will have it's units decreased, if there are any... while (!feof($sliceFile)) { $num = fscanf($sliceFile, "%s %d\n", $sliceName, $unitsAvailable); @@ -175,13 +175,13 @@ function updateSliceFile($name, $units) { //pretty obvious what this does; basically, does the slice exist in -//the slice file yet? (New user of calendar service user may not have +//the slice file yet? (New user of calendar service user may not have //an entry) function isFirstSliceRequest($name) { $sliceFile = fopen("slices.txt", "r"); if (!$sliceFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($sliceFile, LOCK_EX); @@ -241,8 +241,8 @@ function getCurrentSchedule (&$jobArray, &$timesOccupied, &$maxId) { $schedFile = fopen("schedule.txt", "r"); if (!$schedFile) { - echo "

Unable to open remote file.

"; - + echo "

Unable to open remote file.

"; + } flock($schedFile, LOCK_EX); @@ -293,15 +293,15 @@ function findNextQueue($units, $timesOccupied) { $currMonth = gmdate("m"); $currDate = gmdate("d"); $currHour = gmdate("H") + 1; - $currentTime = gmmktime(); + $currentTime = time(); $reqTime = gmmktime($currHour, 0, 0, $currMonth, $currDate, $currYear); $retVal = 1; $i = 0; - + // DAVE // outputting table to display the queue // green background will mean slot is open, and red will mean the slot is used - // + // echo "\n"; echo "\n"; echo "
24 hour Queue: Choose the GMT time slot you desire (green slots are open, red are taken)

\n"; @@ -314,7 +314,7 @@ function findNextQueue($units, $timesOccupied) { while ($i < 12) { $retVal = validateRequest($units, $timesOccupied, $reqTime, $currentTime); if ($retVal == SUCCESS) { // advance timestamp one hour (3600 seconds) - + echo "\n"; } else { @@ -350,7 +350,7 @@ function findNextQueue($units, $timesOccupied) { function sliceDropDown() { global $api; - + $slice_list= array(); $result= $api->GetSlices( Null, array( "name", "slice_id" ) ); // sort_slices( $result ); --> slice sort on name @@ -362,9 +362,9 @@ function sliceDropDown() { foreach ( $result AS $slice ) { echo "
" . gmdate("H:i:s", $reqTime) . "