<?php
function authorizeSlice($sn) {
-
+
global $api;
-
+
$slice_list= array();
$result= $api->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;
//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
$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) {
//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']);
//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";
$sliceFile = fopen("slices.txt", "rw");
if (!$sliceFile) {
- echo "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
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);
//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 "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
flock($sliceFile, LOCK_EX);
$schedFile = fopen("schedule.txt", "r");
if (!$schedFile) {
- echo "<p>Unable to open remote file.</p>";
-
+ echo "<p>Unable to open remote file.</p>";
+
}
flock($schedFile, LOCK_EX);
$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 "<table cellspacing=\"2\" cellpadding=\"1\" border=\"0\" width=550>\n";
echo "<tr><td colspan=\"3\"><span class='bold'>24 hour Queue:</span> Choose the GMT time slot you desire (<font color=\"#339933\">green</font> slots are open, <font color=\"#CC3333\">red</font> are taken) <p></td></tr>\n";
echo "<tr><td width=\"47%\" align=\"right\"><table cellspacing=1 cellpadding=1 border=0 width=130>\n";
while ($i < 12) {
$retVal = validateRequest($units, $timesOccupied, $reqTime, $currentTime);
if ($retVal == SUCCESS) { // advance timestamp one hour (3600 seconds)
-
+
echo "<tr bgcolor=\"#339933\"><td><input type=\"radio\" name=\"queue_time\" value=\"" . gmdate("H:i:s", $reqTime) . "\"> " . gmdate("H:i:s", $reqTime) . " </td></tr>\n";
}
else {
function sliceDropDown() {
global $api;
-
+
$slice_list= array();
$result= $api->GetSlices( Null, array( "name", "slice_id" ) );
// sort_slices( $result ); --> slice sort on name
foreach ( $result AS $slice )
{
echo "<option value='" . $slice["name"] . "'>" . $slice["name"] . "\n";
-
+
}
-
+
}