function fs_install_impl(&$fsdb, $upgrade_if_needed = false) { $db_status_arr = fs_get_db_status($fsdb); $db_status = $db_status_arr['status']; $db_version = $db_status_arr['ver']; $msg = fs_get_database_status_message($db_status_arr); if ($db_status == FS_DB_VALID) { return true; } else { if ($db_status == FS_DB_NOT_CONFIGURED || $db_status == FS_DB_IS_NEWER_THAN_CODE) { echo $msg; return false; } else { if ($db_status == FS_DB_GENERAL_ERROR || $db_status == FS_DB_CONNECTION_ERROR) { echo $msg . " : " . $fsdb->debug(); return false; } else { if ($db_status == FS_DB_NOT_INSTALLED) { if (!fs_db_install($fsdb)) { return false; } } else { if ($db_status == FS_DB_NEED_UPGRADE && $upgrade_if_needed) { if (!fs_db_upgrade($fsdb, $db_version)) { return false; } fs_do_action("db_upgraded"); // after a db upgrade (major releases only) reset donation status for users that didn't donate $donation = fs_get_option('donation_status'); if ($donation != 'donated') { fs_update_option('donation_status', ''); fs_update_option('last_nag_time', time()); } } } } } } return true; }
function fs_ajax_change_language(&$response) { if (fs_check_is_demo($response)) { return; } $language = $_POST['language']; $current = fs_get_option('current_language'); if ($current != $language) { fs_update_option('current_language', $language); $response['refresh'] = 'true'; } }
/** * store some usage FireStats usage information */ function fs_maintain_usage_stats() { if (fs_is_admin()) { $first_run_time = fs_get_system_option('first_run_time'); if (!$first_run_time) { fs_update_system_option('first_run_time', time()); } $firestats_id = fs_get_system_option('firestats_id'); if (!$firestats_id) { fs_update_system_option('firestats_id', mt_rand()); } } $first_login = fs_get_option('first_login'); if (!$first_login) { fs_update_option('first_login', time()); } }
function fs_update_local_option($key, $value) { // only administrators may change local options. // local options are site wide, but on the level of the site that implements // the fs_update_local_option_impl function. if (fs_in_wordpress() && fs_is_wpmu()) { // even non admin user is allowed to save those options in a wpmu blog. $allowed = array('firestats_show_footer', 'firestats_show_footer_stats', 'firestats_add_comment_flag', 'firestats_add_comment_browser_os'); } else { $allowed = array(); } if (!fs_is_admin() && !in_array($key, $allowed)) { echo "Access denied : fs_update_local_option, not admin"; return; } $fs_local_options_list = fs_get_local_options_list(); if (!in_array($key, $fs_local_options_list)) { echo "fs_update_local_option: {$key} is not an authorized local option<br/>"; return; } if (function_exists('fs_update_local_option_impl')) { fs_update_local_option_impl($key, $value); } else { fs_update_option($key, $value); } }