$HTTP_VARS = $_POST; } } // Strip all slashes from this array. if (get_magic_quotes_gpc()) { $HTTP_VARS = stripslashes_array($HTTP_VARS); } //define a global browser sniffer object for use by theme and elsewhere $_OpendbBrowserSniffer = new OpenDbBrowserSniffer(); // if the mysql[i] extension has been loaded, the db_connect function should exist if (function_exists('db_connect')) { // defaults where no database access $_OPENDB_THEME = 'default'; $_OPENDB_LANGUAGE = 'ENGLISH'; if (is_opendb_configured()) { if (is_db_connected()) { // Cache often used configuration entries $CONFIG_VARS['logging'] = get_opendb_config_var('logging'); // Buffer output for possible pushing through ob_gzhandler handler if (is_gzip_compression_enabled($PHP_SELF)) { ob_start('ob_gzhandler'); } // Restrict cookie to site host and path. if (get_opendb_config_var('site', 'restrict_session_cookie_to_host_path') === TRUE) { session_set_cookie_params(0, get_site_path(), get_site_host()); } if (get_opendb_config_var('session_handler', 'enable') === TRUE) { require_once "./lib/dbsession.php"; if (strtolower(ini_get('session.save_handler')) == 'user' || ini_set('session.save_handler', 'user')) { session_set_save_handler('db_session_open', 'db_session_close', 'db_session_read', 'db_session_write', 'db_session_destroy', 'db_session_gc'); } else {
} else { echo "<input type=\"hidden\" name=\"step\" value=\"pre-install\">\n"; } echo "<input type=\"button\" class=\"button\" value=\"Next\" onclick=\"this.value='Working...'; this.disabled=true; this.form.submit(); return true;\">\n"; echo "</form>"; } else { echo "<p class=\"error\">There is no support to upgrade from versions of OpenDb prior to 0.80. You will have to\n\t\t\t\tinstall an older version and upgrade to at least 0.80 first.</p>"; } echo _theme_footer(); } } else { // else step = upgrade / install @set_time_limit(600); echo _theme_header("OpenDb " . get_opendb_version() . " Installation", FALSE); $is_new_install = FALSE; if (is_db_connected() && is_valid_opendb_release_table() && (!is_opendb_partially_installed() || count_opendb_table_rows('s_opendb_release') > 0)) { if (is_opendb_partially_installed()) { // upgrade if (!check_opendb_version()) { $result = install_opendb_upgrade($HTTP_VARS, $errors); if ($result == FALSE) { echo "<p class=\"error\">The following upgrade errors occurred: </p>"; if (is_array($errors)) { echo format_error_block($errors); } } else { if ($result === TRUE && !check_opendb_version()) { echo "<h2>More Upgrades required</h2>"; echo "The upgrade was completed successfully. There are still additional upgrades required.</p>"; echo "\n<form action=\"{$PHP_SELF}\" method=\"GET\">"; echo "<input type=\"hidden\" name=\"step\" value=\"upgrade\">\n";
function get_opendb_db_config_var($group, $id = NULL, $keyid = NULL) { if (is_db_connected()) { if ($group != NULL) { if ($id != NULL && $keyid != NULL) { $query = "SELECT cgiv.group_id, cgiv.id, scgi.type, cgiv.keyid, cgiv.value " . "FROM s_config_group_item_var cgiv, s_config_group_item scgi " . "WHERE cgiv.group_id = scgi.group_id AND " . "cgiv.id = scgi.id AND " . "cgiv.keyid = scgi.keyid AND " . "cgiv.group_id = '{$group}' AND " . "cgiv.id = '{$id}' AND " . "cgiv.keyid = '{$keyid}' " . "LIMIT 0,1"; // enforce only one record returned. } else { if ($id != NULL) { $query = "SELECT cgiv.group_id, cgiv.id, scgi.type, cgiv.keyid, cgiv.value " . "FROM s_config_group_item_var cgiv, s_config_group_item scgi " . "WHERE cgiv.group_id = scgi.group_id AND " . "cgiv.id = scgi.id AND " . "(scgi.type = 'array' OR cgiv.keyid = scgi.keyid) AND " . "cgiv.group_id = '{$group}' AND cgiv.id = '{$id}' " . "ORDER BY cgiv.keyid"; } else { // will need to update these lines if we ever add any more array types. $query = "SELECT cgiv.group_id, cgiv.id, scgi.type, cgiv.keyid, cgiv.value " . "FROM s_config_group_item_var cgiv, s_config_group_item scgi " . "WHERE cgiv.group_id = scgi.group_id AND " . "cgiv.id = scgi.id AND " . "(scgi.type = 'array' OR cgiv.keyid = scgi.keyid) AND " . "cgiv.group_id = '{$group}' " . "ORDER BY cgiv.id, cgiv.keyid"; } } } else { // invalid parameters provided return NULL; } $results = db_query($query); if ($results) { if (db_num_rows($results) > 0) { $results_r = NULL; $tmp_vars_r = NULL; $current_id = NULL; $current_type = NULL; while ($config_var_r = db_fetch_assoc($results)) { // first time through loop if ($current_id == NULL) { $current_id = $config_var_r['id']; $current_type = $config_var_r['type']; } else { if ($current_id !== $config_var_r['id']) { // end of id, so process $results_r[$current_id] = get_db_config_var($current_type, $tmp_vars_r, $group, $id, $keyid); $current_id = $config_var_r['id']; $current_type = $config_var_r['type']; // reset $tmp_vars_r = NULL; } } $tmp_vars_r[$config_var_r['keyid']] = $config_var_r['value']; } db_free_result($results); $results_r[$current_id] = get_db_config_var($current_type, $tmp_vars_r, $group, $id, $keyid); if ($id != NULL) { return $results_r[$current_id]; } // else return $results_r; } else { //if(db_num_rows($results)>0) return NULL; } } else { //if($results) // cannot log here - causes recursive loop //opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($group, $id, $keyid)); return NULL; } } else { //if(db_ping()) return NULL; } }
/** * assumes db is already connected. */ function get_dbuser_privileges() { $user_privileges = array(); if (is_db_connected()) { if (check_opendb_table('user')) { if (db_query("LOCK TABLES user WRITE") !== FALSE) { $user_privileges[] = array('privilege' => 'LOCK TABLES', 'granted' => TRUE); db_query("UNLOCK TABLES"); } else { $user_privileges[] = array('privilege' => 'LOCK TABLES', 'granted' => FALSE); } } } return $user_privileges; }