Пример #1
0
/**
 * Returns a <select> tag populated with all the states in the country.
 *
 * The select_state_tag builds off the traditional select_tag function, and is conveniently populated with 
 * all the states in the default country (sorted alphabetically). Each option in the list has a state code (two-character 
 * for US and Canada) for its value and the state's name as its display title.
 * The options[] array may also contain the following non-html options:
 *   A states[] array containing a list of states to be added in the form array
 * Here's an example of an <option> tag generated by the select_state_tag:
 *
 * <samp>
 *  <option value="NY">New York</option>
 * </samp>
 *
 * <b>Examples:</b>
 * <code>
 *  echo select_state_tag('state', 'NY');
 * </code>
 *
 * @param  string field name 
 * @param  string selected field value (two-character state code)
 * @param  string country (two-character country code)
 * @param  array  additional HTML compliant <select> tag parameters. 
 *                May also include a 'states[]' array containing a list of states to be removed from the list
 *                May also include a 'country' value that will select the states from a country code
 * @return string <select> tag populated with all the states in the default or selected country.
 * @see select_tag, options_for_select
 */
function select_state_tag($name, $value, $options = array())
{
    if (isset($options['country'])) {
        $country = $options['country'];
        unset($options['country']);
    }
    $states = getStates($country);
    if (isset($options['states']) && is_array($options['states'])) {
        foreach ($options['states'] as $key) {
            if (isset($states[$key])) {
                unset($states[$key]);
            }
        }
        unset($options['states']);
    }
    if (isset($options['sort'])) {
        asort($states);
        unset($options['sort']);
    }
    $option_tags = options_for_select($states, $value);
    return select_tag($name, $option_tags, $options);
}
Пример #2
0
function viewRequestInfo()
{
    $requestid = getContinuationVar('requestid');
    $request = getRequestInfo($requestid);
    if ($request['forimaging'] || $request['stateid'] == 18 || $request['laststateid'] == 18) {
        $reservation = $request['reservations'][0];
    } else {
        foreach ($request["reservations"] as $res) {
            if ($res["forcheckout"]) {
                $reservation = $res;
                break;
            }
        }
    }
    $states = getStates();
    $userinfo = getUserInfo($request["userid"], 1, 1);
    print "<DIV align=center>\n";
    print "<H2>View Reservation</H2>\n";
    print "<table summary=\"\">\n";
    print "  <TR>\n";
    print "    <TH align=right>User:</TH>\n";
    print "    <TD>" . $userinfo["unityid"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Start&nbsp;Time:</TH>\n";
    if (datetimeToUnix($request["start"]) < datetimeToUnix($request["daterequested"])) {
        print "    <TD>" . prettyDatetime($request["daterequested"]) . "</TD>\n";
    } else {
        print "    <TD>" . prettyDatetime($request["start"]) . "</TD>\n";
    }
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>End&nbsp;Time:</TH>\n";
    print "    <TD>" . prettyDatetime($request["end"]) . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Request&nbsp;Time:</TH>\n";
    print "    <TD>" . prettyDatetime($request["daterequested"]) . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Last&nbsp;Modified:</TH>\n";
    if (!empty($request["datemodified"])) {
        print "    <TD>" . prettyDatetime($request["datemodified"]) . "</TD>\n";
    } else {
        print "    <TD>Never Modified</TD>\n";
    }
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Current&nbsp;State:</TH>\n";
    print "    <TD>" . $states[$request["stateid"]] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Last&nbsp;State:</TH>\n";
    print "    <TD>";
    if ($request["laststateid"]) {
        print $states[$request["laststateid"]];
    } else {
        print "None";
    }
    print "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Image:</TH>\n";
    print "    <TD>{$reservation['prettyimage']}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Hostname:</TH>\n";
    print "    <TD>{$request['reservations'][0]["hostname"]}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>IP&nbsp;Address:</TH>\n";
    print "    <TD>{$request['reservations'][0]["reservedIP"]}</TD>\n";
    print "  </TR>\n";
    print "</table>\n";
    if (count($request['reservations'] > 1)) {
        array_shift($request['reservations']);
        print "Subimages:<br>\n";
        print "<table summary=\"\">\n";
        foreach ($request["reservations"] as $res) {
            print "  <TR>\n";
            print "    <TH align=right>Image:</TH>\n";
            print "    <TD>{$res["prettyimage"]}</TD>\n";
            print "  </TR>\n";
            print "  <TR>\n";
            print "    <TH align=right>Hostname:</TH>\n";
            print "    <TD>{$res["hostname"]}</TD>\n";
            print "  </TR>\n";
            print "  <TR>\n";
            print "    <TH align=right>IP&nbsp;Address:</TH>\n";
            print "    <TD>{$res["reservedIP"]}</TD>\n";
            print "  </TR>\n";
        }
        print "</table>\n";
    }
    print "<table summary=\"\">\n";
    print "  <TR>\n";
    /*print "    <TD>\n";
    	print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    	print "      <INPUT type=hidden name=mode value=adminEditRequest>\n";
    	print "      <INPUT type=hidden name=requestid value=$requestid>\n";
    	print "      <INPUT type=submit value=Modify>\n";
    	print "      </FORM>\n";
    	print "    </TD>\n";*/
    print "    <TD>\n";
    $cdata = array('requestid' => $requestid, 'notbyowner' => 1, 'ttdata' => getContinuationVar('ttdata'), 'fromtimetable' => 1);
    $cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata, SECINDAY);
    print "      <button dojoType=\"dijit.form.Button\">\n";
    print "        " . i("Delete Reservation") . "\n";
    print "\t      <script type=\"dojo/method\" event=\"onClick\">\n";
    print "          endReservation('{$cont}');\n";
    print "        </script>\n";
    print "      </button>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</table>\n";
    print "</DIV>\n";
    print "<div dojoType=dijit.Dialog\n";
    print "      id=\"endResDlg\"\n";
    print "      title=\"" . i("Delete Reservation") . "\"\n";
    print "      duration=250\n";
    print "      draggable=true>\n";
    print "   <div id=\"endResDlgContent\"></div>\n";
    print "   <input type=\"hidden\" id=\"endrescont\">\n";
    print "   <input type=\"hidden\" id=\"endresid\">\n";
    print "   <div align=\"center\">\n";
    print "   <button id=\"endResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
    print "    " . i("Delete Reservation") . "\n";
    print "\t   <script type=\"dojo/method\" event=\"onClick\">\n";
    print "       submitDeleteReservation();\n";
    print "     </script>\n";
    print "   </button>\n";
    print "   <button dojoType=\"dijit.form.Button\">\n";
    print "     " . i("Cancel") . "\n";
    print "\t   <script type=\"dojo/method\" event=\"onClick\">\n";
    print "       dijit.byId('endResDlg').hide();\n";
    print "       dojo.byId('endResDlgContent').innerHTML = '';\n";
    print "     </script>\n";
    print "   </button>\n";
    print "   </div>\n";
    print "</div>\n";
}
		<div class="form_tdinput">
			<input class="form_input" type="text" name="postcode" id="postcode" value="<?php 
echo $post_postcode;
?>
">
		</div>
	</div>
	<div style="clear: right;"></div><div style="clear: left;"></div>
	<div class="form_row" style="margin-top:20px;">
		<div class="form_tdlabel">
			<label>State :</label>
		</div>
		<div class="form_tdinput">
			<select class="form_input" style="width: 140px;" name="state" id="state">
			<?php 
