Beispiel #1
0
 /**
  * Find which special CPF's to enable.
  *
  * @return array			A list of CPF's to enable
  */
 function to_enable()
 {
     global $SITE_INFO;
     $cpf = array();
     if ($SITE_INFO['forum_type'] != 'ocf' || get_db_forums() != get_db_site() || $GLOBALS['FORUM_DRIVER']->get_drivered_table_prefix() != get_table_prefix()) {
         $cpf['role'] = 1;
         if (get_option('signup_fullname') == '0') {
             $cpf['fullname'] = 1;
         }
         $cpf['sites'] = 1;
     }
     return $cpf;
 }
Beispiel #2
0
/**
 * Parts common to any modular installation step.
 */
function big_installation_common()
{
    if (function_exists('set_time_limit')) {
        @set_time_limit(180);
    }
    if (count($_POST) == 0) {
        exit(do_lang('INST_POST_ERROR'));
    }
    $info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php';
    require_once get_file_base() . '/' . $info_file;
    require_code('database');
    $forum_type = get_forum_type();
    require_code('forum/' . $forum_type);
    $GLOBALS['FORUM_DRIVER'] = object_factory('forum_driver_' . filter_naughty_harsh($forum_type));
    if ($forum_type != 'none') {
        $GLOBALS['FORUM_DRIVER']->connection = new database_driver(get_db_forums(), get_db_forums_host(), get_db_forums_user(), get_db_forums_password(), $GLOBALS['FORUM_DRIVER']->get_drivered_table_prefix());
    }
    $GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED = array();
    $GLOBALS['FORUM_DB'] =& $GLOBALS['FORUM_DRIVER']->connection;
    if (method_exists($GLOBALS['FORUM_DRIVER'], 'check_db')) {
        if (!$GLOBALS['FORUM_DRIVER']->check_db()) {
            warn_exit(do_lang_tempcode('INVALID_FORUM_DATABASE'));
        }
    }
    require_code('database_action');
    require_code('menus2');
    require_code('config');
    require_code('zones2');
}
Beispiel #3
0
/**
 * Get all the image IDs (both already known, and those uncached) of a certain type (i.e. under a subdirectory).
 *
 * @param  ID_TEXT		The type of image (e.g. 'ocf_emoticons')
 * @param  boolean		Whether to search recursively; i.e. in subdirectories of the type subdirectory
 * @param  ?object		The database connection to work over (NULL: site db)
 * @param  ?ID_TEXT		The theme to search in, in addition to the default theme (NULL: current theme)
 * @param  boolean		Whether to only return directories (advanced option, rarely used)
 * @param  boolean		Whether to only return from the database (advanced option, rarely used)
 * @return array			The list of image IDs
 */
function get_all_image_ids_type($type, $recurse = false, $db = NULL, $theme = NULL, $dirs_only = false, $db_only = false)
{
    if (is_null($db)) {
        $db = $GLOBALS['SITE_DB'];
    }
    if (is_null($theme)) {
        $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
    }
    if (substr($type, 0, 4) == 'ocf_' && file_exists(get_file_base() . '/themes/default/images/avatars/index.html')) {
        $type = substr($type, 4);
    }
    if (substr($type, -1) == '/') {
        $type = substr($type, 0, strlen($type) - 1);
    }
    $ids = array();
    if (!$db_only && ($db->connection_write == $GLOBALS['SITE_DB']->connection_write || $dirs_only || get_db_forums() == get_db_site())) {
        _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        if ($theme != 'default') {
            _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
            _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        }
        _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        if ($theme != 'default') {
            _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
            _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
        }
    }
    if (!$dirs_only) {
        $query = 'SELECT DISTINCT id,path FROM ' . $db->get_table_prefix() . 'theme_images WHERE ';
        if (!$db_only) {
            $query .= 'path NOT LIKE \'' . db_encode_like('themes/default/images/%') . '\' AND ' . db_string_not_equal_to('path', 'themes/default/images/blank.gif') . ' AND ';
        }
        $query .= '(' . db_string_equal_to('theme', $theme) . ' OR ' . db_string_equal_to('theme', 'default') . ') AND id LIKE \'' . db_encode_like($type . '%') . '\' ORDER BY path';
        $rows = $db->query($query);
        foreach ($rows as $row) {
            if ($row['path'] == '') {
                continue;
            }
            if (url_is_local($row['path']) && !file_exists((substr($row['path'], 0, 15) == 'themes/default/' ? get_file_base() : get_custom_file_base()) . '/' . rawurldecode($row['path']))) {
                continue;
            }
            if ($row['path'] != 'themes/default/images/blank.gif') {
                $ids[] = $row['id'];
            } else {
                $key = array_search($row['id'], $ids);
                if (is_integer($key)) {
                    unset($ids[$key]);
                }
            }
        }
    }
    sort($ids);
    return array_unique($ids);
}
Beispiel #4
0
 /**
  * See if the importing site is on the same M.S.N. as the site being imported.
  *
  * @param  PATH			The path to the imported site
  * @return boolean		Answer
  */
 function on_same_msn($file_base)
 {
     if (get_param_integer('keep_on_same_msn', NULL) === 0) {
         return false;
     }
     if (get_param_integer('keep_on_same_msn', NULL) === 1) {
         return true;
     }
     //return false;
     global $SITE_INFO;
     $backup_site_info = $SITE_INFO;
     $SITE_INFO = mixed();
     @(include $file_base . '/info.php');
     $sites_site_info = $SITE_INFO;
     $SITE_INFO = $backup_site_info;
     $answer = $sites_site_info['db_forums'] == get_db_forums() && $sites_site_info['db_forums_host'] == get_db_forums_host() && @$sites_site_info['ocf_table_prefix'] === @$SITE_INFO['ocf_table_prefix'];
     return $answer;
 }
