Ejemplo n.º 1
0
function get_link_select($conn, $data)
{
    $type = $data['type'];
    $extra_info = $data['extra'];
    ossim_valid($type, OSS_INPUT, 'illegal:' . _('Type'));
    ossim_valid($extra_info, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _('Parameter'));
    if (ossim_error()) {
        $info_error = _('Error') . ': ' . ossim_get_error();
        ossim_clean_error();
        $return['error'] = TRUE;
        $return['msg'] = $info_error;
        return $return;
    }
    switch ($type) {
        case 'host':
        case 'host_group':
        case 'net':
        case 'net_group':
        case 'incident':
            list($list, $num_rows) = Repository::get_hostnet($conn, $type);
            $result = build_select($list);
            break;
        case 'plugin_sid':
            $result = plugin_select($conn);
            break;
        case 'sid':
            $result = pluginsids_select($conn, $extra_info);
            break;
        case "directive":
            $result = directives_select();
            break;
        case 'taxonomy':
            $result = taxonomy_select($conn);
            break;
        case 'subcategory':
            $result = subcategory_select($conn, $extra_info);
            break;
        default:
            $return['error'] = TRUE;
            $return['msg'] = _('Invalid Type');
            return $return;
    }
    $return['error'] = FALSE;
    $return['data'] = $result;
    return $return;
}
function build_select($con, $portal, $pai, $nivel = 0, $pai_atual, $id_atual)
{
    //	if ($nivel > 1) { return; }
    $sql = "select * from links l inner join links_do_subportal ls\n\t\t\ton l.id = ls.links_id\n\t\t\twhere subportais_id=" . $portal . " and pai=" . $pai . " and ativo=1\n\t\t\torder by link";
    $result = mysql_query($sql);
    $r = "";
    $nivel++;
    while ($links = mysql_fetch_assoc($result)) {
        $fi = build_select($con, $portal, $links["id"], $nivel, $pai_atual, $id_atual);
        if ($pai_atual == $links["id"]) {
            $selected = "selected";
        } else {
            $selected = "";
        }
        if ($id_atual == $links["id"]) {
            $selected .= " disabled";
        }
        if ($fi == "") {
            if ($nivel == 1) {
                $r .= "<optgroup value=" . $links["id"] . " label=\"" . $links["link"] . "\">\n";
                $r .= "\t<option value=" . $links["id"] . " {$selected}>»»" . $links["link"] . "««</option>\n";
                $r .= "</optgroup>\n";
            } else {
                $r .= "\t<option value=" . $links["id"] . " {$selected}>" . $links["link"] . "</option>\n";
            }
        } else {
            if ($nivel == 1) {
                $r .= "<optgroup value=" . $links["id"] . " label=\"" . $links["link"] . "\">\n";
                $r .= "\t<option value=" . $links["id"] . " {$selected}>»»" . $links["link"] . "««</option>\n";
                if ($id_atual != $links["id"]) {
                    $r .= $fi . "\n";
                }
                $r .= "</optgroup>\n";
            } else {
                $r .= "\t<option value=" . $links["id"] . " {$selected}>" . $links["link"] . "</option>\n";
                if ($id_atual != $links["id"]) {
                    $r .= $fi . "\n";
                }
            }
        }
    }
    return $r;
}
Ejemplo n.º 3
0
/**
 * generates the ping UI in HTML and returns it
 */
function disp_ping_ui()
{
    $ret = '';
    if ($_REQUEST['ping_if'] !== 'tun0' || $_REQUEST['ping_if'] !== 'eth0' || $_REQUEST['ping_if'] !== 'eth1') {
        $_REQUEST['ping_if'] = 'eth0';
    }
    //interface dropdown
    $sel = array('id' => 'ping_if', 'selected' => $_REQUEST['ping_if'], array('eth0', 'eth0'), array('eth1', 'eth1'), array('tun0', 'tun0'));
    $ret .= '<h2>Ping Utility</h2>';
    $ret .= '<noscript><strong>The utility requires javascript. You may use the command line instead</strong></noscript>';
    $ret .= '<p>The Ping Utility uses the same ping commands as the PIA-Tunnel scripts.<br>' . 'Try pining a hostname (google.com) to see if name resolution works or ' . 'your computers/router by IP if everything fails.....' . '</p>';
    $ret .= '<p>The following firewall rule applies<br>' . '* outgoing eth0 not allowed when the VPN is connected. connections to the Internet are ' . ' only allowed through tun0' . '</p>';
    $ret .= '<input type="hidden" name="cmd" value="ping_host">';
    $ret .= 'Outgoing interface: ' . build_select($sel) . '<br>';
    $ret .= 'Name or IP ';
    $ret .= ' <input id="inp_host" type="text" name="IP" placeholder="google.com" value="" style="width: 20em;"> ';
    $ret .= ' <input id="btn_ping" type="button" href="#" onclick="send_ping();" name="ping it" value="Ping Host" disabled>';
    $ret .= '<textarea id="ping_out" style="width: 625px; height: 20em;">ping results are stored in /pia/cache/tools_ping.txt ....';
    $ret .= "</textarea>\n";
    $ret .= '<script type="text/javascript">' . 'document.getElementById("btn_ping").disabled = false;' . 'document.getElementById("inp_host").focus();' . 'var timr2;
  function send_ping(){
    document.getElementById("btn_ping").disabled = true;
    var timr1=setTimeout(function(){
      document.getElementById("ping_out").innerHTML = "running .....";
      var _ping = new PingObj();
      _ping.ping("inp_host");
      },500);

    timr2=setInterval(function(){
      var _ping = new PingObj();
       _ping.read();
       },2500);

  }</script>';
    return $ret;
}
Ejemplo n.º 4
0
if (!($ranks = $datastore->get('ranks'))) {
    $datastore->update('ranks');
    $ranks = $datastore->get('ranks');
}
$poster_rank = $rank_image = $rank_style = $rank_select = '';
if ($user_rank = $profiledata['user_rank'] and isset($ranks[$user_rank])) {
    $rank_image = $ranks[$user_rank]['rank_image'] ? '<img src="' . $ranks[$user_rank]['rank_image'] . '" alt="" title="" border="0" />' : '';
    $poster_rank = $ranks[$user_rank]['rank_title'];
    $rank_style = $ranks[$user_rank]['rank_style'];
}
if (IS_ADMIN) {
    $rank_select = array($lang['NONE'] => 0);
    foreach ($ranks as $row) {
        $rank_select[$row['rank_title']] = $row['rank_id'];
    }
    $rank_select = build_select('rank-sel', $rank_select, $user_rank);
}
if (bf($profiledata['user_opt'], 'user_opt', 'user_viewemail') || $profiledata['user_id'] == $userdata['user_id'] || IS_AM) {
    $email_uri = $bb_cfg['board_email_form'] ? 'profile.php?mode=email&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email'];
    $email = '<a class="editable" href="' . $email_uri . '">' . $profiledata['user_email'] . '</a>';
} else {
    $email = '';
}
//
// Generate page
//
$profile_user_id = $profiledata['user_id'] == $userdata['user_id'];
$signature = $bb_cfg['allow_sig'] && $profiledata['user_sig'] ? $profiledata['user_sig'] : '';
if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
    if ($profile_user_id) {
        $signature = $lang['SIGNATURE_DISABLE'];
Ejemplo n.º 5
0
        $datetime_href_s = url_arg($url, $datetime_key, date($dt_format, $row['log_time']));
        $datetime_href_s = url_arg($datetime_href_s, $daysback_key, 1);
        $template->assign_block_vars('log', array('ACTION_DESC' => $lang['LOG_ACTION']['LOG_TYPE'][$log_type_flip[$row['log_type_id']]], 'ACTION_HREF_S' => url_arg($url, $type_key, $row['log_type_id']), 'USER_ID' => $row['log_user_id'], 'USERNAME' => $row['log_username'], 'USER_HREF_S' => url_arg($url, $user_key, $row['log_user_id']), 'USER_IP' => decode_ip($row['log_user_ip']), 'FORUM_ID' => $row['log_forum_id'], 'FORUM_HREF' => BB_ROOT . FORUM_URL . $row['log_forum_id'], 'FORUM_HREF_S' => url_arg($url, $forum_key, $row['log_forum_id']), 'FORUM_NAME' => htmlCHR($forum_name), 'FORUM_ID_NEW' => $row['log_forum_id_new'], 'FORUM_HREF_NEW' => BB_ROOT . FORUM_URL . $row['log_forum_id_new'], 'FORUM_HREF_NEW_S' => url_arg($url, $forum_key, $row['log_forum_id_new']), 'FORUM_NAME_NEW' => htmlCHR($forum_name_new), 'TOPIC_ID' => $row['log_topic_id'], 'TOPIC_HREF' => !$topic_deleted ? BB_ROOT . TOPIC_URL . $row['log_topic_id'] : '', 'TOPIC_HREF_S' => url_arg($url, $topic_key, $row['log_topic_id']), 'TOPIC_TITLE' => $topic_title, 'TOPIC_ID_NEW' => $row['log_topic_id_new'], 'TOPIC_HREF_NEW' => BB_ROOT . TOPIC_URL . $row['log_topic_id_new'], 'TOPIC_HREF_NEW_S' => url_arg($url, $topic_key, $row['log_topic_id_new']), 'TOPIC_TITLE_NEW' => $topic_title_new, 'DATE' => bb_date($row['log_time'], 'j-M'), 'TIME' => bb_date($row['log_time'], 'H:i'), 'DATETIME_HREF_S' => $datetime_href_s, 'MSG' => $msg, 'ROW_CLASS' => $row_class));
        // Topics
        if ($topic_csv && empty($filter['topics'][$row['log_topic_title']])) {
            $template->assign_block_vars('topics', array('TOPIC_TITLE' => $row['log_topic_title']));
            $filter['topics'][$row['log_topic_title']] = true;
        }
        // Forums
        if ($forum_csv && empty($filter['forums'][$forum_name])) {
            $template->assign_block_vars('forums', array('FORUM_NAME' => htmlCHR($forum_name)));
            $filter['forums'][$forum_name] = true;
        }
        // Users
        if ($user_csv && empty($filter['users'][$row['log_username']])) {
            $template->assign_block_vars('users', array('USERNAME' => $row['log_username']));
            $filter['users'][$row['log_username']] = true;
        }
    }
    $template->assign_vars(array('FILTERS' => $topic_csv || $forum_csv || $user_csv, 'FILTER_TOPICS' => !empty($filter['topics']), 'FILTER_FORUMS' => !empty($filter['forums']), 'FILTER_USERS' => !empty($filter['users'])));
} else {
    $template->assign_block_vars('log_not_found', array());
}
//
// Selects
//
$log_type_select = array($lang['ACTS_LOG_ALL_ACTIONS'] => $all_types) + $log_action->log_type_select;
// Order select
$order_options = '<option value="">&nbsp;' . $lang['ACTS_LOG_TIME'] . '&nbsp;</option>';
$template->assign_vars(array('LOG_COLSPAN' => 4, 'DATETIME_NAME' => $datetime_key, 'DATETIME_VAL' => date('Y-m-d', $datetime_val), 'DAYSBACK_NAME' => $daysback_key, 'DAYSBACK_VAL' => $daysback_val, 'FIRST_LOG_TIME' => $first_log_time ? date('Y-m-d', $first_log_time) : $lang['ACC_NONE'], 'TITLE_MATCH_MAX' => $title_match_max_len, 'TITLE_MATCH_NAME' => $title_match_key, 'TITLE_MATCH_VAL' => $title_match_val, 'ORDER_NAME' => '', 'ORDER_OPTIONS' => $order_options, 'SORT_NAME' => $sort_key, 'SORT_ASC' => $sort_asc, 'SORT_DESC' => $sort_desc, 'SORT_ASC_CHECKED' => $sort_val == $sort_asc ? HTML_CHECKED : '', 'SORT_DESC_CHECKED' => $sort_val == $sort_desc ? HTML_CHECKED : '', 'SEL_FORUM' => get_forum_select('admin', "{$forum_key}[]", $forum_selected, $max_forum_name_len, $select_max_height, '', $all_forums), 'SEL_LOG_TYPE' => build_select("{$type_key}[]", $log_type_select, $type_selected, 60, $select_max_height), 'SEL_USERS' => build_select("{$user_key}[]", $users, $user_selected, 16, $select_max_height), 'S_LOG_ACTION' => "admin_log.php", 'TOPIC_CSV' => $topic_csv));
print_page('admin_log.tpl', 'admin');
Ejemplo n.º 6
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
        $action = request_var('action', '');
        $mark = isset($_REQUEST['mark']) ? implode(', ', request_var('mark', array(0))) : '';
        if ($mark) {
            switch ($action) {
                case 'activate':
                case 'delete':
                    if (!$auth->acl_get('a_user')) {
                        trigger_error($user->lang['NO_ADMIN']);
                    }
                    $sql = 'SELECT username 
						FROM ' . USERS_TABLE . "\n\t\t\t\t\t\tWHERE user_id IN ({$mark})";
                    $result = $db->sql_query($sql);
                    $user_affected = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $user_affected[] = $row['username'];
                    }
                    $db->sql_freeresult($result);
                    if ($action == 'activate') {
                        include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                        $mark_ary = explode(', ', $mark);
                        foreach ($mark_ary as $user_id) {
                            user_active_flip($user_id, USER_INACTIVE);
                        }
                        set_config('num_users', $config['num_users'] + sizeof($mark_ary), true);
                        // Update latest username
                        update_last_username();
                    } else {
                        if ($action == 'delete') {
                            if (!$auth->acl_get('a_userdel')) {
                                trigger_error($user->lang['NO_ADMIN']);
                            }
                            $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE user_id IN ({$mark})";
                            $db->sql_query($sql);
                            $sql = 'DELETE FROM ' . USERS_TABLE . " WHERE user_id IN ({$mark})";
                            $db->sql_query($sql);
                            add_log('admin', 'LOG_INDEX_' . strtoupper($action), implode(', ', $user_affected));
                        }
                    }
                    break;
                case 'remind':
                    if (!$auth->acl_get('a_user')) {
                        trigger_error($user->lang['NO_ADMIN']);
                    }
                    if (empty($config['email_enable'])) {
                        trigger_error($user->lang['EMAIL_DISABLED']);
                    }
                    $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey 
						FROM ' . USERS_TABLE . " \n\t\t\t\t\t\tWHERE user_id IN ({$mark})";
                    $result = $db->sql_query($sql);
                    if ($row = $db->sql_fetchrow($result)) {
                        // Send the messages
                        include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                        $messenger = new messenger();
                        $board_url = generate_board_url() . "/ucp.{$phpEx}?mode=activate";
                        $sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
                        $usernames = array();
                        do {
                            $messenger->template('user_remind_inactive', $row['user_lang']);
                            $messenger->replyto($config['board_email']);
                            $messenger->to($row['user_email'], $row['username']);
                            $messenger->im($row['user_jabber'], $row['username']);
                            $messenger->assign_vars(array('EMAIL_SIG' => $sig, 'USERNAME' => html_entity_decode($row['username']), 'SITENAME' => $config['sitename'], 'REGISTER_DATE' => $user->format_date($row['user_regdate']), 'U_ACTIVATE' => "{$board_url}&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']));
                            $messenger->send($row['user_notify_type']);
                            $usernames[] = $row['username'];
                        } while ($row = $db->sql_fetchrow($result));
                        $messenger->save_queue();
                        add_log('admin', 'LOG_INDEX_REMIND', implode(', ', $usernames));
                        unset($usernames);
                    }
                    $db->sql_freeresult($result);
                    break;
            }
        }
        switch ($action) {
            case 'online':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                set_config('record_online_users', 1, true);
                set_config('record_online_date', time(), true);
                add_log('admin', 'LOG_RESET_ONLINE');
                break;
            case 'stats':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                $sql = 'SELECT COUNT(post_id) AS stat 
					FROM ' . POSTS_TABLE . '
					WHERE post_approved = 1';
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                set_config('num_posts', (int) $row['stat'], true);
                $sql = 'SELECT COUNT(topic_id) AS stat
					FROM ' . TOPICS_TABLE . '
					WHERE topic_approved = 1';
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                set_config('num_topics', (int) $row['stat'], true);
                $sql = 'SELECT COUNT(user_id) AS stat
					FROM ' . USERS_TABLE . '
					WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                set_config('num_users', (int) $row['stat'], true);
                $sql = 'SELECT COUNT(attach_id) as stat
					FROM ' . ATTACHMENTS_TABLE;
                $result = $db->sql_query($sql);
                set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
                $db->sql_freeresult($result);
                $sql = 'SELECT SUM(filesize) as stat
					FROM ' . ATTACHMENTS_TABLE;
                $result = $db->sql_query($sql);
                set_config('upload_dir_size', (int) $db->sql_fetchfield('stat'), true);
                $db->sql_freeresult($result);
                add_log('admin', 'LOG_RESYNC_STATS');
                break;
            case 'user':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                $post_count_ary = $auth->acl_getf('f_postcount');
                $forum_read_ary = $auth->acl_getf('f_read');
                $forum_ary = array();
                foreach ($post_count_ary as $forum_id => $allowed) {
                    if ($allowed['f_postcount'] && $forum_read_ary[$forum_id]['f_read']) {
                        $forum_ary[] = $forum_id;
                    }
                }
                if (!sizeof($forum_ary)) {
                    $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
                } else {
                    $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
						FROM ' . POSTS_TABLE . '
						WHERE poster_id <> ' . ANONYMOUS . '
							AND forum_id IN (' . implode(', ', $forum_ary) . ')
						GROUP BY poster_id';
                    $result = $db->sql_query($sql);
                    while ($row = $db->sql_fetchrow($result)) {
                        $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}");
                    }
                    $db->sql_freeresult($result);
                }
                add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
                break;
            case 'date':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                set_config('board_startdate', time() - 1);
                add_log('admin', 'LOG_RESET_DATE');
                break;
            case 'db_track':
                $db->sql_query((SQL_LAYER != 'sqlite' ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . TOPICS_POSTED_TABLE);
                // This can get really nasty... therefore we only do the last six months
                $get_from_time = time() - 6 * 4 * 7 * 24 * 60 * 60;
                // Select forum ids, do not include categories
                $sql = 'SELECT forum_id
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type <> ' . FORUM_CAT;
                $result = $db->sql_query($sql);
                $forum_ids = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $forum_ids[] = $row['forum_id'];
                }
                $db->sql_freeresult($result);
                // Any global announcements? ;)
                $forum_ids[] = 0;
                // Now go through the forums and get us some topics...
                foreach ($forum_ids as $forum_id) {
                    $sql = 'SELECT p.poster_id, p.topic_id
						FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
						WHERE t.forum_id = ' . $forum_id . '
							AND t.topic_moved_id = 0
							AND t.topic_last_post_time > ' . $get_from_time . '
							AND t.topic_id = p.topic_id
							AND p.poster_id <> ' . ANONYMOUS . '
						GROUP BY p.poster_id, p.topic_id';
                    $result = $db->sql_query($sql);
                    $posted = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $posted[$row['poster_id']][] = $row['topic_id'];
                    }
                    $db->sql_freeresult($result);
                    $sql_ary = array();
                    foreach ($posted as $user_id => $topic_row) {
                        foreach ($topic_row as $topic_id) {
                            $sql_ary[] = array('user_id' => $user_id, 'topic_id' => $topic_id, 'topic_posted' => 1);
                        }
                    }
                    unset($posted);
                    if (sizeof($sql_ary)) {
                        switch (SQL_LAYER) {
                            case 'mysql':
                            case 'mysql4':
                            case 'mysqli':
                                $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
                                break;
                            default:
                                foreach ($sql_ary as $ary) {
                                    $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
                                }
                                break;
                        }
                    }
                }
                add_log('admin', 'LOG_RESYNC_POST_MARKING');
                break;
        }
        // Get forum statistics
        $total_posts = $config['num_posts'];
        $total_topics = $config['num_topics'];
        $total_users = $config['num_users'];
        $total_files = $config['num_files'];
        $start_date = $user->format_date($config['board_startdate']);
        $boarddays = (time() - $config['board_startdate']) / 86400;
        $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
        $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
        $users_per_day = sprintf('%.2f', $total_users / $boarddays);
        $files_per_day = sprintf('%.2f', $total_files / $boarddays);
        $upload_dir_size = $config['upload_dir_size'] >= 1048576 ? sprintf('%.2f ' . $user->lang['MB'], $config['upload_dir_size'] / 1048576) : ($config['upload_dir_size'] >= 1024 ? sprintf('%.2f ' . $user->lang['KB'], $config['upload_dir_size'] / 1024) : sprintf('%.2f ' . $user->lang['BYTES'], $config['upload_dir_size']));
        $avatar_dir_size = 0;
        if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) {
            while (($file = readdir($avatar_dir)) !== false) {
                if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) {
                    $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
                }
            }
            @closedir($avatar_dir);
            // This bit of code translates the avatar directory size into human readable format
            // Borrowed the code from the PHP.net annoted manual, origanally written by:
            // Jesse (jesse@jess.on.ca)
            $avatar_dir_size = $avatar_dir_size >= 1048576 ? sprintf('%.2f ' . $user->lang['MB'], $avatar_dir_size / 1048576) : ($avatar_dir_size >= 1024 ? sprintf('%.2f ' . $user->lang['KB'], $avatar_dir_size / 1024) : sprintf('%.2f ' . $user->lang['BYTES'], $avatar_dir_size));
        } else {
            // Couldn't open Avatar dir.
            $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
        }
        if ($posts_per_day > $total_posts) {
            $posts_per_day = $total_posts;
        }
        if ($topics_per_day > $total_topics) {
            $topics_per_day = $total_topics;
        }
        if ($users_per_day > $total_users) {
            $users_per_day = $total_users;
        }
        if ($files_per_day > $total_files) {
            $files_per_day = $total_files;
        }
        $dbsize = get_database_size();
        $s_action_options = build_select(array('online' => 'RESET_ONLINE', 'date' => 'RESET_DATE', 'stats' => 'RESYNC_STATS', 'user' => 'RESYNC_POSTCOUNTS', 'db_track' => 'RESYNC_POST_MARKING'));
        $template->assign_vars(array('TOTAL_POSTS' => $total_posts, 'POSTS_PER_DAY' => $posts_per_day, 'TOTAL_TOPICS' => $total_topics, 'TOPICS_PER_DAY' => $topics_per_day, 'TOTAL_USERS' => $total_users, 'USERS_PER_DAY' => $users_per_day, 'TOTAL_FILES' => $total_files, 'FILES_PER_DAY' => $files_per_day, 'START_DATE' => $start_date, 'AVATAR_DIR_SIZE' => $avatar_dir_size, 'DBSIZE' => $dbsize, 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'GZIP_COMPRESSION' => $config['gzip_compress'] ? $user->lang['ON'] : $user->lang['OFF'], 'U_ACTION' => append_sid("{$phpbb_admin_path}index.{$phpEx}"), 'S_ACTION_OPTIONS' => $auth->acl_get('a_board') ? $s_action_options : ''));
        $log_data = array();
        $log_count = 0;
        if ($auth->acl_get('a_viewlogs')) {
            view_log('admin', $log_data, $log_count, 5);
            foreach ($log_data as $row) {
                $template->assign_block_vars('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action']));
            }
        }
        if ($auth->acl_get('a_user')) {
            $sql = 'SELECT user_id, username, user_regdate
				FROM ' . USERS_TABLE . ' 
				WHERE user_type = ' . USER_INACTIVE . ' 
				ORDER BY user_regdate ASC';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('inactive', array('DATE' => $user->format_date($row['user_regdate']), 'USER_ID' => $row['user_id'], 'USERNAME' => $row['username'], 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&amp;mode=overview&amp;u={$row['user_id']}")));
            }
            $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
            if ($config['email_enable']) {
                $option_ary += array('remind' => 'REMIND');
            }
            $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary)));
        }
        // Display debug_extra notice
        if (defined('DEBUG_EXTRA')) {
            $template->assign_var('S_DEBUG_EXTRA', true);
        }
        $this->tpl_name = 'acp_main';
        $this->page_title = 'ACP_MAIN';
    }
