static function activate($uid, $karmalevel = 'pear.dev') { require_once 'Damblan/Karma.php'; global $dbh, $auth_user; $karma = new Damblan_Karma($dbh); $user = user::info($uid, null, 0); if (!isset($user['registered'])) { return false; } @($arr = unserialize($user['userinfo'])); include_once 'pear-database-note.php'; note::removeAll($uid); $data = array(); $data['registered'] = 1; $data['active'] = 1; /* $data['ppp_only'] = 0; */ if (is_array($arr)) { $data['userinfo'] = $arr[1]; } $data['created'] = gmdate('Y-m-d H:i'); $data['createdby'] = $auth_user->handle; $data['handle'] = $user['handle']; user::update($data, true); $karma->grant($user['handle'], $karmalevel); if ($karma->has($user['handle'], 'pear.dev')) { include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh); $pear_rest->saveMaintainerREST($user['handle']); $pear_rest->saveAllMaintainersREST(); } include_once 'pear-database-note.php'; note::add($uid, "Account opened"); $msg = "Your PEAR account request has been opened.\n" . "To log in, go to http://" . PEAR_CHANNELNAME . "/ and click on \"login\" in\n" . "the top-right menu.\n"; $xhdr = 'From: ' . $auth_user->handle . '@php.net'; if (!DEVBOX) { mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, '-f ' . PEAR_BOUNCE_EMAIL); } return true; }
function activate($uid) { global $dbh, $auth_user; $user =& new PEAR_User($dbh, $uid); if (@$user->registered) { return false; } @($arr = unserialize($user->userinfo)); note::removeAll("uid", $uid); $user->set('registered', 1); /* $user->set('ppp_only', 0); */ if (is_array($arr)) { $user->set('userinfo', $arr[1]); } $user->set('created', gmdate('Y-m-d H:i')); $user->set('createdby', $auth_user->handle); $user->set('registered', 1); $user->store(); note::add("uid", $uid, "Account opened"); $GLOBALS['pear_rest']->saveMaintainerREST($user->handle); $GLOBALS['pear_rest']->saveAllmaintainersREST(); $msg = "Your PECL/PEAR account request has been opened.\n" . "To log in, go to http://pecl.php.net/ and click on \"login\" in\n" . "the top-right menu.\n"; $xhdr = "From: " . $auth_user->handle . "@php.net"; mail($user->email, "Your PECL Account Request", $msg, $xhdr, "-f noreply@php.net"); return true; }
exit; } include_once 'pear-database-note.php'; switch ($_GET['action']) { case "remove": $res = $karma->remove($handle, $_GET['level']); if ($res) { echo "Successfully <b>removed</b> karma "" . htmlspecialchars($_GET['level']) . ""<br /><br />"; note::add($handle, 'removed ' . $_GET['level'] . ' karma', $auth_user->handle); } break; case "grant": $res = $karma->grant($handle, $_POST['level']); if ($res) { echo "Successfully <b>added</b> karma "" . htmlspecialchars($_POST['level']) . ""<br /><br />"; note::add($handle, 'added ' . $_POST['level'] . ' karma', $auth_user->handle); } break; } } $user_karma = $karma->get($handle); if (count($user_karma) == 0) { echo 'No karma yet'; } else { $table = new HTML_Table('style="width: 90%"'); $table->setCaption('Karma levels for ' . htmlspecialchars($handle), 'style="background-color: #CCCCCC;"'); $table->addRow(array("Level", "Added by", "Added at", "Remove"), null, 'th'); foreach ($user_karma as $item) { $remove = sprintf("karma.php?action=remove&handle=%s&level=%s", htmlspecialchars($handle), htmlspecialchars($item['level'])); $table->addRow(array(htmlspecialchars($item['level']), htmlspecialchars($item['granted_by']), htmlspecialchars($item['granted_at']), make_link($remove, make_image("delete.gif"), false, 'onclick="javascript:return confirm(\'Do you really want to remove the karma level ' . htmlspecialchars($item['level']) . '?\');"'))); }
function confirmRequest($handle, $password, $name) { $sql = 'SELECT handle FROM users WHERE handle = ?'; if ($handle == $this->dbh->getOne($sql, array($handle))) { $id = $this->dbh->nextId("karma"); $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); return true; } list($firstname, $lastname) = explode(' ', $name, 2); $data = array('handle' => $handle, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $this->email, 'purpose' => 'bug tracker', 'password' => $password, 'password2' => $password, 'purpose' => 'Open/Comment on bugs', 'moreinfo' => 'Automatic Account Request', 'homepage' => ''); include_once 'pear-database-user.php'; $useradd = user::add($data, true, true); if ($useradd !== true) { return $useradd; } $sql = 'SELECT handle from bug_account_request WHERE salt = ?'; $temphandle = $this->dbh->getOne($sql, array($this->salt)); // update all relevant records to the new handle $this->dbh->query('UPDATE bugdb_comments set reporter_name = ? WHERE handle = ?', array($name, $temphandle)); $this->dbh->query('UPDATE bugdb set reporter_name = ? WHERE handle = ?', array($name, $temphandle)); $this->dbh->query('UPDATE users set handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb set registered = 1, handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb_comments set handle = ? WHERE handle = ?', array($handle, $temphandle)); $this->dbh->query('UPDATE bugdb_patchtracker set developer = ? WHERE developer = ?', array($handle, $temphandle)); $this->handle = $handle; // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma include_once 'pear-database-user.php'; $user = user::info($handle, null, 0); if (!isset($user['registered'])) { return false; } @($arr = unserialize($user['userinfo'])); include_once 'pear-database-note.php'; note::removeAll($handle); $data = array(); $data['registered'] = 1; $data['password'] = $password; $data['name'] = $name; if (is_array($arr)) { $data['userinfo'] = $arr[1]; } $data['create'] = gmdate('Y-m-d'); $data['createBy'] = SITE . 'web'; $data['handle'] = $handle; user::update($data, true); $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web')); $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web')); if (!DB::isError($sth)) { require_once 'bugs/pear-bugs-utils.php'; $pbu = new PEAR_Bugs_Utils(); note::add($this->handle, 'Account opened', SITE . 'web'); $bugs = $this->dbh->getAll('SELECT * FROM bugdb WHERE handle = ?', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($bugs as $bug) { $this->sendBugEmail($bug); } $patches = $this->dbh->getAll('SELECT bugdb.package_name, bugdb_patchtracker.* FROM bugdb_patchtracker, bugdb WHERE bugdb_patchtracker.developer = ? AND bugdb.id = bugdb_patchtracker.bugdb_id', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($patches as $patch) { $pbu->sendPatchEmail($patch); } $bugs = $this->dbh->getAll('SELECT bugdb_comments.email,bugdb_comments.comment, bugdb_comments.reporter_name, bugdb.id, bugdb.bug_type,bugdb.package_name,bugdb.sdesc, bugdb.ldesc,bugdb.php_version, bugdb.php_os,bugdb.status, bugdb.assign,bugdb.package_version FROM bugdb_comments, bugdb WHERE bugdb.id = bugdb_comments.bug AND bugdb_comments.handle = ?', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($bugs as $bug) { $this->sendBugCommentEmail($bug); } $msg = "Your PEAR bug tracker account has been opened.\n" . "Bugs you have opened will now be displayed, and you can\n" . "add new comments to existing bugs"; $xhdr = "From: " . PEAR_WEBMASTER_EMAIL; if (!DEVBOX) { mail($user['email'], "Your PEAR Bug Tracker Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL); } $this->deleteRequest(); return true; } return false; }
function confirmRequest($salt) { if (!$this->find($salt)) { return PEAR::raiseError('cannot find request'); } // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma include_once 'pear-database-user.php'; $user = user::info($this->handle, null, 0); if (!isset($user['registered'])) { return PEAR::raiseError('Error - user request was deleted, please try again'); } include_once 'pear-database-note.php'; note::removeAll($this->handle); $data = array(); $data['handle'] = $user['handle']; $data['registered'] = 1; $data['created'] = gmdate('Y-m-d'); $data['createdby'] = SITE . 'web'; $e = user::update($data, true); if (PEAR::isError($e) || !$e) { return $e; } $query = 'INSERT INTO karma VALUES (?, ?, ?, ?, NOW())'; $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.voter', SITE . 'web')); $id = $this->dbh->nextId('karma'); $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', SITE . 'web')); if (!DB::isError($sth)) { note::add($this->handle, 'Account opened', SITE . 'web'); $msg = "Your PEAR voter account has been opened.\n" . "You can now participate in the elections by going to\n" . " http://" . PEAR_CHANNELNAME . "/election/"; $xhdr = "From: " . PEAR_WEBMASTER_EMAIL; if (!DEVBOX) { mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, "-f " . PEAR_BOUNCE_EMAIL); } $this->deleteRequest(); return true; } return false; }
$packages = $dbh->getAssoc($sql, false, null, DB_FETCHMODE_ASSOC); foreach ($packages as $n => $id) { $m = maintainer::get((int) $id); if (!empty($m)) { echo "\nAltering karma for maintainers of {$n} package id {$id}\n"; foreach ($m as $handle => $m_data) { if (!$karma->has($handle, $karma_level)) { echo "Giving {$handle} {$karma_level} karma\n"; // Bypassing damblan karma because it needs a logged in user $id = $dbh->nextId('karma'); if (DB::isError($id)) { echo "Couldn't get a new id from the karma table\n"; exit; } $query = 'INSERT INTO karma (id, user, level, granted_by, granted_at) VALUES (?, ?, ?, ?, NOW())'; $sth = $dbh->query($query, array($id, $handle, $karma_level, 'peclweb')); if (DB::isError($sth)) { echo "Giving karma to {$handle} failed!\n"; exit; } // Adding a note about it note::add($handle, 'karma ' . $karma_level . ' granted', 'peclweb'); } else { echo "{$handle} already has {$karma_level}\n"; } } } else { echo "Couldn't find any maintainers for {$n} id {$id} possibily an error!\n"; } }
$i = $this->indent; echo "{$i} <tr>\n"; echo "{$i} <td style=\"background-color: #E8E8E8;\""; if ($this->cols > 1) { echo " colspan=\"{$this->cols}\""; } echo ">{$text}</td>\n"; echo "{$i} </tr>\n"; } } response_header('PEAR Administration'); // {{{ adding and deleting notes if (!empty($_REQUEST['cmd'])) { if ($_REQUEST['cmd'] == "Add note" && !empty($_REQUEST['note']) && !empty($_REQUEST['id'])) { include_once 'pear-database-note.php'; note::add($_REQUEST['id'], $_REQUEST['note']); unset($_REQUEST['cmd']); } elseif ($_REQUEST['cmd'] == "Delete note" && !empty($_REQUEST['id'])) { include_once 'pear-database-note.php'; // Delete note note::remove($_REQUEST['id']); } elseif ($_REQUEST['cmd'] == "Open Account" && !empty($_REQUEST['uid'])) { /** * Open account */ $karmalevel = empty($_REQUEST['karma']) ? 'pear.pepr' : $_REQUEST['karma']; // another hack to remove the temporary "purpose" field // from the user's "userinfo" include_once 'pear-database-user.php'; if (user::activate($_REQUEST['uid'], $karmalevel)) { $uid = strip_tags(htmlspecialchars($_REQUEST['uid']));