Beispiel #5
0
/**
 * Standard code module initialisation function.
 */
function init__users()
{
    global $MEMBERS_BLOCKED, $MEMBERS_BLOCKING_US;
    $MEMBERS_BLOCKED = NULL;
    $MEMBERS_BLOCKING_US = NULL;
    global $SESSION_CACHE, $MEMBER_CACHED, $ADMIN_GROUP_CACHE, $MODERATOR_GROUP_CACHE, $USERGROUP_LIST_CACHE;
    global $USER_NAME_CACHE, $MEMBER_EMAIL_CACHE, $USERS_GROUPS_CACHE;
    global $SESSION_CONFIRMED, $GETTING_MEMBER, $EMOTICON_CACHE, $CACHED_THEME, $EMOTICON_LEVELS, $EMOTICON_SET_DIR;
    $EMOTICON_LEVELS = NULL;
    $USER_NAME_CACHE = array();
    $MEMBER_EMAIL_CACHE = array();
    $USERGROUP_LIST_CACHE = NULL;
    $USERS_GROUPS_CACHE = array();
    $ADMIN_GROUP_CACHE = NULL;
    $MODERATOR_GROUP_CACHE = NULL;
    $MEMBER_CACHED = NULL;
    $SESSION_CONFIRMED = 0;
    $GETTING_MEMBER = false;
    $EMOTICON_CACHE = NULL;
    $CACHED_THEME = NULL;
    $EMOTICON_SET_DIR = NULL;
    global $IS_ACTUALLY_ADMIN;
    $IS_ACTUALLY_ADMIN = false;
    global $IS_A_COOKIE_LOGIN;
    $IS_A_COOKIE_LOGIN = false;
    // Load all sessions into memory, if possible
    if (get_value('session_prudence') !== '1') {
        $SESSION_CACHE = persistant_cache_get('SESSION_CACHE');
    } else {
        $SESSION_CACHE = NULL;
    }
    global $IN_MINIKERNEL_VERSION;
    if (!is_array($SESSION_CACHE) && $IN_MINIKERNEL_VERSION == 0) {
        if (get_value('session_prudence') !== '1') {
            $where = '';
        } else {
            $where = ' WHERE the_session=' . strval(get_session_id()) . ' OR ' . db_string_equal_to('ip', get_ip_address());
        }
        $SESSION_CACHE = array();
        if (get_forum_type() == 'ocf' && get_db_site() == get_db_forums() && get_db_site_host() == get_db_forums_host()) {
            $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
            $_s = $GLOBALS['SITE_DB']->query('SELECT s.*,m.m_primary_group FROM ' . get_table_prefix() . 'sessions s LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members m ON m.id=s.the_user' . $where);
            $SESSION_CACHE = list_to_map('the_session', $_s);
            $GLOBALS['NO_DB_SCOPE_CHECK'] = false;
        } else {
            $SESSION_CACHE = list_to_map('the_session', $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'sessions' . $where));
        }
        if (get_value('session_prudence') !== '1') {
            persistant_cache_set('SESSION_CACHE', $SESSION_CACHE);
        }
    }
    // Canonicalise various disparities in how HTTP auth environment variables are set
    if (array_key_exists('REDIRECT_REMOTE_USER', $_SERVER)) {
        $_SERVER['PHP_AUTH_USER'] = preg_replace('#@.*$#', '', $_SERVER['REDIRECT_REMOTE_USER']);
    }
    if (array_key_exists('PHP_AUTH_USER', $_SERVER)) {
        $_SERVER['PHP_AUTH_USER'] = preg_replace('#@.*$#', '', $_SERVER['PHP_AUTH_USER']);
    }
    if (array_key_exists('REMOTE_USER', $_SERVER)) {
        $_SERVER['PHP_AUTH_USER'] = preg_replace('#@.*$#', '', $_SERVER['REMOTE_USER']);
    }
}
Beispiel #6
0
 /**
  * The UI to choose what to import.
  *
  * @param  mixed			Output to show from last action (blank: none)
  * @return tempcode		The UI
  */
 function choose_actions($extra = '')
 {
     $title = get_page_title('IMPORT');
     $session = either_param_integer('session', get_session_id());
     $importer = filter_naughty(get_param('importer'));
     require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer));
     $object = object_factory('Hook_' . filter_naughty_harsh($importer));
     // Test import source is good
     if (method_exists($object, 'probe_db_access')) {
         list($db_name, $db_user, $db_password, $db_table_prefix) = $object->probe_db_access(either_param('old_base_dir'));
     } else {
         $db_name = either_param('db_name');
         $db_user = either_param('db_user');
         $db_password = either_param('db_password');
         $db_table_prefix = either_param('db_table_prefix');
     }
     if ($db_name == get_db_site() && $importer == 'ocp_merge' && $db_table_prefix == $GLOBALS['SITE_DB']->get_table_prefix()) {
         warn_exit(do_lang_tempcode('IMPORT_SELF_NO'));
     }
     $import_source = is_null($db_name) ? NULL : new database_driver($db_name, get_db_site_host(), $db_user, $db_password, $db_table_prefix);
     unset($import_source);
     $lang_array = array();
     $hooks = find_all_hooks('modules', 'admin_import_types');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/modules/admin_import_types/' . filter_naughty_harsh($hook));
         $_hook = object_factory('Hook_admin_import_types_' . filter_naughty_harsh($hook));
         $lang_array += $_hook->run();
     }
     $info = $object->info();
     $session_row = $GLOBALS['SITE_DB']->query_select('import_session', array('*'), array('imp_session' => get_session_id()), '', 1);
     if (array_key_exists(0, $session_row)) {
         $old_base_dir = $session_row[0]['imp_old_base_dir'];
         $db_name = $session_row[0]['imp_db_name'];
         $db_user = $session_row[0]['imp_db_user'];
         $db_table_prefix = $session_row[0]['imp_db_table_prefix'];
         $refresh_time = $session_row[0]['imp_refresh_time'];
     } else {
         $old_base_dir = get_file_base() . '/old';
         $db_name = get_db_site();
         $db_user = get_db_site_user();
         $db_table_prefix = array_key_exists('prefix', $info) ? $info['prefix'] : $GLOBALS['SITE_DB']->get_table_prefix();
         $refresh_time = 15;
     }
     $_import_list = $info['import'];
     $_import_list_2 = array();
     foreach ($_import_list as $import) {
         if (is_null($import)) {
             continue;
         }
         if (!array_key_exists($import, $lang_array)) {
             continue;
         }
         if (is_null($lang_array[$import])) {
             continue;
         }
         $text = do_lang(strtolower($lang_array[$import]) != $lang_array[$import] ? $lang_array[$import] : strtoupper($lang_array[$import]));
         $_import_list_2[$import] = $text;
     }
     if (array_key_exists('ocf_members', $_import_list_2) && get_forum_type() == $importer && $db_name == get_db_forums() && $db_table_prefix == $GLOBALS['FORUM_DB']->get_table_prefix()) {
         $_import_list_2['ocf_switch'] = do_lang_tempcode('SWITCH_TO_OCF');
     }
     $import_list = new ocp_tempcode();
     //	asort($_import_list_2); Let's preserve order here
     $just = get_param('just', NULL);
     $first = true;
     $skip_hidden = array();
     $parts_done = collapse_2d_complexity('imp_id', 'imp_session', $GLOBALS['SITE_DB']->query_select('import_parts_done', array('imp_id', 'imp_session'), array('imp_session' => get_session_id())));
     foreach ($_import_list_2 as $import => $text) {
         if (array_key_exists($import, $parts_done)) {
             $import_list->attach(do_template('IMPORT_ACTION_LINE', array('CHECKED' => false, 'DISABLED' => true, 'NAME' => 'import_' . $import, 'TEXT' => $text, 'ADVANCED_URL' => $info['supports_advanced_import'] ? build_url(array('page' => '_SELF', 'type' => 'advanced_hook', 'session' => $session, 'content_type' => $import, 'importer' => $importer), '_SELF') : new ocp_tempcode())));
         } else {
             $checked = is_null($just) && $first;
             $import_list->attach(do_template('IMPORT_ACTION_LINE', array('_GUID' => 'f2215115f920200a0a1ba6bc776ad945', 'CHECKED' => $checked, 'NAME' => 'import_' . $import, 'TEXT' => $text, 'ADVANCED_URL' => $info['supports_advanced_import'] ? build_url(array('page' => '_SELF', 'type' => 'advanced_hook', 'session' => $session, 'content_type' => $import, 'importer' => $importer), '_SELF') : new ocp_tempcode())));
         }
         if ($just == $import) {
             $first = true;
             $just = NULL;
         } else {
             $first = false;
         }
         $skip_hidden[] = 'import_' . $import;
     }
     $message = array_key_exists('message', $info) ? $info['message'] : '';
     if (count($parts_done) == count($_import_list_2)) {
         inform_exit(do_lang_tempcode($message === '' ? '_IMPORT_ALL_FINISHED' : 'IMPORT_ALL_FINISHED', $message));
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'import', 'session' => $session, 'importer' => $importer), '_SELF');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IMPORT')), array('_SELF:_SELF:session:importer=' . $importer, do_lang_tempcode('IMPORT_SESSION'))));
     $hidden = new ocp_tempcode();
     $hidden->attach(build_keep_post_fields($skip_hidden));
     $hidden->attach(build_keep_form_fields('', true));
     return do_template('IMPORT_ACTION_SCREEN', array('_GUID' => 'a3a69637e541923ad76e9e7e6ec7e1af', 'EXTRA' => $extra, 'MESSAGE' => $message, 'TITLE' => $title, 'FIELDS' => '', 'HIDDEN' => $hidden, 'IMPORTER' => $importer, 'IMPORT_LIST' => $import_list, 'URL' => $url));
 }
