function cleanOldRequests() { $old = gmdate('Y-m-d', strtotime('-1 Day')); $query = 'SELECT handle FROM bug_account_request WHERE created_on < ?'; $all = $this->dbh->getAll($query, array($old)); require_once 'bugs/patchtracker.php'; $p = new Bugs_Patchtracker(); // purge reserved usernames as well as their account requests if (is_array($all)) { foreach ($all as $data) { $this->dbh->query(' DELETE FROM users WHERE handle = ? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb WHERE handle = ? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb_comments WHERE handle = ? ', array($data[0])); $sql = 'SELECT * FROM bugdb_patchtracker WHERE developer = ?'; $patches = $this->dbh->getAll($sql, array($data[0]), DB_FETCHMODE_ASSOC); foreach ($patches as $patch) { $p->detach($patch['bugdb_id'], $patch['patch'], $patch['revision']); } } } $query = 'DELETE FROM bug_account_request WHERE created_on < ?'; // purge out-of-date account requests return $this->dbh->query($query, array($old)); }
<?php if (!isset($id)) { header('HTTP/1.0 400 Bad Request'); exit; } $canpatch = true; require_once 'Text/CAPTCHA/Numeral.php'; $numeralCaptcha = new Text_CAPTCHA_Numeral(); $patchinfo = new Bugs_Patchtracker(); // captcha is not necessary if the user is logged in if (isset($auth_user) && $auth_user->registered) { auth_require('pear.dev', 'pear.bug'); if (isset($_SESSION['answer'])) { unset($_SESSION['answer']); } } if (PEAR::isError($buginfo = $patchinfo->getBugInfo($id))) { response_header('Error :: invalid bug selected'); report_error('Invalid bug "' . $id . '" selected'); response_footer(); exit; } $loggedin = isset($auth_user) && $auth_user->registered; if (!isset($_POST['addpatch'])) { /** * Normal patch form with predefined variables */ $email = isset($_GET['email']) ? $_GET['email'] : ''; $errors = array(); $package = $buginfo['package_name'];
/** * Download a patch */ $revision = isset($_GET['revision']) ? $_GET['revision'] : null; $patch = isset($_GET['patch']) ? $_GET['patch'] : null; $id = isset($_GET['id']) ? (int) $_GET['id'] : null; if (!$revision || !$patch || !$id) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: text/plain'); response_header('Error :: File does not exist'); report_error('Please specify id, patch and revision'); response_footer(); exit; } require_once 'bugs/patchtracker.php'; $pt = new Bugs_Patchtracker(); if (!$pt->isPatchValid($id, $patch, $revision)) { header('HTTP/1.0 404 Not Found'); response_header('Error :: Patch not found'); report_error('Patch or revision does not exist'); response_footer(); exit; } $path = $pt->getPatchFullpath($id, $patch, $revision); if (!file_exists($path)) { header('HTTP/1.0 404 Not Found'); response_header('Error :: File does not exist'); report_error('File does not exist on server'); response_footer(); exit; }
/** * Old links to patches may call this script directly * - in this case, redirect to new URL */ $bug_id = isset($_GET['bug']) ? (int) $_GET['bug'] : null; if ($bug_id === null && isset($_GET['bug_id'])) { $bug_id = (int) $_GET['bug_id']; } $spat = $patch == null ? '' : '&patch=' . $patch; $srev = $revision == null ? '' : '&revision=' . $revision; $edit = $spat ? 12 : 11; header('Location: /bugs/bug.php' . "?id={$bug_id}&edit=" . $edit . $spat . $srev); exit; } $bug_id = $id; $patchinfo = new Bugs_Patchtracker(); $buginfo = $patchinfo->getBugInfo($bug_id); if ($patch === null || $revision === null) { /** * display patch list */ $bug = $buginfo['id']; $patches = $patchinfo->listPatches($bug); $canpatch = auth_check('pear.bug') || auth_check('pear.dev'); response_header('Bug #' . clean($bug) . ' :: Patches'); include PEARWEB_TEMPLATEDIR . '/bugs/listpatches.php'; response_footer(); exit; } if ($revision == 'latest') { //fix revision number
<?php /** * Handles patch upload. * When errors occur, $errors is filled. * In case everything is ok, we redirect to uploaded patch detail page */ if (!isset($id)) { header('HTTP/1.0 400 Bad Request'); exit; } $canpatch = true; require_once 'Text/CAPTCHA/Numeral.php'; $numeralCaptcha = new Text_CAPTCHA_Numeral(); $patchinfo = new Bugs_Patchtracker(); // captcha is not necessary if the user is logged in if (isset($auth_user) && $auth_user->registered) { auth_require('pear.dev', 'pear.bug'); if (isset($_SESSION['answer'])) { unset($_SESSION['answer']); } } if (PEAR::isError($buginfo = $patchinfo->getBugInfo($id))) { response_header('Error :: invalid bug selected'); report_error('Invalid bug "' . $id . '" selected'); response_footer(); exit; } $loggedin = isset($auth_user) && $auth_user->registered; if (!isset($_POST['obsoleted'])) { $_POST['obsoleted'] = array();
</td> </tr> <?php } } ?> </table> </div> <div id="controls"> <?php control(0, 'Comments', $id, $edit); // Display patches $patches = new Bugs_Patchtracker(); $patchcount = $patches->getPatchCount($id); if ($patchcount > 0) { control(11, 'Patches (' . $patchcount . ')', $id, $edit); } if ((!(isset($auth_user) && $auth_user && $auth_user->registered) || !auth_check('pear.dev')) && $edit != 2) { control(3, 'Add Comment', $id, $edit); } if (auth_check('pear.bug') || auth_check('pear.dev')) { control(1, 'Edit', $id, $edit); } control(13, 'Add patch', $id, $edit); //show patch details only when active if ($edit == 12) { control(12, 'Patch details', $id, $edit); }