Ejemplo n.º 1
0
 function Refresh()
 {
     if (!$this->IsValid()) {
         return -1;
     }
     $osid = $this->osid();
     $query_result = DBQueryWarn("select * from os_info where imageid='{$osid}'");
     if (!$query_result || !mysql_num_rows($query_result)) {
         $this->osinfo = NULL;
         return -1;
     }
     $this->osinfo = mysql_fetch_array($query_result);
     return 0;
 }
Ejemplo n.º 2
0
 function ClientSliver($token)
 {
     $safe_token = addslashes($token);
     $dblink = GetDBLink("sa");
     $idx = null;
     if (!$dblink) {
         $this->sliver = null;
         return;
     }
     if (preg_match("/^\\d+\$/", $token)) {
         $idx = $token;
     }
     if (is_null($idx)) {
         $this->sliver = null;
         return;
     }
     $query_result = DBQueryWarn("select * from client_slivers where idx='{$idx}'", $dblink);
     if (!$query_result || !mysql_num_rows($query_result)) {
         $this->sliver = null;
         return;
     }
     $this->dblink = $dblink;
     $this->sliver = mysql_fetch_array($query_result);
 }
Ejemplo n.º 3
0
 function IdleStale()
 {
     $node_id = $this->node_id();
     #
     # We currently have a 5 minute interval for slothd between reports
     # So give some slack in case a node reboots without reporting for
     # a while
     #
     # In Minutes;
     $staletime = 10;
     $stalesec = 60 * $staletime;
     $query_result = DBQueryWarn("select (unix_timestamp(now()) - " . "    unix_timestamp(last_report )) as t " . "from node_activity where node_id='{$node_id}'");
     if (mysql_num_rows($query_result) == 0) {
         return -1;
     }
     $row = mysql_fetch_array($query_result);
     return $row["t"] > $stalesec;
 }