Ejemplo n.º 7
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
        include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
        $user->add_lang('memberlist');
        $action = request_var('action', '');
        $mark = isset($_REQUEST['mark']) ? request_var('mark', array(0)) : array();
        $start = request_var('start', 0);
        $submit = isset($_POST['submit']);
        // Sort keys
        $sort_days = request_var('st', 0);
        $sort_key = request_var('sk', 'i');
        $sort_dir = request_var('sd', 'd');
        $form_key = 'acp_inactive';
        add_form_key($form_key);
        if ($submit && sizeof($mark)) {
            if ($action !== 'delete' && !check_form_key($form_key)) {
                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
            switch ($action) {
                case 'activate':
                case 'delete':
                    $sql = 'SELECT user_id, username
						FROM ' . USERS_TABLE . '
						WHERE ' . $db->sql_in_set('user_id', $mark);
                    $result = $db->sql_query($sql);
                    $user_affected = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $user_affected[$row['user_id']] = $row['username'];
                    }
                    $db->sql_freeresult($result);
                    if ($action == 'activate') {
                        if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                            // Get those 'being activated'...
                            $sql = 'SELECT user_id, username, user_email, user_lang
								FROM ' . USERS_TABLE . '
								WHERE ' . $db->sql_in_set('user_id', $mark) . '
									AND user_type = ' . USER_INACTIVE;
                            $result = $db->sql_query($sql);
                            $inactive_users = array();
                            while ($row = $db->sql_fetchrow($result)) {
                                $inactive_users[] = $row;
                            }
                            $db->sql_freeresult($result);
                        }
                        user_active_flip('activate', $mark);
                        if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users)) {
                            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                            $messenger = new messenger();
                            foreach ($inactive_users as $row) {
                                $messenger->template('admin_welcome_activated', $row['user_lang']);
                                $messenger->to($row['user_email'], $row['username']);
                                $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                                $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                                $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                                $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username'])));
                                $messenger->send(NOTIFY_EMAIL);
                            }
                            $messenger->save_queue();
                        }
                    } else {
                        if ($action == 'delete') {
                            if (confirm_box(true)) {
                                if (!$auth->acl_get('a_userdel')) {
                                    trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                                }
                                foreach ($mark as $user_id) {
                                    user_delete('retain', $user_id, $user_affected[$user_id]);
                                }
                                add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
                            } else {
                                $s_hidden_fields = array('mode' => $mode, 'action' => $action, 'mark' => $mark, 'submit' => 1, 'start' => $start);
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
                            }
                        }
                    }
                    break;
                case 'remind':
                    if (empty($config['email_enable'])) {
                        trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
						FROM ' . USERS_TABLE . '
						WHERE ' . $db->sql_in_set('user_id', $mark) . '
							AND user_inactive_reason';
                    $sql .= $config['require_activation'] == USER_ACTIVATION_ADMIN ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL;
                    $result = $db->sql_query($sql);
                    if ($row = $db->sql_fetchrow($result)) {
                        // Send the messages
                        include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                        $messenger = new messenger();
                        $usernames = array();
                        do {
                            $messenger->template('user_remind_inactive', $row['user_lang']);
                            $messenger->to($row['user_email'], $row['username']);
                            $messenger->im($row['user_jabber'], $row['username']);
                            $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                            $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                            $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                            $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), 'U_ACTIVATE' => generate_board_url() . "/ucp.{$phpEx}?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']));
                            $messenger->send($row['user_notify_type']);
                            $usernames[] = $row['username'];
                        } while ($row = $db->sql_fetchrow($result));
                        $messenger->save_queue();
                        add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
                        unset($usernames);
                    }
                    $db->sql_freeresult($result);
                    break;
            }
        }
        // Sorting
        $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
        $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME']);
        $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean');
        $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        // Define where and sort sql for use in displaying logs
        $sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
        $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        $inactive = array();
        $inactive_count = 0;
        $start = view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
        foreach ($inactive as $row) {
            $template->assign_block_vars('inactive', array('INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => !$row['user_lastvisit'] ? ' - ' : $user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'USERNAME' => $row['username'], 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&amp;mode=overview&amp;u={$row['user_id']}")));
        }
        $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
        if ($config['email_enable']) {
            $option_ary += array('remind' => 'REMIND');
        }
        $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&amp;{$u_sort_param}", $inactive_count, $config['topics_per_page'], $start, true), 'U_ACTION' => $this->u_action . '&amp;start=' . $start));
        $this->tpl_name = 'acp_inactive';
        $this->page_title = 'ACP_INACTIVE_USERS';
    }
Ejemplo n.º 8
0
         if (isset($_REQUEST['c'])) {
             $cat_id = (int) $_REQUEST['c'];
         }
     }
     $catlist = get_list('category', $cat_id, TRUE);
     $forumlocked = $forumunlocked = '';
     $forumstatus == FORUM_LOCKED ? $forumlocked = 'selected="selected"' : ($forumunlocked = 'selected="selected"');
     $statuslist = '<option value="' . FORUM_UNLOCKED . '" ' . $forumunlocked . '>' . $lang['STATUS_UNLOCKED'] . '</option>\\n';
     $statuslist .= '<option value="' . FORUM_LOCKED . '" ' . $forumlocked . '>' . $lang['STATUS_LOCKED'] . '</option>\\n';
     $forum_display_sort_list = get_forum_display_sort_option($forum_display_sort, 'list', 'sort');
     $forum_display_order_list = get_forum_display_sort_option($forum_display_order, 'list', 'order');
     $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
     $s_parent = '<option value="-1">&nbsp;' . $lang['SF_NO_PARENT'] . '</option>\\n';
     $sel_forum = $forum_parent && !isset($_REQUEST['forum_parent']) ? $forum_id : $forum_parent;
     $s_parent .= sf_get_list('forum', $forum_id, $sel_forum);
     $template->assign_vars(array('TPL_EDIT_FORUM' => true, 'S_FORUM_DISPLAY_SORT_LIST' => $forum_display_sort_list, 'S_FORUM_DISPLAY_ORDER_LIST' => $forum_display_order_list, 'S_FORUM_ACTION' => 'admin_forums.php', 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SUBMIT_VALUE' => $buttonvalue, 'S_CAT_LIST' => $catlist, 'S_STATUS_LIST' => $statuslist, 'SHOW_ON_INDEX' => $show_on_index, 'S_PARENT_FORUM' => $s_parent, 'CAT_LIST_CLASS' => $forum_parent ? 'hidden' : '', 'SHOW_ON_INDEX_CLASS' => !$forum_parent ? 'hidden' : '', 'TPL_SELECT' => get_select('forum_tpl', $forum_tpl_id, 'html', $lang['TEMPLATE_DISABLE']), 'ALLOW_REG_TRACKER' => build_select('allow_reg_tracker', array($lang['DISALLOWED'] => 0, $lang['ALLOWED'] => 1), $allow_reg_tracker), 'ALLOW_PORNO_TOPIC' => build_select('allow_porno_topic', array($lang['NONE'] => 0, $lang['YES'] => 1), $allow_porno_topic), 'SELF_MODERATED' => build_select('self_moderated', array($lang['NONE'] => 0, $lang['YES'] => 1), $self_moderated), 'L_FORUM_TITLE' => $l_title, 'PRUNE_DAYS' => $prune_days, 'FORUM_NAME' => htmlCHR($forumname), 'DESCRIPTION' => htmlCHR($forumdesc)));
     break;
 case 'createforum':
     //
     // Create a forum in the DB
     //
     $cat_id = intval($_POST[POST_CAT_URL]);
     $forum_name = (string) $_POST['forumname'];
     $forum_desc = (string) $_POST['forumdesc'];
     $forum_status = intval($_POST['forumstatus']);
     $prune_days = intval($_POST['prune_days']);
     $forum_parent = $_POST['forum_parent'] != -1 ? intval($_POST['forum_parent']) : 0;
     $show_on_index = $forum_parent ? intval($_POST['show_on_index']) : 1;
     $forum_display_sort = intval($_POST['forum_display_sort']);
     $forum_display_order = intval($_POST['forum_display_order']);
     $forum_tpl_id = (int) $_POST['forum_tpl_select'];
Ejemplo n.º 9
0
/**
 * method to get a list of valid VPN connection
 * currently only supporting PIA so I simply index the .ovpn files
 *  - used build_select()
 * @param string $name name and id of element as a string
 * @param array $build_options *Optional* additional build_select() as array (besides name)
 * @return string/bool string containing HTML formated as <select> or FALSE
 */
function VPN_get_connections($name, $build_options = array())
{
    $fw_ret = array();
    $ret = array();
    $sel = array();
    $sel['id'] = $name;
    if (count($build_options) > 0) {
        $sel = array_merge($sel, $build_options);
    }
    if (array_key_exists('ovpn', $_SESSION) !== true) {
        echo "FATAL ERROR: Unable to get list of VPN connections!";
        return false;
    }
    //loop over session to generate options
    foreach ($_SESSION['ovpn'] as $ovpn) {
        if (provider_ready2use($ovpn) === true) {
            $html = htmlentities($ovpn);
            //$ret .= "<option value=\"$html\">$html</option>\n";
            if (supports_forwarding($html) === true) {
                $fw_ret[] = array($html, '*' . $html);
            } else {
                $ret[] = array($html, $html);
            }
        }
    }
    if ($ret == '') {
        return false;
    }
    sort($ret);
    sort($fw_ret);
    if (count($ret) === 0 && count($fw_ret) === 0) {
        $ret[] = array('invalid login data', 'invalid login data');
    }
    $t = array_merge($sel, $fw_ret, $ret);
    $assembled = build_select($t);
    //return "<select name=\"vpn_connections\">\n$ret</select>\n";
    return $assembled;
}
Ejemplo n.º 10
0
    foreach ($forums_ary as $forum_id) {
        $forum_name = $forum_name_html[$forum_id];
        $forum_name = str_short($forum_name, $max_forum_name_len - 2);
        $style = '';
        if (!isset($cat_forum['subforums'][$forum_id])) {
            $class = 'root_forum has_sf';
            $class .= isset($cat_forum['forums_with_sf'][$forum_id]) ? ' has_sf' : '';
            $style = " class=\"{$class}\"";
        }
        $selected = isset($search_in_forums_fary[$forum_id]) ? HTML_SELECTED : '';
        $opt .= '<option id="fs-' . $forum_id . '" value="' . $forum_id . '"' . $style . $selected . '>' . (isset($cat_forum['subforums'][$forum_id]) ? HTML_SF_SPACER : '') . $forum_name . "&nbsp;</option>\n";
    }
    $opt .= "</optgroup>\n";
}
$search_all_opt = '<option value="' . $search_all . '" value="fs-' . $search_all . '"' . ($forum_val == $search_all ? HTML_SELECTED : '') . '>&nbsp;' . htmlCHR($lang['ALL_AVAILABLE']) . "</option>\n";
$cat_forum_select = "\n" . '<select id="fs-main" style="width: 100%;" name="' . $forum_key . '[]" multiple="multiple" size="' . $forum_select_size . "\">\n" . $search_all_opt . $opt . "</select>\n";
// Sort dir
$template->assign_vars(array('SORT_NAME' => $sort_key, 'SORT_ASC' => $sort_asc, 'SORT_DESC' => $sort_desc, 'SORT_ASC_CHECKED' => $sort_val == $sort_asc ? HTML_CHECKED : '', 'SORT_DESC_CHECKED' => $sort_val == $sort_desc ? HTML_CHECKED : ''));
// Displaying options
$tor_type_lang = $lang['GOLD'] . ' / ' . $lang['SILVER'];
$template->assign_vars(array('SHOW_CAT_CHBOX' => build_checkbox($show_cat_key, $lang['BT_SHOW_CAT'], $show_cat_val), 'SHOW_FORUM_CHBOX' => build_checkbox($show_forum_key, $lang['BT_SHOW_FORUM'], $show_forum_val), 'SHOW_AUTHOR_CHBOX' => build_checkbox($show_author_key, $lang['BT_SHOW_AUTHOR'], $show_author_val), 'SHOW_SPEED_CHBOX' => build_checkbox($show_speed_key, $lang['BT_SHOW_SPEED'], $show_speed_val), 'ALL_WORDS_CHBOX' => build_checkbox($all_words_key, $lang['SEARCH_ALL_WORDS'], $all_words_val), 'TOR_TYPE_CHBOX' => build_checkbox($tor_type_key, $tor_type_lang, $tor_type_val), 'ONLY_MY_CHBOX' => build_checkbox($my_key, $lang['BT_ONLY_MY'], $only_my, IS_GUEST), 'ONLY_ACTIVE_CHBOX' => build_checkbox($active_key, $lang['BT_ONLY_ACTIVE'], $active_val), 'SEED_EXIST_CHBOX' => build_checkbox($seed_exist_key, $lang['BT_SEED_EXIST'], $seed_exist), 'ONLY_NEW_CHBOX' => build_checkbox($new_key, $lang['BT_ONLY_NEW'], $only_new, IS_GUEST), 'DL_CANCEL_CHBOX' => build_checkbox($dl_cancel_key, $lang['SEARCH_DL_CANCEL'], $dl_cancel_val, IS_GUEST, 'dlCancel'), 'DL_COMPL_CHBOX' => build_checkbox($dl_compl_key, $lang['SEARCH_DL_COMPLETE'], $dl_compl_val, IS_GUEST, 'dlComplete'), 'DL_DOWN_CHBOX' => build_checkbox($dl_down_key, $lang['SEARCH_DL_DOWN'], $dl_down_val, IS_GUEST, 'dlDown'), 'DL_WILL_CHBOX' => build_checkbox($dl_will_key, $lang['SEARCH_DL_WILL'], $dl_will_val, IS_GUEST, 'dlWill'), 'POSTER_NAME_NAME' => $poster_name_key, 'POSTER_NAME_VAL' => htmlCHR($poster_name_val), 'TITLE_MATCH_NAME' => $title_match_key, 'TITLE_MATCH_VAL' => htmlCHR($title_match_val), 'AJAX_TOPICS' => $user->opt_js['tr_t_ax'], 'SHOW_TIME_TOPICS' => $user->opt_js['tr_t_t'], 'SHOW_CURSOR' => $user->opt_js['hl_tr'], 'HIDE_CONTENTS' => $user->opt_js['h_tsp'], 'U_SEARCH_USER' => "search.php?mode=searchuser&input_name={$poster_name_key}"));
// Hidden fields
$save_through_pages = array('all_words', 'active', 'dl_cancel', 'dl_compl', 'dl_down', 'dl_will', 'my', 'new', 'seed_exist', 'show_author', 'show_cat', 'show_forum', 'show_speed', 'tor_type');
$hidden_fields = array();
foreach ($save_through_pages as $name) {
    $hidden_fields['prev_' . ${"{$name}_key"}] = ${"{$name}_val"};
}
// Set colspan
$tor_colspan = $tor_colspan - $hide_cat - $hide_forum - $hide_author - $hide_speed;
$template->assign_vars(array('PAGE_TITLE' => $lang['TRACKER'], 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), 'CAT_FORUM_SELECT' => $cat_forum_select, 'ORDER_SELECT' => build_select($order_key, $order_select, $order_val), 'TIME_SELECT' => build_select($time_key, $time_select, $time_val), 'S_NOT_SEEN_SELECT' => build_select($s_not_seen_key, $s_not_seen_select, $s_not_seen_val), 'S_RG_SELECT' => build_select($s_rg_key, $s_release_group_select, $s_rg_val), 'TOR_SEARCH_ACTION' => $tracker_url, 'TOR_COLSPAN' => $tor_colspan, 'TITLE_MATCH_MAX' => $title_match_max_len, 'POSTER_NAME_MAX' => $poster_name_max_len, 'POSTER_ERROR' => $poster_error, 'SHOW_SEARCH_OPT' => (bool) $allowed_forums, 'SHOW_CAT' => $show_cat_val, 'SHOW_FORUM' => $show_forum_val, 'SHOW_AUTHOR' => $show_author_val, 'SHOW_SPEED' => $show_speed_val, 'MAX_FS' => $max_forums_selected, 'L_MAX_FS' => sprintf($lang['SEL_CHAPTERS_HELP'], $max_forums_selected), 'TRACKER_URL' => make_url('tracker.php?'), 'TR_CAT_URL' => "{$tracker_url}?{$cat_key}=", 'TR_FORUM_URL' => "{$tracker_url}?{$forum_key}=", 'TR_POSTER_URL' => "{$tracker_url}?{$poster_id_key}="));
print_page('tracker.tpl');
Ejemplo n.º 11
0
/**
 */
