コード例 #1
0
ファイル: submitpub.php プロジェクト: mahyuddin/emulab-stable
    global $form, $fields, $formfields, $formdump, $idx;
    echo "<pre>\n" . htmlspecialchars($formdump) . "\n</pre>\n";
    if (!$deleted) {
        echo '<p>It will appear in the public <a href="expubs.php">Bibliography</a> ';
        echo "under " . htmlspecialchars($formfields['category']) . " like this:</p>";
        echo "<ul>\n<li>\n";
        echo MakeBib(NULL, 0, $formfields);
        echo "</li></ul>\n";
    }
    echo "<a href=\"submitpub.php?idx=" . $idx . "\" style=\"background:yellow\">Edit</a>";
}
if (!isset($idx)) {
    $cols = array('owner', 'submitted_by', 'last_edit_by', 'uuid', 'created', 'last_edit');
    #$owner = $isadmin && !$formfields['ownership'] ? 0 : $uid_idx;
    $owner = $uid_idx;
    $vals = array($owner, $uid_idx, $uid_idx, '"' . mysql_escape_string(NewUUID()) . '"', "now()", "now()");
    foreach ($dbfields as $f) {
        if (isset($formfields[$f])) {
            $dbname = $f;
            $value = $formfields[$f];
            array_push($cols, '`' . $dbname . '`');
            array_push($vals, '"' . mysql_escape_string($value) . '"');
        }
    }
    DBQueryFatal("insert into emulab_pubs (" . implode(",", $cols) . ") values (" . implode(",", $vals) . ")");
    $idx = mysql_insert_id();
    echo "<p>The following  was Submitted: </p>";
    ConfirmationCommon();
    if (!$isadmin) {
        TBMAIL("{$TBMAILADDR_OPS}", "New Publication Submitted", $formdump, "From: " . $this_user->name() . "<" . $this_user->email() . ">");
    }
コード例 #2
0
 function NewGroup($project, $gid, $leader, $description, $unix_name)
 {
     global $TBBASE, $TBMAIL_APPROVAL, $TBMAIL_AUDIT, $TBMAIL_WWW;
     global $MIN_UNIX_GID;
     $starting_gid = $MIN_UNIX_GID;
     $ending_gid = 50000;
     #
     # Check that we can guarantee uniqueness of the unix group name.
     #
     $query_result = DBQueryFatal("select gid from groups " . "where unix_name='{$unix_name}'");
     if (mysql_num_rows($query_result)) {
         TBERROR("Could not form a unique Unix group name: {$unix_name}!", 1);
     }
     # Every group gets a new unique index.
     $gid_idx = TBGetUniqueIndex('next_gid');
     # If project is not defined, then creating initial project group.
     if (!$project) {
         $pid = $gid;
         $pid_idx = $gid_idx;
     } else {
         $pid = $project->pid();
         $pid_idx = $project->pid_idx();
     }
     $uuid = NewUUID();
     # Get me an unused unix id. Nice query, eh? Basically, find
     # unused numbers by looking at existing numbers plus one, and check
     # to see if that number is taken.
     $query_result = DBQueryWarn("select g.unix_gid + 1 as start from groups as g " . "left outer join groups as r on " . "  g.unix_gid + 1 = r.unix_gid " . "where g.unix_gid>={$starting_gid} and " . "      g.unix_gid<{$ending_gid} and " . "      r.unix_gid is null limit 1");
     if (!$query_result || !mysql_num_rows($query_result)) {
         TBERROR("Could not find an unused unix_gid!", 0);
         return null;
     }
     $row = mysql_fetch_row($query_result);
     $unix_gid = $row[0];
     if (!DBQueryWarn("insert into groups set " . " pid='{$pid}', gid='{$gid}', " . " leader='" . $leader->uid() . "'," . " leader_idx='" . $leader->uid_idx() . "'," . " created=now(), " . " description='{$description}', " . " unix_name='{$unix_name}', " . " gid_uuid='{$uuid}', " . " gid_idx={$gid_idx}, " . " pid_idx={$pid_idx}, " . " unix_gid={$unix_gid}")) {
         return null;
     }
     if (!DBQueryWarn("insert into group_stats " . "  (pid,gid,gid_idx,pid_idx,gid_uuid) " . "values ('{$pid}', '{$gid}', {$gid_idx}, " . "        {$pid_idx}, '{$uuid}')")) {
         DBQueryFatal("delete from groups where gid_idx='{$gid_idx}'");
         return null;
     }
     $newgroup = Group::Lookup($gid_idx);
     if (!$newgroup) {
         return null;
     }
     return $newgroup;
 }