cvs: pearweb /include pear-format-html.php /public_html account-edit.php account-info.php accounts.php authors.php detail-author.php edit-author.php
pkginfo.php

From: Date: Fri, 16 Nov 2001 09:21:07 +0000
Subject: cvs: pearweb /include pear-format-html.php /public_html account-edit.php account-info.php accounts.php authors.php detail-author.php edit-author.php
pkginfo.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1338@lists.php.net to get a copy of this message
ssb Fri Nov 16 04:21:07 2001 EDT Added files: /pearweb/public_html account-edit.php account-info.php accounts.php Removed files: /pearweb/public_html authors.php detail-author.php edit-author.php Modified files: /pearweb/include pear-format-html.php /pearweb/public_html pkginfo.php Log: * renamed "author" to "account" to make the terminology match PHP better * implemented simple cvs acl editing

Index: pearweb/include/pear-format-html.php diff -u pearweb/include/pear-format-html.php:1.19 pearweb/include/pear-format-html.php:1.20 --- pearweb/include/pear-format-html.php:1.19 Sun Oct 21 05:08:47 2001 +++ pearweb/include/pear-format-html.php Fri Nov 16 04:21:06 2001 @@ -5,22 +5,22 @@ require_once 'layout.php'; $GLOBALS['main_menu'] = array( - 'index.php' => 'Home', - '/manual/index.php' => 'Documentation', - 'faq.php' => 'PEAR FAQ', - 'packages.php' => 'Browse Packages', - 'authors.php' => 'Browse Authors', - 'account-request.php' => 'Request Account' + '/index.php' => 'Home', + '/manual/index.php' => 'Documentation', + '/faq.php' => 'PEAR FAQ', + '/packages.php' => 'Package Browser', + '/accounts.php' => 'Account Browser', + '/account-request.php' => 'Request Account' ); -$GLOBALS['author_menu'] = array( - 'package-new.php' => 'New Package', - 'release-upload.php' => 'Upload Release' +$GLOBALS['user_menu'] = array( + '/package-new.php' => 'New Package', + '/release-upload.php' => 'Upload Release' ); $GLOBALS['admin_menu'] = array( - 'admin.php' => 'Account Requests', - 'category-manager.php' => 'Manage Categories' + '/admin.php' => 'Account Requests', + '/category-manager.php' => 'Manage Categories' ); $GLOBALS['_style'] = ''; @@ -42,8 +42,8 @@ init_auth_user(); if (!empty($auth_user)) { if (!empty($auth_user->registered)) { - global $author_menu; - $SIDEBAR_DATA .= draw_navigation($author_menu, 'Author Actions:'); + global $user_menu; + $SIDEBAR_DATA .= draw_navigation($user_menu, 'User Actions:'); } if (!empty($auth_user->admin)) { global $admin_menu; Index: pearweb/public_html/pkginfo.php diff -u pearweb/public_html/pkginfo.php:1.8 pearweb/public_html/pkginfo.php:1.9 --- pearweb/public_html/pkginfo.php:1.8 Sun Sep 9 12:18:06 2001 +++ pearweb/public_html/pkginfo.php Fri Nov 16 04:21:07 2001 @@ -29,19 +29,19 @@ $release_date = '2000-01-34'; $release_notes = 'Bug fix release'; -// Authors data +// Accounts data $sth = $dbh->query("SELECT u.handle, u.name, u.email, u.showemail, m.role FROM maintains m, users u WHERE m.package = $pacid AND m.handle = u.handle"); -$authors = ''; +$accounts = ''; while ($sth->fetchInto($row)) { - $authors .= "<tr><td>{$row['name']}"; + $accounts .= "<tr><td>{$row['name']}"; if ($row['showemail'] == 1) { - $authors .= " &lt;<a href=\"mailto:{$row['email']}\">{$row['email']}</a>&gt;"; + $accounts .= " &lt;<a href=\"mailto:{$row['email']}\">{$row['email']}</a>&gt;"; } - $authors .= " ({$row['role']}) [<a href=\"detail-author.php?handle={$row['handle']}\">details</a>]"; - $authors .= "</td></tr>\n"; + $accounts .= " ({$row['role']}) [<a href=\"account-info.php?handle={$row['handle']}\">details</a>]"; + $accounts .= "</td></tr>\n"; } response_header("Package :: $name"); @@ -56,11 +56,11 @@ <td><?php echo $summary;?></td> </tr> <tr> - <th class="pack" bgcolor="#009933" width="20%">Authors</th> + <th class="pack" bgcolor="#009933" width="20%">Accounts</th> <td> - <!-- Authors --> + <!-- Accounts --> <table border="0" cellspacing="1" cellpadding="1" width="100%"> - <?php echo $authors;?> + <?php echo $accounts;?> </table> </td> </tr> Index: pearweb/public_html/account-edit.php +++ pearweb/public_html/account-edit.php <?php auth_require(true); require_once "HTML/Form.php"; if (isset($HTTP_GET_VARS['handle'])) { $handle = $HTTP_GET_VARS['handle']; } elseif (isset($HTTP_POST_VARS['handle'])) { $handle = $HTTP_POST_VARS['handle']; } else { $handle = ""; } response_header("Edit Account: $handle"); if (empty($handle) && !isset($HTTP_POST_VARS['command'])) { PEAR::raiseError("No valid handle found!"); } if (!isset($HTTP_POST_VARS['command'])) { $HTTP_POST_VARS['command'] = "display"; } switch ($HTTP_POST_VARS['command']) { case "update" : { $query = sprintf("UPDATE users SET name = '%s', email = '%s', homepage = '%s', userinfo = '%s', showemail = '%s', admin = '%s'", $HTTP_POST_VARS['name'], $HTTP_POST_VARS['email'], $HTTP_POST_VARS['homepage'], $HTTP_POST_VARS['userinfo'], isset($HTTP_POST_VARS['showemail']) ? 1 : 0, isset($HTTP_POST_VARS['admin']) ? 1 : 0); $query .= " WHERE handle = '" . $HTTP_POST_VARS['handle'] . "'"; $sth = $dbh->query($query); $old_acl = $dbh->getCol("SELECT path FROM cvs_acl ". "WHERE handle = ? AND access = 1", 0, array($handle)); $new_acl = preg_split("/[\r\n]+/", trim($cvs_acl)); $lost_entries = array_diff($old_acl, $new_acl); $new_entries = array_diff($new_acl, $old_acl); if (sizeof($lost_entries) > 0) { $sth = $dbh->prepare("DELETE FROM cvs_acl WHERE handle = ? ". "AND path = ?"); foreach ($lost_entries as $ent) { $del = $dbh->affectedRows(); print "Removing CVS access to $ent for $handle...<br />\n"; $dbh->execute($sth, array($handle, $ent)); } } if (sizeof($new_entries) > 0) { $sth = $dbh->prepare("INSERT INTO cvs_acl (handle,path,access) ". "VALUES(?,?,?)"); foreach ($new_entries as $ent) { print "Adding CVS access to $ent for $handle...<br />\n"; $dbh->execute($sth, array($handle, $ent, 1)); } } print "<i>The update has been executed successfully.</i>"; print "<br /><br />"; print "<a href=\"account-info.php?handle=$handle\">"; print "[Back to info page]</a>"; $handle = $HTTP_POST_VARS['handle']; response_footer(); return; } default : { $dbh->setFetchmode(DB_FETCHMODE_ASSOC); $row = $dbh->getRow("SELECT * FROM users WHERE handle = ?", array($handle)); $cvs_acl_arr = $dbh->getCol("SELECT path FROM cvs_acl ". "WHERE handle = ? AND access = 1", 0, array($handle)); $cvs_acl = implode("\n", $cvs_acl_arr); if ($row === null) { PEAR::raiseError("No account information found!"); } print "<form action=\"" . $HTTP_SERVER_VARS['PHP_SELF'] . "\" method=\"post\">\n"; print "<input type=\"hidden\" name=\"command\" value=\"update\" />\n"; print "<input type=\"hidden\" name=\"handle\" value=\"$handle\" />\n"; print "<h1>Editing account \"".$handle."\"</h1>\n"; print "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Handle:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".$handle."</td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Name:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayText("name", $row['name']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">EMail:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayText("email", $row['email']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Homepage:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayText("homepage", $row['homepage']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Additional user information:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayTextarea("userinfo", $row['userinfo']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">CVS Access:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayTextarea("cvs_acl", $cvs_acl); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Show EMail adress:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayCheckbox("showemail", $row['showemail']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Administrator:</th>\n"; print " <td bgcolor=\"#e8e8e8\">"; HTML_Form::displayCheckbox("admin", $row['admin']); print " </td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">&nbsp;</th>\n"; print " <td bgcolor=\"#e8e8e8\"><input type=\"submit\" />&nbsp;<input type=\"reset\" /></td>\n"; print " </tr>\n"; print "</table>\n"; print "</form>\n"; response_footer(); } } ?> Index: pearweb/public_html/account-info.php +++ pearweb/public_html/account-info.php <?php /** * Details about PEAR accounts * * $Id: account-info.php,v 1.1 2001/11/16 09:21:06 ssb Exp $ */ /** * Redirect to the accounts list if no ID was specified */ if (!isset($HTTP_GET_VARS['handle'])) { localRedirect("/accounts.php"); } else { $handle = $HTTP_GET_VARS['handle']; } response_header("Author information"); $dbh->setFetchmode(DB_FETCHMODE_ASSOC); $row = $dbh->getRow("SELECT * FROM users WHERE registered = 1 AND handle = ?", array($handle)); if ($row === null) { PEAR::raiseError("No account information found!"); } $access = $dbh->getCol("SELECT path FROM cvs_acl WHERE handle = ?", 0, array($handle)); print "<h1>Information about account \"".$handle."\"</h1>\n"; print "<a href=\"account-edit.php?handle=$handle\">[Edit]</a>"; print "<br />\n"; print "<br />\n"; print "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Handle:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".$handle."</td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Name:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".$row['name']."</td>\n"; print " </tr>\n"; if ($row['showemail'] != 0) { print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">EMail:</th>\n"; print " <td bgcolor=\"#e8e8e8\"><a href=\"mailto:".$row['email']."\">".$row['email']."</a></td>\n"; print " </tr>\n"; } if ($row['homepage'] != "") { print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Homepage:</th>\n"; print " <td bgcolor=\"#e8e8e8\"><a href=\"".$row['homepage']."\" target=\"_blank\">".$row['homepage']."</a></td>\n"; print " </tr>\n"; } print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Registered since:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".$row['created']."</td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th bgcolor=\"#CCCCCC\">Additional information:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".$row['userinfo']."&nbsp;</td>\n"; print " </tr>\n"; print " <tr>\n"; print " <th valign=\"top\" bgcolor=\"#cccccc\">CVS Access:</th>\n"; print " <td bgcolor=\"#e8e8e8\">".implode("<br />", $access)."</td>\n"; print " </tr>\n"; if ($row['admin'] == 1) { print " <tr>\n"; print " <td colspan=\"2\" bgcolor=\"#e8e8e8\">".$row['name']." is a PEAR administrator.</td>\n"; print " </tr>\n"; } print "</table>\n"; $query = "SELECT p.id, p.name, m.role FROM packages p, maintains m WHERE m.handle = '$handle' AND p.id = m.package ORDER BY p.name"; $sth = $dbh->query($query); if (DB::IsError($sth)) { DB::raiseError("query failed: ".$sth->message); } if ($sth->numRows() > 0) { print "<br /><br />\n"; print "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">\n"; print " <tr>\n"; print " <th colspan=\"2\" bgcolor=\"#e8e8e8\">Maintaining the following packages:</td>"; print " </tr>\n<tr><th bgcolor=\"#e8e8e8\">Package Name</th>"; print "<th bgcolor=\"#e8e8e8\">Role</th></tr>\n"; while (is_array($row = $sth->fetchRow())) { print " <tr>\n"; print " <td bgcolor=\"#e8e8e8\">"; print " <a href=\"pkginfo.php?pacid={$row['id']}\">{$row['name']}</a>"; print " </td>\n"; print " <td bgcolor=\"#e8e8e8\" align=\"center\">{$row['role']}"; print " </td>\n"; print " </tr>\n"; } print "</table>"; } response_footer(); ?> Index: pearweb/public_html/accounts.php +++ pearweb/public_html/accounts.php <?php auth_require(); response_header("Accounts"); $page_size = 20; print "<H1>Accounts</H1>\n"; $all_firstletters = $dbh->getCol('SELECT SUBSTRING(handle,1,1) FROM users '. 'WHERE registered = 1 ORDER BY handle'); // I wish there was a way to do this in mysql... $first_letter_offsets = array(); for ($i = 0; $i < sizeof($all_firstletters); $i++) { $l = $all_firstletters[$i]; if (isset($first_letter_offsets[$l])) { continue; } $first_letter_offsets[$l] = $i; } if (preg_match('/^[a-z]$/i', @$letter)) { $offset = $first_letter_offsets[$letter]; $offset -= $offset % $page_size; } if (empty($show)) { $show = $page_size; } else { settype($show, "integer"); } settype($offset, "integer"); $naccounts = $dbh->getOne("SELECT COUNT(handle) FROM users ". "WHERE registered = 1"); $last_shown = $offset + $page_size - 1; $firstletters = array_unique($all_firstletters); $last = $offset - $page_size; $lastlink = "$PHP_SELF?offset=$last"; $next = $offset + $page_size; $nextlink = "$PHP_SELF?offset=$next"; print "<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\">\n"; print " <tr bgcolor=\"#cccccc\">\n"; print " <th>"; if ($offset > 0) { print "<a href=\"$lastlink\">&lt;&lt; Last $page_size</a>"; } else { print "&nbsp;"; } print "</th>\n"; print " <td colspan=\"3\">"; print '<table border="0"><tr><td>'; foreach ($firstletters as $fl) { $o = $first_letter_offsets[$fl]; if ($o >= $offset && $o <= $last_shown) { printf('<b>%s</b> ', strtoupper($fl)); } else { printf('<a href="%s?letter=%s">%s</a> ', $PHP_SELF, $fl, strtoupper($fl)); } } print '</td><td rowspan="2">'; print '<form><input type="button" onclick="'; $gourl = "http://" . $HTTP_SERVER_VARS['SERVER_NAME']; if ($HTTP_SERVER_VARS['SERVER_PORT'] != 80) { $gourl .= ":".$HTTP_SERVER_VARS['SERVER_PORT']; } $gourl .= "/account-info.php"; print "u=prompt('Go to account:','');if(u)location.href='$gourl?handle='+u;"; print '" value="Go to account.."/></td></tr><tr><td>'; printf("Displaying accounts %d - %d of %d<br />\n", $offset, min($offset+$show, $naccounts), $naccounts); $sth = $dbh->limitQuery('SELECT handle,name,email,homepage,showemail '. 'FROM users WHERE registered = 1 ORDER BY handle', $offset, $show); if (DB::isError($sth)) { die("query failed: ".DB::errorMessage($dbh)."<br />\n"); } print "</td></tr></table>\n"; print "</td>\n"; print " <th>"; if ($offset + $page_size < $naccounts) { $nn = min($page_size, $naccounts - $offset - $page_size); print "<a href=\"$nextlink\">Next $nn &gt;&gt;</a>"; } else { print "&nbsp;"; } print "</th>\n"; print " </tr>\n"; print " <tr bgcolor=\"#CCCCCC\">\n"; print " <th>Handle</th>\n"; print " <th>Name</th>\n"; print " <th>Email</th>\n"; print " <th>Homepage</th>\n"; print " <th>Commands</th>\n"; print " </tr>\n"; $rowno = 0; while (is_array($row = $sth->fetchRow(DB_FETCHMODE_ASSOC))) { extract($row); if (++$rowno % 2) { print " <tr bgcolor=\"#e8e8e8\">\n"; } else { print " <tr bgcolor=\"#e0e0e0\">\n"; } print " <td>$handle</td>\n"; print " <td>$name</td>\n"; if ($showemail) { print " <td><a href=\"mailto:$email\">$email</a></td>\n"; } else { print " <td>(not shown)</td>\n"; } if (!empty($homepage)) { print "<td><a href=\"$homepage\">$homepage</a></td>"; } else { print '<td>&nbsp;</td>'; } print "\n <td><a href=\"account-edit.php?handle=".$row['handle']."\">[E]</a>&nbsp; <a href=\"account-info.php?handle=".$row['handle']."\">[I]</A></td>\n"; print " </tr>\n"; } print "</table>\n"; response_footer(); ?>
« previous php.pear.cvs (#1338) next »