function get_row_column_mappings_table($s_item_type, $owner_id, $header_row, $field_column_r, $field_default_r, $field_initcap_r)
{
    $buffer = "\n<table>";
    $buffer .= "\n<tr class=\"navbar\"><th></th>" . "<th>" . get_opendb_lang_var('field') . "</th>" . "<th>" . get_opendb_lang_var('default') . "</th>" . "<th> " . get_opendb_lang_var('initcap') . "</th></tr>";
    // If the prompt for this field, matches any of the $tokens, then select that token.
    if (!is_numeric($field_column_r['s_item_type'])) {
        for ($i = 0; $i < count($header_row); $i++) {
            if ($header_row[$i] == 's_item_type' || $header_row[$i] == get_opendb_lang_var('s_item_type')) {
                $field_column_r['s_item_type'] = $i;
                break;
            }
        }
    }
    // If your data includes the item_type, then specify the column, so we
    // can ignore records that are not of the chosen item_type.
    $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . get_opendb_lang_var('s_item_type') . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[s_item_type]", $header_row, $field_column_r['s_item_type']) . "</td>" . "<td class=\"data defaultColumn\">&nbsp;</td>" . "<td class=\"data initcapColumn\">&nbsp;</td>" . "</tr>";
    // --------- Now the main input fields start....
    $results = fetch_item_attribute_type_rs($s_item_type);
    if ($results) {
        while ($item_attribute_type_r = db_fetch_assoc($results)) {
            // purely readonly
            if ($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') {
                $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') {
                    $lookup_results = fetch_newitem_status_type_rs();
                    $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname], FALSE);
                    // do not include 'None' option
                    $initcap_field = NULL;
                    // No initcap for these types of fields.
                } else {
                    if ($item_attribute_type_r['input_type'] !== "textarea" && $item_attribute_type_r['input_type'] !== "url") {
                        // Check if any lookup values for this field.
                        $lookup_results = fetch_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], 'order_no, value ASC');
                        if ($lookup_results) {
                            $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname]);
                            $initcap_field = NULL;
                            // No initcap for these types of fields.
                        } else {
                            //use normal input field.
                            if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') {
                                $item_attribute_type_r['multi_attribute_ind'] = 'N';
                            }
                            $default_field = get_item_input_field("field_default[{$fieldname}]", $item_attribute_type_r, NULL, $field_default_r[$fieldname], FALSE);
                            if ($item_attribute_type_r['input_type'] === 'text') {
                                $initcap_field = get_input_field("field_initcap[{$fieldname}]", NULL, NULL, "checkbox(true,false,)", "N", ifempty($field_initcap_r[$fieldname], get_opendb_config_var('import', 'row_import_default_initcap_checked') ? "true" : "false"), FALSE);
                            } else {
                                //Only for text fields.
                                $initcap_field = NULL;
                            }
                        }
                    } else {
                        $field = NULL;
                        $default_field = NULL;
                        $initcap_field = NULL;
                    }
                }
                // If the prompt for this field, matches any of the $tokens, then select that token.
                if (!is_numeric($field_column_r[$fieldname])) {
                    for ($i = 0; $i < count($header_row); $i++) {
                        // A direct export from CSV Export, so lets match the columns for you.
                        if ($header_row[$i] == $fieldname || $header_row[$i] == $item_attribute_type_r['prompt'] || $item_attribute_type_r['s_field_type'] == 'CATEGORY' && $header_row[$i] == 'Genre') {
                            $field_column_r[$fieldname] = $i;
                            break;
                        }
                    }
                }
                $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . $item_attribute_type_r['prompt'] . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[{$fieldname}]", $header_row, $field_column_r[$fieldname]) . "</td>" . "<td class=\"data defaultColumn\">" . $default_field . "</td>" . "<td class=\"data initcapColumn\">" . $initcap_field . "</td>" . "</tr>";
            }
            //if($item_attribute_type_r['s_field_type'] !== 'ITEM_ID')
        }
        //while
        db_free_result($results);
    }
    //if($results)
    $buffer .= "\n</table>";
    return $buffer;
}
Ejemplo n.º 12
0
 }
 $bt_userdata = DB()->fetch_row($sql);
 $user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null;
 if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) {
     if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
         $dl_allowed = $user_ratio > $min_ratio_dl;
     }
     if (isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS || $bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO) {
         $template->assign_vars(array('SHOW_RATIO_WARN' => true, 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help'])));
     }
 }
 if (!$dl_allowed) {
     $template->assign_block_vars('postrow.attach.tor_reged', array());
     $template->assign_vars(array('TOR_BLOCKED' => true, 'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu={$bt_user_id}&amp;dlc=1")));
 } else {
     $template->assign_block_vars('postrow.attach.tor_reged', array('DOWNLOAD_NAME' => $display_name, 'TRACKER_LINK' => $tracker_link, 'ATTACH_ID' => $attach_id, 'TOR_SILVER_GOLD' => $tor_type, 'TOR_FROZEN' => !IS_AM ? isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id']) ? true : '' : '', 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor_info['tor_status']], 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor_info['tor_status']], 'TOR_STATUS_BY' => $tor_info['checked_user_id'] && $is_auth['auth_mod'] ? '<span title="' . bb_date($tor_info['checked_time']) . '"> &middot; ' . profile_url($tor_info) . ' &middot; <i>' . delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] . '</i></span>' : '', 'TOR_STATUS_SELECT' => build_select('sel_status', array_flip($lang['TOR_STATUS_NAME']), TOR_APPROVED), 'TOR_STATUS_REPLY' => $bb_cfg['tor_comment'] && !IS_GUEST && in_array($tor_info['tor_status'], $bb_cfg['tor_reply']) && $userdata['user_id'] == $tor_info['poster_id'] && $t_data['topic_status'] != TOPIC_LOCKED, 'S_UPLOAD_IMAGE' => $upload_image, 'U_DOWNLOAD_LINK' => $download_link, 'DL_LINK_CLASS' => isset($bt_userdata['user_status']) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed', 'DL_TITLE_CLASS' => isset($bt_userdata['user_status']) ? $dl_status_css[$bt_userdata['user_status']] : 'gen', 'FILESIZE' => $tor_file_size, 'MAGNET' => $tor_magnet, 'HASH' => strtoupper(bin2hex($tor_info['info_hash'])), 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count), 'REGED_TIME' => bb_date($tor_info['reg_time']), 'REGED_DELTA' => delta_time($tor_info['reg_time']), 'TORRENT_SIZE' => humn_size($tor_size), 'COMPLETED' => sprintf($lang['DOWNLOAD_NUMBER'], $tor_info['complete_count'])));
     if ($comment) {
         $template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment));
     }
 }
 if ($bb_cfg['show_tor_info_in_dl_list']) {
     $template->assign_vars(array('SHOW_DL_LIST' => true, 'SHOW_DL_LIST_TOR_INFO' => true, 'TOR_SIZE' => humn_size($tor_size), 'TOR_LONGEVITY' => delta_time($tor_info['reg_time']), 'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times')));
 }
 // Show peers
 if ($show_peers) {
     // Sorting order in full mode
     if ($s_mode == 'full') {
         $full_mode_order = 'tr.remain';
         $full_mode_sort_dir = 'ASC';
         if (isset($_REQUEST['psortasc'])) {
             $full_mode_sort_dir = 'ASC';
Ejemplo n.º 13
0
    $rss_array[$ID] = $data[$index]->title;
}
#
$html_instance->add_parameter(array('ACTION' => 'show_form', 'HEADER' => 'Add Homepage', 'TEXT_CENTER' => '', 'FORM_ACTION' => $_SERVER['PHP_SELF'], 'TD_WIDTH' => '30%', 'BUTTON_TEXT' => 'Save Home'));
$s1 = build_select($element1, 'element1');
$s2 = build_select($element2, 'element2');
$s3 = build_select($element3, 'element3');
$s4 = build_select($element4, 'element4');
$s5 = build_select($element5, 'element5');
$s6 = build_select($element6, 'element6');
$s7 = build_select($element7, 'element7');
$s8 = build_select($element8, 'element8');
$s9 = build_select($element9, 'element9');
$s10 = build_select($element10, 'element10');
$s11 = build_select($element11, 'element11');
$s12 = build_select($element12, 'element12');
$html_instance->add_form_field(array('TYPE' => 'text', 'NAME' => 'title', 'VALUE' => $title, 'SIZE' => 20, 'TEXT' => 'Title'));
$all_select = '<table cellpadding=3><tr><td><b>1.&nbsp;Row</b></td><td>' . $s1 . '</td><td>' . $s2 . '</td></tr>
<tr><td><strong>2. Row</strong></td><td>' . $s3 . '</td><td>' . $s4 . '</td></tr>
<tr><td><strong>3. Row</strong></td><td>' . $s5 . '</td><td>' . $s6 . '</td></tr>
<tr><td><strong>4. Row</strong></td><td>' . $s7 . '</td><td>' . $s8 . '</td></tr>
<tr><td><strong>5. Row</strong></td><td>' . $s9 . '</td><td>' . $s10 . '</td></tr>
<tr><td><strong>6. Row</strong></td><td>' . $s11 . '</td><td>' . $s12 . '</td></tr></table>';
$html_instance->add_form_field(array('TYPE' => 'label', 'TEXT' => $all_select));
$html_instance->process();
#
function build_select($current_value, $name)
{
    global $base_instance, $rss_array;
    $userid = $base_instance->get_userid();
    $all = '';
Ejemplo n.º 14
0
    $post_new_topic = $lang['POST_NEW_TOPIC'];
}
// Post URL generation for templating vars
$template->assign_vars(array('U_POST_NEW_TOPIC' => $post_new_topic_url, 'S_SELECT_TOPIC_DAYS' => build_select('topicdays', array_flip($sel_previous_days), $topic_days), 'S_POST_DAYS_ACTION' => "viewforum.php?f={$forum_id}&amp;start={$start}", 'S_DISPLAY_ORDER' => $s_display_order));
// User authorisation levels output
$u_auth = array();
$u_auth[] = $is_auth['auth_post'] ? $lang['RULES_POST_CAN'] : $lang['RULES_POST_CANNOT'];
$u_auth[] = $is_auth['auth_reply'] ? $lang['RULES_REPLY_CAN'] : $lang['RULES_REPLY_CANNOT'];
$u_auth[] = $is_auth['auth_edit'] ? $lang['RULES_EDIT_CAN'] : $lang['RULES_EDIT_CANNOT'];
$u_auth[] = $is_auth['auth_delete'] ? $lang['RULES_DELETE_CAN'] : $lang['RULES_DELETE_CANNOT'];
$u_auth[] = $is_auth['auth_vote'] ? $lang['RULES_VOTE_CAN'] : $lang['RULES_VOTE_CANNOT'];
$u_auth[] = $is_auth['auth_attachments'] ? $lang['RULES_ATTACH_CAN'] : $lang['RULES_ATTACH_CANNOT'];
$u_auth[] = $is_auth['auth_download'] ? $lang['RULES_DOWNLOAD_CAN'] : $lang['RULES_DOWNLOAD_CANNOT'];
$u_auth[] = $is_auth['auth_mod'] ? $lang['RULES_MODERATE'] : '';
$u_auth = join("<br />\n", $u_auth);
$template->assign_vars(array('SHOW_JUMPBOX' => true, 'PAGE_TITLE' => htmlCHR($forum_data['forum_name']), 'FORUM_ID' => $forum_id, 'FORUM_NAME' => htmlCHR($forum_data['forum_name']), 'TORRENTS' => $forum_data['allow_reg_tracker'], 'POST_IMG' => $forum_data['forum_status'] == FORUM_LOCKED ? $images['post_locked'] : $post_img, 'FOLDER_IMG' => $images['folder'], 'FOLDER_NEW_IMG' => $images['folder_new'], 'FOLDER_LOCKED_IMG' => $images['folder_locked'], 'FOLDER_STICKY_IMG' => $images['folder_sticky'], 'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'], 'FOLDER_DOWNLOAD_IMG' => $images['folder_dl'], 'SHOW_ONLY_NEW_MENU' => true, 'ONLY_NEW_POSTS_ON' => $only_new == ONLY_NEW_POSTS, 'ONLY_NEW_TOPICS_ON' => $only_new == ONLY_NEW_TOPICS, 'TITLE_MATCH' => htmlCHR($title_match), 'SELECT_TPP' => $select_tpp ? build_select('tpp', $select_tpp, $topics_per_page, null, null, 'onchange="$(\'#tpp\').submit();"') : '', 'T_POST_NEW_TOPIC' => $forum_data['forum_status'] == FORUM_LOCKED ? $lang['FORUM_LOCKED'] : $post_new_topic, 'S_AUTH_LIST' => $u_auth, 'U_VIEW_FORUM' => FORUM_URL . $forum_id, 'U_MARK_READ' => FORUM_URL . $forum_id . "&amp;mark=topics", 'U_SEARCH_SELF' => "search.php?uid={$userdata['user_id']}&f={$forum_id}"));
// Okay, lets dump out the page ...
$found_topics = 0;
foreach ($topic_rowset as $topic) {
    $topic_id = $topic['topic_id'];
    $moved = $topic['topic_status'] == TOPIC_MOVED;
    $replies = $topic['topic_replies'];
    $t_hot = $replies >= $bb_cfg['hot_threshold'];
    $t_type = $topic['topic_type'];
    $separator = '';
    $is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id);
    if ($t_type == POST_ANNOUNCE && !defined('ANNOUNCE_SEP')) {
        define('ANNOUNCE_SEP', true);
        $separator = $lang['TOPICS_ANNOUNCEMENT'];
    } elseif ($t_type == POST_STICKY && !defined('STICKY_SEP')) {
        define('STICKY_SEP', true);
Ejemplo n.º 15
0
function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '', $all_forums_option = null)
{
    global $lang, $datastore;
    if (is_array($mode)) {
        $not_auth_forums_fary = array_flip($mode);
        $mode = 'not_auth_forums';
    }
    if (is_null($max_length)) {
        $max_length = HTML_SELECT_MAX_LENGTH;
    }
    $select = is_null($all_forums_option) ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option);
    if (!($forums = $datastore->get('cat_forums'))) {
        $datastore->update('cat_forums');
        $forums = $datastore->get('cat_forums');
    }
    foreach ($forums['f'] as $fid => $f) {
        switch ($mode) {
            case 'guest':
                if ($f['auth_view'] != AUTH_ALL) {
                    continue 2;
                }
                break;
            case 'user':
                if ($f['auth_view'] != AUTH_ALL && $f['auth_view'] != AUTH_REG) {
                    continue 2;
                }
                break;
            case 'not_auth_forums':
                if (isset($not_auth_forums_fary[$f['forum_id']])) {
                    continue 2;
                }
                break;
            case 'admin':
                break;
            default:
                trigger_error(__FUNCTION__ . ": invalid mode '{$mode}'", E_USER_ERROR);
        }
        $cat_title = $forums['c'][$f['cat_id']]['cat_title'];
        $f_name = $f['forum_parent'] ? ' |- ' : '';
        $f_name .= $f['forum_name'];
        while (isset($select[$cat_title][$f_name])) {
            $f_name .= ' ';
        }
        $select[$cat_title][$f_name] = $fid;
        if (!$f['forum_parent']) {
            $class = 'root_forum';
            $class .= isset($f['subforums']) ? ' has_sf' : '';
            $select['__attributes'][$cat_title][$f_name]['class'] = $class;
        }
    }
    return build_select($name, $select, $selected, $max_length, $multiple_size, $js);
}
Ejemplo n.º 16
0
 /**
  * @dataProvider build_select_data
  */
 public function test_build_select($option_ary, $option_default, $expected)
 {
     $this->assertEquals($expected, build_select($option_ary, $option_default));
 }
