protected static function lastcheck_expired() { $lastcheck = AmpConfig::get('autoupdate_lastcheck'); if (!$lastcheck) { User::rebuild_all_preferences(); Preference::update('autoupdate_lastcheck', $GLOBALS['user']->id, '1'); AmpConfig::set('autoupdate_lastcheck', '1', true); } return time() - 3600 * 3 > $lastcheck; }
function init_db() { if (!Preference::exists('myplex_username')) { Preference::insert('myplex_username', 'myPlex Username', '', '25', 'string', 'internal'); Preference::insert('myplex_authtoken', 'myPlex Auth Token', '', '25', 'string', 'internal'); Preference::insert('myplex_published', 'Plex Server is published to myPlex', '0', '25', 'boolean', 'internal'); Preference::insert('plex_uniqid', 'Plex Server Unique Id', uniqid(), '25', 'string', 'internal'); Preference::insert('plex_servername', 'Plex Server Name', 'Ampache', '25', 'string', 'internal'); Preference::insert('plex_public_address', 'Plex Public Address', '', '25', 'string', 'internal'); Preference::insert('plex_public_port', 'Plex Public Port', '32400', '25', 'string', 'internal'); Preference::insert('plex_local_auth', 'myPlex authentication required on local network', '0', '25', 'boolean', 'internal'); Preference::insert('plex_match_email', 'Link myPlex users to Ampache based on e-mail address', '1', '25', 'boolean', 'internal'); User::rebuild_all_preferences(); } }
/** * 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"; Dba::write($sql); // Prevent the script from timing out, which could be bad set_time_limit(0); $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 < '340002') { echo "<p align=\"center\">Database version too old, please upgrade to <a href=\"http://ampache.org/downloads/ampache-3.3.3.5.tar.gz\">Ampache-3.3.3.5</a> first</p>"; 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) { self::set_version('db_version', $version['version']); } else { AmpError::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(); // Let's also clean up the preferences unconditionally User::rebuild_all_preferences(); }
/** * install * This function installs the VLC localplay controller */ public function install() { $sql = "CREATE TABLE `localplay_vlc` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " . "`name` VARCHAR( 128 ) COLLATE utf8_unicode_ci NOT NULL , " . "`owner` INT( 11 ) NOT NULL, " . "`host` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " . "`port` INT( 11 ) UNSIGNED NOT NULL , " . "`password` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " . "`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" . ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $db_results = Dba::query($sql); // Add an internal preference for the users current active instance Preference::insert('vlc_active', 'VLC Active Instance', '0', '25', 'integer', 'internal'); User::rebuild_all_preferences(); return true; }
/* Show Confirmation */ $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins'; $title = T_('Plugin Deactivated'); $body = ''; show_confirmation($title, $body, $url); break; case 'upgrade_plugin': /* Verify that this plugin exists */ $plugins = Plugin::get_plugins(); if (!array_key_exists($_REQUEST['plugin'], $plugins)) { debug_event('plugins', 'Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected', '1'); break; } $plugin = new Plugin($_REQUEST['plugin']); $plugin->upgrade(); User::rebuild_all_preferences(); $url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins'; $title = T_('Plugin Upgraded'); $body = ''; show_confirmation($title, $body, $url); break; case 'show_plugins': $plugins = Plugin::get_plugins(); UI::show_box_top(T_('Plugins'), 'box box_localplay_plugins'); require_once AmpConfig::get('prefix') . '/templates/show_plugins.inc.php'; UI::show_box_bottom(); break; case 'show_localplay': $controllers = Localplay::get_controllers(); UI::show_box_top(T_('Localplay Controllers'), 'box box_localplay_controllers'); require_once AmpConfig::get('prefix') . '/templates/show_localplay_controllers.inc.php';