Exemplo n.º 1
0
function select_account()
{
    $accounts = get_auth_keys();
    //Show Account List
    if (count($accounts) < 1) {
        println("Please authenticate account.");
        println("eg) php auth_request.php");
        exit(1);
    }
    println("Please select the account.");
    foreach ($accounts as $screen_name => $token) {
        println(sprintf("@%s", $screen_name));
    }
    //input screen_name
    echo ">@";
    while (true) {
        //input
        $screen_name = strtolower(trim(read()));
        //authenticate user check
        if (!array_key_exists($screen_name, $accounts)) {
            println("Please select the authenticated account");
            echo ">@";
            continue;
        }
        break;
    }
    return ["screen_name" => $screen_name, "access_token" => $accounts[$screen_name]["access_token_key"], "access_token_secret" => $accounts[$screen_name]["access_token_secret"]];
}
Exemplo n.º 2
0
            $order = $tree['data'][$idx]['forum_order'] + $inc;
            // update the current one
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\t\t\tSET forum_order = " . $order . "\n\t\t\t\t\t\tWHERE forum_id = " . intval(substr($fid, 1));
            $db->sql_query($sql);
        }
    }
    // reorder
    reorder_tree();
    // add topics count and various informations
    get_user_tree($user->data);
    $mode = '';
}
// resync
if ($mode == 'resync') {
    $tkeys = array();
    $tkeys = get_auth_keys($fid, true);
    for ($i = 0; $i < sizeof($tkeys['id']); $i++) {
        $wid = $tkeys['id'][$i];
        if (substr($wid, 0, 1) == POST_FORUM_URL) {
            $class_mcp->sync('forum', intval(substr($wid, 1)));
        }
    }
    // reorder
    reorder_tree();
    // end message
    $message = $lang['Forums_updated'] . $return_msg;
    message_die(GENERAL_MESSAGE, $message);
    exit;
}
// handle edit
if ($mode == 'edit' || $mode == 'create' || $mode == 'delete') {
function announces_from_forums($cur = 'Root', $force_prune = false)
{
    global $db, $template, $board_config, $userdata, $phpEx, $lang, $images, $HTTP_COOKIE_VARS;
    global $tree;
    // fix and prune announces
    announces_prune($force_prune);
    // get the start point
    $type = POST_CAT_URL;
    $id = 0;
    if ($cur != 'Root') {
        $type = substr($cur, 0, 1);
        $id = intval(substr($cur, 1));
        if ($id == 0) {
            $type = POST_CAT_URL;
        }
    }
    // configuration
    $announce_index = isset($board_config['announcement_display']) ? intval($board_config['announcement_display']) : true;
    $announce_forum = isset($board_config['announcement_display_forum']) ? intval($board_config['announcement_display_forum']) : true;
    $announce = $type == POST_CAT_URL && $announce_index || $type == POST_FORUM_URL && $announce_forum;
    if (!$announce) {
        return false;
    }
    // read the forums authorized
    $auth_forum_ids = array();
    $tree_forum_ids = array();
    // get the current item selected
    $cid = $type . $id;
    // get the list of authorized forums except the current one
    for ($i = 0; $i < count($tree['id']); $i++) {
        $fid = $tree['type'][$i] . $tree['id'][$i];
        if ($fid != $cid && $tree['type'][$i] == POST_FORUM_URL && $tree['auth'][$fid]['auth_read']) {
            $auth_forum_ids[] = $tree['id'][$i];
        }
    }
    // no forums authed, return an error
    if (empty($auth_forum_ids)) {
        return false;
    }
    // get auth key
    $keys = array();
    $keys = get_auth_keys($cur, true, -1, -1, 'auth_read');
    $tree_forum_ids = array();
    for ($i = 1; $i < count($keys['id']); $i++) {
        $idx = $keys['idx'][$i];
        $fid = $keys['id'][$i];
        if ($fid != $cid && $tree['type'][$idx] == POST_FORUM_URL && $tree['auth'][$fid]['auth_read']) {
            $tree_forum_ids[] = $tree['id'][$idx];
        }
    }
    // go to root on this branch
    if (isset($tree['main'][$tree['keys'][$cur]])) {
        $fid = $tree['main'][$tree['keys'][$cur]];
        while ($fid != 'Root') {
            $idx = $tree['keys'][$fid];
            if ($fid != $cur && $tree['type'][$idx] == POST_FORUM_URL && $tree['auth'][$fid]['auth_read']) {
                $tree_forum_ids[] = $tree['id'][$idx];
            }
            $fid = isset($tree['main'][$idx]) ? $tree['main'][$idx] : 'Root';
        }
    }
    // select global
    $sql_where = '(t.topic_type=' . POST_GLOBAL_ANNOUNCE . ' AND t.forum_id IN (' . implode(', ', $auth_forum_ids) . '))';
    // select annonces
    if (!empty($tree_forum_ids)) {
        $sql_where .= ' OR (t.topic_type=' . POST_ANNOUNCE . ' AND t.forum_id IN (' . implode(', ', $tree_forum_ids) . '))';
    }
    // get topics data
    $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username, f.forum_name\n\t\t\tFROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2, " . FORUMS_TABLE . " f\n\t\t\tWHERE ({$sql_where})\n\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\tAND p.poster_id = u2.user_id\n\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\tORDER BY t.topic_type DESC, t.topic_last_post_id DESC ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
    }
    while ($row = $db->sql_fetchrow($result)) {
        $row['topic_id'] = POST_TOPIC_URL . $row['topic_id'];
        $topic_rowset[] = $row;
    }
    $db->sql_freeresult($result);
    if (count($topic_rowset) <= 0) {
        return false;
    }
    // send the list
    $footer = '';
    $allow_split_type = intval($board_config['announcement_split']) == 1;
    $display_nav_tree = intval($board_config['announcement_forum']) == 1;
    $inbox = false;
    topic_list('BOARD_ANNOUNCES', 'topics_list_box', $topic_rowset, $lang['Board_announcement'], $allow_split_type, $display_nav_tree, $footer, $inbox);
}
Exemplo n.º 4
0
    $auth = $auth->renewWithRequestToken("oob");
    $url = $auth->getAuthenticateUrl();
    println("Please Access and Authorize.");
    println($url);
    exec("open {$url}");
    println("Input PIN code.");
    echo ">";
    //input pin code
    while (true) {
        $pin = read();
        if (!preg_match("/^[0-9]......\$/", $pin)) {
            println("PIN code is incorrect.");
            println("Please enter the correct PIN code.");
            echo ">";
            continue;
        }
        break;
    }
    $auth = $auth->renewWithAccessToken($pin);
    //get screen_name
    $tweet = $auth->get("statuses/user_timeline", ["count" => 1]);
    $screen_name = strtolower($tweet[0]->user->screen_name);
    //get auth_key list
    $auth_keys = get_auth_keys();
    $auth_keys[$screen_name] = ["consumer_key" => $auth->ck, "consumer_secret" => $auth->cs, "access_token" => $auth->ot, "access_token_secret" => $auth->os];
    if (set_auth_keys($auth_keys)) {
        println("Authenticate Successful!");
    }
} catch (Exception $e) {
    println(sprintf("Exception: %s", $e->getMessage()));
}
Exemplo n.º 5
0
			unset($result_list);
			$total_match_count = sizeof($search_ids);
		}

		//
		// If user is logged in then we'll check to see which (if any) private
		// forums they are allowed to view and include them in the search.
		//
		// If not logged in we explicitly prevent searching of private forums
		//
		$auth_sql = '';
		// get the object list
		$keys = array();
		$keys = get_auth_keys($search_where, true, -1, -1, 'auth_read');
		$keys = get_auth_keys($search_where, true);
		$s_flist = '';
		for ($i = 0; $i < sizeof($keys['id']); $i++)
		{
			if (isset($tree['type'][$keys['idx'][$i]]) && ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL) && isset($tree['auth'][$keys['id'][$i]]['auth_read']) && $tree['auth'][$keys['id'][$i]]['auth_read'])
			{
				$s_flist .= (($s_flist != '') ? ', ' : '') . $tree['id'][$keys['idx'][$i]];
			}
		}

		if ($s_flist != '')
		{
			$auth_sql .= (($auth_sql != '') ? " AND" : '') . " f.forum_id IN ($s_flist) ";
			$auth_sql .= ($search_where_topic ? (" AND p.topic_id = " . $search_where_topic) : '');
		}
		else