Ejemplo n.º 17
0
        $schedule = array($lang['SCHEDULE']['select'] => 0);
        foreach ($lang['SCHEDULE'] as $type => $key) {
            $schedule[$key] = $type;
        }
        $template->assign_vars(array('TPL_CRON_EDIT' => true, 'S_CRON_ACTION' => 'admin_cron.php', 'S_MODE' => 'edit', 'SCHEDULE' => build_select('schedule', $schedule, $row['schedule']), 'RUN_DAY' => build_select('run_day', $run_day, $row['run_day']), 'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_EDIT']));
        break;
    case 'add':
        $run_day = array($lang['DELTA_TIME']['INTERVALS']['mday'][0] => 0);
        for ($i = 1; $i <= 28; $i++) {
            $run_day[$i] = $i;
        }
        $schedule = array();
        foreach ($lang['SCHEDULE'] as $type => $key) {
            $schedule[$key] = $type;
        }
        $template->assign_vars(array('TPL_CRON_EDIT' => true, 'S_CRON_ACTION' => 'admin_cron.php', 'S_MODE' => 'add', 'SCHEDULE' => build_select('schedule', $schedule, 'select', null, null), 'RUN_DAY' => build_select('run_day', $run_day, 0, null, null), 'L_CRON_EDIT_HEAD' => $lang['CRON_EDIT_HEAD_ADD'], 'CRON_ID' => 'none', 'CRON_ACTIVE' => 1, 'CRON_TITLE' => '', 'CRON_SCRIPT' => '', 'RUN_TIME' => '', 'RUN_ORDER' => 255, 'LAST_RUN' => '0000-00-00 00:00:00', 'NEXT_RUN' => '0000-00-00 00:00:00', 'RUN_INTERVAL' => '', 'LOG_ENABLED' => 0, 'LOG_FILE' => '', 'LOG_SQL_QUERIES' => 0, 'DISABLE_BOARD' => 0, 'RUN_COUNTER' => 0));
        break;
    case 'delete':
        delete_jobs($job_id);
        bb_die($lang['JOB_REMOVED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_JOBS'], '<a href="admin_cron.php?mode=list">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
        break;
}
if ($submit) {
    if ($_POST['mode'] == 'list') {
        if ($cron_action == 'run' && $jobs) {
            run_jobs($jobs);
        } else {
            if ($cron_action == 'delete' && $jobs) {
                delete_jobs($jobs);
            } else {
                if (($cron_action == 'disable' || $cron_action == 'enable') && $jobs) {
Ejemplo n.º 18
0
            // Предупреждение
            $mc_class = 'warning';
            break;
        case 4:
            // Нарушение
            $mc_class = 'danger';
            break;
        default:
            $mc_class = '';
            break;
    }
    $mc_select_type = array();
    foreach ($lang['MC_COMMENT'] as $key => $value) {
        $mc_select_type[$key] = $value['type'];
    }
    $template->assign_block_vars('postrow', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POST_ID' => $post_id, 'IS_NEWEST' => $post_id == $newest, 'POSTER_NAME' => profile_url(array('username' => $poster, 'user_rank' => $user_rank)), 'POSTER_NAME_JS' => addslashes($poster), 'POSTER_RANK' => $poster_rank, 'RANK_IMAGE' => $rank_image, 'POSTER_JOINED' => $bb_cfg['show_poster_joined'] ? $poster_longevity : '', 'POSTER_JOINED_DATE' => $poster_joined, 'POSTER_POSTS' => $bb_cfg['show_poster_posts'] ? $poster_posts : '', 'POSTER_FROM' => $bb_cfg['show_poster_from'] ? wbr($poster_from) : '', 'POSTER_BOT' => $poster_id == BOT_UID, 'POSTER_ID' => $poster_id, 'POSTER_AUTHOR' => $poster_id == $t_data['topic_poster'], 'POSTER_GENDER' => $bb_cfg['gender'] ? gender_image($postrow[$i]['user_gender']) : '', 'POSTED_AFTER' => $prev_post_time ? delta_time($postrow[$i]['post_time'], $prev_post_time) : '', 'IS_UNREAD' => is_unread($postrow[$i]['post_time'], $topic_id, $forum_id), 'IS_FIRST_POST' => !$start && $post_id == $t_data['topic_first_post_id'], 'MOD_CHECKBOX' => $moderation && ($start || defined('SPLIT_FORM_START')), 'POSTER_AVATAR' => $poster_avatar, 'POST_NUMBER' => $i + $start + 1, 'POST_DATE' => $post_date, 'MESSAGE' => $message, 'SIGNATURE' => $user_sig, 'EDITED_MESSAGE' => $l_edited_by, 'PM' => $pm_btn, 'PROFILE' => $profile_btn, 'QUOTE' => $quote_btn, 'EDIT' => $edit_btn, 'DELETE' => $delpost_btn, 'IP' => $ip_btn, 'POSTER_BIRTHDAY' => $bb_cfg['birthday_enabled'] && $this_date == $poster_birthday ? '<img src="' . $images['icon_birthday'] . '" alt="" title="' . $lang['HAPPY_BIRTHDAY'] . '" border="0" />' : '', 'MC_COMMENT' => $mc_type ? bbcode2html($mc_comment) : '', 'MC_BBCODE' => $mc_type ? $mc_comment : '', 'MC_CLASS' => $mc_class, 'MC_TITLE' => sprintf($lang['MC_COMMENT'][$mc_type]['title'], $mc_user_id), 'MC_SELECT_TYPE' => build_select("mc_type_{$post_id}", array_flip($mc_select_type), $mc_type), 'RG_AVATAR' => $rg_avatar, 'RG_NAME' => $rg_name, 'RG_URL' => GROUP_URL . $rg_id, 'RG_FIND_URL' => 'tracker.php?srg=' . $rg_id, 'RG_SIG' => $rg_signature, 'RG_SIG_ATTACH' => $postrow[$i]['attach_rg_sig']));
    if ($postrow[$i]['post_attachment'] && $is_auth['auth_download'] && function_exists('display_post_attachments')) {
        display_post_attachments($post_id, $postrow[$i]['post_attachment']);
    }
    if ($moderation && !defined('SPLIT_FORM_START') && ($start || $post_id == $t_data['topic_first_post_id'])) {
        define('SPLIT_FORM_START', TRUE);
    }
    if ($poster_id != BOT_UID) {
        $prev_post_time = $postrow[$i]['post_time'];
    }
}
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id, $max_post_time);
if (defined('SPLIT_FORM_START')) {
    $template->assign_vars(array('SPLIT_FORM' => true, 'START' => $start, 'S_SPLIT_ACTION' => "modcp.php", 'POST_FORUM_URL' => POST_FORUM_URL, 'POST_TOPIC_URL' => POST_TOPIC_URL));
}
// Quick Reply
Ejemplo n.º 19
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template, $phpbb_container, $phpbb_log, $request;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx;
        if (!function_exists('user_active_flip')) {
            include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
        }
        $user->add_lang('memberlist');
        $action = $request->variable('action', '');
        $mark = isset($_REQUEST['mark']) ? $request->variable('mark', array(0)) : array();
        $start = $request->variable('start', 0);
        $submit = isset($_POST['submit']);
        // Sort keys
        $sort_days = $request->variable('st', 0);
        $sort_key = $request->variable('sk', 'i');
        $sort_dir = $request->variable('sd', 'd');
        $form_key = 'acp_inactive';
        add_form_key($form_key);
        /* @var $pagination \phpbb\pagination */
        $pagination = $phpbb_container->get('pagination');
        // We build the sort key and per page settings here, because they may be needed later
        // Number of entries to display
        $per_page = $request->variable('users_per_page', (int) $config['topics_per_page']);
        // Sorting
        $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
        $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']);
        $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded');
        $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        if ($submit && sizeof($mark)) {
            if ($action !== 'delete' && !check_form_key($form_key)) {
                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
            switch ($action) {
                case 'activate':
                case 'delete':
                    $sql = 'SELECT user_id, username
						FROM ' . USERS_TABLE . '
						WHERE ' . $db->sql_in_set('user_id', $mark);
                    $result = $db->sql_query($sql);
                    $user_affected = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $user_affected[$row['user_id']] = $row['username'];
                    }
                    $db->sql_freeresult($result);
                    if ($action == 'activate') {
                        // Get those 'being activated'...
                        $sql = 'SELECT user_id, username' . ($config['require_activation'] == USER_ACTIVATION_ADMIN ? ', user_email, user_lang' : '') . '
							FROM ' . USERS_TABLE . '
							WHERE ' . $db->sql_in_set('user_id', $mark) . '
								AND user_type = ' . USER_INACTIVE;
                        $result = $db->sql_query($sql);
                        $inactive_users = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $inactive_users[] = $row;
                        }
                        $db->sql_freeresult($result);
                        user_active_flip('activate', $mark);
                        if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users)) {
                            if (!class_exists('messenger')) {
                                include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                            }
                            $messenger = new messenger(false);
                            foreach ($inactive_users as $row) {
                                $messenger->template('admin_welcome_activated', $row['user_lang']);
                                $messenger->set_addresses($row);
                                $messenger->anti_abuse_headers($config, $user);
                                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username'])));
                                $messenger->send(NOTIFY_EMAIL);
                            }
                            $messenger->save_queue();
                        }
                        if (!empty($inactive_users)) {
                            foreach ($inactive_users as $row) {
                                $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_ACTIVE', false, array($row['username']));
                                $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_ACTIVE_USER', false, array('reportee_id' => $row['user_id']));
                            }
                            trigger_error(sprintf($user->lang['LOG_INACTIVE_ACTIVATE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
                        }
                        // For activate we really need to redirect, else a refresh can result in users being deactivated again
                        $u_action = $this->u_action . "&amp;{$u_sort_param}&amp;start={$start}";
                        $u_action .= $per_page != $config['topics_per_page'] ? "&amp;users_per_page={$per_page}" : '';
                        redirect($u_action);
                    } else {
                        if ($action == 'delete') {
                            if (confirm_box(true)) {
                                if (!$auth->acl_get('a_userdel')) {
                                    trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                                }
                                user_delete('retain', $mark, true);
                                $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_INACTIVE_' . strtoupper($action), false, array(implode(', ', $user_affected)));
                                trigger_error(sprintf($user->lang['LOG_INACTIVE_DELETE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
                            } else {
                                $s_hidden_fields = array('mode' => $mode, 'action' => $action, 'mark' => $mark, 'submit' => 1, 'start' => $start);
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
                            }
                        }
                    }
                    break;
                case 'remind':
                    if (empty($config['email_enable'])) {
                        trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
						FROM ' . USERS_TABLE . '
						WHERE ' . $db->sql_in_set('user_id', $mark) . '
							AND user_inactive_reason';
                    $sql .= $config['require_activation'] == USER_ACTIVATION_ADMIN ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL;
                    $result = $db->sql_query($sql);
                    if ($row = $db->sql_fetchrow($result)) {
                        // Send the messages
                        if (!class_exists('messenger')) {
                            include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                        }
                        $messenger = new messenger();
                        $usernames = $user_ids = array();
                        do {
                            $messenger->template('user_remind_inactive', $row['user_lang']);
                            $messenger->set_addresses($row);
                            $messenger->anti_abuse_headers($config, $user);
                            $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), 'U_ACTIVATE' => generate_board_url() . "/ucp.{$phpEx}?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']));
                            $messenger->send($row['user_notify_type']);
                            $usernames[] = $row['username'];
                            $user_ids[] = (int) $row['user_id'];
                        } while ($row = $db->sql_fetchrow($result));
                        $messenger->save_queue();
                        // Add the remind state to the database
                        $sql = 'UPDATE ' . USERS_TABLE . '
							SET user_reminded = user_reminded + 1,
								user_reminded_time = ' . time() . '
							WHERE ' . $db->sql_in_set('user_id', $user_ids);
                        $db->sql_query($sql);
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_INACTIVE_REMIND', false, array(implode(', ', $usernames)));
                        trigger_error(sprintf($user->lang['LOG_INACTIVE_REMIND'], implode($user->lang['COMMA_SEPARATOR'], $usernames) . ' ' . adm_back_link($this->u_action)));
                    }
                    $db->sql_freeresult($result);
                    // For remind we really need to redirect, else a refresh can result in more than one reminder
                    $u_action = $this->u_action . "&amp;{$u_sort_param}&amp;start={$start}";
                    $u_action .= $per_page != $config['topics_per_page'] ? "&amp;users_per_page={$per_page}" : '';
                    redirect($u_action);
                    break;
            }
        }
        // Define where and sort sql for use in displaying logs
        $sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
        $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        $inactive = array();
        $inactive_count = 0;
        $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort);
        foreach ($inactive as $row) {
            $template->assign_block_vars('inactive', array('INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => !$row['user_lastvisit'] ? ' - ' : $user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'POSTS' => $row['user_posts'] ? $row['user_posts'] : 0, 'REMINDED' => $row['user_reminded'], 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=users&amp;mode=overview&amp;redirect=acp_inactive')), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USER_EMAIL' => $row['user_email'], 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&amp;mode=overview&amp;u={$row['user_id']}"), 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$row['user_id']}&amp;sr=posts") : ''));
        }
        $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
        if ($config['email_enable']) {
            $option_ary += array('remind' => 'REMIND');
        }
        $base_url = $this->u_action . "&amp;{$u_sort_param}&amp;users_per_page={$per_page}";
        $pagination->generate_template_pagination($base_url, 'pagination', 'start', $inactive_count, $per_page, $start);
        $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'USERS_PER_PAGE' => $per_page, 'U_ACTION' => $this->u_action . "&amp;{$u_sort_param}&amp;users_per_page={$per_page}&amp;start={$start}"));
        $this->tpl_name = 'acp_inactive';
        $this->page_title = 'ACP_INACTIVE_USERS';
    }
Ejemplo n.º 20
0
    /**
     * Display website list for (dis)approval
     *
     * @return null
     */
    public function display_websites()
    {
        global $phpbb_admin_path;
        // Sort keys
        $sort_days = $this->request->variable('st', 0);
        $sort_key = $this->request->variable('sk', 't');
        $sort_dir = $this->request->variable('sd', 'd');
        // Number of entries to display
        $per_page = $this->request->variable('links_per_page', (int) $this->config['dir_show']);
        $start = $this->request->variable('start', 0);
        // Categorie ordering options
        $limit_days = array(0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']);
        $sort_by_text = array('a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME']);
        $sort_by_sql = array('a' => 'u.username_clean', 't' => array('l.link_time', 'l.link_id'));
        $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        // Define where and sort sql for use in displaying logs
        $sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
        $direction = $sort_dir == 'd' ? 'DESC' : 'ASC';
        if (is_array($sort_by_sql[$sort_key])) {
            $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
        } else {
            $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
        }
        $sql = 'SELECT COUNT(1) AS total_links
			FROM ' . DIR_LINK_TABLE . '
			WHERE link_active = 0' . ($sql_where ? " AND link_time >= {$sql_where}" : '');
        $result = $this->db->sql_query($sql);
        $total_links = (int) $this->db->sql_fetchfield('total_links');
        $this->db->sql_freeresult($result);
        // Make sure $start is set to the last page if it exceeds the amount
        $start = $this->pagination->validate_start($start, $per_page, $total_links);
        $sql_array = array('SELECT' => 'l.link_id, l.link_name, l.link_url, l.link_description, l.link_cat, l.link_user_id, l.link_guest_email, l.link_uid, l.link_bitfield, l.link_flags, l.link_banner, l.link_time, c.cat_name, u.user_id, u.username, u.user_colour', 'FROM' => array(DIR_LINK_TABLE => 'l'), 'LEFT_JOIN' => array(array('FROM' => array(DIR_CAT_TABLE => 'c'), 'ON' => 'c.cat_id = l.link_cat'), array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = l.link_user_id')), 'WHERE' => 'l.link_active = 0' . ($sql_where ? " AND l.link_time >= {$sql_where}" : ''), 'ORDER_BY' => $sql_sort_order);
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query_limit($sql, $per_page, $start);
        while ($row = $this->db->sql_fetchrow($result)) {
            $s_banner = $this->link->display_bann($row);
            $username = $row['link_user_id'] == ANONYMOUS ? $row['link_guest_email'] : $row['username'];
            $link_row = array('LINK_URL' => $row['link_url'], 'LINK_NAME' => $row['link_name'], 'LINK_DESC' => generate_text_for_display($row['link_description'], $row['link_uid'], $row['link_bitfield'], $row['link_flags']), 'L_DIR_USER_PROP' => $this->user->lang('DIR_USER_PROP', get_username_string('full', $row['link_user_id'], $username, $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.{$this->php_ext}", 'i=users&amp;mode=overview')), '<select name=c' . $row['link_id'] . '>' . $this->categorie->make_cat_select((int) $row['link_cat']) . '</select>', $this->user->format_date($row['link_time'])), 'BANNER' => $s_banner, 'LINK_ID' => $row['link_id']);
            $this->template->assign_block_vars('linkrow', $link_row);
        }
        $this->db->sql_freeresult($result);
        $option_ary = array('approved' => 'DIR_LINK_ACTIVATE', 'disapproved' => 'DIR_LINK_DELETE');
        $base_url = $this->u_action . "&amp;{$u_sort_param}&amp;links_per_page={$per_page}";
        $this->pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_links, $per_page, $start);
        $this->template->assign_vars(array('S_LINKS_OPTIONS' => build_select($option_ary), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'LINKS_PER_PAGE' => $per_page, 'U_ACTION' => $this->u_action . "&amp;{$u_sort_param}&amp;links_per_page={$per_page}&amp;start={$start}"));
    }
Ejemplo n.º 21
0
 public function select_helper()
 {
     return build_select(array('1' => 'First_Option', '2' => 'Second_Option', '3' => 'Third_Option'), '2');
 }
Ejemplo n.º 22
0
        foreach ($sql as $row) {
            $user_id_sql[] = ',' . $row['ban_userid'];
        }
        $user_id_sql = join('', $user_id_sql);
        if ($group_id != -1) {
            $user_list = DB()->fetch_rowset("\n\t\t\t\tSELECT u.username, u.user_email, u.user_lang\n\t\t\t\tFROM " . BB_USERS . " u, " . BB_USER_GROUP . " ug\n\t\t\t\tWHERE ug.group_id = {$group_id}\n\t\t\t\t\tAND ug.user_pending = 0\n\t\t\t\t\tAND u.user_id = ug.user_id\n\t\t\t\t\tAND u.user_active = 1\n\t\t\t\t\tAND u.user_id NOT IN(" . EXCLUDED_USERS_CSV . $user_id_sql . ")\n\t\t\t");
        } else {
            $user_list = DB()->fetch_rowset("\n\t\t\t\tSELECT username, user_email, user_lang\n\t\t\t\tFROM " . BB_USERS . "\n\t\t\t\tWHERE user_active = 1\n\t\t\t\t\tAND user_id NOT IN(" . EXCLUDED_USERS_CSV . $user_id_sql . ")\n\t\t\t");
        }
        require CLASS_DIR . 'emailer.php';
        foreach ($user_list as $i => $row) {
            $emailer = new emailer($bb_cfg['smtp_delivery']);
            $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>");
            $emailer->email_address($row['username'] . " <{$row['user_email']}>");
            $emailer->use_template('admin_send_email');
            $emailer->assign_vars(array('SUBJECT' => html_entity_decode($subject), 'MESSAGE' => html_entity_decode($message)));
            $emailer->send();
            $emailer->reset();
        }
    }
}
//
// Generate page
//
$sql = "SELECT group_id, group_name\n\tFROM " . BB_GROUPS . "\n\tWHERE group_single_user = 0\n\tORDER BY group_name\n";
$groups = array('-- ' . $lang['ALL_USERS'] . ' --' => -1);
foreach (DB()->fetch_rowset($sql) as $row) {
    $groups[$row['group_name']] = $row['group_id'];
}
$template->assign_vars(array('MESSAGE' => $message, 'SUBJECT' => $subject, 'ERROR_MESSAGE' => $errors ? join('<br />', array_unique($errors)) : '', 'S_USER_ACTION' => 'admin_mass_email.php', 'S_GROUP_SELECT' => build_select(POST_GROUPS_URL, $groups)));
print_page('admin_mass_email.tpl', 'admin');
Ejemplo n.º 23
0
function disp_encryption()
{
    global $GLOB_disp_network_default_fields;
    $html = '';
    $sel = array('id' => 'VPN_ENCRYPTION', 'selected' => $settings['VPN_ENCRYPTION'], array('AES-128-CBC', 'AES-128-CBC (default)'), array('AES-256-CBC', 'AES-256-CBC'), array('BF-CBC', 'Blowfish-CBC'));
    $html .= '<tr><td>VPN encryption</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $GLOB_disp_network_default_fields .= 'VPN_ENCRYPTION,';
    $sel = array('id' => 'VPN_AUTHENTICATION', 'selected' => $settings['VPN_AUTHENTICATION'], array('SHA1', 'SHA1 (160bit) - (default)'), array('SHA256', 'SHA256 (256bit)'));
    $html .= '<tr><td>VPN authentication</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $GLOB_disp_network_default_fields .= 'VPN_AUTHENTICATION,';
    $sel = array('id' => 'VPN_HANDSHAKE', 'selected' => $settings['VPN_HANDSHAKE'], array('RSA-2048', 'RSA 2048bit (default)'), array('RSA-3072', 'RSA 3072bit'), array('RSA-4096', 'RSA 4096bit'), array('ECC-256k1', 'ECC secp256k1 256bit'), array('ECC-256r1', 'ECC secp256r1 256bit'), array('ECC-521', 'ECC secp521r1 521bit'));
    $html .= '<tr><td>Handshake encryption</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $GLOB_disp_network_default_fields .= 'VPN_HANDSHAKE,';
    $sel = array('id' => 'VPN_LOGLEVEL', 'selected' => $settings['VPN_LOGLEVEL'], array('1', '1 (default)'), array('4', '4'), array('6', '6 (debug)'), array('9', '9 (extreme)'));
    $html .= '<tr><td>VPN log verbosity</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $GLOB_disp_network_default_fields .= 'VPN_LOGLEVEL,';
    return $html;
}
Ejemplo n.º 24
0
         }
     }
     break;
     /**
      *  Пол (edit, reg)
      */
 /**
  *  Пол (edit, reg)
  */
 case 'user_gender':
     $user_gender = isset($_POST['user_gender']) ? (int) $_POST['user_gender'] : $pr_data['user_gender'];
     if ($submit && $user_gender != $pr_data['user_gender']) {
         $pr_data['user_gender'] = $user_gender;
         $db_data['user_gender'] = $user_gender;
     }
     $tp_data['USER_GENDER'] = build_select('user_gender', array_flip($lang['GENDER_SELECT']), $pr_data['user_gender']);
     break;
     /**
      *  Возраст (edit)
      */
 /**
  *  Возраст (edit)
  */
 case 'user_birthday':
     $user_birthday = isset($_POST['user_birthday']) ? (string) $_POST['user_birthday'] : $pr_data['user_birthday'];
     if ($submit && $user_birthday != $pr_data['user_birthday']) {
         $birthday_date = date_parse($user_birthday);
         if (!empty($birthday_date['year'])) {
             if (strtotime($user_birthday) >= TIMENOW) {
                 $errors[] = $lang['WRONG_BIRTHDAY_FORMAT'];
             } elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > $bb_cfg['birthday_max_age']) {
Ejemplo n.º 25
0
    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx;
        // Show restore permissions notice
        if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) {
            $this->tpl_name = 'acp_main';
            $this->page_title = 'ACP_MAIN';
            $sql = 'SELECT user_id, username, user_colour
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . $user->data['user_perm_from'];
            $result = $db->sql_query($sql);
            $user_row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $perm_from = '<strong' . ($user_row['user_colour'] ? ' style="color: #' . $user_row['user_colour'] . '">' : '>');
            $perm_from .= $user_row['user_id'] != ANONYMOUS ? '<a href="' . append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&amp;u=' . $user_row['user_id']) . '">' : '';
            $perm_from .= $user_row['username'];
            $perm_from .= $user_row['user_id'] != ANONYMOUS ? '</a>' : '';
            $perm_from .= '</strong>';
            $template->assign_vars(array('S_RESTORE_PERMISSIONS' => true, 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm'), 'PERM_FROM' => $perm_from, 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm'))));
            return;
        }
        $action = request_var('action', '');
        if ($action) {
            if ($action === 'admlogout') {
                $user->unset_admin();
                $redirect_url = append_sid("{$phpbb_root_path}index.{$phpEx}");
                meta_refresh(3, $redirect_url);
                trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>'));
            }
            if (!confirm_box(true)) {
                switch ($action) {
                    case 'online':
                        $confirm = true;
                        $confirm_lang = 'RESET_ONLINE_CONFIRM';
                        break;
                    case 'stats':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_STATS_CONFIRM';
                        break;
                    case 'user':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM';
                        break;
                    case 'date':
                        $confirm = true;
                        $confirm_lang = 'RESET_DATE_CONFIRM';
                        break;
                    case 'db_track':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM';
                        break;
                    case 'purge_cache':
                        $confirm = true;
                        $confirm_lang = 'PURGE_CACHE_CONFIRM';
                        break;
                    default:
                        $confirm = true;
                        $confirm_lang = 'CONFIRM_OPERATION';
                }
                if ($confirm) {
                    confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action)));
                }
            } else {
                switch ($action) {
                    case 'online':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        set_config('record_online_users', 1, true);
                        set_config('record_online_date', time(), true);
                        add_log('admin', 'LOG_RESET_ONLINE');
                        break;
                    case 'stats':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $sql = 'SELECT COUNT(post_id) AS stat
							FROM ' . POSTS_TABLE . '
							WHERE post_approved = 1';
                        $result = $db->sql_query($sql);
                        set_config('num_posts', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(topic_id) AS stat
							FROM ' . TOPICS_TABLE . '
							WHERE topic_approved = 1';
                        $result = $db->sql_query($sql);
                        set_config('num_topics', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(user_id) AS stat
							FROM ' . USERS_TABLE . '
							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
                        $result = $db->sql_query($sql);
                        set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(attach_id) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT SUM(filesize) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        set_config('upload_dir_size', (double) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        if (!function_exists('update_last_username')) {
                            include $phpbb_root_path . "includes/functions_user.{$phpEx}";
                        }
                        update_last_username();
                        add_log('admin', 'LOG_RESYNC_STATS');
                        break;
                    case 'user':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        // Resync post counts
                        $start = $max_post_id = 0;
                        // Find the maximum post ID, we can only stop the cycle when we've reached it
                        $sql = 'SELECT MAX(forum_last_post_id) as max_post_id
							FROM ' . FORUMS_TABLE;
                        $result = $db->sql_query($sql);
                        $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                        $db->sql_freeresult($result);
                        // No maximum post id? :o
                        if (!$max_post_id) {
                            $sql = 'SELECT MAX(post_id)
								FROM ' . POSTS_TABLE;
                            $result = $db->sql_query($sql);
                            $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                            $db->sql_freeresult($result);
                        }
                        // Still no maximum post id? Then we are finished
                        if (!$max_post_id) {
                            add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
                            break;
                        }
                        $step = $config['num_posts'] ? max((int) ($config['num_posts'] / 5), 20000) : 20000;
                        $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
                        while ($start < $max_post_id) {
                            $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
								FROM ' . POSTS_TABLE . '
								WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
									AND post_postcount = 1 AND post_approved = 1
								GROUP BY poster_id';
                            $result = $db->sql_query($sql);
                            if ($row = $db->sql_fetchrow($result)) {
                                do {
                                    $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
                                    $db->sql_query($sql);
                                } while ($row = $db->sql_fetchrow($result));
                            }
                            $db->sql_freeresult($result);
                            $start += $step;
                        }
                        add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
                        break;
                    case 'date':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        set_config('board_startdate', time() - 1);
                        add_log('admin', 'LOG_RESET_DATE');
                        break;
                    case 'db_track':
                        switch ($db->sql_layer) {
                            case 'sqlite':
                            case 'firebird':
                                $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
                                break;
                            default:
                                $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
                                break;
                        }
                        // This can get really nasty... therefore we only do the last six months
                        $get_from_time = time() - 6 * 4 * 7 * 24 * 60 * 60;
                        // Select forum ids, do not include categories
                        $sql = 'SELECT forum_id
							FROM ' . FORUMS_TABLE . '
							WHERE forum_type <> ' . FORUM_CAT;
                        $result = $db->sql_query($sql);
                        $forum_ids = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $forum_ids[] = $row['forum_id'];
                        }
                        $db->sql_freeresult($result);
                        // Any global announcements? ;)
                        $forum_ids[] = 0;
                        // Now go through the forums and get us some topics...
                        foreach ($forum_ids as $forum_id) {
                            $sql = 'SELECT p.poster_id, p.topic_id
								FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
								WHERE t.forum_id = ' . $forum_id . '
									AND t.topic_moved_id = 0
									AND t.topic_last_post_time > ' . $get_from_time . '
									AND t.topic_id = p.topic_id
									AND p.poster_id <> ' . ANONYMOUS . '
								GROUP BY p.poster_id, p.topic_id';
                            $result = $db->sql_query($sql);
                            $posted = array();
                            while ($row = $db->sql_fetchrow($result)) {
                                $posted[$row['poster_id']][] = $row['topic_id'];
                            }
                            $db->sql_freeresult($result);
                            $sql_ary = array();
                            foreach ($posted as $user_id => $topic_row) {
                                foreach ($topic_row as $topic_id) {
                                    $sql_ary[] = array('user_id' => (int) $user_id, 'topic_id' => (int) $topic_id, 'topic_posted' => 1);
                                }
                            }
                            unset($posted);
                            if (sizeof($sql_ary)) {
                                $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
                            }
                        }
                        add_log('admin', 'LOG_RESYNC_POST_MARKING');
                        break;
                    case 'purge_cache':
                        if ((int) $user->data['user_type'] !== USER_FOUNDER) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        global $cache;
                        $cache->purge();
                        // Clear permissions
                        $auth->acl_clear_prefetch();
                        cache_moderators();
                        add_log('admin', 'LOG_PURGE_CACHE');
                        break;
                }
            }
        }
        // Get forum statistics
        $total_posts = $config['num_posts'];
        $total_topics = $config['num_topics'];
        $total_users = $config['num_users'];
        $total_files = $config['num_files'];
        $start_date = $user->format_date($config['board_startdate']);
        $boarddays = (time() - $config['board_startdate']) / 86400;
        $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
        $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
        $users_per_day = sprintf('%.2f', $total_users / $boarddays);
        $files_per_day = sprintf('%.2f', $total_files / $boarddays);
        $upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
        $avatar_dir_size = 0;
        if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) {
            while (($file = readdir($avatar_dir)) !== false) {
                if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) {
                    $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
                }
            }
            closedir($avatar_dir);
            $avatar_dir_size = get_formatted_filesize($avatar_dir_size);
        } else {
            // Couldn't open Avatar dir.
            $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
        }
        if ($posts_per_day > $total_posts) {
            $posts_per_day = $total_posts;
        }
        if ($topics_per_day > $total_topics) {
            $topics_per_day = $total_topics;
        }
        if ($users_per_day > $total_users) {
            $users_per_day = $total_users;
        }
        if ($files_per_day > $total_files) {
            $files_per_day = $total_files;
        }
        if ($config['allow_attachments'] || $config['allow_pm_attach']) {
            $sql = 'SELECT COUNT(attach_id) AS total_orphan
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE is_orphan = 1
					AND filetime < ' . (time() - 3 * 60 * 60);
            $result = $db->sql_query($sql);
            $total_orphan = (int) $db->sql_fetchfield('total_orphan');
            $db->sql_freeresult($result);
        } else {
            $total_orphan = false;
        }
        $dbsize = get_database_size();
        $template->assign_vars(array('TOTAL_POSTS' => $total_posts, 'POSTS_PER_DAY' => $posts_per_day, 'TOTAL_TOPICS' => $total_topics, 'TOPICS_PER_DAY' => $topics_per_day, 'TOTAL_USERS' => $total_users, 'USERS_PER_DAY' => $users_per_day, 'TOTAL_FILES' => $total_files, 'FILES_PER_DAY' => $files_per_day, 'START_DATE' => $start_date, 'AVATAR_DIR_SIZE' => $avatar_dir_size, 'DBSIZE' => $dbsize, 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'TOTAL_ORPHAN' => $total_orphan, 'S_TOTAL_ORPHAN' => $total_orphan === false ? false : true, 'GZIP_COMPRESSION' => $config['gzip_compress'] ? $user->lang['ON'] : $user->lang['OFF'], 'DATABASE_INFO' => $db->sql_server_info(), 'BOARD_VERSION' => $config['version'], 'U_ACTION' => $this->u_action, 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=admin'), 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=inactive&amp;mode=list'), 'S_ACTION_OPTIONS' => $auth->acl_get('a_board') ? true : false, 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false));
        $log_data = array();
        $log_count = 0;
        if ($auth->acl_get('a_viewlogs')) {
            view_log('admin', $log_data, $log_count, 5);
            foreach ($log_data as $row) {
                $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action']));
            }
        }
        if ($auth->acl_get('a_user')) {
            $inactive = array();
            $inactive_count = 0;
            view_inactive_users($inactive, $inactive_count, 10);
            foreach ($inactive as $row) {
                $template->assign_block_vars('inactive', array('INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => !$row['user_lastvisit'] ? ' - ' : $user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'USERNAME' => $row['username'], 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&amp;mode=overview&amp;u={$row['user_id']}")));
            }
            $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
            if ($config['email_enable']) {
                $option_ary += array('remind' => 'REMIND');
            }
            $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary)));
        }
        // Warn if install is still present
        if (file_exists($phpbb_root_path . 'install')) {
            $template->assign_var('S_REMOVE_INSTALL', true);
        }
        if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) {
            // World-Writable? (000x)
            $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x2));
        }
        $this->tpl_name = 'acp_main';
        $this->page_title = 'ACP_MAIN';
    }
