patch as promised
| From: | Steph | Date: | Mon, 13 Sep 2004 12:35:35 +0000 |
| Subject: | patch as promised | ||
| Groups: | php.pear.webmaster | ||
| Request: | Send a blank email to pear-webmaster+get-3130@lists.php.net to get a copy of this message | ||
Hi again,
Attached: a patch for pear-database.php which should meet with everyone's
approval, and might even work. It disables the function for everyone except
localhost, so doesn't need to await an outcome before being applied.
Note that you will also need to rename the field in the users table (or else
change the field name throughout both these patches before applying either
of them). The only reason for the field name change is clarity; whether or
not you make the change depends on how important you feel that is.
ALTER TABLE users CHANGE anon public_info tinyint(1) default NULL;
Note that I've had no opportunity to test anything here - the layout and
wording in the patch for account-edit.php may leave something to be desired.
It's only attached so that you can see what I'm talking about.
- Steph
DevZone Editor
www.zend.com
--- account-edit.php Mon Sep 13 12:52:00 2004 +++ account-edit_new.php Mon Sep 13 13:18:48 2004 @@ -36,7 +36,8 @@ print '<h1>Edit Profile: '; print '<a href="/user/'. $handle . '">' . $handle . '</a></h1>' . "\n"; -print "<ul><li><a href=\"#password\">Manage your password</a></li></ul>"; +print "<ul><li><a href=\"#password\">Manage your password</a></li>"; +print "<li><a href=\"#zprofile\">Update your public profile</a></li></ul>"; $admin = $auth_user->isAdmin(); $user = $auth_user->is($handle); @@ -201,6 +202,67 @@ $form->addHidden('command', 'change_password'); $form->display('class="form-holder" cellspacing="1"', 'Change Password', 'class="form-caption"'); + + +print '<a name="zprofile"></a>' . "\n"; +print '<h2>» Update your public profile</h2>' . "\n"; +print '<b>Some people like to have their profile published elsewhere, and others do not.</b>' . "\n"; +print "If you allow it, the following sites will have access to the 'Homepage' and 'Additional User Information' fields in your standard profile, plus any fields you choose to complete below:\n"; +/* Please make sure that this list tallies with the whitelisted IP addresses in getWhoIsWho() */ +print '<ul><li>Zend (www.zend.com)</li></ul>'; +print "By default, only your name, username, and the packages you maintain are shared.\n"; + +$form = new HTML_Form($_SERVER['PHP_SELF'], 'post'); +$form->addCheckbox('public_info', 'I would like my personal information to be published on the sites listed above', + $row['public_info'], '', + $th, $td); +$form->addText('birthdate', 'Date of birth:', + $row['birthdate'], 40, null, '', + $th, $td); +$form->addText('locale', 'Location:', + $row['locale'], 40, null, '', + $th, $td); +$form->addText('timezone', 'Timezone:', + $row['timezone'], 40, null, '', + $th, $td); +$form->addText('occupation', 'Occupation:', + $row['occupation'], 40, null, '', + $th, $td); +$form->addTextarea('currentjob', 'Current employment:', + $row['currentjob'], 40, 3, null, '', + $th, $td); +$form->addCheckbox('available', 'Available for work?', + $row['available'], '', + $th, $td); +$form->addSelect('certified', 'Zend certified?', array('no', 'PHP 4', 'PHP 5'), 'no', + $row['certified'], 40, null, '', + $th, $td); +$form->addTextarea('otherquals', 'Other qualifications:', + $row['email'], 40, 3, null, '', + $th, $td); +$form->addTextarea('spokenlangs', 'Spoken languages:', + $row['showemail'], 40, 3, null, '', + $th, $td); +$form->addTextarea('programlangs', 'Programming languages:', + $row['programlangs'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otherphpnet', 'Other php.net work:', + $row['otherphpnet'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otheross', 'Other open source projects:' + $row['otheross'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otherhobbies', + 'Non-programming hobbies:', + $row['otherhobbies'], 40, 5, null, '', + $th, $td); +$form->addSubmit('submit', 'Submit', '', + $th, $td); +$form->addHidden('handle', $handle); +$form->addHidden('command', 'update'); +$form->display('class="form-holder" style="margin-bottom: 2em;"' + . ' cellspacing="1"', + 'Edit Your Public Profile', 'class="form-caption"'); ob_end_flush(); response_footer(); --- pear-database.php Mon Sep 13 12:19:00 2004 +++ pear-database_new.php Mon Sep 13 13:13:26 2004 @@ -2314,25 +2314,27 @@ } // }}} - // {{{ * proto array user::getZendWhoIsWho() API 1.0 + // {{{ * 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 the Zend.com website for - * a Who Is Who of the PEAR developers. In order to avoid abuse, + * The output of this method is used on public websites to create + * a Who Is Who of active PEAR and PECL developers. In order to avoid abuse, * access to this method via XML_RPC is granted based on a whitelist * of IP addresses. * + * NOTE: If you add a new IP address to the whitelist, please also update the list + * of sites that have access to this function in /public_html/account-edit.php + * * @access public * @return array */ - function getZendWhoIsWho() { - return false; // until we can flag agreement I guess. + function getWhoIsWho() { global $dbh; // IP whitelist - if (!in_array($_SERVER['REMOTE_ADDR'], array("127.0.0.1", "209.61.191.11"))) { + if (!in_array($_SERVER['REMOTE_ADDR'], array("127.0.0.1"))) { return array(); } @@ -2350,7 +2352,7 @@ . "birthdate, locale, timezone, occupation, " . "currentjob, available, certified, otherquals, " . "spokenlangs, programlangs, otherphpnet, " - . "otheross, otherhobbies, anon " + . "otheross, otherhobbies, public_info " . "FROM users WHERE registered = 1"; $query_group = "SELECT user FROM karma WHERE level = 'pear.group'"; @@ -2370,13 +2372,34 @@ continue; } + // Unset all but core info (handle, name) if public_info flag is negative + if ($user['public_info'] == '0') { + $users[$id]['homepage'] = ''; + $users[$id]['userinfo'] = ''; + $users[$id]['birthdate'] = ''; + $users[$id]['locale'] = ''; + $users[$id]['timezone'] = ''; + $users[$id]['occupation'] = ''; + $users[$id]['currentjob']; + $users[$id]['available'] = ''; + $users[$id]['certified'] = ''; + $users[$id]['otherquals'] = ''; + $users[$id]['spokenlangs'] = ''; + $users[$id]['programlangs'] = ''; + $users[$id]['otherphpnet'] = ''; + $users[$id]['otheross'] = ''; + $users[$id]['otherhobbies'] = ''; + } + + // Nobody needs this field beyond this point + unset($users[$id]['public_info']); + + $users[$id]['type'] = 0; + 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;
--- account-edit.php Mon Sep 13 12:52:00 2004 +++ account-edit_new.php Mon Sep 13 13:18:48 2004 @@ -36,7 +36,8 @@ print '<h1>Edit Profile: '; print '<a href="/user/'. $handle . '">' . $handle . '</a></h1>' . "\n"; -print "<ul><li><a href=\"#password\">Manage your password</a></li></ul>"; +print "<ul><li><a href=\"#password\">Manage your password</a></li>"; +print "<li><a href=\"#zprofile\">Update your public profile</a></li></ul>"; $admin = $auth_user->isAdmin(); $user = $auth_user->is($handle); @@ -201,6 +202,67 @@ $form->addHidden('command', 'change_password'); $form->display('class="form-holder" cellspacing="1"', 'Change Password', 'class="form-caption"'); + + +print '<a name="zprofile"></a>' . "\n"; +print '<h2>» Update your public profile</h2>' . "\n"; +print '<b>Some people like to have their profile published elsewhere, and others do not.</b>' . "\n"; +print "If you allow it, the following sites will have access to the 'Homepage' and 'Additional User Information' fields in your standard profile, plus any fields you choose to complete below:\n"; +/* Please make sure that this list tallies with the whitelisted IP addresses in getWhoIsWho() */ +print '<ul><li>Zend (www.zend.com)</li></ul>'; +print "By default, only your name, username, and the packages you maintain are shared.\n"; + +$form = new HTML_Form($_SERVER['PHP_SELF'], 'post'); +$form->addCheckbox('public_info', 'I would like my personal information to be published on the sites listed above', + $row['public_info'], '', + $th, $td); +$form->addText('birthdate', 'Date of birth:', + $row['birthdate'], 40, null, '', + $th, $td); +$form->addText('locale', 'Location:', + $row['locale'], 40, null, '', + $th, $td); +$form->addText('timezone', 'Timezone:', + $row['timezone'], 40, null, '', + $th, $td); +$form->addText('occupation', 'Occupation:', + $row['occupation'], 40, null, '', + $th, $td); +$form->addTextarea('currentjob', 'Current employment:', + $row['currentjob'], 40, 3, null, '', + $th, $td); +$form->addCheckbox('available', 'Available for work?', + $row['available'], '', + $th, $td); +$form->addSelect('certified', 'Zend certified?', array('no', 'PHP 4', 'PHP 5'), 'no', + $row['certified'], 40, null, '', + $th, $td); +$form->addTextarea('otherquals', 'Other qualifications:', + $row['email'], 40, 3, null, '', + $th, $td); +$form->addTextarea('spokenlangs', 'Spoken languages:', + $row['showemail'], 40, 3, null, '', + $th, $td); +$form->addTextarea('programlangs', 'Programming languages:', + $row['programlangs'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otherphpnet', 'Other php.net work:', + $row['otherphpnet'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otheross', 'Other open source projects:' + $row['otheross'], 40, 3, null, '', + $th, $td); +$form->addTextarea('otherhobbies', + 'Non-programming hobbies:', + $row['otherhobbies'], 40, 5, null, '', + $th, $td); +$form->addSubmit('submit', 'Submit', '', + $th, $td); +$form->addHidden('handle', $handle); +$form->addHidden('command', 'update'); +$form->display('class="form-holder" style="margin-bottom: 2em;"' + . ' cellspacing="1"', + 'Edit Your Public Profile', 'class="form-caption"'); ob_end_flush(); response_footer(); --- pear-database.php Mon Sep 13 12:19:00 2004 +++ pear-database_new.php Mon Sep 13 13:13:26 2004 @@ -2314,25 +2314,27 @@ } // }}} - // {{{ * proto array user::getZendWhoIsWho() API 1.0 + // {{{ * 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 the Zend.com website for - * a Who Is Who of the PEAR developers. In order to avoid abuse, + * The output of this method is used on public websites to create + * a Who Is Who of active PEAR and PECL developers. In order to avoid abuse, * access to this method via XML_RPC is granted based on a whitelist * of IP addresses. * + * NOTE: If you add a new IP address to the whitelist, please also update the list + * of sites that have access to this function in /public_html/account-edit.php + * * @access public * @return array */ - function getZendWhoIsWho() { - return false; // until we can flag agreement I guess. + function getWhoIsWho() { global $dbh; // IP whitelist - if (!in_array($_SERVER['REMOTE_ADDR'], array("127.0.0.1", "209.61.191.11"))) { + if (!in_array($_SERVER['REMOTE_ADDR'], array("127.0.0.1"))) { return array(); } @@ -2350,7 +2352,7 @@ . "birthdate, locale, timezone, occupation, " . "currentjob, available, certified, otherquals, " . "spokenlangs, programlangs, otherphpnet, " - . "otheross, otherhobbies, anon " + . "otheross, otherhobbies, public_info " . "FROM users WHERE registered = 1"; $query_group = "SELECT user FROM karma WHERE level = 'pear.group'"; @@ -2370,13 +2372,34 @@ continue; } + // Unset all but core info (handle, name) if public_info flag is negative + if ($user['public_info'] == '0') { + $users[$id]['homepage'] = ''; + $users[$id]['userinfo'] = ''; + $users[$id]['birthdate'] = ''; + $users[$id]['locale'] = ''; + $users[$id]['timezone'] = ''; + $users[$id]['occupation'] = ''; + $users[$id]['currentjob']; + $users[$id]['available'] = ''; + $users[$id]['certified'] = ''; + $users[$id]['otherquals'] = ''; + $users[$id]['spokenlangs'] = ''; + $users[$id]['programlangs'] = ''; + $users[$id]['otherphpnet'] = ''; + $users[$id]['otheross'] = ''; + $users[$id]['otherhobbies'] = ''; + } + + // Nobody needs this field beyond this point + unset($users[$id]['public_info']); + + $users[$id]['type'] = 0; + 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;