Beispiel #7
0
/**
 * Load stuff that allows user code to work.
 */
function load_user_stuff()
{
    if (!array_key_exists('FORUM_DRIVER', $GLOBALS) || $GLOBALS['FORUM_DRIVER'] === NULL) {
        global $SITE_INFO;
        require_code('forum_stub');
        if (!array_key_exists('forum_type', $SITE_INFO)) {
            $SITE_INFO['forum_type'] = 'ocf';
        }
        require_code('forum/' . $SITE_INFO['forum_type']);
        // So we can at least get user details
        $GLOBALS['FORUM_DRIVER'] = object_factory('forum_driver_' . filter_naughty_harsh($SITE_INFO['forum_type']));
        if ($SITE_INFO['forum_type'] == 'ocf' && get_db_forums() == get_db_site() && $GLOBALS['FORUM_DRIVER']->get_drivered_table_prefix() == get_table_prefix() && !$GLOBALS['DEBUG_MODE']) {
            $GLOBALS['FORUM_DRIVER']->connection = $GLOBALS['SITE_DB'];
        } elseif ($SITE_INFO['forum_type'] != 'none') {
            $GLOBALS['FORUM_DRIVER']->connection = new database_driver(get_db_forums(), get_db_forums_host(), get_db_forums_user(), get_db_forums_password(), $GLOBALS['FORUM_DRIVER']->get_drivered_table_prefix());
        }
        $GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED = array();
        $GLOBALS['FORUM_DB'] =& $GLOBALS['FORUM_DRIVER']->connection;
    }
}