$t = getStates();
foreach ($t as $k => $v) {
    echo "<option value={$k} " . ($post_state == '' && $v == 'New South Wales' || "'" . $post_state . "'" == $k ? "selected" : "") . ">" . $v . "</option>";
}
?>
			</select>
		</div>
	</div>
	<div style="clear: right;"></div><div style="clear: left;"></div>
	<div class="form_row" style="margin-top:20px;">
		<div class="form_tdlabel">
			<label>Country :</label>
		</div>
		<div class="form_tdinput">
			<select class="form_input" style="width: 140px;" name="country" id="country">
			<?php 
Пример #4
0
<?php

include "includes/header.php";
$specs = getSpecs($dbhandle);
$states = getStates($dbhandle);
include "includes/handle_profile.php";
?>
	
      <div class="starter-template left">
        <h3>Profile</h3>
        <p class="lead">Set up your profile to receive notifications</p>
		<form action="" method="post">
		<?php 
if ($msg != '') {
    ?>
		<p class="alert alert-danger"><?php 
    echo $msg;
    ?>
</p>
		<?php 
}
?>
		
		<?php 
if ($msg2 != '') {
    ?>
		<p class="alert alert-success"><?php 
    echo $msg2;
    ?>
</p>
		<?php 
Пример #5
0
 function AJsubmitCompStateChange()
 {
     global $user;
     $newstateid = getContinuationVar('newstateid');
     $compids = getContinuationVar('compids');
     $states = getStates();
     $ret = array('status' => 'success', 'title' => "Change State", 'clearselection' => 0, 'newstate' => $states[$newstateid], 'refreshcount' => 1);
     # get ids from getUserResources because that data should already be in cache
     $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
     $tmp = array_keys($resources['image']);
     $semimageid = $tmp[0];
     $semrevid = getProductionRevisionid($semimageid);
     if (!empty($resources['managementnode'])) {
         $tmp = array_keys($resources['managementnode']);
         $semmnid = $tmp[0];
     } else {
         $allmns = array_keys(getManagementNodes('future'));
         if (empty($allmns)) {
             $ret = array('status' => 'error', 'errormsg' => 'No management nodes are available for controlling the submitted computers.');
             sendJSON($ret);
             return;
         }
         $semmnid = $allmns[0];
     }
     if ($newstateid == 2) {
         $fails = array('provnone' => array(), 'reserved' => array(), 'hostfail' => array(), 'hasvms' => array());
         $availablenow = array();
         $checkvms = array();
         $checkhosts = array();
         $noaction = array();
         $computers = $this->getData($this->defaultGetDataArgs);
         $inusecompids = array();
         $allids = implode(',', $compids);
         $query = "SELECT rs.computerid " . "FROM reservation rs, " . "request rq " . "WHERE rs.requestid = rq.id AND " . "rq.end > NOW() AND " . "rq.start < NOW() AND " . "rq.stateid NOT IN (1, 5, 11, 12) AND " . "rs.computerid IN ({$allids})";
         $qh = doQuery($query);
         while ($row = mysql_fetch_assoc($qh)) {
             $inusecompids[$row['computerid']] = 1;
         }
         # check initial conditions
         foreach ($compids as $compid) {
             # already in available
             if ($computers[$compid]['state'] == 'available') {
                 $noaction[] = $compid;
                 continue;
             }
             # no provisioning engine
             if ($computers[$compid]['provisioning'] == 'None') {
                 $fails['provnone'][] = $compid;
                 continue;
             }
             # non-VM in maintenance without a vmhost entry or in hpc
             if ($computers[$compid]['state'] == 'hpc' || $computers[$compid]['state'] == 'maintenance' && is_null($computers[$compid]['vmprofileid']) && $computers[$compid]['type'] != 'virtualmachine') {
                 $availablenow[] = $compid;
                 continue;
             }
             # has active reservation
             if (array_key_exists($compid, $inusecompids)) {
                 $fails['reserved'][] = $compid;
                 continue;
             }
             # in reload, reloading, reserved, inuse, or failed with no active reservation
             if (preg_match('/^(reload|reloading|reserved|inuse|failed|timeout)$/', $computers[$compid]['state'])) {
                 $availablenow[] = $compid;
                 continue;
             }
             # vmhostinuse - check for assigned VMs
             if ($computers[$compid]['state'] == 'vmhostinuse') {
                 $checkvms[] = $compid;
                 continue;
             }
             # VM in maintenance
             if ($computers[$compid]['state'] == 'maintenance' && $computers[$compid]['type'] == 'virtualmachine') {
                 $checkhosts[] = $compid;
                 continue;
             }
             # maintenance - check for previously being a vmhost
             if ($computers[$compid]['state'] == 'maintenance' && !is_null($computers[$compid]['vmprofileid'])) {
                 $checkvms[] = $compid;
                 continue;
             }
         }
         if (count($checkvms)) {
             $ids = implode(',', $checkvms);
             $query = "SELECT h.id, " . "COUNT(vm.id) AS count " . "FROM computer h " . "LEFT JOIN vmhost vh ON (h.id = vh.computerid) " . "LEFT JOIN computer vm ON (vh.id = vm.vmhostid) " . "WHERE h.id IN ({$ids}) " . "GROUP BY vh.computerid";
             $qh = doQuery($query);
             while ($row = mysql_fetch_assoc($qh)) {
                 if ($row['count']) {
                     $fails['hasvms'][] = $row['id'];
                 } else {
                     $availablenow[] = $row['id'];
                 }
             }
         }
         if (count($checkhosts)) {
             $ids = implode(',', $checkhosts);
             $query = "SELECT h.stateid, " . "vm.id " . "FROM computer vm " . "LEFT JOIN vmhost vh ON (vm.vmhostid = vh.id) " . "LEFT JOIN computer h ON (vh.computerid = h.id) " . "WHERE vm.id IN ({$ids})";
             $qh = doQuery($query);
             while ($row = mysql_fetch_assoc($qh)) {
                 if ($row['stateid'] != 20) {
                     $fails['hostfail'][] = $row['id'];
                 } else {
                     $availablenow[] = $row['id'];
                 }
             }
         }
         if (count($availablenow)) {
             $allids = implode(',', $availablenow);
             $query = "UPDATE computer " . "SET stateid = 2, " . "notes = '' " . "WHERE id IN ({$allids})";
             doQuery($query);
         }
         $msg = '';
         if (count($noaction)) {
             $msg .= "The following computers were already in the available ";
             $msg .= "state:<br><br>\n";
             foreach ($noaction as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($availablenow)) {
             $msg .= "The following computers were changed to the available ";
             $msg .= "state:<br><br>\n";
             foreach ($availablenow as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($fails['provnone'])) {
             $msg .= "<span class=\"rederrormsg\">\n";
             $msg .= "The following computers cannot be in the available state ";
             $msg .= "because they have no provisioning engine:</span><br><br>\n";
             foreach ($fails['provnone'] as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($fails['reserved'])) {
             $msg .= "<span class=\"rederrormsg\">\n";
             $msg .= "The following computers are currently in use and could not have ";
             $msg .= "their states changed at this time:</span><br><br>\n";
             foreach ($fails['reserved'] as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($fails['hasvms'])) {
             $msg .= "<span class=\"rederrormsg\">\n";
             $msg .= "The following computers currently have VMs assigned to them ";
             $msg .= "and cannot be moved to available until the VMs are removed:";
             $msg .= "</span><br><br>\n";
             foreach ($fails['hasvms'] as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($fails['hostfail'])) {
             $msg .= "<span class=\"rederrormsg\">\n";
             $msg .= "The following VMs are not currently assigned to a host in ";
             $msg .= "the vmhostinuse state:</span><br><br>\n";
             foreach ($fails['hostfail'] as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
     } elseif ($newstateid == 10 || $newstateid == 23) {
         if ($newstateid == 10) {
             $notes = processInputVar('notes', ARG_STRING);
             if (get_magic_quotes_gpc()) {
                 $notes = stripslashes($notes);
             }
             $notes = mysql_real_escape_string($notes);
             $notes = $user["unityid"] . " " . unixToDatetime(time()) . "@" . $notes;
         }
         $vclreloadid = getUserlistID('vclreload@Local');
         $computers = $this->getData($this->defaultGetDataArgs);
         $noaction = array();
         $changenow = array();
         $changeasap = array();
         $changetimes = array();
         $vmwithhost = array();
         $fails = array();
         $semstart = unixToDatetime(time());
         $semend = '2038-01-01 00:00:00';
         foreach ($compids as $compid) {
             if ($newstateid == 10 && $computers[$compid]['type'] == 'virtualmachine' && in_array($computers[$compid]['vmhostcomputerid'], $compids)) {
                 $vmwithhost[] = $compid;
             }
             if ($newstateid == 10 && $computers[$compid]['state'] == 'maintenance' || $newstateid == 23 && $computers[$compid]['state'] == 'hpc') {
                 $noaction[] = $compid;
                 continue;
             }
             # try to move future reservations off of computer
             moveReservationsOffComputer($compid);
             cleanSemaphore();
             $reloadstart = getCompFinalReservationTime($compid);
             if ($computers[$compid]['state'] == 'vmhostinuse') {
                 $sem = array('imageid' => $semimageid, 'revid' => $semrevid, 'mnid' => $semmnid, 'start' => $semstart, 'end' => $semend);
                 moveReservationsOffVMs($compid, $sem);
                 cleanSemaphore();
                 $reloadstart = getCompFinalVMReservationTime($compid, 1, 1);
                 if ($reloadstart == -1) {
                     cleanSemaphore();
                     $fails[] = $compid;
                     continue;
                 } elseif ($reloadstart > 0) {
                     if (unixToDatetime($reloadstart) == '2038-01-01 00:00:00') {
                         # host has a VM reserved indefintely
                         $fails[] = $compid;
                         continue;
                     }
                     # schedule tomaintenance/tohpc reservations for VMs and host
                     $noimageid = getImageId('noimage');
                     $revid = getProductionRevisionid($noimageid);
                     $startdt = unixToDatetime($reloadstart);
                     $end = $reloadstart + SECINMONTH;
                     $enddt = unixToDatetime($end);
                     $query = "SELECT vm.id " . "FROM computer vm, " . "vmhost v " . "WHERE v.computerid = {$compid} AND " . "vm.vmhostid = v.id";
                     $qh = doQuery($query);
                     $setnoteids = array();
                     while ($row = mysql_fetch_assoc($qh)) {
                         $checkstart = getExistingChangeStateStartTime($row['id'], 18);
                         if ($checkstart) {
                             if ($checkstart > $reloadstart) {
                                 # update start time of existing tomaintenance reservation
                                 updateExistingToState($row['id'], $startdt, 18);
                             }
                             # leave existing tomaintenance reservation as is
                         } elseif (!simpleAddRequest($row['id'], $noimageid, $revid, $startdt, $enddt, 18, $vclreloadid)) {
                             cleanSemaphore();
                             $fails[] = $compid;
                             continue 2;
                             # jump out of while, continue with foreach loop
                         }
                         $setnoteids[] = $row['id'];
                     }
                     if ($newstateid == 10 && count($setnoteids)) {
                         $inids = implode(',', $setnoteids);
                         $query = "UPDATE computer " . "SET notes = 'maintenance with host {$compid}' " . "WHERE id IN ({$inids})";
                         doQuery($query);
                     }
                     $start = $reloadstart + 300;
                     # allow 5 minutes for VMs to get removed
                     $startdt = unixToDatetime($start);
                     # lock this computer
                     if (!retryGetSemaphore($semimageid, $semrevid, $semmnid, $compid, $startdt, $enddt)) {
                         cleanSemaphore();
                         $fails[] = $compid;
                         continue;
                     }
                     if ($newstateid == 10) {
                         $tostateid = 18;
                     } else {
                         $tostateid = 22;
                     }
                     $checkstart = getExistingChangeStateStartTime($compid, $tostateid);
                     if ($checkstart) {
                         if ($checkstart > $start) {
                             # update start time of existing tomaintenance/tohpc reservation
                             updateExistingToState($compid, $startdt, $tostateid);
                         }
                         # leave existing tomaintenance/tohpc reservation as is
                     } elseif (!simpleAddRequest($compid, $noimageid, $revid, $startdt, $enddt, $tostateid, $vclreloadid)) {
                         cleanSemaphore();
                         $fails[] = $compid;
                         continue;
                     }
                     cleanSemaphore();
                     $changetimes[$compid] = $start;
                     $changeasap[] = $compid;
                     continue;
                 } else {
                     if ($newstateid == 10) {
                         $note = "maintenance with host {$compid}";
                     } else {
                         $note = "maintenance so {$compid} can go to hpc";
                     }
                     # no VMs or no reservations on assigned VMs
                     $query = "UPDATE computer c " . "INNER JOIN vmhost v ON (c.vmhostid = v.id) " . "SET c.stateid = 10, " . "c.notes = '{$note}' " . "WHERE v.computerid = {$compid}";
                     doQuery($query);
                 }
             } elseif ($reloadstart) {
                 if (unixToDatetime($reloadstart) == '2038-01-01 00:00:00') {
                     # node is reserved indefintely
                     $fails[] = $compid;
                     continue;
                 }
                 # computer has reservations, schedule tomaintenance
                 $noimageid = getImageId('noimage');
                 $revid = getProductionRevisionid($noimageid);
                 $startdt = unixToDatetime($reloadstart);
                 $end = $reloadstart + SECINMONTH;
                 $enddt = unixToDatetime($end);
                 # lock this computer
                 if (!retryGetSemaphore($semimageid, $semrevid, $semmnid, $compid, $startdt, $enddt)) {
                     $fails[] = $compid;
                     cleanSemaphore();
                     continue;
                 }
                 if ($newstateid == 10) {
                     $tostateid = 18;
                 } else {
                     $tostateid = 22;
                 }
                 $checkstart = getExistingChangeStateStartTime($compid, $tostateid);
                 if ($checkstart) {
                     if ($checkstart > $reloadstart) {
                         # update start time of existing tomaintenance/tohpc reservation
                         updateExistingToState($compid, $startdt, $tostateid);
                     } else {
                         # leave existing tomaintenance/tohpc reservation as is
                         $reloadstart = $checkstart;
                     }
                 } elseif (!simpleAddRequest($compid, $noimageid, $revid, $startdt, $enddt, $tostateid, $vclreloadid)) {
                     $fails[] = $compid;
                     cleanSemaphore();
                     continue;
                 }
                 cleanSemaphore();
                 $changetimes[$compid] = $reloadstart;
                 $changeasap[] = $compid;
                 continue;
             }
             # change to maintenance/tohpc state and save in $changenow
             // if we wait and put them all in maintenance/hpc at the same time,
             # we may end up moving reservations to the computer later in the
             # loop
             # lock this computer
             if (!retryGetSemaphore($semimageid, $semrevid, $semmnid, $compid, $semstart, $semend)) {
                 $fails[] = $compid;
                 cleanSemaphore();
                 continue;
             }
             $query = "UPDATE computer " . "SET stateid = {$newstateid} " . "WHERE id = {$compid}";
             doQuery($query, 101);
             $changenow[] = $compid;
             cleanSemaphore();
         }
         if ($newstateid == 10 && (count($noaction) || count($changeasap))) {
             $comparr = array_merge($noaction, $changeasap);
             $allids = implode(',', $comparr);
             if (count($vmwithhost)) {
                 $skipids = implode(',', $vmwithhost);
             } else {
                 $skipids = "''";
             }
             $query = "UPDATE computer " . "SET notes = '{$notes}' " . "WHERE id IN ({$allids}) AND " . "id NOT IN ({$skipids})";
             doQuery($query, 101);
             $updatevms = array_intersect($vmwithhost, $comparr);
             if (count($updatevms)) {
                 $inids = implode(',', $updatevms);
                 $query = "UPDATE computer vm " . "INNER JOIN vmhost v ON (vm.vmhostid = v.id) " . "SET vm.notes = CONCAT('maintenance with host ', v.computerid) " . "WHERE vm.id IN ({$inids})";
                 doQuery($query);
             }
         }
         if ($newstateid == 10) {
             $newstate = 'maintenance';
         } else {
             $newstate = 'hpc';
         }
         $msg = '';
         if (count($changenow)) {
             $msg .= "The following computers were immediately placed into the ";
             $msg .= "{$newstate} state:<br><br>\n";
             $msg .= "<span class=\"ready\">\n";
             foreach ($changenow as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "</span><br>\n";
         }
         if (count($changeasap)) {
             $msg .= "The following computers are currently reserved ";
             $msg .= "and will be placed in the {$newstate} state at the time listed ";
             $msg .= "for each computer:\n";
             $msg .= "<table>\n";
             $msg .= "  <tr>\n";
             $msg .= "    <th>Computer</th>\n";
             $msg .= "    <th>Time</th>\n";
             $msg .= "  </tr>\n";
             foreach ($changeasap as $compid) {
                 $msg .= "  <tr>\n";
                 $msg .= "    <td align=center><span class=\"wait\">{$computers[$compid]['hostname']}</span></td>\n";
                 $time = date('n/j/y g:i a', $changetimes[$compid]);
                 $msg .= "    <td align=center>{$time}</td>\n";
                 $msg .= "  </tr>\n";
             }
             $msg .= "</table>\n";
             $msg .= "<br>\n";
         }
         if (count($fails)) {
             $msg .= "The following computers are currently reserved ";
             $msg .= "but could not be scheduled to be moved to the {$newstate} state ";
             $msg .= "at this time:<br><br>\n";
             $msg .= "<span class=\"rederrormsg\">\n";
             foreach ($fails as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "</span><br>\n";
         }
         if (count($noaction)) {
             $msg .= "The following computers were already in the {$newstate} state";
             if ($newstateid == 10) {
                 $msg .= " and had their notes on being in the maintenance state updated";
             }
             $msg .= ":<br><br>\n";
             foreach ($noaction as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
     } elseif ($newstateid == 20) {
         $profileid = processInputVar('profileid', ARG_NUMERIC);
         $profiles = getContinuationVar('profiles');
         if (!array_key_exists($profileid, $profiles)) {
             $ret = array('status' => 'error', 'errormsg' => 'Invalid profile submitted');
             sendJSON($ret);
             return;
         }
         $vclreloadid = getUserlistID('vclreload@Local');
         $imagerevisionid = getProductionRevisionid($profiles[$profileid]['imageid']);
         $computers = $this->getData($this->defaultGetDataArgs);
         $noaction = array();
         $changenow = array();
         $changenowreload = array();
         $changeasap = array();
         $changetimes = array();
         $fails = array();
         $semstart = unixToDatetime(time());
         $semend = '2038-01-01 00:00:00';
         $maintvmids = array();
         $vmnotallowed = array();
         $allvmids = array();
         $allids = implode(',', $compids);
         $query = "SELECT v.computerid AS compid, " . "vm.id AS vmid, " . "vm.notes, " . "vm.stateid AS vmstateid " . "FROM computer vm, " . "vmhost v " . "WHERE v.computerid IN ({$allids}) AND " . "vm.vmhostid = v.id";
         $qh = doQuery($query);
         while ($row = mysql_fetch_assoc($qh)) {
             if (!array_key_exists($row['compid'], $maintvmids)) {
                 $maintvmids[$row['compid']] = array();
             }
             if ($row['vmstateid'] == 10 && $row['notes'] == "maintenance with host {$row['compid']}") {
                 $maintvmids[$row['compid']][] = $row['vmid'];
             }
             $allvmids[$row['compid']][] = $row['vmid'];
         }
         foreach ($compids as $compid) {
             if ($computers[$compid]['type'] == 'virtualmachine') {
                 $vmnotallowed[] = $compid;
                 continue;
             }
             # try to move future reservations off of computer
             moveReservationsOffComputer($compid);
             cleanSemaphore();
             if ($computers[$compid]['state'] == 'maintenance') {
                 if ($computers[$compid]['provisioning'] != 'None') {
                     # schedule tovmhostinuse
                     $start = getReloadStartTime();
                     # put computer in reload state so vcld will not ignore due to being in maintenance
                     $query = "UPDATE computer " . "SET stateid = 19 " . "WHERE id = {$compid}";
                     doQuery($query);
                     $rc = $this->scheduleTovmhostinuse($compid, $profiles[$profileid]['imageid'], $start, $profileid, $computers[$compid]['vmprofileid']);
                     cleanSemaphore();
                     if (!$rc) {
                         $fails[] = $compid;
                         continue;
                     }
                     if (!is_null($computers[$compid]['vmprofileid']) && array_key_exists($compid, $maintvmids) && count($maintvmids[$compid])) {
                         $noimageid = getImageId('noimage');
                         $revid = getProductionRevisionid($noimageid);
                         $reloadstart = $start + 1800;
                         $reloadstartdt = unixToDatetime($reloadstart);
                         $end = $reloadstart + 3600;
                         $enddt = unixToDatetime($end);
                         foreach ($maintvmids[$compid] as $vmid) {
                             if (!retryGetSemaphore($semimageid, $semrevid, $semmnid, $vmid, $reloadstartdt, $enddt)) {
                                 continue;
                             }
                             simpleAddRequest($vmid, $noimageid, $revid, $reloadstartdt, $enddt, 19, $vclreloadid);
                             # continue even if failed to schedule VM to be reloaded
                         }
                         cleanSemaphore();
                     }
                     $changenowreload[] = $compid;
                 } else {
                     $query = "UPDATE computer " . "SET stateid = 20, " . "notes = '' " . "WHERE id = {$compid}";
                     doQuery($query);
                     $this->updateVmhostProfile($compid, $profileid, $computers[$compid]['vmprofileid']);
                     if (array_key_exists($compid, $maintvmids) && count($maintvmids[$compid])) {
                         $allids = implode(',', $maintvmids[$compid]);
                         $query = "UPDATE computer " . "SET stateid = 2, " . "notes = '' " . "WHERE id in ({$allids})";
                         doQuery($query);
                     }
                     $changenow[] = $compid;
                 }
             } elseif ($computers[$compid]['state'] == 'hpc') {
                 if ($computers[$compid]['provisioning'] != 'None') {
                     # schedule tovmhostinuse
                     $start = getReloadStartTime();
                     # put computer in reload state so vcld will not ignore due to being in maintenance
                     $query = "UPDATE computer " . "SET stateid = 19 " . "WHERE id = {$compid}";
                     doQuery($query);
                     $rc = $this->scheduleTovmhostinuse($compid, $profiles[$profileid]['imageid'], $start, $profileid, $computers[$compid]['vmprofileid']);
                     cleanSemaphore();
                     if (!$rc) {
                         $fails[] = $compid;
                         continue;
                     }
                     $changenowreload[] = $compid;
                 } else {
                     $query = "UPDATE computer " . "SET stateid = 20, " . "notes = '' " . "WHERE id = {$compid}";
                     doQuery($query);
                     $this->updateVmhostProfile($compid, $profileid, $computers[$compid]['vmprofileid']);
                     $changenow[] = $compid;
                 }
             } elseif ($computers[$compid]['state'] == 'vmhostinuse') {
                 if ($profiles[$computers[$compid]['vmprofileid']]['imageid'] != $profiles[$profileid]['imageid']) {
                     if ($computers[$compid]['provisioning'] != 'None') {
                         $sem = array('imageid' => $semimageid, 'revid' => $semrevid, 'mnid' => $semmnid, 'start' => $semstart, 'end' => $semend);
                         moveReservationsOffVMs($compid, $sem);
                         cleanSemaphore();
                         $reloadstart = getCompFinalVMReservationTime($compid, 1);
                         if ($reloadstart < 0) {
                             $fails[] = $compid;
                             cleanSemaphore();
                             continue;
                         }
                         if ($reloadstart == 0) {
                             $start = getReloadStartTime();
                         } else {
                             $start = $reloadstart;
                         }
                         $noimageid = getImageId('noimage');
                         $revid = getProductionRevisionid($noimageid);
                         $startdt = unixToDatetime($start);
                         $end = $start + SECINWEEK;
                         $enddt = unixToDatetime($end);
                         if ($start == $reloadstart) {
                             # check for existing reload reservations for all VMs and host
                             $times = array();
                             $reqids = array();
                             $inids = implode(',', $allvmids[$compid]);
                             $query = "SELECT UNIX_TIMESTAMP(MIN(rq.start)) AS start, " . "rs.computerid, " . "rq.id " . "FROM request rq, " . "reservation rs " . "WHERE rs.requestid = rq.id AND " . "rs.computerid IN ({$inids}) AND " . "rq.stateid = 19 AND " . "rs.imageid = {$noimageid} AND " . "rq.start > NOW() " . "GROUP BY rs.computerid " . "ORDER BY start";
                             $qh = doQuery($query);
                             if (mysql_num_rows($qh) == count($allvmids)) {
                                 while ($row = mysql_fetch_assoc($qh)) {
                                     $times[$row['start']] = 1;
                                     $reqids[] = $row['id'];
                                 }
                                 if (count($times) == 1) {
                                     # found existing reload reservations for all VMs, now check host
                                     $hoststart = $times[0] + 300;
                                     $hoststartdt = unixToDatetime($hoststart);
                                     $hostend = $hoststart + SECINYEAR;
                                     $hostenddt = unixToDatetime($hostend);
                                     $query = "SELECT rq.id, " . "rq.start " . "FROM request rq, " . "reservation rs " . "WHERE rs.requestid = rq.id AND " . "rs.computerid = {$compid} AND " . "rq.start = '{$hoststartdt}' AND " . "rq.end = '{$hostenddt}' AND " . "rs.imageid = '{$profiles[$profileid]['imageid']}' AND " . "rq.stateid = 21";
                                     $qh = doQuery($query);
                                     if ($row = mysql_fetch_assoc($qh)) {
                                         # node was previously scheduled to be reloaded for vmhostinuse
                                         if ($times[0] > $start) {
                                             # update existing reservations
                                             $allreqids = implode(',', $reqids);
                                             $query1 = "UPDATE request " . "SET start = '{$startdt}', " . "end = '{$enddt}' " . "WHERE id IN ({$allreqids})";
                                             # delay host by 5 minutes
                                             $start = $start + 300;
                                             $startdt = unixToDatetime($start);
                                             $end = $start + SECINYEAR;
                                             $enddt = unixToDatetime($end);
                                             # lock this computer
                                             if (!retryGetSemaphore($semimageid, $semrevid, $semmnid, $compid, $startdt, $enddt)) {
                                                 $fails[] = $compid;
                                                 continue;
                                             }
                                             doQuery($query1);
                                             $query2 = "UPDATE request " . "SET start = '{$startdt}', " . "end = '{$enddt}' " . "WHERE id = {$row['id']}";
                                             doQuery($query2);
                                             $changeasap[] = $compid;
                                             $changetimes[$compid] = $start;
                                         } else {
                                             # just leave the existing ones there
                                             $changeasap[] = $compid;
                                             $changetimes[$compid] = $times[0] + 300;
                                         }
                                         cleanSemaphore();
                                         continue;
                                     }
                                 }
                             }
                         }
                         if (array_key_exists($compid, $allvmids)) {
                             foreach ($allvmids[$compid] as $vmid) {
                                 $rc = simpleAddRequest($vmid, $noimageid, $revid, $startdt, $enddt, 19, $vclreloadid);
                                 if (!$rc) {
                                     $fails[] = $compid;
                                     cleanSemaphore();
                                     continue 2;
                                     # jump out of this foreach to the bigger foreach
                                 }
                             }
                         }
                         $start = $start + 300;
                         # give 5 minutes for VMs
                         $rc = $this->scheduleTovmhostinuse($compid, $profiles[$profileid]['imageid'], $start, $profileid, $computers[$compid]['vmprofileid']);
                         if (!$rc) {
                             $fails[] = $compid;
                             continue;
                         }
                         if ($reloadstart) {
                             $changeasap[] = $compid;
                             $changetimes[$compid] = $reloadstart;
                         } else {
                             $changenowreload[] = $compid;
                         }
                     } else {
                         $this->updateVmhostProfile($compid, $profileid, $computers[$compid]['vmprofileid']);
                         $changenow[] = $compid;
                     }
                 } else {
                     $noaction[] = $compid;
                 }
             } elseif (($reloadstart = moveReservationsOffComputer($compid)) == 0) {
                 $start = getCompFinalReservationTime($compid, 21);
                 $rc = $this->scheduleTovmhostinuse($compid, $profiles[$profileid]['imageid'], $start, $profileid, $computers[$compid]['vmprofileid']);
                 if (!$rc) {
                     $fails[] = $compid;
                     continue;
                 }
                 $changeasap[] = $compid;
                 if (isset($this->startchange)) {
                     $start = $this->startchange;
                 }
                 $changetimes[$compid] = $start;
             } else {
                 if ($computers[$compid]['provisioning'] != 'None') {
                     $start = getCompFinalReservationTime($compid, 21);
                     $now = 0;
                     if ($start == 0) {
                         $start = getReloadStartTime();
                         $now = 1;
                     }
                     $rc = $this->scheduleTovmhostinuse($compid, $profiles[$profileid]['imageid'], $start, $profileid, $computers[$compid]['vmprofileid']);
                     if (!$rc) {
                         $fails[] = $compid;
                         continue;
                     }
                     if ($now) {
                         $changenowreload[] = $compid;
                     } else {
                         $changeasap[] = $compid;
                         $changetimes[$compid] = $start;
                     }
                 } else {
                     $query = "UPDATE computer " . "SET stateid = 20, " . "notes = '' " . "WHERE id = {$compid}";
                     doQuery($query);
                     $this->updateVmhostProfile($compid, $profileid, $computers[$compid]['vmprofileid']);
                     $changenow[] = $compid;
                 }
             }
         }
         $msg = '';
         if (count($changenow)) {
             $msg .= "The following computers were placed into the vmhostinuse state ";
             $msg .= "or had their VM Host Profiles updated:<br><br>\n";
             foreach ($changenow as $compid) {
                 $msg .= "<span class=\"ready\">{$computers[$compid]['hostname']}</span><br>\n";
             }
             $msg .= "<br>\n";
             $ret['clearselection'] = 1;
             $ret['refreshcount'] = 5;
         }
         if (count($changenowreload)) {
             $msg .= "The following computers have been scheduled to be immediately reloaded<br>\n";
             $msg .= "and placed into the vmhostinuse state:<br><br>\n";
             foreach ($changenowreload as $compid) {
                 $msg .= "<span class=\"ready\">{$computers[$compid]['hostname']}</span><br>\n";
             }
             $msg .= "<br>\n";
             $ret['clearselection'] = 1;
             $ret['refreshcount'] = 5;
         }
         if (count($changeasap)) {
             $msg .= "The following computers are currently reserved and have been scheduled<br>\n";
             $msg .= "to be reloaded and placed into the vmhostinuse state at the time listed<br>\n";
             $msg .= "for each computers:<br><br>\n";
             $msg .= "<table>\n";
             $msg .= "  <tr>\n";
             $msg .= "    <th>Computer</th>\n";
             $msg .= "    <th>Reload time</th>\n";
             $msg .= "  </tr>\n";
             foreach ($changeasap as $compid) {
                 $msg .= "  <tr>\n";
                 $msg .= "    <td align=center><span class=\"wait\">{$computers[$compid]['hostname']}</span></td>\n";
                 $time = date('n/j/y g:i a', $changetimes[$compid]);
                 $msg .= "    <td align=center>{$time}</td>\n";
                 $msg .= "  </tr>\n";
             }
             $msg .= "</table>\n";
             $msg .= "<br>\n";
         }
         if (count($fails)) {
             $msg .= "Problems were encountered while trying to move the following computers<br>\n";
             $msg .= "to the vmhostinuse state:<br><br>\n";
             foreach ($fails as $compid) {
                 $msg .= "<span class=\"rederrormsg\">{$computers[$compid]['hostname']}</span><br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($vmnotallowed)) {
             $msg .= "The following computers are VMs which cannot be placed into the ";
             $msg .= "vmhostinuse state:<br><br>\n";
             foreach ($vmnotallowed as $compid) {
                 $msg .= "<span class=\"rederrormsg\">{$computers[$compid]['hostname']}</span><br>\n";
             }
             $msg .= "<br>\n";
         }
         if (count($noaction)) {
             $msg .= "The following computers were already in the vmhostinuse state:<br><br>\n";
             foreach ($noaction as $compid) {
                 $msg .= "{$computers[$compid]['hostname']}<br>\n";
             }
             $msg .= "<br>\n";
         }
     }
     # clear user resource cache for this type
     $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 1, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 0, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $ret['msg'] = $msg;
     sendJSON($ret);
 }
Пример #6
0
 public function change()
 {
     if (!isAdmin()) {
         $this->kickOut();
     }
     if ($_POST) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('Organization', 'Organization', 'trim|required|xss_clean');
         $this->form_validation->set_rules('SourceDescription', 'Source Description', 'trim|required|xss_clean');
         $this->form_validation->set_rules('ContactName', 'Contact Name', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Phone', 'Phone Number', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Email', 'Email Address', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Address', 'Address', 'trim|required|xss_clean');
         $this->form_validation->set_rules('City', 'City', 'trim|required|xss_clean');
         $this->form_validation->set_rules('State', 'State', 'trim|required|xss_clean');
         $this->form_validation->set_rules('ZipCode', 'Zip Code', 'trim|required|xss_clean');
         $this->form_validation->set_rules('TopicCategory', 'Topic Category', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Title', 'Title', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Abstract', 'Abstract', 'trim|required|xss_clean');
     }
     if ($this->form_validation->run() == FALSE) {
         $errors = validation_errors();
         if (!empty($errors)) {
             addError($errors);
         }
     } else {
         //Array for generating MetadatID
         $dataPoint = array('TopicCategory' => $this->input->post('TopicCategory'), 'Title' => $this->input->post('Title'), 'Abstract' => $this->input->post('Abstract'), 'ProfileVersion' => $this->cNull($this->config->item('ProfileVersion')), 'MetadataLink' => $this->input->post('MetadataLink'));
         $metaID = $this->sources->updateMD($dataPoint, $this->input->post('MetadataID'));
         $result = $this->sources->updateSource($this->input->post('Organization'), $this->input->post('SourceDescription'), $this->input->post('SourceLink'), $this->input->post('ContactName'), $this->input->post('Phone'), $this->input->post('Email'), $this->input->post('Address'), $this->input->post('City'), $this->input->post('State'), $this->input->post('ZipCode'), $this->input->post('Citation'), $this->input->post('MetadataID'), $this->input->post('SourceID'));
         if ($result) {
             addSuccess(getTxt('SourceEdited'));
         } else {
             addError(getTxt('ProcessingError'));
         }
     }
     $sources = $this->sources->getAll();
     $sourceOptions = optionsSource($sources);
     //List of CSS to pass to this view
     $data = $this->StyleData;
     $data['sourceOptions'] = $sourceOptions;
     //Getting the states dropdown
     $states = getStates();
     $states['NULL'] = getTxt('International');
     $stateOptions = genOptions($states);
     $data['stateOptions'] = $stateOptions;
     //Gets the topicCategory dropdown
     //getTC was created in the model
     $topics = $this->sources->getTC();
     $topicsArray = array();
     foreach ($topics as $topic) {
         $topicsArray[$topic['Term']] = translateTerm($topic['Term']);
     }
     $topicOptions = genOptions($topicsArray);
     $data['topicOptions'] = $topicOptions;
     $this->load->view('sources/changesource', $data);
 }
Пример #7
0
function viewRequestInfo()
{
    $requestid = getContinuationVar("requestid");
    $request = getRequestInfo($requestid);
    if ($request['forimaging']) {
        $reservation = $request['reservations'][0];
    } else {
        foreach ($request["reservations"] as $res) {
            if ($res["forcheckout"]) {
                $reservation = $res;
                break;
            }
        }
    }
    $states = getStates();
    $userinfo = getUserInfo($request["userid"]);
    print "<DIV align=center>\n";
    print "<H2>View Reservation</H2>\n";
    print "<table summary=\"\">\n";
    print "  <TR>\n";
    print "    <TH align=right>User:</TH>\n";
    print "    <TD>" . $userinfo["unityid"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Start&nbsp;Time:</TH>\n";
    if (datetimeToUnix($request["start"]) < datetimeToUnix($request["daterequested"])) {
        print "    <TD>" . prettyDatetime($request["daterequested"]) . "</TD>\n";
    } else {
        print "    <TD>" . prettyDatetime($request["start"]) . "</TD>\n";
    }
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>End&nbsp;Time:</TH>\n";
    print "    <TD>" . prettyDatetime($request["end"]) . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Request&nbsp;Time:</TH>\n";
    print "    <TD>" . prettyDatetime($request["daterequested"]) . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Last&nbsp;Modified:</TH>\n";
    if (!empty($request["datemodified"])) {
        print "    <TD>" . prettyDatetime($request["datemodified"]) . "</TD>\n";
    } else {
        print "    <TD>Never Modified</TD>\n";
    }
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Current&nbsp;State:</TH>\n";
    print "    <TD>" . $states[$request["stateid"]] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Last&nbsp;State:</TH>\n";
    print "    <TD>";
    if ($request["laststateid"]) {
        print $states[$request["laststateid"]];
    } else {
        print "None";
    }
    print "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Image:</TH>\n";
    print "    <TD>{$reservation['prettyimage']}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Hostname:</TH>\n";
    print "    <TD>{$request['reservations'][0]["hostname"]}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>IP&nbsp;Address:</TH>\n";
    print "    <TD>{$request['reservations'][0]["reservedIP"]}</TD>\n";
    print "  </TR>\n";
    print "</table>\n";
    if (count($request['reservations'] > 1)) {
        array_shift($request['reservations']);
        print "Subimages:<br>\n";
        print "<table>\n";
        foreach ($request["reservations"] as $res) {
            print "  <TR>\n";
            print "    <TH align=right>Image:</TH>\n";
            print "    <TD>{$res["prettyimage"]}</TD>\n";
            print "  </TR>\n";
            print "  <TR>\n";
            print "    <TH align=right>Hostname:</TH>\n";
            print "    <TD>{$res["hostname"]}</TD>\n";
            print "  </TR>\n";
            print "  <TR>\n";
            print "    <TH align=right>IP&nbsp;Address:</TH>\n";
            print "    <TD>{$res["reservedIP"]}</TD>\n";
            print "  </TR>\n";
        }
        print "</table>\n";
    }
    print "<table summary=\"\">\n";
    print "  <TR>\n";
    /*print "    <TD>\n";
    	print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    	print "      <INPUT type=hidden name=mode value=adminEditRequest>\n";
    	print "      <INPUT type=hidden name=requestid value=$requestid>\n";
    	print "      <INPUT type=submit value=Modify>\n";
    	print "      </FORM>\n";
    	print "    </TD>\n";*/
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cdata = array('requestid' => $requestid, 'notbyowner' => 1);
    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=\"Delete Reservation\">\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</table>\n";
    print "</DIV>\n";
}
Пример #8
0
<?php

/*
* -------------------------------------------------------------------------
*	For Edit, Take the 3rd Argument and fetch all values from database. 
* -------------------------------------------------------------------------
*/
$city_options = array();
$state_options = array();
$state_options = getStates();
$charity_organization_id = arg(3);
$query = "SELECT * FROM c2s_charity_org_master WHERE charity_organization_id = " . $charity_organization_id;
$result = db_query($query);
foreach ($result as $value) {
    $charity_org_name = $value->charity_org_name;
    $number_501_c_3 = $value->number_501_c_3;
    $charity_org_address = $value->charity_org_address;
    $charity_org_city = $value->charity_org_city;
    $charity_org_state = $value->charity_org_state;
    $charity_org_zip = $value->charity_org_zip;
    $phone_number = $value->phone_number;
    $email_id = $value->email_id;
    $website_url = $value->website_url;
    $bank_account_number = $value->bank_account_number;
    $bank_account_name = $value->bank_account_name;
    $bank_name = $value->bank_name;
    $bank_phone = $value->bank_phone;
    $bank_account_type = $value->bank_account_type;
    $bank_aba_routing_number = $value->bank_aba_routing_number;
    $input_class = 'input_disabled';
    $select_class = 'input_disabled';
Пример #9
0
/**
 * Return full name of a US state
 *
 * @return String Name of state
 */
function getFullStateName($state)
{
    $statesarray = getStates();
    return $statesarray[$state];
}
Пример #10
0
<?php

require_once './conf.php';
require_once './core/DB.php';
require_once './core/BaseModel.php';
require_once './model/Candidate.php';
require_once './model/Zstate.php';
require_once './model/CandidateAddress.php';
use Model\Candidate;
$candidate = new Candidate();
$params = $_REQUEST;
$params['ip'] = $_SERVER['HTTP_HOST'];
echo '<pre>';
//print_r(signup($params));
//print_r(addState($params['name']));
print_r(getStates(array('name' => array('op' => 'LIKE', 'val' => $params['name']))));
function signup($params)
{
    global $candidate;
    return $candidate->add(array('fullname' => $params['fullname'], 'phone' => $params['phone'], 'email' => $params['email'], 'passwd' => $params['passwd'], 'dob' => $params['dob'], 'gender' => $params['gender'], 'update_by' => $params['ip']));
}
function addAddress($params)
{
    $candidateAddress = new \Model\CandidateAddress();
    return $candidateAddress->add(array('candidate_id' => $params['candidate_id'], 'is_present' => $params['is_present'], 'address' => $params['address'], 'city' => $params['city'], 'state' => $params['state'], 'zip' => $params['zip'], 'update_by' => $params['ip']));
}
function addState($name)
{
    $stateModel = new Model\Zstate();
    return $stateModel->add(array('name' => $name));
}
Пример #11
0
if (!isset($_SESSION["userID"])) {
    echo "Votre session a expiré, veuillez vous reconnecter.";
    exit;
}
if (!isset($_REQUEST["action"])) {
    echo "Erreur d'appel de la page.";
    exit;
}
header("Content-Type: application/json; charset=utf-8");
$aSchools = getGroupsData();
if ($_REQUEST["action"] != "state") {
    if (!(isset($_REQUEST["schoolID"]) && in_array($_REQUEST["schoolID"], array_keys($aSchools)))) {
        echo "Etablissement invalide";
        exit;
    }
    if ($_REQUEST["action"] == "add") {
        CertiGen::queueAdd($_REQUEST["schoolID"]);
    }
    if ($_REQUEST["action"] == "cancel") {
        CertiGen::queueCancel($_REQUEST["schoolID"]);
    }
    // When the queue is modified we want to immediately return the state
    // This allows us to have one less request and an immediate update of the page
    $_REQUEST["action"] = "state";
}
// We only want to know the current state of each school
if ($_REQUEST["action"] == "state") {
    $aSchools = getStates($aSchools);
    echo json_encode($aSchools);
    exit;
}
Пример #12
0
<?php

/*
 * Created on 29-Nov-08
 * General Services.
 */
$action = $_REQUEST['action'];
/**
 * Called By Ajax to build States list.
 */
if ($action == 'getStates') {
    $country = $_REQUEST['country'];
    $allStates = getStates($country);
    $string = "";
    foreach ($allStates as &$state) {
        $string = $string . "-" . $state;
    }
    echo $string;
}
/**
 * 
 */
function getCountries()
{
    return array("India", "USA", "UK");
}
function getStates($cntry)
{
    if ($cntry == "India") {
        return array("AP", "Tamil Nadu", "Karnataka", "Kerala");
    } else {
Пример #13
0
 public function change()
 {
     if ($_POST) {
         //Try uploading the site image. If no new image is set, it should be an error.
         $name = 'siteimg' . time();
         //Processing the SiteImage.
         $config['upload_path'] = './uploads/';
         $config['allowed_types'] = 'gif|jpg|png|jpeg';
         $config['max_size'] = '1024';
         $config['max_width'] = '0';
         $config['max_height'] = '0';
         $config['file_name'] = $name;
         $this->load->library('upload', $config);
         $name = "";
         if ($this->upload->do_upload('picture')) {
             $uploaddata = $this->upload->data();
             $name = $uploaddata['file_name'];
         }
         //Create the site.
         $site = $this->createSite();
         $siteID = $this->input->post('SiteID');
         if ($name != "") {
             //Add image to sitepic table.
             $this->site->addPic($name, $siteID);
         }
         $result = $this->site->update($site, $siteID);
         if (!$result) {
             addError(getTxt('ProcessingError') . " Error while adding sites. ");
         } else {
             //Update Series.
             $series = array('SiteCode' => $this->input->post('SiteCode'), 'SiteName' => $this->input->post('SiteName'), 'SiteType' => $this->input->post('SiteType'));
             $this->load->model('sc', '', TRUE);
             //Add to the series catalog
             $result = $this->sc->updateSite($series, $siteID);
             if ($result) {
                 addSuccess(getTxt('SiteSuccessfullyEdited'));
             } else {
                 addError(getTxt('ProcessingError') . " Error while updating Series. ");
             }
         }
     }
     $sources = $this->sources->getAll();
     $sourceOptions = optionsSource($sources);
     $types = $this->site->getSiteTypes();
     $typesArray = array();
     foreach ($types as $type) {
         $typesArray[$type['Term']] = translateTerm($type['Term']);
     }
     $typeOptions = genOptions($typesArray);
     $vds = $this->site->getVD();
     $verticalDatumArray = array();
     foreach ($vds as $vd) {
         $verticalDatumArray[$vd['Term']] = translateTerm($vd['Term']);
     }
     $vdOptions = genOptions($verticalDatumArray);
     $srs = $this->site->getSR();
     $srArray = array();
     foreach ($srs as $sr) {
         $srArray[$sr['SpatialReferenceID']] = translateTerm($sr['SRSName']);
     }
     $srOptions = genOptions($srArray);
     //List of CSS to pass to this view
     $data = $this->StyleData;
     $data['sourceOptions'] = $sourceOptions;
     $data['typeOptions'] = $typeOptions;
     $data['vdOptions'] = $vdOptions;
     $data['srOptions'] = $srOptions;
     //Getting the states dropdown
     $states = getStates();
     $states['NULL'] = getTxt('International');
     $stateOptions = genOptions($states);
     $data['stateOptions'] = $stateOptions;
     $this->load->view('sites/editsite', $data);
 }
Пример #14
0
function countryBids($uid, $country, $bid)
{
    ///api/help/bid/state?uid=&state=&bid=
    $url = APIHTTPPATH . '/help/bid/country?uid=' . $uid . '&country=' . $country . '&bid=' . $bid;
    $countryBids = curlget($url);
    $countryBids = json_decode($countryBids, 1);
    return $countryBids;
}
if (!empty($_GET['country']) && !empty($_GET['state'])) {
    $countryList = getCountry();
    $stateList = getStates($_GET['country']);
    $cityList = getCityList($_GET['state']);
} else {
    if (!empty($_GET['country'])) {
        $countryList = getCountry();
        $stateList = getStates($_GET['country']);
    } else {
        $countryList = getCountry();
    }
}
if (!empty($_GET['bidCountryAmount']) && !empty($_GET['country'])) {
    $bid = countryBids($_SESSION['user']['id'], $_GET['country'], $_GET['bidCountryAmount']);
} else {
    if (!empty($_GET['bidStateAmount']) && !empty($_GET['state'])) {
        $bid = stateBids($_SESSION['user']['id'], $_GET['state'], $_GET['bidStateAmount']);
    } else {
        if (!empty($_GET['bidCityAmount']) && !empty($_GET['city'])) {
            $bid = cityBids($_SESSION['user']['id'], $_GET['city'], $_GET['bidCityAmount']);
        }
    }
}
Пример #15
0
function printComputerInfo($ipaddress, $stateid, $owner, $platformid, $scheduleid, $currentimgid, $ram, $numprocs, $procspeed, $network, $hostname, $compid, $type, $provisioningid)
{
    $states = getStates();
    $platforms = getPlatforms();
    $schedules = getSchedules();
    $images = getImages();
    $provisioning = getProvisioning();
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>Hostname:</TH>\n";
    print "    <TD>{$hostname}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>IP&nbsp;Address:</TH>\n";
    print "    <TD>{$ipaddress}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>State:</TH>\n";
    print "    <TD>" . $states[$stateid] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Owner:</TH>\n";
    print "    <TD>{$owner}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Platform:</TH>\n";
    print "    <TD>" . $platforms[$platformid] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Schedule:</TH>\n";
    print "    <TD>" . $schedules[$scheduleid]["name"] . "</TD>\n";
    print "  </TR>\n";
    if (!empty($currentimgid)) {
        print "  <TR>\n";
        print "    <TH align=right>Current&nbsp;Image:</TH>\n";
        print "    <TD>" . $images[$currentimgid]["prettyname"] . "</TD>\n";
        print "  </TR>\n";
    }
    print "  <TR>\n";
    print "    <TH align=right>RAM (MB):</TH>\n";
    print "    <TD>{$ram}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>No.&nbsp;Processors:</TH>\n";
    print "    <TD>{$numprocs}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Processor&nbsp;Speed&nbsp;(MHz):</TH>\n";
    print "    <TD>{$procspeed}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Network&nbsp;Speed&nbsp;(Mbps):</TH>\n";
    print "    <TD>{$network}</TD>\n";
    print "  </TR>\n";
    if (!empty($compid)) {
        print "  <TR>\n";
        print "    <TH align=right>Computer&nbsp;ID:</TH>\n";
        print "    <TD>{$compid}</TD>\n";
        print "  </TR>\n";
    }
    print "  <TR>\n";
    print "    <TH align=right>Type:</TH>\n";
    print "    <TD>{$type}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Provisioning Engine:</TH>\n";
    print "    <TD>" . $provisioning[$provisioningid]['prettyname'] . "</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
}
Пример #16
0
function XMLRPCgetRequestIds()
{
    global $user;
    $requests = getUserRequests("all");
    if (empty($requests)) {
        return array('status' => 'success', 'requests' => array());
    }
    $states = getStates();
    $ret = array();
    foreach ($requests as $req) {
        $start = datetimeToUnix($req['start']);
        $end = datetimeToUnix($req['end']);
        $tmp = array('requestid' => $req['id'], 'imageid' => $req['imageid'], 'imagename' => $req['prettyimage'], 'start' => $start, 'end' => $end, 'OS' => $req['OS'], 'isserver' => $req['server'], 'admin' => $req['serveradmin']);
        if ($req['currstateid'] == 14) {
            $tmp['state'] = $states[$req['laststateid']];
        } else {
            $tmp['state'] = $states[$req['currstateid']];
        }
        if ($req['server']) {
            $tmp['servername'] = $req['servername'];
        }
        array_push($ret, $tmp);
    }
    return array('status' => 'success', 'requests' => $ret);
}