diff options
Diffstat (limited to 'admin')
-rw-r--r-- | admin/access.php | 154 | ||||
-rw-r--r-- | admin/catalog.php | 566 | ||||
-rw-r--r-- | admin/duplicates.php | 24 | ||||
-rw-r--r-- | admin/export.php | 68 | ||||
-rw-r--r-- | admin/flag.php | 488 | ||||
-rw-r--r-- | admin/index.php | 26 | ||||
-rw-r--r-- | admin/mail.php | 76 | ||||
-rw-r--r-- | admin/modules.php | 228 | ||||
-rw-r--r-- | admin/shout.php | 56 | ||||
-rw-r--r-- | admin/system.php | 52 | ||||
-rw-r--r-- | admin/users.php | 348 |
11 files changed, 1043 insertions, 1043 deletions
diff --git a/admin/access.php b/admin/access.php index 60e86d62..3945d174 100644 --- a/admin/access.php +++ b/admin/access.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,91 +23,91 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); switch ($_REQUEST['action']) { - case 'delete_record': - if (!Core::form_verify('delete_access')) { - UI::access_denied(); - exit; - } - Access::delete($_REQUEST['access_id']); - $url = Config::get('web_path') . '/admin/access.php'; - show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url); - break; - case 'show_delete_record': - if (Config::get('demo_mode')) { break; } - $access = new Access($_GET['access_id']); - show_confirmation(T_('Deletion Request'), T_('Are you sure you want to permanently delete') . ' ' . $access->name, - 'admin/access.php?action=delete_record&access_id=' . $access->id,1,'delete_access'); - break; - case 'add_host': + case 'delete_record': + if (!Core::form_verify('delete_access')) { + UI::access_denied(); + exit; + } + Access::delete($_REQUEST['access_id']); + $url = Config::get('web_path') . '/admin/access.php'; + show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url); + break; + case 'show_delete_record': + if (Config::get('demo_mode')) { break; } + $access = new Access($_GET['access_id']); + show_confirmation(T_('Deletion Request'), T_('Are you sure you want to permanently delete') . ' ' . $access->name, + 'admin/access.php?action=delete_record&access_id=' . $access->id,1,'delete_access'); + break; + case 'add_host': - // Make sure we've got a valid form submission - if (!Core::form_verify('add_acl','post')) { - UI::access_denied(); - exit; - } + // Make sure we've got a valid form submission + if (!Core::form_verify('add_acl','post')) { + UI::access_denied(); + exit; + } - Access::create($_POST); + Access::create($_POST); - // Create Additional stuff based on the type - if ($_POST['addtype'] == 'stream' || - $_POST['addtype'] == 'all' - ) { - $_POST['type'] = 'stream'; - Access::create($_POST); - } - if ($_POST['addtype'] == 'all') { - $_POST['type'] = 'interface'; - Access::create($_POST); - } + // Create Additional stuff based on the type + if ($_POST['addtype'] == 'stream' || + $_POST['addtype'] == 'all' + ) { + $_POST['type'] = 'stream'; + Access::create($_POST); + } + if ($_POST['addtype'] == 'all') { + $_POST['type'] = 'interface'; + Access::create($_POST); + } - if (!Error::occurred()) { - $url = Config::get('web_path') . '/admin/access.php'; - show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'),$url); - } - else { - $action = 'show_add_' . $_POST['type']; - require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; - } - break; - case 'update_record': - if (!Core::form_verify('edit_acl')) { - UI::access_denied(); - exit; - } - $access = new Access($_REQUEST['access_id']); - $access->update($_POST); - if (!Error::occurred()) { - show_confirmation(T_('Updated'), T_('Access List Entry updated'), Config::get('web_path').'/admin/access.php'); - } - else { - $access->format(); - require_once Config::get('prefix') . '/templates/show_edit_access.inc.php'; - } - break; - case 'show_add_current': - case 'show_add_rpc': - case 'show_add_local': - case 'show_add_advanced': - $action = $_REQUEST['action']; - require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; - break; - case 'show_edit_record': - $access = new Access($_REQUEST['access_id']); - $access->format(); - require_once Config::get('prefix') . '/templates/show_edit_access.inc.php'; - break; - default: - $list = array(); - $list = Access::get_access_lists(); - require_once Config::get('prefix') .'/templates/show_access_list.inc.php'; - break; + if (!Error::occurred()) { + $url = Config::get('web_path') . '/admin/access.php'; + show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'),$url); + } + else { + $action = 'show_add_' . $_POST['type']; + require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; + } + break; + case 'update_record': + if (!Core::form_verify('edit_acl')) { + UI::access_denied(); + exit; + } + $access = new Access($_REQUEST['access_id']); + $access->update($_POST); + if (!Error::occurred()) { + show_confirmation(T_('Updated'), T_('Access List Entry updated'), Config::get('web_path').'/admin/access.php'); + } + else { + $access->format(); + require_once Config::get('prefix') . '/templates/show_edit_access.inc.php'; + } + break; + case 'show_add_current': + case 'show_add_rpc': + case 'show_add_local': + case 'show_add_advanced': + $action = $_REQUEST['action']; + require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; + break; + case 'show_edit_record': + $access = new Access($_REQUEST['access_id']); + $access->format(); + require_once Config::get('prefix') . '/templates/show_edit_access.inc.php'; + break; + default: + $list = array(); + $list = Access::get_access_lists(); + require_once Config::get('prefix') .'/templates/show_access_list.inc.php'; + break; } // end switch on action UI::show_footer(); ?> diff --git a/admin/catalog.php b/admin/catalog.php index 472ee8ce..936b39a8 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,294 +23,294 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit; + UI::access_denied(); + exit; } UI::show_header(); /* Big switch statement to handle various actions */ switch ($_REQUEST['action']) { - case 'fixed': - /* Does this use now? */ - delete_flagged($flag); - $type = 'show_flagged_songs'; - require Config::get('prefix') . '/templates/flag.inc'; - break; - case 'add_to_all_catalogs': - $catalog = new Catalog(); - $_REQUEST['catalogs'] = $catalog->get_catalog_ids(); - case 'add_to_catalog': - toggle_visible('ajax-loading'); - ob_end_flush(); - if (Config::get('demo_mode')) { break; } - if ($_REQUEST['catalogs'] ) { - foreach ($_REQUEST['catalogs'] as $catalog_id) { - $catalog = new Catalog($catalog_id); - $catalog->add_to_catalog(); - } - } - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog Updated'); - $body = ''; - show_confirmation($title,$body,$url); - toggle_visible('ajax-loading'); - break; - case 'update_all_catalogs': - $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); - case 'update_catalog': - toggle_visible('ajax-loading'); - ob_end_flush(); - /* If they are in demo mode stop here */ - if (Config::get('demo_mode')) { break; } - - if (isset($_REQUEST['catalogs'])) { - foreach ($_REQUEST['catalogs'] as $catalog_id) { - $catalog = new Catalog($catalog_id); - $catalog->verify_catalog(); - } - } - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog Updated'); - $body = ''; - show_confirmation($title,$body,$url); - toggle_visible('ajax-loading'); - break; - case 'full_service': - toggle_visible('ajax-loading'); - ob_end_flush(); - /* Make sure they aren't in demo mode */ - if (Config::get('demo_mode')) { UI::access_denied(); break; } - - if (!$_REQUEST['catalogs']) { - $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); - } - - /* This runs the clean/verify/add in that order */ - foreach ($_REQUEST['catalogs'] as $catalog_id) { - $catalog = new Catalog($catalog_id); - $catalog->clean_catalog(); - $catalog->count = 0; - $catalog->verify_catalog(); - $catalog->count = 0; - $catalog->add_to_catalog(); - } - Dba::optimize_tables(); - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog Updated'); - $body = ''; - show_confirmation($title,$body,$url); - toggle_visible('ajax-loading'); - break; - case 'delete_catalog': - /* Make sure they aren't in demo mode */ - if (Config::get('demo_mode')) { break; } - - if (!Core::form_verify('delete_catalog')) { - UI::access_denied(); - exit; - } - - /* Delete the sucker, we don't need to check perms as thats done above */ - Catalog::delete($_GET['catalog_id']); - $next_url = Config::get('web_path') . '/admin/catalog.php'; - show_confirmation(T_('Catalog Deleted'), T_('The Catalog and all associated records have been deleted'),$next_url); - break; - case 'show_delete_catalog': - $catalog_id = scrub_in($_GET['catalog_id']); - - $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id); - show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog'); - break; - case 'remove_disabled': - if (Config::get('demo_mode')) { break; } - - $song = $_REQUEST['song']; - - if (count($song)) { - $catalog->remove_songs($song); - $body = T_ngettext('Song Removed', 'Songs Removed', count($song)); - } - else { - $body = T_('No Songs Removed'); - } - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_ngettext('Disabled Song Processed','Disabled Songs Processed',count($song)); - show_confirmation($title,$body,$url); - break; - case 'clean_all_catalogs': - $catalog = new Catalog(); - $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); - case 'clean_catalog': - toggle_visible('ajax-loading'); - ob_end_flush(); - /* If they are in demo mode stop them here */ - if (Config::get('demo_mode')) { break; } - - // Make sure they checked something - if (isset($_REQUEST['catalogs'])) { - foreach($_REQUEST['catalogs'] as $catalog_id) { - $catalog = new Catalog($catalog_id); - $catalog->clean_catalog(); - } // end foreach catalogs - Dba::optimize_tables(); - } - - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog Cleaned'); - $body = ''; - show_confirmation($title,$body,$url); - toggle_visible('ajax-loading'); - break; - case 'update_catalog_settings': - /* No Demo Here! */ - if (Config::get('demo_mode')) { break; } - - /* Update the catalog */ - Catalog::update_settings($_POST); - - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog Updated'); - $body = ''; - show_confirmation($title,$body,$url); - break; - case 'update_from': - if (Config::get('demo_mode')) { break; } - - // First see if we need to do an add - if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) { - if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) { - $catalog = new Catalog($catalog_id); - $catalog->run_add(array('subdirectory'=>$_POST['add_path'])); - } - } // end if add - - // Now check for an update - if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) { - if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) { - $songs = Song::get_from_path($_POST['update_path']); - foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); } - } - } // end if update - - break; - case 'add_catalog': - /* Wah Demo! */ - if (Config::get('demo_mode')) { break; } - - ob_end_flush(); - - if (!strlen($_POST['path']) || !strlen($_POST['name'])) { - Error::add('general', T_('Error: Name and path not specified')); - } - - if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') { - Error::add('general', T_('Error: Remote selected, but path is not a URL')); - } - if ($POST['type'] == 'remote' AND (!strlen($POST['remote_username']) OR !strlen($POST['remote_password']))) { - Error::add('general', T_('Error: Username and Password Required for Remote Catalogs')); - } - - if (!Core::form_verify('add_catalog','post')) { - UI::access_denied(); - exit; - } - - // Make sure that there isn't a catalog with a directory above this one - if (Catalog::get_from_path($_POST['path'])) { - Error::add('general', T_('Error: Defined Path is inside an existing catalog')); - } - - // If an error hasn't occured - if (!Error::occurred()) { - - $catalog_id = Catalog::create($_POST); - - if (!$catalog_id) { - require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; - break; - } - - $catalog = new Catalog($catalog_id); - - // Run our initial add - $catalog->run_add($_POST); - - UI::show_box_top(T_('Catalog Created'), 'box box_catalog_created'); - echo "<h2>" . T_('Catalog Created') . "</h2>"; - Error::display('general'); - Error::display('catalog_add'); - UI::show_box_bottom(); - - show_confirmation('','', Config::get('web_path').'/admin/catalog.php'); - - } - else { - require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; - } - break; - case 'clear_stats': - if (Config::get('demo_mode')) { UI::access_denied(); break; } - Stats::clear(); - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Catalog statistics cleared'); - $body = ''; - show_confirmation($title, $body, $url); - break; - default: - case 'show_catalogs': - require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php'; - break; - case 'show_add_catalog': - require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; - break; - case 'clear_now_playing': - if (Config::get('demo_mode')) { UI::access_denied(); break; } - Stream::clear_now_playing(); - show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),Config::get('web_path') . '/admin/catalog.php'); - break; - case 'show_disabled': - /* Stop the demo hippies */ - if (Config::get('demo_mode')) { break; } - - $songs = Song::get_disabled(); - if (count($songs)) { - require Config::get('prefix') . '/templates/show_disabled_songs.inc.php'; - } - else { - echo "<div class=\"error\" align=\"center\">" . T_('No Disabled songs found') . "</div>"; - } - break; - case 'show_delete_catalog': - /* Stop the demo hippies */ - if (Config::get('demo_mode')) { UI::access_denied(); break; } - - $catalog = new Catalog($_REQUEST['catalog_id']); - $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']); - show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1); - break; - case 'show_customize_catalog': - $catalog = new Catalog($_REQUEST['catalog_id']); - require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php'; - break; - case 'gather_album_art': - toggle_visible('ajax-loading'); - ob_end_flush(); - - $catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs(); - - // Itterate throught the catalogs and gather as needed - foreach ($catalogs as $catalog_id) { - $catalog = new Catalog($catalog_id); - require Config::get('prefix') . '/templates/show_gather_art.inc.php'; - flush(); - $catalog->get_art('',1); - } - $url = Config::get('web_path') . '/admin/catalog.php'; - $title = T_('Album Art Search Finished'); - $body = ''; - show_confirmation($title,$body,$url); - break; + case 'fixed': + /* Does this use now? */ + delete_flagged($flag); + $type = 'show_flagged_songs'; + require Config::get('prefix') . '/templates/flag.inc'; + break; + case 'add_to_all_catalogs': + $catalog = new Catalog(); + $_REQUEST['catalogs'] = $catalog->get_catalog_ids(); + case 'add_to_catalog': + toggle_visible('ajax-loading'); + ob_end_flush(); + if (Config::get('demo_mode')) { break; } + if ($_REQUEST['catalogs'] ) { + foreach ($_REQUEST['catalogs'] as $catalog_id) { + $catalog = new Catalog($catalog_id); + $catalog->add_to_catalog(); + } + } + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog Updated'); + $body = ''; + show_confirmation($title,$body,$url); + toggle_visible('ajax-loading'); + break; + case 'update_all_catalogs': + $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); + case 'update_catalog': + toggle_visible('ajax-loading'); + ob_end_flush(); + /* If they are in demo mode stop here */ + if (Config::get('demo_mode')) { break; } + + if (isset($_REQUEST['catalogs'])) { + foreach ($_REQUEST['catalogs'] as $catalog_id) { + $catalog = new Catalog($catalog_id); + $catalog->verify_catalog(); + } + } + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog Updated'); + $body = ''; + show_confirmation($title,$body,$url); + toggle_visible('ajax-loading'); + break; + case 'full_service': + toggle_visible('ajax-loading'); + ob_end_flush(); + /* Make sure they aren't in demo mode */ + if (Config::get('demo_mode')) { UI::access_denied(); break; } + + if (!$_REQUEST['catalogs']) { + $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); + } + + /* This runs the clean/verify/add in that order */ + foreach ($_REQUEST['catalogs'] as $catalog_id) { + $catalog = new Catalog($catalog_id); + $catalog->clean_catalog(); + $catalog->count = 0; + $catalog->verify_catalog(); + $catalog->count = 0; + $catalog->add_to_catalog(); + } + Dba::optimize_tables(); + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog Updated'); + $body = ''; + show_confirmation($title,$body,$url); + toggle_visible('ajax-loading'); + break; + case 'delete_catalog': + /* Make sure they aren't in demo mode */ + if (Config::get('demo_mode')) { break; } + + if (!Core::form_verify('delete_catalog')) { + UI::access_denied(); + exit; + } + + /* Delete the sucker, we don't need to check perms as thats done above */ + Catalog::delete($_GET['catalog_id']); + $next_url = Config::get('web_path') . '/admin/catalog.php'; + show_confirmation(T_('Catalog Deleted'), T_('The Catalog and all associated records have been deleted'),$next_url); + break; + case 'show_delete_catalog': + $catalog_id = scrub_in($_GET['catalog_id']); + + $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id); + show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog'); + break; + case 'remove_disabled': + if (Config::get('demo_mode')) { break; } + + $song = $_REQUEST['song']; + + if (count($song)) { + $catalog->remove_songs($song); + $body = T_ngettext('Song Removed', 'Songs Removed', count($song)); + } + else { + $body = T_('No Songs Removed'); + } + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_ngettext('Disabled Song Processed','Disabled Songs Processed',count($song)); + show_confirmation($title,$body,$url); + break; + case 'clean_all_catalogs': + $catalog = new Catalog(); + $_REQUEST['catalogs'] = Catalog::get_catalog_ids(); + case 'clean_catalog': + toggle_visible('ajax-loading'); + ob_end_flush(); + /* If they are in demo mode stop them here */ + if (Config::get('demo_mode')) { break; } + + // Make sure they checked something + if (isset($_REQUEST['catalogs'])) { + foreach($_REQUEST['catalogs'] as $catalog_id) { + $catalog = new Catalog($catalog_id); + $catalog->clean_catalog(); + } // end foreach catalogs + Dba::optimize_tables(); + } + + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog Cleaned'); + $body = ''; + show_confirmation($title,$body,$url); + toggle_visible('ajax-loading'); + break; + case 'update_catalog_settings': + /* No Demo Here! */ + if (Config::get('demo_mode')) { break; } + + /* Update the catalog */ + Catalog::update_settings($_POST); + + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog Updated'); + $body = ''; + show_confirmation($title,$body,$url); + break; + case 'update_from': + if (Config::get('demo_mode')) { break; } + + // First see if we need to do an add + if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) { + if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) { + $catalog = new Catalog($catalog_id); + $catalog->run_add(array('subdirectory'=>$_POST['add_path'])); + } + } // end if add + + // Now check for an update + if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) { + if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) { + $songs = Song::get_from_path($_POST['update_path']); + foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); } + } + } // end if update + + break; + case 'add_catalog': + /* Wah Demo! */ + if (Config::get('demo_mode')) { break; } + + ob_end_flush(); + + if (!strlen($_POST['path']) || !strlen($_POST['name'])) { + Error::add('general', T_('Error: Name and path not specified')); + } + + if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') { + Error::add('general', T_('Error: Remote selected, but path is not a URL')); + } + if ($POST['type'] == 'remote' AND (!strlen($POST['remote_username']) OR !strlen($POST['remote_password']))) { + Error::add('general', T_('Error: Username and Password Required for Remote Catalogs')); + } + + if (!Core::form_verify('add_catalog','post')) { + UI::access_denied(); + exit; + } + + // Make sure that there isn't a catalog with a directory above this one + if (Catalog::get_from_path($_POST['path'])) { + Error::add('general', T_('Error: Defined Path is inside an existing catalog')); + } + + // If an error hasn't occured + if (!Error::occurred()) { + + $catalog_id = Catalog::create($_POST); + + if (!$catalog_id) { + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; + break; + } + + $catalog = new Catalog($catalog_id); + + // Run our initial add + $catalog->run_add($_POST); + + UI::show_box_top(T_('Catalog Created'), 'box box_catalog_created'); + echo "<h2>" . T_('Catalog Created') . "</h2>"; + Error::display('general'); + Error::display('catalog_add'); + UI::show_box_bottom(); + + show_confirmation('','', Config::get('web_path').'/admin/catalog.php'); + + } + else { + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; + } + break; + case 'clear_stats': + if (Config::get('demo_mode')) { UI::access_denied(); break; } + Stats::clear(); + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Catalog statistics cleared'); + $body = ''; + show_confirmation($title, $body, $url); + break; + default: + case 'show_catalogs': + require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php'; + break; + case 'show_add_catalog': + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; + break; + case 'clear_now_playing': + if (Config::get('demo_mode')) { UI::access_denied(); break; } + Stream::clear_now_playing(); + show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),Config::get('web_path') . '/admin/catalog.php'); + break; + case 'show_disabled': + /* Stop the demo hippies */ + if (Config::get('demo_mode')) { break; } + + $songs = Song::get_disabled(); + if (count($songs)) { + require Config::get('prefix') . '/templates/show_disabled_songs.inc.php'; + } + else { + echo "<div class=\"error\" align=\"center\">" . T_('No Disabled songs found') . "</div>"; + } + break; + case 'show_delete_catalog': + /* Stop the demo hippies */ + if (Config::get('demo_mode')) { UI::access_denied(); break; } + + $catalog = new Catalog($_REQUEST['catalog_id']); + $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']); + show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1); + break; + case 'show_customize_catalog': + $catalog = new Catalog($_REQUEST['catalog_id']); + require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php'; + break; + case 'gather_album_art': + toggle_visible('ajax-loading'); + ob_end_flush(); + + $catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs(); + + // Itterate throught the catalogs and gather as needed + foreach ($catalogs as $catalog_id) { + $catalog = new Catalog($catalog_id); + require Config::get('prefix') . '/templates/show_gather_art.inc.php'; + flush(); + $catalog->get_art('',1); + } + $url = Config::get('web_path') . '/admin/catalog.php'; + $title = T_('Album Art Search Finished'); + $body = ''; + show_confirmation($title,$body,$url); + break; } // end switch /* Show the Footer */ diff --git a/admin/duplicates.php b/admin/duplicates.php index fe518bd5..fbaa29b8 100644 --- a/admin/duplicates.php +++ b/admin/duplicates.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,23 +23,23 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit; + UI::access_denied(); + exit; } UI::show_header(); /* Switch on Action */ switch ($_REQUEST['action']) { - case 'find_duplicates': - $search_type = Dba::escape($_REQUEST['search_type']); - $duplicates = Song::find_duplicates($search_type); - require_once Config::get('prefix') . '/templates/show_duplicate.inc.php'; - require_once Config::get('prefix') . '/templates/show_duplicates.inc.php'; - break; - default: - require_once Config::get('prefix') . '/templates/show_duplicate.inc.php'; - break; + case 'find_duplicates': + $search_type = Dba::escape($_REQUEST['search_type']); + $duplicates = Song::find_duplicates($search_type); + require_once Config::get('prefix') . '/templates/show_duplicate.inc.php'; + require_once Config::get('prefix') . '/templates/show_duplicates.inc.php'; + break; + default: + require_once Config::get('prefix') . '/templates/show_duplicate.inc.php'; + break; } // end switch on action UI::show_footer(); diff --git a/admin/export.php b/admin/export.php index 5805a1fe..9e52bb64 100644 --- a/admin/export.php +++ b/admin/export.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,54 +23,54 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit; + UI::access_denied(); + exit; } UI::show_header(); /* Switch on Action */ switch ($_REQUEST['action']) { - case 'export': + case 'export': - // This may take a while - set_time_limit(0); + // This may take a while + set_time_limit(0); - $catalog = new Catalog($_REQUEST['export_catalog']); + $catalog = new Catalog($_REQUEST['export_catalog']); - // Clear everything we've done so far - ob_end_clean(); + // Clear everything we've done so far + ob_end_clean(); - // This will disable buffering so contents are sent immediately to browser. - // This is very useful for large catalogs because it will immediately display the download dialog to user, - // instead of waiting until contents are generated, which could take a long time. - ob_implicit_flush(true); + // This will disable buffering so contents are sent immediately to browser. + // This is very useful for large catalogs because it will immediately display the download dialog to user, + // instead of waiting until contents are generated, which could take a long time. + ob_implicit_flush(true); - header("Content-Transfer-Encoding: binary"); - header("Cache-control: public"); + header("Content-Transfer-Encoding: binary"); + header("Cache-control: public"); - $date = date("d/m/Y",time()); + $date = date("d/m/Y",time()); - switch($_REQUEST['export_format']) { - case 'itunes': - header("Content-Type: application/itunes+xml; charset=utf-8"); - header("Content-Disposition: attachment; filename=\"ampache-itunes-$date.xml\""); - $catalog->export('itunes'); - break; - case 'csv': - header("Content-Type: application/vnd.ms-excel"); - header("Content-Disposition: filename=\"ampache-export-$date.csv\""); - $catalog->export('csv'); - break; - } // end switch on format + switch($_REQUEST['export_format']) { + case 'itunes': + header("Content-Type: application/itunes+xml; charset=utf-8"); + header("Content-Disposition: attachment; filename=\"ampache-itunes-$date.xml\""); + $catalog->export('itunes'); + break; + case 'csv': + header("Content-Type: application/vnd.ms-excel"); + header("Content-Disposition: filename=\"ampache-export-$date.csv\""); + $catalog->export('csv'); + break; + } // end switch on format - // We don't want the footer so we're done here - exit; + // We don't want the footer so we're done here + exit; - break; - default: - require_once Config::get('prefix') . '/templates/show_export.inc.php'; - break; + break; + default: + require_once Config::get('prefix') . '/templates/show_export.inc.php'; + break; } // end switch on action UI::show_footer(); diff --git a/admin/flag.php b/admin/flag.php index bb3e64aa..fe12baa4 100644 --- a/admin/flag.php +++ b/admin/flag.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,282 +23,282 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); switch ($_REQUEST['action']) { - case 'edit_song': - $catalog = new Catalog(); - $song = new Song($_REQUEST['song_id']); - $new_song = new Song(); + case 'edit_song': + $catalog = new Catalog(); + $song = new Song($_REQUEST['song_id']); + $new_song = new Song(); - /* Setup the vars so we can use the update_song function */ - $new_song->title = unhtmlentities(scrub_in($_REQUEST['title'])); - $new_song->track = unhtmlentities(scrub_in($_REQUEST['track'])); - $new_song->year = unhtmlentities(scrub_in($_REQUEST['year'])); - $new_song->comment = unhtmlentities(scrub_in($_REQUEST['comment'])); + /* Setup the vars so we can use the update_song function */ + $new_song->title = unhtmlentities(scrub_in($_REQUEST['title'])); + $new_song->track = unhtmlentities(scrub_in($_REQUEST['track'])); + $new_song->year = unhtmlentities(scrub_in($_REQUEST['year'])); + $new_song->comment = unhtmlentities(scrub_in($_REQUEST['comment'])); - /* If no change in string take Drop down */ - if (strcasecmp(stripslashes($_REQUEST['album_string']),$song->get_album_name()) == 0) { - $album = $song->get_album_name($_REQUEST['album']); - } - else { - $album = scrub_in($_REQUEST['album_string']); - } + /* If no change in string take Drop down */ + if (strcasecmp(stripslashes($_REQUEST['album_string']),$song->get_album_name()) == 0) { + $album = $song->get_album_name($_REQUEST['album']); + } + else { + $album = scrub_in($_REQUEST['album_string']); + } - if (strcasecmp(stripslashes($_REQUEST['artist_string']),$song->get_artist_name()) == 0) { - $artist = $song->get_artist_name($_REQUEST['artist']); - } - else { - $artist = scrub_in($_REQUEST['artist_string']); - } + if (strcasecmp(stripslashes($_REQUEST['artist_string']),$song->get_artist_name()) == 0) { + $artist = $song->get_artist_name($_REQUEST['artist']); + } + else { + $artist = scrub_in($_REQUEST['artist_string']); + } - /* Use the check functions to get / create ids for this info */ - $new_song->album = $catalog->check_album(unhtmlentities($album)); - $new_song->artist = $catalog->check_artist(unhtmlentities($artist)); + /* Use the check functions to get / create ids for this info */ + $new_song->album = $catalog->check_album(unhtmlentities($album)); + $new_song->artist = $catalog->check_artist(unhtmlentities($artist)); - /* Update this mofo, store an old copy for cleaning */ - $old_song = new Song(); - $old_song->artist = $song->artist; - $old_song->album = $song->album; - $song->update_song($song->id,$new_song); + /* Update this mofo, store an old copy for cleaning */ + $old_song = new Song(); + $old_song->artist = $song->artist; + $old_song->album = $song->album; + $song->update_song($song->id,$new_song); - /* Now that it's been updated clean old junk entries */ - $catalog = new Catalog(); - $cleaned = $catalog->clean_single_song($old_song); + /* Now that it's been updated clean old junk entries */ + $catalog = new Catalog(); + $cleaned = $catalog->clean_single_song($old_song); - /* Add a tagging record of this so we can fix the file */ - if ($_REQUEST['flag']) { - $flag = new Flag(); - $flag->add($song->id,'song','retag','Edited Song, auto-tag'); - } + /* Add a tagging record of this so we can fix the file */ + if ($_REQUEST['flag']) { + $flag = new Flag(); + $flag->add($song->id,'song','retag','Edited Song, auto-tag'); + } - if (isset($cleaned['artist']) || isset($cleaned['album'])) { $_SESSION['source'] = Config::get('web_path') . '/index.php'; } + if (isset($cleaned['artist']) || isset($cleaned['album'])) { $_SESSION['source'] = Config::get('web_path') . '/index.php'; } - show_confirmation(T_('Song Updated'), T_('The requested song has been updated'),$_SESSION['source']); - break; - // Show the page for editing a full album - case 'show_edit_album': + show_confirmation(T_('Song Updated'), T_('The requested song has been updated'),$_SESSION['source']); + break; + // Show the page for editing a full album + case 'show_edit_album': - $album = new Album($_REQUEST['album_id']); + $album = new Album($_REQUEST['album_id']); - require_once Config::get('prefix') . '/templates/show_edit_album.inc.php'; + require_once Config::get('prefix') . '/templates/show_edit_album.inc.php'; - break; - // Update all songs from this album - case 'edit_album': + break; + // Update all songs from this album + case 'edit_album': - // Build the needed album - $album = new Album($_REQUEST['album_id']); + // Build the needed album + $album = new Album($_REQUEST['album_id']); - // Create the needed catalog object cause we can't do - // static class methods :( - $catalog = new Catalog(); - $flag = new Flag(); + // Create the needed catalog object cause we can't do + // static class methods :( + $catalog = new Catalog(); + $flag = new Flag(); - /* Check the new Name */ - $album_id = $catalog->check_album($_REQUEST['name'],$_REQUEST['year']); + /* Check the new Name */ + $album_id = $catalog->check_album($_REQUEST['name'],$_REQUEST['year']); - $songs = $album->get_songs(); + $songs = $album->get_songs(); - foreach ($songs as $song) { - // Make that copy and change the album - $new_song = $song; - $new_song->album = $album_id; + foreach ($songs as $song) { + // Make that copy and change the album + $new_song = $song; + $new_song->album = $album_id; - $song->update_song($song->id,$new_song); + $song->update_song($song->id,$new_song); - if ($_REQUEST['flag'] == '1') { - $flag->add($song->id,'song','retag','Edited Song, auto-tag'); - } + if ($_REQUEST['flag'] == '1') { + $flag->add($song->id,'song','retag','Edited Song, auto-tag'); + } - } // end foreach songs + } // end foreach songs - // Clean out the old album - Album::gc(); + // Clean out the old album + Album::gc(); - show_confirmation(T_('Album Updated'),'',Config::get('web_path') . '/admin/index.php'); + show_confirmation(T_('Album Updated'),'',Config::get('web_path') . '/admin/index.php'); - break; - // Show the page for editing a full artist - case 'show_edit_artist': + break; + // Show the page for editing a full artist + case 'show_edit_artist': - $artist = new Artist($_REQUEST['artist_id']); + $artist = new Artist($_REQUEST['artist_id']); - require_once Config::get('prefix') . '/templates/show_edit_artist.inc.php'; + require_once Config::get('prefix') . '/templates/show_edit_artist.inc.php'; - break; - // Update all songs by this artist - case 'edit_artist': + break; + // Update all songs by this artist + case 'edit_artist': - // Build the needed artist - $artist = new Artist($_REQUEST['artist_id']); - - // Create the needed objects, a pox on PHP4 - $catalog = new Catalog(); - $flag = new Flag(); + // Build the needed artist + $artist = new Artist($_REQUEST['artist_id']); + + // Create the needed objects, a pox on PHP4 + $catalog = new Catalog(); + $flag = new Flag(); - /* Check the new Name */ - $artist_id = $catalog->check_artist($_REQUEST['name']); - - $songs = $artist->get_songs(); - - foreach ($songs as $song) { - // Make that copy and change the artist - $new_song = $song; - $new_song->artist = $artist_id; - - $song->update_song($song->id,$new_song); - - if ($_REQUEST['flag'] == '1') { - $flag->add($song->id,'song','retag','Edited Song, auto-tag'); - } - - } // end foreach songs - - // Clean out the old artist(s) - Artist::gc(); - - show_confirmation(T_('Artist Updated'),'',Config::get('web_path') . '/admin/index.php'); - - break; - /* Done by 'Select' code passes array of song ids */ - case 'mass_update': - $songs = $_REQUEST['song']; - $catalog = new Catalog(); - $object = $_REQUEST['update_field']; - $flag = new Flag(); - - /* If this is an album we need to pull the songs */ - if ($_REQUEST['type'] == 'album') { - - // Define the results array - $results = array(); - - foreach ($songs as $album_id) { - $album = new Album($album_id); - $results = array_merge($results,$album->get_song_ids()); - } // end foreach albums - - // Re-assign the variable... HACK ALERT :( - $songs = $results; - - } // is album - - /* Foreach the songs we need to update */ - foreach ($songs as $song_id) { - - $new_song = new Song($song_id); - $old_song = new Song(); - $old_song->artist = $new_song->artist; - $old_song->album = $new_song->album; - - /* Restrict which fields can be updated */ - switch ($object) { - case 'album': - $new_song->album = $catalog->check_album(unhtmlentities($_REQUEST['update_value'])); - break; - case 'artist': - $new_song->artist = $catalog->check_artist(unhtmlentities($_REQUEST['update_value'])); - break; - case 'year': - $new_song->year = intval($_REQUEST['update_value']); - break; - default: - // Rien a faire - break; - } // end switch - - /* Update this mofo, store an old copy for cleaning */ - $new_song->update_song($song_id,$new_song); - - /* Now that it's been updated clean old junk entries */ - $cleaned = $catalog->clean_single_song($old_song); - - $flag->add($song_id,'song','retag','Edited Song, auto-tag'); - - } // end foreach songs - - // Show a confirmation that this worked - show_confirmation(T_('Songs Updated'),'',return_referer()); - break; - case 'reject_flag': - $flag_id = scrub_in($_REQUEST['flag_id']); - $flag = new Flag($flag_id); - $flag->delete_flag(); - $flag->format_name(); - $url = return_referer(); - $title = T_('Flag Removed'); - $body = T_('Flag Removed from') . " " . $flag->name; - show_confirmation($title,$body,$url); - break; - case 'reject_flags': - $flags = $_REQUEST['song']; - - foreach ($flags as $flag_id) { - $flag = new Flag($flag_id); - if ($_REQUEST['update_action'] == 'reject') { - $flag->delete_flag(); - } - else { - $flag->approve(); - } - } // end foreach flags - $title = T_('Flags Updated'); - show_confirmation($title,'',return_referer()); - break; - case 'show_edit_song': - $_SESSION['source'] = return_referer(); - $song = new Song($_REQUEST['song']); - $song->fill_ext_info(); - $song->format_song(); - require_once Config::get('prefix') . '/templates/show_edit_song.inc.php'; - break; - case 'disable': - $song_obj = new Song(); - // If we pass just one, make it still work - if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(0,$_REQUEST['song_ids']); } - else { - foreach ($_REQUEST['song_ids'] as $song_id) { - $song_obj->update_enabled(0,$song_id); - } // end foreach - } // end else - show_confirmation(T_('Songs Disabled'), T_('The requested song(s) have been disabled'),return_referer()); - break; - case 'enabled': - $song_obj = new Song(); - // If we pass just one, make it still work - if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(1,$_REQUEST['song_ids']); } - else { - foreach ($_REQUEST['song_ids'] as $song_id) { - $song_obj->update_enabled(1,$song_id); - } // end foreach - } // end else - show_confirmation(T_('Songs Enabled'), T_('The requested song(s) have been enabled'),return_referer()); - break; - case 'show_disabled': - $disabled = Flag::get_disabled(); - $browse = new Browse(); - $browse->set_type('song'); - $browse->set_static_content(true); - $browse->save_objects($disabled); - $browse->show_objects($disabled); - $browse->store(); - break; - default: - case 'show_flagged': - $flagged = Flag::get_all(); - Flag::build_cache($flagged); - $browse = new Browse(); - $browse->set_type('flagged'); - $browse->set_static_content(true); - $browse->save_objects($flagged); - $browse->show_objects($flagged); - $browse->store(); - break; + /* Check the new Name */ + $artist_id = $catalog->check_artist($_REQUEST['name']); + + $songs = $artist->get_songs(); + + foreach ($songs as $song) { + // Make that copy and change the artist + $new_song = $song; + $new_song->artist = $artist_id; + + $song->update_song($song->id,$new_song); + + if ($_REQUEST['flag'] == '1') { + $flag->add($song->id,'song','retag','Edited Song, auto-tag'); + } + + } // end foreach songs + + // Clean out the old artist(s) + Artist::gc(); + + show_confirmation(T_('Artist Updated'),'',Config::get('web_path') . '/admin/index.php'); + + break; + /* Done by 'Select' code passes array of song ids */ + case 'mass_update': + $songs = $_REQUEST['song']; + $catalog = new Catalog(); + $object = $_REQUEST['update_field']; + $flag = new Flag(); + + /* If this is an album we need to pull the songs */ + if ($_REQUEST['type'] == 'album') { + + // Define the results array + $results = array(); + + foreach ($songs as $album_id) { + $album = new Album($album_id); + $results = array_merge($results,$album->get_song_ids()); + } // end foreach albums + + // Re-assign the variable... HACK ALERT :( + $songs = $results; + + } // is album + + /* Foreach the songs we need to update */ + foreach ($songs as $song_id) { + + $new_song = new Song($song_id); + $old_song = new Song(); + $old_song->artist = $new_song->artist; + $old_song->album = $new_song->album; + + /* Restrict which fields can be updated */ + switch ($object) { + case 'album': + $new_song->album = $catalog->check_album(unhtmlentities($_REQUEST['update_value'])); + break; + case 'artist': + $new_song->artist = $catalog->check_artist(unhtmlentities($_REQUEST['update_value'])); + break; + case 'year': + $new_song->year = intval($_REQUEST['update_value']); + break; + default: + // Rien a faire + break; + } // end switch + + /* Update this mofo, store an old copy for cleaning */ + $new_song->update_song($song_id,$new_song); + + /* Now that it's been updated clean old junk entries */ + $cleaned = $catalog->clean_single_song($old_song); + + $flag->add($song_id,'song','retag','Edited Song, auto-tag'); + + } // end foreach songs + + // Show a confirmation that this worked + show_confirmation(T_('Songs Updated'),'',return_referer()); + break; + case 'reject_flag': + $flag_id = scrub_in($_REQUEST['flag_id']); + $flag = new Flag($flag_id); + $flag->delete_flag(); + $flag->format_name(); + $url = return_referer(); + $title = T_('Flag Removed'); + $body = T_('Flag Removed from') . " " . $flag->name; + show_confirmation($title,$body,$url); + break; + case 'reject_flags': + $flags = $_REQUEST['song']; + + foreach ($flags as $flag_id) { + $flag = new Flag($flag_id); + if ($_REQUEST['update_action'] == 'reject') { + $flag->delete_flag(); + } + else { + $flag->approve(); + } + } // end foreach flags + $title = T_('Flags Updated'); + show_confirmation($title,'',return_referer()); + break; + case 'show_edit_song': + $_SESSION['source'] = return_referer(); + $song = new Song($_REQUEST['song']); + $song->fill_ext_info(); + $song->format_song(); + require_once Config::get('prefix') . '/templates/show_edit_song.inc.php'; + break; + case 'disable': + $song_obj = new Song(); + // If we pass just one, make it still work + if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(0,$_REQUEST['song_ids']); } + else { + foreach ($_REQUEST['song_ids'] as $song_id) { + $song_obj->update_enabled(0,$song_id); + } // end foreach + } // end else + show_confirmation(T_('Songs Disabled'), T_('The requested song(s) have been disabled'),return_referer()); + break; + case 'enabled': + $song_obj = new Song(); + // If we pass just one, make it still work + if (!is_array($_REQUEST['song_ids'])) { $song_obj->update_enabled(1,$_REQUEST['song_ids']); } + else { + foreach ($_REQUEST['song_ids'] as $song_id) { + $song_obj->update_enabled(1,$song_id); + } // end foreach + } // end else + show_confirmation(T_('Songs Enabled'), T_('The requested song(s) have been enabled'),return_referer()); + break; + case 'show_disabled': + $disabled = Flag::get_disabled(); + $browse = new Browse(); + $browse->set_type('song'); + $browse->set_static_content(true); + $browse->save_objects($disabled); + $browse->show_objects($disabled); + $browse->store(); + break; + default: + case 'show_flagged': + $flagged = Flag::get_all(); + Flag::build_cache($flagged); + $browse = new Browse(); + $browse->set_type('flagged'); + $browse->set_static_content(true); + $browse->save_objects($flagged); + $browse->show_objects($flagged); + $browse->store(); + break; } // end switch UI::show_footer(); diff --git a/admin/index.php b/admin/index.php index e79e28ac..86003326 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,23 +23,23 @@ require_once '../lib/init.php'; if (!Access::check('interface',100)) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); switch ($_REQUEST['action']) { - default: - // Show Catalogs - $catalog_ids = Catalog::get_catalogs(); - $browse = new Browse(); - $browse->set_type('catalog'); - $browse->set_static_content(true); - $browse->save_objects($catalog_ids); - $browse->show_objects($catalog_ids); - $browse->store(); - break; + default: + // Show Catalogs + $catalog_ids = Catalog::get_catalogs(); + $browse = new Browse(); + $browse->set_type('catalog'); + $browse->set_static_content(true); + $browse->save_objects($catalog_ids); + $browse->show_objects($catalog_ids); + $browse->store(); + break; } UI::show_footer(); diff --git a/admin/mail.php b/admin/mail.php index 6ed43fd8..b5f9c802 100644 --- a/admin/mail.php +++ b/admin/mail.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,55 +23,55 @@ require_once '../lib/init.php'; if (!Access::check('interface','75')) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); // Action switch switch ($_REQUEST['action']) { - case 'send_mail': - if (Config::get('demo_mode')) { - UI::access_denied(); - exit; - } + case 'send_mail': + if (Config::get('demo_mode')) { + UI::access_denied(); + exit; + } - // Multi-byte Character Mail - if(function_exists('mb_language')) { - ini_set("mbstring.internal_encoding","UTF-8"); - mb_language("uni"); - } + // Multi-byte Character Mail + if(function_exists('mb_language')) { + ini_set("mbstring.internal_encoding","UTF-8"); + mb_language("uni"); + } - $mailer = new Ampache_Mail(); + $mailer = new Ampache_Mail(); - // Set the vars on the object - $mailer->subject = $_REQUEST['subject']; - $mailer->message = $_REQUEST['message']; + // Set the vars on the object + $mailer->subject = $_REQUEST['subject']; + $mailer->message = $_REQUEST['message']; - if ($_REQUEST['from'] == 'system') { - $mailer->set_default_sender(); - } - else { - $mailer->sender = $GLOBALS['user']->email; - $mailer->sender_name = $GLOBALS['user']->fullname; - } + if ($_REQUEST['from'] == 'system') { + $mailer->set_default_sender(); + } + else { + $mailer->sender = $GLOBALS['user']->email; + $mailer->sender_name = $GLOBALS['user']->fullname; + } - if($mailer->send_to_group($_REQUEST['to'])) { - $title = T_('E-mail Sent'); - $body = T_('Your E-mail was successfully sent.'); - } - else { - $title = T_('E-mail Not Sent'); - $body = T_('Your E-mail was not sent.'); - } - $url = Config::get('web_path') . '/admin/mail.php'; - show_confirmation($title,$body,$url); + if($mailer->send_to_group($_REQUEST['to'])) { + $title = T_('E-mail Sent'); + $body = T_('Your E-mail was successfully sent.'); + } + else { + $title = T_('E-mail Not Sent'); + $body = T_('Your E-mail was not sent.'); + } + $url = Config::get('web_path') . '/admin/mail.php'; + show_confirmation($title,$body,$url); - break; - default: - require_once Config::get('prefix') . '/templates/show_mail_users.inc.php'; - break; + break; + default: + require_once Config::get('prefix') . '/templates/show_mail_users.inc.php'; + break; } // end switch UI::show_footer(); diff --git a/admin/modules.php b/admin/modules.php index 33ec00e6..382f326a 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,8 +23,8 @@ require_once '../lib/init.php'; if (!$GLOBALS['user']->has_access(100)) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } @@ -32,125 +32,125 @@ if (!$GLOBALS['user']->has_access(100)) { UI::show_header(); switch ($_REQUEST['action']) { - case 'install_localplay': - $localplay = new Localplay($_REQUEST['type']); - if (!$localplay->player_loaded()) { - Error::add('general', T_('Install Failed, Controller Error')); - Error::display('general'); - break; - } - // Install it! - $localplay->install(); + case 'install_localplay': + $localplay = new Localplay($_REQUEST['type']); + if (!$localplay->player_loaded()) { + Error::add('general', T_('Install Failed, Controller Error')); + Error::display('general'); + break; + } + // Install it! + $localplay->install(); - // Go ahead and enable Localplay (Admin->System) as we assume they want to do that - // if they are enabling this - Preference::update('allow_localplay_playback','-1','1'); - Preference::update('localplay_level',$GLOBALS['user']->id,'100'); - Preference::update('localplay_controller',$GLOBALS['user']->id,$localplay->type); + // Go ahead and enable Localplay (Admin->System) as we assume they want to do that + // if they are enabling this + Preference::update('allow_localplay_playback','-1','1'); + Preference::update('localplay_level',$GLOBALS['user']->id,'100'); + Preference::update('localplay_controller',$GLOBALS['user']->id,$localplay->type); - header("Location:" . Config::get('web_path') . '/admin/modules.php?action=show_localplay'); - break; - case 'confirm_uninstall_localplay': - $type = scrub_in($_REQUEST['type']); - $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_localplay&type=' . $type; - $title = T_('Are you sure you want to remove this plugin?'); - $body = ''; - show_confirmation($title,$body,$url,1); - break; - case 'uninstall_localplay': - $type = scrub_in($_REQUEST['type']); + header("Location:" . Config::get('web_path') . '/admin/modules.php?action=show_localplay'); + break; + case 'confirm_uninstall_localplay': + $type = scrub_in($_REQUEST['type']); + $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_localplay&type=' . $type; + $title = T_('Are you sure you want to remove this plugin?'); + $body = ''; + show_confirmation($title,$body,$url,1); + break; + case 'uninstall_localplay': + $type = scrub_in($_REQUEST['type']); - $localplay = new Localplay($type); - $localplay->uninstall(); + $localplay = new Localplay($type); + $localplay->uninstall(); - /* Show Confirmation */ - $url = Config::get('web_path') . '/admin/modules.php?action=show_localplay'; - $title = T_('Plugin Deactivated'); - $body = ''; - show_confirmation($title,$body,$url); - break; - case 'install_plugin': - /* Verify that this plugin exists */ - $plugins = Plugin::get_plugins(); - if (!array_key_exists($_REQUEST['plugin'],$plugins)) { - debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); - break; - } - $plugin = new Plugin($_REQUEST['plugin']); - if (!$plugin->install()) { - debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1'); - $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; - $title = T_('Unable to Install Plugin'); - $body = ''; - show_confirmation($title,$body,$url); - break; - } + /* Show Confirmation */ + $url = Config::get('web_path') . '/admin/modules.php?action=show_localplay'; + $title = T_('Plugin Deactivated'); + $body = ''; + show_confirmation($title,$body,$url); + break; + case 'install_plugin': + /* Verify that this plugin exists */ + $plugins = Plugin::get_plugins(); + if (!array_key_exists($_REQUEST['plugin'],$plugins)) { + debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); + break; + } + $plugin = new Plugin($_REQUEST['plugin']); + if (!$plugin->install()) { + debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1'); + $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; + $title = T_('Unable to Install Plugin'); + $body = ''; + show_confirmation($title,$body,$url); + break; + } - // Don't trust the plugin to this stuff - User::rebuild_all_preferences(); + // Don't trust the plugin to this stuff + User::rebuild_all_preferences(); - /* Show Confirmation */ - $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; - $title = T_('Plugin Activated'); - $body = ''; - show_confirmation($title,$body,$url); - break; - case 'confirm_uninstall_plugin': - $plugin = scrub_in($_REQUEST['plugin']); - $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_plugin&plugin=' . $plugin; - $title = T_('Are you sure you want to remove this plugin?'); - $body = ''; - show_confirmation($title,$body,$url,1); - break; - case 'uninstall_plugin': - /* Verify that this plugin exists */ - $plugins = Plugin::get_plugins(); - if (!array_key_exists($_REQUEST['plugin'],$plugins)) { - debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); - break; - } - $plugin = new Plugin($_REQUEST['plugin']); - $plugin->uninstall(); + /* Show Confirmation */ + $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; + $title = T_('Plugin Activated'); + $body = ''; + show_confirmation($title,$body,$url); + break; + case 'confirm_uninstall_plugin': + $plugin = scrub_in($_REQUEST['plugin']); + $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_plugin&plugin=' . $plugin; + $title = T_('Are you sure you want to remove this plugin?'); + $body = ''; + show_confirmation($title,$body,$url,1); + break; + case 'uninstall_plugin': + /* Verify that this plugin exists */ + $plugins = Plugin::get_plugins(); + if (!array_key_exists($_REQUEST['plugin'],$plugins)) { + debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); + break; + } + $plugin = new Plugin($_REQUEST['plugin']); + $plugin->uninstall(); - // Don't trust the plugin to do it - User::rebuild_all_preferences(); + // Don't trust the plugin to do it + User::rebuild_all_preferences(); - /* Show Confirmation */ - $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; - $title = T_('Plugin Deactivated'); - $body = ''; - show_confirmation($title,$body,$url); - break; - case 'upgrade_plugin': - /* Verify that this plugin exists */ - $plugins = Plugin::get_plugins(); - if (!array_key_exists($_REQUEST['plugin'],$plugins)) { - debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); - break; - } - $plugin = new Plugin($_REQUEST['plugin']); - $plugin->upgrade(); - User::rebuild_all_preferences(); - $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; - $title = T_('Plugin Upgraded'); - $body = ''; - show_confirmation($title, $body, $url); - break; - case 'show_plugins': - $plugins = Plugin::get_plugins(); - UI::show_box_top(T_('Plugins'), 'box box_localplay_plugins'); - require_once Config::get('prefix') . '/templates/show_plugins.inc.php'; - UI::show_box_bottom(); - break; - case 'show_localplay': - $controllers = Localplay::get_controllers(); - UI::show_box_top(T_('Localplay Controllers'), 'box box_localplay_controllers'); - require_once Config::get('prefix') . '/templates/show_localplay_controllers.inc.php'; - UI::show_box_bottom(); - break; - default: - // Rien a faire - break; + /* Show Confirmation */ + $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; + $title = T_('Plugin Deactivated'); + $body = ''; + show_confirmation($title,$body,$url); + break; + case 'upgrade_plugin': + /* Verify that this plugin exists */ + $plugins = Plugin::get_plugins(); + if (!array_key_exists($_REQUEST['plugin'],$plugins)) { + debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1'); + break; + } + $plugin = new Plugin($_REQUEST['plugin']); + $plugin->upgrade(); + User::rebuild_all_preferences(); + $url = Config::get('web_path') . '/admin/modules.php?action=show_plugins'; + $title = T_('Plugin Upgraded'); + $body = ''; + show_confirmation($title, $body, $url); + break; + case 'show_plugins': + $plugins = Plugin::get_plugins(); + UI::show_box_top(T_('Plugins'), 'box box_localplay_plugins'); + require_once Config::get('prefix') . '/templates/show_plugins.inc.php'; + UI::show_box_bottom(); + break; + case 'show_localplay': + $controllers = Localplay::get_controllers(); + UI::show_box_top(T_('Localplay Controllers'), 'box box_localplay_controllers'); + require_once Config::get('prefix') . '/templates/show_localplay_controllers.inc.php'; + UI::show_box_bottom(); + break; + default: + // Rien a faire + break; } // end switch UI::show_footer(); diff --git a/admin/shout.php b/admin/shout.php index ca6933ac..d34160b3 100644 --- a/admin/shout.php +++ b/admin/shout.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,39 +23,39 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit; + UI::access_denied(); + exit; } UI::show_header(); // Switch on the incomming action switch ($_REQUEST['action']) { - case 'edit_shout': - $shout_id = $_POST['shout_id']; - $update = Shoutbox::update($_POST); - show_confirmation(T_('Shoutbox Post Updated'),'',Config::get('web_path').'/admin/shout.php'); - break; - case 'show_edit': - $shout = new Shoutbox($_REQUEST['shout_id']); - $object = Shoutbox::get_object($shout->object_type,$shout->object_id); - $object->format(); - $client = new User($shout->user); - $client->format(); - require_once Config::get('prefix') . '/templates/show_edit_shout.inc.php'; - break; - case 'delete': - $shout_id = Shoutbox::delete($_REQUEST['shout_id']); - show_confirmation(T_('Shoutbox Post Deleted'),'',Config::get('web_path').'/admin/shout.php'); - break; - default: - $browse = new Browse(); - $browse->set_type('shoutbox'); - $browse->set_simple_browse(true); - $shoutbox_ids = $browse->get_objects(); - $browse->show_objects($shoutbox_ids); - $browse->store(); - break; + case 'edit_shout': + $shout_id = $_POST['shout_id']; + $update = Shoutbox::update($_POST); + show_confirmation(T_('Shoutbox Post Updated'),'',Config::get('web_path').'/admin/shout.php'); + break; + case 'show_edit': + $shout = new Shoutbox($_REQUEST['shout_id']); + $object = Shoutbox::get_object($shout->object_type,$shout->object_id); + $object->format(); + $client = new User($shout->user); + $client->format(); + require_once Config::get('prefix') . '/templates/show_edit_shout.inc.php'; + break; + case 'delete': + $shout_id = Shoutbox::delete($_REQUEST['shout_id']); + show_confirmation(T_('Shoutbox Post Deleted'),'',Config::get('web_path').'/admin/shout.php'); + break; + default: + $browse = new Browse(); + $browse->set_type('shoutbox'); + $browse->set_simple_browse(true); + $shoutbox_ids = $browse->get_objects(); + $browse->show_objects($shoutbox_ids); + $browse->store(); + break; } // end switch on action UI::show_footer(); diff --git a/admin/system.php b/admin/system.php index e98f592d..7b12385d 100644 --- a/admin/system.php +++ b/admin/system.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,37 +23,37 @@ require_once '../lib/init.php'; if (!Access::check('interface',100) OR Config::get('demo_mode')) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); /* Switch on action boys */ switch ($_REQUEST['action']) { - /* This re-generates the config file comparing - * /config/ampache.cfg to .cfg.dist - */ - case 'generate_config': - ob_end_clean(); - $current = parse_ini_file(Config::get('prefix') . '/config/ampache.cfg.php'); - $final = generate_config($current); - $browser = new Horde_Browser(); - $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(Config::get('prefix') . '/config/ampache.cfg.php.dist')); - echo $final; - exit; - break; - case 'reset_db_charset': - Dba::reset_db_charset(); - show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), Config::get('web_path').'/admin/system.php?action=show_debug'); - break; - case 'show_debug': - $configuration = Config::get_all(); - require_once Config::get('prefix') . '/templates/show_debug.inc.php'; - break; - default: - // Rien a faire - break; + /* This re-generates the config file comparing + * /config/ampache.cfg to .cfg.dist + */ + case 'generate_config': + ob_end_clean(); + $current = parse_ini_file(Config::get('prefix') . '/config/ampache.cfg.php'); + $final = generate_config($current); + $browser = new Horde_Browser(); + $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(Config::get('prefix') . '/config/ampache.cfg.php.dist')); + echo $final; + exit; + break; + case 'reset_db_charset': + Dba::reset_db_charset(); + show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), Config::get('web_path').'/admin/system.php?action=show_debug'); + break; + case 'show_debug': + $configuration = Config::get_all(); + require_once Config::get('prefix') . '/templates/show_debug.inc.php'; + break; + default: + // Rien a faire + break; } // end switch UI::show_footer(); diff --git a/admin/users.php b/admin/users.php index 84d19938..e8aecb76 100644 --- a/admin/users.php +++ b/admin/users.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -23,185 +23,185 @@ require_once '../lib/init.php'; if (!Access::check('interface','100')) { - UI::access_denied(); - exit(); + UI::access_denied(); + exit(); } UI::show_header(); // Switch on the actions switch ($_REQUEST['action']) { - case 'update_user': - if (Config::get('demo_mode')) { break; } - - if (!Core::form_verify('edit_user','post')) { - UI::access_denied(); - exit; - } - - /* Clean up the variables */ - $user_id = scrub_in($_POST['user_id']); - $username = scrub_in($_POST['username']); - $fullname = scrub_in($_POST['fullname']); - $email = scrub_in($_POST['email']); - $access = scrub_in($_POST['access']); - $pass1 = $_POST['password_1']; - $pass2 = $_POST['password_2']; - - /* Setup the temp user */ - $client = new User($user_id); - - /* Verify Input */ - if (empty($username)) { - Error::add('username', T_("Error Username Required")); - } - if ($pass1 !== $pass2 && !empty($pass1)) { - Error::add('password', T_("Error Passwords don't match")); - } - - /* If we've got an error then break! */ - if (Error::occurred()) { - $_REQUEST['action'] = 'show_edit'; - break; - } // if we've had an oops! - - if ($access != $client->access) { - $client->update_access($access); - } - if ($email != $client->email) { - $client->update_email($email); - } - if ($username != $client->username) { - $client->update_username($username); - } - if ($fullname != $client->fullname) { - $client->update_fullname($fullname); - } - if ($pass1 == $pass2 && strlen($pass1)) { - $client->update_password($pass1); - } - - show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), Config::get('web_path'). '/admin/users.php'); - break; - case 'add_user': - if (Config::get('demo_mode')) { break; } - - if (!Core::form_verify('add_user','post')) { - UI::access_denied(); - exit; - } - - $username = scrub_in($_POST['username']); - $fullname = scrub_in($_POST['fullname']); - $email = scrub_in($_POST['email']); - $access = scrub_in($_POST['access']); - $pass1 = $_POST['password_1']; - $pass2 = $_POST['password_2']; - - if ($pass1 !== $pass2 || !strlen($pass1)) { - Error::add('password', T_("Error Passwords don't match")); - } - - if (empty($username)) { - Error::add('username', T_('Error Username Required')); - } - - /* make sure the username doesn't already exist */ - if (!User::check_username($username)) { - Error::add('username', T_('Error Username already exists')); - } - - if (!Error::occurred()) { - /* Attempt to create the user */ - $user_id = User::create($username, $fullname, $email, $pass1, $access); - if (!$user_id) { - Error::add('general', T_("Error: Insert Failed")); - } - - } // if no errors - else { - $_REQUEST['action'] = 'show_add_user'; - break; - } - if ($access == 5){ $access = T_('Guest');} - elseif ($access == 25){ $access = T_('User');} - elseif ($access == 100){ $access = T_('Admin');} - - /* HINT: %1 Username, %2 Access num */ - show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), Config::get('web_path').'/admin/users.php'); - break; - case 'enable': - $client = new User($_REQUEST['user_id']); - $client->enable(); - show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php'); - break; - case 'disable': - $client = new User($_REQUEST['user_id']); - if ($client->disable()) { - show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php'); - } - else { - show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), Config::get('web_path').'/admin/users.php'); - } - break; - case 'show_edit': - if (Config::get('demo_mode')) { break; } - $client = new User($_REQUEST['user_id']); - require_once Config::get('prefix') . '/templates/show_edit_user.inc.php'; - break; - case 'confirm_delete': - if (Config::get('demo_mode')) { break; } - if (!Core::form_verify('delete_user')) { - UI::access_denied(); - exit; - } - $client = new User($_REQUEST['user_id']); - if ($client->delete()) { - show_confirmation(T_('User Deleted'), sprintf(T_('%s has been Deleted'), $client->username), Config::get('web_path'). "/admin/users.php"); - } - else { - show_confirmation(T_('Delete Error'), T_("Unable to delete last Admin User"), Config::get('web_path')."/admin/users.php"); - } - break; - case 'delete': - if (Config::get('demo_mode')) { break; } - $client = new User($_REQUEST['user_id']); - show_confirmation(T_('Deletion Request'), - sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname), - Config::get('web_path')."/admin/users.php?action=confirm_delete&user_id=" . $_REQUEST['user_id'],1,'delete_user'); - break; - /* Show IP History for the Specified User */ - case 'show_ip_history': - /* get the user and their history */ - $working_user = new User($_REQUEST['user_id']); - - if (!isset($_REQUEST['all'])){ - $history = $working_user->get_ip_history(0,1); - } - else { - $history = $working_user->get_ip_history(); - } - require Config::get('prefix') . '/templates/show_ip_history.inc.php'; - break; - case 'show_add_user': - if (Config::get('demo_mode')) { break; } - require_once Config::get('prefix') . '/templates/show_add_user.inc.php'; - break; - case 'show_preferences': - $client = new User($_REQUEST['user_id']); - $preferences = Preference::get_all($client->id); - require_once Config::get('prefix') . '/templates/show_user_preferences.inc.php'; - break; - default: - $browse = new Browse(); - $browse->reset_filters(); - $browse->set_type('user'); - $browse->set_simple_browse(1); - $browse->set_sort('name','ASC'); - $user_ids = $browse->get_objects(); - $browse->show_objects($user_ids); - $browse->store(); - break; + case 'update_user': + if (Config::get('demo_mode')) { break; } + + if (!Core::form_verify('edit_user','post')) { + UI::access_denied(); + exit; + } + + /* Clean up the variables */ + $user_id = scrub_in($_POST['user_id']); + $username = scrub_in($_POST['username']); + $fullname = scrub_in($_POST['fullname']); + $email = scrub_in($_POST['email']); + $access = scrub_in($_POST['access']); + $pass1 = $_POST['password_1']; + $pass2 = $_POST['password_2']; + + /* Setup the temp user */ + $client = new User($user_id); + + /* Verify Input */ + if (empty($username)) { + Error::add('username', T_("Error Username Required")); + } + if ($pass1 !== $pass2 && !empty($pass1)) { + Error::add('password', T_("Error Passwords don't match")); + } + + /* If we've got an error then break! */ + if (Error::occurred()) { + $_REQUEST['action'] = 'show_edit'; + break; + } // if we've had an oops! + + if ($access != $client->access) { + $client->update_access($access); + } + if ($email != $client->email) { + $client->update_email($email); + } + if ($username != $client->username) { + $client->update_username($username); + } + if ($fullname != $client->fullname) { + $client->update_fullname($fullname); + } + if ($pass1 == $pass2 && strlen($pass1)) { + $client->update_password($pass1); + } + + show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), Config::get('web_path'). '/admin/users.php'); + break; + case 'add_user': + if (Config::get('demo_mode')) { break; } + + if (!Core::form_verify('add_user','post')) { + UI::access_denied(); + exit; + } + + $username = scrub_in($_POST['username']); + $fullname = scrub_in($_POST['fullname']); + $email = scrub_in($_POST['email']); + $access = scrub_in($_POST['access']); + $pass1 = $_POST['password_1']; + $pass2 = $_POST['password_2']; + + if ($pass1 !== $pass2 || !strlen($pass1)) { + Error::add('password', T_("Error Passwords don't match")); + } + + if (empty($username)) { + Error::add('username', T_('Error Username Required')); + } + + /* make sure the username doesn't already exist */ + if (!User::check_username($username)) { + Error::add('username', T_('Error Username already exists')); + } + + if (!Error::occurred()) { + /* Attempt to create the user */ + $user_id = User::create($username, $fullname, $email, $pass1, $access); + if (!$user_id) { + Error::add('general', T_("Error: Insert Failed")); + } + + } // if no errors + else { + $_REQUEST['action'] = 'show_add_user'; + break; + } + if ($access == 5){ $access = T_('Guest');} + elseif ($access == 25){ $access = T_('User');} + elseif ($access == 100){ $access = T_('Admin');} + + /* HINT: %1 Username, %2 Access num */ + show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), Config::get('web_path').'/admin/users.php'); + break; + case 'enable': + $client = new User($_REQUEST['user_id']); + $client->enable(); + show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php'); + break; + case 'disable': + $client = new User($_REQUEST['user_id']); + if ($client->disable()) { + show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php'); + } + else { + show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), Config::get('web_path').'/admin/users.php'); + } + break; + case 'show_edit': + if (Config::get('demo_mode')) { break; } + $client = new User($_REQUEST['user_id']); + require_once Config::get('prefix') . '/templates/show_edit_user.inc.php'; + break; + case 'confirm_delete': + if (Config::get('demo_mode')) { break; } + if (!Core::form_verify('delete_user')) { + UI::access_denied(); + exit; + } + $client = new User($_REQUEST['user_id']); + if ($client->delete()) { + show_confirmation(T_('User Deleted'), sprintf(T_('%s has been Deleted'), $client->username), Config::get('web_path'). "/admin/users.php"); + } + else { + show_confirmation(T_('Delete Error'), T_("Unable to delete last Admin User"), Config::get('web_path')."/admin/users.php"); + } + break; + case 'delete': + if (Config::get('demo_mode')) { break; } + $client = new User($_REQUEST['user_id']); + show_confirmation(T_('Deletion Request'), + sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname), + Config::get('web_path')."/admin/users.php?action=confirm_delete&user_id=" . $_REQUEST['user_id'],1,'delete_user'); + break; + /* Show IP History for the Specified User */ + case 'show_ip_history': + /* get the user and their history */ + $working_user = new User($_REQUEST['user_id']); + + if (!isset($_REQUEST['all'])){ + $history = $working_user->get_ip_history(0,1); + } + else { + $history = $working_user->get_ip_history(); + } + require Config::get('prefix') . '/templates/show_ip_history.inc.php'; + break; + case 'show_add_user': + if (Config::get('demo_mode')) { break; } + require_once Config::get('prefix') . '/templates/show_add_user.inc.php'; + break; + case 'show_preferences': + $client = new User($_REQUEST['user_id']); + $preferences = Preference::get_all($client->id); + require_once Config::get('prefix') . '/templates/show_user_preferences.inc.php'; + break; + default: + $browse = new Browse(); + $browse->reset_filters(); + $browse->set_type('user'); + $browse->set_simple_browse(1); + $browse->set_sort('name','ASC'); + $user_ids = $browse->get_objects(); + $browse->show_objects($user_ids); + $browse->store(); + break; } // end switch on action /* Show the footer */ |