<?php
###############################################################################
# Copyright (C) 2000 Derek Leung
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# You may modify your copy or copies of this Program or any portion of it,
# but you must cause the modified files to carry prominent notices stating
# that you changed the files and the date of any change. And you are required
# to keep a copy of this License along with this Program.
#
# You are not required to accept this License, since you have not signed it.
# However, nothing else grants you permission to modify or distribute this
# Program or its derivative works. These actions are prohibited by law if
# you do not accept this License. Therefore, by modifying or distributing
# this Program (or any work based on this Program), you indicate your
# acceptance of this License to do so, and all its terms and conditions
# for copying, distributing or modifying this Program or works based on it.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# See the GNU General Public License for more details.
# http://www.opensource.org/licenses/gpl-license.html
#
# Code base on myPhportal http://sourceforge.net/projects/myphportal
#
###############################################################################
require("mainfile.php");
###################################################################################################################
# Main program start here
###################################################################################################################
// show the header
ps_header("");;
// initialize variable
$pagesize = 20;
$filepath="memberslist.php";
if (!isset($letter)) { $letter = "All"; }
if (!isset($sortby)) { $sortby = "uname"; }
if (!isset($orderby)) { $orderby = "ASC"; }
if (!isset($page)) { $page = 1; }
/* This is the header section that displays the last registered and who's logged in and whatnot */
$result = mysql_query("select uname from ps_users order by uid DESC limit 0,1");
list($lastuser) = mysql_fetch_row($result);
if ($result) {
mysql_free_result($result);
}
echo "\n<!-- memberlist.php listMembers -->\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\"><tr><td>\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\"><tr><td>\n";
echo "<center><b>".translate("Member List")."</b><br><br>\n";
echo "".translate("Greetings to our latest registered user:")." <A HREF=\"user.php?op=userinfo&uname=$lastuser\">$lastuser</a>\n</center>\n<br>\n";
$numrows = mysql_num_rows(mysql_query("select uid from ps_users"));
echo "<center>".sprintf(translate("We have <b>%s</b> registered user(s) so far."),$numrows)."</center><br>";
// display the a list of alphabets
alpha($sortby,$filepath,"?");
// initialize variables for sortlinks
$input = array();
$element[method]="uname";
$element[name] = "Username";
$input[] = $element;
$element[method]="name";
$element[name] = "Real Name";
$input[] = $element;
$element[method]="femail";
$element[name] = "Email";
$input[] = $element;
$element[method]="regDate";
$element[name] = "Register Date";
$input[] = $element;
SortLinks($sortby,$filepath,$letter,"?",$input);
$input=NULL;
unset($input);
$min = $pagesize * ($page - 1); // This is where we start our record set from
$max = $pagesize; // This is how many rows to select
// select the users now
$count = "SELECT uid FROM ps_users ";
$select = "select u.uid, u.uname, u.regDate, i.femail, i.name from ps_users u, ps_users_info i ";
// sort by alphabet
if ( ( $letter != "Other" ) AND ( $letter != "All" ) ) {
$where = "where uname like '".$letter."%' and u.uid = i.uid ";
$where2 = "where uname like '".$letter."%' ";
// sort by Others..like numbers
} else if ( ( $letter == "Other" ) AND ( $letter != "All" ) ) {
$where = "where uname REGEXP \"^\[1-9]\" and u.uid = i.uid ";
$where2 = "where uname REGEXP \"^\[1-9]\" ";
// no where clause
} else {
$where = "where u.uid = i.uid ";
$where2 = "";
}
// sort by base on $sortby input
$sort = "order by $sortby";
// limit the selection
$limit = " $orderby LIMIT ".$min.", ".$max;
// count how many users base on where clause
$count_result = mysql_query($count.$where2);
$num_rows_per_order = mysql_num_rows($count_result);
if ($count_result) {
mysql_free_result($count_result);
}
// do the query now
$result = mysql_query($select.$where.$sort.$limit) or die(mysql_error() );
echo "<br>";
// display the list
echo "<table width=\"100%\" border=\"0\" cellspacing=\"2\" class=\"sidebox\"><tr>\n";
echo "<td class=sideboxtop align=\"center\"><b>".translate("Username")."</b></td>\n";
echo "<td class=sideboxtop align=\"center\"><b>".translate("Real Name")."</b></td>\n";
echo "<td class=sideboxtop align=\"center\"><b>".translate("Email")."</b></td>\n";
echo "<td class=sideboxtop align=\"center\"><b>".translate("Register Date")."</b></td>\n";
echo "</tr>";
// for alternate color
$a = 0;
$dcolor_A = "sidebox";
$dcolor_B = "sidebox2";
//number of users per sorted and limit query
$num_rows = mysql_num_rows($result);
if ( $num_rows_per_order > 0 ) {
while($user = mysql_fetch_array($result) ) {
$dcolor = ($a == 0 ? $dcolor_A : $dcolor_B);
echo "<tr><td class=$dcolor><A HREF=\"user.php?op=userinfo&uname=$user[uname]\">$user[uname]</a> </td>\n";
echo "<td class=$dcolor>$user[name] </td>\n";
echo "<td class=$dcolor>$user[femail] </td>\n";
echo "<td class=$dcolor>".formatshorttimestamp($user[regDate])." </td>\n";
echo "</tr>";
$a = ($dcolor == $dcolor_A ? 1 : 0);
}
if ($result) {
mysql_free_result($result);
}
// start of next/prev/row links.
echo "\n<tr><td colspan='4' align='right'>\n";
echo "<hr size='1'>\n";
// initialize the variable for numberLink call
$input[num_rows_per_order] = $num_rows_per_order;
$input[pagesize] = $pagesize;
$input[num_rows] = $num_rows;
$input[page] = $page;
$input[item] = "user(s)";
$input[letter] = $letter;
$input[sortby] = $sortby;
$input[filepath] = "memberslist.php";
$input[orderby] = $orderby;
$input[separator] = "?";
numberLink($input);
echo "</td></tr>\n";
// end of next/prev/row links
} else { // you have no members on this letter
echo "<tr><td class=\"sideboxtop\" colspan=\"4\" align=\"center\"><br>\n";
echo "<b>".translate("No Members Found for")." $letter</b>\n";
echo "<br></td></tr>\n";
}
echo "\n</table><br>\n";
echo "</td></tr></table></td></tr></table>";
ps_footer("");
?>