Usermgr.php link don't work. when i click on it it just stays there and doesn't do nothing. Before i uploaded the 1.2 it used to work fine. No idea wat is causing the proble. PLease help need to manage users
More info or some HTML source posted here would do wonders.
the server is http://www.djboxny.com/gallery1/ i am using image maigck. All was fine until i updated from vertion 1.1 something to 1.2 since there were no intructions on updating i when thru the update.php on the 1.2 vertion hopes this helps
thanks in advance
The link can't help as much as the HTML source. (The link requires admin credentials, which we don't need just yet.)
Have you tried logging in as an admin, then calling usermgr.php directly for your browser's address bar? This could at least give you the ability to manage users until you find out why the link is not working.
i send u a private message hope u can help me
I took a look around, and your link is not broken. For some reason, the usermgr.php script is not responding. This could be due to a timeout of some sort or a corrupted file.
Here are some things you can try:
1. Try downloading a fresh copy of usermgr.php and overwrite the old copy.
2. Use a database tool like PHPMyAdmin to inspect the CPG users table in your database. Check it, repair it if necessary, index it, optimize it, etc.
3. Most often in upgrades the trouble comes from database changes. You could install a test version of 1.2 and then compare the structure of the two CPG users tables. If there is a difference, you would need to fix it.
4. I don't know how many users you have, but if you had a tremendous number, there could be problems with timeouts or low memory allocation for result sets in MySQL.
5. If the above things fail, you can also try downgrading back to 1.1.
Via PM:
Quote from: "djboxny"Well, I have more than 3,000 users. Could that be it?
Possibly. You'll have to experiment to be sure.
To see if this could be a time out, try the following edit to usermgr.php:
// ------------------------------------------------------------------------- //
set_time_limit(300);
define('IN_COPPERMINE', true);
The addition of set_time_limit(300); tells the server to give the script five minutes to run.
You can also get general information about your server setup by saving the following code in a php file:
<?php
phpinfo();
?>
Running that code will cause the server to tell you important information such as maximum execution time, etc.
I am inclined to think this problem is less related to timeouts and more likely related to the MySQL result memory setting. To find out if this is the case, you'll need to use PHPMyAdmin to run this SQL query:
SELECT count(*) FROM {$CONFIG['TABLE_USERS']} WHERE 1;
{$CONFIG['TABLE_USERS']} should be replaced with your database's user table name. If PHPMyAdmin can't return a result, chances are good that the MySQL result set is larger than the MySQL memory limit. The other option is that the result set is larger than PHP's memory limit, but I doubt that is the case.
Your server administrator will have to change the MySQL result set memory limit if that is the problem.
Also, please use this thread, http://forum.coppermine-gallery.net/index.php?topic=4210, to respond instead of PMs. That way everyone who may have your problem can benefit from this discussion.
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.1 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// 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. //
// ------------------------------------------------------------------------- //
define('IN_COPPERMINE', true);
define('USERMGR_PHP', true);
define('PROFILE_PHP', true);
require('include/init.inc.php');
if (defined('UDB_INTEGRATION')) udb_edit_users();
if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
function list_users()
{
global $CONFIG, $PHP_SELF, $HTTP_GET_VARS;
global $lang_usermgr_php, $lang_byte_units, $register_date_fmt;
$sort_codes = array('name_a' => 'user_name ASC',
'name_d' => 'user_name DESC',
'group_a' => 'group_name ASC',
'group_d' => 'group_name DESC',
'reg_a' => 'user_regdate ASC',
'reg_d' => 'user_regdate DESC',
'pic_a' => 'pic_count ASC',
'pic_d' => 'pic_count DESC',
'disku_a' => 'disk_usage ASC',
'disku_d' => 'disk_usage DESC',
);
$sort = (!isset($HTTP_GET_VARS['sort']) || !isset($sort_codes[$HTTP_GET_VARS['sort']])) ? 'reg_d' : $HTTP_GET_VARS['sort'];
$tab_tmpl = array('left_text' => '<td width="100%%" align="left" valign="middle" class="tableh1_compact" style="white-space: nowrap"><b>' . $lang_usermgr_php['u_user_on_p_pages'] . '</b></td>' . "\n",
'tab_header' => '',
'tab_trailer' => '',
'active_tab' => '<td><img src="images/spacer.gif" width="1" height="1"></td>' . "\n" . '<td align="center" valign="middle" class="tableb_compact"><b>%d</b></td>',
'inactive_tab' => '<td><img src="images/spacer.gif" width="1" height="1"></td>' . "\n" . '<td align="center" valign="middle" class="navmenu"><a href="' . $PHP_SELF . '?page=%d&sort=' . $sort . '"<b>%d</b></a></td>' . "\n"
);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_USERS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$user_count = $nbEnr[0];
mysql_free_result($result);
if (!$user_count) cpg_die(CRITICAL_ERROR, $lang_usermgr_php['err_no_users'], __FILE__, __LINE__);
$user_per_page = 25;
$page = isset($HTTP_GET_VARS['page']) ? (int)$HTTP_GET_VARS['page'] : 1;
$lower_limit = ($page-1) * $user_per_page;
$total_pages = ceil($user_count / $user_per_page);
$sql = "SELECT user_id, user_name, user_email, UNIX_TIMESTAMP(user_regdate) as user_regdate, group_name, user_active, " . "COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage, group_quota " . "FROM {$CONFIG['TABLE_USERS']} AS u " . "INNER JOIN {$CONFIG['TABLE_USERGROUPS']} AS g ON user_group = group_id " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.owner_id = u.user_id " . "GROUP BY user_id " . "ORDER BY " . $sort_codes[$sort] . " " . "LIMIT $lower_limit, $user_per_page";
$result = db_query($sql);
$tabs = create_tabs($user_count, $page, $total_pages, $tab_tmpl);
starttable('100%');
echo <<< EOT
<tr>
<td class="tableh1"><b><span class="statlink">{$lang_usermgr_php['name']}</span></b></td>
<td class="tableh1"><b><span class="statlink">{$lang_usermgr_php['group']}</span></b></td>
<td class="tableh1"><b><span class="statlink">{$lang_usermgr_php['registered_on']}</span></b></td>
<td class="tableh1" colspan="2" align="center"><b><span class="statlink">{$lang_usermgr_php['operations']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_usermgr_php['pictures']}</span></b></td>
<td class="tableh1" colspan="2" align="center"><b><span class="statlink">{$lang_usermgr_php['disk_space']}</span></b></td>
</tr>
EOT;
while ($user = mysql_fetch_array($result)) {
if ($user['user_active'] == 'NO') $user['group_name'] = '<i>' . $lang_usermgr_php['inactive'] . '</i>';
$user['user_regdate'] = localised_date($user['user_regdate'], $register_date_fmt);
if ($user['pic_count']) {
$usr_link_start = '<a href="thumbnails.php?album=lastupby&uid=' . $user['user_id'] . '" target="_blank">';
$usr_link_end = '</a>';
} else {
$usr_link_start = '';
$usr_link_end = '';
}
echo <<< EOT
<tr>
<td class="tableb">$usr_link_start{$user['user_name']}$usr_link_end</td>
<td class="tableb">{$user['group_name']}</td>
<td class="tableb">{$user['user_regdate']}</td>
<td class="tableb" align="center"><div class="admin_menu"><a href="$PHP_SELF?op=edit&user_id={$user['user_id']}">{$lang_usermgr_php['edit']}</a></div></td>
<td class="tableb" align="center"><div class="admin_menu"><a href="delete.php?id={$user['user_id']}&what=user" onclick="return confirm('{$lang_usermgr_php['confirm_del']}');">{$lang_usermgr_php['delete']}</a></div></td>
<td class="tableb" align="center">{$user['pic_count']}</td>
<td class="tableb" align="right">{$user['disk_usage']} {$lang_byte_units[1]}</td>
<td class="tableb" align="right">{$user['group_quota']} {$lang_byte_units[1]}</td>
</tr>
EOT;
} // while
mysql_free_result($result);
$lb = "<select name=\"album_listbox\" class=\"listbox\" onChange=\"if(this.options[this.selectedIndex].value) window.location.href='$PHP_SELF?page=$page&sort='+this.options[this.selectedIndex].value;\">\n";
foreach($sort_codes as $key => $value) {
$selected = ($key == $sort) ? "SELECTED" : "";
$lb .= " <option value=\"" . $key . "\" $selected>" . $lang_usermgr_php[$key] . "</option>\n";
}
$lb .= "</select>\n";
echo <<<EOT
<tr>
<form method="post" action="$PHP_SELF?op=new_user">
<td colspan="8" align="center" class="tablef">
<table cellpadding="0" cellspacing="0">
<tr>
<td><input type="submit" value="{$lang_usermgr_php['create_new_user']}" class="button"></td>
<td><img src="images/spacer.gif" width="50" height="1" alt="" /></td>
<td><b>{$lang_usermgr_php['sort_by']}</b></td>
<td><img src="images/spacer.gif" width="10" height="1" alt="" /></td>
<td>$lb</td>
</tr>
</table>
</td>
</form>
</tr>
<tr>
<td colspan="8" style="padding: 0px;">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
$tabs
</tr>
</table>
</td>
</tr>
EOT;
endtable();
}
function edit_user($user_id)
{
global $CONFIG, $PHP_SELF;
global $lang_usermgr_php, $lang_yes, $lang_no;
$form_data = array(
array('input', 'user_name', $lang_usermgr_php['name'], 25),
array('password', 'user_password', $lang_usermgr_php['password'], 25),
array('yesno', 'user_active', $lang_usermgr_php['user_active']),
array('group_list', 'user_group', $lang_usermgr_php['user_group']),
array('input', 'user_email', $lang_usermgr_php['user_email'], 255),
array('input', 'user_location', $lang_usermgr_php['user_location'], 255),
array('input', 'user_interests', $lang_usermgr_php['user_interests'], 255),
array('input', 'user_website', $lang_usermgr_php['user_web_site'], 255),
array('input', 'user_occupation', $lang_usermgr_php['user_occupation'], 255)
);
$sql = "SELECT * FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '$user_id'";
$result = db_query($sql);
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_usermgr_php['err_unknown_user'], __FILE__, __LINE__);
$user_data = mysql_fetch_array($result);
mysql_free_result($result);
starttable(500, $lang_usermgr_php['modify_user'], 2);
echo <<<EOT
<form method="post" action="$PHP_SELF?op=update&user_id=$user_id">
EOT;
foreach ($form_data as $element) switch ($element[0]) {
case 'input' :
$user_data[$element[1]] = $user_data[$element[1]];
echo <<<EOT
<tr>
<td width="40%" class="tableb">
{$element[2]}
</td>
<td width="60%" class="tableb" valign="top">
<input type="text" style="width: 100%" name="{$element[1]}" maxlength="{$element[3]}" value="{$user_data[$element[1]]}" class="textinput">
</td>
</tr>
EOT;
break;
case 'password' :
echo <<<EOT
<tr>
<td width="40%" class="tableb">
{$element[2]}
</td>
<td width="60%" class="tableb" valign="top">
<input type="input" style="width: 100%" name="{$element[1]}" maxlength="{$element[3]}" value="" class="textinput">
</td>
</tr>
EOT;
break;
case 'yesno' :
$value = $user_data[$element[1]];
$yes_selected = ($value == 'YES') ? 'selected' : '';
$no_selected = ($value == 'NO') ? 'selected' : '';
echo <<< EOT
<tr>
<td class="tableb">
{$element[2]}
</td>
<td class="tableb">
<select name="{$element[1]}" class="listbox">
<option value="YES" $yes_selected>$lang_yes</option>
<option value="NO" $no_selected>$lang_no</option>
</select>
</td>
</tr>
EOT;
break;
case 'group_list' :
$sql = "SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} ORDER BY group_name";
$result = db_query($sql);
$group_list = db_fetch_rowset($result);
mysql_free_result($result);
$sel_group = $user_data[$element[1]];
$user_group_list = ($user_data['user_lang'] == '') ? ',' . $sel_group . ',' : ',' . $user_data['user_lang'] . ',' . $sel_group . ',';
echo <<<EOT
<tr>
<td class="tableb">
{$element[2]}
</td>
<td class="tableb" valign="top">
<select name="{$element[1]}" class="listbox">
EOT;
$group_cb = '';
foreach($group_list as $group) {
echo ' <option value="' . $group['group_id'] . '"' . ($group['group_id'] == $sel_group ? ' selected' : '') . '>' . $group['group_name'] . "</option>\n";
$checked = strpos(' ' . $user_group_list, ',' . $group['group_id'] . ',') ? 'checked' : '';
$group_cb .= '<input name="group_list[]" type="checkbox" value="' . $group['group_id'] . '" ' . $checked . '>' . $group['group_name'] . "<br />\n";
}
echo <<<EOT
</select><br />
$group_cb
</td>
</tr>
EOT;
break;
default:
cpg_die(CRITICAL_ERROR, 'Invalid action for form creation ' . $element[0], __FILE__, __LINE__);
}
echo <<<EOT
<tr>
<td colspan="2" class="tableh2">
<b>{$lang_usermgr_php['notes']}</b>
</td>
</tr>
<tr>
<td colspan="2" class="tableb">
<ul>
{$lang_usermgr_php['note_list']}
</ul>
</td>
</tr>
<tr>
<td colspan="2" align="center" class="tablef">
<input type="submit" value="{$lang_usermgr_php['modify_user']}" class="button">
</td>
</form>
</tr>
EOT;
endtable();
}
function update_user($user_id)
{
global $CONFIG, $PHP_SELF, $HTTP_POST_VARS;
global $lang_usermgr_php, $lang_register_php;
$user_name = addslashes(trim($HTTP_POST_VARS['user_name']));
$user_password = addslashes(trim($HTTP_POST_VARS['user_password']));
$user_email = addslashes(trim($HTTP_POST_VARS['user_email']));
$user_location = addslashes($HTTP_POST_VARS['user_location']);
$user_interests = addslashes($HTTP_POST_VARS['user_interests']);
$user_website = addslashes($HTTP_POST_VARS['user_website']);
$user_occupation = addslashes($HTTP_POST_VARS['user_occupation']);
$user_active = $HTTP_POST_VARS['user_active'];
$user_group = $HTTP_POST_VARS['user_group'];
$group_list = isset($HTTP_POST_VARS['group_list']) ? $HTTP_POST_VARS['group_list'] : '';
$sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '" . addslashes($user_name) . "' AND user_id != $user_id";
$result = db_query($sql);
if (mysql_num_rows($result)) {
cpg_die(ERROR, $lang_register_php['err_user_exists'], __FILE__, __LINE__);
return false;
}
mysql_free_result($result);
if (strlen($user_name) < 2) cpg_die(ERROR, $lang_register_php['err_uname_short'], __FILE__, __LINE__);
if (strlen($user_password) && strlen($user_password) < 2) cpg_die(ERROR, $lang_register_php['err_password_short'], __FILE__, __LINE__);
if (is_array($group_list)) {
$user_group_list = '';
foreach($group_list as $group) $user_group_list .= ($group != $user_group) ? $group . ',' : '';
$user_group_list = substr($user_group_list, 0, -1);
} else {
$user_group_list = '';
}
$sql_update = "UPDATE {$CONFIG['TABLE_USERS']} " . "SET " . "user_name = '$user_name', " . "user_email = '$user_email', " . "user_active = '$user_active', " . "user_group = '$user_group', " . "user_location = '$user_location', " . "user_interests = '$user_interests', " . "user_website = '$user_website', " . "user_occupation= '$user_occupation', " . "user_lang = '$user_group_list'";
if (strlen($user_password)) $sql_update .= ", user_password = '$user_password'";
$sql_update .= " WHERE user_id = '$user_id'";
db_query($sql_update);
}
$op = isset($HTTP_GET_VARS['op']) ? $HTTP_GET_VARS['op'] : '';
switch ($op) {
case 'edit' :
$user_id = isset($HTTP_GET_VARS['user_id']) ? (int)$HTTP_GET_VARS['user_id'] : -1;
if (USER_ID == $user_id) cpg_die(ERROR, $lang_usermgr_php['err_edit_self'], __FILE__, __LINE__);
pageheader($lang_usermgr_php['title']);
edit_user($user_id);
pagefooter();
ob_end_flush();
break;
case 'update' :
$user_id = isset($HTTP_GET_VARS['user_id']) ? (int)$HTTP_GET_VARS['user_id'] : -1;
update_user($user_id);
db_query("DELETE FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '' LIMIT 1");
pageheader($lang_usermgr_php['title']);
list_users();
pagefooter();
ob_end_flush();
break;
case 'new_user' :
db_query("INSERT INTO {$CONFIG['TABLE_USERS']}(user_regdate, user_active) VALUES (NOW(), 'YES')");
$user_id = mysql_insert_id();
pageheader($lang_usermgr_php['title']);
edit_user($user_id);
pagefooter();
ob_end_flush();
break;
default :
db_query("DELETE FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '' LIMIT 1");
pageheader($lang_usermgr_php['title']);
list_users();
pagefooter();
ob_end_flush();
break;
}
?>
when i changed only the usrmgr.php from the gallery to the 1 in the gallery 1.1 i had before it worked fine. The only filei changed the usrmgr file for the old one and it work. Are there any special features in the new. Or do u think u know whats the problem
Nothing changed in the usermgr.php file between 1.1 and 1.2, so the copy that did not work was most likely corrupted.
Now with the beta vertion. Its really odd i just upload the Old usermgr.php from vertion 1.1 and it works great with the new beta. but as before when i try to use the one that comes with the release it just stands there and never goes anywere
Quote from: hyperion on March 04, 2004, 07:52:01 AM
Nothing changed in the usermgr.php file between 1.1 and 1.2, so the copy that did not work was most likely corrupted.
Hmm, not quite right.
The SQL statement in list_users() changed!
Quote from: djboxny on March 04, 2004, 05:08:21 AM
when i changed only the usrmgr.php from the gallery to the 1 in the gallery 1.1 i had before it worked fine. The only filei changed the usrmgr file for the old one and it work. Are there any special features in the new. Or do u think u know whats the problem
It should be ok to just copy the SQL statement from list_users() over.
I guess, its a MySQL resource limit issue. If have that problem only on a tiny box.
The big box works fine with the original 1.2 release.