PHP Method User::Lookup, codiad Code Examples

This page contains top rated real world PHP examples of method User::Lookup from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: url_defs.php Project: mahyuddin/emulab-stable
0
function VerifyPageArguments($argspec, $required)
{
    global $drewheader;
    if ($drewheader) {
        trigger_error("PAGEHEADER called before VerifyPageArguments " . "(called by RequiredPageArguments or OptionalPageArguments). " . "Won't be able to return proper HTTP status code on Error " . "in " . $_SERVER['SCRIPT_FILENAME'] . ",", E_USER_WARNING);
    }
    $result = array();
    while ($argspec and count($argspec) > 1) {
        $name = array_shift($argspec);
        $type = array_shift($argspec);
        $yep = 0;
        unset($object);
        switch ($type) {
            case PAGEARG_EXPERIMENT:
                if (isset($_REQUEST[URL_EXPERIMENT])) {
                    $idx = $_REQUEST[URL_EXPERIMENT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_EXPTIDX])) {
                    $idx = $_REQUEST[URL_EXPTIDX];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_EID])) {
                    $pid = $_REQUEST[URL_PID];
                    $eid = $_REQUEST[URL_EID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_EID, $eid)) {
                        $object = Experiment::LookupByPidEid($pid, $eid);
                    }
                }
                break;
            case PAGEARG_TEMPLATE:
                if (isset($_REQUEST[URL_GUID]) && isset($_REQUEST[URL_VERS])) {
                    $guid = $_REQUEST[URL_GUID];
                    $vers = $_REQUEST[URL_VERS];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GUID, $guid) && ValidateArgument(PAGEARG_VERS, $vers)) {
                        $object = Template::Lookup($guid, $vers);
                    }
                } elseif (isset($_REQUEST[URL_TEMPLATE])) {
                    $guidvers = $_REQUEST[URL_TEMPLATE];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = Template::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_INSTANCE:
                if (isset($_REQUEST[URL_INSTANCE])) {
                    $idx = $_REQUEST[URL_INSTANCE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_INSTANCE, $idx)) {
                        $object = TemplateInstance::LookupByExptidx($idx);
                    }
                }
                break;
            case PAGEARG_METADATA:
                if (isset($_REQUEST[URL_METADATA])) {
                    $guidvers = $_REQUEST[URL_METADATA];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = TemplateMetadata::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_PROJECT:
                if (isset($_REQUEST[URL_PROJECT])) {
                    $idx = $_REQUEST[URL_PROJECT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PROJECT, $idx)) {
                        $object = Project::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID])) {
                    $pid = $_REQUEST[URL_PID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid)) {
                        $object = Project::Lookup($pid);
                    }
                }
                break;
            case PAGEARG_GROUP:
                if (isset($_REQUEST[URL_GROUP])) {
                    $idx = $_REQUEST[URL_GROUP];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GROUP, $idx)) {
                        $object = Group::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_GID])) {
                    $pid = $_REQUEST[URL_PID];
                    $gid = $_REQUEST[URL_GID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_GID, $gid)) {
                        $object = Group::LookupByPidGid($pid, $gid);
                    }
                }
                break;
            case PAGEARG_NODE:
                if (isset($_REQUEST[URL_NODE])) {
                    $idx = $_REQUEST[URL_NODE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODE, $idx)) {
                        $object = Node::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_NODEID])) {
                    $nodeid = $_REQUEST[URL_NODEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                } elseif (isset($_REQUEST[URL_NODEID_ALT])) {
                    $nodeid = $_REQUEST[URL_NODEID_ALT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                }
                break;
            case PAGEARG_USER:
                if (isset($_REQUEST[URL_USER])) {
                    $idx = $_REQUEST[URL_USER];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_USER, $idx)) {
                        $object = User::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_UID])) {
                    $uid = $_REQUEST[URL_UID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_UID, $uid)) {
                        $object = User::Lookup($uid);
                    }
                }
                break;
            case PAGEARG_IMAGE:
                if (isset($_REQUEST[URL_IMAGEID])) {
                    $imageid = $_REQUEST[URL_IMAGEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                } elseif (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $imageid = $_REQUEST[$name];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                }
                break;
            case PAGEARG_OSINFO:
                if (isset($_REQUEST[URL_OSID])) {
                    $osid = $_REQUEST[URL_OSID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_OSINFO, $osid)) {
                        $object = OSinfo::Lookup($osid);
                    }
                }
                break;
            case PAGEARG_BOOLEAN:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (strcasecmp("{$object}", "yes") == 0 || strcasecmp("{$object}", "1") == 0 || strcasecmp("{$object}", "true") == 0 || strcasecmp("{$object}", "on") == 0) {
                        $object = True;
                    } elseif (strcasecmp("{$object}", "no") == 0 || strcasecmp("{$object}", "0") == 0 || strcasecmp("{$object}", "false") == 0 || strcasecmp("{$object}", "off") == 0) {
                        $object = False;
                    }
                }
                break;
            case PAGEARG_INTEGER:
            case PAGEARG_NUMERIC:
            case PAGEARG_ARRAY:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (!ValidateArgument($type, $object)) {
                        unset($object);
                    }
                }
                break;
            case PAGEARG_ANYTHING:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Anything allowed, caller BETTER check it.
                }
                break;
            case PAGEARG_ALPHALIST:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    if (!preg_match("/^[\\d\\w\\-\\ \\,]+\$/", $object)) {
                        unset($object);
                    } else {
                        $object = preg_split("/[\\,\\;]+\\s*/", $_REQUEST[$name]);
                    }
                }
                break;
            case PAGEARG_STRING:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Pages never get arguments with special chars. Check.
                    if (preg_match("/[\\'\"]/", $object)) {
                        $object = htmlspecialchars($object);
                        PAGEARGERROR("Invalid characters in '{$name}': {$object}");
                    }
                }
                break;
            case PAGEARG_PASSWORD:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Only printable chars.
                    if (!preg_match("/^[ -~]+\$/", $object)) {
                        PAGEARGERROR("Invalid characters in '{$name}'");
                    }
                }
                break;
            case PAGEARG_LOGFILE:
                if (isset($_REQUEST[URL_LOGFILE])) {
                    $logid = $_REQUEST[URL_LOGFILE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_LOGFILE, $logid)) {
                        $object = Logfile::Lookup($logid);
                    }
                }
                break;
        }
        if (isset($object)) {
            $result[$name] = $object;
            $GLOBALS[$name] = $object;
        } elseif ($yep) {
            #
            # Value supplied but could not be mapped to object.
            # Lets make that clear in the error message.
            #
            USERERROR("Could not map page arguments to '{$name}'", 1);
        } elseif ($required) {
            PAGEARGERROR("Must provide '{$name}' page argument");
        } else {
            unset($GLOBALS[$name]);
        }
    }
    return $result;
}
Example #2
Show file File: changeuid.php Project: mahyuddin/emulab-stable
0
    return;
}
#
# If not clicked, then put up a form.
#
if (!isset($submit)) {
    SPITFORM($target_user, "", null);
    return;
}
# Sanity checks
$error = null;
if (!isset($new_uid) || $new_uid == "") {
    $error = "UID: Must supply a new UID";
} elseif (!TBvalid_uid($new_uid)) {
    $error = "UID: " . TBFieldErrorString();
} elseif (User::Lookup($new_uid) || posix_getpwnam($new_uid)) {
    $error = "UID: Already in use. Pick another";
}
if ($error) {
    SPITFORM($target_user, $new_uid, $error);
    return;
}
#
# Standard Testbed Header.
#
PAGEHEADER("Change login UID for user");
# Okay, call out to backend to change.
STARTBUSY("Changing UID");
#
# Run the backend script.
#
Example #3
Show file File: imageid_defs.php Project: mahyuddin/emulab-stable
0
 function Show($showperms = 0)
 {
     global $TBBASE;
     $imageid = $this->imageid();
     $imagename = $this->imagename();
     $pid = $this->pid();
     $gid = $this->gid();
     $description = $this->description();
     $loadpart = $this->loadpart();
     $loadlength = $this->loadlength();
     $part1_osid = $this->part1_osid();
     $part2_osid = $this->part2_osid();
     $part3_osid = $this->part3_osid();
     $part4_osid = $this->part4_osid();
     $default_osid = $this->default_osid();
     $path = $this->path();
     $shared = $this->shared();
     $globalid = $this->isglobal();
     $creator = $this->creator();
     $creator_urn = $this->creator_urn();
     $created = $this->created();
     $updated = $this->updated();
     $updater = $this->updater();
     $updater_urn = $this->updater_urn();
     $uuid = $this->uuid();
     $mbr_version = $this->mbr_version();
     $hash = $this->hash();
     #
     # An imported image has a metadata_url, and at the moment I
     # do want to worry about exporting an imported image.
     #
     $imagefile_url = $this->imagefile_url();
     $metadata_url = $this->metadata_url();
     if (!$metadata_url) {
         $metadata_url = "{$TBBASE}/image_metadata.php?uuid={$uuid}";
     }
     if (!$description) {
         $description = " ";
     }
     if (!$path) {
         $path = " ";
     }
     if (!$created) {
         $created = "N/A";
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=2 cellpadding=2 cellspacing=2>\n";
     echo "<tr>\n                <td>Image Name: </td>\n                <td class=\"left\">{$imagename}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Description: </td>\n                <td class=left>\n";
     echo "{$description}";
     echo "   </td>\n \t      </tr>\n";
     echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n              </tr>\n";
     echo "<tr>\n                  <td>Group: </td>\n                  <td class=\"left\">\n                    <a href='showgroup.php3?pid={$pid}&gid={$gid}'>{$gid}</a></td>\n              </tr>\n";
     echo "<tr>\n                <td>Created: </td>\n                <td class=left>{$created}</td>\n \t      </tr>\n";
     echo "<tr>\n                <td>Creator: </td>\n                <td class=left>{$creator}</td>\n     \t      </tr>\n";
     if ($creator_urn) {
         echo "<tr>\n                    <td>Creator URN: </td>\n                    <td class=left>{$creator_urn}</td>\n         \t  </tr>\n";
     }
     if ($updated) {
         echo "<tr>\n                    <td>Updated: </td>\n                    <td class=left>{$updated}</td>\n     \t          </tr>\n";
         echo "<tr>\n                    <td>Updated By: </td>\n                    <td class=left>{$updater}</td>\n     \t          </tr>\n";
         if ($updater_urn) {
             echo "<tr>\n                        <td>Updater URN: </td>\n                        <td class=left>{$updater_urn}</td>\n         \t          </tr>\n";
         }
     }
     #
     # Find the last time this image was used.
     #
     $usage_result = DBQueryFatal("select FROM_UNIXTIME(stamp) as lastused " . "  from image_history " . "where action='os_setup' and imageid='{$imageid}' " . "order by stamp desc limit 1");
     if (mysql_num_rows($usage_result)) {
         $urow = mysql_fetch_array($usage_result);
         $lastused = $urow['lastused'];
         echo "<tr>\n                    <td>Last Used: </td>\n                    <td class=\"left\">{$lastused}</td>\n                  </tr>\n";
     }
     echo "<tr>\n                <td>Load Partition: </td>\n                <td class=\"left\">{$loadpart}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Load Length: </td>\n                <td class=\"left\">{$loadlength}</td>\n              </tr>\n";
     if ($part1_osid) {
         echo "<tr>\n                     <td>Partition 1 OS: </td>\n                     <td class=\"left\">";
         SpitOSIDLink($part1_osid);
         echo "   </td>\n                  </tr>\n";
     }
     if ($part2_osid) {
         echo "<tr>\n                     <td>Partition 2 OS: </td>\n                     <td class=\"left\">";
         SpitOSIDLink($part2_osid);
         echo "   </td>\n                  </tr>\n";
     }
     if ($part3_osid) {
         echo "<tr>\n                     <td>Partition 3 OS: </td>\n                     <td class=\"left\">";
         SpitOSIDLink($part3_osid);
         echo "   </td>\n                  </tr>\n";
     }
     if ($part4_osid) {
         echo "<tr>\n                     <td>Partition 4 OS: </td>\n                     <td class=\"left\">";
         SpitOSIDLink($part4_osid);
         echo "   </td>\n                  </tr>\n";
     }
     if ($default_osid) {
         echo "<tr>\n                     <td>Boot OS: </td>\n                     <td class=\"left\">";
         SpitOSIDLink($default_osid);
         echo "   </td>\n                  </tr>\n";
     }
     echo "<tr>\n                <td>Filename: </td>\n                <td class=left>\n";
     echo "{$path}";
     echo "  </td>\n              </tr>\n";
     echo "<tr>\n                  <td>Types: </td>\n                  <td class=left>\n";
     echo "&nbsp;";
     foreach ($this->Types() as $type) {
         echo "{$type} &nbsp; ";
     }
     echo "  </td>\n              </tr>\n";
     echo "<tr>\n                <td>Shared?: </td>\n                <td class=left>\n";
     if ($shared) {
         echo "Yes";
     } else {
         echo "No";
     }
     echo "  </td>\n              </tr>\n";
     echo "<tr>\n                <td>Global?: </td>\n                <td class=left>\n";
     $globalflip = $globalid ? 0 : 1;
     $globalval = $globalid ? "Yes" : "No";
     echo "{$globalval} (<a href=toggle.php?imageid={$imageid}" . "&type=imageglobal&value={$globalflip}>Toggle</a>)";
     echo "  </td>\n              </tr>\n";
     echo "<tr>\n                <td>Internal ID: </td>\n                <td class=left>{$imageid}</td>\n              </tr>\n";
     echo "<tr>\n                <td>MBR Version: </td>\n                <td class=left>{$mbr_version}</td>\n              </tr>\n";
     # Until I change the schema.
     if ($mbr_version == 99) {
         echo "<tr>\n                    <td>XEN Package: </td>\n                    <td class=left>Yes</td>\n                  </tr>\n";
     }
     if ($this->ezid()) {
         $doesxen = 0;
         $osinfo = OSinfo::Lookup($imageid);
         if ($osinfo && $osinfo->def_parentosid()) {
             $parentosinfo = OSinfo::Lookup($osinfo->def_parentosid());
             if ($parentosinfo && $parentosinfo->FeatureSupported("xen-host")) {
                 $doesxen = 1;
             }
         }
         $xenval = $doesxen ? "Yes" : "No";
         $xenflip = $doesxen ? 0 : 1;
         echo "<tr>\n                  <td>XEN Capable?:</td>\n   \t          <td class=left>\n                     {$xenval} (<a href=toggle.php?imageid={$imageid}" . "&type=imagedoesxen&value={$xenflip}>Toggle</a>\n                      if you know this image can run\n               as a XEN guest. More info\n               <a target=_blank\n                  href='https://wiki.emulab.net/wiki/Emulab/wiki/xen'>here</a>)\n              </td>\n             </tr>\n";
     }
     if ($hash) {
         echo "<tr>\n                    <td>SHA1 Hash: </td>\n                    <td class=left>{$hash}</td>\n                  </tr>\n";
     }
     echo "<tr>\n                <td>UUID: </td>\n                <td class=left>{$uuid}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Metadata URL: </td>\n                <td class=left><a href='{$metadata_url}'>https:// ...</a></td>\n              </tr>\n";
     if ($imagefile_url) {
         echo "<tr>\n                   <td>Image File URL: </td>\n                   <td class=left><a href='{$imagefile_url}'>https:// ...</a></td>\n                  </tr>\n";
     }
     #
     # Show who all can access this image outside the project.
     #
     if ($showperms) {
         $query_result = DBQueryFatal("select * from image_permissions " . "where imageid='{$imageid}' " . "order by permission_type,permission_id");
         if (mysql_num_rows($query_result)) {
             echo "<tr>\n                      <td align=center colspan=2>\n                      External permissions\n                      </td>\n                  </tr>\n";
             while ($row = mysql_fetch_array($query_result)) {
                 $perm_type = $row['permission_type'];
                 $perm_idx = $row['permission_idx'];
                 $writable = $row['allow_write'];
                 if ($writable) {
                     $writable = "(read/write)";
                 } else {
                     $writable = "(read only)";
                 }
                 if ($perm_type == "user") {
                     $user = User::Lookup($perm_idx);
                     if (isset($user)) {
                         $uid = $user->uid();
                         echo "<tr>\n                                    <td>User: </td>\n                                    <td class=left>{$uid} {$writable}</td>\n                                  </tr>\n";
                     }
                 } elseif ($perm_type == "group") {
                     $group = Group::Lookup($perm_idx);
                     if (isset($group)) {
                         $pid = $group->pid();
                         $gid = $group->gid();
                         echo "<tr>\n                                    <td>Group: </td>\n                                    <td class=left>{$pid}/{$gid} {$writable}</td>\n                                  </tr>\n";
                     }
                 }
             }
         }
     }
     echo "</table>\n";
 }
Example #4
Show file File: node_defs.php Project: mahyuddin/emulab-stable
0
 function ShowWideAreaNode($embedded = 0)
 {
     $node_id = $this->node_id();
     $query_result = DBQueryFatal("select * from widearea_nodeinfo " . "where node_id='{$node_id}'");
     if (!mysql_num_rows($query_result)) {
         return;
     }
     $row = mysql_fetch_array($query_result);
     $contact_uid = $row["contact_uid"];
     $machine_type = $row["machine_type"];
     $connect_type = $row["connect_type"];
     $city = $row["city"];
     $state = $row["state"];
     $zip = $row["zip"];
     $country = $row["country"];
     $hostname = $row["hostname"];
     $site = $row["site"];
     $boot_method = $row["boot_method"];
     $gateway = $row["gateway"];
     $dns = $row["dns"];
     if (!($user = User::Lookup($contact_uid))) {
         # This is not an error since the field is set to "nobody" when
         # there is no contact info. Why is that?
         $showuser_url = CreateURL("showuser", URLARG_UID, $contact_uid);
     } else {
         $showuser_url = CreateURL("showuser", $user);
     }
     if (!$embedded) {
         echo "<table border=2 cellpadding=0 cellspacing=2\n                         align=center>\n";
     } else {
         echo "<tr>\n                   <td align=center colspan=2>\n                       Widearea Info\n                   </td>\n                 </tr>\n";
     }
     echo "<tr>\n                  <td>Contact UID:</td>\n                  <td class=left>\n                      <a href='{$showuser_url}'>{$contact_uid}</a></td>\n              </tr>\n";
     echo "<tr>\n                  <td>Machine Type:</td>\n                  <td class=left>{$machine_type}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>connect Type:</td>\n                  <td class=left>{$connect_type}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>City:</td>\n                  <td class=left>{$city}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>State:</td>\n                  <td class=left>{$state}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>ZIP:</td>\n                  <td class=left>{$zip}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Country:</td>\n                  <td class=left>{$country}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Hostname:</td>\n                  <td class=left>{$hostname}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Boot Method:</td>\n                  <td class=left>{$boot_method}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Gateway:</td>\n                  <td class=left>{$gateway}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>DNS:</td>\n                  <td class=left>{$dns}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Site:</td>\n                  <td class=left>{$site}</td>\n              </tr>\n";
     if (!$embedded) {
         echo "</table>\n";
     }
 }
Example #5
Show file File: user_defs.php Project: mahyuddin/emulab-stable
0
 function ApprovalList($listify = 1)
 {
     $uid_idx = $this->uid_idx();
     #
     # Find all of the groups that this person has project/group root in,
     # and then in all of those groups, all of the people who are awaiting
     # to be approved (status = none).
     #
     # Okay, so this operation sucks out the right people by joining the
     # group_membership table with itself.
     #
     $query_result = DBQueryFatal("select g.uid_idx,g.gid_idx " . "   from group_membership as authed " . "left join group_membership as g on " . "    g.pid_idx=authed.pid_idx and " . "    g.gid_idx=authed.gid_idx " . "left join users as u on u.uid_idx=g.uid_idx " . "where u.status!='" . TBDB_USERSTATUS_UNVERIFIED . "'" . "  and u.status!='" . TBDB_USERSTATUS_NEWUSER . "'" . "  and g.uid_idx!='{$uid_idx}' and " . "      g.trust='" . TBDB_TRUSTSTRING_NONE . "' " . "  and authed.uid_idx='{$uid_idx}' and " . "     (authed.trust='group_root' or " . "      authed.trust='project_root') " . "ORDER BY g.uid,g.pid,g.gid");
     if (!$listify) {
         return mysql_num_rows($query_result);
     }
     # Else, create a list of the groups.
     $result = array();
     while ($row = mysql_fetch_array($query_result)) {
         $uid_idx = $row["uid_idx"];
         $gid_idx = $row["gid_idx"];
         if (!($group = Group::Lookup($gid_idx))) {
             TBERROR("User::ApprovalList: " . "Could not load group {$gid_idx}!", 1);
         }
         if (!($user = User::Lookup($uid_idx))) {
             TBERROR("User::ApprovalList: " . "Could not load user {$uid_idx}!", 1);
         }
         if (!array_key_exists("{$uid_idx}", $result)) {
             $result["{$uid_idx}"] = array();
         }
         $result["{$uid_idx}"][] = $group;
     }
     return $result;
 }
Example #6
Show file File: experiment_defs.php Project: mahyuddin/emulab-stable
0
 function Show($short = 0, $sortby = "")
 {
     global $TBDBNAME, $TBDOCBASE, $WIKIDOCURL;
     $pid = $this->pid();
     $eid = $this->eid();
     $nodecounts = array();
     # Node counts, by class.
     $query_result = DBQueryFatal("select nt.class,count(*) from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join node_types as nt on n.type=nt.type " . "where pid='{$pid}' and eid='{$eid}' group by nt.class");
     while ($row = mysql_fetch_array($query_result)) {
         $class = $row[0];
         $count = $row[1];
         $nodecounts[$class] = $count;
     }
     $query_result = DBQueryFatal("select e.*, s.archive_idx, pl.slicename, " . "round(e.minimum_nodes+.1,0) as min_nodes, " . "round(e.maximum_nodes+.1,0) as max_nodes " . " from experiments as e " . "left join experiment_stats as s on s.exptidx=e.idx " . "left join plab_slices as pl" . " on e.pid = pl.pid and e.eid = pl.eid " . "where e.pid='{$pid}' and e.eid='{$eid}'");
     if (($exprow = mysql_fetch_array($query_result)) == 0) {
         TBERROR("Experiment {$eid} in project {$pid} is gone!\n", 1);
     }
     $exp_gid = $exprow["gid"];
     $exp_name = $exprow["expt_name"];
     $exp_swapped = $exprow["expt_swapped"];
     $exp_swapuid = $exprow["expt_swap_uid"];
     $exp_end = $exprow["expt_end"];
     $exp_created = $exprow["expt_created"];
     $exp_head = $exprow["expt_head_uid"];
     $exp_swapper = $exprow["swapper_idx"];
     $exp_state = $exprow["state"];
     $exp_shared = $exprow["shared"];
     $exp_path = $exprow["path"];
     $batchmode = $exprow["batchmode"];
     $canceled = $exprow["canceled"];
     $attempts = $exprow["attempts"];
     $expt_locked = $exprow["expt_locked"];
     $priority = $exprow["priority"];
     $swappable = $exprow["swappable"];
     $noswap_reason = $exprow["noswap_reason"];
     $idleswap = $exprow["idleswap"];
     $idleswap_timeout = $exprow["idleswap_timeout"];
     $noidleswap_reason = $exprow["noidleswap_reason"];
     $autoswap = $exprow["autoswap"];
     $autoswap_timeout = $exprow["autoswap_timeout"];
     $idle_ignore = $exprow["idle_ignore"];
     $savedisk = $exprow["savedisk"];
     $swapreqs = $exprow["swap_requests"];
     $lastswapreq = $exprow["last_swap_req"];
     $minnodes = $exprow["min_nodes"];
     $maxnodes = $exprow["max_nodes"];
     $virtnodes = $exprow["virtnode_count"];
     $syncserver = $exprow["sync_server"];
     $mem_usage = $exprow["mem_usage"];
     $cpu_usage = $exprow["cpu_usage"];
     $exp_slice = $exprow["slicename"];
     $linktest_level = $exprow["linktest_level"];
     $linktest_pid = $exprow["linktest_pid"];
     $usemodelnet = $exprow["usemodelnet"];
     $mnet_cores = $exprow["modelnet_cores"];
     $mnet_edges = $exprow["modelnet_edges"];
     $lockdown = $exprow["lockdown"];
     $skipvlans = $exprow["skipvlans"];
     $exptidx = $exprow["idx"];
     $archive_idx = $exprow["archive_idx"];
     $dpdb = $exprow["dpdb"];
     $dpdbname = $exprow["dpdbname"];
     $dpdbpassword = $exprow["dpdbpassword"];
     $uuid = $exprow["eid_uuid"];
     $paniced = $exprow["paniced"];
     $panic_date = $exprow["panic_date"];
     $autoswap_hrs = $autoswap_timeout / 60.0;
     $idleswap_hrs = $idleswap_timeout / 60.0;
     $noswap = "({$noswap_reason})";
     $noidleswap = "({$noidleswap_reason})";
     $autoswap_str = $autoswap_hrs . " hour" . ($autoswap_hrs == 1 ? "" : "s");
     $idleswap_str = $idleswap_hrs . " hour" . ($idleswap_hrs == 1 ? "" : "s");
     if (!($head_user = User::Lookup($exp_head))) {
         TBERROR("Error getting object for user {$exp_head}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     if (!($swapper = User::Lookup($exp_swapper))) {
         TBERROR("Error getting object for user {$exp_swapper}", 1);
     }
     $swapper_uid = $swapper->uid();
     $swapper_url = CreateURL("showuser", $swapper);
     if ($swappable) {
         $swappable = "Yes";
     } else {
         $swappable = "<b>No</b> {$noswap}";
     }
     if ($idleswap) {
         $idleswap = "Yes (after {$idleswap_str})";
     } else {
         $idleswap = "<b>No</b> {$noidleswap}";
     }
     if ($autoswap) {
         $autoswap = "<b>Yes</b> (after {$autoswap_str})";
     } else {
         $autoswap = "No";
     }
     if ($idle_ignore) {
         $idle_ignore = "<b>Yes</b>";
     } else {
         $idle_ignore = "No";
     }
     if ($savedisk) {
         $savedisk = "<b>Yes</b>";
     } else {
         $savedisk = "No";
     }
     if ($expt_locked) {
         $expt_locked = "({$expt_locked})";
     } else {
         $expt_locked = "";
     }
     $query_result = DBQueryFatal("select cause_desc " . "from experiment_stats as s,errors,causes " . "where s.exptidx = {$exptidx} " . "and errors.cause = causes.cause " . "and s.last_error = errors.session");
     if ($row = mysql_fetch_array($query_result)) {
         $err_cause = $row[0];
     } else {
         $err_cause = '';
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     if (!$short) {
         $thisurl = CreateURL("showexp", $this);
         echo "<tr>\n                <td>Name: </td>\n                <td class=left><a href='{$thisurl}'>{$eid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$exp_name}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$pid}'>{$pid}</a></td>\n              </tr>\n";
         echo "<tr>\n                <td>Group: </td>\n                <td class=\"left\">\n                  <a href='showgroup.php3?pid={$pid}&gid={$exp_gid}'>{$exp_gid}</a>\n                </td>\n              </tr>\n";
         if (isset($exp_slice)) {
             echo "<tr>\n                  <td>Planetlab Slice: </td>\n                  <td class=\"left\">{$exp_slice}</td>\n                </tr>\n";
         }
     }
     echo "<tr>\n            <td>Creator: </td>\n            <td class=\"left\">\n              <a href='{$showuser_url}'>{$exp_head}</a></td>\n          </tr>\n";
     if (!$swapper->SameUser($head_user)) {
         echo "<tr>\n                      <td>Swapper: </td>\n                      <td class=\"left\">\n                          <a href='{$swapper_url}'>{$swapper_uid}</a></td>\n                  </tr>\n";
     }
     if (!$short) {
         $instance = TemplateInstance::LookupByExptidx($exptidx);
         if (!is_null($instance)) {
             $guid = $instance->guid();
             $vers = $instance->vers();
             echo "<tr>\n                    <td>Template: </td>\n                    <td class=\"left\">\n                       <a href='template_show.php?guid={$guid}&version={$vers}'>\n                          {$guid}/{$vers}</a>";
             if ($instance->runidx()) {
                 $runidx = $instance->runidx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Current Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             } else {
                 $runidx = $instance->LastRunIdx();
                 $runid = $instance->GetRunID($runidx);
                 $url = CreateURL("experimentrun_show", $instance, "runidx", $runidx);
                 echo " (Last Run:\n                       <a href='{$url}'>{$runid}</a>)</td>";
             }
             echo "</tr>\n";
         }
         echo "<tr>\n                <td>Created: </td>\n                <td class=\"left\">{$exp_created}</td>\n              </tr>\n";
         if ($exp_swapped) {
             echo "<tr>\n                    <td>Last Swap/Modify: </td>\n                    <td class=\"left\">{$exp_swapped}\n                        (<a href='{$swapper_url}'>{$swapper_uid}</a>)</td>\n                  </tr>\n";
         }
         if (ISADMIN()) {
             echo "<tr>\n                    <td><a href='{$WIKIDOCURL}/Swapping#swapping'>Swappable:</a></td>\n                    <td class=\"left\">{$swappable}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td><a href='{$WIKIDOCURL}/Swapping#idleswap'>Idle-Swap:</a></td>\n                  <td class=\"left\">{$idleswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#autoswap'>Max. Duration:</a></td>\n                <td class=\"left\">{$autoswap}</td>\n              </tr>\n";
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/Swapping#swapstatesave'>Save State:</a></td>\n                <td class=\"left\">{$savedisk}</td>\n              </tr>\n";
         if (ISADMIN()) {
             echo "<tr>\n                    <td>Idle Ignore:</td>\n                    <td class=\"left\">{$idle_ignore}</td>\n                 </tr>\n";
         }
         echo "<tr>\n                <td>Path: </td>\n                <td class=left>{$exp_path}</td>\n              </tr>\n";
         echo "<tr>\n                <td>Status: </td>\n                <td id=exp_state class=\"left\">{$exp_state} {$expt_locked}</td>\n              </tr>\n";
         if ($err_cause) {
             echo "<tr>\n                    <td>Last Error: </td>\n                    <td class=\"left\"><a href=\"showlasterror.php3?pid={$pid}&eid={$eid}\">{$err_cause}</a></td>\n                  </tr>\n";
         }
         if ($paniced) {
             echo "<tr>\n                    <td>Paniced on: </td>\n                    <td class=left>{$panic_date}</td>\n                  </tr>\n";
         }
         if ($linktest_pid) {
             $linktest_running = "<b>(Linktest Running)</b>";
         } else {
             $linktest_running = "";
         }
         echo "<tr>\n                <td><a href='{$WIKIDOCURL}/linktest'>" . "Linktest Level</a>: </td>\n                <td class=\"left\">{$linktest_level} {$linktest_running}</td>\n              </tr>\n";
     }
     if (count($nodecounts)) {
         echo "<tr>\n                 <td>Reserved Nodes: </td>\n                 <td class=\"left\">\n";
         while (list($class, $count) = each($nodecounts)) {
             echo "{$count} ({$class}) &nbsp; ";
         }
         echo "   </td>\n              </tr>\n";
     } elseif (!$short) {
         if ($minnodes != "") {
             echo "<tr>\n                      <td>Min/Max Nodes: </td>\n                      <td class=\"left\"><font color=green>\n                          {$minnodes}/{$maxnodes} (estimates)</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Minumum Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
         if ($virtnodes) {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font>\n                          {$virtnodes}</font></td>\n                  </tr>\n";
         } else {
             echo "<tr>\n                      <td>Virtual Nodes: </td>\n                      <td class=\"left\"><font color=green>Unknown</font></td>\n                  </tr>\n";
         }
     }
     if (!$short) {
         if ($mem_usage || $cpu_usage) {
             echo "<tr>\n                      <td>Mem Usage Est: </td>\n                      <td class=\"left\">{$mem_usage}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>CPU Usage Est: </td>\n                      <td class=\"left\">{$cpu_usage}</td>\n                  </tr>\n";
         }
         $lastact = $this->LastAct();
         $idletime = $this->IdleTime();
         $stale = $this->IdleStale();
         if ($lastact != -1) {
             echo "<tr>\n                      <td>Last Activity: </td>\n                      <td class=\"left\">{$lastact}</td>\n                  </tr>\n";
             if ($stale) {
                 $str = "(stale)";
             } else {
                 $str = "";
             }
             echo "<tr>\n                      <td>Idle Time: </td>\n                      <td class=\"left\">{$idletime} hours {$str}</td>\n                  </tr>\n";
         }
         if (!($swapreqs == "" || $swapreqs == 0)) {
             echo "<tr>\n                      <td>Swap Requests: </td>\n                      <td class=\"left\">{$swapreqs}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Last Swap Req.: </td>\n                      <td class=\"left\">{$lastswapreq}</td>\n                  </tr>\n";
         }
         $lockflip = $lockdown ? 0 : 1;
         $lockval = $lockdown ? "Yes" : "No";
         echo "<tr>\n                   <td>Locked Down:</td>\n                   <td>{$lockval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=lockdown&value={$lockflip}>Toggle</a>)\n                   </td>\n              </tr>\n";
         if (ISADMIN() || STUDLY() || OPSGUY()) {
             $thisflip = $skipvlans ? 0 : 1;
             $flipval = $skipvlans ? "Yes" : "No";
             echo "<tr>\n                       <td>Skip Vlans:</td>\n                       <td>{$flipval} (<a href=toggle.php?pid={$pid}&eid={$eid}" . "&type=skipvlans&value={$thisflip}>Toggle</a>)\n                       </td>\n                      </tr>\n";
         }
     }
     if ($batchmode) {
         echo "<tr>\n                    <td>Batch Mode: </td>\n                    <td class=\"left\">Yes</td>\n                  </tr>\n";
         echo "<tr>\n                    <td>Start Attempts: </td>\n                    <td class=\"left\">{$attempts}</td>\n                  </tr>\n";
     }
     if ($canceled) {
         echo "<tr>\n                 <td>Cancel Flag: </td>\n                 <td class=\"left\">{$canceled}</td>\n              </tr>\n";
     }
     if (!$short) {
         if (ISADMIN()) {
             echo "<tr>\n                        <td>UUID: </td>\n                        <td class=left>{$uuid}</td>\n                      </tr>\n";
         }
         if ($usemodelnet) {
             echo "<tr>\n                      <td>Use Modelnet: </td>\n                      <td class=\"left\">Yes</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Core Nodes: </td>\n                      <td class=\"left\">{$mnet_cores}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>Modelnet Phys Edge Nodes: </td>\n                      <td class=\"left\">{$mnet_edges}</td>\n                  </tr>\n";
         }
         if (isset($syncserver)) {
             echo "<tr>\n                      <td>Sync Server: </td>\n                      <td class=\"left\">{$syncserver}</td>\n                  </tr>\n";
         }
         if ($dpdb && $dpdbname && $dpdbpassword) {
             echo "<tr>\n                      <td>DataBase Name: </td>\n                      <td class=\"left\">{$dpdbname}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase User: </td>\n                      <td class=\"left\">E{$exptidx}</td>\n                  </tr>\n";
             echo "<tr>\n                      <td>DataBase Password: </td>\n                      <td class=\"left\">{$dpdbpassword}</td>\n                  </tr>\n";
         }
         echo "<tr>\n                  <td>Index: </td>\n                  <td class=\"left\">{$exptidx}";
         if ($archive_idx) {
             echo " ({$archive_idx}) ";
         }
         echo " </td>\n              </tr>\n";
     }
     if (!$short) {
         if ($this->geniflags()) {
             $slice = GeniSlice::Lookup("geni-cm", $uuid);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">\n                                     <a href='{$url}'>{$slice_urn}</a></td>\n                              </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (CM): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
             }
         } else {
             $slice = GeniSlice::LookupByExperiment("geni-sa", $this);
             if ($slice) {
                 $slice_hrn = $slice->hrn();
                 $slice_urn = $slice->urn();
                 if (ISADMIN()) {
                     $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "sa");
                     echo "<tr>\n                                 <td>Geni Slice (SA): </td>\n                                 <td class=\"left\">\n                                      <a href='{$url}'>{$slice_urn}</a></td>\n                             </tr>\n";
                 } else {
                     echo "<tr>\n                                <td>Geni Slice (SA): </td>\n                                <td class=\"left\">{$slice_urn}</td>\n                              </tr>\n";
                 }
                 $slice = GeniSlice::Lookup("geni-cm", $slice_hrn);
                 if ($slice) {
                     if (ISADMIN()) {
                         $url = CreateURL("showslice", "slice_idx", $slice->idx(), "showtype", "cm");
                         echo "<tr>\n                                     <td>Geni Slice (CM): </td>\n                                     <td class=\"left\">\n                                           <a href='{$url}'>{$slice_urn}</a></td>\n                                  </tr>\n";
                     } else {
                         echo "<tr>\n                                    <td>Geni Slice (SA): </td>\n                                    <td class=\"left\">{$slice_urn}</td>\n                                  </tr>\n";
                     }
                 }
             }
         }
     }
     echo "</table>\n";
 }
Example #7
Show file File: osinfo_defs.php Project: mahyuddin/emulab-stable
0
 function Show()
 {
     $osid = $this->osid();
     $os_description = $this->description();
     $os_OS = $this->OS();
     $os_version = $this->version();
     $os_path = $this->path();
     $os_magic = $this->magic();
     $os_osfeatures = $this->osfeatures();
     $os_op_mode = $this->op_mode();
     $os_pid = $this->pid();
     $os_shared = $this->shared();
     $os_osname = $this->osname();
     $creator = $this->creator();
     $created = $this->created();
     $mustclean = $this->mustclean();
     $nextosid = $this->nextosid();
     $def_parentosid = $this->def_parentosid();
     $max_concurrent = $this->max_concurrent();
     $reboot_waittime = $this->reboot_waittime();
     $uuid = $this->uuid();
     $ezid = $this->ezid();
     $mfs = $this->mfs();
     if (!($creator_user = User::Lookup($creator))) {
         TBERROR("Error getting object for user {$creator}", 1);
     }
     $showuser_url = CreateURL("showuser", $creator_user);
     if (!$os_description) {
         $os_description = "&nbsp;";
     }
     if (!$os_version) {
         $os_version = "&nbsp;";
     }
     if (!$os_path) {
         $os_path = "&nbsp;";
     }
     if (!$os_magic) {
         $os_magic = "&nbsp;";
     }
     if (!$os_osfeatures) {
         $os_osfeatures = "&nbsp;";
     }
     if (!$os_op_mode) {
         $os_op_mode = "&nbsp;";
     }
     if (!$created) {
         $created = "N/A";
     }
     if (!$reboot_waittime) {
         $reboot_waittime = "&nbsp;";
     }
     #
     # Generate the table.
     #
     echo "<table align=center border=1>\n";
     echo "<tr>\n                <td>Name: </td>\n                <td class=\"left\">{$os_osname}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Project: </td>\n                <td class=\"left\">\n                  <a href='showproject.php3?pid={$os_pid}'>{$os_pid}</a></td>\n              </tr>\n";
     echo "<tr>\n                <td>Creator: </td>\n                <td class=left>\n                  <a href='{$showuser_url}'>{$creator}</a></td>\n \t      </tr>\n";
     echo "<tr>\n                <td>Created: </td>\n                <td class=left>{$created}</td>\n    \t      </tr>\n";
     echo "<tr>\n                <td>Description: </td>\n                <td class=\"left\">{$os_description}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Operating System: </td>\n                <td class=\"left\">{$os_OS}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Version: </td>\n                <td class=\"left\">{$os_version}</td>\n             </tr>\n";
     echo "<tr>\n                <td>Path: </td>\n                <td class=\"left\">{$os_path}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Magic (uname -r -s): </td>\n                <td class=\"left\">{$os_magic}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Features: </td>\n                <td class=\"left\">{$os_osfeatures}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Operational Mode: </td>\n                <td class=\"left\">{$os_op_mode}</td>\n              </tr>\n";
     if (isset($max_concurrent) and $max_concurrent > 0) {
         echo "<tr>\n                    <td>Max Concurrent Usage: </td>\n                    <td class=\"left\">{$max_concurrent}</td>\n                  </tr>\n";
     }
     echo "<tr>\n                <td>Reboot Waittime: </td>\n                <td class=\"left\">{$reboot_waittime}</td>\n              </tr>\n";
     echo "<tr>\n                <td>Shared?: </td>\n                <td class=left>" . YesNo($os_shared) . "</td>\n              </tr>\n";
     echo "<tr>\n                <td>Must Clean?: </td>\n                <td class=left>" . YesNo($mustclean) . "</td>\n              </tr>\n";
     if ($nextosid) {
         if ($nextosid == 0) {
             echo "<tr>\n\t\t        <td>Next Osid: </td>\n\t\t        <td class=left>\n\t\t\t    Mapped via DB table: osid_map</td></tr>\n";
         } else {
             $nextosinfo = OSinfo::Lookup($nextosid);
             $nextosname = $nextosinfo->osname();
             echo "<tr>\n                        <td>Next Osid: </td>\n                        <td class=left>\n                            <a href='showosinfo.php3?osid={$nextosid}'>\n                                            {$nextosname}</a></td>\n                      </tr>\n";
         }
     }
     if ($def_parentosid) {
         $nextosinfo = OSinfo::Lookup($def_parentosid);
         $nextosname = $nextosinfo->osname();
         echo "<tr>\n                      <td>Parent Osid: </td>\n                      <td class=left>\n                          <a href='showosinfo.php3?osid={$def_parentosid}'>\n                                           {$nextosname}</a></td>\n                  </tr>\n";
     }
     if ($ezid) {
         echo "<tr>\n                        <td>Image Link: </td>\n                        <td class=left>\n                            <a href='showimageid.php3?imageid={$osid}'>\n                                            {$os_osname}</a></td>\n                      </tr>\n";
     }
     if ($mfs) {
         echo "<tr>\n                        <td>MFS: </td>\n                        <td class=left>Yes</td>\n                      </tr>\n";
     }
     echo "<tr>\n                <td>Internal ID: </td>\n                <td class=\"left\">{$osid}</td>\n              </tr>\n";
     echo "<tr>\n                <td>UUID: </td>\n                <td class=left>{$uuid}</td>\n              </tr>\n";
     if ($def_parentosid) {
         $parent_result = DBQueryFatal("select m.parent_osid,o.osname,o.pid " . "   from os_submap as m " . "left join os_info as o on o.osid=m.parent_osid " . "where m.osid='{$osid}'");
         if (mysql_num_rows($parent_result)) {
             while ($prow = mysql_fetch_array($parent_result)) {
                 $posid = $prow["parent_osid"];
                 $posname = $prow["osname"];
                 echo "<tr>";
                 echo "  <td>Parent {$posid}:</td>";
                 echo "  <td class=left>";
                 echo "   <a href='showosinfo.php3?osid={$posid}'>";
                 echo "{$posname}</a></td>\n";
                 echo "</tr>\n";
             }
         }
     }
     echo "</table>\n";
 }
Example #8
Show file File: group_defs.php Project: mahyuddin/emulab-stable
0
 function ShowMembers($prived = 0)
 {
     $gid_idx = $this->gid_idx();
     $pid_idx = $this->pid_idx();
     $project = $this->Project();
     $query_result = DBQueryFatal("select uid_idx,trust from group_membership " . "where pid_idx='{$pid_idx}' and gid_idx='{$gid_idx}'");
     if (!mysql_num_rows($query_result)) {
         return;
     }
     $showdel = $prived && $pid_idx == $gid_idx ? 1 : 0;
     $projgrp = $this->IsProjectGroup();
     echo "<center>\n";
     if ($projgrp) {
         echo "<h3>Project Members</h3>\n";
     } else {
         echo "<h3>Group Members</h3>\n";
     }
     echo "</center>\n              <table align=center border=1 cellpadding=1\n                     id='userlist' cellspacing=2>\n";
     echo "<thead class='sort'>";
     echo "<tr>\n                  <th>Name</th>\n";
     echo "<th>Affiliation</th>\n";
     if (!$projgrp) {
         echo "<th>Email</th>\n";
     }
     echo "    <th>UID</th>\n                  <th>Privs</th>\n";
     if ($showdel) {
         echo "<th>Remove</th>\n";
     }
     echo "</tr></thead>\n";
     while ($row = mysql_fetch_array($query_result)) {
         $uid_idx = $row["uid_idx"];
         $trust = $row["trust"];
         if (!($target_user = User::Lookup($uid_idx))) {
             TBERROR("Could not lookup object for user {$uid_idx}", 1);
         }
         $usr_name = $target_user->name();
         $usr_affil = $target_user->affil_abbrev();
         $usr_email = $target_user->email();
         $usr_uid = $target_user->uid();
         $showuser_url = CreateURL("showuser", $target_user);
         $deluser_url = CreateURL("deleteuser", $target_user, $project);
         echo "<tr>\n                      <td>{$usr_name}</td>\n";
         echo "<td>{$usr_affil}</td>\n";
         if (!$projgrp) {
             echo "<td>{$usr_email}</td>\n";
         }
         echo "    <td>\n                        <a href='{$showuser_url}'>{$usr_uid}</a>\n                      </td>\n";
         if ($trust == TBDB_TRUSTSTRING_NONE) {
             echo "<td><font color=red>{$trust}</font></td>\n";
         } else {
             echo "<td>{$trust}</td>\n";
         }
         if ($showdel) {
             echo "<td align=center>\n\t\t          <a href='{$deluser_url}'>\n                             <img alt='Delete User' src=redball.gif></td>\n";
         }
         echo "</tr>\n";
     }
     echo "</table>\n";
     echo "<script type='text/javascript' language='javascript'>\n\t       sorttable.makeSortable(getObjbyName('userlist'));\n             </script>\n";
 }
Example #9
Show file File: toggle.php Project: mahyuddin/emulab-stable
0
} elseif ($type == "stud") {
    # must be admin
    if (!$isadmin) {
        USERERROR("You do not have permission to toggle {$type}!", 1);
    }
    if (!($target_user = User::Lookup($user))) {
        PAGEARGERROR("Target user '{$user}' is not a valid user!");
    }
    $zapurl = CreateURL("showuser", $target_user);
    $target_user->SetStudly($value);
} elseif ($type == "widearearoot") {
    # must be admin
    if (!$isadmin) {
        USERERROR("You do not have permission to toggle {$type}!", 1);
    }
    if (!($target_user = User::Lookup($user))) {
        PAGEARGERROR("Target user '{$user}' is not a valid user!");
    }
    $zapurl = CreateURL("showuser", $target_user);
    $target_user->SetWideAreaRoot($value);
} elseif ($type == "lockdown") {
    # must be admin
    if (!$isadmin) {
        USERERROR("You do not have permission to toggle {$type}!", 1);
    }
    if (!($experiment = Experiment::LookupByPidEid($pid, $eid))) {
        PAGEARGERROR("Experiment {$pid}/{$eid} is not a valid experiment!");
    }
    $zapurl = CreateURL("showexp", $experiment);
    $experiment->SetLockDown($value);
} elseif ($type == "skipvlans") {
Example #10
Show file File: template_defs.php Project: mahyuddin/emulab-stable
0
 function Show($detailed, $withanno = 0, $showhidden = 0)
 {
     $exptidx = $this->exptidx();
     $runidx = $this->runidx();
     $guid = $this->guid();
     $vers = $this->vers();
     $pid = $this->pid();
     $uid = $this->uid();
     $start = $this->start_time();
     $stop = $this->stop_time();
     $description = $this->description();
     $template = $this->template();
     $pcount = $template->ParameterCount();
     # Instance descriptions are metatdata that can be changed.
     # But use a naming convention.
     $desc_metaname = "__instance_description_{$exptidx}";
     $desc_metadata = $template->LookupMetadataByName($desc_metaname);
     if (!($user = User::Lookup($uid))) {
         TBERROR("Could not lookup object for user {$uid}", 1);
     }
     $showuser_url = CreateURL("showuser", $user);
     # If the instance is swapped in, we can provide a link to
     # experiment.
     if ($this->experiment) {
         $showexp_url = CreateURL("showexp", $this->experiment);
     }
     # If there are hidden runs, then add an option to show them
     $query_result = DBQueryFatal("select count(*) from experiment_runs " . "where exptidx='{$exptidx}' and hidden!=0");
     $row = mysql_fetch_array($query_result);
     $numhidden = $row[0];
     if ($detailed) {
         SUBPAGESTART();
         SUBMENUSTART("Instance Options");
         WRITESUBMENUBUTTON("Export Instance", CreateURL("template_export", $this));
         WRITESUBMENUBUTTON("Load Database", CreateURL("template_analyze", $this));
         WRITESUBMENUBUTTON("View Archive", CreateURL("archive_view", $this));
         WRITESUBMENUBUTTON("Replay", CreateURL("swapin", $template, "replay_instance_idx", $exptidx));
         if ($numhidden) {
             $tag = $showhidden ? "Hide" : "Show";
             $val = $showhidden ? 0 : 1;
             WRITESUBMENUBUTTON("{$tag} Hidden Runs", CreateURL("instance_show", $this, "showhidden", $val));
         }
         SUBMENUEND();
     }
     echo "<center>\n";
     if ($detailed && $pcount) {
         echo "<table border=0 bgcolor=#000 color=#000 class=stealth " . " cellpadding=0 cellspacing=0 align=center>\n";
         echo "<tr valign=top>";
         echo "<td class=stealth align=center>\n";
     }
     echo "<center>\n               <h3>Instance Details</h3>\n             </center>\n";
     echo "<table align=center cellpadding=2 cellspacing=2 border=1>\n";
     ShowItem("Template", MakeLink("template", "guid={$guid}&version={$vers}", "{$guid}/{$vers}"));
     ShowItem("ID", $exptidx);
     if ($description && $description != "") {
         $onmouseover = MakeMouseOver($description);
         if (strlen($description) > 40) {
             $description = substr($description, 0, 40) . " <b>... </b>";
         }
     } else {
         $onmouseover = "";
         $description = "Click to Add";
     }
     # If no metadata, assume its for an instance prior to modifiable
     # instance descriptions.
     if ($desc_metadata) {
         $desc_anchor = MakeAnchor(CreateURL("template_metadata", $template, $desc_metadata) . "&action=modify", $description, $onmouseover);
     } else {
         $desc_anchor = MakeAnchor(CreateURL("template_metadata", $template) . "&action=add" . "&metadata_type=instance_description" . "&formfields[name]={$desc_metaname}", $description, $onmouseover);
     }
     ShowItem("Description", $desc_anchor);
     if ($this->experiment) {
         ShowItem("Experiment", MakeAnchor($showexp_url, $this->eid()));
     }
     ShowItem("Project", MakeLink("project", "pid={$pid}", $pid));
     ShowItem("Creator", MakeAnchor($showuser_url, $uid));
     ShowItem("Started", $start);
     ShowItem("Stopped", isset($stop) ? $stop : "&nbsp");
     ShowItem("Current Run", isset($runidx) ? $runidx : "&nbsp");
     echo "</table>\n";
     if ($detailed && $pcount) {
         echo "</td>";
         echo "<td align=center class=stealth> &nbsp &nbsp &nbsp </td>\n";
         echo "<td class=stealth align=center>\n";
         $this->ShowBindings();
         echo "</tr>";
         echo "</table>\n";
     }
     if ($detailed) {
         SUBPAGEEND();
     }
     if ($withanno) {
         $this->ShowAnnotation();
     }
     if ($detailed) {
         $this->ShowRunList(1, $showhidden);
     }
     echo "</center>\n";
 }
Example #11
Show file File: project_defs.php Project: mahyuddin/emulab-stable
0
 function Show()
 {
     global $WIKISUPPORT, $CVSSUPPORT, $TBPROJ_DIR, $TBCVSREPO_DIR;
     global $MAILMANSUPPORT, $OPSCVSURL, $USERNODE;
     $group = $this->DefaultGroup();
     $pid = $this->pid();
     $proj_idx = $this->pid_idx();
     $proj_created = $this->created();
     $proj_name = $this->name();
     $proj_URL = $this->URL();
     $proj_public = YesNo($this->ispublic());
     $proj_funders = $this->funders();
     $proj_head_idx = $this->head_idx();
     $proj_members = $this->num_members();
     $proj_pcs = $this->num_pcs();
     # These are now booleans, not actual counts.
     $proj_linked = YesNo($this->linked_to_us());
     $proj_why = nl2br($this->why());
     $approved = YesNo($this->approved());
     $expt_count = $this->expt_count();
     $expt_last = $this->expt_last();
     $wikiname = $group->wikiname();
     $cvsrepo_public = $this->cvsrepo_public();
     $allow_workbench = $this->allow_workbench();
     # Before project approval, display ron/plab request status.
     if ($this->approved()) {
         $proj_ronpcs = YesNo(strpos($this->pcremote_ok(), "pcron") !== false);
         $proj_plabpcs = YesNo(strpos($this->pcremote_ok(), "pcplabphys") !== false);
     } else {
         $proj_ronpcs = YesNo($this->num_ron());
         $proj_plabpcs = YesNo($this->num_pcplab());
     }
     if (!($head_user = User::Lookup($proj_head_idx))) {
         TBERROR("Could not lookup object for user {$proj_head_idx}", 1);
     }
     $showuser_url = CreateURL("showuser", $head_user);
     $showproj_url = CreateURL("showproject", $this);
     $proj_head_uid = $head_user->uid();
     if (!$expt_last) {
         $expt_last = "&nbsp;";
     }
     echo "<center>\n              <h3>Project Profile</h3>\n              </center>\n              <table align=center cellpadding=2 border=1>\n";
     #
     # Generate the table.
     #
     echo "<tr>\n                  <td>Name: </td>\n                  <td class=\"left\">\n                      <a href='{$showproj_url}'>{$pid} ({$proj_idx})</a></td>\n              </tr>\n";
     echo "<tr>\n                  <td>Description: </td>\n                  <td class=\"left\">{$proj_name}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Project Head: </td>\n                  <td class=\"left\">\n                      <a href='{$showuser_url}'>{$proj_head_uid}</a></td>\n              </tr>\n";
     echo "<tr>\n              <td>URL: </td>\n                  <td class=\"left\">\n                      <a href='{$proj_URL}'>{$proj_URL}</a></td>\n              </tr>\n";
     if ($WIKISUPPORT && isset($wikiname)) {
         $wikiurl = "gotowiki.php3?redurl={$wikiname}/WebHome";
         echo "<tr>\n                      <td>Project Wiki:</td>\n                      <td class=\"left\">\n                          <a href='{$wikiurl}'>{$wikiname}</a></td>\n                  </tr>\n";
     }
     if ($CVSSUPPORT) {
         $cvsdir = "{$TBCVSREPO_DIR}/{$pid}";
         $cvsurl = "cvsweb/cvswebwrap.php3?pid={$pid}";
         echo "<tr>\n                      <td>Project CVS Repository:</td>\n                      <td class=\"left\">\n                          {$cvsdir} <a href='{$cvsurl}'>(CVSweb)</a></td>\n                  </tr>\n";
         $YesNo = YesNo($cvsrepo_public);
         $flip = $cvsrepo_public ? 0 : 1;
         echo "<tr>\n                      <td>CVS Repository Publically Readable?:</td>\n                      <td><a href=toggle.php?pid={$pid}&type=cvsrepo_public" . "&value={$flip}>{$YesNo}</a> (Click to toggle)</td>\n                  </tr>\n";
         if ($cvsrepo_public) {
             $puburl = "{$OPSCVSURL}/?cvsroot={$pid}";
             $pserver = ":pserver:anoncvs@{$USERNODE}:/cvsrepos/{$pid}";
             echo "<tr>\n                          <td>Public CVSWeb Address:</td>\n                          <td><a href={$puburl}>" . htmlspecialchars($puburl) . "</a></td>\n                      </tr>\n";
             echo "<tr>\n                          <td>CVS pserver Address:</td>\n                          <td>" . htmlspecialchars($pserver) . "</td>\n                      </tr>\n";
         }
     }
     if ($MAILMANSUPPORT) {
         $mmurl = "gotommlist.php3?pid={$pid}";
         echo "<tr>\n                      <td>Project Mailing List:</td>\n                      <td class=\"left\">\n                          <a href='{$mmurl}'>{$pid}-users</a> ";
         if (ISADMIN()) {
             $mmurl .= "&wantadmin=1";
             echo "<a href='{$mmurl}'>(admin access)</a>";
         }
         echo "    </td>\n                  </tr>\n";
         if (ISADMIN()) {
             $mmurl = "gotommlist.php3?listname={$pid}-admin&asadmin=1";
             echo "<tr>\n                         <td>Project Admin Mailing List:</td>\n                         <td class=\"left\">\n                             <a href='{$mmurl}'>{$pid}-admin</a> ";
             $mmurl = "gotommlist.php3?listname={$pid}-admin&wantadmin=1";
             echo "<a href='{$mmurl}'>(admin access)</a>";
             echo "    </td>\n                     </tr>\n";
         }
     }
     echo "<tr>\n                  <td>Publicly Visible: </td>\n                  <td class=\"left\">{$proj_public}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Link to Us?: </td>\n                  <td class=\"left\">{$proj_linked}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Funders: </td>\n                  <td class=\"left\">{$proj_funders}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>#Project Members: </td>\n                  <td class=\"left\">{$proj_members}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>#PCs: </td>\n                  <td class=\"left\">{$proj_pcs}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Planetlab Access: </td>\n                  <td class=\"left\">{$proj_plabpcs}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>RON Access: </td>\n                  <td class=\"left\">{$proj_ronpcs}</td>\n              </tr>\n";
     # Fine-grained Datapository access: show node_ids over all sub-groups.
     # Should probably do likewise in individual sub-group pages.
     # "dp_projects" node_attributes are lists of group gid_idxs.
     $query_result = DBQueryFatal("select distinct g.gid_idx, a.node_id " . "  from groups as g, node_attributes as a " . "where g.pid_idx='{$proj_idx}' " . "  and a.attrkey='dp_projects' " . "  and FIND_IN_SET(g.gid_idx, a.attrvalue) " . "order by g.gid_idx, a.node_id");
     $proj_dp_nodes = "";
     while ($row = mysql_fetch_array($query_result)) {
         $node_id = $row["node_id"];
         if ($proj_dp_nodes) {
             $proj_dp_nodes .= ", ";
         }
         $proj_dp_nodes .= $node_id;
     }
     if ($proj_dp_nodes) {
         echo "<tr>\n\t\t      <td>Datapository Access: </td>\n\t\t      <td class=\"left\">{$proj_dp_nodes}</td>\n\t\t  </tr>\n";
     }
     echo "<tr>\n                  <td>Created: </td>\n                  <td class=\"left\">{$proj_created}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Experiments Created:</td>\n                  <td class=\"left\">{$expt_count}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Date of last experiment:</td>\n                  <td class=\"left\">{$expt_last}</td>\n              </tr>\n";
     echo "<tr>\n                  <td>Approved?: </td>\n                  <td class=\"left\">{$approved}</td>\n\t      </tr>\n";
     if (ISADMIN()) {
         $YesNo = YesNo($allow_workbench);
         $flip = $allow_workbench ? 0 : 1;
         echo "<tr>\n                      <td>Allow Workbench:</td>\n                      <td><a href=toggle.php?pid={$pid}&type=workbench" . "&value={$flip}>{$YesNo}</a> (Click to toggle)</td>\n                  </tr>\n";
     }
     echo "<tr>\n                  <td colspan='2'>Why?:</td>\n              </tr>\n";
     echo "<tr>\n                  <td colspan='2' width=600>{$proj_why}</td>\n              </tr>\n";
     echo "</table>\n";
 }