cvs: pearweb / generateREST.php package.php package.xml /include pear-auth.php pear-database-category.php pear-database-channel.php
pear-database-maintainer.php pear-database-note.php pear-database-package.php pear-database-release.php pear-database-statistics.php
pear-database-user.php pear-database.php pear-format-html-form.php pear-patches.php pear-prepend.php pear-rest.php xmlrpc-methods.php
xmlrpc-testlogin.php /include/Damblan Bugs.php Trackback.php /include/bugs pear-bug-accountrequest.php /include/election
pear-election-accountrequest.php pear-voter.php /include/package releasehelper.php /include/pepr pepr.php /include/roadmap info.php
package-generator.php /include/users passwordmanage.php /public_html account-edit.php account-info.php account-request-existingpackage.php
account-request-newpackage.php get index.php package-changelog.php package-delete.php package-edit.php package-info.php package-new.php
package-stats.php release-upload.php /publi! c_html/about forgot-password.php /public_html/account password-confirm-change.php /public_html/admin
category-manager.php index.php karma.php package-approval.php package-maintainers.php /public_html/bugs roadmap.php stats.php
/public_html/bugs/include functions.inc /public_html/error 404.php /public_html/feeds feeds.php /public_html/pepr index.php pepr-comments-show.php
pepr-proposal-edit.php pepr-proposal-show.php pepr-votes-show.php /public_html/trackback trackback.php

From: Date: Sun, 22 Apr 2007 01:51:37 +0000
Subject: cvs: pearweb / generateREST.php package.php package.xml /include pear-auth.php pear-database-category.php pear-database-channel.php
pear-database-maintainer.php pear-database-note.php pear-database-package.php pear-database-release.php pear-database-statistics.php
pear-database-user.php pear-database.php pear-format-html-form.php pear-patches.php pear-prepend.php pear-rest.php xmlrpc-methods.php
xmlrpc-testlogin.php /include/Damblan Bugs.php Trackback.php /include/bugs pear-bug-accountrequest.php /include/election
pear-election-accountrequest.php pear-voter.php /include/package releasehelper.php /include/pepr pepr.php /include/roadmap info.php
package-generator.php /include/users passwordmanage.php /public_html account-edit.php account-info.php account-request-existingpackage.php
account-request-newpackage.php get index.php package-changelog.php package-delete.php package-edit.php package-info.php package-new.php
package-stats.php release-upload.php /publi! c_html/about forgot-password.php /public_html/account password-confirm-change.php /public_html/admin
category-manager.php index.php karma.php package-approval.php package-maintainers.php /public_html/bugs roadmap.php stats.php
/public_html/bugs/include functions.inc /public_html/error 404.php /public_html/feeds feeds.php /public_html/pepr index.php pepr-comments-show.php
pepr-proposal-edit.php pepr-proposal-show.php pepr-votes-show.php /public_html/trackback trackback.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-46085@lists.php.net to get a copy of this message
dufuz Sun Apr 22 01:51:37 2007 UTC Added files: /pearweb/include pear-database-category.php pear-database-channel.php pear-database-maintainer.php pear-database-note.php pear-database-package.php pear-database-release.php pear-database-statistics.php pear-database-user.php xmlrpc-testlogin.php Removed files: /pearweb/include pear-database.php Modified files: /pearweb generateREST.php package.php package.xml /pearweb/include pear-auth.php pear-format-html-form.php pear-patches.php pear-prepend.php pear-rest.php xmlrpc-methods.php /pearweb/include/Damblan Bugs.php Trackback.php /pearweb/include/bugs pear-bug-accountrequest.php /pearweb/include/election pear-election-accountrequest.php pear-voter.php /pearweb/include/package releasehelper.php /pearweb/include/pepr pepr.php /pearweb/include/roadmap info.php package-generator.php /pearweb/include/users passwordmanage.php /pearweb/public_html account-edit.php account-info.php account-request-existingpackage.php account-request-newpackage.php get index.php package-changelog.php package-delete.php package-edit.php package-info.php package-new.php package-stats.php release-upload.php /pearweb/public_html/about forgot-password.php /pearweb/public_html/account password-confirm-change.php /pearweb/public_html/admin category-manager.php index.php karma.php package-approval.php package-maintainers.php /pearweb/public_html/bugs roadmap.php stats.php /pearweb/public_html/bugs/include functions.inc /pearweb/public_html/error 404.php /pearweb/public_html/feeds feeds.php /pearweb/public_html/pepr index.php pepr-comments-show.php pepr-proposal-edit.php pepr-proposal-show.php pepr-votes-show.php /pearweb/public_html/trackback trackback.php Log: Request #10798 Split up the pear-database file # pear-database.php is a gonnah, lets dance! # Please test, especially the xmlrpc part