Exemplo n.º 6
0
function get_event_topics(&$events, &$number, $start_date, $end_date, $limit = false, $start = 0, $max_limit = -1, $fid = '')
{
    global $tree, $template, $lang, $images, $user, $db, $cache, $config, $bbcode;
    if (!class_exists('bbcode')) {
        include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
    }
    if (empty($bbcode)) {
        $bbcode = new bbcode();
    }
    // get some parameter
    $topic_title_length = isset($config['calendar_title_length']) ? intval($config['calendar_title_length']) : 30;
    $topic_text_length = isset($config['calendar_text_length']) ? intval($config['calendar_text_length']) : 200;
    if ($max_limit < 0) {
        $max_limit = $config['topics_per_page'];
    }
    // get the forums authorized (compliency with categories hierarchy v2 mod)
    $cat_hierarchy = function_exists(get_auth_keys);
    $s_forums_ids = '';
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
        // forum or cat asked
        $is_ask = array();
        if ($fid == 'Root' || $fid == POST_CAT_URL . 0) {
            $fid = '';
        }
        if (!empty($fid)) {
            $type = substr($fid, 0, 1);
            $id = intval(substr($fid, 1));
            if ($type == POST_CAT_URL) {
                $sql = "SELECT forum_id FROM " . FORUMS_TABLE . " WHERE parent_id = '" . $id . "'";
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $is_ask[$row['forum_id']] = true;
                }
                $db->sql_freeresult($result);
            } elseif ($type == POST_FORUM_URL) {
                $is_ask[$id] = true;
            } else {
                return;
            }
        }
        // get the list of authorized forums
        while (list($forum_id, $forum_auth) = each($is_auth)) {
            if ($forum_auth['auth_read'] && (empty($fid) || isset($is_ask[$forum_id]))) {
                $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $forum_id;
            }
        }
    } else {
        if (empty($fid) || $fid == POST_CAT_URL . 0) {
            $fid = 'Root';
        }
        // get auth key
        $keys = array();
        $keys = get_auth_keys($fid, true, -1, -1, 'auth_read');
        for ($i = 0; $i < sizeof($keys['id']); $i++) {
            if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL && $tree['auth'][$keys['id'][$i]]['auth_read']) {
                $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $tree['id'][$keys['idx'][$i]];
            }
        }
    }
    // no forums authed, return
    if (empty($s_forum_ids)) {
        return;
    }
    // select topics
    $sql_forums_field = '';
    $sql_forums_file = '';
    $sql_forums_match = '';
    if (!$cat_hierarchy) {
        $sql_forums_field = ', f.forum_name';
        $sql_forums_file = ', ' . FORUMS_TABLE . ' AS f';
        $sql_forums_match = ' AND f.forum_id = t.forum_id';
    }
    $sql = "SELECT\n\t\t\t\t\tt.*,\n\t\t\t\t\tp.poster_id, p.post_username, p.post_text, p.enable_bbcode, p.enable_html, p.enable_smilies,\n\t\t\t\t\tu.username, u.user_active, u.user_color,\n\t\t\t\t\tlp.poster_id AS lp_poster_id,\n\t\t\t\t\tlu.username AS lp_username,\n\t\t\t\t\tlp.post_username AS lp_post_username,\n\t\t\t\t\tlp.post_time AS lp_post_time\n\t\t\t\t\t{$sql_forums_field}\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS lp, " . USERS_TABLE . " lu {$sql_forums_file}\n\t\t\tWHERE\n\t\t\t\tt.forum_id IN ({$s_forum_ids})\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND u.user_id = p.poster_id\n\t\t\t\tAND lp.post_id = t.topic_last_post_id\n\t\t\t\tAND lu.user_id = lp.poster_id\n\t\t\t\tAND t.topic_calendar_time < {$end_date}\n\t\t\t\tAND (t.topic_calendar_time + t.topic_calendar_duration) >= {$start_date}\n\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\t{$sql_forums_match}\n\t\t\tORDER BY\n\t\t\t\tt.topic_calendar_time, t.topic_calendar_duration DESC, t.topic_last_post_id DESC";
    $result = $db->sql_query($sql);
    // get the number of occurences
    $number = $db->sql_numrows($result);
    // if limit per page asked, limit the number of results
    if ($limit) {
        $db->sql_freeresult($result);
        $sql .= " LIMIT {$start}, {$max_limit}";
        $result = $db->sql_query($sql);
    }
    $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? 1 : 0;
    $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? 1 : 0;
    $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? 1 : 0;
    // read the items
    while ($row = $db->sql_fetchrow($result)) {
        // prepare the message
        $topic_author_id = $row['poster_id'];
        $topic_author = $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username'];
        $topic_time = $row['topic_time'];
        $topic_last_author_id = $row['lp_poster_id'];
        $topic_last_author = $row['lp_poster_id'] == ANONYMOUS ? $row['lp_post_username'] : $row['lp_username'];
        $topic_last_time = $row['lp_post_time'];
        $topic_views = $row['topic_views'];
        $topic_replies = $row['topic_replies'];
        $topic_icon = $row['topic_icon'];
        $topic_title = $row['topic_title'];
        $message = htmlspecialchars($row['post_text']);
        $topic_calendar_time = $row['topic_calendar_time'];
        $topic_calendar_duration = $row['topic_calendar_duration'];
        $topic_link = append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $row['topic_id']);
        $topic_title = censor_text($topic_title);
        $message = censor_text($message);
        $short_title = strlen($topic_title) > $topic_title_length + 3 ? substr($topic_title, 0, $topic_title_length) . '...' : $topic_title;
        // Convert and clean special chars!
        $topic_title = htmlspecialchars_clean($topic_title);
        $short_title = htmlspecialchars_clean($short_title);
        // SMILEYS IN TITLE - BEGIN
        if ($config['smilies_topic_title'] && !$lofi) {
            $topic_title = $bbcode->parse_only_smilies($topic_title);
            $short_title = $bbcode->parse_only_smilies($short_title);
        }
        // SMILEYS IN TITLE - END
        $dsp_topic_icon = '';
        if (function_exists('get_icon_title')) {
            $dsp_topic_icon = get_icon_title($topic_icon, 0, POST_CALENDAR);
        }
        // parse the message
        $message = substr($message, 0, $topic_text_length);
        // remove HTML if not allowed
        if (!$config['allow_html'] && $row['enable_html']) {
            $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
        }
        $message = $bbcode->parse($message);
        // get the date format
        $fmt = $lang['DATE_FORMAT_CALENDAR'];
        if (!empty($topic_calendar_duration)) {
            $fmt = $config['default_dateformat'];
        }
        // replace \n with <br />
        //$message = preg_replace("/[\n\r]{1,2}/", '<br />', $message);
        // build the overview
        $sav_tpl = $template->_tpldata;
        $det_handler = '_overview_topic_' . $row['topic_id'];
        $template->set_filenames(array($det_handler => 'calendar_overview_topic.tpl'));
        $nav_desc = '';
        if ($cat_hierarchy) {
            $nav_desc = make_cat_nav_tree(POST_FORUM_URL . $row['forum_id'], '', '', 'gensmall');
        } else {
            $nav_desc = '<a href="' . append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $row['forum_id']) . '" class="gensmall">' . $row['forum_name'] . '</a>';
        }
        $template->assign_vars(array('L_CALENDAR_EVENT' => $lang['Calendar_event'], 'L_AUTHOR' => $lang['Author'], 'L_TOPIC_DATE' => $lang['Date'], 'L_FORUM' => $lang['Forum'], 'L_VIEWS' => $lang['Views'], 'L_REPLIES' => $lang['Replies'], 'TOPIC_TITLE' => $dsp_topic_icon . '&nbsp;' . $topic_title, 'CALENDAR_EVENT' => get_calendar_title_date($topic_calendar_time, $topic_calendar_duration), 'AUTHOR' => $topic_author, 'TOPIC_DATE' => create_date($user->data['user_dateformat'], $topic_time, $config['board_timezone']), 'NAV_DESC' => $nav_desc, 'CALENDAR_MESSAGE' => $message, 'VIEWS' => $topic_views, 'REPLIES' => $topic_replies));
        $template->assign_var_from_handle('_calendar_overview', $det_handler);
        $message = $template->_tpldata['.'][0]['_calendar_overview'];
        $template->_tpldata = $sav_tpl;
        // remove \n remaining from the template
        $message = preg_replace("/[\n\r]{1,2}/", '', $message);
        // store only the new values
        $new_row = array();
        $new_row['event_id'] = POST_TOPIC_URL . $row['topic_id'];
        $new_row['event_author_id'] = $topic_author_id;
        $new_row['event_author'] = $topic_author;
        $new_row['event_author_active'] = $row['user_active'];
        $new_row['event_author_color'] = $row['user_color'];
        $new_row['event_time'] = $topic_time;
        $new_row['event_last_author_id'] = $topic_last_author_id;
        $new_row['event_last_author'] = $topic_last_author;
        $new_row['event_last_time'] = $topic_last_time;
        $new_row['event_replies'] = $topic_replies;
        $new_row['event_views'] = $topic_views;
        $new_row['event_type'] = $row['topic_type'];
        $new_row['event_status'] = $row['topic_status'];
        $new_row['event_moved_id'] = $row['topic_moved_id'];
        $new_row['event_last_id'] = $row['topic_last_post_id'];
        $new_row['event_forum_id'] = $row['forum_id'];
        $new_row['event_forum_name'] = $row['forum_name'];
        $new_row['event_icon'] = $topic_icon;
        $new_row['event_title'] = $topic_title;
        $new_row['event_short_title'] = $short_title;
        $new_row['event_message'] = $message;
        $new_row['event_calendar_time'] = $topic_calendar_time;
        $new_row['event_calendar_duration'] = $topic_calendar_duration;
        $new_row['event_link'] = $topic_link;
        $new_row['event_birthday'] = false;
        $new_row['event_txt_class'] = 'genmed';
        $new_row['event_type_icon'] = '<img src="' . $images['icon_tiny_topic'] . '" style="vertical-align: bottom;" alt="" hspace="2" />';
        $events[] = $new_row;
    }
    $db->sql_freeresult($result);
}
function get_tree_option($cur = '', $all = false)
{
    global $tree, $lang;
    $keys = array();
    $keys = get_auth_keys('Root', $all);
    $last_level = -1;
    $res = '';
    for ($i = 0; $i < sizeof($keys['id']); $i++) {
        // only get object that are not forum links type
        if (empty($tree['type'][$keys['idx'][$i]]) || empty($tree['data'][$keys['idx'][$i]]['forum_link']) || $tree['type'][$keys['idx'][$i]] != POST_FORUM_URL) {
            $level = $keys['real_level'][$i];
            $inc = '';
            for ($k = 0; $k < $level; $k++) {
                $inc .= "[*{$k}*]&nbsp;&nbsp;&nbsp;";
            }
            if ($level < $last_level) {
                //insert spacer if level goes down
                $res .= '<option value="-1">' . $inc . '|&nbsp;&nbsp;&nbsp;</option>';
                // make valid lines solid
                $res = str_replace("[*{$level}*]", "|", $res);
                // erase all unnessecary lines
                for ($k = $level + 1; $k < $last_level; $k++) {
                    $res = str_replace("[*{$k}*]", "&nbsp;", $res);
                }
            } elseif ($level == 0 && $last_level == -1) {
                $res .= '<option value="-1">|</option>';
            }
            $last_level = $level;
            $selected = $cur == $keys['id'][$i] ? ' selected="selected"' : '';
            $res .= '<option value="' . $keys['id'][$i] . '"' . $selected . '>';
            // name
            $name = strip_tags(get_object_lang($keys['id'][$i], 'name', $all));
            if ($keys['level'][$i] >= 0) {
                $res .= $inc . '|--';
            }
            $res .= $name . '</option>';
        }
    }
    // erase all unnessecary lines
    for ($k = 0; $k < $last_level; $k++) {
        $res = str_replace("[*{$k}*]", "&nbsp;", $res);
    }
    return $res;
}
function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys)
{
    global $template, $phpEx, $board_config, $lang, $images;
    global $tree;
    //
    // init
    //
    $display = false;
    // get the sub_forum switch value
    $sub_forum = intval($board_config['sub_forum']);
    if ($sub_forum == 2 && defined('IN_VIEWFORUM')) {
        $sub_forum = 1;
    }
    $pack_first_level = $sub_forum == 2;
    // verify the cat_break parm
    if ($cur != 'Root' && $real_level == -1) {
        $cat_break = false;
    }
    // display the level
    $this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
    //
    // display each kind of row
    //
    // root level head
    if ($real_level == -1) {
        // get max inc level
        $max = -1;
        if ($sub_forum == 2) {
            $max = 0;
        }
        if ($sub_forum == 1) {
            $max = 1;
        }
        $keys = array();
        $keys = get_auth_keys($cur, false, -1, $max);
        $max_level = get_max_depth($cur, false, -1, $keys, $max);
    }
    // table header
    if ($board_config['split_cat'] && $cat_break && $real_level == 0 || (!$board_config['split_cat'] || !$cat_break) && $real_level == -1) {
        // if break, get the local max level
        if ($board_config['split_cat'] && $cat_break && $real_level == 0) {
            $max_level = 0;
            // the array is sorted
            $start = false;
            $stop = false;
            for ($i = 0; $i < count($keys['id']) && !$stop; $i++) {
                if ($start && $tree['main'][$keys['idx'][$i]] == $tree['main'][$this_key]) {
                    $stop = true;
                    $break;
                }
                if ($keys['id'][$i] == $cur) {
                    $start = true;
                }
                if ($start && !$stop && $keys['level'][$i] > $max_level) {
                    $max_level = $keys['level'][$i];
                }
            }
        }
        $template->assign_block_vars('catrow', array());
        $template->assign_block_vars('catrow.tablehead', array('L_FORUM' => $this_key < 0 ? $lang['Forum'] : get_object_lang($cur, 'name'), 'INC_SPAN' => $max_level + 2));
    }
    // get the level
    $level = $keys['level'][$keys['keys'][$cur]];
    // sub-forum view management
    $pull_down = true;
    if ($sub_forum > 0) {
        $pull_down = false;
        if ($real_level == 0 && $sub_forum == 1) {
            $pull_down = true;
        }
    }
    if ($level >= 0) {
        // cat header row
        if ($tree['type'][$this_key] == POST_CAT_URL && $pull_down) {
            // display a cat row
            $cat = $tree['data'][$this_key];
            $cat_id = $tree['id'][$this_key];
            // get the class colors
            $class_catLeft = "catLeft";
            $class_cat = "cat";
            $class_rowpic = "rowpic";
            // send to template
            $template->assign_block_vars('catrow', array());
            $template->assign_block_vars('catrow.cathead', array('CAT_TITLE' => get_object_lang($cur, 'name'), 'CAT_DESC' => ereg_replace('<[^>]+>', '', get_object_lang($cur, 'desc')), 'CLASS_CATLEFT' => $class_catLeft, 'CLASS_CAT' => $class_cat, 'CLASS_ROWPIC' => $class_rowpic, 'INC_SPAN' => $max_level - $level + 2, 'U_VIEWCAT' => append_sid("forum.{$phpEx}?" . POST_CAT_URL . "={$cat_id}")));
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.cathead.inc', array('INC_CLASS' => $k % 2 ? 'row1' : 'row2'));
            }
            // something displayed
            $display = true;
        }
    }
    // forum header row
    if ($level >= 0) {
        if ($tree['type'][$this_key] == POST_FORUM_URL || $tree['type'][$this_key] == POST_CAT_URL && !$pull_down) {
            // get the data
            $data = $tree['data'][$this_key];
            $id = $tree['id'][$this_key];
            $type = $tree['type'][$this_key];
            $sub = !empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view'];
            // specific to the data type
            $title = get_object_lang($cur, 'name');
            $desc = get_object_lang($cur, 'desc');
            // specific to something attached
            if ($sub) {
                $i_new = $images['category_new'];
                $a_new = $lang['New_posts'];
                $i_norm = $images['category'];
                $a_norm = $lang['No_new_posts'];
                $i_locked = $images['category_locked'];
                $a_locked = $lang['Forum_locked'];
            } else {
                $i_new = $images['forum_new'];
                $a_new = $lang['New_posts'];
                $i_norm = $images['forum'];
                $a_norm = $lang['No_new_posts'];
                $i_locked = $images['forum_locked'];
                $a_locked = $lang['Forum_locked'];
            }
            // forum link type
            if ($tree['type'][$this_key] == POST_FORUM_URL && !empty($tree['data'][$this_key]['forum_link'])) {
                $i_new = $images['link'];
                $a_new = $lang['Forum_link'];
                $i_norm = $images['link'];
                $a_norm = $lang['Forum_link'];
                $i_locked = $images['link'];
                $a_locked = $lang['Forum_link'];
            }
            // front icon
            $folder_image = $data['tree.unread_topics'] ? $i_new : $i_norm;
            $folder_alt = $data['tree.unread_topics'] ? $a_new : $a_norm;
            if ($data['tree.locked']) {
                $folder_image = $i_locked;
                $folder_alt = $a_locked;
            }
            // moderators list
            $l_moderators = '';
            $moderator_list = '';
            if ($type == POST_FORUM_URL) {
                if (count($forum_moderators[$id]) > 0) {
                    $l_moderators = count($forum_moderators[$id]) == 1 ? $lang['Moderator'] : $lang['Moderators'];
                    $moderator_list = implode(', ', $forum_moderators[$id]);
                }
            }
            // last post
            $last_post = $lang['No_Posts'];
            if ($data['tree.topic_last_post_id']) {
                // resize
                $topic_title = $data['tree.topic_title'];
                if (strlen($topic_title) > intval($board_config['last_topic_title_length']) - 3) {
                    $topic_title = substr($topic_title, 0, intval($board_config['last_topic_title_length'])) . '...';
                }
                $topic_title = '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . "=" . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '" title="' . $data['tree.topic_title'] . '">' . $topic_title . '</a><br />';
                $last_post_time = create_date($board_config['default_dateformat'], $data['tree.post_time'], $board_config['board_timezone']);
                $last_post = $board_config['last_topic_title'] ? $topic_title : '';
                $last_post .= $last_post_time . '<br />';
                $last_post .= $data['tree.post_user_id'] == ANONYMOUS ? $data['tree.post_username'] . ' ' : '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $data['tree.post_user_id']) . '">' . $data['tree.post_username'] . '</a> ';
                $last_post .= '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
            }
            // links to sub-levels
            $links = '';
            if ($sub && (!$pull_down || $type == POST_FORUM_URL && $sub_forum > 0) && intval($board_config['sub_level_links']) > 0) {
                for ($j = 0; $j < count($tree['sub'][$cur]); $j++) {
                    if ($tree['auth'][$tree['sub'][$cur][$j]]['auth_view']) {
                        $wcur = $tree['sub'][$cur][$j];
                        $wthis = $tree['keys'][$wcur];
                        $wdata = $tree['data'][$wthis];
                        $wname = get_object_lang($wcur, 'name');
                        $wdesc = get_object_lang($wcur, 'desc');
                        switch ($tree['type'][$wthis]) {
                            case POST_FORUM_URL:
                                $wpgm = append_sid("./viewforum.{$phpEx}?" . POST_FORUM_URL . '=' . $tree['id'][$wthis]);
                                break;
                            case POST_CAT_URL:
                                $wpgm = append_sid("./forum.{$phpEx}?" . POST_CAT_URL . '=' . $tree['id'][$wthis]);
                                break;
                            default:
                                $wpgm = append_sid("./index.{$phpEx}");
                                break;
                        }
                        $link = '';
                        $wdesc = ereg_replace('<[^>]+>', '', $wdesc);
                        if ($wname != '') {
                            $link = '<a href="' . $wpgm . '" title="' . $wdesc . '" class="gensmall">' . $wname . '</a>';
                        }
                        if (intval($board_config['sub_level_links']) == 2) {
                            $wsub = !empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view'];
                            // specific to something attached
                            if ($wsub) {
                                $wi_new = $images['icon_minicat_new'];
                                $wa_new = $lang['New_posts'];
                                $wi_norm = $images['icon_minicat'];
                                $wa_norm = $lang['No_new_posts'];
                                $wi_locked = $images['icon_minicat_locked'];
                                $wa_locked = $lang['Forum_locked'];
                            } else {
                                $wi_new = $images['icon_minipost_new'];
                                $wa_new = $lang['icon_minipost'];
                                $wi_norm = $images['icon_minipost'];
                                $wa_norm = $lang['No_new_posts'];
                                $wi_locked = $images['icon_minipost_lock'];
                                $wa_locked = $lang['Forum_locked'];
                            }
                            // forum link type
                            if ($tree['type'][$wthis] == POST_FORUM_URL && !empty($wdata['forum_link'])) {
                                $wi_new = $images['icon_minilink'];
                                $wa_new = $lang['Forum_link'];
                                $wi_norm = $images['icon_minilink'];
                                $wa_norm = $lang['Forum_link'];
                                $wi_locked = $images['icon_minilink'];
                                $wa_locked = $lang['Forum_link'];
                            }
                            // front icon
                            $wfolder_image = $wdata['tree.unread_topics'] ? $wi_new : $wi_norm;
                            $wfolder_alt = $wdata['tree.unread_topics'] ? $wa_new : $wa_norm;
                            if ($wdata['tree.locked']) {
                                $wfolder_image = $wi_locked;
                                $wfolder_alt = $wa_locked;
                            }
                            $wlast_post = '<span style="white-space: nowrap;">';
                            if ($tree['type'][$wthis] == POST_FORUM_URL && (!empty($wdata['forum_link']) or empty($wdata['tree.topic_last_post_id']))) {
                                $wlast_post .= '<a href="' . append_sid("./viewforum.{$phpEx}?" . POST_FORUM_URL . '=' . $wdata['forum_id']) . '">';
                            } else {
                                if ($tree['type'][$wthis] == POST_CAT_URL && empty($wdata['tree.topic_last_post_id'])) {
                                    $wlast_post .= '<a href="' . append_sid("index.{$phpEx}?" . POST_CAT_URL . '=' . $wdata['cat_id']) . '">';
                                } else {
                                    $wlast_post .= '<a href="' . append_sid("./viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">';
                                }
                            }
                            $wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" /></a>';
                        }
                        if ($link != '') {
                            $links .= ($links != '' ? ',</span> ' : '') . $wlast_post . $link;
                        }
                    }
                }
                if ($links != '') {
                    $links .= '</span>';
                }
            }
            // forum icon
            $icon_img = empty($data['icon']) ? '' : (isset($images[$data['icon']]) ? $images[$data['icon']] : $data['icon']);
            // send to template
            $template->assign_block_vars('catrow', array());
            $template->assign_block_vars('catrow.forumrow', array('FORUM_FOLDER_IMG' => $folder_image, 'ICON_IMG' => $icon_img, 'FORUM_NAME' => $title, 'FORUM_DESC' => $desc, 'POSTS' => $data['tree.forum_posts'], 'TOPICS' => $data['tree.forum_topics'], 'LAST_POST' => $last_post, 'MODERATORS' => $moderator_list, 'L_MODERATOR' => empty($moderator_list) ? '' : (empty($l_moderators) ? '<br />' : '<br /><b>' . $l_moderators . ':</b>&nbsp;'), 'L_LINKS' => empty($links) ? '' : (empty($lang['Subforums']) ? '<br />' : '<br /><b>' . $lang['Subforums'] . ':</b>&nbsp;'), 'LINKS' => $links, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_VIEWFORUM' => $type == POST_FORUM_URL ? append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$id}") : append_sid("forum.{$phpEx}?" . POST_CAT_URL . "={$id}"), 'U_TARGET' => $tree['type'][$this] == POST_FORUM_URL && !empty($tree['data'][$this]['forum_link']) && !$tree['data'][$this]['forum_link_internal'] ? 'target="_blank"' : '', 'INC_SPAN' => $max_level - $level + 1, 'INC_CLASS' => !($level % 2) ? 'row1' : 'row2'));
            // display icon
            if (!empty($icon_img)) {
                $template->assign_block_vars('catrow.forumrow.forum_icon', array());
            }
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.forumrow.inc', array('INC_CLASS' => $k % 2 ? 'row1' : 'row2'));
            }
            // forum link type
            if ($tree['type'][$this_key] == POST_FORUM_URL && !empty($tree['data'][$this_key]['forum_link'])) {
                $s_hit_count = '';
                if ($tree['data'][$this_key]['forum_link_hit_count']) {
                    $s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$this_key]['forum_link_hit']);
                }
                $template->assign_block_vars('catrow.forumrow.forum_link', array('HIT_COUNT' => $s_hit_count));
            } else {
                $template->assign_block_vars('catrow.forumrow.forum_link_no', array());
            }
            // something displayed
            $display = true;
        }
    }
    // display sub-levels
    for ($i = 0; $i < count($tree['sub'][$cur]); $i++) {
        if (!empty($keys['keys'][$tree['sub'][$cur][$i]])) {
            $wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level + 1, $max_level, $keys);
            if ($wdisplay) {
                $display = true;
            }
        }
    }
    if ($level >= 0) {
        // forum footer row
        if ($tree['type'][$this_key] == POST_FORUM_URL) {
        }
    }
    if ($level >= 0) {
        // cat footer
        if ($tree['type'][$this_key] == POST_CAT_URL && $pull_down) {
            $template->assign_block_vars('catrow', array());
            $template->assign_block_vars('catrow.catfoot', array('INC_SPAN' => $max_level - $level + 5));
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.catfoot.inc', array('INC_SPAN' => $max_level - $level + 5, 'INC_CLASS' => $k % 2 ? 'row1' : 'row2'));
            }
        }
    }
    // root level footer
    if ($board_config['split_cat'] && $cat_break && $real_level == 0 || (!$board_config['split_cat'] || !$cat_break) && $real_level == -1) {
        $template->assign_block_vars('catrow', array());
        $template->assign_block_vars('catrow.tablefoot', array());
    }
    return $display;
}
Exemplo n.º 9
0
} elseif ($mode == 'user' && (isset($_POST['username']) || $user_id) || $mode == 'group' && $group_id) {
    $username = request_var('username', '', true);
    $username = htmlspecialchars_decode($username, ENT_COMPAT);
    if (!empty($username)) {
        $this_userdata = get_userdata($username, true);
        if (!is_array($this_userdata)) {
            if (!defined('STATUS_404')) {
                define('STATUS_404', true);
            }
            message_die(GENERAL_MESSAGE, 'NO_USER');
        }
        $user_id = $this_userdata['user_id'];
    }
    // get all sorted by level
    $keys = array();
    $keys = get_auth_keys('Root', true);
    // get the maximum level
    $max_level = 0;
    for ($i = 0; $i < sizeof($keys['id']); $i++) {
        if ($keys['real_level'][$i] > $max_level) {
            $max_level = $keys['real_level'][$i];
        }
    }
    // extract forums
    $forum_access = array();
    for ($i = 0; $i < sizeof($keys['id']); $i++) {
        if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL) {
            $forum_access[] = $tree['data'][$keys['idx'][$i]];
        }
    }
    if (empty($adv)) {
Exemplo n.º 10
0
     if ($user->data['session_logged_in'] && !$user->data['is_bot']) {
         // UPI2DB - BEGIN
         if (!$user->data['upi2db_access']) {
             $user->set_cookie('f_all', time(), $user->cookie_expire);
         } else {
             marking_posts();
         }
         // UPI2DB - END
     }
     $redirect_url = append_sid(CMS_PAGE_FORUM);
     meta_refresh(3, $redirect_url);
 } else {
     if ($user->data['session_logged_in'] && !$user->data['is_bot']) {
         // get the list of object authorized
         $keys = array();
         $keys = get_auth_keys($viewcatkey);
         // mark each forums
         for ($i = 0; $i < sizeof($keys['id']); $i++) {
             if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL) {
                 $forum_id = $tree['id'][$keys['idx'][$i]];
                 $sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = '" . $forum_id . "'";
                 $result = $db->sql_query($sql);
                 if ($row = $db->sql_fetchrow($result)) {
                     $tracking_forums = isset($_COOKIE[$config['cookie_name'] . '_f']) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
                     $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_t']) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
                     if (sizeof($tracking_forums) + sizeof($tracking_topics) >= 150 && empty($tracking_forums[$forum_id])) {
                         asort($tracking_forums);
                         unset($tracking_forums[key($tracking_forums)]);
                     }
                     if ($row['last_post'] > $user->data['user_lastvisit']) {
                         $tracking_forums[$forum_id] = time();
Exemplo n.º 11
0
function get_tree_option_optg($cur = '', $all = false, $opt_prefix = true, $mark_selected = false)
{
    global $tree, $lang;
    $keys = array();
    $keys = get_auth_keys('Root', $all);
    $last_level = -1;
    $cat_open = false;
    for ($i = 0; $i < sizeof($keys['id']); $i++) {
        // only get object that are not forum links type
        if ($tree['type'][$keys['idx'][$i]] != POST_FORUM_URL || empty($tree['data'][$keys['idx'][$i]]['forum_link'])) {
            $level = $keys['real_level'][$i];
            $inc = '';
            for ($k = 0; $k < $level; $k++) {
                $inc .= "[*{$k}*]&nbsp;&nbsp;&nbsp;";
            }
            if ($level < $last_level) {
                //insert spacer if level goes down
                //$res .='<option value="-1">' . $inc . '|&nbsp;&nbsp;&nbsp;</option>';
                // make valid lines solid
                $res = str_replace("[*{$level}*]", "|", $res);
                // erase all unnessecary lines
                for ($k = $level + 1; $k < $last_level; $k++) {
                    $res = str_replace("[*{$k}*]", "&nbsp;", $res);
                }
            } elseif ($level == 0 && $last_level == -1) {
                //$res .='<option value="-1">|</option>';
            }
            $last_level = $level;
            if ($tree['type'][$keys['idx'][$i]] == POST_CAT_URL) {
                if ($cat_open == true) {
                    $res .= '</optgroup>';
                } else {
                    $cat_open = true;
                }
                $res .= '<optgroup label="';
                // name
                $name = strip_tags(get_object_lang($keys['id'][$i], 'name', $all));
                if ($keys['level'][$i] >= 0) {
                    $res .= $inc . '|--';
                }
                $res .= $name . '">';
            } else {
                if ($keys['id'][$i] != 'Root') {
                    $is_selected = $cur == $keys['id'][$i] ? true : false;
                    $selected = $is_selected ? ' selected="selected"' : '';
                    if ($opt_prefix == true) {
                        $res .= '<option value="' . $keys['id'][$i] . '"' . $selected . '>';
                    } else {
                        $res .= '<option value="' . str_replace(POST_FORUM_URL, '', $keys['id'][$i]) . '"' . $selected . '>';
                    }
                    // name
                    $name = ($is_selected && $mark_selected ? ' * ' : '') . strip_tags(get_object_lang($keys['id'][$i], 'name', $all));
                    if ($keys['level'][$i] >= 0) {
                        $res .= $inc . '|--';
                    }
                    $res .= $name . '</option>';
                }
            }
        }
    }
    if ($cat_open == true) {
        $res .= '</optgroup>';
    }
    // erase all unnecessary lines
    for ($k = 0; $k < $last_level; $k++) {
        $res = str_replace("[*{$k}*]", "&nbsp;", $res);
    }
    return $res;
}