diff options
-rw-r--r-- | admin/catalog.php | 8 | ||||
-rw-r--r-- | admin/users.php | 19 | ||||
-rwxr-xr-x | docs/CHANGELOG | 6 | ||||
-rw-r--r-- | lib/general.lib.php | 40 | ||||
-rw-r--r-- | modules/admin.php | 53 |
5 files changed, 66 insertions, 60 deletions
diff --git a/admin/catalog.php b/admin/catalog.php index c5513284..c3bf3675 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -194,8 +194,9 @@ switch ($_REQUEST['action']) { break; case 'really_clear_stats': + if (conf('demo_mode')) { break; } - if ($_REQUEST['confrim'] == 'Yes') { + if ($_REQUEST['confirm'] == 'Yes') { clear_catalog_stats(); } include(conf('prefix') . '/templates/catalog.inc'); @@ -214,15 +215,14 @@ switch ($_REQUEST['action']) { case 'Clear Catalog': if (conf('demo_mode')) { break; } show_confirm_action(_("Do you really want to clear your catalog?"), - "/admin/catalog.php", "action=really_clear_catalog"); + "admin/catalog.php", "action=really_clear_catalog"); print("<hr />\n"); break; case 'clear_stats': if (conf('demo_mode')) { break; } show_confirm_action(_("Do you really want to clear the statistics for this catalog?"), - "/admin/catalog.php", "action=really_clear_stats"); - print("<hr />\n"); + "admin/catalog.php", "action=really_clear_stats"); break; case 'show_disabled': diff --git a/admin/users.php b/admin/users.php index a48f39e4..4a2f0ed6 100644 --- a/admin/users.php +++ b/admin/users.php @@ -118,12 +118,25 @@ switch ($action) { if (($pass1 !== $pass2)) { $GLOBALS['error']->add_error('password',_("Error Passwords don't match")); } + if (empty($username)) { $GLOBALS['error']->add_error('username',_("Error Username Required")); } - if (!$user->create($username, $fullname, $email, $pass1, $access)) { - $GLOBALS['error']->add_error('general',"Error: Insert Failed"); - } + + /* make sure the username doesn't already exist */ + if (!check_username($username)) { + $GLOBALS['error']->add_error('username',_("Error Username already exists")); + } + + if (!$GLOBALS['error']->error_state) { + + /* Attempt to create the user */ + if (!$user->create($username, $fullname, $email, $pass1, $access)) { + $GLOBALS['error']->add_error('general',"Error: Insert Failed"); + } + + } // if no errors + /* If we end up with an error */ if ($GLOBALS['error']->error_state) { show_user_form('','$username','$fullname','$email','$access','new_user',''); diff --git a/docs/CHANGELOG b/docs/CHANGELOG index db384eea..461fca0e 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -8,6 +8,12 @@ - Added initial TV page for viewing of nowplaying and additional information (Thx sigger) - Updated Archive library to 2.1 Released 08/13/2005 + - Corrected math error with automagic downsampling (Thx J) + - Corrected some of the no_auth preference problems + - Fixed a problem where Clearing the catalog stats, didn't actually + do anything + - Fixed a slight logic error that could give a weird error when + you attempted to create two users with the same username diff --git a/lib/general.lib.php b/lib/general.lib.php index e343b75c..7eebe074 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -756,4 +756,44 @@ function tbl_name($table) { } // tbl_name +/** + * clear_catalog_stats() + * + * Use this to clear the stats for the entire Ampache server. + * @package Catalog + * @catagory Clear + */ +function clear_catalog_stats() { + + $dbh = dbh(); + + /* Wipe out the object_count table */ + $sql = "TRUNCATE object_count"; + $results = mysql_query($sql, $dbh); + + /* Set every song to unplayed */ + $sql = "UPDATE song SET played='0'"; + $results = mysql_query($sql, $dbh); + +} // clear_catalog_stats + +/** + * check_username + * this function checks to make sure the specified username doesn't already exist + * @package General + * @catagory Users + */ +function check_username($username) { + + $sql = "SELECT username FROM user WHERE username = '" . sql_escape($username) . "'"; + $db_results = mysql_query($sql, dbh()); + + if (mysql_fetch_row($db_results)) { + return fakse; + } + + return true; + +} // check_username + ?> diff --git a/modules/admin.php b/modules/admin.php index 346e373f..42e24e48 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -151,59 +151,6 @@ function show_delete_stats($username) { } // show_delete_stats() -/* - * clear_catalog_stats() - * - * Use this to clear the stats for the entire Ampache server. - * - */ - -function clear_catalog_stats() { - $dbh = dbh(); - $sql = "DELETE FROM object_count"; - $result = mysql_query($sql, $dbh); - $sql = "UPDATE song SET played = 'false'"; - $result = mysql_query($sql, $dbh); -} // clear_catalog_stats - - -/* - * check_user_form - * - */ - -function check_user_form ($username, $fullname, $email, $pass1, $pass2, $type) { - global $dbh; - - $sql = "SELECT * FROM user WHERE username='$username'"; - $db_result = mysql_query($sql, $dbh); - - if ( mysql_num_rows($db_result) ) { - return "That username is already taken, please choose another."; - } - - if ( $type == 'new_user' ) { - if ( empty($username) ) { - return "Please fill in a username."; - } - elseif ( ($pass1 != $pass2) || (empty($pass1) || empty($pass2)) ) { - return "Sorry, your passwords do no match."; - } - } - elseif ( empty($fullname) ) { - return "Please fill in a full name."; - } - elseif ( empty($email) ) { - return "Please fill in an email address."; - } - elseif ( ($pass1 != $pass2) || (empty($pass1) || empty($pass2)) ) { - if ( $type == 'new_user' ) { - return "Sorry, your passwords do no match."; - } - } - - return false; -} // check_user_form() /* * get_user |