Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 07:40 am EST
Geeklog Forums
Modifying userlist.php?
julianna
Anonymous
Hi.
I don't know enough php to be able to do this, so I'm hoping someone can help me with this.
1. userlist.php is currently set to hide the list from anonymous users. What needs to be changed for the list to be accessible to anonymous users?
2. I want to add (well, replace "send email" with) the information from the location field of the userinfo table. I figured out how to remove the "send email" link, but can't figure out how to request the location and insert it on the page without it overriding the other information.
Thanks!
I don't know enough php to be able to do this, so I'm hoping someone can help me with this.
1. userlist.php is currently set to hide the list from anonymous users. What needs to be changed for the list to be accessible to anonymous users?
2. I want to add (well, replace "send email" with) the information from the location field of the userinfo table. I figured out how to remove the "send email" link, but can't figure out how to request the location and insert it on the page without it overriding the other information.
Thanks!
16
16
Quote
julianna
Anonymous
Okay, I figured out #2. Below is modification to the code which will:
-remove the userphoto
-replace the "email user" with the location information from the "userinfo" table
-create a heading for the location information
-sort the users alphabetically
$retval .= '<table width="100%" border="0">' . LB;
$retval .= '<tr><td><b>' . $LANG04[2] . '</b></td><td><b>' . $LANG04[3] . '</b></td><td><b>' . $LANG04[106] .'</b></td></tr>' . LB;
$num_pages = ceil(DB_getItem($_TABLES['users'],'count(*)','uid > 1') / $limit);
$offset = ($curpage - 1) * $limit;
$sql = "SELECT *
FROM {$_TABLES['userinfo']},{$_TABLES['users']}
WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid
AND {$_TABLES['userinfo']}.uid > 1
ORDER BY (username)
";
$result = DB_query($sql);
$nrows = DB_numRows($result);
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .= '<tr><td><a href="' . $_CONF['site_url']
. '/users.php?mode=profile&uid=' . $A['uid'] . '">'
. $A['username'] . '</a>';
$retval .= '</td><td>' . $A['fullname']
. '</td><td>' . $A['location']
. '</td></tr>' . LB;
}
This replaces
$retval .= '<table width="100%" border="0">' . LB;
$retval .= '<tr><td><b>' . $LANG04[2] . '</b></td><td><b>' . $LANG04[3] . '</b></td></tr>' . LB;
$num_pages = ceil(DB_getItem($_TABLES['users'],'count(*)','uid > 1') / $limit);
$offset = ($curpage - 1) * $limit;
$sql = "SELECT uid,username,fullname,email,photo FROM {$_TABLES['users']} WHERE uid > 1 LIMIT $offset,$limit";
$result = DB_query($sql);
$nrows = DB_numRows($result);
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .= '<tr><td><a href="' . $_CONF['site_url']
. '/users.php?mode=profile&uid=' . $A['uid'] . '">'
. $A['username'] . '</a>';
if (!empty($A['photo']) AND $_CONF['allow_user_photo'] == 1) {
$retval .= ' <a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '"><img src="' . $_CONF['layout_url'] . '/images/smallcamera.gif" border="0" alt=""></a>';
}
$retval .= '</td><td>' . $A['fullname']
. '</td><td><a href="' . $_CONF['site_url']
. '/profiles.php?uid=' . $A['uid']
. '">' . $LANG04[81] .'</a></td></tr>' . LB;
}
Now to work on #1....
-remove the userphoto
-replace the "email user" with the location information from the "userinfo" table
-create a heading for the location information
-sort the users alphabetically
Text Formatted Code
$retval .= '<table width="100%" border="0">' . LB;
$retval .= '<tr><td><b>' . $LANG04[2] . '</b></td><td><b>' . $LANG04[3] . '</b></td><td><b>' . $LANG04[106] .'</b></td></tr>' . LB;
$num_pages = ceil(DB_getItem($_TABLES['users'],'count(*)','uid > 1') / $limit);
$offset = ($curpage - 1) * $limit;
$sql = "SELECT *
FROM {$_TABLES['userinfo']},{$_TABLES['users']}
WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid
AND {$_TABLES['userinfo']}.uid > 1
ORDER BY (username)
";
$result = DB_query($sql);
$nrows = DB_numRows($result);
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .= '<tr><td><a href="' . $_CONF['site_url']
. '/users.php?mode=profile&uid=' . $A['uid'] . '">'
. $A['username'] . '</a>';
$retval .= '</td><td>' . $A['fullname']
. '</td><td>' . $A['location']
. '</td></tr>' . LB;
}
This replaces
Text Formatted Code
$retval .= '<table width="100%" border="0">' . LB;
$retval .= '<tr><td><b>' . $LANG04[2] . '</b></td><td><b>' . $LANG04[3] . '</b></td></tr>' . LB;
$num_pages = ceil(DB_getItem($_TABLES['users'],'count(*)','uid > 1') / $limit);
$offset = ($curpage - 1) * $limit;
$sql = "SELECT uid,username,fullname,email,photo FROM {$_TABLES['users']} WHERE uid > 1 LIMIT $offset,$limit";
$result = DB_query($sql);
$nrows = DB_numRows($result);
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .= '<tr><td><a href="' . $_CONF['site_url']
. '/users.php?mode=profile&uid=' . $A['uid'] . '">'
. $A['username'] . '</a>';
if (!empty($A['photo']) AND $_CONF['allow_user_photo'] == 1) {
$retval .= ' <a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '"><img src="' . $_CONF['layout_url'] . '/images/smallcamera.gif" border="0" alt=""></a>';
}
$retval .= '</td><td>' . $A['fullname']
. '</td><td><a href="' . $_CONF['site_url']
. '/profiles.php?uid=' . $A['uid']
. '">' . $LANG04[81] .'</a></td></tr>' . LB;
}
Now to work on #1....
18
14
Quote
mach
Anonymous
where do you find userlist.php?
14
21
Quote
julianna
Anonymous
julianna
Anonymous
Finally! I figured out how to do #1. There's probably a better way to do it, but this is what I did:
Replace
if (empty ($_USER['username'])) { // prevent anon users from viewing the list
/* The following will only work in Geeklog 1.3.6rc1 and up
$display .= COM_startBlock($LANG_LOGIN[1]);
$login = new Template($_CONF['path_layout'] . 'submit');
$login->set_file (array ('login'=>'submitloginrequired.thtml'));
$login->set_var ('login_message', $LANG_LOGIN[2]);
$login->set_var ('site_url', $_CONF['site_url']);
$login->set_var ('lang_login', $LANG_LOGIN[3]);
$login->set_var ('lang_newuser', $LANG_LOGIN[4]);
$login->parse ('output', 'login');
$display .= $login->finish ($login->get_var('output'));
$display .= COM_endBlock();
*/
// poor man's solution for Geeklog up to 1.3.5sr2
$display .= COM_startBlock($LANG04[21]);
$display .= 'Sorry, to view the list of members of this site, you need to be a member yourself. Please register or log in.';
$display .= COM_endBlock();
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
with
if (empty ($_USER['username'])) {
$display .= listusers($page);
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
Replace
Text Formatted Code
if (empty ($_USER['username'])) { // prevent anon users from viewing the list
/* The following will only work in Geeklog 1.3.6rc1 and up
$display .= COM_startBlock($LANG_LOGIN[1]);
$login = new Template($_CONF['path_layout'] . 'submit');
$login->set_file (array ('login'=>'submitloginrequired.thtml'));
$login->set_var ('login_message', $LANG_LOGIN[2]);
$login->set_var ('site_url', $_CONF['site_url']);
$login->set_var ('lang_login', $LANG_LOGIN[3]);
$login->set_var ('lang_newuser', $LANG_LOGIN[4]);
$login->parse ('output', 'login');
$display .= $login->finish ($login->get_var('output'));
$display .= COM_endBlock();
*/
// poor man's solution for Geeklog up to 1.3.5sr2
$display .= COM_startBlock($LANG04[21]);
$display .= 'Sorry, to view the list of members of this site, you need to be a member yourself. Please register or log in.';
$display .= COM_endBlock();
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
with
Text Formatted Code
if (empty ($_USER['username'])) {
$display .= listusers($page);
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
15
17
Quote
mach
Anonymous
nevermind...
to allow access to anybody, just remove the relevant if/else statement leaving the contents of the else statement intact.
this is the if/else from the userlist.php that I found just now--don't know if it is what you're looking at:
if (empty ($_USER['username'])) { // prevent anon users from viewing the list
/* The following will only work in Geeklog 1.3.6rc1 and up
$display .= COM_startBlock($LANG_LOGIN[1]);
$login = new Template($_CONF['path_layout'] . 'submit');
$login->set_file (array ('login'=>'submitloginrequired.thtml'));
$login->set_var ('login_message', $LANG_LOGIN[2]);
$login->set_var ('site_url', $_CONF['site_url']);
$login->set_var ('lang_login', $LANG_LOGIN[3]);
$login->set_var ('lang_newuser', $LANG_LOGIN[4]);
$login->parse ('output', 'login');
$display .= $login->finish ($login->get_var('output'));
$display .= COM_endBlock();
*/
// poor man's solution for Geeklog up to 1.3.5sr2
$display .= COM_startBlock($LANG04[21]);
$display .= 'Sorry, to view the list of members of this site, you need to be a member yourself. Please register or log in.';
$display .= COM_endBlock();
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
change all that just to read:
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
hth
to allow access to anybody, just remove the relevant if/else statement leaving the contents of the else statement intact.
this is the if/else from the userlist.php that I found just now--don't know if it is what you're looking at:
Text Formatted Code
$display = COM_siteHeader ('menu');if (empty ($_USER['username'])) { // prevent anon users from viewing the list
/* The following will only work in Geeklog 1.3.6rc1 and up
$display .= COM_startBlock($LANG_LOGIN[1]);
$login = new Template($_CONF['path_layout'] . 'submit');
$login->set_file (array ('login'=>'submitloginrequired.thtml'));
$login->set_var ('login_message', $LANG_LOGIN[2]);
$login->set_var ('site_url', $_CONF['site_url']);
$login->set_var ('lang_login', $LANG_LOGIN[3]);
$login->set_var ('lang_newuser', $LANG_LOGIN[4]);
$login->parse ('output', 'login');
$display .= $login->finish ($login->get_var('output'));
$display .= COM_endBlock();
*/
// poor man's solution for Geeklog up to 1.3.5sr2
$display .= COM_startBlock($LANG04[21]);
$display .= 'Sorry, to view the list of members of this site, you need to be a member yourself. Please register or log in.';
$display .= COM_endBlock();
} else {
if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
}
Text Formatted Code
$display = COM_siteHeader ('menu');if (empty($page)) {
$page = 1;
}
$display .= listusers($page);
16
17
Quote
mach
Anonymous
guess i spoke to soon
14
15
Quote
julianna
Anonymous
Thanks, mach.
That was one of the first things I tried, but it gives me a blank page for some reason.
That was one of the first things I tried, but it gives me a blank page for some reason.
12
15
Quote
All times are EST. The time is now 07:40 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content