Ejemplo n.º 4
0
    #
    if ($formfields["searchwhat"] == "this") {
        $versionclause = "and i.parent_vers='{$vers}'";
    }
    $query_string = "select r.*,b.runidx,i.parent_vers " . "     from experiment_template_instances as i " . "left join experiment_run_bindings as b on b.exptidx=i.exptidx " . "left join experiment_runs as r on " . "     r.exptidx=b.exptidx and r.idx=b.runidx " . "where (i.parent_guid='{$guid}' {$versionclause}) and ({$clausestring}) " . "group by i.idx,b.runidx having count(b.runidx) {$matchif}";
}
#TBERROR($query_string, 0);
$query_result = DBQueryWarn($query_string);
if (!$query_result || !mysql_num_rows($query_result)) {
    $errors["Match Failure"] = "There were no matches";
    SPITFORM($formfields, $errors);
    return;
}
# Save this search to the DB if requested.
if (isset($formfields['savesearch']) && $formfields['savesearch']) {
    DBQueryWarn("replace into experiment_template_searches set " . " uid_idx='{$uid_idx}', created=now(), " . " parent_guid='{$guid}', " . " parent_vers='" . $root->vers() . "'," . " name='" . addslashes($formfields['savename']) . "'," . " expr='" . addslashes(serialize($formfields)) . "'");
    # Indicate that we are using a saved search, so that we get delete button.
    $prevsearch = $formfields['savename'];
}
# Spit the form again so the user can change the search criteria.
SPITFORM($formfields, $errors);
echo "<br>\n";
if ($formfields["searchwhich"] == "template") {
    AddSortedTable("mytable");
    echo "<table align=center id='mytable'\n\t\t border=1 cellpadding=5 cellspacing=2>\n";
    echo "<thead class='sort'>\n";
    echo "<tr>\n            <th>Vers</th>\n            <th>Parent</th>\n            <th>TID</th>\n            <th>Created</th>\n            <th>Description</th>\n          </tr>\n";
    echo "</thead>\n";
    while ($row = mysql_fetch_array($query_result)) {
        $vers = $row['vers'];
        $tid = $row['tid'];
Ejemplo n.º 5
0
 function Refresh()
 {
     if (!$this->IsValid()) {
         return -1;
     }
     $imageid = $this->imageid();
     $query_result = DBQueryWarn("select * from images where imageid='{$imageid}'");
     if (!$query_result || !mysql_num_rows($query_result)) {
         $this->imageid = NULL;
         return -1;
     }
     $this->image = mysql_fetch_array($query_result);
     #
     # Reload the type info.
     #
     $types = array();
     $query_result = DBQueryFatal("select distinct type from osidtoimageid " . "where imageid='{$imageid}'");
     while ($row = mysql_fetch_array($query_result)) {
         $types[] = $row['type'];
     }
     $this->types = $types;
     return 0;
 }
Ejemplo n.º 6
0
 function ExperimentResources($rsrcidx)
 {
     $safe_rsrcidx = addslashes($rsrcidx);
     $query_result = DBQueryWarn("select r.* from experiment_resources as r " . "where r.idx='{$safe_rsrcidx}'");
     if (!$query_result || !mysql_num_rows($query_result)) {
         $this->resources = null;
         return;
     }
     $this->resources = mysql_fetch_array($query_result);
 }
Ejemplo n.º 7
0
 function TableDelete($table, $conditions = "")
 {
     $uid_idx = $this->uid_idx();
     if ($conditions && $conditions != "") {
         $conditions = "and ({$conditions})";
     } else {
         $conditions = "";
     }
     if (!DBQueryWarn("delete from {$table} " . "where uid_idx='{$uid_idx}' {$conditions}")) {
         return -1;
     }
     return 0;
 }
Ejemplo n.º 8
0
 function AddNewMember($user)
 {
     $uid = $user->uid();
     $uid_idx = $user->uid_idx();
     $pid = $this->pid();
     $pid_idx = $this->pid_idx();
     $gid = $this->gid();
     $gid_idx = $this->gid_idx();
     if (!DBQueryWarn("insert into group_membership " . "(uid, uid_idx, gid, gid_idx, pid, pid_idx, " . " trust, date_applied) " . "values ('{$uid}', '{$uid_idx}', '{$gid}', '{$gid_idx}', " . "        '{$pid}', '{$pid_idx}', " . "        'none', now())")) {
         return -1;
     }
     return 0;
 }
Ejemplo n.º 9
0
 function ShowRunBindings($runidx = null)
 {
     $exptidx = $this->exptidx();
     $id = "{$exptidx}_runbindings";
     if (!$runidx) {
         $runidx = $this->runidx();
     }
     $query_result = DBQueryWarn("select * from experiment_run_bindings " . "where exptidx='{$exptidx}' and runidx='{$runidx}' " . "order by name");
     if (!mysql_num_rows($query_result)) {
         return 0;
     }
     AddSortedTable($id);
     echo "<center>\n               <h3>Run Bindings</h3>\n             </center> \n             <table id='{$id}'\n                    align=center border=1 cellpadding=5 cellspacing=2>\n";
     echo "<thead class='sort'>\n";
     echo "<tr>\n                <th>Name</th>\n                <th>Value</th>\n              </tr>\n";
     echo "</thead>\n";
     while ($row = mysql_fetch_array($query_result)) {
         $name = $row['name'];
         $value = $row['value'];
         if (!isset($value)) {
             $value = "&nbsp";
         }
         echo "<tr>\n                   <td>{$name}</td>\n                   <td>{$value}</td>\n                  </tr>\n";
     }
     echo "</table>\n";
     return 1;
 }
Ejemplo n.º 10
0
 function NewProject($pid, $leader, $args)
 {
     global $TBBASE, $TBMAIL_APPROVAL, $TBMAIL_AUDIT, $TBMAIL_WWW;
     #
     # The array of inserts is assumed to be safe already. Generate
     # a list of actual insert clauses to be joined below.
     #
     $insert_data = array();
     foreach ($args as $name => $value) {
         $insert_data[] = "{$name}='{$value}'";
     }
     # First create the underlying default group for the project.
     if (!($newgroup = Group::NewGroup(null, $pid, $leader, 'Default Group', $pid))) {
         return null;
     }
     # Every project gets a new unique index, which comes from the group.
     $pid_idx = $newgroup->gid_idx();
     # Now tack on other stuff we need.
     $insert_data[] = "pid='{$pid}'";
     $insert_data[] = "pid_idx='{$pid_idx}'";
     $insert_data[] = "head_uid='" . $leader->uid() . "'";
     $insert_data[] = "head_idx='" . $leader->uid_idx() . "'";
     $insert_data[] = "created=now()";
     # Insert into DB. Should probably lock the table ...
     if (!DBQuerywarn("insert into projects set " . implode(",", $insert_data))) {
         $newgroup->Delete();
         return null;
     }
     if (!DBQueryWarn("insert into project_stats (pid, pid_idx) " . "values ('{$pid}', {$pid_idx})")) {
         $newgroup->Delete();
         DBQueryFatal("delete from projects where pid_idx='{$pid_idx}'");
         return null;
     }
     $newproject = Project::Lookup($pid_idx);
     if (!$newproject) {
         return null;
     }
     #
     # The creator of a group is not automatically added to the group,
     # but we do want that for a new project.
     #
     if ($newgroup->AddNewMember($leader) < 0) {
         $newgroup->Delete();
         DBQueryWarn("delete from project_stats where pid_idx={$pid_idx}");
         DBQueryWarn("delete from projects where pid_idx={$pid_idx}");
         return null;
     }
     return $newproject;
 }