Ejemplo n.º 26
0
/**
 * generates a setup UI for the user
 * @global PIASettings $_settings
 */
function disp_wizard_default()
{
    global $_settings;
    global $_pia;
    $settings = $_settings->get_settings();
    $disp_body = '';
    $fields = '';
    //comma separate list of settings offered here
    $disp_body .= '<div class="box wizard">';
    $disp_body .= '<form action="/?page=config&amp;cmd=store_setting" method="post">' . "\n";
    $disp_body .= '<input type="hidden" name="store" value="dhcpd_settings">';
    $disp_body .= '<h2>PIA-Tunnel Setup Wizard</h2>' . "\n";
    //web UI account
    $disp_body .= 'Please enter a username and password for logging into the Web-UI<br>';
    $disp_body .= "<table>\n";
    $disp_body .= '<tr><td>Web-UI Username</td><td><input type="text" style="width: 15em" name="WEB_UI_USER" value="" placeholder="Username for the Web-UI" required></td>';
    $disp_body .= '<tr><td>Web-UI Password</td><td><input type="password" style="width: 15em" name="WEB_UI_PASSWORD" value="" placeholder="Password for the Web-UI" required></td>';
    $disp_body .= "</table>\n";
    $disp_body .= '<input type="hidden" name="WEB_UI_NAMESPACE" value="' . $_pia->rand_string(10) . '">';
    $disp_body .= '<input type="hidden" name="WEB_UI_COOKIE" value="' . $_pia->rand_string(20) . '">';
    $disp_body .= '<hr>';
    $fields .= 'WEB_UI_USER,WEB_UI_PASSWORD,WEB_UI_NAMESPACE,WEB_UI_COOKIE,';
    //username
    $disp_body .= '<p>Please enter your VPN account information for one provider.<br>' . 'You may configure additional accounts after the setup wizard is finished.</p>';
    $disp_body .= "<table>\n";
    $disp_body .= '<tr><td>VPN Provider</td><td>';
    $disp_body .= '<select name="vpn_provider">';
    $disp_body .= '<option value="PIAtcp">PrivateInternetAccess.com</option>';
    $disp_body .= '<option value="FrootVPN">FrootVPN.com</option>';
    $disp_body .= '</select>';
    $disp_body .= '</td>';
    $disp_body .= '<tr><td>VPN Account Username</td><td><input type="text" style="width: 15em" name="username" value="" placeholder="Your Account Username" required></td>';
    $disp_body .= '<tr><td>VPN Account Password</td><td><input type="password" style="width: 15em" name="password" value="" placeholder="Your Account Password" required></td>';
    $disp_body .= "</table>\n";
    $disp_body .= '<hr>';
    // Gateway
    $disp_body .= '<p>This virtual machine may act as a default gateway for your network and/or ' . 'a virtual private Lan.<br>' . 'The public LAN is your network, where your DSL/Cable router is connected.</p>';
    $disp_body .= "<table>\n";
    $fields .= 'FORWARD_PUBLIC_LAN,';
    $sel = array('id' => 'FORWARD_PUBLIC_LAN', 'selected' => $settings['FORWARD_PUBLIC_LAN'], array('yes', 'yes'), array('no', 'no'));
    $disp_body .= '<tr><td>VPN Gateway for public LAN</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $fields .= 'FORWARD_VM_LAN,';
    $sel = array('id' => 'FORWARD_VM_LAN', 'selected' => $settings['FORWARD_VM_LAN'], array('yes', 'yes'), array('no', 'no'));
    $disp_body .= '<tr><td>VPN Gateway for VM LAN</td><td>' . build_select($sel) . '</td></tr>' . "\n";
    $disp_body .= "</table>\n";
    $disp_body .= '<hr>';
    // set a proper root password
    $disp_body .= '<p>Please enter a new root password below or accept the generated one.' . 'You may reset the password at any time using the "Tools" menu.<br>' . 'Passwords may not be less than 3 characters long!</p>';
    $disp_body .= '<br><strong>WARNING</strong> The console is set to a German QWERTZ keyboard layout. Run "dpkg-reconfigure keyboard-configuration" to change the layout. (only required if you login to command line)';
    $disp_body .= "<table>\n";
    $disp_body .= '<tr><td>root password</td><td><input type="text" style="width:25em;" name="new_root_password" value="' . $_pia->rand_string(50) . '"></td></tr>' . "\n";
    $disp_body .= "</table>\n";
    $disp_body .= '<br><input type="submit" name="store settings" value="Store Settings">';
    $disp_body .= '<input type="hidden" name="store_fields" value="' . rtrim($fields, ',') . '">';
    $disp_body .= '</form>';
    $disp_body .= '</div>';
    $disp_body .= "<p>&nbsp;</p>\n";
    return $disp_body;
}
Ejemplo n.º 27
0
    function main($id, $mode)
    {
        global $config, $db, $cache, $user, $auth, $template, $request, $phpbb_log;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container, $phpbb_dispatcher, $phpbb_filesystem;
        // Show restore permissions notice
        if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) {
            $this->tpl_name = 'acp_main';
            $this->page_title = 'ACP_MAIN';
            $sql = 'SELECT user_id, username, user_colour
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . $user->data['user_perm_from'];
            $result = $db->sql_query($sql);
            $user_row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']);
            $template->assign_vars(array('S_RESTORE_PERMISSIONS' => true, 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm'), 'PERM_FROM' => $perm_from, 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm'))));
            return;
        }
        $action = $request->variable('action', '');
        if ($action) {
            if ($action === 'admlogout') {
                $user->unset_admin();
                redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
            }
            if (!confirm_box(true)) {
                switch ($action) {
                    case 'online':
                        $confirm = true;
                        $confirm_lang = 'RESET_ONLINE_CONFIRM';
                        break;
                    case 'stats':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_STATS_CONFIRM';
                        break;
                    case 'user':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM';
                        break;
                    case 'date':
                        $confirm = true;
                        $confirm_lang = 'RESET_DATE_CONFIRM';
                        break;
                    case 'db_track':
                        $confirm = true;
                        $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM';
                        break;
                    case 'purge_cache':
                        $confirm = true;
                        $confirm_lang = 'PURGE_CACHE_CONFIRM';
                        break;
                    case 'purge_sessions':
                        $confirm = true;
                        $confirm_lang = 'PURGE_SESSIONS_CONFIRM';
                        break;
                    default:
                        $confirm = true;
                        $confirm_lang = 'CONFIRM_OPERATION';
                }
                if ($confirm) {
                    confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action)));
                }
            } else {
                switch ($action) {
                    case 'online':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $config->set('record_online_users', 1, false);
                        $config->set('record_online_date', time(), false);
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_ONLINE');
                        if ($request->is_ajax()) {
                            trigger_error('RESET_ONLINE_SUCCESS');
                        }
                        break;
                    case 'stats':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $sql = 'SELECT COUNT(post_id) AS stat
							FROM ' . POSTS_TABLE . '
							WHERE post_visibility = ' . ITEM_APPROVED;
                        $result = $db->sql_query($sql);
                        $config->set('num_posts', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(topic_id) AS stat
							FROM ' . TOPICS_TABLE . '
							WHERE topic_visibility = ' . ITEM_APPROVED;
                        $result = $db->sql_query($sql);
                        $config->set('num_topics', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(user_id) AS stat
							FROM ' . USERS_TABLE . '
							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
                        $result = $db->sql_query($sql);
                        $config->set('num_users', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(attach_id) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        $config->set('num_files', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT SUM(filesize) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        $config->set('upload_dir_size', (double) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        if (!function_exists('update_last_username')) {
                            include $phpbb_root_path . "includes/functions_user.{$phpEx}";
                        }
                        update_last_username();
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_STATS');
                        if ($request->is_ajax()) {
                            trigger_error('RESYNC_STATS_SUCCESS');
                        }
                        break;
                    case 'user':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        // Resync post counts
                        $start = $max_post_id = 0;
                        // Find the maximum post ID, we can only stop the cycle when we've reached it
                        $sql = 'SELECT MAX(forum_last_post_id) as max_post_id
							FROM ' . FORUMS_TABLE;
                        $result = $db->sql_query($sql);
                        $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                        $db->sql_freeresult($result);
                        // No maximum post id? :o
                        if (!$max_post_id) {
                            $sql = 'SELECT MAX(post_id) as max_post_id
								FROM ' . POSTS_TABLE;
                            $result = $db->sql_query($sql);
                            $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                            $db->sql_freeresult($result);
                        }
                        // Still no maximum post id? Then we are finished
                        if (!$max_post_id) {
                            $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS');
                            break;
                        }
                        $step = $config['num_posts'] ? max((int) ($config['num_posts'] / 5), 20000) : 20000;
                        $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
                        while ($start < $max_post_id) {
                            $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
								FROM ' . POSTS_TABLE . '
								WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
									AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . '
								GROUP BY poster_id';
                            $result = $db->sql_query($sql);
                            if ($row = $db->sql_fetchrow($result)) {
                                do {
                                    $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
                                    $db->sql_query($sql);
                                } while ($row = $db->sql_fetchrow($result));
                            }
                            $db->sql_freeresult($result);
                            $start += $step;
                        }
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS');
                        if ($request->is_ajax()) {
                            trigger_error('RESYNC_POSTCOUNTS_SUCCESS');
                        }
                        break;
                    case 'date':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $config->set('board_startdate', time() - 1);
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_DATE');
                        if ($request->is_ajax()) {
                            trigger_error('RESET_DATE_SUCCESS');
                        }
                        break;
                    case 'db_track':
                        switch ($db->get_sql_layer()) {
                            case 'sqlite':
                            case 'sqlite3':
                                $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
                                break;
                            default:
                                $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
                                break;
                        }
                        // This can get really nasty... therefore we only do the last six months
                        $get_from_time = time() - 6 * 4 * 7 * 24 * 60 * 60;
                        // Select forum ids, do not include categories
                        $sql = 'SELECT forum_id
							FROM ' . FORUMS_TABLE . '
							WHERE forum_type <> ' . FORUM_CAT;
                        $result = $db->sql_query($sql);
                        $forum_ids = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $forum_ids[] = $row['forum_id'];
                        }
                        $db->sql_freeresult($result);
                        // Any global announcements? ;)
                        $forum_ids[] = 0;
                        // Now go through the forums and get us some topics...
                        foreach ($forum_ids as $forum_id) {
                            $sql = 'SELECT p.poster_id, p.topic_id
								FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
								WHERE t.forum_id = ' . $forum_id . '
									AND t.topic_moved_id = 0
									AND t.topic_last_post_time > ' . $get_from_time . '
									AND t.topic_id = p.topic_id
									AND p.poster_id <> ' . ANONYMOUS . '
								GROUP BY p.poster_id, p.topic_id';
                            $result = $db->sql_query($sql);
                            $posted = array();
                            while ($row = $db->sql_fetchrow($result)) {
                                $posted[$row['poster_id']][] = $row['topic_id'];
                            }
                            $db->sql_freeresult($result);
                            $sql_ary = array();
                            foreach ($posted as $user_id => $topic_row) {
                                foreach ($topic_row as $topic_id) {
                                    $sql_ary[] = array('user_id' => (int) $user_id, 'topic_id' => (int) $topic_id, 'topic_posted' => 1);
                                }
                            }
                            unset($posted);
                            if (sizeof($sql_ary)) {
                                $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
                            }
                        }
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POST_MARKING');
                        if ($request->is_ajax()) {
                            trigger_error('RESYNC_POST_MARKING_SUCCESS');
                        }
                        break;
                    case 'purge_cache':
                        $config->increment('assets_version', 1);
                        $cache->purge();
                        // Remove old renderers from the text_formatter service. Since this
                        // operation is performed after the cache is purged, there is not "current"
                        // renderer and in effect all renderers will be purged
                        $phpbb_container->get('text_formatter.cache')->tidy();
                        // Clear permissions
                        $auth->acl_clear_prefetch();
                        phpbb_cache_moderators($db, $cache, $auth);
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_CACHE');
                        if ($request->is_ajax()) {
                            trigger_error('PURGE_CACHE_SUCCESS');
                        }
                        break;
                    case 'purge_sessions':
                        if ((int) $user->data['user_type'] !== USER_FOUNDER) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $tables = array(CONFIRM_TABLE, SESSIONS_TABLE);
                        foreach ($tables as $table) {
                            switch ($db->get_sql_layer()) {
                                case 'sqlite':
                                case 'sqlite3':
                                    $db->sql_query("DELETE FROM {$table}");
                                    break;
                                default:
                                    $db->sql_query("TRUNCATE TABLE {$table}");
                                    break;
                            }
                        }
                        // let's restore the admin session
                        $reinsert_ary = array('session_id' => (string) $user->session_id, 'session_page' => (string) substr($user->page['page'], 0, 199), 'session_forum_id' => $user->page['forum'], 'session_user_id' => (int) $user->data['user_id'], 'session_start' => (int) $user->data['session_start'], 'session_last_visit' => (int) $user->data['session_last_visit'], 'session_time' => (int) $user->time_now, 'session_browser' => (string) trim(substr($user->browser, 0, 149)), 'session_forwarded_for' => (string) $user->forwarded_for, 'session_ip' => (string) $user->ip, 'session_autologin' => (int) $user->data['session_autologin'], 'session_admin' => 1, 'session_viewonline' => (int) $user->data['session_viewonline']);
                        $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary);
                        $db->sql_query($sql);
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_SESSIONS');
                        if ($request->is_ajax()) {
                            trigger_error('PURGE_SESSIONS_SUCCESS');
                        }
                        break;
                }
            }
        }
        // Version check
        $user->add_lang('install');
        if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.4', '<')) {
            $template->assign_vars(array('S_PHP_VERSION_OLD' => true, 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '<a href="https://www.phpbb.com/community/viewtopic.php?f=14&amp;t=2152375">', '</a>')));
        }
        if ($auth->acl_get('a_board')) {
            /* @var $version_helper \phpbb\version_helper */
            $version_helper = $phpbb_container->get('version_helper');
            try {
                $recheck = $request->variable('versioncheck_force', false);
                $updates_available = $version_helper->get_suggested_updates($recheck);
                $template->assign_var('S_VERSION_UP_TO_DATE', empty($updates_available));
            } catch (\RuntimeException $e) {
                $template->assign_vars(array('S_VERSIONCHECK_FAIL' => true, 'VERSIONCHECK_FAIL_REASON' => $e->getMessage() !== $user->lang('VERSIONCHECK_FAIL') ? $e->getMessage() : ''));
            }
        } else {
            // We set this template var to true, to not display an outdated version notice.
            $template->assign_var('S_VERSION_UP_TO_DATE', true);
        }
        /**
         * Notice admin
         *
         * @event core.acp_main_notice
         * @since 3.1.0-RC3
         */
        $phpbb_dispatcher->dispatch('core.acp_main_notice');
        // Get forum statistics
        $total_posts = $config['num_posts'];
        $total_topics = $config['num_topics'];
        $total_users = $config['num_users'];
        $total_files = $config['num_files'];
        $start_date = $user->format_date($config['board_startdate']);
        $boarddays = (time() - $config['board_startdate']) / 86400;
        $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
        $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
        $users_per_day = sprintf('%.2f', $total_users / $boarddays);
        $files_per_day = sprintf('%.2f', $total_files / $boarddays);
        $upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
        $avatar_dir_size = 0;
        if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) {
            while (($file = readdir($avatar_dir)) !== false) {
                if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) {
                    $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
                }
            }
            closedir($avatar_dir);
            $avatar_dir_size = get_formatted_filesize($avatar_dir_size);
        } else {
            // Couldn't open Avatar dir.
            $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
        }
        if ($posts_per_day > $total_posts) {
            $posts_per_day = $total_posts;
        }
        if ($topics_per_day > $total_topics) {
            $topics_per_day = $total_topics;
        }
        if ($users_per_day > $total_users) {
            $users_per_day = $total_users;
        }
        if ($files_per_day > $total_files) {
            $files_per_day = $total_files;
        }
        if ($config['allow_attachments'] || $config['allow_pm_attach']) {
            $sql = 'SELECT COUNT(attach_id) AS total_orphan
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE is_orphan = 1
					AND filetime < ' . (time() - 3 * 60 * 60);
            $result = $db->sql_query($sql);
            $total_orphan = (int) $db->sql_fetchfield('total_orphan');
            $db->sql_freeresult($result);
        } else {
            $total_orphan = false;
        }
        $dbsize = get_database_size();
        $template->assign_vars(array('TOTAL_POSTS' => $total_posts, 'POSTS_PER_DAY' => $posts_per_day, 'TOTAL_TOPICS' => $total_topics, 'TOPICS_PER_DAY' => $topics_per_day, 'TOTAL_USERS' => $total_users, 'USERS_PER_DAY' => $users_per_day, 'TOTAL_FILES' => $total_files, 'FILES_PER_DAY' => $files_per_day, 'START_DATE' => $start_date, 'AVATAR_DIR_SIZE' => $avatar_dir_size, 'DBSIZE' => $dbsize, 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'TOTAL_ORPHAN' => $total_orphan, 'S_TOTAL_ORPHAN' => $total_orphan === false ? false : true, 'GZIP_COMPRESSION' => $config['gzip_compress'] && @extension_loaded('zlib') ? $user->lang['ON'] : $user->lang['OFF'], 'DATABASE_INFO' => $db->sql_server_info(), 'BOARD_VERSION' => $config['version'], 'U_ACTION' => $this->u_action, 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&amp;mode=admin'), 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=inactive&amp;mode=list'), 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=update&amp;mode=version_check'), 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'versioncheck_force=1'), 'S_VERSIONCHECK' => $auth->acl_get('a_board') ? true : false, 'S_ACTION_OPTIONS' => $auth->acl_get('a_board') ? true : false, 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false));
        $log_data = array();
        $log_count = false;
        if ($auth->acl_get('a_viewlogs')) {
            view_log('admin', $log_data, $log_count, 5);
            foreach ($log_data as $row) {
                $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action']));
            }
        }
        if ($auth->acl_get('a_user')) {
            $user->add_lang('memberlist');
            $inactive = array();
            $inactive_count = 0;
            view_inactive_users($inactive, $inactive_count, 10);
            foreach ($inactive as $row) {
                $template->assign_block_vars('inactive', array('INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => !$row['user_lastvisit'] ? ' - ' : $user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'POSTS' => $row['user_posts'] ? $row['user_posts'] : 0, 'REMINDED' => $row['user_reminded'], 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=users&amp;mode=overview')), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&amp;mode=overview&amp;u={$row['user_id']}"), 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$row['user_id']}&amp;sr=posts") : ''));
            }
            $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
            if ($config['email_enable']) {
                $option_ary += array('remind' => 'REMIND');
            }
            $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary)));
        }
        // Warn if install is still present
        if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) {
            $template->assign_var('S_REMOVE_INSTALL', true);
        }
        // Warn if no search index is created
        if ($config['num_posts'] && class_exists($config['search_type'])) {
            $error = false;
            $search_type = $config['search_type'];
            $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
            if (!$search->index_created()) {
                $template->assign_vars(array('S_SEARCH_INDEX_MISSING' => true, 'L_NO_SEARCH_INDEX' => $user->lang('NO_SEARCH_INDEX', $search->get_name(), '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=acp_search&amp;mode=index') . '">', '</a>')));
            }
        }
        if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)) {
            // World-Writable? (000x)
            $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x2));
        }
        if (extension_loaded('mbstring')) {
            $template->assign_vars(array('S_MBSTRING_LOADED' => true, 'S_MBSTRING_FUNC_OVERLOAD_FAIL' => intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING), 'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => @ini_get('mbstring.encoding_translation') != 0, 'S_MBSTRING_HTTP_INPUT_FAIL' => !in_array(@ini_get('mbstring.http_input'), array('pass', '')), 'S_MBSTRING_HTTP_OUTPUT_FAIL' => !in_array(@ini_get('mbstring.http_output'), array('pass', ''))));
        }
        // Fill dbms version if not yet filled
        if (empty($config['dbms_version'])) {
            $config->set('dbms_version', $db->sql_server_info(true));
        }
        $this->tpl_name = 'acp_main';
        $this->page_title = 'ACP_MAIN';
    }
