global $FS_SESSION_ERROR; $FS_SESSION_ERROR = $res; } } if (file_exists(dirname(__FILE__) . '/../demo')) { define('DEMO', true); } if (!defined('FS_COMMIT_STRATEGY')) { define('FS_COMMIT_STRATEGY', FS_COMMIT_IMMEDIATE); } global $FS_CONTEXT; if (!isset($FS_CONTEXT)) { detect_context(); } // if we run in wordpress, load its config to gain access to the api and configuration if (fs_in_wordpress()) { global $FS_CONTEXT; $config_path = $FS_CONTEXT['WP_PATH']; require_once $config_path; } if (!defined('FS_DEFAULT_LANG')) { define('FS_DEFAULT_LANG', 'en_US'); } require_once dirname(__FILE__) . '/auth.php'; require_once dirname(__FILE__) . '/db-common.php'; require_once dirname(__FILE__) . '/fs-gettext.php'; require_once dirname(__FILE__) . '/db-config-utils.php'; require_once dirname(__FILE__) . '/plugins.php'; // will trigger the initialization of the database connection $fsdb =& fs_get_db_conn(); require_once dirname(__FILE__) . '/utils.php';
function fs_wp_get_users($user_id = null) { if (!fs_in_wordpress()) { echo "not in wp"; return array(); // currently users are only suppored when installed under wordpress } $wpdb =& $GLOBALS['wpdb']; $sql = "SELECT ID,display_name FROM {$wpdb->users}"; $users = $wpdb->get_results($sql, ARRAY_A); if ($users === false) { return false; } foreach ($users as $u) { $res[] = array('id' => $u['ID'], 'name' => $u['display_name']); } return $res; }
function fs_should_show_use_wp_button() { $in_wordpress = fs_in_wordpress() && fs_full_installation(); $db_config_type = fs_get_db_config_type(); return $in_wordpress && $db_config_type != FS_DB_CONFIG_WORDPRESS; }
function fs_ajax_useWordpressDB(&$response) { if (!fs_ajax_assert_admin($response)) { return; } if (fs_get_db_config_type() != FS_DB_CONFIG_FILE) { $response['status'] = 'error'; $response['message'] = fs_r('Not using configuration file'); return; } if (!fs_in_wordpress()) { ajax_error($response, fs_r('Not installed inside Wordpress')); return; } ob_start(); $res = unlink(FS_ABS_PATH . '/php/fs-config.php'); $output = ob_get_clean(); if (!$res) { ajax_error($response, sprintf(fs_r('Failed to delete fs-config.php : %s'), $output)); } else { $response['db_status'] = 'ok'; fs_sendDBConfig($response); $response['styles']['switch_to_external_system']['display'] = 'none'; } }
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); } }