- :
- -
+ :
+ +
diff --git a/admin/access.php b/admin/access.php index 60e86d62f8..3945d174d0 100644 --- a/admin/access.php +++ b/admin/access.php @@ -1,5 +1,5 @@ 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 472ee8ced9..936b39a85a 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -1,5 +1,5 @@ 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 "
" . T_('Completed updating remote catalog(s)') . ".
" . T_('Completed updating remote catalog(s)') . ".
' . implode(' | ', $r) . ' |
' . implode(' | ', $r) . ' |
'; } - echo T_('No updates needed.'); - if (!defined('CLI')) { - echo '[Return]
'; - } - else { - echo "\n"; - } - } - } // display_update + if (!$update_needed) { + if (!defined('CLI')) { echo ''; } + echo T_('No updates needed.'); + if (!defined('CLI')) { + echo '[Return]
'; + } + else { + echo "\n"; + } + } + } // display_update - /** - * run_update - * This function actually updates the db. - * it goes through versions and finds the ones - * that need to be run. Checking to make sure - * the function exists first. - */ - public static function run_update() { + /** + * run_update + * This function actually updates the db. + * it goes through versions and finds the ones + * that need to be run. Checking to make sure + * the function exists first. + */ + public static function run_update() { - /* Nuke All Active session before we start the mojo */ - $sql = "TRUNCATE session"; - $db_results = Dba::write($sql); - - // Prevent the script from timing out, which could be bad - set_time_limit(0); - - /* Verify that there are no plugins installed - //FIXME: provide a link to remove all plugins, otherwise this could turn into a catch 22 - if (!$self::plugins_installed()) { - $GLOBALS['error']->add_error('general', T_('Plugins detected, please remove all Plugins and try again')); - return false; - } */ - - $methods = array(); + /* Nuke All Active session before we start the mojo */ + $sql = "TRUNCATE session"; + $db_results = Dba::write($sql); + + // Prevent the script from timing out, which could be bad + set_time_limit(0); + + /* Verify that there are no plugins installed + //FIXME: provide a link to remove all plugins, otherwise this could turn into a catch 22 + if (!$self::plugins_installed()) { + $GLOBALS['error']->add_error('general', T_('Plugins detected, please remove all Plugins and try again')); + return false; + } */ + + $methods = array(); - $current_version = self::get_version(); - - // Run a check to make sure that they don't try to upgrade from a version that - // won't work. - if ($current_version < '340001') { - echo "Database version too old, please upgrade to Ampache-3.3.3.5 first
"; - return false; - } - - - $methods = get_class_methods('Update'); - - if (!is_array((self::$versions))) { - self::$versions = self::populate_version(); - } - - foreach (self::$versions as $version) { + $current_version = self::get_version(); + + // Run a check to make sure that they don't try to upgrade from a version that + // won't work. + if ($current_version < '340001') { + echo "Database version too old, please upgrade to Ampache-3.3.3.5 first
"; + return false; + } + + + $methods = get_class_methods('Update'); + + if (!is_array((self::$versions))) { + self::$versions = self::populate_version(); + } + + foreach (self::$versions as $version) { - // If it's newer than our current version - // let's see if a function exists and run the - // bugger - if ($version['version'] > $current_version) { - $update_function = "update_" . $version['version']; - if (in_array($update_function,$methods)) { - $success = call_user_func(array('Update',$update_function)); - - // If the update fails drop out - if (!$success) { - Error::display('update'); - return false; - } - } - - } - - } // end foreach version + // If it's newer than our current version + // let's see if a function exists and run the + // bugger + if ($version['version'] > $current_version) { + $update_function = "update_" . $version['version']; + if (in_array($update_function,$methods)) { + $success = call_user_func(array('Update',$update_function)); + + // If the update fails drop out + if (!$success) { + Error::display('update'); + return false; + } + } + + } + + } // end foreach version - // Once we've run all of the updates let's re-sync the character set as the user - // can change this between updates and cause mis-matches on any new tables - Dba::reset_db_charset(); + // Once we've run all of the updates let's re-sync the character set as the user + // can change this between updates and cause mis-matches on any new tables + Dba::reset_db_charset(); - } // run_update + } // run_update - /** - * set_version - * This updates the 'update_info' which is used by the updater - * and plugins - */ - private static function set_version($key,$value) { + /** + * set_version + * This updates the 'update_info' which is used by the updater + * and plugins + */ + private static function set_version($key,$value) { - $sql = "UPDATE update_info SET value='$value' WHERE `key`='$key'"; - $db_results = Dba::write($sql); + $sql = "UPDATE update_info SET value='$value' WHERE `key`='$key'"; + $db_results = Dba::write($sql); - } //set_version + } //set_version - /** - * update_340001 - * This update moves back to the ID for user UID and - * adds date to the user_vote so that it can be sorted - * correctly - */ - private function update_340001() { + /** + * update_340001 + * This update moves back to the ID for user UID and + * adds date to the user_vote so that it can be sorted + * correctly + */ + private function update_340001() { - // Build the User -> ID map using the username as the key - $sql = "SELECT `id`,`username` FROM `user`"; - $db_results = Dba::read($sql); + // Build the User -> ID map using the username as the key + $sql = "SELECT `id`,`username` FROM `user`"; + $db_results = Dba::read($sql); - $user_array = array(); + $user_array = array(); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['username']; - $user_array[$username] = Dba::escape($r['id']); - } // end while + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['username']; + $user_array[$username] = Dba::escape($r['id']); + } // end while - // Alter the user table so that you can't have an ID beyond the - // range of the other tables which have to allow for -1 - $sql = "ALTER TABLE `user` CHANGE `id` `id` INT ( 11 ) NOT NULL AUTO_INCREMENT"; - $db_results = Dba::write($sql); + // Alter the user table so that you can't have an ID beyond the + // range of the other tables which have to allow for -1 + $sql = "ALTER TABLE `user` CHANGE `id` `id` INT ( 11 ) NOT NULL AUTO_INCREMENT"; + $db_results = Dba::write($sql); - // Now pull the access list users, alter table and then re-insert - $sql = "SELECT DISTINCT(`user`) FROM `access_list`"; - $db_results = Dba::read($sql); + // Now pull the access list users, alter table and then re-insert + $sql = "SELECT DISTINCT(`user`) FROM `access_list`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - // Build the new SQL - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + // Build the new SQL + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `access_list` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `access_list` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while access_list + } // end while access_list - // Alter the table - $sql = "ALTER TABLE `access_list` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `access_list` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now pull flagged users, update and alter - $sql = "SELECT DISTINCT(`user`) FROM `flagged`"; - $db_results = Dba::read($sql); + // Now pull flagged users, update and alter + $sql = "SELECT DISTINCT(`user`) FROM `flagged`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `flagged` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `flagged` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - // Alter the table - $sql = "ALTER TABLE `flagged` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `flagged` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now fix up the ip history - $sql = "SELECT DISTINCT(`user`) FROM `ip_history`"; - $db_results = Dba::read($sql); + // Now fix up the ip history + $sql = "SELECT DISTINCT(`user`) FROM `ip_history`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `ip_history` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `ip_history` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - // Alter the table - $sql = "ALTER TABLE `ip_history` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `ip_history` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now fix now playing - $sql = "SELECT DISTINCT(`user`) FROM `now_playing`"; - $db_results = Dba::read($sql); + // Now fix now playing + $sql = "SELECT DISTINCT(`user`) FROM `now_playing`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `now_playing` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `now_playing` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - // Alter the table - $sql = "ALTER TABLE `now_playing` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `now_playing` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now fix the playlist table - $sql = "SELECT DISTINCT(`user`) FROM `playlist`"; - $db_results = Dba::read($sql); + // Now fix the playlist table + $sql = "SELECT DISTINCT(`user`) FROM `playlist`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `playlist` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `playlist` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - // Alter the table - $sql = "ALTER TABLE `playlist` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `playlist` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Drop unused table - $sql = "DROP TABLE `playlist_permission`"; - $db_results = Dba::write($sql); + // Drop unused table + $sql = "DROP TABLE `playlist_permission`"; + $db_results = Dba::write($sql); - // Now fix the ratings table - $sql = "SELECT DISTINCT(`user`) FROM `ratings`"; - $db_results = Dba::read($sql); + // Now fix the ratings table + $sql = "SELECT DISTINCT(`user`) FROM `ratings`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `ratings` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `ratings` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - $sql = "ALTER TABLE `ratings` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `ratings` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now work on the tag_map - $sql = "ALTER TABLE `tag_map` CHANGE `user_id` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Now work on the tag_map + $sql = "ALTER TABLE `tag_map` CHANGE `user_id` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Now fix user preferences - $sql = "SELECT DISTINCT(`user`) FROM `user_preference`"; - $db_results = Dba::read($sql); + // Now fix user preferences + $sql = "SELECT DISTINCT(`user`) FROM `user_preference`"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $username = $r['user']; - $user_id = $user_array[$username]; - $username = Dba::escape($username); + while ($r = Dba::fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = Dba::escape($username); - $sql = "UPDATE `user_preference` SET `user`='$user_id' WHERE `user`='$username'"; - $update_results = Dba::write($sql); + $sql = "UPDATE `user_preference` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = Dba::write($sql); - } // end while + } // end while - // Alter the table - $sql = "ALTER TABLE `user_preference` CHANGE `user` `user` INT ( 11 ) NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `user_preference` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = Dba::write($sql); - // Add a date to the user_vote - $sql = "ALTER TABLE `user_vote` ADD `date` INT( 11 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); + // Add a date to the user_vote + $sql = "ALTER TABLE `user_vote` ADD `date` INT( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); - // Add the index for said field - $sql = "ALTER TABLE `user_vote` ADD INDEX(`date`)"; - $db_results = Dba::write($sql); + // Add the index for said field + $sql = "ALTER TABLE `user_vote` ADD INDEX(`date`)"; + $db_results = Dba::write($sql); - // Add the thumb fields to album - $sql = "ALTER TABLE `album` ADD `thumb` TINYBLOB NULL ,ADD `thumb_mime` VARCHAR( 128 ) NULL"; - $db_results = Dba::write($sql); + // Add the thumb fields to album + $sql = "ALTER TABLE `album` ADD `thumb` TINYBLOB NULL ,ADD `thumb_mime` VARCHAR( 128 ) NULL"; + $db_results = Dba::write($sql); - // Now add in the min_object_count preference and the random_method - $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES('min_object_count','1','Min Element Count','5','integer','interface')"; - $db_results = Dba::write($sql); + // Now add in the min_object_count preference and the random_method + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES('min_object_count','1','Min Element Count','5','integer','interface')"; + $db_results = Dba::write($sql); - $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES('random_method','default','Random Method','5','string','interface')"; - $db_results = Dba::write($sql); + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES('random_method','default','Random Method','5','string','interface')"; + $db_results = Dba::write($sql); - // Delete old preference - $sql = "DELETE FROM `preferences` WHERE `name`='min_album_size'"; - $db_results = Dba::write($sql); + // Delete old preference + $sql = "DELETE FROM `preferences` WHERE `name`='min_album_size'"; + $db_results = Dba::write($sql); - // Make Hash a non-required field and smaller - $sql = "ALTER TABLE `song` CHANGE `hash` `hash` VARCHAR ( 64 ) NULL"; - $db_results = Dba::write($sql); + // Make Hash a non-required field and smaller + $sql = "ALTER TABLE `song` CHANGE `hash` `hash` VARCHAR ( 64 ) NULL"; + $db_results = Dba::write($sql); - // Make user access an int, nothing else - $sql = "UPDATE `user` SET `access`='100' WHERE `access`='admin'"; - $db_results = Dba::write($sql); + // Make user access an int, nothing else + $sql = "UPDATE `user` SET `access`='100' WHERE `access`='admin'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `user` SET `access`='25' WHERE `access`='user'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `user` SET `access`='25' WHERE `access`='user'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `user` SET `access`='5' WHERE `access`='guest'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `user` SET `access`='5' WHERE `access`='guest'"; + $db_results = Dba::write($sql); - // Alter the table - $sql = "ALTER TABLE `user` CHANGE `access` `access` TINYINT ( 4 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); + // Alter the table + $sql = "ALTER TABLE `user` CHANGE `access` `access` TINYINT ( 4 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); - // Add in Label and Catalog # and language - $sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL"; - $db_results = Dba::write($sql); + // Add in Label and Catalog # and language + $sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL"; + $db_results = Dba::write($sql); - /* Fix every users preferences */ - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while results + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results - self::set_version('db_version','340001'); + self::set_version('db_version','340001'); - return true; + return true; - } //update_340001 + } //update_340001 - /** - * update_340002 - * This update tweaks the preferences a little more and make sure that the - * min_object_count has a rational value - */ - private function update_340002() { + /** + * update_340002 + * This update tweaks the preferences a little more and make sure that the + * min_object_count has a rational value + */ + private function update_340002() { - /* Add the offset_limit preference and remove it from the user table */ - $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('offset_limit','50','Offset Limit','5','integer','interface')"; - $db_results = Dba::write($sql); + /* Add the offset_limit preference and remove it from the user table */ + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('offset_limit','50','Offset Limit','5','integer','interface')"; + $db_results = Dba::write($sql); - self::set_version('db_version','340002'); + self::set_version('db_version','340002'); - return true; + return true; - } // update_340002 + } // update_340002 - /** - * update_340003 - * This update moves the album art out of the album table - * and puts it in an album_data table. It also makes some - * minor changes to the song table in an attempt to reduce - * the size of each row - */ - public static function update_340003() { + /** + * update_340003 + * This update moves the album art out of the album table + * and puts it in an album_data table. It also makes some + * minor changes to the song table in an attempt to reduce + * the size of each row + */ + public static function update_340003() { - $sql = "ALTER TABLE `song` CHANGE `mode` `mode` ENUM( 'abr', 'vbr', 'cbr' ) NULL DEFAULT 'cbr'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` CHANGE `mode` `mode` ENUM( 'abr', 'vbr', 'cbr' ) NULL DEFAULT 'cbr'"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` CHANGE `time` `time` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` CHANGE `time` `time` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` CHANGE `rate` `rate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` CHANGE `rate` `rate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` CHANGE `bitrate` `bitrate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` CHANGE `bitrate` `bitrate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` CHANGE `track` `track` SMALLINT( 5 ) UNSIGNED NULL DEFAULT NULL "; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` CHANGE `track` `track` SMALLINT( 5 ) UNSIGNED NULL DEFAULT NULL "; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `user` CHANGE `disabled` `disabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `user` CHANGE `disabled` `disabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `album_data` (" . - "`album_id` INT( 11 ) UNSIGNED NOT NULL , " . - "`art` MEDIUMBLOB NULL , " . - "`art_mime` VARCHAR( 64 ) NULL , " . - "`thumb` BLOB NULL , " . - "`thumb_mime` VARCHAR( 64 ) NULL , " . - "UNIQUE ( `album_id` )" . - ") ENGINE = MYISAM"; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `album_data` (" . + "`album_id` INT( 11 ) UNSIGNED NOT NULL , " . + "`art` MEDIUMBLOB NULL , " . + "`art_mime` VARCHAR( 64 ) NULL , " . + "`thumb` BLOB NULL , " . + "`thumb_mime` VARCHAR( 64 ) NULL , " . + "UNIQUE ( `album_id` )" . + ") ENGINE = MYISAM"; + $db_results = Dba::write($sql); - /* Foreach the Albums and move the data into the new album_data table */ - $sql = "SELECT * FROM album"; - $db_results = Dba::write($sql); + /* Foreach the Albums and move the data into the new album_data table */ + $sql = "SELECT * FROM album"; + $db_results = Dba::write($sql); - while ($data = Dba::fetch_assoc($db_results)) { - $id = $data['id']; - $art = Dba::escape($data['art']); - $art_mime = Dba::escape($data['art_mime']); - $thumb = Dba::escape($data['thumb']); - $thumb_mime = Dba::escape($data['thumb_mime']); - $sql = "INSERT INTO `album_data` (`album_id`,`art`,`art_mime`,`thumb`,`thumb_mime`)" . - " VALUES ('$id','$art','$art_mime','$thumb','$thumb_mime')"; - $insert_results = Dba::write($sql); - } // end while + while ($data = Dba::fetch_assoc($db_results)) { + $id = $data['id']; + $art = Dba::escape($data['art']); + $art_mime = Dba::escape($data['art_mime']); + $thumb = Dba::escape($data['thumb']); + $thumb_mime = Dba::escape($data['thumb_mime']); + $sql = "INSERT INTO `album_data` (`album_id`,`art`,`art_mime`,`thumb`,`thumb_mime`)" . + " VALUES ('$id','$art','$art_mime','$thumb','$thumb_mime')"; + $insert_results = Dba::write($sql); + } // end while - $sql = "RENAME TABLE `song_ext_data` TO `song_data`"; - $db_results = Dba::write($sql); + $sql = "RENAME TABLE `song_ext_data` TO `song_data`"; + $db_results = Dba::write($sql); - $sql = "RENAME TABLE `preferences` TO `preference`"; - $db_results = Dba::write($sql); + $sql = "RENAME TABLE `preferences` TO `preference`"; + $db_results = Dba::write($sql); - $sql = "RENAME TABLE `ratings` TO `rating`"; - $db_results = Dba::write($sql); + $sql = "RENAME TABLE `ratings` TO `rating`"; + $db_results = Dba::write($sql); - // Go ahead and drop the art/thumb stuff - $sql = "ALTER TABLE `album` DROP `art`, DROP `art_mime`, DROP `thumb`, DROP `thumb_mime`"; - $db_results = Dba::write($sql); + // Go ahead and drop the art/thumb stuff + $sql = "ALTER TABLE `album` DROP `art`, DROP `art_mime`, DROP `thumb`, DROP `thumb_mime`"; + $db_results = Dba::write($sql); - // We need to fix the user_vote table - $sql = "ALTER TABLE `user_vote` CHANGE `user` `user` INT( 11 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); + // We need to fix the user_vote table + $sql = "ALTER TABLE `user_vote` CHANGE `user` `user` INT( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); - // Remove offset limit from the user - $sql = "ALTER TABLE `user` DROP `offset_limit`"; - $db_results = Dba::write($sql); + // Remove offset limit from the user + $sql = "ALTER TABLE `user` DROP `offset_limit`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - /* Add the rate_limit preference */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')"; - $db_results = Dba::write($sql); + /* Add the rate_limit preference */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')"; + $db_results = Dba::write($sql); - /* Add the playlist_method preference and remove it from the user table */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')"; - $db_results = Dba::write($sql); + /* Add the playlist_method preference and remove it from the user table */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - self::set_version('db_version','340003'); - - return true; - - } // update_340003 - - /** - * update_340004 - * Update the session.id to varchar(64) to handle - * newer configs - */ - public static function update_340004() { + self::set_version('db_version','340003'); + + return true; + + } // update_340003 + + /** + * update_340004 + * Update the session.id to varchar(64) to handle + * newer configs + */ + public static function update_340004() { - /* Alter the session.id so that it's 64 */ - $sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL"; - $db_results = Dba::write($sql); + /* Alter the session.id so that it's 64 */ + $sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL"; + $db_results = Dba::write($sql); - /* Add Playlist Related Preferences */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('playlist_add','append','Add Behavior','5','string','playlist')"; - $db_results = Dba::write($sql); + /* Add Playlist Related Preferences */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('playlist_add','append','Add Behavior','5','string','playlist')"; + $db_results = Dba::write($sql); - // Switch the existing preferences over to this new catagory - $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='playlist_method' " . - " OR `name`='playlist_type'"; - $db_results = Dba::write($sql); + // Switch the existing preferences over to this new catagory + $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='playlist_method' " . + " OR `name`='playlist_type'"; + $db_results = Dba::write($sql); - // Change the default value for playlist_method - $sql = "UPDATE `preference` SET `value`='normal' WHERE `name`='playlist_method'"; - $db_results = Dba::write($sql); + // Change the default value for playlist_method + $sql = "UPDATE `preference` SET `value`='normal' WHERE `name`='playlist_method'"; + $db_results = Dba::write($sql); - // Add in the shoutbox - $sql = "CREATE TABLE `user_shout` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " . - "`user` INT( 11 ) NOT NULL , " . - "`text` TEXT NOT NULL , " . - "`date` INT( 11 ) UNSIGNED NOT NULL , " . - "`sticky` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0', " . - "`object_id` INT( 11 ) UNSIGNED NOT NULL , " . - "`object_type` VARCHAR( 32 ) NOT NULL " . - ") ENGINE = MYISAM"; - $db_results = Dba::write($sql); + // Add in the shoutbox + $sql = "CREATE TABLE `user_shout` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " . + "`user` INT( 11 ) NOT NULL , " . + "`text` TEXT NOT NULL , " . + "`date` INT( 11 ) UNSIGNED NOT NULL , " . + "`sticky` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0', " . + "`object_id` INT( 11 ) UNSIGNED NOT NULL , " . + "`object_type` VARCHAR( 32 ) NOT NULL " . + ") ENGINE = MYISAM"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `user_shout` ADD INDEX ( `sticky` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `user_shout` ADD INDEX ( `sticky` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `user_shout` ADD INDEX ( `date` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `user_shout` ADD INDEX ( `date` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `user_shout` ADD INDEX ( `user` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `user_shout` ADD INDEX ( `user` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `now_playing` CHANGE `start_time` `expire` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `now_playing` CHANGE `start_time` `expire` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "OPTIMIZE TABLE `album`"; - $db_results = Dba::write($sql); + $sql = "OPTIMIZE TABLE `album`"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - // Update our database version now that we are all done - self::set_version('db_version','340004'); + // Update our database version now that we are all done + self::set_version('db_version','340004'); - return true; + return true; - } // update_340004 + } // update_340004 - /** - * update_340005 - * This update fixes the preferences types - */ - public static function update_340005() { + /** + * update_340005 + * This update fixes the preferences types + */ + public static function update_340005() { - // Turn user_rating into a tinyint and call it score - $sql = "ALTER TABLE `rating` CHANGE `user_rating` `score` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'"; - $db_results = Dba::write($sql); + // Turn user_rating into a tinyint and call it score + $sql = "ALTER TABLE `rating` CHANGE `user_rating` `score` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='random_method'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='random_method'"; + $db_results = Dba::write($sql); - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('transcode','default','Transcoding','25','string','streaming')"; - $db_results = Dba::write($sql); + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('transcode','default','Transcoding','25','string','streaming')"; + $db_results = Dba::write($sql); - /* We need to check for playlist_method here because I fubar'd an earlier update */ - $sql = "SELECT * FROM `preference` WHERE `name`='playlist_method'"; - $db_results = Dba::read($sql); - if (!Dba::num_rows($db_results)) { - /* Add the playlist_method preference and remove it from the user table */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('playlist_method','default','Playlist Method','5','string','playlist')"; - $db_results = Dba::write($sql); - } + /* We need to check for playlist_method here because I fubar'd an earlier update */ + $sql = "SELECT * FROM `preference` WHERE `name`='playlist_method'"; + $db_results = Dba::read($sql); + if (!Dba::num_rows($db_results)) { + /* Add the playlist_method preference and remove it from the user table */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('playlist_method','default','Playlist Method','5','string','playlist')"; + $db_results = Dba::write($sql); + } - // Add in the object_type to the tmpplaylist data table so that we can have non-songs in there - $sql = "ALTER TABLE `tmp_playlist_data` ADD `object_type` VARCHAR( 32 ) NULL AFTER `tmp_playlist`"; - $db_results = Dba::write($sql); + // Add in the object_type to the tmpplaylist data table so that we can have non-songs in there + $sql = "ALTER TABLE `tmp_playlist_data` ADD `object_type` VARCHAR( 32 ) NULL AFTER `tmp_playlist`"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - self::set_version('db_version','340005'); + self::set_version('db_version','340005'); - return true; + return true; - } // update_340005 + } // update_340005 - /** - * update_340006 - * This just updates the size of the album_data table - * and removes the random_method config option - */ - public static function update_340006() { + /** + * update_340006 + * This just updates the size of the album_data table + * and removes the random_method config option + */ + public static function update_340006() { - $sql = "DESCRIBE `album_data`"; - $db_results = Dba::read($sql); + $sql = "DESCRIBE `album_data`"; + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - if ($row['Field'] == 'art' AND $row['Type'] == 'blob') { - $blob_needed = true; - } - } // end while - if ($blob_needed) { - $sql = "ALTER TABLE `album_data` CHANGE `art` `art` MEDIUMBLOB NULL DEFAULT NULL"; - $db_results = Dba::write($sql); - } + while ($row = Dba::fetch_assoc($db_results)) { + if ($row['Field'] == 'art' AND $row['Type'] == 'blob') { + $blob_needed = true; + } + } // end while + if ($blob_needed) { + $sql = "ALTER TABLE `album_data` CHANGE `art` `art` MEDIUMBLOB NULL DEFAULT NULL"; + $db_results = Dba::write($sql); + } - // No matter what remove that random method preference - $sql = "DELETE FROM `preference` WHERE `name`='random_method'"; - $db_results = Dba::write($sql); + // No matter what remove that random method preference + $sql = "DELETE FROM `preference` WHERE `name`='random_method'"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - self::set_version('db_version','340006'); + self::set_version('db_version','340006'); - return true; + return true; - } // update_340006 + } // update_340006 - /** - * update_340007 - * This update converts the session.value to a longtext - * and adds a session_stream table - */ - public static function update_340007() { + /** + * update_340007 + * This update converts the session.value to a longtext + * and adds a session_stream table + */ + public static function update_340007() { - // Tweak the session table to handle larger session vars for my page-a-nation hotness - $sql = "ALTER TABLE `session` CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; - $db_results = Dba::write($sql); + // Tweak the session table to handle larger session vars for my page-a-nation hotness + $sql = "ALTER TABLE `session` CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; + $db_results = Dba::write($sql); - // Create the new stream table where we will store stream SIDs - $sql = "CREATE TABLE `session_stream` ( " . - "`id` VARCHAR( 64 ) NOT NULL , " . - "`user` INT( 11 ) UNSIGNED NOT NULL , " . - "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . - "`expire` INT( 11 ) UNSIGNED NOT NULL , " . - "`ip` INT( 11 ) UNSIGNED NULL , " . - "PRIMARY KEY ( `id` ) " . - ") ENGINE = MYISAM"; - $db_results = Dba::write($sql); + // Create the new stream table where we will store stream SIDs + $sql = "CREATE TABLE `session_stream` ( " . + "`id` VARCHAR( 64 ) NOT NULL , " . + "`user` INT( 11 ) UNSIGNED NOT NULL , " . + "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . + "`expire` INT( 11 ) UNSIGNED NOT NULL , " . + "`ip` INT( 11 ) UNSIGNED NULL , " . + "PRIMARY KEY ( `id` ) " . + ") ENGINE = MYISAM"; + $db_results = Dba::write($sql); - // Change the now playing to use stream session ids for its ID - $sql = "ALTER TABLE `now_playing` CHANGE `id` `id` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; - $db_results = Dba::write($sql); + // Change the now playing to use stream session ids for its ID + $sql = "ALTER TABLE `now_playing` CHANGE `id` `id` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; + $db_results = Dba::write($sql); - // Now longer needed because of the new hotness - $sql = "ALTER TABLE `now_playing` DROP `session`"; - $db_results = Dba::write($sql); + // Now longer needed because of the new hotness + $sql = "ALTER TABLE `now_playing` DROP `session`"; + $db_results = Dba::write($sql); - self::set_version('db_version','340007'); + self::set_version('db_version','340007'); - return true; + return true; - } // update_340007 + } // update_340007 - /** - * update_340008 - * This modifies the playlist table to handle the different types of objects that it needs to be able to - * store, and tweaks how dynamic playlist stuff works - */ - public static function update_340008() { + /** + * update_340008 + * This modifies the playlist table to handle the different types of objects that it needs to be able to + * store, and tweaks how dynamic playlist stuff works + */ + public static function update_340008() { - $sql = "ALTER TABLE `playlist_data` CHANGE `song` `object_id` INT( 11 ) UNSIGNED NULL DEFAULT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist_data` CHANGE `song` `object_id` INT( 11 ) UNSIGNED NULL DEFAULT NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `playlist_data` CHANGE `dyn_song` `dynamic_song` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist_data` CHANGE `dyn_song` `dynamic_song` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `playlist_data` ADD `object_type` VARCHAR( 32 ) NOT NULL DEFAULT 'song' AFTER `object_id`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist_data` ADD `object_type` VARCHAR( 32 ) NOT NULL DEFAULT 'song' AFTER `object_id`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `playlist` ADD `genre` INT( 11 ) UNSIGNED NOT NULL AFTER `type`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist` ADD `genre` INT( 11 ) UNSIGNED NOT NULL AFTER `type`"; + $db_results = Dba::write($sql); - $sql = "DELETE FROM `preference` WHERE `name`='allow_downsample_playback'"; - $db_results = Dba::write($sql); + $sql = "DELETE FROM `preference` WHERE `name`='allow_downsample_playback'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `description`='Transcode Bitrate' WHERE `name`='sample_rate'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `description`='Transcode Bitrate' WHERE `name`='sample_rate'"; + $db_results = Dba::write($sql); - // Check for old tables and drop if found, seems like there was a glitch that caused them - // not to get droped.. *shrug* - $sql = "DROP TABLE IF EXISTS `preferences`"; - $db_results = Dba::write($sql); + // Check for old tables and drop if found, seems like there was a glitch that caused them + // not to get droped.. *shrug* + $sql = "DROP TABLE IF EXISTS `preferences`"; + $db_results = Dba::write($sql); - $sql = "DROP TABLE IF EXISTS `song_ext_data`"; - $db_results = Dba::write($sql); + $sql = "DROP TABLE IF EXISTS `song_ext_data`"; + $db_results = Dba::write($sql); - $sql = "DROP TABLE IF EXISTS `ratings`"; - $db_results = Dba::write($sql); + $sql = "DROP TABLE IF EXISTS `ratings`"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - self::set_version('db_version','340008'); + self::set_version('db_version','340008'); - return true; + return true; - } // update_340008 + } // update_340008 - /** - * update_340009 - * This modifies the song table to handle pos fields - */ - public static function update_340009() { + /** + * update_340009 + * This modifies the song table to handle pos fields + */ + public static function update_340009() { - $sql = "ALTER TABLE `album` ADD `disk` smallint(5) UNSIGNED DEFAULT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `album` ADD `disk` smallint(5) UNSIGNED DEFAULT NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `album` ADD INDEX (`disk`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `album` ADD INDEX (`disk`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `access_list` ADD `dns` VARCHAR( 255 ) NOT NULL AFTER `end`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `access_list` ADD `dns` VARCHAR( 255 ) NOT NULL AFTER `end`"; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `artist_data` (" . - "`artist_id` INT( 11 ) UNSIGNED NOT NULL ," . - "`art` MEDIUMBLOB NOT NULL ," . - "`art_mime` VARCHAR( 32 ) NOT NULL ," . - "`thumb` BLOB NOT NULL ," . - "`thumb_mime` VARCHAR( 32 ) NOT NULL ," . - "`bio` TEXT NOT NULL , " . - "UNIQUE (`artist_id`) ) ENGINE = MYISAM"; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `artist_data` (" . + "`artist_id` INT( 11 ) UNSIGNED NOT NULL ," . + "`art` MEDIUMBLOB NOT NULL ," . + "`art_mime` VARCHAR( 32 ) NOT NULL ," . + "`thumb` BLOB NOT NULL ," . + "`thumb_mime` VARCHAR( 32 ) NOT NULL ," . + "`bio` TEXT NOT NULL , " . + "UNIQUE (`artist_id`) ) ENGINE = MYISAM"; + $db_results = Dba::write($sql); - self::set_version('db_version','340009'); + self::set_version('db_version','340009'); - return true; + return true; - } // update_340009 + } // update_340009 - /** - * update_340010 - * Bunch of minor tweaks to the preference table - */ - public static function update_340010() { + /** + * update_340010 + * Bunch of minor tweaks to the preference table + */ + public static function update_340010() { - $sql = "UPDATE `preference` SET `catagory`='options' WHERE `name` LIKE 'localplay_%'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `catagory`='options' WHERE `name` LIKE 'localplay_%'"; + $db_results = Dba::write($sql); - $sql = "DELETE FROM `preference` WHERE `name`='playlist_add'"; - $db_results = Dba::write($sql); + $sql = "DELETE FROM `preference` WHERE `name`='playlist_add'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `catagory`='plugins' WHERE (`name` LIKE 'mystrands_%' OR `name` LIKE 'lastfm_%') AND `catagory`='options'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `catagory`='plugins' WHERE (`name` LIKE 'mystrands_%' OR `name` LIKE 'lastfm_%') AND `catagory`='options'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `value`='default' WHERE `name`='playlist_method'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `value`='default' WHERE `name`='playlist_method'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'"; + $db_results = Dba::write($sql); - /* Fix every users preferences */ - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while results + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results - self::set_version('db_version','340010'); + self::set_version('db_version','340010'); - return true; + return true; - } // update_340010 + } // update_340010 - /** - * update_340011 - * This updates the democratic play stuff so that can handle a little more complext mojo - * It also adds yet another table to the db to handle the sessions for API access. Eventually - * should combine all of the session tables, but I'll do that later - */ - public static function update_340011() { + /** + * update_340011 + * This updates the democratic play stuff so that can handle a little more complext mojo + * It also adds yet another table to the db to handle the sessions for API access. Eventually + * should combine all of the session tables, but I'll do that later + */ + public static function update_340011() { - // First add the new table for the new session stuff - $sql = "CREATE TABLE `session_api` ( " . - "`id` VARCHAR( 64 ) NOT NULL , " . - "`user` INT( 11 ) UNSIGNED NOT NULL , " . - "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . - "`level` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0', " . - "`expire` INT( 11 ) UNSIGNED NOT NULL , " . - "`ip` INT( 11 ) UNSIGNED NULL , " . - "PRIMARY KEY ( `id` ) " . - ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; - $db_results = Dba::write($sql); + // First add the new table for the new session stuff + $sql = "CREATE TABLE `session_api` ( " . + "`id` VARCHAR( 64 ) NOT NULL , " . + "`user` INT( 11 ) UNSIGNED NOT NULL , " . + "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . + "`level` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0', " . + "`expire` INT( 11 ) UNSIGNED NOT NULL , " . + "`ip` INT( 11 ) UNSIGNED NULL , " . + "PRIMARY KEY ( `id` ) " . + ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; + $db_results = Dba::write($sql); - self::set_version('db_version','340011'); + self::set_version('db_version','340011'); - return true; + return true; - } // 340011 + } // 340011 - /** - * update_340012 - * This update adds in the democratic stuff, checks for some potentially screwed up indexes - * and removes the timestamp from the playlist, and adds the field to the catalog for the upload dir - */ - public static function update_340012() { + /** + * update_340012 + * This update adds in the democratic stuff, checks for some potentially screwed up indexes + * and removes the timestamp from the playlist, and adds the field to the catalog for the upload dir + */ + public static function update_340012() { - $sql = "ALTER TABLE `catalog` ADD `add_path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `path`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `catalog` ADD `add_path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `path`"; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `democratic` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . - "`name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ," . - "`cooldown` TINYINT( 4 ) UNSIGNED NULL ," . - "`level` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '25'," . - "`user` INT( 11 ) NOT NULL ," . - "`primary` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'" . - ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `democratic` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . + "`name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ," . + "`cooldown` TINYINT( 4 ) UNSIGNED NULL ," . + "`level` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '25'," . + "`user` INT( 11 ) NOT NULL ," . + "`primary` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'" . + ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `democratic` ADD INDEX (`primary`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `democratic` ADD INDEX (`primary`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `democratic` ADD INDEX (`level`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `democratic` ADD INDEX (`level`)"; + $db_results = Dba::write($sql); - self::set_version('db_version','340012'); + self::set_version('db_version','340012'); - return true; + return true; - } // update_340012 + } // update_340012 - /** - * update_340013 - * This update removes a whole bunch of preferences that are no longer - * being used in any way, and changes the ACL XML-RPC to just RPC - */ - public static function update_340013() { + /** + * update_340013 + * This update removes a whole bunch of preferences that are no longer + * being used in any way, and changes the ACL XML-RPC to just RPC + */ + public static function update_340013() { - $sql = "DELETE FROM `preference` WHERE `name`='localplay_mpd_hostname' OR `name`='localplay_mpd_port' " . - "OR `name`='direct_link' OR `name`='localplay_mpd_password' OR `name`='catalog_echo_count'"; - $db_results = Dba::write($sql); + $sql = "DELETE FROM `preference` WHERE `name`='localplay_mpd_hostname' OR `name`='localplay_mpd_port' " . + "OR `name`='direct_link' OR `name`='localplay_mpd_password' OR `name`='catalog_echo_count'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `preference` SET `description`='Localplay Access' WHERE `name`='localplay_level'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `preference` SET `description`='Localplay Access' WHERE `name`='localplay_level'"; + $db_results = Dba::write($sql); - $sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff - self::set_version('db_version','340013'); + self::set_version('db_version','340013'); - return true; + return true; - } // update_340013 + } // update_340013 - /** - * update_340014 - * This update drops the session_api table that I added just two updates ago - * it's been nice while it lasted but it's time to pack your stuff and GTFO - * at the same time it updates the core session table to handle the additional - * stuff we're going to ask it to do. - */ - public static function update_340014() { + /** + * update_340014 + * This update drops the session_api table that I added just two updates ago + * it's been nice while it lasted but it's time to pack your stuff and GTFO + * at the same time it updates the core session table to handle the additional + * stuff we're going to ask it to do. + */ + public static function update_340014() { - $sql = "DROP TABLE `session_api`"; - $db_results = Dba::write($sql); + $sql = "DROP TABLE `session_api`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `session` CHANGE `type` `type` ENUM ('mysql','ldap','http','api','xml-rpc') NOT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `session` CHANGE `type` `type` ENUM ('mysql','ldap','http','api','xml-rpc') NOT NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `session` ADD `agent` VARCHAR ( 255 ) NOT NULL AFTER `type`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `session` ADD `agent` VARCHAR ( 255 ) NOT NULL AFTER `type`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `session` ADD INDEX (`type`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `session` ADD INDEX (`type`)"; + $db_results = Dba::write($sql); - self::set_version('db_version','340014'); + self::set_version('db_version','340014'); - return true; + return true; - } // update_340014 + } // update_340014 - /** - * update_340015 - * This update tweaks the playlist table responding to complaints from usres - * who say it doesn't work, unreproduceable. This also adds an index to the - * album art table to try to make the random album art faster - */ - public static function update_340015() { + /** + * update_340015 + * This update tweaks the playlist table responding to complaints from usres + * who say it doesn't work, unreproduceable. This also adds an index to the + * album art table to try to make the random album art faster + */ + public static function update_340015() { - $sql = "ALTER TABLE `playlist` DROP `date`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist` DROP `date`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `playlist` ADD `date` INT ( 11 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist` ADD `date` INT ( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); - // Pull all of the rating information - $sql = "SELECT `id`,`rating` FROM `rating`"; - $db_results = Dba::read($sql); + // Pull all of the rating information + $sql = "SELECT `id`,`rating` FROM `rating`"; + $db_results = Dba::read($sql); - $results = array(); + $results = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $results[] = $row; - } + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row; + } - $sql = "ALTER TABLE `rating` DROP `rating`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `rating` DROP `rating`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `rating` ADD `rating` TINYINT ( 4 ) NOT NULL"; - $db_results = Dba::write($sql); - - foreach ($results as $row) { - $rating = Dba::escape($row['rating']); - $id = Dba::escape($row['id']); - $sql = "UPDATE `rating` SET `rating`='$rating' WHERE `id`='$id'"; - $db_results = Dba::write($sql); - } - - self::set_version('db_version','340015'); - - return true; - - } // update_340015 - - /** - * update_340016 - * This adds in the base_playlist to the democratic table... should have - * done this in the previous one but I screwed up... sigh - */ - public static function update_340016() { - - $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT ( 11 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); - - self::set_version('db_version','340016'); - - return true; - - } // update_340016 - - /** - * update_340017 - * This finalizes the democratic table. - * and fixes the charset crap - */ - public static function update_340017() { - - $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT( 11 ) UNSIGNED NOT NULL AFTER `name`"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `tmp_playlist` DROP `base_playlist`"; - $db_results = Dba::write($sql); - - $sql = "DELETE FROM `tmp_playlist` WHERE `session`='-1'"; - $db_results = Dba::write($sql); - - $sql = "TRUNCATE `democratic`"; - $db_results = Dba::write($sql); - - self::set_version('db_version','340017'); - - return true; - - } // update_340017 - - /** - * update_340018 - * This attempts to correct the charset on your database, it does some checking - * to make sure that if we do this it will actually will work. We will fail this update - * if it would cause problems - */ - public static function update_340018() { - - // MySQL translate real charset names into fancy smancy MySQL land names - switch (strtoupper(Config::get('site_charset'))) { - case 'CP1250': - case 'WINDOWS-1250': - case 'WINDOWS-1252': - $target_charset = 'cp1250'; - $target_collation = 'cp1250_general_ci'; - break; - case 'ISO-8859': - case 'ISO-8859-2': - $target_charset = 'latin2'; - $target_collation = 'latin2_general_ci'; - break; - case 'ISO-8859-1': - $target_charset = 'latin1'; - $target_charset = 'latin1_general_ci'; - break; - case 'EUC-KR': - $target_charset = 'euckr'; - $target_collation = 'euckr_korean_ci'; - break; - case 'CP932': - $target_charset = 'sjis'; - $target_collation = 'sjis_japanese_ci'; - break; - case 'KOI8-U': - $target_charset = 'koi8u'; - $target_collation = 'koi8u_general_ci'; - break; - case 'KOI8-R': - $target_charset = 'koi8r'; - $target_collation = 'koi8r_general_ci'; - break; - case 'ISO-8859': - $target_charset = 'latin2'; - $target_collation = 'latin2_general_ci'; - break; - default; - case 'UTF-8': - $target_charset = 'utf8'; - $target_collation = 'utf8_unicode_ci'; - break; - } // end mysql charset translation - - // Alter the charset for the entire database - $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; - $db_results = Dba::write($sql); - - $sql = "SHOW TABLES"; - $db_results = Dba::read($sql); - - // Go through the tables! - while ($row = Dba::fetch_row($db_results)) { - $sql = "DESCRIBE `" . $row['0'] . "`"; - $describe_results = Dba::read($sql); - - // Change the tables default charset and colliation - $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; - $alter_table = Dba::write($sql); - - // Itterate through the columns of the table - while ($table = Dba::fetch_assoc($describe_results)) { - if ( - (strpos($table['Type'], 'varchar') !== false) || - (strpos($table['Type'], 'enum') !== false) || - strpos($table['Table'],'text') !== false) { - $sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset; - $charset_results = Dba::write($sql); - if (!$charset_results) { - debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3'); - } // if it fails - } // if its a varchar - } // end columns - - } // end tables - - self::set_version('db_version','340018'); - - return true; - - } // update_340018 - - /** - * update_350001 - * This updates modifies the tag tables per codeunde1load's specs from his tag patch - * it also adjusts the prefix fields so that we can use more prefixes - */ - public static function update_350001() { - - $sql = "ALTER TABLE `tag_map` ADD `tag_id` INT ( 11 ) UNSIGNED NOT NULL AFTER `id`"; - $db_results = Dba::write($sql); - - $sql = "RENAME TABLE `tags` TO `tag`"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `tag` CHANGE `map_id` `id` INT ( 11 ) UNSIGNED NOT NULL auto_increment"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `album` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `artist` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; - $db_results = Dba::write($sql); - - self::set_version('db_version','350001'); - - return true; - - } // update_350001 - - /** - * update_350002 - * This update adds in the browse_cache table that we use to hold peoples cached browse results - * rather then try to store everything in the session we split them out into one serilized array per - * row, per person. A little slow this way when browsing, but faster when now browsing and more flexible - */ - public static function update_350002() { - - $sql = "CREATE TABLE `tmp_browse` (`sid` varchar(128) NOT NULL,`data` longtext NOT NULL," . - " UNIQUE KEY `sid` (`sid`)) ENGINE=MyISAM"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `tmp_browse` ADD INDEX ( `type` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `rating` ADD `rating` TINYINT ( 4 ) NOT NULL"; + $db_results = Dba::write($sql); + + foreach ($results as $row) { + $rating = Dba::escape($row['rating']); + $id = Dba::escape($row['id']); + $sql = "UPDATE `rating` SET `rating`='$rating' WHERE `id`='$id'"; + $db_results = Dba::write($sql); + } + + self::set_version('db_version','340015'); + + return true; + + } // update_340015 + + /** + * update_340016 + * This adds in the base_playlist to the democratic table... should have + * done this in the previous one but I screwed up... sigh + */ + public static function update_340016() { + + $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT ( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); + + self::set_version('db_version','340016'); + + return true; + + } // update_340016 + + /** + * update_340017 + * This finalizes the democratic table. + * and fixes the charset crap + */ + public static function update_340017() { + + $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT( 11 ) UNSIGNED NOT NULL AFTER `name`"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `tmp_playlist` DROP `base_playlist`"; + $db_results = Dba::write($sql); + + $sql = "DELETE FROM `tmp_playlist` WHERE `session`='-1'"; + $db_results = Dba::write($sql); + + $sql = "TRUNCATE `democratic`"; + $db_results = Dba::write($sql); + + self::set_version('db_version','340017'); + + return true; + + } // update_340017 + + /** + * update_340018 + * This attempts to correct the charset on your database, it does some checking + * to make sure that if we do this it will actually will work. We will fail this update + * if it would cause problems + */ + public static function update_340018() { + + // MySQL translate real charset names into fancy smancy MySQL land names + switch (strtoupper(Config::get('site_charset'))) { + case 'CP1250': + case 'WINDOWS-1250': + case 'WINDOWS-1252': + $target_charset = 'cp1250'; + $target_collation = 'cp1250_general_ci'; + break; + case 'ISO-8859': + case 'ISO-8859-2': + $target_charset = 'latin2'; + $target_collation = 'latin2_general_ci'; + break; + case 'ISO-8859-1': + $target_charset = 'latin1'; + $target_charset = 'latin1_general_ci'; + break; + case 'EUC-KR': + $target_charset = 'euckr'; + $target_collation = 'euckr_korean_ci'; + break; + case 'CP932': + $target_charset = 'sjis'; + $target_collation = 'sjis_japanese_ci'; + break; + case 'KOI8-U': + $target_charset = 'koi8u'; + $target_collation = 'koi8u_general_ci'; + break; + case 'KOI8-R': + $target_charset = 'koi8r'; + $target_collation = 'koi8r_general_ci'; + break; + case 'ISO-8859': + $target_charset = 'latin2'; + $target_collation = 'latin2_general_ci'; + break; + default; + case 'UTF-8': + $target_charset = 'utf8'; + $target_collation = 'utf8_unicode_ci'; + break; + } // end mysql charset translation + + // Alter the charset for the entire database + $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $db_results = Dba::write($sql); + + $sql = "SHOW TABLES"; + $db_results = Dba::read($sql); + + // Go through the tables! + while ($row = Dba::fetch_row($db_results)) { + $sql = "DESCRIBE `" . $row['0'] . "`"; + $describe_results = Dba::read($sql); + + // Change the tables default charset and colliation + $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $alter_table = Dba::write($sql); + + // Itterate through the columns of the table + while ($table = Dba::fetch_assoc($describe_results)) { + if ( + (strpos($table['Type'], 'varchar') !== false) || + (strpos($table['Type'], 'enum') !== false) || + strpos($table['Table'],'text') !== false) { + $sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset; + $charset_results = Dba::write($sql); + if (!$charset_results) { + debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3'); + } // if it fails + } // if its a varchar + } // end columns + + } // end tables + + self::set_version('db_version','340018'); + + return true; + + } // update_340018 + + /** + * update_350001 + * This updates modifies the tag tables per codeunde1load's specs from his tag patch + * it also adjusts the prefix fields so that we can use more prefixes + */ + public static function update_350001() { + + $sql = "ALTER TABLE `tag_map` ADD `tag_id` INT ( 11 ) UNSIGNED NOT NULL AFTER `id`"; + $db_results = Dba::write($sql); + + $sql = "RENAME TABLE `tags` TO `tag`"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `tag` CHANGE `map_id` `id` INT ( 11 ) UNSIGNED NOT NULL auto_increment"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `album` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `artist` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; + $db_results = Dba::write($sql); + + self::set_version('db_version','350001'); + + return true; + + } // update_350001 + + /** + * update_350002 + * This update adds in the browse_cache table that we use to hold peoples cached browse results + * rather then try to store everything in the session we split them out into one serilized array per + * row, per person. A little slow this way when browsing, but faster when now browsing and more flexible + */ + public static function update_350002() { + + $sql = "CREATE TABLE `tmp_browse` (`sid` varchar(128) NOT NULL,`data` longtext NOT NULL," . + " UNIQUE KEY `sid` (`sid`)) ENGINE=MyISAM"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `tmp_browse` ADD INDEX ( `type` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` DROP `genre`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` DROP `genre`"; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `user_catalog` (`user` INT( 11 ) UNSIGNED NOT NULL ,`catalog` INT( 11 ) UNSIGNED NOT NULL ,`level` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '5', " . - "INDEX ( `user` )) ENGINE = MYISAM"; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `user_catalog` (`user` INT( 11 ) UNSIGNED NOT NULL ,`catalog` INT( 11 ) UNSIGNED NOT NULL ,`level` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '5', " . + "INDEX ( `user` )) ENGINE = MYISAM"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `user_catalog` ADD INDEX ( `catalog` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `user_catalog` ADD INDEX ( `catalog` )"; + $db_results = Dba::write($sql); - self::set_version('db_version','350002'); + self::set_version('db_version','350002'); - return true; + return true; - } // update_350002 + } // update_350002 - /** - * update_350003 - * This update tweakes the tag tables a little bit more, we're going to simplify things for the first little bit and then - * then if it all works out we will worry about making it complex again. One thing at a time people... - */ - public static function update_350003() { + /** + * update_350003 + * This update tweakes the tag tables a little bit more, we're going to simplify things for the first little bit and then + * then if it all works out we will worry about making it complex again. One thing at a time people... + */ + public static function update_350003() { - $sql = "ALTER TABLE `tag` DROP `order`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tag` DROP `order`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `tag` DROP INDEX `order`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tag` DROP INDEX `order`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `tag` ADD UNIQUE ( `name` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tag` ADD UNIQUE ( `name` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `tag` CHANGE `name` `name` VARCHAR( 255 )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tag` CHANGE `name` `name` VARCHAR( 255 )"; + $db_results = Dba::write($sql); - // Make sure that they don't have any of the mystrands crap left - $sql = "DELETE FROM `preference` WHERE `name`='mystrands_user' OR `name`='mystrands_pass'"; - $db_results = Dba::write($sql); + // Make sure that they don't have any of the mystrands crap left + $sql = "DELETE FROM `preference` WHERE `name`='mystrands_user' OR `name`='mystrands_pass'"; + $db_results = Dba::write($sql); - self::set_version('db_version','350003'); + self::set_version('db_version','350003'); - return true; + return true; - } // update_350003 + } // update_350003 - /** - * update_350004 - * This update makes some changes to the ACL table so that it can support IPv6 entries as well as some other feature - * enhancements - */ - public static function update_350004() { + /** + * update_350004 + * This update makes some changes to the ACL table so that it can support IPv6 entries as well as some other feature + * enhancements + */ + public static function update_350004() { - $sql = "ALTER TABLE `session` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `session` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `session_stream` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `session_stream` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; + $db_results = Dba::write($sql); - // Pull all of the IP history, this could take a while - $sql = "SELECT * FROM `ip_history`"; - $db_results = Dba::read($sql); + // Pull all of the IP history, this could take a while + $sql = "SELECT * FROM `ip_history`"; + $db_results = Dba::read($sql); - $ip_history = array(); + $ip_history = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $row['ip'] = long2ip($row['ip']); - $ip_history[] = $row; - } - - // Clear the table before we make the changes - $sql = "TRUNCATE `ip_history`"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `ip_history` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `ip_history` ADD `agent` VARCHAR ( 255 ) NULL AFTER `date`"; - $db_results = Dba::write($sql); - - // Reinsert the old rows - foreach ($ip_history as $row) { - $ip = Dba::escape(inet_pton($row['ip'])); - $sql = "INSERT INTO `ip_history` (`user`,`ip`,`date`,`agent`) " . - "VALUES ('" . $row['user'] . "','" . $ip . "','" . $row['date'] . "',NULL)"; - $db_results = Dba::write($sql); - } - - // First pull all of their current ACL's - $sql = "SELECT * FROM `access_list`"; - $db_results = Dba::read($sql); - - $acl_information = array(); + while ($row = Dba::fetch_assoc($db_results)) { + $row['ip'] = long2ip($row['ip']); + $ip_history[] = $row; + } + + // Clear the table before we make the changes + $sql = "TRUNCATE `ip_history`"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `ip_history` CHANGE `ip` `ip` VARBINARY( 255 ) NULL"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `ip_history` ADD `agent` VARCHAR ( 255 ) NULL AFTER `date`"; + $db_results = Dba::write($sql); + + // Reinsert the old rows + foreach ($ip_history as $row) { + $ip = Dba::escape(inet_pton($row['ip'])); + $sql = "INSERT INTO `ip_history` (`user`,`ip`,`date`,`agent`) " . + "VALUES ('" . $row['user'] . "','" . $ip . "','" . $row['date'] . "',NULL)"; + $db_results = Dba::write($sql); + } + + // First pull all of their current ACL's + $sql = "SELECT * FROM `access_list`"; + $db_results = Dba::read($sql); + + $acl_information = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $row['start'] = long2ip($row['start']); - $row['end'] = long2ip($row['end']); - $acl_information[] = $row; - } - - $sql = "TRUNCATE `access_list`"; - $db_results = Dba::write($sql); - - // Make the changes to the database - $sql = "ALTER TABLE `access_list` CHANGE `start` `start` VARBINARY( 255 ) NOT NULL"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `access_list` CHANGE `end` `end` VARBINARY( 255 ) NOT NULL"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `access_list` DROP `dns`"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `access_list` ADD `enabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `key`"; - $db_results = Dba::write($sql); - - // If we had nothing in there before add some base ALLOW ALL stuff as we're going - // to start defaulting Access Control to On. - if (!count($acl_information)) { - $v6_start = Dba::escape(inet_pton('::')); - $v6_end = Dba::escape(inet_pton('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')); - $v4_start = Dba::escape(inet_pton('0.0.0.0')); - $v4_end = Dba::escape(inet_pton('255.255.255.255')); - $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . - "VALUES ('DEFAULTv4','75','$v4_start','$v4_end',NULL,'-1','interface','1')"; - $db_results = Dba::write($sql); - $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . - "VALUES ('DEFAULTv4','75','$v4_start','$v4_end',NULL,'-1','stream','1')"; - $db_results = Dba::write($sql); - $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . - "VALUES ('DEFAULTv6','75','$v6_start','$v6_end',NULL,'-1','interface','1')"; - $db_results = Dba::write($sql); - $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . - "VALUES ('DEFAULTv6','75','$v6_start','$v6_end',NULL,'-1','stream','1')"; - $db_results = Dba::write($sql); - } // Adding default information - - foreach ($acl_information as $row) { - $row['start'] = Dba::escape(inet_pton($row['start'])); - $row['end'] = Dba::escape(inet_pton($row['end'])); - $row['key'] = Dba::escape($row['key']); - $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . - "VALUES ('" . Dba::escape($row['name']) . "','" . intval($row['level']) . - "','" . $row['start'] . "','" . $row['end'] . "','" . $row['key'] . "','" . intval($row['user']) . "','" . - $row['type'] . "','1')"; - $db_results = Dba::write($sql); - } // end foreach of existing rows - - self::set_version('db_version','350004'); - - return true; - - } // update_350004 - - /** - * update_350005 - * This update adds the video table... *gasp* no you didn't - */ - public static function update_350005() { - - $sql = " CREATE TABLE `video` (" . - "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . - "`file` VARCHAR( 255 ) NOT NULL , " . - "`catalog` INT( 11 ) UNSIGNED NOT NULL ," . - "`title` VARCHAR( 255 ) NOT NULL ," . - "`video_codec` VARCHAR( 255 ) NOT NULL ," . - "`audio_codec` VARCHAR( 255 ) NOT NULL ," . - "`resolution_x` MEDIUMINT UNSIGNED NOT NULL ," . - "`resolution_y` MEDIUMINT UNSIGNED NOT NULL ," . - "`time` INT( 11 ) UNSIGNED NOT NULL ," . - "`size` BIGINT UNSIGNED NOT NULL," . - "`mime` VARCHAR( 255 ) NOT NULL," . - "`enabled` TINYINT( 1) NOT NULL DEFAULT '1'" . - ") ENGINE = MYISAM "; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `access_list` ADD INDEX ( `enabled` )"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `video` ADD INDEX ( `file` )"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `video` ADD INDEX ( `enabled` )"; - $db_results = Dba::write($sql); - - $sql = "ALTER TABLE `video` ADD INDEX ( `title` )"; - $db_results = Dba::write($sql); - - self::set_version('db_version','350005'); - - return true; - - } // update_350005 - - /** - * update_350006 - * This update inserts the Lyrics pref table... - */ - public static function update_350006() { - - $sql = "INSERT INTO `preference` VALUES (69,'show_lyrics','0','Show Lyrics',0,'boolean','interface')"; - $db_results = Dba::write($sql); - - $sql = "INSERT INTO `user_preference` VALUES (1,69,'0')"; - $db_results = Dba::write($sql); - - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); - - User::fix_preferences('-1'); - - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff - - self::set_version('db_version','350006'); - - return true; - - } // update_350006 - - /** - * update_350007 - * This update adds in the random rules tables, and also increases the size of the blobs - * on the album and artist data. Also add track to tmp_playlist_data - */ - public static function update_350007() { + while ($row = Dba::fetch_assoc($db_results)) { + $row['start'] = long2ip($row['start']); + $row['end'] = long2ip($row['end']); + $acl_information[] = $row; + } + + $sql = "TRUNCATE `access_list`"; + $db_results = Dba::write($sql); + + // Make the changes to the database + $sql = "ALTER TABLE `access_list` CHANGE `start` `start` VARBINARY( 255 ) NOT NULL"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `access_list` CHANGE `end` `end` VARBINARY( 255 ) NOT NULL"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `access_list` DROP `dns`"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `access_list` ADD `enabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `key`"; + $db_results = Dba::write($sql); + + // If we had nothing in there before add some base ALLOW ALL stuff as we're going + // to start defaulting Access Control to On. + if (!count($acl_information)) { + $v6_start = Dba::escape(inet_pton('::')); + $v6_end = Dba::escape(inet_pton('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')); + $v4_start = Dba::escape(inet_pton('0.0.0.0')); + $v4_end = Dba::escape(inet_pton('255.255.255.255')); + $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . + "VALUES ('DEFAULTv4','75','$v4_start','$v4_end',NULL,'-1','interface','1')"; + $db_results = Dba::write($sql); + $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . + "VALUES ('DEFAULTv4','75','$v4_start','$v4_end',NULL,'-1','stream','1')"; + $db_results = Dba::write($sql); + $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . + "VALUES ('DEFAULTv6','75','$v6_start','$v6_end',NULL,'-1','interface','1')"; + $db_results = Dba::write($sql); + $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . + "VALUES ('DEFAULTv6','75','$v6_start','$v6_end',NULL,'-1','stream','1')"; + $db_results = Dba::write($sql); + } // Adding default information + + foreach ($acl_information as $row) { + $row['start'] = Dba::escape(inet_pton($row['start'])); + $row['end'] = Dba::escape(inet_pton($row['end'])); + $row['key'] = Dba::escape($row['key']); + $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`key`,`user`,`type`,`enabled`) " . + "VALUES ('" . Dba::escape($row['name']) . "','" . intval($row['level']) . + "','" . $row['start'] . "','" . $row['end'] . "','" . $row['key'] . "','" . intval($row['user']) . "','" . + $row['type'] . "','1')"; + $db_results = Dba::write($sql); + } // end foreach of existing rows + + self::set_version('db_version','350004'); + + return true; + + } // update_350004 + + /** + * update_350005 + * This update adds the video table... *gasp* no you didn't + */ + public static function update_350005() { + + $sql = " CREATE TABLE `video` (" . + "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . + "`file` VARCHAR( 255 ) NOT NULL , " . + "`catalog` INT( 11 ) UNSIGNED NOT NULL ," . + "`title` VARCHAR( 255 ) NOT NULL ," . + "`video_codec` VARCHAR( 255 ) NOT NULL ," . + "`audio_codec` VARCHAR( 255 ) NOT NULL ," . + "`resolution_x` MEDIUMINT UNSIGNED NOT NULL ," . + "`resolution_y` MEDIUMINT UNSIGNED NOT NULL ," . + "`time` INT( 11 ) UNSIGNED NOT NULL ," . + "`size` BIGINT UNSIGNED NOT NULL," . + "`mime` VARCHAR( 255 ) NOT NULL," . + "`enabled` TINYINT( 1) NOT NULL DEFAULT '1'" . + ") ENGINE = MYISAM "; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `access_list` ADD INDEX ( `enabled` )"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `video` ADD INDEX ( `file` )"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `video` ADD INDEX ( `enabled` )"; + $db_results = Dba::write($sql); + + $sql = "ALTER TABLE `video` ADD INDEX ( `title` )"; + $db_results = Dba::write($sql); + + self::set_version('db_version','350005'); + + return true; + + } // update_350005 + + /** + * update_350006 + * This update inserts the Lyrics pref table... + */ + public static function update_350006() { + + $sql = "INSERT INTO `preference` VALUES (69,'show_lyrics','0','Show Lyrics',0,'boolean','interface')"; + $db_results = Dba::write($sql); + + $sql = "INSERT INTO `user_preference` VALUES (1,69,'0')"; + $db_results = Dba::write($sql); + + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); + + User::fix_preferences('-1'); + + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff + + self::set_version('db_version','350006'); + + return true; + + } // update_350006 + + /** + * update_350007 + * This update adds in the random rules tables, and also increases the size of the blobs + * on the album and artist data. Also add track to tmp_playlist_data + */ + public static function update_350007() { - // We need to clear the thumbs as they will need to be re-generated - $sql = "UPDATE `album_data` SET `thumb`=NULL,`thumb_mime`=NULL"; - $db_results = Dba::write($sql); + // We need to clear the thumbs as they will need to be re-generated + $sql = "UPDATE `album_data` SET `thumb`=NULL,`thumb_mime`=NULL"; + $db_results = Dba::write($sql); - $sql = "UPDATE `artist_data` SET `thumb`=NULL,`thumb_mime`=NULL"; - $db_results = Dba::write($sql); + $sql = "UPDATE `artist_data` SET `thumb`=NULL,`thumb_mime`=NULL"; + $db_results = Dba::write($sql); - // Change the db thumb sizes - $sql = "ALTER TABLE `album_data` CHANGE `thumb` `thumb` MEDIUMBLOB NULL"; - $db_results = Dba::write($sql); + // Change the db thumb sizes + $sql = "ALTER TABLE `album_data` CHANGE `thumb` `thumb` MEDIUMBLOB NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `artist_data` CHANGE `thumb` `thumb` MEDIUMBLOB NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `artist_data` CHANGE `thumb` `thumb` MEDIUMBLOB NULL"; + $db_results = Dba::write($sql); - // Remove dead column - $sql = "ALTER TABLE `playlist_data` DROP `dynamic_song`"; - $db_results = Dba::write($sql); + // Remove dead column + $sql = "ALTER TABLE `playlist_data` DROP `dynamic_song`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `playlist` DROP `genre`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `playlist` DROP `genre`"; + $db_results = Dba::write($sql); - // Add track item to tmp_playlist_data so we can order this stuff manually - $sql = "ALTER TABLE `tmp_playlist_data` ADD `track` INT ( 11 ) UNSIGNED NULL"; - $db_results = Dba::write($sql); + // Add track item to tmp_playlist_data so we can order this stuff manually + $sql = "ALTER TABLE `tmp_playlist_data` ADD `track` INT ( 11 ) UNSIGNED NULL"; + $db_results = Dba::write($sql); - $sql = "DROP TABLE `genre`"; - $db_results = Dba::write($sql); + $sql = "DROP TABLE `genre`"; + $db_results = Dba::write($sql); - // Clean up the catalog and add last_clean to it - $sql = "ALTER TABLE `catalog` ADD `last_clean` INT ( 11 ) UNSIGNED NULL AFTER `last_update`"; - $db_results = Dba::write($sql); + // Clean up the catalog and add last_clean to it + $sql = "ALTER TABLE `catalog` ADD `last_clean` INT ( 11 ) UNSIGNED NULL AFTER `last_update`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `catalog` DROP `add_path`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `catalog` DROP `add_path`"; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `dynamic_playlist` (" . - "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . - "`name` VARCHAR( 255 ) NOT NULL ," . - "`user` INT( 11 ) NOT NULL ," . - "`date` INT( 11 ) UNSIGNED NOT NULL ," . - "`type` VARCHAR( 128 ) NOT NULL" . - ") ENGINE = MYISAM "; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `dynamic_playlist` (" . + "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . + "`name` VARCHAR( 255 ) NOT NULL ," . + "`user` INT( 11 ) NOT NULL ," . + "`date` INT( 11 ) UNSIGNED NOT NULL ," . + "`type` VARCHAR( 128 ) NOT NULL" . + ") ENGINE = MYISAM "; + $db_results = Dba::write($sql); - $sql = "CREATE TABLE `dynamic_playlist_data` (" . - "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . - "`dynamic_id` INT( 11 ) UNSIGNED NOT NULL ," . - "`field` VARCHAR( 255 ) NOT NULL ," . - "`internal_operator` VARCHAR( 64 ) NOT NULL ," . - "`external_operator` VARCHAR( 64 ) NOT NULL ," . - "`value` VARCHAR( 255 ) NOT NULL" . - ") ENGINE = MYISAM"; - $db_results = Dba::write($sql); + $sql = "CREATE TABLE `dynamic_playlist_data` (" . + "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . + "`dynamic_id` INT( 11 ) UNSIGNED NOT NULL ," . + "`field` VARCHAR( 255 ) NOT NULL ," . + "`internal_operator` VARCHAR( 64 ) NOT NULL ," . + "`external_operator` VARCHAR( 64 ) NOT NULL ," . + "`value` VARCHAR( 255 ) NOT NULL" . + ") ENGINE = MYISAM"; + $db_results = Dba::write($sql); - self::set_version('db_version','350007'); + self::set_version('db_version','350007'); - return true; + return true; - } // update_350007 + } // update_350007 - /** - * update_350008 - * Change song_id references to be object so they are a little more general - * add a type to now playing table so that we can handle different playing information - */ - public static function update_350008() { + /** + * update_350008 + * Change song_id references to be object so they are a little more general + * add a type to now playing table so that we can handle different playing information + */ + public static function update_350008() { - $sql = "ALTER TABLE `now_playing` CHANGE `song_id` `object_id` INT( 11 ) UNSIGNED NOT NULL"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `now_playing` CHANGE `song_id` `object_id` INT( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `now_playing` ADD `object_type` VARCHAR ( 255 ) NOT NULL AFTER `object_id`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `now_playing` ADD `object_type` VARCHAR ( 255 ) NOT NULL AFTER `object_id`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `now_playing` ADD INDEX ( `expire` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `now_playing` ADD INDEX ( `expire` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `video` ADD `addition_time` INT( 11 ) UNSIGNED NOT NULL AFTER `mime`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `video` ADD `addition_time` INT( 11 ) UNSIGNED NOT NULL AFTER `mime`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `video` ADD `update_time` INT( 11 ) UNSIGNED NULL AFTER `addition_time`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `video` ADD `update_time` INT( 11 ) UNSIGNED NULL AFTER `addition_time`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `video` ADD INDEX (`addition_time`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `video` ADD INDEX (`addition_time`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `video` ADD INDEX (`update_time`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `video` ADD INDEX (`update_time`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `album_data` ADD INDEX ( `art_mime` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `album_data` ADD INDEX ( `art_mime` )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `tmp_browse` ADD `type` VARCHAR ( 255 ) NOT NULL AFTER `sid`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tmp_browse` ADD `type` VARCHAR ( 255 ) NOT NULL AFTER `sid`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `tmp_browse` ADD INDEX (`type)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `tmp_browse` ADD INDEX (`type)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` DROP `hash`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` DROP `hash`"; + $db_results = Dba::write($sql); - self::set_version('db_version','350008'); + self::set_version('db_version','350008'); - } // update_350008 + } // update_350008 - /** - * update_360001 - * This adds the MB UUIDs to the different tables as well as some additional cleanup - */ - public static function update_360001() { + /** + * update_360001 + * This adds the MB UUIDs to the different tables as well as some additional cleanup + */ + public static function update_360001() { - $sql = "ALTER TABLE `album` ADD `mbid` CHAR ( 36 ) AFTER `prefix`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `album` ADD `mbid` CHAR ( 36 ) AFTER `prefix`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `artist` ADD `mbid` CHAR ( 36 ) AFTER `prefix`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `artist` ADD `mbid` CHAR ( 36 ) AFTER `prefix`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` ADD `mbid` CHAR ( 36 ) AFTER `track`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` ADD `mbid` CHAR ( 36 ) AFTER `track`"; + $db_results = Dba::write($sql); - // Remove any RIO related information from the database as the plugin has been removed - $sql = "DELETE FROM `update_info` WHERE `key` LIKE 'Plugin_Ri%'"; - $db_results = Dba::write($sql); + // Remove any RIO related information from the database as the plugin has been removed + $sql = "DELETE FROM `update_info` WHERE `key` LIKE 'Plugin_Ri%'"; + $db_results = Dba::write($sql); - $sql = "DELETE FROM `preference` WHERE `name` LIKE 'rio_%'"; - $db_results = Dba::write($sql); + $sql = "DELETE FROM `preference` WHERE `name` LIKE 'rio_%'"; + $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff - self::set_version('db_version','360001'); + self::set_version('db_version','360001'); - } // update_360001 + } // update_360001 - /** - * update_360002 - * This update makes changes to the cataloging to accomodate the new method for syncing between - * Ampache instances, could be adapted to sync with whatever for "full" catalog - */ - public static function update_360002() { + /** + * update_360002 + * This update makes changes to the cataloging to accomodate the new method for syncing between + * Ampache instances, could be adapted to sync with whatever for "full" catalog + */ + public static function update_360002() { - // Drop the key from catalog and ACL - $sql = "ALTER TABLE `catalog` DROP `key`"; - $db_results = Dba::write($sql); + // Drop the key from catalog and ACL + $sql = "ALTER TABLE `catalog` DROP `key`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `access_list` DROP `key`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `access_list` DROP `key`"; + $db_results = Dba::write($sql); - // Add in Username / Password for catalog - to be used for remote catalogs - $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `catalog_type`"; - $db_results = Dba::write($sql); + // Add in Username / Password for catalog - to be used for remote catalogs + $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `catalog_type`"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`"; + $db_results = Dba::write($sql); - // Adjust the Filename field in song, make it gi-normous. If someone has anything close to - // this file length, they seriously need to reconsider what they are doing. - $sql = "ALTER TABLE `song` CHANGE `file` `file` VARCHAR ( 4096 )"; - $db_results = Dba::write($sql); + // Adjust the Filename field in song, make it gi-normous. If someone has anything close to + // this file length, they seriously need to reconsider what they are doing. + $sql = "ALTER TABLE `song` CHANGE `file` `file` VARCHAR ( 4096 )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `video` CHANGE `file` `file` VARCHAR ( 4096 )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `video` CHANGE `file` `file` VARCHAR ( 4096 )"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )"; + $db_results = Dba::write($sql); - // Index the Artist, Album, and Song tables to prepare for Fulltext searches. - $sql = "ALTER TABLE `artist` ADD FULLTEXT(`name`)"; - $db_results = Dba::write($sql); + // Index the Artist, Album, and Song tables to prepare for Fulltext searches. + $sql = "ALTER TABLE `artist` ADD FULLTEXT(`name`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `album` ADD FULLTEXT(`name`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `album` ADD FULLTEXT(`name`)"; + $db_results = Dba::write($sql); - $sql = "ALTER TABLE `song` ADD FULLTEXT(`title`)"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `song` ADD FULLTEXT(`title`)"; + $db_results = Dba::write($sql); - // Now add in the min_object_count preference and the random_method - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('bandwidth','50','Bandwidth','5','integer','interface')"; - $db_results = Dba::write($sql); + // Now add in the min_object_count preference and the random_method + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('bandwidth','50','Bandwidth','5','integer','interface')"; + $db_results = Dba::write($sql); - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('features','50','Features','5','integer','interface')"; - $db_results = Dba::write($sql); + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('features','50','Features','5','integer','interface')"; + $db_results = Dba::write($sql); - /* Fix every users preferences */ - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while results + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results - self::set_version('db_version','360002'); - - } // update_360002 - - /** - * update_360003 - * This update moves the image data to its own table. - */ - public static function update_360003() { - $sql = "CREATE TABLE `image` (" . - "`id` int(11) unsigned NOT NULL auto_increment," . - "`image` mediumblob NOT NULL," . - "`mime` varchar(64) NOT NULL," . - "`size` varchar(64) NOT NULL," . - "`object_type` varchar(64) NOT NULL," . - "`object_id` int(11) unsigned NOT NULL," . - "PRIMARY KEY (`id`)," . - "KEY `object_type` (`object_type`)," . - "KEY `object_id` (`object_id`)" . - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; - $db_results = Dba::write($sql); - - foreach (array('album', 'artist') as $type) { - $sql = "SELECT `" . $type . "_id` AS `object_id`, " . - "`art`, `art_mime` FROM `" . $type . - "_data` WHERE `art` IS NOT NULL"; - $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - $sql = "INSERT INTO `image` " . - "(`image`, `mime`, `size`, " . - "`object_type`, `object_id`) " . - "VALUES('" . Dba::escape($row['art']) . - "', '" . $row['art_mime'] . - "', 'original', '" . $type . "', '" . - $row['object_id'] . "')"; - $db_other_results = Dba::write($sql); - } - $sql = "DROP TABLE `" . $type . "_data`"; - $db_results = Dba::write($sql); - } - - self::set_version('db_version','360003'); - - } // update_360003 + self::set_version('db_version','360002'); + + } // update_360002 + + /** + * update_360003 + * This update moves the image data to its own table. + */ + public static function update_360003() { + $sql = "CREATE TABLE `image` (" . + "`id` int(11) unsigned NOT NULL auto_increment," . + "`image` mediumblob NOT NULL," . + "`mime` varchar(64) NOT NULL," . + "`size` varchar(64) NOT NULL," . + "`object_type` varchar(64) NOT NULL," . + "`object_id` int(11) unsigned NOT NULL," . + "PRIMARY KEY (`id`)," . + "KEY `object_type` (`object_type`)," . + "KEY `object_id` (`object_id`)" . + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; + $db_results = Dba::write($sql); + + foreach (array('album', 'artist') as $type) { + $sql = "SELECT `" . $type . "_id` AS `object_id`, " . + "`art`, `art_mime` FROM `" . $type . + "_data` WHERE `art` IS NOT NULL"; + $db_results = Dba::read($sql); + while ($row = Dba::fetch_assoc($db_results)) { + $sql = "INSERT INTO `image` " . + "(`image`, `mime`, `size`, " . + "`object_type`, `object_id`) " . + "VALUES('" . Dba::escape($row['art']) . + "', '" . $row['art_mime'] . + "', 'original', '" . $type . "', '" . + $row['object_id'] . "')"; + $db_other_results = Dba::write($sql); + } + $sql = "DROP TABLE `" . $type . "_data`"; + $db_results = Dba::write($sql); + } + + self::set_version('db_version','360003'); + + } // update_360003 /** - * update_360004 - * This update creates an index on the rating table. - */ - public static function update_360004() { - $sql = "CREATE UNIQUE INDEX `unique_rating` ON `rating` (`user`, `object_type`, `object_id`)"; - $db_results = Dba::write($sql); - - self::set_version('db_version','360004'); - } // update_360004 - - /** - * update_360005 - * This changes the tmp_browse table around. - */ - public static function update_360005() { - $sql = "DROP TABLE `tmp_browse`"; - $db_results = Dba::write($sql); - - $sql = "CREATE TABLE `tmp_browse` (" . - "`id` int(13) NOT NULL auto_increment," . - "`sid` varchar(128) character set utf8 NOT NULL default ''," . - "`data` longtext NOT NULL," . - "`object_data` longtext," . - "PRIMARY KEY (`sid`,`id`)" . - ") ENGINE=MyISAM DEFAULT CHARSET=utf8"; - $db_results = Dba::write($sql); - - self::set_version('db_version','360005'); - } // update_360005 - - /** - * update_360006 - * This adds the table for newsearch/dynamic playlists - */ - public static function update_360006() { - $sql = "CREATE TABLE `search` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `user` int(11) NOT NULL, - `type` enum('private','public') CHARACTER SET utf8 DEFAULT NULL, - `rules` mediumtext NOT NULL, - `name` varchar(255) CHARACTER SET utf8 DEFAULT NULL, - `logic_operator` varchar(3) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`id`) - ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8"; - $db_results = Dba::write($sql); - - self::set_version('db_version','360006'); - } - - /** - * update_360007 - * This fixes the session table - */ - public static function update_360007() { - $sql = "ALTER TABLE `session` MODIFY `type` ENUM ('mysql','ldap','http','api','xml-rpc','local') NOT NULL"; - $db_results = Dba::write($sql); - self::set_version('db_version','360007'); - } - - /** - * update_360008 - * Fix bug that caused the remote_username/password fields to not be created - */ - public static function update_360008() { - - $remote_username = false; - $remote_password = false; - - $sql = "DESCRIBE `catalog`"; - $db_results = Dba::read($sql); - - while ($row = Dba::fetch_assoc($db_results)) { - if ($row['Field'] == 'remote_username') { - $remote_username = true; - } - if ($row['Field'] == 'remote_password') { - $remote_password = true; - } - } // end while - - if (!$remote_username) { - // Add in Username / Password for catalog - to be used for remote catalogs - $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `catalog_type`"; - $db_results = Dba::write($sql); - } - if (!$remote_password) { - $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`"; - $db_results = Dba::write($sql); - } - - self::set_version('db_version','360008'); - - } // update_360008 - - - /** - * update_360009 - * The main session table was already updated to use varchar(64) for the ID, - * tmp_playlist needs the same change - */ - public static function update_360009() { - $sql = "ALTER TABLE `tmp_playlist` CHANGE `session` `session` VARCHAR(64)"; - $db_results = Dba::write($sql); - - self::set_version('db_version','360009'); - } - - /** - * update_360010 - * MBz NGS means collaborations have more than one MBID (the ones - * belonging to the underlying artists). We need a bigger column. - */ - public static function update_360010() { - $sql = 'ALTER TABLE `artist` CHANGE `mbid` `mbid` VARCHAR(1369)'; - $db_results = Dba::write($sql); - - self::set_version('db_version', '360010'); - } - - /** - * update_380011 - * We need a place to store actual playlist data for downloadable - * playlist files. - */ - public static function update_360011() { - $sql = 'CREATE TABLE `stream_playlist` (' . - '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,' . - '`sid` varchar(64) NOT NULL,' . - '`url` text NOT NULL,' . - '`info_url` text DEFAULT NULL,' . - '`image_url` text DEFAULT NULL,' . - '`title` varchar(255) DEFAULT NULL,' . - '`author` varchar(255) DEFAULT NULL,' . - '`album` varchar(255) DEFAULT NULL,' . - '`type` varchar(255) DEFAULT NULL,' . - '`time` smallint(5) DEFAULT NULL,' . - 'PRIMARY KEY (`id`), KEY `sid` (`sid`))'; - $db_results = Dba::write($sql); - self::set_version('db_version', '360011'); - } + * update_360004 + * This update creates an index on the rating table. + */ + public static function update_360004() { + $sql = "CREATE UNIQUE INDEX `unique_rating` ON `rating` (`user`, `object_type`, `object_id`)"; + $db_results = Dba::write($sql); + + self::set_version('db_version','360004'); + } // update_360004 + + /** + * update_360005 + * This changes the tmp_browse table around. + */ + public static function update_360005() { + $sql = "DROP TABLE `tmp_browse`"; + $db_results = Dba::write($sql); + + $sql = "CREATE TABLE `tmp_browse` (" . + "`id` int(13) NOT NULL auto_increment," . + "`sid` varchar(128) character set utf8 NOT NULL default ''," . + "`data` longtext NOT NULL," . + "`object_data` longtext," . + "PRIMARY KEY (`sid`,`id`)" . + ") ENGINE=MyISAM DEFAULT CHARSET=utf8"; + $db_results = Dba::write($sql); + + self::set_version('db_version','360005'); + } // update_360005 + + /** + * update_360006 + * This adds the table for newsearch/dynamic playlists + */ + public static function update_360006() { + $sql = "CREATE TABLE `search` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user` int(11) NOT NULL, + `type` enum('private','public') CHARACTER SET utf8 DEFAULT NULL, + `rules` mediumtext NOT NULL, + `name` varchar(255) CHARACTER SET utf8 DEFAULT NULL, + `logic_operator` varchar(3) CHARACTER SET utf8 DEFAULT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8"; + $db_results = Dba::write($sql); + + self::set_version('db_version','360006'); + } + + /** + * update_360007 + * This fixes the session table + */ + public static function update_360007() { + $sql = "ALTER TABLE `session` MODIFY `type` ENUM ('mysql','ldap','http','api','xml-rpc','local') NOT NULL"; + $db_results = Dba::write($sql); + self::set_version('db_version','360007'); + } + + /** + * update_360008 + * Fix bug that caused the remote_username/password fields to not be created + */ + public static function update_360008() { + + $remote_username = false; + $remote_password = false; + + $sql = "DESCRIBE `catalog`"; + $db_results = Dba::read($sql); + + while ($row = Dba::fetch_assoc($db_results)) { + if ($row['Field'] == 'remote_username') { + $remote_username = true; + } + if ($row['Field'] == 'remote_password') { + $remote_password = true; + } + } // end while + + if (!$remote_username) { + // Add in Username / Password for catalog - to be used for remote catalogs + $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `catalog_type`"; + $db_results = Dba::write($sql); + } + if (!$remote_password) { + $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`"; + $db_results = Dba::write($sql); + } + + self::set_version('db_version','360008'); + + } // update_360008 + + + /** + * update_360009 + * The main session table was already updated to use varchar(64) for the ID, + * tmp_playlist needs the same change + */ + public static function update_360009() { + $sql = "ALTER TABLE `tmp_playlist` CHANGE `session` `session` VARCHAR(64)"; + $db_results = Dba::write($sql); + + self::set_version('db_version','360009'); + } + + /** + * update_360010 + * MBz NGS means collaborations have more than one MBID (the ones + * belonging to the underlying artists). We need a bigger column. + */ + public static function update_360010() { + $sql = 'ALTER TABLE `artist` CHANGE `mbid` `mbid` VARCHAR(1369)'; + $db_results = Dba::write($sql); + + self::set_version('db_version', '360010'); + } + + /** + * update_380011 + * We need a place to store actual playlist data for downloadable + * playlist files. + */ + public static function update_360011() { + $sql = 'CREATE TABLE `stream_playlist` (' . + '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,' . + '`sid` varchar(64) NOT NULL,' . + '`url` text NOT NULL,' . + '`info_url` text DEFAULT NULL,' . + '`image_url` text DEFAULT NULL,' . + '`title` varchar(255) DEFAULT NULL,' . + '`author` varchar(255) DEFAULT NULL,' . + '`album` varchar(255) DEFAULT NULL,' . + '`type` varchar(255) DEFAULT NULL,' . + '`time` smallint(5) DEFAULT NULL,' . + 'PRIMARY KEY (`id`), KEY `sid` (`sid`))'; + $db_results = Dba::write($sql); + self::set_version('db_version', '360011'); + } } // end update class ?> diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 01f709f276..edc711e9fc 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -1,5 +1,5 @@ id = intval($user_id); + $this->id = intval($user_id); - $info = $this->_get_info(); + $info = $this->_get_info(); - foreach ($info as $key=>$value) { - // Let's not save the password in this object :S - if ($key == 'password') { continue; } - $this->$key = $value; - } + foreach ($info as $key=>$value) { + // Let's not save the password in this object :S + if ($key == 'password') { continue; } + $this->$key = $value; + } - // Make sure the Full name is always filled - if (strlen($this->fullname) < 1) { $this->fullname = $this->username; } + // Make sure the Full name is always filled + if (strlen($this->fullname) < 1) { $this->fullname = $this->username; } - } // Constructor + } // Constructor - /** - * _get_info - * This function returns the information for this object - */ - private function _get_info() { + /** + * _get_info + * This function returns the information for this object + */ + private function _get_info() { - $id = intval($this->id); + $id = intval($this->id); - if (parent::is_cached('user',$id)) { - return parent::get_from_cache('user',$id); - } + if (parent::is_cached('user',$id)) { + return parent::get_from_cache('user',$id); + } - // If the ID is -1 then - if ($id == '-1') { - $data['username'] = 'System'; - $data['fullname'] = 'Ampache User'; - $data['access'] = '25'; - return $data; - } + // If the ID is -1 then + if ($id == '-1') { + $data['username'] = 'System'; + $data['fullname'] = 'Ampache User'; + $data['access'] = '25'; + return $data; + } - $sql = "SELECT * FROM `user` WHERE `id`='$id'"; - $db_results = Dba::read($sql); + $sql = "SELECT * FROM `user` WHERE `id`='$id'"; + $db_results = Dba::read($sql); - $data = Dba::fetch_assoc($db_results); + $data = Dba::fetch_assoc($db_results); - parent::add_to_cache('user',$id,$data); + parent::add_to_cache('user',$id,$data); - return $data; + return $data; - } // _get_info + } // _get_info - /** - * load_playlist - * This is called once per page load it makes sure that this session - * has a tmp_playlist, creating it if it doesn't, then sets $this->playlist - * as a tmp_playlist object that can be fiddled with later on - */ - public function load_playlist() { + /** + * load_playlist + * This is called once per page load it makes sure that this session + * has a tmp_playlist, creating it if it doesn't, then sets $this->playlist + * as a tmp_playlist object that can be fiddled with later on + */ + public function load_playlist() { - $session_id = session_id(); + $session_id = session_id(); - $this->playlist = Tmp_Playlist::get_from_session($session_id); + $this->playlist = Tmp_Playlist::get_from_session($session_id); - } // load_playlist + } // load_playlist - /** - * get_from_username - * This returns a built user from a username. This is a - * static function so it doesn't require an instance - */ - public static function get_from_username($username) { + /** + * get_from_username + * This returns a built user from a username. This is a + * static function so it doesn't require an instance + */ + public static function get_from_username($username) { - $username = Dba::escape($username); + $username = Dba::escape($username); - $sql = "SELECT `id` FROM `user` WHERE `username`='$username'"; - $db_results = Dba::read($sql); - $results = Dba::fetch_assoc($db_results); + $sql = "SELECT `id` FROM `user` WHERE `username`='$username'"; + $db_results = Dba::read($sql); + $results = Dba::fetch_assoc($db_results); - $user = new User($results['id']); + $user = new User($results['id']); - return $user; + return $user; - } // get_from_username + } // get_from_username - /** - * get_from_email - * This returns a built user from a email. This is a - * static function so it doesn't require an instance - */ - public static function get_from_email($email) { + /** + * get_from_email + * This returns a built user from a email. This is a + * static function so it doesn't require an instance + */ + public static function get_from_email($email) { - $email = Dba::escape($email); + $email = Dba::escape($email); - $sql = "SELECT `id` FROM `user` WHERE `email`='$email'"; - $db_results = Dba::read($sql); - $results = Dba::fetch_assoc($db_results); + $sql = "SELECT `id` FROM `user` WHERE `email`='$email'"; + $db_results = Dba::read($sql); + $results = Dba::fetch_assoc($db_results); - $user = new User($results['id']); + $user = new User($results['id']); - return $user; + return $user; - } // get_from_username + } // get_from_username - /** - * get_catalogs - * This returns the catalogs as an array of ids that this user is allowed to access - */ - public function get_catalogs() { + /** + * get_catalogs + * This returns the catalogs as an array of ids that this user is allowed to access + */ + public function get_catalogs() { - if (parent::is_cached('user_catalog',$this->id)) { - return parent::get_from_cache('user_catalog',$this->id); - } + if (parent::is_cached('user_catalog',$this->id)) { + return parent::get_from_cache('user_catalog',$this->id); + } - $sql = "SELECT * FROM `user_catalog` WHERE `user`='$user_id'"; - $db_results = Dba::read($sql); + $sql = "SELECT * FROM `user_catalog` WHERE `user`='$user_id'"; + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - $catalogs[] = $row['catalog']; - } + while ($row = Dba::fetch_assoc($db_results)) { + $catalogs[] = $row['catalog']; + } - parent::add_to_cache('user_catalog',$this->id,$catalogs); + parent::add_to_cache('user_catalog',$this->id,$catalogs); - return $catalogs; + return $catalogs; - } // get_catalogs + } // get_catalogs - /** - * get_preferences - * This is a little more complicate now that we've got many types of preferences - * This funtions pulls all of them an arranges them into a spiffy little array - * You can specify a type to limit it to a single type of preference - * []['title'] = ucased type name - * []['prefs'] = array(array('name','display','value')); - * []['admin'] = t/f value if this is an admin only section - */ - function get_preferences($type = 0, $system = false) { + /** + * get_preferences + * This is a little more complicate now that we've got many types of preferences + * This funtions pulls all of them an arranges them into a spiffy little array + * You can specify a type to limit it to a single type of preference + * []['title'] = ucased type name + * []['prefs'] = array(array('name','display','value')); + * []['admin'] = t/f value if this is an admin only section + */ + function get_preferences($type = 0, $system = false) { - // Fill out the user id - $user_id = $system ? Dba::escape(-1) : Dba::escape($this->id); + // Fill out the user id + $user_id = $system ? Dba::escape(-1) : Dba::escape($this->id); - if (!$system) { - $user_limit = "AND preference.catagory != 'system'"; - } - - if ($type != '0') { - $user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'"; - } - - - $sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " . - "FROM preference INNER JOIN user_preference ON user_preference.preference=preference.id " . - "WHERE user_preference.user='$user_id' " . $user_limit . - " ORDER BY preference.catagory, preference.description"; - - $db_results = Dba::read($sql); - - /* Ok this is crapy, need to clean this up or improve the code FIXME */ - while ($r = Dba::fetch_assoc($db_results)) { - $type = $r['catagory']; - $admin = false; - if ($type == 'system') { $admin = true; } - $type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']); - $results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]); - } // end while - - return $results; - - } // get_preferences - - /** - * set_preferences - * sets the prefs for this specific user - */ - public function set_preferences() { - - $user_id = Dba::escape($this->id); - - $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='$user_id' " . - "AND user_preference.preference=preference.id AND preference.type != 'system'"; - $db_results = Dba::read($sql); - - while ($r = Dba::fetch_assoc($db_results)) { - $key = $r['name']; - $this->prefs[$key] = $r['value']; - } - } // set_preferences - - /** - * get_favorites - * returns an array of your $type favorites - */ - function get_favorites($type) { - - $web_path = Config::get('web_path'); - - $results = Stats::get_user(Config::get('popular_threshold'),$type,$this->id,1); - - $items = array(); - - foreach ($results as $r) { - /* If its a song */ - if ($type == 'song') { - $data = new Song($r['object_id']); - $data->count = $r['count']; - $data->format(); - $data->f_name = $data->f_link; - $items[] = $data; - } - /* If its an album */ - elseif ($type == 'album') { - $data = new Album($r['object_id']); - $data->count = $r['count']; - $data->format(); - $items[] = $data; - } - /* If its an artist */ - elseif ($type == 'artist') { - $data = new Artist($r['object_id']); - $data->count = $r['count']; - $data->format(); - $data->f_name = $data->f_link; - $items[] = $data; - } - /* If it's a genre */ - elseif ($type == 'genre') { - $data = new Genre($r['object_id']); - $data->count = $r['count']; - $data->format(); - $data->f_name = $data->f_link; - $items[] = $data; - } - - } // end foreach - - return $items; - - } // get_favorites - - /** - * get_recommendations - * This returns recommended objects of $type. The recommendations - * are based on voodoo economics,the phase of the moon and my current BAL. - */ - function get_recommendations($type) { - - /* First pull all of your ratings of this type */ - $sql = "SELECT object_id,user_rating FROM ratings " . - "WHERE object_type='" . Dba::escape($type) . "' AND user='" . Dba::escape($this->id) . "'"; - $db_results = Dba::read($sql); - - // Incase they only have one user - $users = array(); - - while ($r = Dba::fetch_assoc($db_results)) { - /* Store the fact that you rated this */ - $key = $r['object_id']; - $ratings[$key] = true; - - /* Build a key'd array of users with this same rating */ - $sql = "SELECT user FROM ratings WHERE object_type='" . Dba::escape($type) . "' " . - "AND user !='" . Dba::escape($this->id) . "' AND object_id='" . Dba::escape($r['object_id']) . "' " . - "AND user_rating ='" . Dba::escape($r['user_rating']) . "'"; - $user_results = Dba::read($sql); - - while ($user_info = Dba::fetch_assoc($user_results)) { - $key = $user_info['user']; - $users[$key]++; - } - - } // end while - - /* now we've got your ratings, and all users and the # of ratings that match your ratings - * sort the users[$key] array by value and then find things they've rated high (4+) that you - * haven't rated - */ - $recommendations = array(); - asort($users); - - foreach ($users as $user_id=>$score) { - - /* Find everything they've rated at 4+ */ - $sql = "SELECT object_id,user_rating FROM ratings " . - "WHERE user='" . Dba::escape($user_id) . "' AND user_rating >='4' AND " . - "object_type = '" . Dba::escape($type) . "' ORDER BY user_rating DESC"; - $db_results = Dba::read($sql); - - while ($r = Dba::fetch_assoc($db_results)) { - $key = $r['object_id']; - if (isset($ratings[$key])) { continue; } - - /* Let's only get 5 total for now */ - if (count($recommendations) > 5) { return $recommendations; } - - $recommendations[$key] = $r['user_rating']; - - } // end while - - - } // end foreach users - - return $recommendations; - - } // get_recommendations - - /** - * is_logged_in - * checks to see if $this user is logged in returns their current IP if they - * are logged in - */ - public function is_logged_in() { - - $username = Dba::escape($this->username); - - $sql = "SELECT `id`,`ip` FROM `session` WHERE `username`='$username'" . - " AND `expire` > ". time(); - $db_results = Dba::read($sql); - - if ($row = Dba::fetch_assoc($db_results)) { - $ip = $row['ip'] ? $row['ip'] : NULL; - return $ip; - } - - return false; - - } // is_logged_in + if (!$system) { + $user_limit = "AND preference.catagory != 'system'"; + } + + if ($type != '0') { + $user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'"; + } + + + $sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " . + "FROM preference INNER JOIN user_preference ON user_preference.preference=preference.id " . + "WHERE user_preference.user='$user_id' " . $user_limit . + " ORDER BY preference.catagory, preference.description"; + + $db_results = Dba::read($sql); + + /* Ok this is crapy, need to clean this up or improve the code FIXME */ + while ($r = Dba::fetch_assoc($db_results)) { + $type = $r['catagory']; + $admin = false; + if ($type == 'system') { $admin = true; } + $type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']); + $results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]); + } // end while + + return $results; + + } // get_preferences + + /** + * set_preferences + * sets the prefs for this specific user + */ + public function set_preferences() { + + $user_id = Dba::escape($this->id); + + $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='$user_id' " . + "AND user_preference.preference=preference.id AND preference.type != 'system'"; + $db_results = Dba::read($sql); + + while ($r = Dba::fetch_assoc($db_results)) { + $key = $r['name']; + $this->prefs[$key] = $r['value']; + } + } // set_preferences + + /** + * get_favorites + * returns an array of your $type favorites + */ + function get_favorites($type) { + + $web_path = Config::get('web_path'); + + $results = Stats::get_user(Config::get('popular_threshold'),$type,$this->id,1); + + $items = array(); + + foreach ($results as $r) { + /* If its a song */ + if ($type == 'song') { + $data = new Song($r['object_id']); + $data->count = $r['count']; + $data->format(); + $data->f_name = $data->f_link; + $items[] = $data; + } + /* If its an album */ + elseif ($type == 'album') { + $data = new Album($r['object_id']); + $data->count = $r['count']; + $data->format(); + $items[] = $data; + } + /* If its an artist */ + elseif ($type == 'artist') { + $data = new Artist($r['object_id']); + $data->count = $r['count']; + $data->format(); + $data->f_name = $data->f_link; + $items[] = $data; + } + /* If it's a genre */ + elseif ($type == 'genre') { + $data = new Genre($r['object_id']); + $data->count = $r['count']; + $data->format(); + $data->f_name = $data->f_link; + $items[] = $data; + } + + } // end foreach + + return $items; + + } // get_favorites + + /** + * get_recommendations + * This returns recommended objects of $type. The recommendations + * are based on voodoo economics,the phase of the moon and my current BAL. + */ + function get_recommendations($type) { + + /* First pull all of your ratings of this type */ + $sql = "SELECT object_id,user_rating FROM ratings " . + "WHERE object_type='" . Dba::escape($type) . "' AND user='" . Dba::escape($this->id) . "'"; + $db_results = Dba::read($sql); + + // Incase they only have one user + $users = array(); + + while ($r = Dba::fetch_assoc($db_results)) { + /* Store the fact that you rated this */ + $key = $r['object_id']; + $ratings[$key] = true; + + /* Build a key'd array of users with this same rating */ + $sql = "SELECT user FROM ratings WHERE object_type='" . Dba::escape($type) . "' " . + "AND user !='" . Dba::escape($this->id) . "' AND object_id='" . Dba::escape($r['object_id']) . "' " . + "AND user_rating ='" . Dba::escape($r['user_rating']) . "'"; + $user_results = Dba::read($sql); + + while ($user_info = Dba::fetch_assoc($user_results)) { + $key = $user_info['user']; + $users[$key]++; + } + + } // end while + + /* now we've got your ratings, and all users and the # of ratings that match your ratings + * sort the users[$key] array by value and then find things they've rated high (4+) that you + * haven't rated + */ + $recommendations = array(); + asort($users); + + foreach ($users as $user_id=>$score) { + + /* Find everything they've rated at 4+ */ + $sql = "SELECT object_id,user_rating FROM ratings " . + "WHERE user='" . Dba::escape($user_id) . "' AND user_rating >='4' AND " . + "object_type = '" . Dba::escape($type) . "' ORDER BY user_rating DESC"; + $db_results = Dba::read($sql); + + while ($r = Dba::fetch_assoc($db_results)) { + $key = $r['object_id']; + if (isset($ratings[$key])) { continue; } + + /* Let's only get 5 total for now */ + if (count($recommendations) > 5) { return $recommendations; } + + $recommendations[$key] = $r['user_rating']; + + } // end while + + + } // end foreach users + + return $recommendations; + + } // get_recommendations + + /** + * is_logged_in + * checks to see if $this user is logged in returns their current IP if they + * are logged in + */ + public function is_logged_in() { + + $username = Dba::escape($this->username); + + $sql = "SELECT `id`,`ip` FROM `session` WHERE `username`='$username'" . + " AND `expire` > ". time(); + $db_results = Dba::read($sql); + + if ($row = Dba::fetch_assoc($db_results)) { + $ip = $row['ip'] ? $row['ip'] : NULL; + return $ip; + } + + return false; + + } // is_logged_in - /** - * has_access - * this function checkes to see if this user has access - * to the passed action (pass a level requirement) - */ - function has_access($needed_level) { + /** + * has_access + * this function checkes to see if this user has access + * to the passed action (pass a level requirement) + */ + function has_access($needed_level) { - if (!Config::get('use_auth') || Config::get('demo_mode')) { return true; } + if (!Config::get('use_auth') || Config::get('demo_mode')) { return true; } - if ($this->access >= $needed_level) { return true; } + if ($this->access >= $needed_level) { return true; } - return false; + return false; - } // has_access + } // has_access - /** - * update - * This function is an all encompasing update function that - * calls the mini ones does all the error checking and all that - * good stuff - */ - public function update($data) { + /** + * update + * This function is an all encompasing update function that + * calls the mini ones does all the error checking and all that + * good stuff + */ + public function update($data) { - if (empty($data['username'])) { - Error::add('username', T_('Error Username Required')); - } + if (empty($data['username'])) { + Error::add('username', T_('Error Username Required')); + } - if ($data['password1'] != $data['password2'] AND !empty($data['password1'])) { - Error::add('password', T_("Error Passwords don't match")); - } + if ($data['password1'] != $data['password2'] AND !empty($data['password1'])) { + Error::add('password', T_("Error Passwords don't match")); + } - if (Error::occurred()) { - return false; - } + if (Error::occurred()) { + return false; + } - foreach ($data as $name=>$value) { - switch ($name) { - case 'password1'; - $name = 'password'; - case 'access': - case 'email': - case 'username': - case 'fullname'; - if ($this->$name != $value) { - $function = 'update_' . $name; - $this->$function($value); - } - break; - default: - // Rien a faire - break; - } // end switch on field + foreach ($data as $name=>$value) { + switch ($name) { + case 'password1'; + $name = 'password'; + case 'access': + case 'email': + case 'username': + case 'fullname'; + if ($this->$name != $value) { + $function = 'update_' . $name; + $this->$function($value); + } + break; + default: + // Rien a faire + break; + } // end switch on field - } // end foreach + } // end foreach - return true; + return true; - } // update + } // update - /** - * update_username - * updates their username - */ - public function update_username($new_username) { + /** + * update_username + * updates their username + */ + public function update_username($new_username) { - $new_username = Dba::escape($new_username); - $sql = "UPDATE `user` SET `username`='$new_username' WHERE `id`='$this->id'"; - $this->username = $new_username; - $db_results = Dba::write($sql); + $new_username = Dba::escape($new_username); + $sql = "UPDATE `user` SET `username`='$new_username' WHERE `id`='$this->id'"; + $this->username = $new_username; + $db_results = Dba::write($sql); - } // update_username + } // update_username - /** - * update_validation - * This is used by the registration mumbojumbo - * Use this function to update the validation key - * NOTE: crap this doesn't have update_item the humanity of it all - */ - public function update_validation($new_validation) { + /** + * update_validation + * This is used by the registration mumbojumbo + * Use this function to update the validation key + * NOTE: crap this doesn't have update_item the humanity of it all + */ + public function update_validation($new_validation) { - $new_validation = Dba::escape($new_validation); - $sql = "UPDATE `user` SET `validation`='$new_validation', `disabled`='1' WHERE `id`='" . Dba::escape($this->id) . "'"; - $db_results = Dba::write($sql); - $this->validation = $new_validation; + $new_validation = Dba::escape($new_validation); + $sql = "UPDATE `user` SET `validation`='$new_validation', `disabled`='1' WHERE `id`='" . Dba::escape($this->id) . "'"; + $db_results = Dba::write($sql); + $this->validation = $new_validation; - return $db_results; + return $db_results; - } // update_validation + } // update_validation - /** - * update_fullname - * updates their fullname - */ - public function update_fullname($new_fullname) { + /** + * update_fullname + * updates their fullname + */ + public function update_fullname($new_fullname) { - $new_fullname = Dba::escape($new_fullname); - $sql = "UPDATE `user` SET `fullname`='$new_fullname' WHERE `id`='$this->id'"; - $db_results = Dba::write($sql); - - } // update_fullname - - /** - * update_email - * updates their email address - */ - public function update_email($new_email) { + $new_fullname = Dba::escape($new_fullname); + $sql = "UPDATE `user` SET `fullname`='$new_fullname' WHERE `id`='$this->id'"; + $db_results = Dba::write($sql); + + } // update_fullname + + /** + * update_email + * updates their email address + */ + public function update_email($new_email) { - $new_email = Dba::escape($new_email); - $sql = "UPDATE `user` SET `email`='$new_email' WHERE `id`='$this->id'"; - $db_results = Dba::write($sql); + $new_email = Dba::escape($new_email); + $sql = "UPDATE `user` SET `email`='$new_email' WHERE `id`='$this->id'"; + $db_results = Dba::write($sql); - } // update_email - - /** - * disable - * This disables the current user - */ - public function disable() { - - // Make sure we aren't disabling the last admin - $sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'"; - $db_results = Dba::read($sql); - - if (!Dba::num_rows($db_results)) { return false; } - - $sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'"; - $db_results = Dba::write($sql); - - // Delete any sessions they may have - $sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'"; - $db_results = Dba::write($sql); - - return true; - - } // disable - - /** - * enable - * this enables the current user - */ - public function enable() { - - $sql = "UPDATE `user` SET `disabled`='0' WHERE id='" . $this->id . "'"; - $db_results = Dba::write($sql); + } // update_email + + /** + * disable + * This disables the current user + */ + public function disable() { + + // Make sure we aren't disabling the last admin + $sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'"; + $db_results = Dba::read($sql); + + if (!Dba::num_rows($db_results)) { return false; } + + $sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'"; + $db_results = Dba::write($sql); + + // Delete any sessions they may have + $sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'"; + $db_results = Dba::write($sql); + + return true; + + } // disable + + /** + * enable + * this enables the current user + */ + public function enable() { + + $sql = "UPDATE `user` SET `disabled`='0' WHERE id='" . $this->id . "'"; + $db_results = Dba::write($sql); - return true; + return true; - } // enable + } // enable - /** - * update_access - * updates their access level - */ - public function update_access($new_access) { + /** + * update_access + * updates their access level + */ + public function update_access($new_access) { - /* Prevent Only User accounts */ - if ($new_access < '100') { - $sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'"; - $db_results = Dba::read($sql); - if (!Dba::num_rows($db_results)) { return false; } - } - - $new_access = Dba::escape($new_access); - $sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'"; - $db_results = Dba::write($sql); - - } // update_access - - /*! - @function update_last_seen - @discussion updates the last seen data for this user - */ - function update_last_seen() { - - $sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'"; - $db_results = Dba::write($sql); + /* Prevent Only User accounts */ + if ($new_access < '100') { + $sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'"; + $db_results = Dba::read($sql); + if (!Dba::num_rows($db_results)) { return false; } + } + + $new_access = Dba::escape($new_access); + $sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'"; + $db_results = Dba::write($sql); + + } // update_access + + /*! + @function update_last_seen + @discussion updates the last seen data for this user + */ + function update_last_seen() { + + $sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'"; + $db_results = Dba::write($sql); - } // update_last_seen + } // update_last_seen - /** - * update_user_stats - * updates the playcount mojo for this specific user - */ - public function update_stats($song_id) { + /** + * update_user_stats + * updates the playcount mojo for this specific user + */ + public function update_stats($song_id) { - $song_info = new Song($song_id); - $song_info->format(); - $user = $this->id; + $song_info = new Song($song_id); + $song_info->format(); + $user = $this->id; - if (!strlen($song_info->file)) { return false; } + if (!strlen($song_info->file)) { return false; } - $this->set_preferences(); + $this->set_preferences(); - foreach (Plugin::get_plugins('save_songplay') as $plugin_name) { - $plugin = new Plugin($plugin_name); - if ($plugin->load()) { - $plugin->_plugin->save_songplay($song_info); - } - } + foreach (Plugin::get_plugins('save_songplay') as $plugin_name) { + $plugin = new Plugin($plugin_name); + if ($plugin->load()) { + $plugin->_plugin->save_songplay($song_info); + } + } - // Do this last so the 'last played checks are correct' - Stats::insert('song',$song_id,$user); - Stats::insert('album',$song_info->album,$user); - Stats::insert('artist',$song_info->artist,$user); + // Do this last so the 'last played checks are correct' + Stats::insert('song',$song_id,$user); + Stats::insert('album',$song_info->album,$user); + Stats::insert('artist',$song_info->artist,$user); - return true; + return true; - } // update_stats + } // update_stats - /** - * insert_ip_history - * This inserts a row into the IP History recording this user at this - * address at this time in this place, doing this thing.. you get the point - */ - public function insert_ip_history() { + /** + * insert_ip_history + * This inserts a row into the IP History recording this user at this + * address at this time in this place, doing this thing.. you get the point + */ + public function insert_ip_history() { - if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ - $sip = $_SERVER['HTTP_X_FORWARDED_FOR']; - debug_event('User Ip', 'Login from ip adress: ' . $sip,'3'); - } - else { - $sip = $_SERVER['REMOTE_ADDR']; - debug_event('User Ip', 'Login from ip adress: ' . $sip,'3'); - } + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ + $sip = $_SERVER['HTTP_X_FORWARDED_FOR']; + debug_event('User Ip', 'Login from ip adress: ' . $sip,'3'); + } + else { + $sip = $_SERVER['REMOTE_ADDR']; + debug_event('User Ip', 'Login from ip adress: ' . $sip,'3'); + } - $ip = Dba::escape(inet_pton($sip)); - $date = time(); - $user = $this->id; - $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']); - - $sql = "INSERT INTO `ip_history` (`ip`,`user`,`date`,`agent`) VALUES ('$ip','$user','$date','$agent')"; - $db_results = Dba::write($sql); - - /* Clean up old records... sometimes */ - if (rand(1,100) > 60) { - $date = time() - (86400*Config::get('user_ip_cardinality')); - $sql = "DELETE FROM `ip_history` WHERE `date` < $date"; - $db_results = Dba::write($sql); - } - - return true; - - } // insert_ip_history - - /** - * create - * inserts a new user into ampache - */ - public static function create($username, $fullname, $email, $password, $access, $disabled = false) { - - /* Lets clean up the fields... */ - $username = Dba::escape($username); - $fullname = Dba::escape($fullname); - $email = Dba::escape($email); - $access = Dba::escape($access); - $password = hash('sha256', $password); - $disabled = $disabled ? 1 : 0; - - /* Now Insert this new user */ - $sql = "INSERT INTO `user` (`username`, `disabled`, " . - "`fullname`, `email`, `password`, `access`, " . - "`create_date`)" . - "VALUES('$username', '$disabled', '$fullname', " . - "'$email', '$password', '$access', '" . time() ."')"; - $db_results = Dba::write($sql); - - if (!$db_results) { return false; } - - // Get the insert_id - $insert_id = Dba::insert_id(); - - /* Populates any missing preferences, in this case all of them */ - self::fix_preferences($insert_id); - - return $insert_id; - - } // create - - /** - * update_password - * updates a users password - */ - public function update_password($new_password) { - - $new_password = hash('sha256',$new_password); - - $new_password = Dba::escape($new_password); - $sql = "UPDATE `user` SET `password`='$new_password' WHERE `id`='$this->id'"; - $db_results = Dba::write($sql); - - // Clear this (temp fix) - if ($db_results) { unset($_SESSION['userdata']['password']); } - - } // update_password - - /** - * format - * This function sets up the extra variables we need when we are displaying a - * user for an admin, these should not be normally called when creating a - * user object - */ - public function format() { - - /* If they have a last seen date */ - if (!$this->last_seen) { $this->f_last_seen = T_('Never'); } - else { $this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen); } - - /* If they have a create date */ - if (!$this->create_date) { $this->f_create_date = T_('Unknown'); } - else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); } - - // Base link - $this->f_link = '' . $this->fullname . ''; - - /* Calculate their total Bandwidth Useage */ - $sql = "SELECT `song`.`size` FROM `song` LEFT JOIN `object_count` ON `song`.`id`=`object_count`.`object_id` " . - "WHERE `object_count`.`user`='$this->id' AND `object_count`.`object_type`='song'"; - $db_results = Dba::read($sql); - - while ($r = Dba::fetch_assoc($db_results)) { - $total = $total + $r['size']; - } - - $this->f_useage = UI::format_bytes($total); - - /* Get Users Last ip */ - if (count($data = $this->get_ip_history(1))) { - $this->ip_history = inet_ntop($data['0']['ip']); - } - else { - $this->ip_history = T_('Not Enough Data'); - } - - } // format_user - - /** - * format_favorites - * takes an array of objects and formats them corrrectly - * and returns a simply array with just count); - - // Go through the favs - foreach ($items as $data) { - - // Make all number lengths equal - $len = strlen($data->count); - while ($len < $maxlen) { - $data->count = "0" . $data->count; - $len++; - } - - $item = "[$data->count] - $data->f_name"; - $results[]->f_name_link = $item; - } // end foreach items - - return $results; - - } // format_favorites - - /** - * format_recommendations - * This takes an array of [object_id] = ratings - * and displays them in a semi-pretty format - */ - function format_recommendations($items,$type) { - - foreach ($items as $object_id=>$rating) { - - switch ($type) { - case 'artist': - $object = new Artist($object_id); - $object->format_artist(); - $name = $object->link; - break; - case 'album': - $object = new Album($object_id); - $object->format_album(); - $name = $object->f_link; - break; - case 'song': - $object = new Song($object_id); - $object->format_song(); - $name = $object->f_link; - break; - } // end switch on type - $results[] = "- -
-+ +
++ +
-
+: | -- - | +: | ++ + |
: | -- - | +: | ++ + |
: | -- - - | +: | ++ + + |
: | -- - | +: | ++ + |
: | -- - | +: | ++ + |
: | -- - | +: | ++ + | ||||
: | -- - - - - | +: | ++ + + + + | ||||
: | -- - | +: | ++ + | ||||
: |
-
- |
+
+
||||||
- (255.255.255.255) / (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) - | ++ (255.255.255.255) / (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) + | ||||||
: | -- - - | -: | -- - - | +: | ++ + + | +: | ++ + + |
: | -- |
- : - %A = - %a = - %c = - %T = - %t = - %y = - %o = - |
+ : | ++ |
+ : + %A = + %a = + %c = + %T = + %t = + %y = + %o = + |
: | -+ | : | +|||
: | -
- |
+ : | +
+ |
||
: | -* | +: | +* | ||
: | -* | +: | +* | ||
: | -+ | : | +|||
: |
- + | : |
+ |||
: | -+ | : | +|||
: | -+ | : | +
- | - - - | ++ | + + + |
- | - - - | ++ | + + + |
- | - - - | ++ | + + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
: | -+ | : | +|
: | -
- |
+ : | +
+ |
+ | |
+ | |
+ | |
- - - - - | ++ + + + + |
- : - | -- - - | ++ : + | ++ + + |
: | -- - | +: | ++ + |
- : - | -- - | ++ : + | ++ + |
- : - | -- - - | ++ : + | ++ + + |
- : - | -- - | ++ : + | ++ + |
- : - | ++ : + |
access; ${$var_name} = 'selected="selected"'; ?>
|
- - | -- - | -- - | ++ + | ++ + | ++ + |
- - | -- - | -- - | ++ + | ++ + | ++ + |
- | + | + | |
- | base_playlist); ?> | ++ | base_playlist); ?> |
- | + | + | |
- | + | + |
- | + | + | |
---|---|---|---|
- | + | + | |
- | + | + | |
- | + | + | |
- | + | + | |
Open Basedir | -+ | Open Basedir | +|
- | + | + | |
- | + | + | |
- | + | + | |
- | + | + |
: | +: |
-
- /> + + /> /> /> /> - |
+
- | - | - | + | + | + | + | |
---|---|---|---|---|---|---|---|
- |
-
- |
- - - | -
- |
+
+ |
+
+ |
+ + + | +
+ |
- - | -- - | -- - | ++ + | ++ + | ++ + | ||
- - | ++ + |
: | -+ | : | +|||||
: | +: |
|
|||||
: | -- - - | -: | -- - - | +: | ++ + + | +: | ++ + + |
: | -- user); ?> - | +: | ++ user); ?> + | ||||
: | -- level; ${$name} = 'checked="checked"'; ?> - > - > - > - > - | +: | ++ level; ${$name} = 'checked="checked"'; ?> + > + > + > + > + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
: | -- |
- : - %A= - %a= - %c= - %T= - %t= - %y= - %o= - |
+ : | ++ |
+ : + %A= + %a= + %c= + %T= + %t= + %y= + %o= + |
- | catalog_type)); ?> | ++ | catalog_type)); ?> | ||
: | @@ -51,24 +51,24 @@* | ||||
: | -- - | +: | ++ + | ||
- : - |
- - - | +
+ : + |
+ + + |
- | - | - | - | - | + | + | + | + | + | + | |
---|---|---|---|---|---|---|---|---|---|---|---|
- + | - + | - + | - + | - + | - - - id . '&type=live_stream_row','download', T_('Save Changes'),'save_live_stream_' . $radio->id,'edit_live_stream_' . $radio->id); ?> + + + id . '&type=live_stream_row','download', T_('Save Changes'),'save_live_stream_' . $radio->id,'edit_live_stream_' . $radio->id); ?> |
- - | -
- type; ${$name} = ' selected="selected"'; ?>
- | - - - id . '&type=playlist_row','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> - | ++ + | +
+ type; ${$name} = ' selected="selected"'; ?>
+ | + + + id . '&type=playlist_row','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> + |
- - | -
- type; ${$name} = ' selected="selected"'; ?>
- | - - - id . '&type=playlist_title','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> - | ++ + | +
+ type; ${$name} = ' selected="selected"'; ?>
+ | + + + id . '&type=playlist_title','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> + |
f_link, $object->f_link); ?> + | f_link, $object->f_link); ?> |
+ | |
+ | |
sticky == "1") { echo "checked"; } ?>/> | +sticky == "1") { echo "checked"; } ?>/> |
- - | ++ + |
- - | -
- type; ${$name} = ' selected="selected"'; ?>
- | - - - id . '&type=smartplaylist_row','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> - | ++ + | +
+ type; ${$name} = ' selected="selected"'; ?>
+ | + + + id . '&type=smartplaylist_row','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> + |
- - | -
- type; ${$name} = ' selected="selected"'; ?>
- | - - - id . '&type=smartplaylist_title','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> - | ++ + | +
+ type; ${$name} = ' selected="selected"'; ?>
+ | + + + id . '&type=smartplaylist_title','download', T_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?> + |
: | -file); ?> | +: | +file); ?> |
- | - - | ++ | + + |
- |
- album); ?>
- - - |
+ + |
+ album); ?>
+ + + |
- |
- artist); ?>
- - - |
+ + |
+ artist); ?>
+ + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
- | - - | ++ | + + |
+ | |||
---|---|---|---|
- : - | -- - - | ++ : + | ++ + + |
: | -- - | +: | ++ + |
- : - | -- - | ++ : + | ++ + |
- : - | -- - - | ++ : + | ++ + + |
- : - | -- - | ++ : + | ++ + |
- : - | -+ | + : + | +
access; ${$var_name} = 'selected="selected"'; ?>
|
+
+ | |||
- |
- |
+ + |
+ |
- | - - | ++ | + + |
- | - - | ++ | + + |
: | -
- : |
+
+ |
+ |
: | -
- |
+ : | +
+ |
- - | -- - | ++ + | ++ + |
- - | -- - | ++ + | ++ + |
- - | -- - | ++ + | ++ + |
- - | -- - | ++ + | ++ + |
- | + | + | |
- | + | + | |
- | + | + | |
- | + | + |
Ampache Installation.
- For the love of Music.
Ampache Installation.
+ For the love of Music.
- | + | + | |
- | + | + | |
- | + | + | |
- | + | + | |
- | + | + | |
- | - - /> - - - | ++ | + + /> + + + |
[ ] @@ -92,32 +92,32 @@ ] | |
- | - - [] - | -
Ampache Installation.
- For the love of Music.
Ampache Installation.
+ For the love of Music.