Ejemplo n.º 28
0
$chars_select = array();
foreach ($chars_opt as $val => $opt) {
    $chars_select[$opt['lang']] = $val;
}
$GPC = array('all_words' => array('allw', 1, CHBOX), 'cat' => array('c', null, REQUEST), 'chars' => array('ch', $show_all, SELECT), 'display_as' => array('dm', $as_topics, SELECT), 'dl_cancel' => array('dla', 0, CHBOX), 'dl_compl' => array('dlc', 0, CHBOX), 'dl_down' => array('dld', 0, CHBOX), 'dl_user_id' => array('dlu', $user_id, CHBOX), 'dl_will' => array('dlw', 0, CHBOX), 'forum' => array('f', $search_all, REQUEST), 'my_topics' => array('myt', 0, CHBOX), 'new' => array('new', 0, CHBOX), 'new_topics' => array('nt', 0, CHBOX), 'order' => array('o', $ord_posted, SELECT), 'poster_id' => array('uid', null, REQUEST), 'poster_name' => array('pn', null, REQUEST), 'sort' => array('s', $sort_desc, SELECT), 'text_match' => array('nm', null, REQUEST), 'time' => array('tm', $search_all, SELECT), 'title_only' => array('to', 0, CHBOX), 'topic' => array('t', null, REQUEST));
// Define all GPC vars with default values
foreach ($GPC as $var_name => $var_options) {
    $GLOBALS["{$var_name}_key"] = $var_options[KEY_NAME];
    $GLOBALS["{$var_name}_val"] = $var_options[DEF_VAL];
}
// Output basic page
if (empty($_GET) && empty($_POST)) {
    // Make forum select box
    $forum_select_mode = explode(',', $excluded_forums_csv);
    $forum_select = get_forum_select($forum_select_mode, "{$forum_key}[]", $search_all, $max_forum_name_len, $forum_select_size, 'style="width: 95%;"', $search_all);
    $template->assign_vars(array('TPL_SEARCH_MAIN' => true, 'PAGE_TITLE' => $lang['SEARCH'], 'POSTER_ID_KEY' => $poster_id_key, 'TEXT_MATCH_KEY' => $text_match_key, 'POSTER_NAME_KEY' => $poster_name_key, 'THIS_USER_ID' => $userdata['user_id'], 'THIS_USER_NAME' => addslashes($userdata['username']), 'SEARCH_ACTION' => "search.php", 'U_SEARCH_USER' => "search.php?mode=searchuser&amp;input_name={$poster_name_key}", 'ONLOAD_FOCUS_ID' => 'text_match_input', 'MY_TOPICS_ID' => 'my_topics', 'MY_TOPICS_CHBOX' => build_checkbox($my_topics_key, $lang['SEARCH_MY_TOPICS'], $my_topics_val, true, null, 'my_topics'), 'TITLE_ONLY_CHBOX' => build_checkbox($title_only_key, $lang['SEARCH_TITLES_ONLY'], true, $bb_cfg['disable_ft_search_in_posts']), 'ALL_WORDS_CHBOX' => build_checkbox($all_words_key, $lang['SEARCH_ALL_WORDS'], true), 'DL_CANCEL_CHBOX' => build_checkbox($dl_cancel_key, $lang['SEARCH_DL_CANCEL'], $dl_cancel_val, IS_GUEST, 'dlCancel'), 'DL_COMPL_CHBOX' => build_checkbox($dl_compl_key, $lang['SEARCH_DL_COMPLETE'], $dl_compl_val, IS_GUEST, 'dlComplete'), 'DL_DOWN_CHBOX' => build_checkbox($dl_down_key, $lang['SEARCH_DL_DOWN'], $dl_down_val, IS_GUEST, 'dlDown'), 'DL_WILL_CHBOX' => build_checkbox($dl_will_key, $lang['SEARCH_DL_WILL'], $dl_will_val, IS_GUEST, 'dlWill'), 'ONLY_NEW_CHBOX' => build_checkbox($new_key, $lang['BT_ONLY_NEW'], $new_val, IS_GUEST), 'NEW_TOPICS_CHBOX' => build_checkbox($new_topics_key, $lang['NEW_TOPICS'], $new_topics_val, IS_GUEST), 'FORUM_SELECT' => $forum_select, 'TIME_SELECT' => build_select($time_key, $time_select, $time_val), 'ORDER_SELECT' => build_select($order_key, $order_select, $order_val), 'SORT_SELECT' => build_select($sort_key, $sort_select, $sort_val), 'CHARS_SELECT' => '', 'DISPLAY_AS_SELECT' => build_select($display_as_key, $display_as_select, $display_as_val)));
    print_page('search.tpl');
}
unset($forums);
$datastore->rm('cat_forums');
// Restore previously found items list and search settings if we have valid $search_id
if ($search_id) {
    $row = DB()->fetch_row("\n\t\tSELECT search_array, search_settings\n\t\tFROM " . BB_SEARCH . "\n\t\tWHERE session_id = '{$session_id}'\n\t\t\tAND search_type = " . SEARCH_TYPE_POST . "\n\t\t\tAND search_id = '{$search_id}'\n\t\tLIMIT 1\n\t");
    if (empty($row['search_settings'])) {
        bb_die($lang['SESSION_EXPIRED']);
    }
    $previous_settings = unserialize($row['search_settings']);
    $items_found = explode(',', $row['search_array']);
}
// Get simple "CHBOX" and "SELECT" type vars
foreach ($GPC as $name => $params) {