function getProject($pID) { $this->getAllByPK($pID); $row = $this->getNext(); $p = new project(); $p->getAllByPK($row['package']); return $p->getNext(); }
$b = new bug(); $b->getAll(); $u = new user(); $p = new project(); $TITLE = "Latest {$Count} bugs"; $i = 0; $CONTENT .= "<h1>Last {$Count} bugs filed</h1>"; $CONTENT .= "\n<table class = 'sortable' >\n\t<tr class = 'nobg' >\n\t\t<th>ID</th> <th> Status </th> <th> Severity </th> <th>Owner</th> <th>Project</th> <th>Private</th> <th>Title</th>\n\t</tr>\n"; while ($row = $b->getNext()) { $u->getAllByPK($row['owner']); $owner = $u->getNext(); if ($owner['uID'] <= 0) { $owner['real_name'] = "Nobody"; } $p->getAllByPK($row['package']); $package = $p->getNext(); if (isset($_SESSION['id'])) { $id = $_SESSION['id']; } else { $id = -1; // NOT -10000!!!!!! } $privacy = checkBugViewAuth($row['bID'], $id); if ($privacy[1]) { $picon = "<img src = '" . $SITE_PREFIX . "imgs/locked.png' alt = 'Private' />"; } else { $picon = "<img src = '" . $SITE_PREFIX . "imgs/unlocked.png' alt = 'Public' />"; } if (!$privacy[0]) { if ($i < $Count) { $CONTENT .= "\t<tr>\n<td>" . $row['bID'] . "<td>Unknown</td><td>Unknown</td></td><td>Unknown</td><td>Private</td><td>" . $picon . "</td><td>Private</td>\n\t</tr>\n";
<?php $p = new project(); $b = new bug(); $p->getByCol("project_name", $argv[1]); // this is goddamn awesome $row = $p->getNext(); $b->getByCol("package", $row['pID']); // this is goddamn awesome $booboos = $b->numrows(); $critical = 0; // doh // $b->specialSelect( "bug_status != 1" ); if (isset($row['pID'])) { $TITLE = $row['project_name'] . ", one of the fantastic projects on Whube"; $CONTENT = "\n<h1>" . $row['project_name'] . "</h1>\n" . $row['descr'] . "<br />\n<br />\nThere are " . $booboos . " bugs in the tracker on this package. " . $critical . " are critical.\n"; } else { $_SESSION['err'] = "Project " . $argv[1] . " does not exist!"; header("Location: {$SITE_PREFIX}" . "t/home"); exit(0); }
include "conf/site.php"; include "libs/php/globals.php"; requireLogin(); if (isset($_POST['project']) && isset($_POST['title']) && isset($_POST['descr'])) { include "model/user.php"; include "model/project.php"; include "model/bug.php"; $b = new bug(); $u = new user(); $p = new project(); // let's first verify the project. $pname = htmlentities($_POST['project'], ENT_QUOTES); $title = htmlentities($_POST['title'], ENT_QUOTES); $descr = htmlentities($_POST['descr'], ENT_QUOTES); $p->getByCol("project_name", $pname); $project = $p->getNext(); if ($project != NULL && $project['pID'] > 0) { $fields = array("package" => $project['pID'], "reporter" => $_SESSION['id'], "title" => $title, "descr" => $descr); $id = $b->createNew($fields); $_SESSION['msg'] = "New bug created!"; header("Location: {$SITE_PREFIX}" . "t/bug/{$id}"); exit(0); } else { $_SESSION['err'] = "Please enter a real project!"; header("Location: {$SITE_PREFIX}" . "t/new-bug"); exit(0); } } else { $_SESSION['err'] = "Please fill in all the forms!"; header("Location: {$SITE_PREFIX}" . "t/new-bug"); exit(0);
function checkBugViewAuth($bugID, $requester) { $b = new bug(); $u = new user(); $p = new project(); $b->getAllByPK($bugID); $bug = $b->getNext(); if (isset($bug['bID'])) { if (isset($_SESSION['patrick_stewart']) && $_SESSION['patrick_stewart']) { // see gate for context return array(true, $bug['private']); // public bug, dummy } $whoami = $requester; if ($bug['private']) { // good query. $u->getAllByPK($bug['owner']); $owner = $u->getNext(); $u->getAllByPK($bug['reporter']); $reporter = $u->getNext(); $p->getAllByPK($bug['package']); $project = $p->getNext(); $oid = -10000; $rid = -10000; $pid = -10000; if (isset($owner['uID'])) { $oid = $owner['uID']; } if (isset($reporter['uID'])) { $rid = $reporter['uID']; } if (isset($project['oID'])) { $pid = $project['oID']; } if ($oid != $whoami && $rid != $whoami && $pid != $whoami) { return array(false, $bug['private']); } else { return array(true, $bug['private']); } } else { return array(true, $bug['private']); // public bug, dummy } } else { return array(false, false); // bug iz no good } /* if bug.private: check if is owner check if is reporter check if is asignee check if is project owner check if site administrator / staff any of the above: Yes, otherwise, no else: Yes Query bug, if it's public, don't give a shit. */ }
$owner = clean($_POST['owner']); /* New owner of the bug ( perhaps ) */ $descr = clean($_POST['descr']); /* New descr of the bug ( perhaps ) */ $priv = false; if (isset($_POST['private'])) { $priv = true; } else { $priv = false; } $o = new user(); $p = new project(); $o->getByCol("username", $owner); $p->getByCol("project_name", $project); $own = $o->getNext(); $pkg = $p->getNext(); $projectID = $pkg['pID']; $ownerID = $own['uID']; $posted_data = array("bug_severity" => $sever, "bug_status" => $status, "package" => $projectID, "owner" => $ownerID, "title" => $title, "private" => $priv, "descr" => $descr); // print_r( $posted_data ); $b->getAllByPK($bugid); $row = $b->getNext(); // print_r( $row ); // searched bug /* --> $row should look like: ** NOTE: IGNORE THE [n] ETC! THEY ARE STUPID IF YOU DON'T QUERY FUR THEM ** Array ( [bID] => 1 <-- PK, bug ID [bug_status] => 1 <-- FK, status table by ID [bug_severity] => 1 <-- FK, severity table by ID [package] => 1 <-- FK, project table by pID
<?php $p = new project(); $b = new bug(); $u = new user(); $u->getByCol("username", $argv[1]); $user = $u->getNext(); $RIGHTS_OBJECT->getAllByPK($user['uID']); $user_rights = $RIGHTS_OBJECT->getNext(); $p->getAll("owner", $user['uID']); // this is goddamn awesome $projects = $p->numrows(); $b->getByCol("package", $user["uID"]); // this is goddamn awesome $booboos = $b->numrows(); $critical = 0; // doh // $b->specialSelect( "bug_status != 1" ); if (isset($user["username"])) { $projectList = ""; $i = 0; while ($row = $p->getNext()) { $projectList .= "<li><a href='../project/" . $row['project_name'] . "'>" . $row['project_name'] . "</a></li>"; $i++; } $TITLE = $user["username"] . ", one of the fantastic users on Whube"; $CONTENT = "\n<h1>" . $user["username"] . "</h1>\nThis here be " . $user['real_name'] . ".<br />\nThere are " . $booboos . " bugs filed by " . $user['username'] . ". " . $critical . " are critical.<br />\n<br />\n" . $user_rights['admin'] . " - Admin<br />\n" . $user_rights['staff'] . " - Staff<br />\n" . $user_rights['doner'] . " - Doner<br />\n" . $user_rights['member'] . " - Member<br />\n" . $user_rights['banned'] . " - Banned<br />\n<br />\n\n" . ucwords($user['username']) . " is owner of " . $projects . " projects. These projects are: \n<ul>" . $projectList . "</ul>\n"; } else { $_SESSION['err'] = "User " . $argv[1] . " does not exist!"; header("Location: {$SITE_PREFIX}" . "t/home"); exit(0); }