http://cvs.php.net/viewvc.cgi/pearweb/generateREST.php?r1=1.11&r2=1.12&diff_format=u Index: pearweb/generateREST.php diff -u pearweb/generateREST.php:1.11 pearweb/generateREST.php:1.12 --- pearweb/generateREST.php:1.11 Sun Mar 25 04:44:10 2007 +++ pearweb/generateREST.php Sun Apr 22 01:51:34 2007 @@ -2,7 +2,7 @@ /** * Generate static REST files for pear.php.net from existing data * @author Greg Beaver <cellog@php.net> - * @version $Id: generateREST.php,v 1.11 2007/03/25 04:44:10 dufuz Exp $ + * @version $Id: generateREST.php,v 1.12 2007/04/22 01:51:34 dufuz Exp $ */ /** * Useful files to have @@ -18,10 +18,10 @@ define('DEVBOX', false); } -require_once "PEAR.php"; +require_once 'PEAR.php'; -include_once "pear-database.php"; -include_once "pear-rest.php"; +include_once 'pear-database.php'; +include_once 'pear-rest.php'; if (!isset($pear_rest)) { if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') { $pear_rest = new pear_rest('/var/lib/pearweb/rest'); @@ -48,6 +48,8 @@ System::mkdir(array('-p', $pear_rest->_restdir)); chmod($pear_rest->_restdir, 0777); echo "Generating Category REST...\n"; + +include_once 'pear-database-category.php'; foreach (category::listAll() as $category) { echo " $category[name]..."; $pear_rest->saveCategoryREST($category['name']); @@ -71,6 +73,8 @@ require_once 'PEAR/PackageFile.php'; $config = &PEAR_Config::singleton(); $pkg = new PEAR_PackageFile($config); + +include_once 'pear-database-package.php'; foreach (package::listAllNames() as $package) { echo " $package\n"; $pear_rest->savePackageREST($package); @@ -110,5 +114,4 @@ echo " $category[name]..."; $pear_rest->savePackagesCategoryREST($category['name']); echo "done\n"; -} -?> \ No newline at end of file +} \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/package.php?r1=1.150&r2=1.151&diff_format=u Index: pearweb/package.php diff -u pearweb/package.php:1.150 pearweb/package.php:1.151 --- pearweb/package.php:1.150 Tue Apr 17 22:28:47 2007 +++ pearweb/package.php Sun Apr 22 01:51:34 2007 @@ -18,18 +18,11 @@ 'tests/', ), )); -$a->setReleaseVersion('1.13.0'); +$a->setReleaseVersion('1.14.0'); $a->setReleaseStability('stable'); $a->setAPIStability('stable'); $a->setNotes(' - * Fix Bug #10563: search bugs for current package [cellog] - * Fix Bug #10683: "This package been superseded" problem [cweiske] - * Fix Bug #10694: RC releases not accepted when uploading new release [cipri] - * Fix Bug #10706: popular.rss feed broken [cellog] - * Fix Bug #10710: errors/glitches confirming account [cellog] - * Fix Bug #10756: Can\'t upload patch [cellog] - * Implement Feature #10359: Developer bugfix stats for last month [cellog] - * Implement Feature #10368: Bug reporting stats [cellog] + * Request #10798 Split up the pear-database file [helgi] '); $a->resetUsesrole(); $a->addUsesRole('web', 'Role_Web', 'pearified.com'); http://cvs.php.net/viewvc.cgi/pearweb/package.xml?r1=1.197&r2=1.198&diff_format=u Index: pearweb/package.xml diff -u pearweb/package.xml:1.197 pearweb/package.xml:1.198 --- pearweb/package.xml:1.197 Tue Apr 17 22:28:47 2007 +++ pearweb/package.xml Sun Apr 22 01:51:34 2007 @@ -12,7 +12,7 @@ - sql defining the database and an MDB2_Schema files - a few regression tests - templates - + See the pearweb_phars package for install-pear-nozlib.phar/go-pear.phar See the pearweb_channelxml package for channel.xml</description> <lead> @@ -64,15 +64,15 @@ <active>yes</active> </developer> <developer> - <name>Helgi Bormar</name> + <name>Helgi Thormar</name> <user>dufuz</user> <email>dufuz@php.net</email> - <active>no</active> + <active>yes</active> </developer> - <date>2007-04-17</date> - <time>17:29:19</time> + <date>2007-04-22</date> + <time>01:20:05</time> <version> - <release>1.13.0</release> + <release>1.14.0</release> <api>0.1.1</api> </version> <stability> @@ -200,10 +200,6 @@ <file name="info.php" role="web" /> <file name="package-generator.php" role="web" /> </dir> <!-- /include/roadmap --> - <dir name="tags"> - <file name="Cloud.php" role="web" /> - <file name="Manager.php" role="web" /> - </dir> <!-- /include/tags --> <dir name="users"> <file name="passwordmanage.php" role="web" /> </dir> <!-- /include/users --> @@ -213,7 +209,14 @@ <file name="pear-cache.php" role="web" /> <file name="pear-category.php" role="web" /> <file name="pear-config.php" role="web" /> - <file name="pear-database.php" role="web" /> + <file name="pear-database-user.php" role="web" /> + <file name="pear-database-note.php" role="web" /> + <file name="pear-database-maintainer.php" role="web" /> + <file name="pear-database-release.php" role="web" /> + <file name="pear-database-channel.php" role="web" /> + <file name="pear-database-statistics.php" role="web" /> + <file name="pear-database-package.php" role="web" /> + <file name="pear-database-category.php" role="web" /> <file name="pear-format-html-form.php" role="web" /> <file name="pear-format-html.php" role="web" /> <file name="pear-format-xmlrpc.php" role="web" /> @@ -225,6 +228,7 @@ <file name="site.php" role="web" /> <file name="xmlrpc-cache.php" role="web" /> <file name="xmlrpc-methods.php" role="web" /> + <file name="xmlrpc-testlogin.php" role="web" /> </dir> <!-- /include --> <dir name="public_html"> <dir name="about"> @@ -500,10 +504,6 @@ <file name="tabs_list.php" role="web" /> <file name="tutorials.php" role="web" /> </dir> <!-- /public_html/support --> - <dir name="tags"> - <file name="admin.php" role="web" /> - <file name="packages.php" role="web" /> - </dir> <!-- /public_html/tags --> <dir name="trackback"> <file name="trackback-admin.php" role="web" /> <file name="trackback-overview.php" role="web" /> @@ -603,11 +603,6 @@ <file name="note.tpl.php" role="web" /> <file name="view-full-note.tpl.php" role="web" /> </dir> <!-- /templates/notes --> - <dir name="tags"> - <file name="admin.tpl.php" role="web" /> - <file name="cloud.tpl.php" role="web" /> - <file name="package.tpl.php" role="web" /> - </dir> <!-- /templates/tags --> <dir name="users"> <file name="lostpassword.php" role="web" /> <file name="passwordform.php" role="web" /> @@ -1925,7 +1920,27 @@ <release>stable</release> <api>stable</api> </stability> - <date>2007-04-17</date> + <date>2007-04-21</date> + <license uri="http://www.php.net/license">PHP License</license> + <notes>* Fix Bug #10563: search bugs for current package [cellog] +* Fix Bug #10683: &quot;This package been superseded&quot; problem [cweiske] +* Fix Bug #10694: RC releases not accepted when uploading new release [cipri] +* Fix Bug #10706: popular.rss feed broken [cellog] +* Fix Bug #10710: errors/glitches confirming account [cellog] +* Fix Bug #10756: Can&apos;t upload patch [cellog] +* Implement Feature #10359: Developer bugfix stats for last month [cellog] +* Implement Feature #10368: Bug reporting stats [cellog]</notes> + </release> + <release> + <version> + <release>1.14.0</release> + <api>0.1.1</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2007-04-22</date> <license uri="http://www.php.net/license">PHP License</license> <notes> * Fix Bug #10563: search bugs for current package [cellog] http://cvs.php.net/viewvc.cgi/pearweb/include/pear-auth.php?r1=1.61&r2=1.62&diff_format=u Index: pearweb/include/pear-auth.php diff -u pearweb/include/pear-auth.php:1.61 pearweb/include/pear-auth.php:1.62 --- pearweb/include/pear-auth.php:1.61 Thu Apr 5 19:28:00 2007 +++ pearweb/include/pear-auth.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: pear-auth.php,v 1.61 2007/04/05 19:28:00 cellog Exp $ + $Id: pear-auth.php,v 1.62 2007/04/22 01:51:35 dufuz Exp $ */ function auth_reject($realm = null, $message = null) @@ -109,6 +109,7 @@ global $dbh, $auth_user; if (empty($auth_user)) { + include_once 'pear-database-user.php'; $auth_user = new PEAR_User($dbh, $user); } $error = ''; @@ -133,7 +134,7 @@ } else { $crypted = md5($passwd); } - + if ($crypted == @$auth_user->password) { $ok = true; } else { @@ -165,7 +166,7 @@ static $karma; require_once "Damblan/Karma.php"; - + global $auth_user; if (!isset($auth_user)) { http://cvs.php.net/viewvc.cgi/pearweb/include/pear-format-html-form.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/pear-format-html-form.php diff -u pearweb/include/pear-format-html-form.php:1.4 pearweb/include/pear-format-html-form.php:1.5 --- pearweb/include/pear-format-html-form.php:1.4 Wed Oct 4 09:45:09 2006 +++ pearweb/include/pear-format-html-form.php Sun Apr 22 01:51:35 2007 @@ -15,13 +15,13 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-format-html-form.php,v 1.4 2006/10/04 09:45:09 mj Exp $ + $Id: pear-format-html-form.php,v 1.5 2007/04/22 01:51:35 dufuz Exp $ */ require_once "HTML/Form.php"; /** - * Subclass of HTML_Form that provides methods to create special form + * Subclass of HTML_Form that provides methods to create special form * fields for the PEAR website. * * This class is derived from HTML_Form and provides a number of methods @@ -29,7 +29,7 @@ * * @author Martin Jansen <mj@php.net> * @extends HTML_Form - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class PEAR_Web_Form extends HTML_Form { @@ -47,6 +47,7 @@ static $values = null; if (!is_array($values)) { + include_once 'pear-database-package.php'; $list = package::listAllNames(); foreach ($list as $p_name) { @@ -71,6 +72,7 @@ static $values = null; if (!is_array($values)) { + include_once 'pear-database-user.php'; $list = user::listAll(true); foreach ($list as $user) { http://cvs.php.net/viewvc.cgi/pearweb/include/pear-patches.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/pear-patches.php diff -u pearweb/include/pear-patches.php:1.4 pearweb/include/pear-patches.php:1.5 --- pearweb/include/pear-patches.php:1.4 Wed Jan 26 12:40:05 2005 +++ pearweb/include/pear-patches.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-patches.php,v 1.4 2005/01/26 12:40:05 pajoye Exp $ + $Id: pear-patches.php,v 1.5 2007/04/22 01:51:35 dufuz Exp $ */ require_once "PEAR.php"; @@ -27,7 +27,7 @@ * needs some cleanup. * * @author Martin Jansen <mj@php.net> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class patches { @@ -36,9 +36,9 @@ var $reject_reasons = array("Bogus", "Applied", "Outdated", "Already fixed", "Won't fix"); - var $required = array("email" => "Please provide a email address", - "title" => "Please provide a title for your patch", - "description" => "Please provide a description of your patch", + var $required = array("email" => "Please provide a email address", + "title" => "Please provide a title for your patch", + "description" => "Please provide a description of your patch", "package" => "No package has been specified", "release" => "No release has been specified"); @@ -86,7 +86,7 @@ $query = "INSERT INTO patches VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())"; $result = $this->dbh->query($query, array($id, $package, $release, $email, $handle, - $filename, $title, + $filename, $title, $description ) ); @@ -110,7 +110,9 @@ * @param string Description of the patch * @return boolean */ - function announce($id, $filename, $package, $release, $email, $handle, $title, $description) { + function announce($id, $filename, $package, $release, $email, $handle, $title, $description) + { + include_once 'pear-database-package.php'; $name = package::info($package, "name"); $receivers = array("martin@localhost"); http://cvs.php.net/viewvc.cgi/pearweb/include/pear-prepend.php?r1=1.62&r2=1.63&diff_format=u Index: pearweb/include/pear-prepend.php diff -u pearweb/include/pear-prepend.php:1.62 pearweb/include/pear-prepend.php:1.63 --- pearweb/include/pear-prepend.php:1.62 Tue Oct 11 15:02:06 2005 +++ pearweb/include/pear-prepend.php Sun Apr 22 01:51:35 2007 @@ -15,9 +15,10 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: pear-prepend.php,v 1.62 2005/10/11 15:02:06 pajoye Exp $ + $Id: pear-prepend.php,v 1.63 2007/04/22 01:51:35 dufuz Exp $ */ -require_once "pear-config.php"; + +require_once 'pear-config.php'; if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { error_reporting(E_ALL); define('DEVBOX', true); @@ -37,12 +38,9 @@ } include_once "pear-format-$format.php"; - include_once "pear-auth.php"; -include_once "pear-database.php"; include_once "pear-rest.php"; - function get($name) { if (!empty($_GET[$name])) { @@ -70,7 +68,7 @@ auth_logout(); } -if (!empty($_COOKIE['PEAR_USER']) && !@auth_verify($_COOKIE['PEAR_USER'], $_COOKIE['PEAR_PW'])) { +if (!empty($_COOKIE['PEAR_USER']) && !auth_verify($_COOKIE['PEAR_USER'], $_COOKIE['PEAR_PW'])) { $__user = $_COOKIE['PEAR_USER']; setcookie('PEAR_USER', '', 0, '/'); unset($_COOKIE['PEAR_USER']); @@ -83,23 +81,19 @@ auth_reject(null, $msg); } -if (!function_exists('file_get_contents')) { - function file_get_contents($file, $use_include_path = false) { - if (!$fp = fopen($file, 'r', $use_include_path)) { - return false; - } - $data = fread($fp, filesize($file)); - fclose($fp); - return $data; - } -} - -if (!function_exists('file_put_contents')) { - function file_put_contents($fname, $contents) - { - $fp = fopen($fname, 'wb'); - fwrite($fp, $contents); - fclose($fp); +/** + * Converts a Unix timestamp to a date() formatted string in the UTC time zone + * + * @param int $ts a Unix timestamp from the local machine. If none + * is provided the current time is used. + * @param string $format a format string, as per http://php.net/date + * + * @return string the time formatted time + */ +function make_utc_date($ts = null, $format = 'Y-m-d H:i \U\T\C') +{ + if (!$ts) { + $ts = time(); } -} - + return gmdate($format, $ts); +} \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/include/pear-rest.php?r1=1.36&r2=1.37&diff_format=u Index: pearweb/include/pear-rest.php diff -u pearweb/include/pear-rest.php:1.36 pearweb/include/pear-rest.php:1.37 --- pearweb/include/pear-rest.php:1.36 Fri Mar 30 03:02:10 2007 +++ pearweb/include/pear-rest.php Sun Apr 22 01:51:35 2007 @@ -18,6 +18,7 @@ @chmod($cdir, 0777); } + include_once 'pear-database-category.php'; $categories = category::listAll(); $info = '<?xml version="1.0" encoding="UTF-8" ?> <a xmlns="http://pear.php.net/dtd/rest.allcategories" @@ -110,6 +111,8 @@ } $pdir = $this->_restdir . DIRECTORY_SEPARATOR . 'p'; $rdir = $this->_restdir . DIRECTORY_SEPARATOR . 'r'; + + include_once 'pear-database-category.php'; $packages = category::listPackages($category); $fullpackageinfo = '<?xml version="1.0" encoding="UTF-8" ?> <f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo" @@ -196,8 +199,8 @@ http://pear.php.net/dtd/rest.allpackages.xsd"> <c>' . PEAR_CHANNELNAME . '</c> '; - foreach (package::listAllNames() as $package) - { + include_once 'pear-database-package.php'; + foreach (package::listAllNames() as $package) { $info .= ' <p>' . $package . '</p> '; } @@ -221,6 +224,7 @@ require_once 'System.php'; global $dbh; $extra = '/rest/'; + include_once 'pear-database-package.php'; $package = package::info($package); $pdir = $this->_restdir . DIRECTORY_SEPARATOR . 'p'; @@ -233,11 +237,11 @@ strtolower($package['name']))); @chmod($pdir . DIRECTORY_SEPARATOR . strtolower($package['name']), 0777); } - $catinfo = $dbh->getOne('SELECT c.name FROM packages, categories c WHERE + $catinfo = $dbh->getOne('SELECT c.name FROM packages, categories c WHERE c.id = ?', array($package['categoryid']), DB_FETCHMODE_ASSOC); if (isset($package['parent']) && $package['parent']) { $parent = ' - <pa xlink:href="' . $extra . 'p/' . $package['parent'] . '">' . + <pa xlink:href="' . $extra . 'p/' . $package['parent'] . '">' . $package['parent'] . '</pa>'; } else { $parent = ''; @@ -306,6 +310,7 @@ require_once 'PEAR/Config.php'; global $dbh; $extra = '/rest/'; + include_once 'pear-database-package.php'; $pid = package::info($package, 'id'); $releases = $dbh->getAll('SELECT * FROM releases WHERE package = ? ORDER BY releasedate DESC', array($pid), DB_FETCHMODE_ASSOC); @@ -534,6 +539,7 @@ { require_once 'System.php'; global $dbh; + include_once 'pear-database-package.php'; $pid = package::info($package, 'id'); $maintainers = $dbh->getAll('SELECT * FROM maintains WHERE package = ?', array($pid), DB_FETCHMODE_ASSOC); @@ -635,6 +641,7 @@ function saveAllMaintainersREST() { + include_once 'pear-database-user.php'; $maintainers = user::listAll(); $info = '<?xml version="1.0" encoding="UTF-8" ?> <m xmlns="http://pear.php.net/dtd/rest.allmaintainers" http://cvs.php.net/viewvc.cgi/pearweb/include/xmlrpc-methods.php?r1=1.17&r2=1.18&diff_format=u Index: pearweb/include/xmlrpc-methods.php diff -u pearweb/include/xmlrpc-methods.php:1.17 pearweb/include/xmlrpc-methods.php:1.18 --- pearweb/include/xmlrpc-methods.php:1.17 Fri Sep 9 15:31:40 2005 +++ pearweb/include/xmlrpc-methods.php Sun Apr 22 01:51:35 2007 @@ -20,8 +20,21 @@ require_once "signatures.php"; -parse_signatures_from_file("../include/pear-database.php", - $xmlrpc_method_index, "index"); +// Parse all the classes with proto signature in them +parse_signatures_from_file('../include/xmlrpc-testlogin.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-category.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-package.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-maintainer.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-release.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-note.php', + $xmlrpc_method_index, 'index'); +parse_signatures_from_file('../include/pear-database-user.php', + $xmlrpc_method_index, 'index'); // {{{ pear_register_xmlrpc_methods() http://cvs.php.net/viewvc.cgi/pearweb/include/Damblan/Bugs.php?r1=1.3&r2=1.4&diff_format=u Index: pearweb/include/Damblan/Bugs.php diff -u pearweb/include/Damblan/Bugs.php:1.3 pearweb/include/Damblan/Bugs.php:1.4 --- pearweb/include/Damblan/Bugs.php:1.3 Fri Mar 23 00:23:48 2007 +++ pearweb/include/Damblan/Bugs.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: David Coallier <davidc@php.net> | +----------------------------------------------------------------------+ - $Id: Bugs.php,v 1.3 2007/03/23 00:23:48 cellog Exp $ + $Id: Bugs.php,v 1.4 2007/04/22 01:51:35 dufuz Exp $ */ /** @@ -29,7 +29,7 @@ /** * Get maintainers * - * Get maintainers to inform of a trackback (the + * Get maintainers to inform of a trackback (the * lead maintainers of a package). * * @since @@ -42,9 +42,11 @@ */ function getMaintainers ($id, $leadOnly = false, $activeOnly = true) { + include_once 'pear-database-maintainer.php'; $maintainers = maintainer::get($id, $leadOnly, $activeOnly); $res = array(); + include_once 'pear-database-user.php'; foreach ($maintainers as $maintainer => $data) { $tmpUser = user::info($maintainer, 'email'); if (!is_array($tmpUser) || !isset($tmpUser['email'])) { http://cvs.php.net/viewvc.cgi/pearweb/include/Damblan/Trackback.php?r1=1.18&r2=1.19&diff_format=u Index: pearweb/include/Damblan/Trackback.php diff -u pearweb/include/Damblan/Trackback.php:1.18 pearweb/include/Damblan/Trackback.php:1.19 --- pearweb/include/Damblan/Trackback.php:1.18 Sat Mar 10 21:48:58 2007 +++ pearweb/include/Damblan/Trackback.php Sun Apr 22 01:51:35 2007 @@ -404,9 +404,11 @@ */ function getMaintainers ($activeOnly = true) { + include_once 'pear-database-maintainer.php'; $maintainers = maintainer::get($this->get('id'), true, $activeOnly); $res = array(); + include_once 'pear-database-user.php'; foreach ($maintainers as $maintainer => $data) { $tmpUser = user::info($maintainer, 'email'); if (empty($tmpUser['email'])) { http://cvs.php.net/viewvc.cgi/pearweb/include/bugs/pear-bug-accountrequest.php?r1=1.19&r2=1.20&diff_format=u Index: pearweb/include/bugs/pear-bug-accountrequest.php diff -u pearweb/include/bugs/pear-bug-accountrequest.php:1.19 pearweb/include/bugs/pear-bug-accountrequest.php:1.20 --- pearweb/include/bugs/pear-bug-accountrequest.php:1.19 Tue Apr 17 22:31:01 2007 +++ pearweb/include/bugs/pear-bug-accountrequest.php Sun Apr 22 01:51:35 2007 @@ -158,6 +158,8 @@ if ($password !== $password2) { $errors[] = 'Passwords do not match'; } + + include_once 'pear-database-user.php'; if (user::exists($handle)) { $errors[] = 'User name "' . $handle . '" already exists, please choose another user name'; @@ -191,7 +193,7 @@ function confirmRequest($handle, $password, $name) { - if ($handle == $this->dbh->getOne('SELECT handle FROM users WHERE + if ($handle == $this->dbh->getOne('SELECT handle FROM users WHERE handle=?', array($handle))) { $id = $this->dbh->nextId("karma"); @@ -214,6 +216,7 @@ 'homepage' => '', ); + include_once 'pear-database-user.php'; $useradd = user::add($data, true); if (is_array($useradd)) { @@ -234,11 +237,14 @@ // implicitly without human intervention // copied from the user class and Damblan_Karma + include_once 'pear-database-user.php'; $user =& new PEAR_User($this->dbh, $this->handle); if (@$user->registered) { return false; } @$arr = unserialize($user->userinfo); + + include_once 'pear-database-note.php'; note::removeAll("uid", $this->handle); $user->set('registered', 1); $user->set('password', $password); @@ -267,7 +273,7 @@ } $patches = $this->dbh->getAll('SELECT bugdb.package_name,bugdb_patchtracker.* FROM bugdb_patchtracker, bugdb - WHERE bugdb_patchtracker.developer=? + WHERE bugdb_patchtracker.developer=? AND bugdb.id=bugdb_patchtracker.bugdb_id', array($this->handle), DB_FETCHMODE_ASSOC); foreach ($patches as $patch) { @@ -318,6 +324,7 @@ return array(PEAR_DOC_EMAIL, PEAR_DOC_EMAIL); } + include_once 'pear-database-package.php'; $maintainers = package::info($package_name, 'authors'); $to = array(); @@ -331,7 +338,7 @@ /* subscription */ if ($bug_id) { $bug_id = (int)$bug_id; - + $assigned = $dbh->getOne('SELECT assign FROM bugdb WHERE id=' . $bug_id); if ($assigned) { $assigned = $dbh->getOne('SELECT email FROM users WHERE handle="' . $assigned . '"'); @@ -487,9 +494,9 @@ $patchName = urlencode($patch['patch']); $mailData = array( 'id' => $patch['bugdb_id'], - 'url' => 'http://' . PEAR_CHANNELNAME . + 'url' => 'http://' . PEAR_CHANNELNAME . "/bugs/patch-display.php?bug=$patch[bugdb_id]&patch=$patchName&revision=$patch[revision]&display=1", - + 'date' => date('Y-m-d H:i:s'), 'name' => $patch['patch'], 'package' => $patch['package_name'], @@ -498,7 +505,7 @@ 'packageUrl' => 'http://' . PEAR_CHANNELNAME . '/bugs/bug.php?id=' . $patch['bugdb_id'], ); - + $additionalHeaders['To'] = Damblan_Bugs::getMaintainers($patch['package_name']); $mailer = Damblan_Mailer::create('Patch_Added', $mailData); $res = true; @@ -521,9 +528,9 @@ $max_message_length = 10 * 1024; $max_comments = 5; $output = ""; $count = 0; - + $res =& $this->dbh->query("SELECT ts, email, comment, handle FROM bugdb_comments WHERE bug=$bug_id ORDER BY ts DESC"); - + # skip the most recent unless the caller wanted all comments if (!$all) { $row =& $res->fetchRow(DB_FETCHMODE_ORDERED); @@ -531,7 +538,7 @@ return ''; } } - + while (($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) && strlen($output) < $max_message_length && $count++ < $max_comments) { $email = $row[3] ? @@ -539,7 +546,7 @@ $this->spam_protect($row[1], 'text'); $output .= "[$row[0]] $email\n\n$row[2]\n\n$divider\n\n"; } - + if (strlen($output) < $max_message_length && $count < $max_comments) { $res =& $this->dbh->query("SELECT ts1,email,ldesc,handle FROM bugdb WHERE id=$bug_id"); if (!$res) { @@ -556,7 +563,7 @@ } else { return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "The remainder of the comments for this report are too long. To view\nthe rest of the comments, please view the bug report online at\n http://pear.php.net/bugs/bug.php?id=$bug_id\n"); } - + return ''; } http://cvs.php.net/viewvc.cgi/pearweb/include/election/pear-election-accountrequest.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/election/pear-election-accountrequest.php diff -u pearweb/include/election/pear-election-accountrequest.php:1.4 pearweb/include/election/pear-election-accountrequest.php:1.5 --- pearweb/include/election/pear-election-accountrequest.php:1.4 Mon Mar 12 16:56:48 2007 +++ pearweb/include/election/pear-election-accountrequest.php Sun Apr 22 01:51:35 2007 @@ -55,6 +55,7 @@ $data = array_merge($additionnalData, $data); + include_once 'pear-database-user.php'; $useradd = user::add($data); if (is_array($useradd)) { @@ -97,11 +98,13 @@ // implicitly without human intervention // copied from the user class and Damblan_Karma + include_once 'pear-database-user.php'; $user =& new PEAR_User($this->dbh, $this->handle); if (@$user->registered) { return false; } @$arr = unserialize($user->userinfo); + include_once 'pear-database-note.php'; note::removeAll("uid", $this->handle); $user->set('registered', 1); if (is_array($arr)) { http://cvs.php.net/viewvc.cgi/pearweb/include/election/pear-voter.php?r1=1.6&r2=1.7&diff_format=u Index: pearweb/include/election/pear-voter.php diff -u pearweb/include/election/pear-voter.php:1.6 pearweb/include/election/pear-voter.php:1.7 --- pearweb/include/election/pear-voter.php:1.6 Wed Mar 21 21:37:10 2007 +++ pearweb/include/election/pear-voter.php Sun Apr 22 01:51:35 2007 @@ -176,7 +176,7 @@ c.choice = e.choice ORDER BY e.votetotal DESC ', array($id), DB_FETCHMODE_ASSOC); - + // calculate winners $order = array(); foreach ($info['results'] as $result) { @@ -373,6 +373,7 @@ function email($election, $votes, $salt) { + include_once 'pear-database-user.php'; $info = user::info($this->user); $email = '"' . $info['name'] . '" <' . $info['email'] . '>'; $headers = "From: bounce-no-user@php.net\n"; http://cvs.php.net/viewvc.cgi/pearweb/include/package/releasehelper.php?r1=1.6&r2=1.7&diff_format=u Index: pearweb/include/package/releasehelper.php diff -u pearweb/include/package/releasehelper.php:1.6 pearweb/include/package/releasehelper.php:1.7 --- pearweb/include/package/releasehelper.php:1.6 Thu Apr 5 19:28:00 2007 +++ pearweb/include/package/releasehelper.php Sun Apr 22 01:51:35 2007 @@ -11,6 +11,8 @@ function package_releasehelper($package) { $this->_dbh = &$GLOBALS['dbh']; + + include_once 'pear-database-package.php'; $this->_info = package::info($package, 'releases'); $this->_pkgid = package::info($package, 'id'); if (is_array($this->_info) && $this->_info) { @@ -30,8 +32,8 @@ if (!isset($this->_lastid)) { return false; } - $info = $this->_dbh->getOne('SELECT packagexml FROM files WHERE release="' . - $this->_lastid . '" AND package="' . $this->_pkgid . '"', array()); + $info = $this->_dbh->getOne('SELECT packagexml FROM files WHERE `release`="' . + $this->_lastid . '" AND `package`="' . $this->_pkgid . '"', array()); return !preg_match('/<package[^>]+version\s*=\s*"2.0"/', $info); } @@ -179,7 +181,7 @@ } } } - $version = explode('.', $this->_lastversion); + $version = explode('.', $this->_lastversion); if ($this->_laststate == 'stable') { return array($version[0] . '.' . ($version[1] + 1) . '.0a1', 'alpha'); } http://cvs.php.net/viewvc.cgi/pearweb/include/pepr/pepr.php?r1=1.71&r2=1.72&diff_format=u Index: pearweb/include/pepr/pepr.php diff -u pearweb/include/pepr/pepr.php:1.71 pearweb/include/pepr/pepr.php:1.72 --- pearweb/include/pepr/pepr.php:1.71 Sat Mar 17 21:14:21 2007 +++ pearweb/include/pepr/pepr.php Sun Apr 22 01:51:35 2007 @@ -22,7 +22,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: pepr.php,v 1.71 2007/03/17 21:14:21 cellog Exp $ + * @version $Id: pepr.php,v 1.72 2007/04/22 01:51:35 dufuz Exp $ */ /**#@+ @@ -657,6 +657,7 @@ $prefix = ""; } $prefix = PROPOSAL_EMAIL_PREFIX . $prefix . " "; + include_once 'pear-database-user.php'; $actorinfo = user::info($user_handle); $ownerinfo = user::info($this->user_handle); $this->getVotes($dbh); http://cvs.php.net/viewvc.cgi/pearweb/include/roadmap/info.php?r1=1.2&r2=1.3&diff_format=u Index: pearweb/include/roadmap/info.php diff -u pearweb/include/roadmap/info.php:1.2 pearweb/include/roadmap/info.php:1.3 --- pearweb/include/roadmap/info.php:1.2 Mon Mar 5 23:18:48 2007 +++ pearweb/include/roadmap/info.php Sun Apr 22 01:51:35 2007 @@ -13,6 +13,8 @@ if (!$ret) { return false; } + + include_once 'pear-database-package.php'; $releases = array_keys(package::info($package, 'releases')); foreach ($ret as $roadmap) { if (in_array($roadmap[0], $releases)) continue; http://cvs.php.net/viewvc.cgi/pearweb/include/roadmap/package-generator.php?r1=1.6&r2=1.7&diff_format=u Index: pearweb/include/roadmap/package-generator.php diff -u pearweb/include/roadmap/package-generator.php:1.6 pearweb/include/roadmap/package-generator.php:1.7 --- pearweb/include/roadmap/package-generator.php:1.6 Mon Mar 5 19:16:14 2007 +++ pearweb/include/roadmap/package-generator.php Sun Apr 22 01:51:35 2007 @@ -101,6 +101,7 @@ function getBlankPackage() { require_once 'PEAR/Validate.php'; + include_once 'pear-database-package.php'; $info = package::info($this->_package); $maintainers = package::info($this->_package, 'authors'); $pf = new PEAR_PackageFile_v2_rw; http://cvs.php.net/viewvc.cgi/pearweb/include/users/passwordmanage.php?r1=1.3&r2=1.4&diff_format=u Index: pearweb/include/users/passwordmanage.php diff -u pearweb/include/users/passwordmanage.php:1.3 pearweb/include/users/passwordmanage.php:1.4 --- pearweb/include/users/passwordmanage.php:1.3 Thu Mar 8 03:09:08 2007 +++ pearweb/include/users/passwordmanage.php Sun Apr 22 01:51:35 2007 @@ -63,6 +63,7 @@ if (PEAR::isError($e)) { $errors[] = 'Could not change password: ' . $e->getMessage(); } else { + include_once 'pear-database-user.php'; $info = user::info($user); $this->_mailer = Damblan_mailer::create(array( 'To' => array($info['name'] . ' <' . $info['email'] . '>'), @@ -82,7 +83,7 @@ will NOT change until you confirm the change, and it cannot be changed without the password reset code. Password change requests are automatically purged after 24 hours. - + PEAR Quality Assurance.'), array('username' => $user, 'salt' => $salt)); $this->_mailer->send(); } http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-edit.php?r1=1.56&r2=1.57&diff_format=u Index: pearweb/public_html/account-edit.php diff -u pearweb/public_html/account-edit.php:1.56 pearweb/public_html/account-edit.php:1.57 --- pearweb/public_html/account-edit.php:1.56 Mon Dec 11 21:10:46 2006 +++ pearweb/public_html/account-edit.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-edit.php,v 1.56 2006/12/11 21:10:46 arnaud Exp $ + $Id: account-edit.php,v 1.57 2007/04/22 01:51:35 dufuz Exp $ */ auth_require(); @@ -85,13 +85,13 @@ } if ($k == 'latitude') { - $user_data_post['latitude'] = + $user_data_post['latitude'] = isset($_POST['latitude']) ? strip_tags($_POST['latitude']) : ''; } if ($k == 'longitude') { - $user_data_post['longitude'] = + $user_data_post['longitude'] = isset($_POST['longitude']) ? strip_tags($_POST['longitude']) : ''; } @@ -114,6 +114,7 @@ } } + include_once 'pear-database-user.php'; $user = user::update($user_data_post); $old_acl = $dbh->getCol('SELECT path FROM cvs_acl '. @@ -149,6 +150,7 @@ break; case 'change_password': + include_once 'pear-database-user.php'; $user = &new PEAR_User($dbh, $handle); if (empty($_POST['password_old']) || empty($_POST['password']) || http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-info.php?r1=1.50&r2=1.51&diff_format=u Index: pearweb/public_html/account-info.php diff -u pearweb/public_html/account-info.php:1.50 pearweb/public_html/account-info.php:1.51 --- pearweb/public_html/account-info.php:1.50 Mon Mar 5 04:32:33 2007 +++ pearweb/public_html/account-info.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-info.php,v 1.50 2007/03/05 04:32:33 cellog Exp $ + $Id: account-info.php,v 1.51 2007/04/22 01:51:35 dufuz Exp $ */ /** @@ -39,6 +39,7 @@ $dbh->setFetchmode(DB_FETCHMODE_ASSOC); +include_once 'pear-database-user.php'; $row = user::info($handle); if ($row === null) { @@ -68,7 +69,7 @@ echo '<h1>User Information: ' . htmlspecialchars($row['name']) . "</h1>\n"; -if (isset($auth_user) && is_object($auth_user) +if (isset($auth_user) && is_object($auth_user) && ($auth_user->handle == $handle || auth_check('pear.admin'))) { @@ -193,6 +194,8 @@ <?php $packages = user::getPackages($handle); + +include_once 'pear-database-note.php'; $notes = note::getAll($handle); if (count($packages) > 0 || count($notes) > 0) { http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-request-existingpackage.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/account-request-existingpackage.php diff -u pearweb/public_html/account-request-existingpackage.php:1.1 pearweb/public_html/account-request-existingpackage.php:1.2 --- pearweb/public_html/account-request-existingpackage.php:1.1 Sat Nov 4 02:41:51 2006 +++ pearweb/public_html/account-request-existingpackage.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-request-existingpackage.php,v 1.1 2006/11/04 02:41:51 cellog Exp $ + $Id: account-request-existingpackage.php,v 1.2 2007/04/22 01:51:35 dufuz Exp $ */ define('HTML_FORM_TH_ATTR', 'class="form-label_left"'); @@ -77,6 +77,7 @@ } // The add method performs further validation then creates the acct + include_once 'pear-database-user.php'; $ok = user::add($stripped); if (!empty($stripped['jumpto'])) { http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-request-newpackage.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/account-request-newpackage.php diff -u pearweb/public_html/account-request-newpackage.php:1.1 pearweb/public_html/account-request-newpackage.php:1.2 --- pearweb/public_html/account-request-newpackage.php:1.1 Sat Nov 4 02:41:51 2006 +++ pearweb/public_html/account-request-newpackage.php Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: account-request-newpackage.php,v 1.1 2006/11/04 02:41:51 cellog Exp $ + $Id: account-request-newpackage.php,v 1.2 2007/04/22 01:51:35 dufuz Exp $ */ define('HTML_FORM_TH_ATTR', 'class="form-label_left"'); @@ -77,6 +77,7 @@ } // The add method performs further validation then creates the acct + include_once 'pear-database-user.php'; $ok = user::add($stripped); if (!empty($stripped['jumpto'])) { http://cvs.php.net/viewvc.cgi/pearweb/public_html/get?r1=1.20&r2=1.21&diff_format=u Index: pearweb/public_html/get diff -u pearweb/public_html/get:1.20 pearweb/public_html/get:1.21 --- pearweb/public_html/get:1.20 Thu Apr 5 19:28:05 2007 +++ pearweb/public_html/get Sun Apr 22 01:51:35 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: get,v 1.20 2007/04/05 19:28:05 cellog Exp $ + $Id: get,v 1.21 2007/04/22 01:51:35 dufuz Exp $ */ /** @@ -85,6 +85,7 @@ } switch (sizeof($opts)) { case 2: { + include_once 'pear-database-release.php'; if (preg_match('/^([a-zA-Z0-9_]+)-(.+)\.(tar|tgz)\z/', $opts[1], $matches)) { list(, $package, $version) = $matches; $ok = release::HTTPdownload($package, $version, $opts[1], $uncompress); @@ -97,6 +98,7 @@ break; } case 3: { + include_once 'pear-database-release.php'; $ok = release::HTTPdownload($opts[1], $opts[2], null, $uncompress); break; } http://cvs.php.net/viewvc.cgi/pearweb/public_html/index.php?r1=1.126&r2=1.127&diff_format=u Index: pearweb/public_html/index.php diff -u pearweb/public_html/index.php:1.126 pearweb/public_html/index.php:1.127 --- pearweb/public_html/index.php:1.126 Mon Mar 19 02:32:50 2007 +++ pearweb/public_html/index.php Sun Apr 22 01:51:35 2007 @@ -15,9 +15,10 @@ +----------------------------------------------------------------------+ | Authors: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: index.php,v 1.126 2007/03/19 02:32:50 cellog Exp $ + $Id: index.php,v 1.127 2007/04/22 01:51:35 dufuz Exp $ */ +include_once 'pear-database-release.php'; $recent = release::getRecent(5); if (@sizeof($recent) > 0) { $RSIDEBAR_DATA = "<strong>Recent&nbsp;Releases:</strong>\n"; @@ -61,7 +62,7 @@ <h1>PEAR - PHP Extension and Application Repository</h1> <h2>&raquo; Hot off the Press</h2> -<p><strong>[March 18, 2007]</strong> Official results of PEAR's future direction are +<p><strong>[March 18, 2007]</strong> Official results of PEAR's future direction are <a href="http://pear.php.net/election/info.php?election=6&results=1">here</a>. The official new Constitution for PEAR is available for viewing <a href="http://pear.php.net/manual/en/constitution.php">here</a>. Elections @@ -117,6 +118,7 @@ echo menu_link("New Package Proposal", "pepr/pepr-proposal-edit.php"); echo '</div>'; + include_once 'pear-database-user.php'; if (user::isAdmin($auth_user->handle)) { echo '<h2>&raquo; Administrators</h2>'; echo '<div class="indent">'; http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-changelog.php?r1=1.18&r2=1.19&diff_format=u Index: pearweb/public_html/package-changelog.php diff -u pearweb/public_html/package-changelog.php:1.18 pearweb/public_html/package-changelog.php:1.19 --- pearweb/public_html/package-changelog.php:1.18 Wed Jan 26 12:40:06 2005 +++ pearweb/public_html/package-changelog.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-changelog.php,v 1.18 2005/01/26 12:40:06 pajoye Exp $ + $Id: package-changelog.php,v 1.19 2007/04/22 01:51:36 dufuz Exp $ */ // expected url vars: pacid package @@ -25,6 +25,7 @@ $pacid = (isset($_GET['pacid'])) ? (int) $_GET['pacid'] : null; } +include_once 'pear-database-package.php'; $pkg = package::info($pacid); if (empty($pkg['name'])) { http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-delete.php?r1=1.18&r2=1.19&diff_format=u Index: pearweb/public_html/package-delete.php diff -u pearweb/public_html/package-delete.php:1.18 pearweb/public_html/package-delete.php:1.19 --- pearweb/public_html/package-delete.php:1.18 Sat Jan 7 17:47:00 2006 +++ pearweb/public_html/package-delete.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-delete.php,v 1.18 2006/01/07 17:47:00 danielc Exp $ + $Id: package-delete.php,v 1.19 2007/04/22 01:51:36 dufuz Exp $ */ /* @@ -34,8 +34,8 @@ } +include_once 'pear-database-package.php'; if (!isset($_POST['confirm'])) { - $pkg = package::info($_GET['id']); print_package_navigation($_GET['id'], $pkg['name'], '/package-delete.php?id=' . $_GET['id']); @@ -72,9 +72,9 @@ // XXX: Implement backup functionality // make_backup($_GET['id']); - $tables = array('releases' => 'package', + $tables = array('releases' => 'package', 'maintains' => 'package', - 'deps' => 'package', + 'deps' => 'package', 'files' => 'package', 'packages' => 'id'); http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-edit.php?r1=1.43&r2=1.44&diff_format=u Index: pearweb/public_html/package-edit.php diff -u pearweb/public_html/package-edit.php:1.43 pearweb/public_html/package-edit.php:1.44 --- pearweb/public_html/package-edit.php:1.43 Sat Mar 31 03:59:01 2007 +++ pearweb/public_html/package-edit.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-edit.php,v 1.43 2007/03/31 03:59:01 cellog Exp $ + $Id: package-edit.php,v 1.44 2007/04/22 01:51:36 dufuz Exp $ */ /* @@ -52,6 +52,7 @@ exit; } +include_once 'pear-database-user.php'; if (!user::maintains($auth_user->handle, $_GET['id'], 'lead') && !user::isAdmin($auth_user->handle) && !user::isQA($auth_user->handle)) @@ -63,6 +64,7 @@ } // Update +include_once 'pear-database-package.php'; if (isset($_POST['submit'])) { if (!$_POST['name'] || !$_POST['license'] || !$_POST['summary']) { report_error('You have to enter values for name, license and summary!'); @@ -136,6 +138,7 @@ break; } + include_once 'pear-datbase-release.php'; if (release::remove($_GET['id'], $_GET['release'])) { echo "<b>Release successfully deleted.</b><br /><br />\n"; } else { http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-info.php?r1=1.133&r2=1.134&diff_format=u Index: pearweb/public_html/package-info.php diff -u pearweb/public_html/package-info.php:1.133 pearweb/public_html/package-info.php:1.134 --- pearweb/public_html/package-info.php:1.133 Thu Apr 12 01:51:11 2007 +++ pearweb/public_html/package-info.php Sun Apr 22 01:51:36 2007 @@ -16,7 +16,7 @@ | Authors: Martin Jansen <mj@php.net> | | Tomas V.V.Cox <cox@idecnet.com> | +----------------------------------------------------------------------+ - $Id: package-info.php,v 1.133 2007/04/12 01:51:11 cellog Exp $ + $Id: package-info.php,v 1.134 2007/04/22 01:51:36 dufuz Exp $ */ @@ -36,6 +36,7 @@ // Package data if (!empty($pacid)) { + include_once 'pear-database-package.php'; $pkg = package::info($pacid); // $stats = $dbh->getAssoc('SELECT //releases.package, @@ -48,7 +49,7 @@ // package_stats.package = packages.name //GROUP BY releases.package //ORDER BY d DESC'); -// +// // $amount = $stats[$pkg['packageid']]; // $newstats = array_flip(array_values($stats)); // $rank = ($newstats[$amount] + 1) . ' of ' . count($stats); @@ -83,6 +84,7 @@ $karma =& new Damblan_Karma($dbh); $trackbackIsAdmin = (isset($auth_user) && $karma->has($auth_user->handle, 'pear.dev')); if ($trackbackIsAdmin) { + include_once 'pear-database-package.php'; if ($pkg['blocktrackbacks'] && $params['allowtrackbacks'] == 1) { package::allowTrackbacks($pkg['name'], true); localRedirect('/package/' . $pkg['name'] . '/trackbacks'); @@ -116,6 +118,7 @@ if (empty($pacid) || !isset($pkg['name'])) { // Let's see if $pacid is a PECL package if (!isset($pkg['name'])) { + include_once 'pear-database-package.php'; $pkg_name = package::info($pacid, 'name', true); if (!empty($pkg_name)) { header('HTTP/1.0 301 Moved Permanently'); @@ -150,6 +153,7 @@ $supersede = (bool) $pkg['new_channel']; // Maintainer information +include_once 'pear-database-maintainer.php'; $maintainers = maintainer::get($pacid); $accounts = '<ul>'; //$bugs = new PEAR_Bugs; @@ -453,6 +457,7 @@ // {{{ Dependants + include_once 'pear-database-package.php'; $dependants = package::getDependants($name); if ($rel_count > 0 && count($dependants) > 0) { print '<tr>'; http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-new.php?r1=1.38&r2=1.39&diff_format=u Index: pearweb/public_html/package-new.php diff -u pearweb/public_html/package-new.php:1.38 pearweb/public_html/package-new.php:1.39 --- pearweb/public_html/package-new.php:1.38 Thu Apr 5 19:28:05 2007 +++ pearweb/public_html/package-new.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: package-new.php,v 1.38 2007/04/05 19:28:05 cellog Exp $ + $Id: package-new.php,v 1.39 2007/04/22 01:51:36 dufuz Exp $ */ require_once 'HTML/Form.php'; @@ -63,6 +63,7 @@ } $dbh->expectError(DB_ERROR_CONSTRAINT); + include_once 'pear-database-package.php'; $pkg = package::add(array( 'name' => $_POST['name'], 'type' => 'pear', http://cvs.php.net/viewvc.cgi/pearweb/public_html/package-stats.php?r1=1.79&r2=1.80&diff_format=u Index: pearweb/public_html/package-stats.php diff -u pearweb/public_html/package-stats.php:1.79 pearweb/public_html/package-stats.php:1.80 --- pearweb/public_html/package-stats.php:1.79 Fri Oct 20 23:50:16 2006 +++ pearweb/public_html/package-stats.php Sun Apr 22 01:51:36 2007 @@ -16,7 +16,7 @@ | Authors: Martin Jansen <mj@php.net> | | Richard Heyes <richard@php.net> | +----------------------------------------------------------------------+ - $Id: package-stats.php,v 1.79 2006/10/20 23:50:16 cellog Exp $ + $Id: package-stats.php,v 1.80 2007/04/22 01:51:36 dufuz Exp $ */ require_once 'HTML/Form.php'; @@ -70,6 +70,7 @@ echo ' <td>'."\n"; echo ' <select name="cid" onchange="javascript:reloadMe();">'."\n"; echo ' <option value="">Select category ...</option>'."\n"; +include_once 'pear-database-category.php'; foreach (category::listAll() as $value) { $selected = ''; if (isset($_GET['cid']) && $_GET['cid'] == $value['id']) { @@ -135,7 +136,8 @@ $bb->end(); if (isset($_GET['pid']) && (int)$_GET['pid']) { - + include_once 'pear-database-statistics.php'; + include_once 'pear-database-package.php'; $info = package::info($_GET['pid'],null,false); if (isset($info['releases']) && sizeof($info['releases'])>0) { @@ -318,8 +320,8 @@ $total_categories = $dbh->getOne(sprintf("SELECT COUNT(*) FROM categories WHERE parent = %d", $_GET['cid'])); // Query to get package list from package_stats_table - $query = sprintf("SELECT SUM(ps.dl_number) AS dl_number, ps.package, ps.release, ps.pid, ps.rid, ps.cid - FROM package_stats ps, packages p + $query = sprintf("SELECT SUM(ps.dl_number) AS dl_number, ps.package, ps.release, ps.pid, ps.rid, ps.cid + FROM package_stats ps, packages p WHERE p.package_type = 'pear' AND p.id = ps.pid AND p.category = %s GROUP BY ps.pid ORDER BY dl_number DESC", $_GET['cid'] @@ -337,7 +339,7 @@ $total_categories = number_format($dbh->getOne('SELECT COUNT(*) FROM categories'), 0, '.', ','); $total_downloads = number_format($dbh->getOne('SELECT SUM(dl_number) FROM package_stats, packages p WHERE package_stats.pid = p.id AND p.package_type="pear"'), 0, '.', ','); - $query = "SELECT sum(ps.dl_number) as dl_number, ps.package, ps.pid, ps.rid, ps.cid + $query = "SELECT sum(ps.dl_number) as dl_number, ps.package, ps.pid, ps.rid, ps.cid FROM package_stats ps, packages p WHERE p.id = ps.pid AND p.package_type = 'pear' GROUP BY ps.pid ORDER BY dl_number DESC"; http://cvs.php.net/viewvc.cgi/pearweb/public_html/release-upload.php?r1=1.82&r2=1.83&diff_format=u Index: pearweb/public_html/release-upload.php diff -u pearweb/public_html/release-upload.php:1.82 pearweb/public_html/release-upload.php:1.83 --- pearweb/public_html/release-upload.php:1.82 Tue Apr 17 22:25:43 2007 +++ pearweb/public_html/release-upload.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: release-upload.php,v 1.82 2007/04/17 22:25:43 cellog Exp $ + $Id: release-upload.php,v 1.83 2007/04/22 01:51:36 dufuz Exp $ */ auth_require('pear.dev'); @@ -99,11 +99,15 @@ $errors[] = 'No package.xml found in this release'; break; } + + include_once 'pear-database-package.php'; $pacid = package::info($info->getPackage(), 'id'); if (PEAR::isError($pacid)) { $errors[] = $pacid->getMessage(); break; } + + include_once 'pear-database-user.php'; if (!auth_check('pear.admin') && !auth_check('pear.qa') && !user::maintains($auth_user->handle, $pacid, 'lead')) { @@ -131,12 +135,16 @@ 'active' => !isset($user['active']) || $user['active'] == 'yes', ); } + + include_once 'pear-database-maintainer.php'; $e = maintainer::updateAll($pacid, $users); if (PEAR::isError($e)) { $errors[] = $e->getMessage(); break; } $pear_rest->savePackageMaintainerREST($info->getPackage()); + + include_once 'pear-database-release.php'; $file = release::upload($info->getPackage(), $info->getVersion(), $info->getState(), $info->getNotes(), $distfile, md5_file($distfile), $info, $packagexml, @@ -151,6 +159,7 @@ @unlink($distfile); PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, 'report_warning'); + include_once 'pear-database-release.php'; if (is_a($info, 'PEAR_PackageFile_v1') || is_a($info, 'PEAR_PackageFile_v2')) { release::promote_v2($info, $file); } else { @@ -258,7 +267,8 @@ } $errors[] = $info->getMessage(); } else { - $id = package::info($info->getPackage(), 'id'); + include_once 'pear-database-package.php'; + $id = package::info($info->getPackage(), 'id'); $name = package::info($info->getPackage(), 'name'); if ($info->getPackage() != $name) { // case does not match @@ -373,6 +383,7 @@ return true; } // Try to see if the user is an admin + include_once 'pear-database-user.php'; $res = user::isAdmin($user); return ($res === true); } http://cvs.php.net/viewvc.cgi/pearweb/public_html/about/forgot-password.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/public_html/about/forgot-password.php diff -u pearweb/public_html/about/forgot-password.php:1.4 pearweb/public_html/about/forgot-password.php:1.5 --- pearweb/public_html/about/forgot-password.php:1.4 Thu Mar 8 02:58:32 2007 +++ pearweb/public_html/about/forgot-password.php Sun Apr 22 01:51:36 2007 @@ -16,7 +16,7 @@ | Authors: Martin Jansen <mj@php.net> | | Gregory Beaver <cellog@php.net> | +----------------------------------------------------------------------+ - $Id: forgot-password.php,v 1.4 2007/03/08 02:58:32 cellog Exp $ + $Id: forgot-password.php,v 1.5 2007/04/22 01:51:36 dufuz Exp $ */ $errors = array(); if (isset($_POST['resetpass'])) { @@ -34,6 +34,8 @@ $errors[] = 'Passwords do not match'; } } + + include_once 'pear-database-user.php'; if (array('handle' => $_POST['handle']) != user::info($_POST['handle'], 'handle')) { $errors[] = 'Unknown user "' . $_POST['handle'] . '"'; $_POST['handle'] = ''; http://cvs.php.net/viewvc.cgi/pearweb/public_html/account/password-confirm-change.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/account/password-confirm-change.php diff -u pearweb/public_html/account/password-confirm-change.php:1.1 pearweb/public_html/account/password-confirm-change.php:1.2 --- pearweb/public_html/account/password-confirm-change.php:1.1 Thu Mar 8 02:58:32 2007 +++ pearweb/public_html/account/password-confirm-change.php Sun Apr 22 01:51:36 2007 @@ -10,6 +10,7 @@ if (!isset($_POST['handle']) || empty($_POST['handle'])) { $errors[] = 'Please enter Username'; } else { + include_once 'pear-database-user.php'; if (array('handle' => $_POST['handle']) != user::info($_POST['handle'], 'handle')) { $errors[] = 'Unknown user "' . $_POST['handle'] . '"'; } http://cvs.php.net/viewvc.cgi/pearweb/public_html/admin/category-manager.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/public_html/admin/category-manager.php diff -u pearweb/public_html/admin/category-manager.php:1.4 pearweb/public_html/admin/category-manager.php:1.5 --- pearweb/public_html/admin/category-manager.php:1.4 Sat Sep 10 13:21:49 2005 +++ pearweb/public_html/admin/category-manager.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Richard Heyes | +----------------------------------------------------------------------+ - $Id: category-manager.php,v 1.4 2005/09/10 13:21:49 pajoye Exp $ + $Id: category-manager.php,v 1.5 2007/04/22 01:51:36 dufuz Exp $ */ auth_require(true); @@ -31,7 +31,7 @@ */ $template_dir = dirname(dirname(__FILE__)) . '/../templates/'; - + /** * Function to recurse thru the tree adding nodes to treemenu */ @@ -40,20 +40,20 @@ global $dbh; $parent = is_null($parent) ? 'IS NULL' : '= ' . $parent; - + // Get categories $categories = $dbh->getAll(sprintf('SELECT id, parent, name, description, npackages ' - . 'FROM categories WHERE parent %s ORDER BY name, id', + . 'FROM categories WHERE parent %s ORDER BY name, id', $parent - ), - null, + ), + null, DB_FETCHMODE_ASSOC ); if (count($categories)) { foreach ($categories as $cat) { $newNode = &$structure->addItem(new HTML_TreeNode(array('text' => htmlspecialchars($cat['name']), - 'icon' => 'folder.gif'), + 'icon' => 'folder.gif'), array('onclick' => 'category_click(event, this, ' . $cat['id'] . ')') ) ); @@ -66,7 +66,8 @@ * Form submitted? */ if (!empty($_POST)) { - include_once '../../include/pear-category.php'; + include_once 'pear-category.php'; + include_once 'pear-database-category.php'; switch (@$_POST['action']) { case 'add': @@ -105,13 +106,13 @@ localRedirect('/admin/category-manager.php'); } } - + /** * Create the menu, set the db to assoc mode */ require_once('HTML/TreeMenu.php'); $treeMenu = new HTML_TreeMenu(); - + /** * Get the categories */ http://cvs.php.net/viewvc.cgi/pearweb/public_html/admin/index.php?r1=1.21&r2=1.22&diff_format=u Index: pearweb/public_html/admin/index.php diff -u pearweb/public_html/admin/index.php:1.21 pearweb/public_html/admin/index.php:1.22 --- pearweb/public_html/admin/index.php:1.21 Sat Mar 31 03:59:09 2007 +++ pearweb/public_html/admin/index.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: index.php,v 1.21 2007/03/31 03:59:09 cellog Exp $ + $Id: index.php,v 1.22 2007/04/22 01:51:36 dufuz Exp $ */ auth_require(true); @@ -47,10 +47,12 @@ if (!empty($_REQUEST['cmd'])) { if ($_REQUEST['cmd'] == "Add note" && !empty($_REQUEST['note']) && !empty($_REQUEST['key']) && !empty($_REQUEST['id'])) { + include_once 'pear-database-note.php'; note::add($_REQUEST['key'], $_REQUEST['id'], $_REQUEST['note']); unset($_REQUEST['cmd']); } elseif ($_REQUEST['cmd'] == "Delete note" && !empty($_REQUEST['id'])) { + include_once 'pear-database-note.php'; /** * Delete note */ @@ -64,15 +66,17 @@ $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'])); print "<p>Opened account $uid...</p>\n"; } - + } elseif ($_REQUEST['cmd'] == "Reject Request" && !empty($_REQUEST['uid'])) { /** * Reject account request */ + include_once 'pear-database-user.php'; if (is_array($_REQUEST['uid'])) { foreach ($_REQUEST['uid'] as $uid) { user::rejectRequest($uid, $_REQUEST['reason']); @@ -87,13 +91,14 @@ /** * Delete account request */ + include_once 'pear-database-user.php'; if (is_array($_REQUEST['uid'])) { foreach ($_REQUEST['uid'] as $uid) { user::remove($uid); echo 'Account request deleted: ' . $uid . '<br />'; } - - + + } elseif (user::remove($_REQUEST['uid'])) { print "<p>Deleted account request for \"$uid\"...</p>"; } @@ -144,6 +149,7 @@ // {{{ "approve account request" form if (!empty($acreq)) { + include_once 'pear-database-user.php'; $requser =& new PEAR_User($dbh, $acreq); if (empty($requser->name)) { break; @@ -201,7 +207,7 @@ print "$i </tr>\n"; print "$i</table>\n"; print "$i</form>\n"; - + $bb->end(); ?> @@ -275,7 +281,7 @@ function highlightAccountRow(spanObj) { var highlightColor = '#cfffb7'; - + if (typeof(arguments[1]) == 'undefined') { action = (spanObj.parentNode.parentNode.childNodes[0].style.backgroundColor == highlightColor); } else { @@ -294,22 +300,22 @@ } } } - + allSelected = false; - + function toggleSelectAll(linkElement) { tableBodyElement = linkElement.parentNode.parentNode.parentNode.parentNode; - + for (var i=0; i<tableBodyElement.childNodes.length; i++) { if (tableBodyElement.childNodes[i].childNodes[0].childNodes[0].tagName == 'INPUT') { highlightAccountRow(tableBodyElement.childNodes[i].childNodes[1].childNodes[0], !allSelected); } } - + allSelected = !allSelected; } - + function setCmdInput(mode) { switch (mode) { @@ -330,7 +336,7 @@ } break; } - + return false; } //--> http://cvs.php.net/viewvc.cgi/pearweb/public_html/admin/karma.php?r1=1.11&r2=1.12&diff_format=u Index: pearweb/public_html/admin/karma.php diff -u pearweb/public_html/admin/karma.php:1.11 pearweb/public_html/admin/karma.php:1.12 --- pearweb/public_html/admin/karma.php:1.11 Fri Mar 30 03:34:18 2007 +++ pearweb/public_html/admin/karma.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: karma.php,v 1.11 2007/03/30 03:34:18 cellog Exp $ + $Id: karma.php,v 1.12 2007/04/22 01:51:36 dufuz Exp $ */ require_once "Damblan/Karma.php"; @@ -50,6 +50,7 @@ } else { if (!empty($_GET['action'])) { + include_once 'pear-database-note.php'; switch ($_GET['action']) { case "remove" : @@ -69,7 +70,7 @@ echo "Successfully <b>added</b> karma &quot;" . htmlspecialchars($_POST['level']) . "&quot;<br /><br />"; - + note::add('uid', $handle, 'added ' . $_GET['level'] . ' karma', $auth_user->handle); } @@ -92,7 +93,7 @@ htmlspecialchars($item['granted_by']), htmlspecialchars($item['granted_at']), make_link($remove, make_image("delete.gif"), - false, + false, 'onclick="javascript:return confirm(\'Do you really want to remove the karma level ' . htmlspecialchars($item['level' ]) . '?\');"')); } $bb->end(); http://cvs.php.net/viewvc.cgi/pearweb/public_html/admin/package-approval.php?r1=1.15&r2=1.16&diff_format=u Index: pearweb/public_html/admin/package-approval.php diff -u pearweb/public_html/admin/package-approval.php:1.15 pearweb/public_html/admin/package-approval.php:1.16 --- pearweb/public_html/admin/package-approval.php:1.15 Thu Sep 28 20:24:48 2006 +++ pearweb/public_html/admin/package-approval.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: package-approval.php,v 1.15 2006/09/28 20:24:48 mj Exp $ + $Id: package-approval.php,v 1.16 2007/04/22 01:51:36 dufuz Exp $ */ auth_require("pear.admin"); @@ -46,6 +46,7 @@ if ($action == 'approved') { $pear_rest->savePackageREST($row['name']); $pear_rest->saveAllPackagesREST(); + include_once 'pear-database-package.php'; $pear_rest->savePackagesCategoryREST(package::info($row['name'], 'category')); } // {{{ Logging mechanism @@ -80,7 +81,7 @@ . "updating the database or the package has already been " . $action . " by someone else.<br /><br />"; } -} +} $query = "SELECT * FROM packages WHERE approved = 0 AND package_type = 'pear'"; $rows = $dbh->getAll($query, null, DB_FETCHMODE_ASSOC); @@ -92,7 +93,7 @@ $bb = new BorderBox("Unapproved packages", "90%", "", 2, true); foreach ($rows as $row) { - $bb->plainRow($row['name'], + $bb->plainRow($row['name'], make_link("$self?approve=" . $row['id'], "Approve") . delim() . make_link("$self?reject=" . $row['id'], "Reject") http://cvs.php.net/viewvc.cgi/pearweb/public_html/admin/package-maintainers.php?r1=1.24&r2=1.25&diff_format=u Index: pearweb/public_html/admin/package-maintainers.php diff -u pearweb/public_html/admin/package-maintainers.php:1.24 pearweb/public_html/admin/package-maintainers.php:1.25 --- pearweb/public_html/admin/package-maintainers.php:1.24 Sun Dec 31 09:38:04 2006 +++ pearweb/public_html/admin/package-maintainers.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Pierre-Alain Joye <pajoye@php.net> | +----------------------------------------------------------------------+ - $Id: package-maintainers.php,v 1.24 2006/12/31 09:38:04 arnaud Exp $ + $Id: package-maintainers.php,v 1.25 2007/04/22 01:51:36 dufuz Exp $ */ auth_require(); @@ -27,11 +27,12 @@ report_error('Invalid package'); } +include_once 'pear-database-package.php'; $package_name = package::info($pid, 'name'); response_header('Administration - ' . htmlspecialchars($package_name) . ' - Package Maintainers'); - +include_once 'pear-database-maintainer.php'; $maintainers = maintainer::get($pid); // Maintainer being lead can go further, if not QA and up @@ -45,6 +46,7 @@ if (isset($_POST['handle']['new']) && !empty($_POST['handle']['new'])) { $new = strip_tags($_POST['handle']['new']); + include_once 'pear-database-user.php'; if (!ereg('^[0-9a-z_]{2,20}$', $new)) { report_error('Invalid handle: ' . $new); } elseif (!user::exists($new)) { http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/roadmap.php?r1=1.17&r2=1.18&diff_format=u Index: pearweb/public_html/bugs/roadmap.php diff -u pearweb/public_html/bugs/roadmap.php:1.17 pearweb/public_html/bugs/roadmap.php:1.18 --- pearweb/public_html/bugs/roadmap.php:1.17 Sun Apr 8 22:38:21 2007 +++ pearweb/public_html/bugs/roadmap.php Sun Apr 22 01:51:36 2007 @@ -83,6 +83,7 @@ } } $bugtest = Bug_DataObject::pearDB('maintains'); + include_once 'pear-database-package.php'; $bugtest->package = package::info($_GET['package'], 'id'); $bugtest->handle = $auth_user->handle; if (!$bugtest->find(true) || !$bugtest->role == 'lead') { @@ -260,6 +261,7 @@ $features = clone($bugdb); $bugdb->whereAdd('bug_type IN ("Bug", "Documentation Bug")'); $releases = Bug_DataObject::pearDB('releases'); + include_once 'pear-database-package.php'; $releases->package = package::info($_GET['package'], 'id'); $releases->orderBy('releasedate DESC'); if ($releases->find(true)) { @@ -393,6 +395,7 @@ $bugdb->limit($begin, $limit); } +include_once 'pear-database-package.php'; $releases = package::info($_GET['package'], 'releases'); $savant->showold = isset($_GET['showold']); $savant->releases = array_keys($releases); @@ -417,30 +420,30 @@ if (isset($_GET['roadmapdetail']) && $_GET['roadmapdetail'] === $allroadmaps->roadmap_version) { $features = clone($bugdb); $bugs = clone($bugdb); - + $roadmaps->roadmap_id = $allroadmaps->id; $features->selectAs(); $features->joinAdd($roadmaps); $features->bug_type = 'Feature/Change Request'; $rows = $features->find(false); - + if ($mysql4) { $total_rows = $dbh->getOne('SELECT FOUND_ROWS()'); } else { /* lame mysql 3 compatible attempt to allow browsing the search */ $total_rows = $rows < 10 ? $rows : $begin + $rows + 10; } - + if ($rows) { $package_string = ''; - + $link = 'roadmap.php' . '?' . $package_string . '&amp;order_by=' . $order_by . '&amp;direction=' . $direction . '&amp;limit=' . $limit; - + $savant->begin = $begin; $savant->rows = $rows; $savant->total_rows = $total_rows; @@ -457,29 +460,29 @@ } else { $features = 'None'; } - + $bugs->bug_type = 'Bug'; $bugs->selectAs(); $bugs->joinAdd($roadmaps); $rows = $bugs->find(false); - + if ($mysql4) { $total_rows = $dbh->getOne('SELECT FOUND_ROWS()'); } else { /* lame mysql 3 compatible attempt to allow browsing the search */ $total_rows = $rows < 10 ? $rows : $begin + $rows + 10; } - + if ($rows) { $package_string = ''; - + $link = 'roadmap.php' . '?' . $package_string . '&amp;order_by=' . $order_by . '&amp;direction=' . $direction . '&amp;limit=' . $limit; - + $savant->begin = $begin; $savant->rows = $rows; $savant->total_rows = $total_rows; http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/stats.php?r1=1.50&r2=1.51&diff_format=u Index: pearweb/public_html/bugs/stats.php diff -u pearweb/public_html/bugs/stats.php:1.50 pearweb/public_html/bugs/stats.php:1.51 --- pearweb/public_html/bugs/stats.php:1.50 Thu Apr 12 03:15:55 2007 +++ pearweb/public_html/bugs/stats.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ * @package Bugs * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: stats.php,v 1.50 2007/04/12 03:15:55 cellog Exp $ + * @version $Id: stats.php,v 1.51 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -144,6 +144,7 @@ /* * Fetch list of all categories */ +include_once 'pear-database-category.php'; $res = category::listAll(); ?> http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/include/functions.inc?r1=1.141&r2=1.142&diff_format=u Index: pearweb/public_html/bugs/include/functions.inc diff -u pearweb/public_html/bugs/include/functions.inc:1.141 pearweb/public_html/bugs/include/functions.inc:1.142 --- pearweb/public_html/bugs/include/functions.inc:1.141 Tue Apr 10 03:31:46 2007 +++ pearweb/public_html/bugs/include/functions.inc Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ * @package Bugs * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: functions.inc,v 1.141 2007/04/10 03:31:46 cellog Exp $ + * @version $Id: functions.inc,v 1.142 2007/04/22 01:51:36 dufuz Exp $ */ @@ -859,7 +859,7 @@ /* if a developer assigns someone else, let that other person know about it */ if ($edit == 1 && $in['assign'] && $in['assign'] != $bug['assign']) { - + include_once 'pear-database-user.php'; $info = user::info($in['assign'], "email"); $email = $info['email']; @@ -1058,6 +1058,7 @@ return array(PEAR_DOC_EMAIL, PEAR_DOC_EMAIL); } + include_once 'pear-database-package.php'; $maintainers = package::info($package_name, 'authors'); $to = array(); @@ -1298,7 +1299,7 @@ $dbh->query($query); return true; } - + class Bug_DataObject { http://cvs.php.net/viewvc.cgi/pearweb/public_html/error/404.php?r1=1.26&r2=1.27&diff_format=u Index: pearweb/public_html/error/404.php diff -u pearweb/public_html/error/404.php:1.26 pearweb/public_html/error/404.php:1.27 --- pearweb/public_html/error/404.php:1.26 Mon Jul 11 19:47:43 2005 +++ pearweb/public_html/error/404.php Sun Apr 22 01:51:36 2007 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: 404.php,v 1.26 2005/07/11 19:47:43 mj Exp $ + $Id: 404.php,v 1.27 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -31,6 +31,7 @@ */ if (strlen($_SERVER['REDIRECT_URL']) > 0 && $_SERVER['REDIRECT_URL']{1} == '~') { $user = substr($_SERVER['REDIRECT_URL'], 2); + include_once 'pear-database-user.php'; if (preg_match(PEAR_COMMON_USER_NAME_REGEX, $user) && user::exists($user)) { localRedirect("/user/" . urlencode($user)); } @@ -41,6 +42,7 @@ $pinfo_url = '/package/'; // Check strictly +include_once 'pear-database-package.php'; $name = package::info(basename($pkg), 'name'); if (!DB::isError($name)) { if (!empty($name)) { @@ -83,7 +85,7 @@ Searching the current list of packages for <i><?php echo basename(strip_tags($_SERVER['REQUEST_URI'])); ?></i> included the following results: - + <ul> <?php foreach($packages as $p) { ?> <li> @@ -92,7 +94,7 @@ </li> <?php } ?> </ul> - + <?php if($show_search_link) { ?> <p align="center"> <?php print_link(getURL('/search.php?q=' . basename(strip_tags($_SERVER['REQUEST_URI']))), 'View full search results...'); ?> http://cvs.php.net/viewvc.cgi/pearweb/public_html/feeds/feeds.php?r1=1.10&r2=1.11&diff_format=u Index: pearweb/public_html/feeds/feeds.php diff -u pearweb/public_html/feeds/feeds.php:1.10 pearweb/public_html/feeds/feeds.php:1.11 --- pearweb/public_html/feeds/feeds.php:1.10 Sat Oct 21 00:20:13 2006 +++ pearweb/public_html/feeds/feeds.php Sun Apr 22 01:51:36 2007 @@ -15,10 +15,10 @@ +----------------------------------------------------------------------+ | Authors: Pierre-Alain Joye <pajoye@php.net> | +----------------------------------------------------------------------+ - $Id: feeds.php,v 1.10 2006/10/21 00:20:13 cellog Exp $ + $Id: feeds.php,v 1.11 2007/04/22 01:51:36 dufuz Exp $ */ -require_once "pepr/pepr.php"; +require_once 'pepr/pepr.php'; function rss_bailout() { header('HTTP/1.0 404 Not Found'); @@ -116,14 +116,14 @@ switch ($type) { case 'latest': - include_once 'pear-database.php'; + include_once 'pear-database-release.php'; $items = release::getRecent(10); $channel_title = 'PEAR: Latest releases'; $channel_description = 'The latest releases in PEAR.'; break; case 'popular': - include_once 'pear-database.php'; + include_once 'pear-database-release.php'; $items = release::getPopular(10, true); foreach ($items as $i => $item) { $items[$i]['releasenotes'] = 'Downloads per day: ' . number_format($item['releasenotes'], 2); @@ -134,6 +134,7 @@ case 'user': $user = $argument; + include_once 'pear-database-user.php'; if (!user::exists($user)) { rss_bailout(); } @@ -146,6 +147,7 @@ case 'pkg': $package = $argument; + include_once 'pear-database-package.php'; if (package::isValid($package) == false) { rss_bailout(); return PEAR::raiseError("The requested URL " . $_SERVER['REQUEST_URI'] . " was not found on this server."); @@ -159,6 +161,7 @@ case 'cat': $category = $argument; + include_once 'pear-database-category.php'; if (category::isValid($category) == false) { rss_bailout(); } http://cvs.php.net/viewvc.cgi/pearweb/public_html/pepr/index.php?r1=1.7&r2=1.8&diff_format=u Index: pearweb/public_html/pepr/index.php diff -u pearweb/public_html/pepr/index.php:1.7 pearweb/public_html/pepr/index.php:1.8 --- pearweb/public_html/pepr/index.php:1.7 Thu Jun 15 20:02:35 2006 +++ pearweb/public_html/pepr/index.php Sun Apr 22 01:51:36 2007 @@ -19,7 +19,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: index.php,v 1.7 2006/06/15 20:02:35 mj Exp $ + * @version $Id: index.php,v 1.8 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -40,7 +40,7 @@ if (isset($_GET['search'])) { $searchString = trim($_GET['search']); $searchString = preg_replace('/;/', '', $searchString); - $proposals = proposal::search($searchString); + $proposals = proposal::search($searchString); $searchPostfix = '_search_'.urlencode($searchString); } else { $proposals =& proposal::getAll($dbh, @$selectStatus, null, @$order); @@ -94,6 +94,8 @@ break; } } + + include_once 'pear-database-user.php'; if (!isset($users[$proposal->user_handle])) { $users[$proposal->user_handle] = user::info($proposal->user_handle); } http://cvs.php.net/viewvc.cgi/pearweb/public_html/pepr/pepr-comments-show.php?r1=1.20&r2=1.21&diff_format=u Index: pearweb/public_html/pepr/pepr-comments-show.php diff -u pearweb/public_html/pepr/pepr-comments-show.php:1.20 pearweb/public_html/pepr/pepr-comments-show.php:1.21 --- pearweb/public_html/pepr/pepr-comments-show.php:1.20 Fri Aug 25 13:08:05 2006 +++ pearweb/public_html/pepr/pepr-comments-show.php Sun Apr 22 01:51:36 2007 @@ -17,7 +17,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: pepr-comments-show.php,v 1.20 2006/08/25 13:08:05 pajoye Exp $ + * @version $Id: pepr-comments-show.php,v 1.21 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -156,6 +156,7 @@ if (is_array($comments) && (count($comments) > 0)) { echo ' <td class="ulcell" valign="top">' . "\n"; echo ' <ul class="spaced">' . "\n"; + include_once 'pear-database-user.php'; foreach ($comments as $comment) { if (empty($userInfos[$comment->user_handle])) { $userInfos[$comment->user_handle] = user::info($comment->user_handle); http://cvs.php.net/viewvc.cgi/pearweb/public_html/pepr/pepr-proposal-edit.php?r1=1.51&r2=1.52&diff_format=u Index: pearweb/public_html/pepr/pepr-proposal-edit.php diff -u pearweb/public_html/pepr/pepr-proposal-edit.php:1.51 pearweb/public_html/pepr/pepr-proposal-edit.php:1.52 --- pearweb/public_html/pepr/pepr-proposal-edit.php:1.51 Sat Mar 17 21:14:24 2007 +++ pearweb/public_html/pepr/pepr-proposal-edit.php Sun Apr 22 01:51:36 2007 @@ -20,7 +20,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: pepr-proposal-edit.php,v 1.51 2007/03/17 21:14:24 cellog Exp $ + * @version $Id: pepr-proposal-edit.php,v 1.52 2007/04/22 01:51:36 dufuz Exp $ */ auth_require('pear.pepr'); @@ -99,6 +99,7 @@ </tr> '); +include_once 'pear-database-category.php'; $categories = category::listAll(); $mapCategories['RFC'] = 'RFC (No package category!)'; foreach ($categories as $categorie) { @@ -113,7 +114,7 @@ * Dropdown possible licenses, less confusing for users */ $possibleLicenses = array( - 'PHP License 3.01' => 'PHP License 3.01', + 'PHP License 3.01' => 'PHP License 3.01', 'Apache License' => 'Apache License', 'LGPL' => 'LGPL', 'BSD Style' => 'BSD Style', @@ -126,27 +127,27 @@ /** * Easy codes. makes it easier for people to put - * bb codes + * bb codes */ -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Bold', +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Bold', array('onclick' => "insertTags('pkg_description', '[b]', '[/b]','bold')")); -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Italic', - array('onclick' => +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Italic', + array('onclick' => "insertTags('pkg_description', '[i]', '[/i]','italic')")); -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Underline', +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Underline', array('onclick' => "insertTags('pkg_description', '[u]', '[/u]','underline')")); -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Red Txt', +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'Red Txt', array('onclick' => "insertTags('pkg_description', '[color=red]', '[/color]','red text')")); -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'PHPCode', +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'PHPCode', array('onclick' => "insertTags('pkg_description', '[code=php]', '[/code]','print \'php code\';')")); -$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'List', - array('onclick' => +$bbhelpers[] = HTML_QuickForm::createElement('link', null, '_blank', '#', 'List', + array('onclick' => "insertTags('pkg_description', '[list]\\n[*]', '\\n[/list]','list')")); $form->addGroup($bbhelpers, 'markup_help', 'BB Helpers (beta)', ' | '); http://cvs.php.net/viewvc.cgi/pearweb/public_html/pepr/pepr-proposal-show.php?r1=1.55&r2=1.56&diff_format=u Index: pearweb/public_html/pepr/pepr-proposal-show.php diff -u pearweb/public_html/pepr/pepr-proposal-show.php:1.55 pearweb/public_html/pepr/pepr-proposal-show.php:1.56 --- pearweb/public_html/pepr/pepr-proposal-show.php:1.55 Wed Nov 1 23:18:46 2006 +++ pearweb/public_html/pepr/pepr-proposal-show.php Sun Apr 22 01:51:36 2007 @@ -17,7 +17,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: pepr-proposal-show.php,v 1.55 2006/11/01 23:18:46 cellog Exp $ + * @version $Id: pepr-proposal-show.php,v 1.56 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -113,7 +113,7 @@ } ?> - + </ul> </td> </tr> @@ -209,6 +209,7 @@ 'package_proposal_changelog')) { echo "<ul>\n"; + include_once 'pear-database-user.php'; foreach ($changelog as $comment) { if (!isset($userinfos[$comment->user_handle])) { $userinfo[$comment->user_handle] = user::info($comment->user_handle); @@ -227,7 +228,7 @@ case 'bbcode': default: require_once 'HTML/BBCodeParser.php'; - $bbparser = new HTML_BBCodeParser(array('filters' => 'Basic,Images,Links,Lists,Extended')); + $bbparser = new HTML_BBCodeParser(array('filters' => 'Basic,Images,Links,Lists,Extended')); echo nl2br($bbparser->qparse($comment->comment)); break; } http://cvs.php.net/viewvc.cgi/pearweb/public_html/pepr/pepr-votes-show.php?r1=1.9&r2=1.10&diff_format=u Index: pearweb/public_html/pepr/pepr-votes-show.php diff -u pearweb/public_html/pepr/pepr-votes-show.php:1.9 pearweb/public_html/pepr/pepr-votes-show.php:1.10 --- pearweb/public_html/pepr/pepr-votes-show.php:1.9 Fri Aug 25 13:08:05 2006 +++ pearweb/public_html/pepr/pepr-votes-show.php Sun Apr 22 01:51:36 2007 @@ -17,7 +17,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: pepr-votes-show.php,v 1.9 2006/08/25 13:08:05 pajoye Exp $ + * @version $Id: pepr-votes-show.php,v 1.10 2007/04/22 01:51:36 dufuz Exp $ */ /** @@ -248,6 +248,7 @@ echo ' <td class="ulcell" valign="top">' . "\n<ul>\n"; + include_once 'pear-database-user.php'; foreach ($proposal->votes as $vote) { if (!isset($users[$vote->user_handle])) { $users[$vote->user_handle] =& user::info($vote->user_handle); http://cvs.php.net/viewvc.cgi/pearweb/public_html/trackback/trackback.php?r1=1.24&r2=1.25&diff_format=u Index: pearweb/public_html/trackback/trackback.php diff -u pearweb/public_html/trackback/trackback.php:1.24 pearweb/public_html/trackback/trackback.php:1.25 --- pearweb/public_html/trackback/trackback.php:1.24 Tue Mar 13 22:49:56 2007 +++ pearweb/public_html/trackback/trackback.php Sun Apr 22 01:51:36 2007 @@ -17,7 +17,7 @@ | Authors: Tobias Schlitt <toby@php.net> | | | +----------------------------------------------------------------------+ - $Id: trackback.php,v 1.24 2007/03/13 22:49:56 cellog Exp $ + $Id: trackback.php,v 1.25 2007/04/22 01:51:36 dufuz Exp $ */ @@ -48,6 +48,7 @@ } // Sanity check, see if package exists +include_once 'pear-database-package.php'; $testid = package::info($id, 'id'); if (!$testid || PEAR::isError($testid)) { echo Services_Trackback::getResponseError('No package with ID '.$id.' found. Trackback not possible.', 1); http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-category.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-category.php +++ pearweb/include/pear-database-category.php <?php /* +----------------------------------------------------------------------+ | PEAR Web site version 1.0 | +----------------------------------------------------------------------+ | Copyright (c) 2001-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Stig S. Bakken <ssb@fast.no> | | Tomas V.V. Cox <cox@php.net> | | Martin Jansen <mj@php.net> | | Richard Heyes <richard@php.net> | +----------------------------------------------------------------------+ $Id: pear-database-category.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ // These classes correspond to tables and methods define operations on // each. They are packaged into classes for easier xmlrpc // integration. /** * Class to handle categories * * @class category * @package pearweb * @author Stig S. Bakken <ssb@fast.no> * @author Tomas V.V. Cox <cox@php.net> * @author Martin Jansen <mj@php.net> * @author Richard Heyes <richard@php.net> */ class category { // {{{ *proto int category::add(struct) API 1.0 /** * Add new category * * $data = array( * 'name' => 'category name', * 'desc' => 'category description', * 'parent' => 'category parent id' * ); * * @param array * @return mixed ID of the category or PEAR error object */ function add($data) { global $dbh; $name = $data['name']; if (empty($name)) { return PEAR::raiseError('no name given'); } $desc = (empty($data['desc'])) ? 'none' : $data['desc']; $parent = (empty($data['parent'])) ? null : $data['parent']; $sql = 'INSERT INTO categories (id, name, description, parent)'. 'VALUES (?, ?, ?, ?)'; $id = $dbh->nextId('categories'); $err = $dbh->query($sql, array($id, $name, $desc, $parent)); if (DB::isError($err)) { return $err; } $err = renumber_visitations($id, $parent); if (PEAR::isError($err)) { return $err; } $GLOBALS['pear_rest']->saveCategoryREST($name); $GLOBALS['pear_rest']->saveAllCategoriesREST(); return $id; } /** * Updates a categories details * * @param integer $id Category ID * @param string $name Category name * @param string $desc Category Description * @return mixed True on success, pear_error otherwise */ function update($id, $name, $desc = '') { return $GLOBALS['dbh']->query(sprintf('UPDATE categories SET name = %s, description = %s WHERE id = %d', $GLOBALS['dbh']->quote($name), $GLOBALS['dbh']->quote($desc), $id)); } /** * Deletes a category * * @param integer $id Cateogry ID */ function delete($id) { // if ($GLOBALS['dbh']->query('SELECT COUNT(*) FROM categories WHERE parent = ' . (int)$id) > 0) { // return PEAR::raiseError('Cannot delete a category which has subcategories'); // } // // // Get parent ID if any // $parentID = $GLOBALS['dbh']->getOne('SELECT parent FROM categories WHERE id = ' . $id); // if (!$parentID) { // $nextID = $GLOBALS['dbh']->getOne('SELECT id FROM categories WHERE cat_left = ' . $GLOBALS['dbh']->getOne('SELECT cat_right + 1 FROM categories WHERE id = ' . $id)); // } else { // $nextID = $parentID; // } $name = $GLOBALS['dbh']->getOne('SELECT name FROM categories WHERE id = ?', array($id)); // Get parent ID if any $parentID = $GLOBALS['dbh']->getOne('SELECT parent FROM categories WHERE id = ' . $id); // Delete it $deleted_cat_left = $GLOBALS['dbh']->getOne('SELECT cat_left FROM categories WHERE id = ' . $id); $deleted_cat_right = $GLOBALS['dbh']->getOne('SELECT cat_right FROM categories WHERE id = ' . $id); $GLOBALS['dbh']->query('DELETE FROM categories WHERE id = ' . $id); // Renumber $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 1, cat_right = cat_right - 1 WHERE cat_left > ' . $deleted_cat_left . ' AND cat_right < ' . $deleted_cat_right); $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 2, cat_right = cat_right - 2 WHERE cat_right > ' . $deleted_cat_right); // Update any child categories $GLOBALS['dbh']->query(sprintf('UPDATE categories SET parent = %s WHERE parent = %d', ($parentID ? $parentID : 'NULL'), $id)); $GLOBALS['pear_rest']->deleteCategoryREST($name); return true; } // }}} // {{{ proto array category::listAll() API 1.0 /** * List all categories * * @return array */ function listAll() { global $dbh; return $dbh->getAll("SELECT * FROM categories ORDER BY name", null, DB_FETCHMODE_ASSOC); } // }}} // {{{ proto array category::listPackages(string) API 1.0 /** * Return a list of packages in this category * * @param string $category * @return array */ function listPackages($category) { global $dbh; $query = 'SELECT p.id, p.name FROM packages p, categories c WHERE p.category = c.id AND c.name = ?'; $recent = $dbh->getAll($query, array($category), DB_FETCHMODE_ASSOC); return $recent; } // }}} // {{{ proto array category::getRecent(int, string) API 1.0 /** * Get list of recent releases for the given category * * @param int Number of releases to return * @param string Name of the category * @return array */ function getRecent($n, $category) { global $dbh; $recent = array(); $query = "SELECT p.id AS id, " . "p.name AS name, " . "p.summary AS summary, " . "r.version AS version, " . "r.releasedate AS releasedate, " . "r.releasenotes AS releasenotes, " . "r.doneby AS doneby, " . "r.state AS state " . "FROM packages p, releases r, categories c " . "WHERE p.package_type = 'pear' AND p.id = r.package " . "AND p.category = c.id AND c.name = '" . $category . "'" . "ORDER BY r.releasedate DESC"; $sth = $dbh->limitQuery($query, 0, $n); while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } // }}} // {{{ *proto bool category::isValid(string) API 1.0 /** * Determines if the given category is valid * * @access public * @param string Name of the category * @return boolean */ function isValid($category) { global $dbh; $query = "SELECT id FROM categories WHERE name = ?"; $sth = $dbh->query($query, array($category)); return ($sth->numRows() > 0); } // }}} } // {{{ renumber_visitations() /** * * * Some useful "visitation model" tricks: * * To find the number of child elements: * (right - left - 1) / 2 * * To find the number of child elements (including self): * (right - left + 1) / 2 * * To get all child nodes: * * SELECT * FROM table WHERE left > <self.left> AND left < <self.right> * * * To get all child nodes, including self: * * SELECT * FROM table WHERE left BETWEEN <self.left> AND <self.right> * "ORDER BY left" gives tree view * * To get all leaf nodes: * * SELECT * FROM table WHERE right-1 = left; */ function renumber_visitations($id, $parent = null) { global $dbh; if ($parent === null) { $left = $dbh->getOne("select max(cat_right) + 1 from categories where parent is null"); $left = ($left !== null) ? $left : 1; // first node } else { $left = $dbh->getOne("select cat_right from categories where id = $parent"); } $right = $left + 1; // update my self $err = $dbh->query("update categories set cat_left = $left, cat_right = $right where id = $id"); if (PEAR::isError($err)) { return $err; } if ($parent === null) { return true; } $err = $dbh->query("update categories set cat_left = cat_left+2 where cat_left > $left"); if (PEAR::isError($err)) { return $err; } // (cat_right >= $left) == update the parent but not the node itself $err = $dbh->query("update categories set cat_right = cat_right+2 where cat_right >= $left and id <> $id"); if (PEAR::isError($err)) { return $err; } return true; } // }}} http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-channel.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-channel.php +++ pearweb/include/pear-database-channel.php <?php /* +----------------------------------------------------------------------+ | PEAR Web site version 1.0 | +----------------------------------------------------------------------+ | Copyright (c) 2001-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gregory Beaver <cellog@php.net> | +----------------------------------------------------------------------+ $Id: pear-database-channel.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ class channel { /** * Add a new channel to the database * @todo add server validation * - verify it is a valid server name * - connect and retrieve the channel.xml * to verify that this is possible */ function add($name, $server) { global $dbh; $query = 'INSERT INTO channels (name) VALUES (?)'; $err = $dbh->query($query, array($name)); if (DB::isError($err)) { return $err; } // clear cache include_once 'xmlrpc-cache.php'; $cache = new XMLRPC_Cache; $cache->remove('channel.listAll', array()); } // {{{ proto array channel::listAll() API 1.0 /** * List all registered channels * @return array Format: array(array(channel server), array(channel server),... ) */ function listAll() { global $dbh; $query = 'SELECT * FROM channels'; return $dbh->getAll($query, null, DB_FETCHMODE_ORDERED); } // }}} } http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-maintainer.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-maintainer.php +++ pearweb/include/pear-database-maintainer.php <?php /** * Class to handle maintainers * * @class maintainer * @package pearweb * @author Stig S. Bakken <ssb@fast.no> * @author Tomas V.V. Cox <cox@php.net> * @author Martin Jansen <mj@php.net> */ class maintainer { // {{{ +proto int maintainer::add(int|string, string, string) API 1.0 /** * Add new maintainer * * @static * @param mixed Name of the package or it's ID * @param string Handle of the user * @param string Role of the user * @param integer Is the developer actively working on the project? * @return mixed True or PEAR error object */ function add($package, $user, $role, $active = 1) { global $dbh, $pear_rest; include_once 'pear-database-user.php'; if (!user::exists($user)) { return PEAR::raiseError("User $user does not exist"); } include_once 'pear-database-package.php'; if (is_string($package)) { $package = package::info($package, 'id'); } $err = $dbh->query("INSERT INTO maintains (handle, package, role, active) VALUES (?, ?, ?, ?)", array($user, $package, $role, (int)$active)); if (DB::isError($err)) { return $err; } $packagename = package::info($package, 'name'); $pear_rest->savePackageMaintainerREST($packagename); return true; } // }}} // {{{ proto struct maintainer::get(int|string, [bool]) API 1.0 /** * Get maintainer(s) for package * * @static * @param mixed Name of the package or it's ID * @param boolean Only return lead maintainers? * @param boolean Only get all maintainers but possibility * of getting all maintainer if active is set to false. * @return array */ function get($package, $lead = false, $active = false) { global $dbh; if (is_string($package)) { include_once 'pear-database-package.php'; $package = package::info($package, 'id'); } $query = "SELECT handle, role, active FROM maintains WHERE package = ?"; if ($lead) { $query .= " AND role = 'lead'"; } if ($active) { $query .= ' AND active = 1'; } $query .= " ORDER BY active DESC"; return $dbh->getAssoc($query, true, array($package), DB_FETCHMODE_ASSOC); } // }}} // {{{ proto struct maintainer::getByUser(string) API 1.0 /** * Get the roles of a specific user * * @static * @param string Handle of the user * @return array */ function getByUser($user) { global $dbh; $query = 'SELECT p.name, m.role FROM packages p, maintains m WHERE p.package_type = ? AND p.approved = 1 AND m.package = p.id AND m.handle = ?'; return $dbh->getAssoc($query, array('pear'), array($user)); } // }}} // {{{ proto bool maintainer::isValidRole(string) API 1.0 /** * Check if role is valid * * @static * @param string Name of the role * @return boolean */ function isValidRole($role) { require_once "PEAR/Common.php"; static $roles; if (empty($roles)) { $roles = PEAR_Common::getUserRoles(); } return in_array($role, $roles); } // }}} // {{{ +proto bool maintainer::remove(int|string, string) API 1.0 /** * Remove user from package * * @static * @param mixed Name of the package or it's ID * @param string Handle of the user * @return True or PEAR error object */ function remove($package, $user) { global $dbh, $auth_user; include_once 'pear-database-user.php'; if (!$auth_user->isAdmin() && !$auth_user->isQA() && !user::maintains($auth_user->handle, $package, 'lead')) { return PEAR::raiseError('maintainer::remove: insufficient privileges'); } if (is_string($package)) { include_once 'pear-database-package.php'; $package = package::info($package, 'id'); } $sql = "DELETE FROM maintains WHERE package = ? AND handle = ?"; return $dbh->query($sql, array($package, $user)); } // }}} // {{{ +proto bool maintainer::updateAll(int, array [,bool]) API 1.0 /** * Update user and roles of a package * * @static * @param int $pkgid The package id to update * @param array $users Assoc array containing the list of users * in the form: '<user>' => array('role' => '<role>', 'active' => '<active>') * @param bool Whether to print the logging information to the screen * @return mixed PEAR_Error or true */ function updateAll($pkgid, $users, $print = false) { require_once "Damblan/Log.php"; global $dbh, $auth_user; $admin = $auth_user->isAdmin(); $qa = $auth_user->isQA(); // Only admins and leads can do this. if (maintainer::mayUpdate($pkgid) == false) { return PEAR::raiseError('maintainer::updateAll: insufficient privileges'); } $logger = new Damblan_Log; if ($print) { require_once "Damblan/Log/Print.php"; $observer = new Damblan_Log_Print; $logger->attach($observer); } include_once 'pear-database-package.php'; $pkg_name = package::info((int)$pkgid, "name"); // Needed for logging if (empty($pkg_name)) { PEAR::raiseError('maintainer::updateAll: no such package'); } $old = maintainer::get($pkgid); if (DB::isError($old)) { return $old; } $old_users = array_keys($old); $new_users = array_keys($users); if (!$admin && !$qa && !in_array($auth_user->handle, $new_users)) { return PEAR::raiseError("You can not delete your own maintainer role or you will not ". "be able to complete the update process. Set your name ". "in package.xml or let the new lead developer upload ". "the new release"); } foreach ($users as $user => $u) { $role = $u['role']; $active = $u['active']; if (!maintainer::isValidRole($role)) { return PEAR::raiseError("invalid role '$role' for user '$user'"); } // The user is not present -> add him if (!in_array($user, $old_users)) { $e = maintainer::add($pkgid, $user, $role, $active); if (PEAR::isError($e)) { return $e; } $logger->log("[Maintainer] NEW: " . $user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle); continue; } // Users exists but the role or the "active" flag have changed -> update it if ($role != $old[$user]['role'] || $active != $old[$user]['active']) { $res = maintainer::update($pkgid, $user, $role, $active); if (DB::isError($res)) { return $res; } $logger->log("[Maintainer] UPDATE: " . $user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle); } } // Drop users who are no longer maintainers foreach ($old_users as $old_user) { if (!in_array($old_user, $new_users)) { $res = maintainer::remove($pkgid, $old_user); if (DB::isError($res)) { return $res; } $logger->log("[Maintainer] REMOVED: " . $old_user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle); } } return true; } // }}} // {{{ update /** * Update maintainer entry * * @access public * @param int Package ID * @param string Username * @param string Role * @param string Is the developer actively working on the package? */ function update($package, $user, $role, $active) { global $dbh; $query = "UPDATE maintains SET role = ?, active = ? " . "WHERE package = ? AND handle = ?"; return $dbh->query($query, array($role, $active, $package, $user)); } // }}} // {{{ NOEXPORT maintainer::mayUpdate(int) /** * Checks if the current user is allowed to update the maintainer data * * @access public * @param int ID of the package * @return boolean */ function mayUpdate($package) { global $auth_user; $admin = $auth_user->isAdmin(); $qa = $auth_user->isQA(); include_once 'pear-database-user.php'; if (!$admin && !$qa && !user::maintains($auth_user->handle, $package, 'lead')) { return false; } return true; } // }}} } http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-note.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-note.php +++ pearweb/include/pear-database-note.php <?php /** * Class to handle notes * * @class note * @package pearweb * @author Stig S. Bakken <ssb@fast.no> * @author Tomas V.V. Cox <cox@php.net> * @author Martin Jansen <mj@php.net> */ class note { // {{{ +proto bool note::add(string, int, string, string) API 1.0 function add($key, $value, $note, $author = "") { global $dbh, $auth_user; if (empty($author)) { $author = $auth_user->handle; } if (!in_array($key, array('uid', 'rid', 'cid', 'pid'), true)) { // bad hackers not allowed $key = 'uid'; } $nid = $dbh->nextId("notes"); $stmt = $dbh->prepare("INSERT INTO notes (id,$key,nby,ntime,note) ". "VALUES(?,?,?,?,?)"); $res = $dbh->execute($stmt, array($nid, $value, $author, gmdate('Y-m-d H:i'), $note)); if (DB::isError($res)) { return $res; } return true; } // }}} // {{{ +proto bool note::remove(int) API 1.0 function remove($id) { global $dbh; $id = (int)$id; $res = $dbh->query("DELETE FROM notes WHERE id = $id"); if (DB::isError($res)) { return $res; } return true; } // }}} // {{{ +proto bool note::removeAll(string, int) API 1.0 function removeAll($key, $value) { global $dbh; $res = $dbh->query("DELETE FROM notes WHERE $key = ". $dbh->quote($value)); if (DB::isError($res)) { return $res; } return true; } // }}} // {{{ function getAll($user) { global $dbh; return $dbh->getAll('SELECT id, nby, ntime, note FROM notes' . ' WHERE uid = ? ORDER BY ntime', array($user)); } // }}} } http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-package.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-package.php +++ pearweb/include/pear-database-package.php <?php /* +----------------------------------------------------------------------+ | PEAR Web site version 1.0 | +----------------------------------------------------------------------+ | Copyright (c) 2001-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Stig S. Bakken <ssb@fast.no> | | Tomas V.V. Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ $Id: pear-database-package.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ /** * Class to handle packages * * @class package * @package pearweb * @author Stig S. Bakken <ssb@fast.no> * @author Tomas V.V. Cox <cox@php.net> * @author Martin Jansen <mj@php.net> */ class package { // {{{ *proto int package::add(struct) API 1.0 /** * Add new package * * @param array * @return mixed ID of new package or PEAR error object */ function add($data) { global $dbh, $auth_user; // name, category // license, summary, description // lead extract($data); if (empty($license)) { $license = "PHP License"; } if (!empty($category) && (int)$category == 0) { $category = $dbh->getOne("SELECT id FROM categories WHERE name = ?", array($category)); } if (empty($category)) { return PEAR::raiseError("package::add: invalid `category' field"); } if (empty($name)) { return PEAR::raiseError("package::add: invalid `name' field"); } $query = "INSERT INTO packages (id,name,package_type,category,license,summary,description,homepage,cvs_link) VALUES(?,?,?,?,?,?,?,?,?)"; $id = $dbh->nextId("packages"); $err = $dbh->query($query, array($id, $name, $type, $category, $license, $summary, $description, $homepage, $cvs_link)); if (DB::isError($err)) { return $err; } $sql = "UPDATE categories SET npackages = npackages + 1 WHERE id = $category"; if (DB::isError($err = $dbh->query($sql))) { return $err; } if (isset($lead) && DB::isError($err = maintainer::add($id, $lead, 'lead'))) { return $err; } $event = $auth_user->handle . " (" . $auth_user->name . ") has added a new package " . $name; $mailtext = $event . "\n\nApprove: http://" . PEAR_CHANNELNAME . "/admin/package-approval.php?approve=" . $id; $mailtext .= "\nReject: http://" . PEAR_CHANNELNAME . "/admin/package-approval.php?reject=" . $id; // {{{ Logging mechanism require_once "Damblan/Log.php"; require_once "Damblan/Log/Mail.php"; // Syslog $logger = new Damblan_Log; $logger->log($event); // Logging via email $logger = new Damblan_Log_Mail; $logger->setRecipients("pear-group@php.net,arnaud@limbourg.com"); $logger->setHeader("From", $auth_user->email); $logger->setHeader("Message-Id", "<approve-request-" . $id . "@" . PEAR_CHANNELNAME . ">"); $logger->setHeader("Subject", "New package"); $logger->log($mailtext); // }}} return $id; } // }}} // {{{ proto array package::getDownloadURL(struct, [string], [string]) API 1.1 /** * Get a download URL, or an array containing the latest version and its * release info. * * If a bundle is specified, then an array of information from getDownloadURL() * will be returned * @param array an array in format: * array( * 'channel' => channel name (not used in pear), * 'package' => package name, * ['version' => specific version to retrieve,] * ['state' => specific state to retrieve,] * ['bundle' => specific bundle to retrieve,] * ) * @param string preferred_state configuration value * @param string|false installed version of this package * @return bool|array */ function getDownloadURL($packageinfo, $prefstate = 'stable', $installed = false) { if (!isset($packageinfo['package'])) { return PEAR::raiseError('getDownloadURL parameter $packageinfo must ' . 'contain a "package" index'); } if (isset($packageinfo['channel']) && $packageinfo['channel'] != PEAR_CHANNELNAME) { return PEAR::raiseError('getDownloadURL channel must be ' . PEAR_CHANNELNAME); } include_once 'pear-database-release.php'; $states = release::betterStates($prefstate, true); if (!$states) { return PEAR::raiseError("getDownloadURL: preferred state '$prefstate' " . 'is not a valid stability state'); } $package = $packageinfo['package']; $state = $version = null; if (isset($packageinfo['state'])) { $state = $packageinfo['state']; } if (isset($packageinfo['version'])) { $version = $packageinfo['version']; } $info = package::info($package, 'releases'); if (!count($info)) { return false; } $found = false; $release = false; foreach ($info as $ver => $release) { if ($installed && version_compare($ver, $installed, '<')) { continue; } if (isset($state)) { if ($release['state'] == $state) { $found = true; break; } } elseif (isset($version)) { if ($ver == $version) { $found = true; break; } } else { if (in_array($release['state'], $states)) { $found = true; break; } } } if ($found) { return array('version' => $ver, 'info' => package::getPackageFile($packageinfo['package'], $ver), 'url' => 'http://' . $_SERVER['SERVER_NAME'] . '/get/' . $package . '-' . $ver); } else { reset($info); list($ver, $release) = each($info); return array('version' => $ver, 'info' => package::getPackageFile($packageinfo['package'], $ver)); } } // }}} // {{{ proto string package::getPackageFile(string|int, string) API 1.0 /** * @param string|int package name or id * @param string release version * @return string|PEAR_Error|null package.xml contents from this release */ function getPackageFile($package, $version) { global $dbh; $what = is_numeric($package) ? 'id' : 'name'; $relids = $dbh->getRow('SELECT releases.id as rid, packages.id as pid' . ' FROM releases, packages WHERE ' . "packages.$what = ? AND releases.version = ? AND " . 'releases.package = packages.id', array($package, $version), DB_FETCHMODE_ASSOC); if (PEAR::isError($relids)) { return $relids; } if ($relids === null) { $ptest = $dbh->getOne('SELECT id FROM packages WHERE ' . $what . ' = ?', array($package)); if ($ptest === null) { return PEAR::raiseError('Unknown package "' . $package . '"'); } $rtest = $dbh->getOne('SELECT id FROM releases WHERE version = ?', array($version)); if ($rtest === null) { return PEAR::raiseError('No release of version "' . $version . '" for package "' . $package . '"'); } } if (is_array($relids) && isset($relids['rid'])) { $packagexml = $dbh->getOne('SELECT packagexml FROM files WHERE ' . 'package = ? AND `release` = ?', array($relids['pid'], $relids['rid'])); if (is_string($packagexml)) { return $packagexml; } } } // }}} // {{{ proto array package::getDepDownloadURL(string, struct, struct, [string], [string]) API 1.1 /** * Get a download URL for a dependency, or an array containing the * latest version and its release info. * * If a bundle is specified, then an array of information * will be returned * @param string package.xml version for the dependency (1.0 or 2.0) * @param array dependency information * @param array dependent package information * @param string preferred state * @param string installed version of this dependency * @return bool|array */ function getDepDownloadURL($xsdversion, $dependency, $deppackage, $prefstate = 'stable', $installed = false) { $info = package::info($dependency['name'], 'releases', true); if (!count($info)) { return false; } include_once 'pear-database-release.php'; $states = release::betterStates($prefstate, true); if (!$states) { return PEAR::raiseError("getDepDownloadURL: preferred state '$prefstate' " . 'is not a valid stability state'); } $exclude = array(); $min = $max = $recommended = false; if ($xsdversion == '1.0') { $pinfo['package'] = $dependency['name']; $pinfo['channel'] = 'pear.php.net'; // this is always true - don't change this switch ($dependency['rel']) { case 'ge' : $min = $dependency['version']; break; case 'gt' : $min = $dependency['version']; $exclude = array($dependency['version']); break; case 'eq' : $recommended = $dependency['version']; break; case 'lt' : $max = $dependency['version']; $exclude = array($dependency['version']); break; case 'le' : $max = $dependency['version']; break; case 'ne' : $exclude = array($dependency['version']); break; } } elseif ($xsdversion == '2.0') { $pinfo['package'] = $dependency['name']; if ($dependency['channel'] != PEAR_CHANNELNAME) { return PEAR::raiseError('getDepDownloadURL channel must be ' . PEAR_CHANNELNAME); } $min = isset($dependency['min']) ? $dependency['min'] : false; $max = isset($dependency['max']) ? $dependency['max'] : false; $recommended = isset($dependency['recommended']) ? $dependency['recommended'] : false; if (isset($dependency['exclude'])) { if (!isset($dependency['exclude'][0])) { $exclude = array($dependency['exclude']); } } } $found = false; $release = false; foreach ($info as $ver => $release) { if (in_array($ver, $exclude)) { // skip excluded versions continue; } // allow newer releases to say "I'm OK with the dependent package" if ($xsdversion == '2.0' && isset($release['compatibility'])) { if (isset($release['compatibility'][$deppackage['channel']] [$deppackage['package']]) && in_array($ver, $release['compatibility'][$deppackage['channel']] [$deppackage['package']])) { $recommended = $ver; } } if ($recommended) { if ($ver != $recommended) { // if we want a specific // version, then skip all others continue; } else { if (!in_array($release['state'], $states)) { // the stability is too low, but we must return the // recommended version if possible return array('version' => $ver, 'info' => package::getPackageFile($dependency['name'], $ver)); } } } if ($min && version_compare($ver, $min, 'lt')) { // skip too old versions continue; } if ($max && version_compare($ver, $max, 'gt')) { // skip too new versions continue; } if ($installed && version_compare($ver, $installed, '<')) { continue; } if (in_array($release['state'], $states)) { // if in the preferred state... $found = true; // ... then use it break; } } if ($found) { return array('version' => $ver, 'info' => package::getPackageFile($dependency['name'], $ver), 'url' => 'http://' . $_SERVER['SERVER_NAME'] . '/get/' . $pinfo['package'] . '-' . $ver); } else { reset($info); list($ver, $release) = each($info); return array('version' => $ver, 'info' => package::getPackageFile($dependency['name'], $ver)); } } // }}} // {{{ proto struct package::info(string|int, [string], [bool]) API 1.0 /* * Implemented $field values: * releases, notes, category, description, authors, categoryid, * packageid, authors */ /** * Get package information * * @static * @param mixed Name of the package or it's ID * @param string Single field to fetch * @param boolean Should PECL packages also be taken into account? * @return mixed */ static function info($pkg, $field = null, $allow_pecl = false) { global $dbh; $what = is_numeric($pkg) ? 'id' : 'name'; if ($allow_pecl) { $package_type = "((p.package_type = 'pear' AND p.approved = 1) OR p.package_type = 'pecl') AND "; } else { $package_type = "p.package_type = 'pear' AND p.approved = 1 AND "; } $pkg_sql = "SELECT p.id AS packageid, p.name AS name, ". "p.package_type AS type, ". "c.id AS categoryid, c.name AS category, ". "p.stablerelease AS stable, p.license AS license, ". "p.summary AS summary, p.homepage AS homepage, ". "p.description AS description, p.cvs_link AS cvs_link, ". "p.doc_link as doc_link, ". "p.unmaintained AS unmaintained,". "p.newpk_id AS newpk_id, p.newpackagename as new_package, p.newchannel as new_channel, p.blocktrackbacks" . " FROM packages p, categories c ". "WHERE " . $package_type . " c.id = p.category AND p.{$what} = ?"; $rel_sql = "SELECT version, id, doneby, license, summary, ". "description, releasedate, releasenotes, state " . //, packagexmlversion ". "FROM releases ". "WHERE package = ? ". "ORDER BY releasedate DESC"; $notes_sql = "SELECT id, nby, ntime, note FROM notes WHERE pid = ?"; $deps_sql = "SELECT type, relation, version, name, `release` as `release`, optional FROM deps WHERE package = ? ORDER BY optional ASC"; $newpk_sql = "SELECT name FROM packages WHERE id=?"; if ($field == null) { $info = $dbh->getRow($pkg_sql, array($pkg), DB_FETCHMODE_ASSOC); $info['releases'] = $dbh->getAssoc($rel_sql, false, array($info['packageid']), DB_FETCHMODE_ASSOC); $rels = sizeof($info['releases']) ? array_keys($info['releases']) : array(''); $info['stable'] = $rels[0]; $info['notes'] = $dbh->getAssoc($notes_sql, false, array(@$info['packageid']), DB_FETCHMODE_ASSOC); $deps = $dbh->getAll($deps_sql, array(@$info['packageid']), DB_FETCHMODE_ASSOC); foreach($deps as $dep) { $rel_version = null; foreach($info['releases'] as $version => $rel) { if ($rel['id'] == $dep['release']) { $rel_version = $version; break; }; }; if ($rel_version !== null) { unset($dep['release']); $info['releases'][$rel_version]['deps'][] = $dep; }; }; } else { // get a single field if ($field == 'releases' || $field == 'notes') { if ($what == "name") { $pid = $dbh->getOne("SELECT p.id FROM packages p ". "WHERE " . $package_type . " p.name = ?", array($pkg)); } else { $pid = $pkg; } if ($field == 'releases') { $info = $dbh->getAssoc($rel_sql, false, array($pid), DB_FETCHMODE_ASSOC); } elseif ($field == 'notes') { $info = $dbh->getAssoc($notes_sql, false, array($pid), DB_FETCHMODE_ASSOC); } } elseif ($field == 'category') { $sql = "SELECT c.name FROM categories c, packages p ". "WHERE c.id = p.category AND " . $package_type . " p.{$what} = ?"; $info = $dbh->getOne($sql, array($pkg)); } elseif ($field == 'description') { $sql = "SELECT description FROM packages p WHERE " . $package_type . " p.{$what} = ?"; $info = $dbh->query($sql, array($pkg)); } elseif ($field == 'authors') { $sql = "SELECT u.handle, u.name, u.email, u.showemail, m.active, m.role FROM maintains m, users u, packages p WHERE " . $package_type ." m.package = p.id AND p.$what = ? AND m.handle = u.handle"; $info = $dbh->getAll($sql, array($pkg), DB_FETCHMODE_ASSOC); } else { if ($field == 'categoryid') { $dbfield = 'category'; } elseif ($field == 'packageid') { $dbfield = 'id'; } else { $dbfield = $field; } $sql = "SELECT $dbfield FROM packages p WHERE " . $package_type ." p.{$what} = ?"; $info = $dbh->getOne($sql, array($pkg)); } } return $info; } // }}} // {{{ proto struct package::search(string, [bool|string], [bool], [bool], [bool]) API 1.0 /** * */ function search($fragment, $summary = false, $released_only = true, $stable_only = true, $include_pecl = false) { $all = package::listAll($released_only, $stable_only, $include_pecl); if (!$all) { return PEAR::raiseError('no packages found'); } $ret = array(); foreach ($all as $name => $info) { $found = (!empty($fragment) && stristr($name, $fragment) !== false); if (!$found && !(isset($summary) && !empty($summary) && (stristr($info['summary'], $summary) !== false || stristr($info['description'], $summary) !== false))) { continue; }; $ret[$name] = $info; } return $ret; } // }}} // {{{ NOEXPORT struct package::listAllNames() /** * Lists the IDs and names of all approved PEAR packages * * Returns an associative array where the key of each element is * a package ID, while the value is the name of the corresponding * package. * * @static * @return array */ function listAllNames() { global $dbh; return $dbh->getAssoc("SELECT id, name FROM packages WHERE package_type = 'pear' AND approved = 1 ORDER BY name"); } // }}} // {{{ proto struct package::listAll([bool], [bool], [bool]) API 1.0 /** * List all packages * * @static * @param boolean Only list released packages? * @param boolean If listing released packages only, only list stable releases? * @param boolean List also PECL packages * @return array */ function listAll($released_only = true, $stable_only = true, $include_pecl = null) { global $dbh, $HTTP_RAW_POST_DATA; if ($include_pecl === null && isset($HTTP_RAW_POST_DATA)) { $include_pecl = true; } $package_type = ''; if (!$include_pecl) { $package_type = "p.package_type = 'pear' AND p.approved = 1 AND "; } $packageinfo = $dbh->getAssoc("SELECT p.name, p.id AS packageid, ". "c.id AS categoryid, c.name AS category, ". "p.license AS license, ". "p.summary AS summary, ". "p.description AS description, ". "m.handle AS lead ". " FROM packages p, categories c, maintains m ". "WHERE " . $package_type . " c.id = p.category ". " AND p.id = m.package ". " AND m.role = 'lead' ". "ORDER BY p.name", false, null, DB_FETCHMODE_ASSOC); $allreleases = $dbh->getAssoc( "SELECT p.name, r.id AS rid, r.version AS stable, r.state AS state ". "FROM packages p, releases r ". "WHERE " . $package_type . ' p.id = r.package ' . "ORDER BY r.releasedate ASC ", false, null, DB_FETCHMODE_ASSOC); if ($released_only) { $stablereleases = $dbh->getAssoc( "SELECT p.name, r.id AS rid, r.version AS stable, r.state AS state ". "FROM packages p, releases r ". "WHERE " . $package_type . "p.id = r.package ". "AND r.state = 'stable' " . "ORDER BY r.releasedate ASC ", false, null, DB_FETCHMODE_ASSOC); } else { $stablereleases = $allreleases; } $deps = $dbh->getAll( "SELECT package, `release` , type, relation, `version`, name ". "FROM deps", null, DB_FETCHMODE_ASSOC); foreach ($packageinfo as $pkg => $info) { $packageinfo[$pkg]['stable'] = false; } foreach ($stablereleases as $pkg => $stable) { $packageinfo[$pkg]['stable'] = $stable['stable']; $packageinfo[$pkg]['unstable'] = false; $packageinfo[$pkg]['state'] = $stable['state']; } if (!$stable_only) { foreach ($allreleases as $pkg => $stable) { if ($stable['state'] == 'stable') { if (version_compare($packageinfo[$pkg]['stable'], $stable['stable'], '<')) { // only change it if the version number is newer $packageinfo[$pkg]['stable'] = $stable['stable']; } } else { if (!isset($packageinfo[$pkg]['unstable']) || version_compare($packageinfo[$pkg]['unstable'], $stable['stable'], '<')) { // only change it if the version number is newer $packageinfo[$pkg]['unstable'] = $stable['stable']; } } $packageinfo[$pkg]['state'] = $stable['state']; if (isset($packageinfo[$pkg]['unstable']) && !$packageinfo[$pkg]['stable']) { $packageinfo[$pkg]['stable'] = $packageinfo[$pkg]['unstable']; } } } $var = !$stable_only ? 'allreleases' : 'stablereleases'; foreach (array_keys($packageinfo) as $pkg) { $_deps = array(); foreach ($deps as $dep) { if ($dep['package'] == $packageinfo[$pkg]['packageid'] && isset($$var[$pkg]) && $dep['release'] == $$var[$pkg]['rid']) { unset($dep['rid']); unset($dep['release']); if ($dep['type'] == 'pkg' && isset($packageinfo[$dep['name']])) { $dep['package'] = $packageinfo[$dep['name']]['packageid']; } else { $dep['package'] = 0; } $_deps[] = $dep; }; }; $packageinfo[$pkg]['deps'] = $_deps; }; if ($released_only) { if (!$stable_only) { foreach ($packageinfo as $pkg => $info) { if (!isset($allreleases[$pkg]) && !isset($stablereleases[$pkg])) { unset($packageinfo[$pkg]); } } } else { foreach ($packageinfo as $pkg => $info) { if (!isset($stablereleases[$pkg])) { unset($packageinfo[$pkg]); } } } } return $packageinfo; } // }}} // {{{ proto struct package::listAllwithReleases() API 1.0 /** * Get list of packages and their releases * * @access public * @return array * @static */ function listAllwithReleases() { global $dbh; $query = "SELECT p.id AS pid, p.name, r.id AS rid, r.version, r.state FROM packages p, releases r WHERE p.package_type = 'pear' AND p.approved = 1 AND p.id = r.package ORDER BY p.name, r.version DESC"; $sth = $dbh->query($query); if (DB::isError($sth)) { return $sth; } $packages = array(); while ($row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) { $packages[$row['pid']]['name'] = $row['name']; $packages[$row['pid']]['releases'][] = array('id' => $row['rid'], 'version' => $row['version'], 'state' => $row['state'] ); } return $packages; } // }}} // {{{ proto struct package::listLatestReleases([string]) API 1.0 /** * List latest releases * * @static * @param string Only list release with specific state (Optional) * @return array */ function listLatestReleases($state = '') { global $dbh; $query = "SELECT ". "p.name AS package, ". "r.version AS version, ". "r.state AS state, ". "f.fullpath AS fullpath ". "FROM packages p, releases r, files f ". "WHERE p.package_type = 'pear' AND p.approved = 1 AND p.id = r.package ". "AND f.package = p.id ". "AND f.release = r.id"; include_once 'pear-database-release.php'; if (release::isValidState($state)) { $better = release::betterStates($state); $query .= " AND (r.state = '$state'"; $i = 0; if (is_array($better)) { foreach ($better as $b) { $query .= " OR r.state = '$b'"; } } $query .= ")"; } $query .= " ORDER BY p.name"; $sortfunc = "version_compare_firstelem"; $res = $dbh->getAssoc($query, false, null, DB_FETCHMODE_ASSOC, true); foreach ($res as $pkg => $ver) { if (sizeof($ver) > 1) { usort($ver, $sortfunc); } $res[$pkg] = array_pop($ver); $res[$pkg]['filesize'] = (int)@filesize($res[$pkg]['fullpath']); unset($res[$pkg]['fullpath']); } return $res; } // }}} // {{{ proto struct package::listUpgrades(struct) API 1.0 /** * List available upgrades * * @static * @param array Array containing the currently installed packages * @return array */ function listUpgrades($currently_installed) { global $dbh; if (sizeof($currently_installed) == 0) { return array(); } $query = "SELECT ". "p.name AS package, ". "r.id AS releaseid, ". "r.package AS packageid, ". "r.version AS version, ". "r.state AS state, ". "r.doneby AS doneby, ". "r.license AS license, ". "r.summary AS summary, ". "r.description AS description, ". "r.releasedate AS releasedate, ". "r.releasenotes AS releasenotes ". "FROM releases r, packages p WHERE p.package_type = 'pear' AND p.approved = 1 AND r.package = p.id AND ("; $conditions = array(); foreach ($currently_installed as $package => $info) { extract($info); // state, version $conditions[] = "(package = '$package' AND state = '$state')"; } $query .= implode(" OR ", $conditions) . ")"; return $dbh->getAssoc($query, false, null, DB_FETCHMODE_ASSOC); } // }}} // {{{ +proto bool package::updateInfo(string|int, struct) API 1.0 /** * Updates fields of an existant package * * @param int $pkgid The package ID to update * @param array $data Assoc in the form 'field' => 'value'. * @return mixed True or PEAR_Error */ function updateInfo($pkgid, $data) { global $dbh, $auth_user; $package_id = package::info($pkgid, 'id'); if (PEAR::isError($package_id) || empty($package_id)) { return PEAR::raiseError("Package not registered or not approved. Please register it first with \"New Package\" or wait until it gets approved."); } if ($auth_user->isAdmin() == false && $auth_user->isQA() == false) { include_once 'pear-database-user.php'; $role = user::maintains($auth_user->handle, $package_id); if ($role != 'lead' && $role != 'developer') { return PEAR::raiseError('package::updateInfo: insufficient privileges'); } } // XXX (cox) what about 'name'? $allowed = array('license', 'summary', 'description', 'category'); $fields = $prep = array(); foreach ($allowed as $a) { if (isset($data[$a])) { $fields[] = "$a = ?"; $prep[] = $data[$a]; } } if (!count($fields)) { return; } $sql = 'UPDATE packages SET ' . implode(', ', $fields) . " WHERE id=$package_id"; $row = package::info($pkgid, 'name'); $GLOBALS['pear_rest']->saveAllPackagesREST(); $GLOBALS['pear_rest']->savePackageREST($row); $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pkgid, 'category')); return $dbh->query($sql, $prep); } // }}} // {{{ getDependants() /** * Get packages that depend on the given package * * @param string Name of the package * @return array List of package that depend on $package */ function getDependants($package) { global $dbh; $query = 'SELECT p.name AS p_name, ' . ' MAX(r.version) AS max_dep, ' . ' MAX(rm.version) as max_pkg ' . 'FROM packages p, deps AS d ' . ' LEFT JOIN (releases AS r) ON (r.id = d.release) ' . ' LEFT JOIN releases AS rm ON (rm.package = d.package) ' . "WHERE d.package = p.id AND d.type = 'pkg' " . " AND d.name = ? " . "GROUP BY d.package"; return $dbh->getAll($query, array($package), DB_FETCHMODE_ASSOC); } // }}} // {{{ proto array package::getRecent(int, string) API 1.0 /** * Get list of recent releases for the given package * * @param int Number of releases to return * @param string Name of the package * @return array */ function getRecent($n, $package) { global $dbh; $recent = array(); $query = "SELECT p.id AS id, " . "p.name AS name, " . "p.summary AS summary, " . "r.version AS version, " . "r.releasedate AS releasedate, " . "r.releasenotes AS releasenotes, " . "r.doneby AS doneby, " . "r.state AS state " . "FROM packages p, releases r " . "WHERE p.package_type = 'pear' AND p.approved = 1 AND p.id = r.package " . "AND p.name = '" . $package . "'" . "ORDER BY r.releasedate DESC"; $sth = $dbh->limitQuery($query, 0, $n); while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } // }}} // {{{ *proto bool package::isValid(string) API 1.0 /** * Determines if the given package is valid * * @access public * @param string Name of the package * @return boolean */ function isValid($package) { global $dbh; $query = "SELECT id FROM packages WHERE package_type = 'pear' AND approved = 1 AND name = ?"; $sth = $dbh->query($query, array($package)); return ($sth->numRows() > 0); } // }}} // {{{ getNotes() /** * Get all notes for given package * * @access public * @param int ID of the package * @return array */ function getNotes($package) { global $dbh; $query = "SELECT * FROM notes WHERE pid = ? ORDER BY ntime"; return $dbh->getAll($query, array($package), DB_FETCHMODE_ASSOC); } // }}} // {{{ allowTrackbacks() /** * Enable or disable trackbacks for a package * * @access public * @param int ID of the package * @return void */ function allowTrackbacks($name, $allow) { global $dbh; $query = 'UPDATE packages SET blocktrackbacks=' . ((int) !$allow) . ' WHERE name=' . $dbh->quoteSmart($name); $res = $dbh->query($query); } // }}} } // {{{ class PEAR_Package require_once 'DB/storage.php'; class PEAR_Package extends DB_storage { function PEAR_Package(&$dbh, $package, $keycol = "name") { $this->DB_storage("packages", $keycol, $dbh); $this->pushErrorHandling(PEAR_ERROR_RETURN); $this->setup($package); $this->popErrorHandling(); } /** * Generate link for package * * Returns HTML-code that creates a link to /package/<package> * * @access public * @return string */ function makeLink() { return make_link("/package/" . $this->name . "/", $this->name); } } // }}} // {{{ version_compare_firstelem() function version_compare_firstelem($a, $b) { reset($a); $elem = key($a); return version_compare($a[$elem], $b[$elem]); } // }}} http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-release.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-release.php +++ pearweb/include/pear-database-release.php <?php /* +----------------------------------------------------------------------+ | PEAR Web site version 1.0 | +----------------------------------------------------------------------+ | Copyright (c) 2001-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Stig S. Bakken <ssb@fast.no> | | Tomas V.V. Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ $Id: pear-database-release.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ /** * Class to handle releases * * @class release * @package pearweb * @author Stig S. Bakken <ssb@fast.no> * @author Tomas V.V. Cox <cox@php.net> * @author Martin Jansen <mj@php.net> */ class release { // {{{ proto array release::getRecent([int]) API 1.0 /** * Get recent releases * * @static * @param integer Number of releases to return * @return array */ function getRecent($n = 5) { global $dbh; $sth = $dbh->limitQuery("SELECT packages.id AS id, ". "packages.name AS name, ". "packages.summary AS summary, ". "releases.version AS version, ". "releases.releasedate AS releasedate, ". "releases.releasenotes AS releasenotes, ". "releases.doneby AS doneby, ". "releases.state AS state ". "FROM packages, releases ". "WHERE packages.id = releases.package ". "AND packages.approved = 1 ". "AND packages.package_type = 'pear' ". "ORDER BY releases.releasedate DESC", 0, $n); $recent = array(); // XXX Fixme when DB gets limited getAll() while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } // }}} // {{{ proto array release::getDateRange(int,int) API 1.0 // }}} // {{{ proto array release::getPopular(int) API 1.0 function getPopular($n = 5, $rss = false) { global $dbh; if ($rss) { $query = ' SELECT packages.name, releases.version, downloads, releasedate, downloads/(CEIL((unix_timestamp(NOW()) - unix_timestamp(releases.releasedate))/86400)) as releasenotes FROM releases, packages, aggregated_package_stats a WHERE packages.name <> "pearweb" AND packages.name <> "pearweb_phars" AND packages.id = releases.package AND packages.package_type = \'pear\' AND a.release_id = releases.id AND a.package_id = packages.id AND packages.newpk_id IS NULL AND packages.unmaintained = 0 AND a.yearmonth = "' . date('Y-m-01 00:00:00', time()) . '" ORDER BY releasenotes DESC'; } else { $query = ' SELECT packages.name, releases.version, downloads, downloads/(CEIL((unix_timestamp(NOW()) - unix_timestamp(releases.releasedate))/86400)) as d FROM releases, packages, aggregated_package_stats a WHERE packages.name <> "pearweb" AND packages.name <> "pearweb_phars" AND packages.id = releases.package AND packages.package_type = \'pear\' AND a.release_id = releases.id AND a.package_id = packages.id AND packages.newpk_id IS NULL AND packages.unmaintained = 0 AND a.yearmonth = "' . date('Y-m-01 00:00:00', time()) . '" ORDER BY d DESC'; } $sth = $dbh->limitQuery($query, 0, $n); $recent = array(); // XXX Fixme when DB gets limited getAll() while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } /** * Get release in a specific time range * * @static * @param integer Timestamp of start date * @param integer Timestamp of end date * @return array */ function getDateRange($start,$end) { global $dbh; $recent = array(); if (!is_numeric($start)) { return $recent; } if (!is_numeric($end)) { return $recent; } $start_f = date('Y-m-d 00:00:00',$start); $end_f = date('Y-m-d 00:00:00',$end); // limited to 50 to stop overkill on the server! $sth = $dbh->limitQuery("SELECT packages.id AS id, ". "packages.name AS name, ". "packages.summary AS summary, ". "packages.description AS description, ". "releases.version AS version, ". "releases.releasedate AS releasedate, ". "releases.releasenotes AS releasenotes, ". "releases.doneby AS doneby, ". "releases.state AS state ". "FROM packages, releases ". "WHERE packages.id = releases.package ". "AND releases.releasedate > '{$start_f}' AND releases.releasedate < '{$end_f}'". "ORDER BY releases.releasedate DESC",0,50); while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } // }}} // {{{ +proto string release::upload(string, string, string, string, binary, string) API 1.0 /** * Upload new release * * @static * @param string Name of the package * @param string Version string * @param string State of the release * @param string Release notes * @param string Filename of the release tarball * @param string MD5 checksum of the tarball */ function upload($package, $version, $state, $relnotes, $tarball, $md5sum, $pkg_info = false, $packagexml = false, $compatible = false) { global $auth_user; include_once 'pear-database-user.php'; $role = user::maintains($auth_user->handle, $package); if ($role != 'lead' && $role != 'developer' && !$auth_user->isAdmin() && !$auth_user->isQA()) { return PEAR::raiseError('release::upload: insufficient privileges'); } $ref = release::validateUpload($package, $version, $state, $relnotes, $tarball, $md5sum); if (PEAR::isError($ref)) { return $ref; } return release::confirmUpload($package, $version, $state, $relnotes, $md5sum, $ref['package_id'], $ref['file'], $pkg_info, $packagexml, $compatible); } // }}} // {{{ +proto string release::validateUpload(string, string, string, string, binary, string) API 1.0 /** * Determine if uploaded file is a valid release * * @param string Name of the package * @param string Version string * @param string State of the release * @param string Release notes * @param string Filename of the release tarball * @param string MD5 checksum of the tarball * @return mixed */ function validateUpload($package, $version, $state, $relnotes, $tarball, $md5sum) { global $dbh, $auth_user; include_once 'pear-database-user.php'; $role = user::maintains($auth_user->handle, $package); if ($role != 'lead' && $role != 'developer' && !$auth_user->isAdmin() && !$auth_user->isQA()) { return PEAR::raiseError('release::validateUpload: insufficient privileges'); } // (2) verify that package exists include_once 'pear-database-package.php'; $package_id = package::info($package, 'id'); if (PEAR::isError($package_id) || empty($package_id)) { return PEAR::raiseError("package `$package' must be registered first"); } // (3) verify that version does not exist $test = $dbh->getOne("SELECT version FROM releases ". "WHERE package = ? AND version = ?", array($package_id, $version)); if (PEAR::isError($test)) { return $test; } if ($test) { return PEAR::raiseError("already exists: $package $version"); } // (4) store tar ball to temp file $tempfile = sprintf("%s/%s%s-%s.tgz", PEAR_TARBALL_DIR, ".new.", $package, $version); $file = sprintf("%s/%s-%s.tgz", PEAR_TARBALL_DIR, $package, $version); if (!@copy($tarball, $tempfile)) { return PEAR::raiseError("writing $tempfile failed: $php_errormsg"); } if (!isset($package_id)) { return PEAR::raiseError("bad upload: package_id missing"); } // later: do lots of integrity checks on the tarball if (!@rename($tempfile, $file)) { return PEAR::raiseError("renaming failed: $php_errormsg"); } // (5) verify MD5 checksum $testsum = md5_file($file); if ($testsum != $md5sum) { $bytes = strlen($data); return PEAR::raiseError("bad md5 checksum (checksum=$testsum ($bytes bytes: $data), specified=$md5sum)"); } // (6) unpack tarball $target = @fopen(PEAR_TARBALL_DIR . "/" . $package . "-" . $version . ".tar", "w+"); if ($target) { fwrite($target, file_get_contents("compress.zlib://" . $file)); fclose($target); } return array("package_id" => $package_id, "file" => $file ); } // }}} // {{{ +proto bool release::confirmUpload(string, string, string, string, string, int, binary) API 1.0 /** * Confirm release upload * * @param string Package name * @param string Package version * @param string Package state * @param string Release notes * @param string md5 * @param int Package id from database * @param string package contents * @static * @return string the file name of the upload or PEAR_Error object if problems */ function confirmUpload($package, $version, $state, $relnotes, $md5sum, $package_id, $file, $pkg_info = false, $packagexml = false, $compatible = false) { require_once "PEAR/Common.php"; global $dbh, $auth_user, $_PEAR_Common_dependency_types, $_PEAR_Common_dependency_relations; if (!$pkg_info) { require_once 'Archive/Tar.php'; $tar = &new Archive_Tar($file); $oldpackagexml = $tar->extractInString('package.xml'); if (null === $packagexml = $tar->extractInString('package2.xml')) { if ($oldpackagexml === null) { return PEAR::raiseError('Archive uploaded does not appear to contain a package.xml!'); } $packagexml = $oldpackagexml; } $compatible = $oldpackagexml != $packagexml ? true : false; } // Update releases table $query = "INSERT INTO releases (id,package,version,state,doneby,". "releasedate,releasenotes) VALUES(?,?,?,?,?,NOW(),?)"; $sth = $dbh->prepare($query); $release_id = $dbh->nextId("releases"); $dbh->execute($sth, array($release_id, $package_id, $version, $state, $auth_user->handle, $relnotes)); // Update files table $query = "INSERT INTO files ". "(id,package,release,md5sum,basename,fullpath,packagexml) ". "VALUES(?,?,?,?,?,?,?)"; $sth = $dbh->prepare($query); $file_id = $dbh->nextId("files"); $ok = $dbh->execute($sth, array($file_id, $package_id, $release_id, $md5sum, basename($file), $file, $packagexml)); /* * Code duplication with deps error * Should be droped soon or later using transaction * (and add mysql4 as a pe(ar|cl)web requirement) */ if (PEAR::isError($ok)) { $dbh->query("DELETE FROM releases WHERE id = $release_id"); @unlink($file); return $ok; } // Update dependency table $query = "INSERT INTO deps " . "(package, `release`, type, relation, version, name, optional) " . "VALUES (?,?,?,?,?,?,?)"; $sth = $dbh->prepare($query); if (!$pkg_info) { require_once 'PEAR/PackageFile.php'; require_once 'PEAR/Config.php'; $config = &PEAR_Config::singleton(); $pf = &new PEAR_PackageFile($config); $pkg_info = $pf->fromXmlString($packagexml, PEAR_VALIDATE_DOWNLOADING, $compatible ? 'package2.xml' : 'package.xml'); } $deps = $pkg_info->getDeps(true); // get the package2.xml actual content $storedeps = $pkg_info->getDeps(); // get the BC-compatible content $pearused = false; if (isset($deps['required']['package'])) { if (!isset($deps['required']['package'][0])) { $deps['required']['package'] = array($deps['required']['package']); } foreach ($deps['required']['package'] as $pkgdep) { if ($pkgdep['channel'] == 'pear.php.net' && strtolower($pkgdep['name']) == 'pear') { $pearused = true; } } } if (is_array($storedeps)) { foreach ($storedeps as $dep) { $prob = array(); if (empty($dep['type']) || !in_array($dep['type'], $_PEAR_Common_dependency_types)) { $prob[] = 'type'; } if (empty($dep['name'])) { /* * NOTE from pajoye in ver 1.166: * This works for now. * This would require a 'cleaner' InfoFromXXX * which may return a defined set of data using * default values if required. */ if (strtolower($dep['type']) == 'php') { $dep['name'] = 'PHP'; } else { $prob[] = 'name'; } } elseif (strtolower($dep['name']) == 'pear') { if (!$pearused && $compatible) { // there is no need for a PEAR dependency here continue; } if (!$pearused && !$compatible) { $dep['name'] = 'PEAR Installer'; } } if (empty($dep['rel']) || !in_array($dep['rel'], $_PEAR_Common_dependency_relations)) { $prob[] = 'rel'; } if (empty($dep['optional'])) { $optional = 0; } else { if ($dep['optional'] != strtolower($dep['optional'])) { $prob[] = 'optional'; } $optional = $dep['optional'] == 'yes' ? 1 : 0; } if (count($prob)) { $res = PEAR::raiseError('The following attribute(s) ' . 'were missing or need proper values: ' . implode(', ', $prob)); } else { $res = $dbh->execute($sth, array( $package_id, $release_id, $dep['type'], $dep['rel'], @$dep['version'], $dep['name'], $optional)); } if (PEAR::isError($res)) { $dbh->query('DELETE FROM deps WHERE ' . "release = $release_id"); $dbh->query('DELETE FROM releases WHERE ' . "id = $release_id"); @unlink($file); return $res; } } } include_once 'pear-database-package.php'; if (!in_array(package::info($package, 'name'), array('pearweb', 'pearweb_phars'), true)) { // Add release archive file to API documentation queue $query = "INSERT INTO apidoc_queue (filename, queued) " . "VALUES ('" . $file. "', NOW())"; /* * Don't abort the release if something goes wrong. */ $dbh->pushErrorHandling(PEAR_ERROR_RETURN); $sth = $dbh->query($query); $dbh->popErrorHandling(); } // Update Cache $GLOBALS['pear_rest']->saveAllReleasesREST($package); $GLOBALS['pear_rest']->saveReleaseREST($file, $packagexml, $pkg_info, $auth_user->handle, $release_id); $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($package, 'category')); // gotta clear all the permutations include_once 'xmlrpc-cache.php'; $cache = new XMLRPC_Cache; $cache->remove('package.listAll', array(false)); $cache->remove('package.listAll', array(true)); $cache->remove('package.listAll', array(false, true)); $cache->remove('package.listAll', array(false, false)); $cache->remove('package.listAll', array(true, true)); $cache->remove('package.listAll', array(true, false)); $cache->remove('package.listAll', array(false, true, true)); $cache->remove('package.listAll', array(false, true, false)); $cache->remove('package.listAll', array(false, false, true)); $cache->remove('package.listAll', array(false, false, false)); $cache->remove('package.listAll', array(true, true, true)); $cache->remove('package.listAll', array(true, true, false)); $cache->remove('package.listAll', array(true, false, true)); $cache->remove('package.listAll', array(true, false, false)); // make sure pecl is also removed $cache->remove('package.info', array($package, null)); $cache->remove('package.info', array($package, array(null, null, true))); return $file; } // }}} // {{{ +proto bool release::dismissUpload(string) API 1.0 /** * Dismiss release upload * * @param string * @return boolean */ function dismissUpload($upload_ref) { return (bool)@unlink($upload_ref); } // }}} // {{{ NOEXPORT release::HTTPdownload(string, [string], [string], [bool]) /** * Download release via HTTP * * Not for xmlrpc export! * * @param string Name of the package * @param string Version string * @param string Filename * @param boolean Uncompress file before downloading? * @return mixed * @static */ function HTTPdownload($package, $version = null, $file = null, $uncompress = false) { global $dbh; include_once 'pear-database-package.php'; $package_id = package::info($package, 'packageid', true); if (!$package_id) { return PEAR::raiseError("release download:: package '".htmlspecialchars($package). "' does not exist"); } elseif (PEAR::isError($package_id)) { return $package_id; } if ($file !== null) { if (substr($file, -4) == '.tar') { $file = substr($file, 0, -4) . '.tgz'; $uncompress = true; } $row = $dbh->getRow("SELECT fullpath, `release`, id FROM files ". "WHERE UPPER(basename) = ?", array(strtoupper($file)), DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; } elseif ($row === null) { return PEAR::raiseError("File '$file' not found"); } $path = $row['fullpath']; $log_release = $row['release']; $log_file = $row['id']; $basename = $file; } elseif ($version == null) { // Get the most recent version $row = $dbh->getRow("SELECT id FROM releases ". "WHERE package = $package_id ". "ORDER BY releasedate DESC", DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; } $release_id = $row['id']; } elseif (release::isValidState($version)) { $version = strtolower($version); // Get the most recent version with a given state $row = $dbh->getRow("SELECT id FROM releases ". "WHERE package = $package_id ". "AND state = '$version' ". "ORDER BY releasedate DESC", DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; } $release_id = $row['id']; if (!isset($release_id)) { return PEAR::raiseError("$package does not have any releases with state \"$version\""); } } else { // Get a specific release $row = $dbh->getRow("SELECT id FROM releases ". "WHERE package = $package_id ". "AND version = '$version'", DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; } $release_id = $row['id']; } if (!isset($path) && isset($release_id)) { $sql = "SELECT fullpath, basename, id FROM files WHERE release = ". $release_id; $row = $dbh->getRow($sql, DB_FETCHMODE_ORDERED); if (PEAR::isError($row)) { return $row; } list($path, $basename, $log_file) = $row; if (empty($path) || !@is_file($path)) { return PEAR::raiseError("release download:: no version information found"); } } if (isset($path)) { if (!isset($log_release)) { $log_release = $release_id; } release::logDownload($package_id, $log_release, $log_file); header('Last-modified: ' . gmdate('D, d M Y H:i:s \G\M\T', filemtime($path))); header('Content-type: application/octet-stream'); if ($uncompress) { $tarname = preg_replace('/\.tgz\z/', '.tar', $basename); header('Content-disposition: attachment; filename="'.$tarname.'"'); readgzfile($path); } else { header('Content-disposition: attachment; filename="'.$basename.'"'); header('Content-length: '.filesize($path)); readfile($path); } return true; } header('HTTP/1.0 404 Not Found'); print 'File not found'; } // }}} // {{{ proto bool release::isValidState(string) API 1.0 /** * Determine if release state is valid * * @static * @param string State * @return boolean */ function isValidState($state) { static $states = array('devel', 'snapshot', 'alpha', 'beta', 'stable'); return in_array($state, $states); } // }}} // {{{ proto array release::betterStates(string) API 1.0 /** * Convert a state into an array of less stable states * * @param string Release state * @param boolean include the state in the array returned * @return boolean */ function betterStates($state, $include = false) { static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable'); $i = array_search($state, $states); if ($include) { $i--; } if ($i === false) { return false; } return array_slice($states, $i + 1); } // }}} // {{{ NOEXPORT release::logDownload(integer, string, string) /** * Log release download * * @param integer ID of the package * @param integer ID of the release * @param string Filename */ function logDownload($package, $release_id, $file = null) { global $dbh; $dbh->query('UPDATE aggregated_package_stats SET downloads=downloads+1 WHERE package_id=? AND release_id=? AND yearmonth="' . date('Y-m-01') . '"', array($package, $release_id)); if ($dbh->affectedRows() == 0) { $dbh->query('INSERT INTO aggregated_package_stats (package_id, release_id, yearmonth, downloads) VALUES(?,?,?,1)', array($package, $release_id, date('Y-m-01'))); } // This method can be used when we have MySQL 4.1, // 30% efficiency gain at least over previous method // $dbh->query('INSERT INTO aggregated_package_stats // (package_id, release_id, yearmonth, downloads) // VALUES(?,?,?,1) // ON DUPLICATE KEY UPDATE downloads=downloads+1', // array($package, $release_id, date('Y-m-01'))); // {{{ Update package_stats table // This method can be used when we have MySQL 4.1, // 30% efficiency gain at least over previous method // $query = 'INSERT INTO package_stats // (dl_number, package, release, pid, rid, cid, last_dl) // VALUES (1, ?, ?, ?, ?, ?, ?) // ON DUPLICATE KEY UPDATE // dl_number=dl_number+1, // last_dl = "' . date('Y-m-d H:i:s') . '"'; // // $dbh->query($query, array($pkg_info['name'], // $version, // $package, // $release_id, // $pkg_info['categoryid'], // date('Y-m-d H:i:s') // ) // ); $query = 'UPDATE package_stats ' . ' SET dl_number = dl_number + 1,' . " last_dl = '" . date('Y-m-d H:i:s') . "'" . ' WHERE pid = ? AND rid = ?'; $dbh->query($query, array($package, $release_id)); if ($dbh->affectedRows() == 0) { include_once 'pear-database-package.php'; $pkg_info = package::info($package, null); $query = 'SELECT version FROM releases' . ' WHERE package = ? AND id = ?'; $version = $dbh->getOne($query, array($package, $release_id)); if (!$version) { return PEAR::raiseError('release:: the package you requested' . ' has no release by that number'); } $query = 'INSERT INTO package_stats' . ' (dl_number, package, `release`, pid, rid, cid, last_dl)' . ' VALUES (1, ?, ?, ?, ?, ?, ?)'; $dbh->query($query, array($pkg_info['name'], $version, $package, $release_id, $pkg_info['categoryid'], date('Y-m-d H:i:s') ) ); } // }}} } // }}} // {{{ +proto string release::promote(array, string) API 1.0 /** * Promote new release * * @param array Coming from PEAR_common::infoFromDescFile('package.xml') * @param string Filename of the new uploaded release * @return void */ function promote($pkginfo, $upload) { if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { return; } include_once 'pear-database-package.php'; $pacid = package::info($pkginfo['package'], 'packageid'); $authors = package::info($pkginfo['package'], 'authors'); $txt_authors = ''; foreach ($authors as $a) { if (!$a['active']) { continue; } $txt_authors .= $a['name']; if ($a['showemail']) { $txt_authors .= " <{$a['email']}>"; } $txt_authors .= " ({$a['role']})\n"; } $upload = basename($upload); $release = "{$pkginfo['package']}-{$pkginfo['version']} ({$pkginfo['release_state']})"; $channel = PEAR_CHANNELNAME; $txtanounce =<<<END The new PEAR package $release has been released at http://$channel/. Release notes ------------- {$pkginfo['release_notes']} Package Info ------------ {$pkginfo['description']} Related Links ------------- Package home: http://$channel/package/$pkginfo[package] Changelog: http://$channel/package/$pkginfo[package]/download/$pkginfo[version] Download: http://download.$channel/package/$upload Authors ------- $txt_authors END; $to = '"PEAR general list" <' . PEAR_GENERAL_EMAIL . '>'; $from = '"PEAR Announce" <' . PEAR_ANNOUNCE_EMAIL . '>'; $subject = "[ANNOUNCEMENT] $release Released."; mail($to, $subject, $txtanounce, "From: $from", "-f bounce-no-user@php.net"); } // }}} // {{{ +proto string release::promote_v2(array, string) API 1.0 /** * Promote new release * * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 * @param string Filename of the new uploaded release * @return void */ function promote_v2($pkginfo, $upload) { if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { return; } include_once 'pear-database-package.php'; $pacid = package::info($pkginfo->getPackage(), 'packageid'); $authors = package::info($pkginfo->getPackage(), 'authors'); $txt_authors = ''; foreach ($authors as $a) { if (!$a['active']) { continue; } $txt_authors .= $a['name']; if ($a['showemail']) { $txt_authors .= " <{$a['email']}>"; } $txt_authors .= " ({$a['role']})\n"; } $upload = basename($upload); $release = $pkginfo->getPackage() . '-' . $pkginfo->getVersion() . ' (' . $pkginfo->getState() . ')'; $txtanounce ='The new PEAR package ' . $release . ' has been released at http://' . PEAR_CHANNELNAME . '/. Release notes ------------- ' . $pkginfo->getNotes() . ' Package Info ------------ ' . $pkginfo->getDescription() . ' Related Links ------------- Package home: http://' . PEAR_CHANNELNAME . '/package/' . $pkginfo->getPackage() . ' Changelog: http://' . PEAR_CHANNELNAME . '/package/' . $pkginfo->getPackage() . '/download/' . $pkginfo->getVersion() . ' Download: http://download.' . PEAR_CHANNELNAME . '/package/' . $upload . ' Authors ------- ' . $txt_authors; $to = '"PEAR general list" <' . PEAR_GENERAL_EMAIL . '>'; $from = '"PEAR Announce" <' . PEAR_ANNOUNCE_EMAIL . '>'; $subject = "[ANNOUNCEMENT] $release Released."; mail($to, $subject, $txtanounce, "From: $from", "-f bounce-no-user@php.net"); } // }}} // {{{ NOEXPORT release::remove(int, int) /** * Remove release * * @param integer ID of the package * @param integer ID of the release * @return boolean */ function remove($package, $release) { global $dbh, $auth_user; include_once 'pear-database-user.php'; if (!$auth_user->isAdmin() && !$auth_user->isQA() && !user::maintains($auth_user->handle, $package, 'lead')) { return PEAR::raiseError('release::remove: insufficient privileges'); } $success = true; // get files that have to be removed $query = sprintf("SELECT fullpath FROM files WHERE package = '%s' AND release = '%s'", $package, $release); $sth = $dbh->query($query); while ($row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) { if (!@unlink($row['fullpath'])) { $success = false; } } $query = sprintf("DELETE FROM files WHERE package = '%s' AND `release` = '%s'", $package, $release ); $sth = $dbh->query($query); include_once 'pear-database-package.php'; $pname = package::info($package, 'name'); $version = $dbh->getOne('SELECT version from releases WHERE package = ? and id = ?', array($package, $release)); $query = sprintf("DELETE FROM releases WHERE package = '%s' AND id = '%s'", $package, $release ); $sth = $dbh->query($query); // remove statistics on this release $dbh->query('DELETE FROM package_stats WHERE pid = ? AND rid = ?', array($package, $release)); $dbh->query('DELETE FROM aggregated_package_stats WHERE package_id = ? AND release_id = ?', array($package, $release)); $GLOBALS['pear_rest']->saveAllReleasesREST($pname); $GLOBALS['pear_rest']->deleteReleaseREST($pname, $version); $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pname, 'category')); if (PEAR::isError($sth)) { return false; } return true; } // }}} // {{{ getFAQ() /** * Get FAQ items for given package version * * @param string Name of the package * @param string Version string of the package * @return mixed PEAR_Error or Array */ function getFAQ($package, $version) { global $dbh; $query = "SELECT f.* FROM packages_faq f, packages p, releases r " . "WHERE p.name = ? AND p.id = r.package AND r.version = ? AND r.id = f.release"; return $dbh->getAll($query, array($package, $version), DB_FETCHMODE_ASSOC); } // }}} } http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-statistics.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-statistics.php +++ pearweb/include/pear-database-statistics.php <?php /* +----------------------------------------------------------------------+ | PEAR Web site version 1.0 | +----------------------------------------------------------------------+ | Copyright (c) 2001-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Stig Bakken <ssb@fast.no> | | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | | Gregory Beaver <cellog@php.net> | +----------------------------------------------------------------------+ $Id: pear-database-statistics.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ class statistics { // {{{ package() /** * Get general package statistics * * @param integer ID of the package * @return array */ function package($id) { global $dbh; $query = "SELECT SUM(dl_number) FROM package_stats WHERE pid = " . (int)$id; return $dbh->getOne($query); } // }}} // {{{ release() function release($id, $rid = "") { global $dbh; $query = 'SELECT s.release, s.dl_number, s.last_dl, r.releasedate ' . 'FROM package_stats AS s ' . 'LEFT JOIN releases AS r ON (s.rid = r.id) ' . "WHERE pid = " . (int)$id; if (!empty($rid)) { $query .= " AND rid = " . (int)$rid; } $query .= " GROUP BY rid ORDER BY rid DESC"; return $dbh->getAll($query, DB_FETCHMODE_ASSOC); } // }}} } http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-user.php?view=markup&rev=1.1 Index: pearweb/include/pear-database-user.php +++ pearweb/include/pear-database-user.php <?php class user { // {{{ *proto bool user::remove(string) API 1.0 function remove($uid) { global $dbh; include_once 'pear-database-note.php'; note::removeAll("uid", $uid); $GLOBALS['pear_rest']->deleteMaintainerREST($uid); $GLOBALS['pear_rest']->saveAllMaintainersREST(); $dbh->query('DELETE FROM users WHERE handle = '. $dbh->quote($uid)); return ($dbh->affectedRows() > 0); } // }}} // {{{ *proto bool user::rejectRequest(string, string) API 1.0 function rejectRequest($uid, $reason) { global $dbh, $auth_user; list($email) = $dbh->getRow('SELECT email FROM users WHERE handle = ?', array($uid)); include_once 'pear-database-note.php'; note::add("uid", $uid, "Account rejected: $reason"); $msg = "Your PEAR account request was rejected by " . $auth_user->handle . ":\n\n". "$reason\n"; $xhdr = "From: " . $auth_user->handle . "@php.net"; mail($email, "Your PEAR Account Request", $msg, $xhdr, "-f bounce-no-user@php.net"); return true; } // }}} // {{{ *proto bool user::activate(string) API 1.0 function activate($uid, $karmalevel = 'pear.dev') { require_once "Damblan/Karma.php"; global $dbh, $auth_user; $user =& new PEAR_User($dbh, $uid); $karma = new Damblan_Karma($dbh); if (@$user->registered) { return false; } @$arr = unserialize($user->userinfo); include_once 'pear-database-note.php'; 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->store(); $karma->grant($user->handle, $karmalevel); if ($karma->has($user->handle, 'pear.dev')) { $GLOBALS['pear_rest']->saveMaintainerREST($user->handle); $GLOBALS['pear_rest']->saveAllMaintainersREST(); } include_once 'pear-database-note.php'; note::add("uid", $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"; mail($user->email, "Your PEAR Account Request", $msg, $xhdr, "-f bounce-no-user@php.net"); return true; } // }}} // {{{ +proto bool user::isAdmin(string) API 1.0 function isAdmin($handle) { require_once "Damblan/Karma.php"; global $dbh; $karma = new Damblan_Karma($dbh); return $karma->has($handle, "pear.admin"); } // }}} // {{{ +proto bool user::isQA(string) API post 1.0 function isQA($handle) { require_once 'Damblan/Karma.php'; global $dbh; $karma = new Damblan_Karma($dbh); return $karma->has($handle, 'pear.qa'); } // }}} // {{{ proto bool user::listAdmins() API 1.0 function listAdmins() { require_once "Damblan/Karma.php"; global $dbh; $karma = new Damblan_Karma($dbh); return $karma->getUser("pear.admin"); } // }}} // {{{ +proto bool user::exists(string) API 1.0 function exists($handle) { global $dbh; $sql = "SELECT handle FROM users WHERE handle=?"; $res = $dbh->query($sql, array($handle)); return ($res->numRows() > 0); } // }}} // {{{ +proto string user::maintains(string|int, [string]) API 1.0 function maintains($user, $pkgid, $role = 'any') { global $dbh; include_once 'pear-database-package.php'; $package_id = package::info($pkgid, 'id'); if ($role == 'any') { return $dbh->getOne('SELECT role FROM maintains WHERE handle = ? '. 'AND package = ?', array($user, $package_id)); } if (is_array($role)) { return $dbh->getOne('SELECT role FROM maintains WHERE handle = ? AND package = ? '. 'AND role IN ("?")', array($user, $package_id, implode('","', $role))); } return $dbh->getOne('SELECT role FROM maintains WHERE handle = ? AND package = ? '. 'AND role = ?', array($user, $package_id, $role)); } // }}} // {{{ function getPackages($user) { global $dbh; $query = 'SELECT p.id, p.name, m.role, m.active' . ' FROM packages p, maintains m' . ' WHERE m.handle = ? AND p.id = m.package AND p.package_type = "pear"' . ' ORDER BY p.name'; return $dbh->getAll($query, array($user)); } // }}} // {{{ proto string user::info(string, [string]) API 1.0 function info($user, $field = null) { global $dbh; if ($field === null) { $row = $dbh->getRow('SELECT * FROM users WHERE registered = 1 AND handle = ?', array($user), DB_FETCHMODE_ASSOC); unset($row['password']); return $row; } if ($field == 'password' || preg_match('/[^a-z]/', $user)) { return null; } return $dbh->getRow('SELECT ! FROM users WHERE handle = ?', array($field, $user), DB_FETCHMODE_ASSOC); } // }}} // {{{ listAll() function listAll($registered_only = true) { global $dbh; $query = "SELECT * FROM users"; if ($registered_only === true) { $query .= " WHERE registered = 1"; } $query .= " ORDER BY handle"; return $dbh->getAll($query, null, DB_FETCHMODE_ASSOC); } // }}} // {{{ add() /** * Add a new user account * * During most of this method's operation, PEAR's error handling * is set to PEAR_ERROR_RETURN. * * But, during the DB_storage::set() phase error handling is set to * PEAR_ERROR_CALLBACK the report_warning() function. So, if an * error happens a warning message is printed AND the incomplete * user information is removed. * * @param array $data Information about the user * * @return mixed true if there are no problems, false if sending the * email failed, 'set error' if DB_storage::set() failed * or an array of error messages for other problems * * @access public */ function add(&$data, $md5ed = false) { global $dbh; PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $errors = array(); $required = array( 'handle' => 'Username', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email address', 'purpose' => 'Intended purpose', ); $name = $data['firstname'] . " " . $data['lastname']; foreach ($required as $field => $desc) { if (empty($data[$field])) { $data['jumpto'] = $field; $errors[] = 'Please enter ' . $desc; } } if (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $data['handle'])) { $errors[] = 'Username must start with a letter and contain' . ' only letters and digits'; } // Basic name validation // First- and lastname must be longer than 1 character if (strlen($data['firstname']) == 1) { $errors[] = 'Your firstname appears to be too short.'; } if (strlen($data['lastname']) == 1) { $errors[] = 'Your lastname appears to be too short.'; } // Firstname and lastname must start with an uppercase letter if (!preg_match("/^[A-Z]/", $data['firstname'])) { $errors[] = 'Your firstname must begin with an uppercase letter'; } if (!preg_match("/^[A-Z]/", $data['lastname'])) { $errors[] = 'Your lastname must begin with an uppercase letter'; } // No names with only uppercase letters if ($data['firstname'] === strtoupper($data['firstname'])) { $errors[] = 'Your firstname must not consist of only uppercase letters.'; } if ($data['lastname'] === strtoupper($data['lastname'])) { $errors[] = 'Your lastname must not consist of only uppercase letters.'; } if ($data['password'] != $data['password2']) { $data['password'] = $data['password2'] = ""; $data['jumpto'] = "password"; $errors[] = 'Passwords did not match'; } if (!$data['password']) { $data['jumpto'] = "password"; $errors[] = 'Empty passwords not allowed'; } $handle = strtolower($data['handle']); $obj =& new PEAR_User($dbh, $handle); if (isset($obj->created)) { $data['jumpto'] = "handle"; $errors[] = 'Sorry, that username is already taken'; } if ($errors) { $data['display_form'] = true; return $errors; } $err = $obj->insert($handle); if (DB::isError($err)) { if ($err->getCode() == DB_ERROR_CONSTRAINT) { $data['display_form'] = true; $data['jumpto'] = 'handle'; $errors[] = 'Sorry, that username is already taken'; } else { $data['display_form'] = false; $errors[] = $err; } return $errors; } $data['display_form'] = false; if ($md5ed) { $md5pw = $data['password']; } else { $md5pw = md5($data['password']); } $showemail = @(bool)$data['showemail']; // hack to temporarily embed the "purpose" in // the user's "userinfo" column $userinfo = serialize(array($data['purpose'], $data['moreinfo'])); $set_vars = array('name' => $name, 'email' => $data['email'], 'homepage' => $data['homepage'], 'showemail' => $showemail, 'password' => $md5pw, 'registered' => 0, 'userinfo' => $userinfo); PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, 'report_warning'); foreach ($set_vars as $var => $value) { $err = $obj->set($var, $value); if (PEAR::isError($err)) { user::remove($data['handle']); return 'set error'; } } $obj->store(); PEAR::popErrorHandling(); $msg = "Requested from: {$_SERVER['REMOTE_ADDR']}\n". "Username: {$handle}\n". "Real Name: {$name}\n". (isset($data['showemail']) ? "Email: {$data['email']}\n" : "") . "Purpose:\n". "{$data['purpose']}\n\n". "To handle: http://{$_SERVER['SERVER_NAME']}/admin/?acreq={$handle}\n"; if ($data['moreinfo']) { $msg .= "\nMore info:\n{$data['moreinfo']}\n"; } $xhdr = "From: $name <{$data['email']}>\nMessage-Id: <account-request-{$handle}@" . PEAR_CHANNELNAME . ">\n"; // $xhdr .= "\nBCC: pear-group@php.net"; $subject = "PEAR Account Request: {$handle}"; if (DEVBOX == false) { if (PEAR_CHANNELNAME == 'pear.php.net') { $ok = @mail('pear-group@php.net', $subject, $msg, $xhdr, '-f bounce-no-user@php.net'); } } else { $ok = true; } PEAR::popErrorHandling(); return $ok; } // }}} // {{{ update /** * Update user information * * @access public * @param array User information * @return object Instance of PEAR_User */ function update($data) { global $dbh; $fields = array('name', 'email', 'homepage', 'showemail', 'userinfo', 'pgpkeyid', 'wishlist', 'latitude', 'longitude', ); $user =& new PEAR_User($dbh, $data['handle']); foreach ($data as $key => $value) { if (!in_array($key, $fields)) { continue; } $user->set($key, $value); } $user->store(); return $user; } // }}} // {{{ getRecentReleases(string, [int]) /** * Get recent releases for the given user * * @access public * @param string Handle of the user * @param int Number of releases (default is 10) * @return array */ function getRecentReleases($handle, $n = 10) { global $dbh; $recent = array(); $query = "SELECT p.id AS id, " . "p.name AS name, " . "p.summary AS summary, " . "r.version AS version, " . "r.releasedate AS releasedate, " . "r.releasenotes AS releasenotes, " . "r.doneby AS doneby, " . "r.state AS state " . "FROM packages p, releases r, maintains m " . "WHERE p.package_type = 'pear' AND p.id = r.package " . "AND p.id = m.package AND m.handle = '" . $handle . "' " . "ORDER BY r.releasedate DESC"; $sth = $dbh->limitQuery($query, 0, $n); while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) { $recent[] = $row; } return $recent; } // }}} // {{{ * proto array user::getWhoIsWho() API 1.0 /** * Get list of current developers and the packages they maintain. * * The output of this method is used on public websites for * a Who Is Who of the PEAR developers. In order to avoid abuse, * access to this method via XML_RPC is granted based on a whitelist * of IP addresses. * * @access public * @return array */ function getWhoIsWho() { global $dbh; // IP whitelist if (!in_array($_SERVER['REMOTE_ADDR'], array('209.61.191.11'))) { return array(); } $query_maintainers = "SELECT p.name, m.role, p.package_type " . "FROM maintains m, packages p " . "WHERE m.package = p.id AND m.handle = ?"; $maintainers = $dbh->prepare($query_maintainers); $group = $dbh->prepare("SELECT COUNT(id) " . "FROM karma " . "WHERE level = 'pear.group' AND user = ?"); /* The PECL developers don't have the "pear.dev" karma level. * Thus every registered user needs to be checked. */ $query = "SELECT handle, name, homepage, userinfo " . "FROM users WHERE registered = 1"; $query_group = "SELECT user FROM karma WHERE level = 'pear.group'"; $group_ids = $dbh->getCol($query_group); $group_ids = array_flip($group_ids); $users = $dbh->getAll($query, null, DB_FETCHMODE_ASSOC); foreach ($users as $id => $user) { // Figure out which packages are maintained by the user $sth = $dbh->execute($maintainers, array($user['handle'])); // Skip if the user is maintaining nothing if ($sth->numRows() == 0) { unset($users[$id]); continue; } while ($row =& $sth->fetchRow(DB_FETCHMODE_ASSOC)) { $users[$id]['maintains'][] = $row; if (!isset($users[$id]['type'])) { $users[$id]['type'] = 0; } // Returned 'type' is 1 for PEAR, 2 for PECL or 3 for both switch ($users[$id]['type']) { case '3': break; case '2': if ($row['package_type'] == 'pear') { $users[$id]['type'] = 3; } break; case '1': if ($row['package_type'] == 'pecl') { $users[$id]['type'] = 3; } break; default: if ($row['package_type'] == 'pecl') { $users[$id]['type'] = 2; } else { $users[$id]['type'] = 1; } break; } } if (isset($group_ids[$user['handle']])) { $users[$id]['group'] = 1; } else { $users[$id]['group'] = 0; } } return $users; } // }}} } require_once 'DB/storage.php'; class PEAR_User extends DB_storage { function PEAR_User(&$dbh, $user) { $this->DB_storage("users", "handle", $dbh); if (strpos($user, '@')) { $this->DB_storage('users', 'email', $dbh); } else { $this->DB_storage('users', 'handle', $dbh); } $this->pushErrorHandling(PEAR_ERROR_RETURN); $this->setup($user); $this->popErrorHandling(); } function is($handle) { global $auth_user; if (isset($auth_user) && $auth_user) { $ret = strtolower($auth_user->handle); } else { $ret = strtolower($this->handle); } return (strtolower($handle) == $ret); } function isAdmin() { return (user::isAdmin($this->handle)); } function isQA() { return user::isQA($this->handle); } /** * Generate link for user * * @access public * @return string */ function makeLink() { return make_link("/user/" . $this->handle . "/", $this->name); } } http://cvs.php.net/viewvc.cgi/pearweb/include/xmlrpc-testlogin.php?view=markup&rev=1.1 Index: pearweb/include/xmlrpc-testlogin.php +++ pearweb/include/xmlrpc-testlogin.php <?php /** * Defines one test function for the xmlrpc interface * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category pearweb * @package xmlrpc * @author Helgi Þormar Þorbjörnsson <dufuz@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License * @version $Id: xmlrpc-testlogin.php,v 1.1 2007/04/22 01:51:35 dufuz Exp $ */ // {{{ +proto string logintest() API 1.0 function logintest() { return true; } // }}}
« previous php.pear.cvs (#46085) next »