function nodeurl($lang, $thread_id, $node_id) { global $db_debug; $flag = $db_debug; $db_debug = false; $action = false; $args = array(); if ($thread_id) { $r = thread_get($lang, $thread_id); if (!$r) { return false; } $action = $r['thread_type']; $args[] = $r['thread_name']; } if ($node_id) { $r = node_get($lang, $node_id); if (!$r) { return false; } $args[] = $r['node_name']; } $db_debug = $flag; return url($action, $lang, $args); }
function threadsummary($lang, $thread) { global $system_languages, $with_toolbar; if (!user_has_role('writer')) { return run('error/unauthorized', $lang); } $slang = false; if (isset($_GET['slang'])) { $slang = $_GET['slang']; } else { $slang = $lang; } if (!in_array($slang, $system_languages)) { return run('error/notfound', $lang); } $thread_id = thread_id($thread); if (!$thread_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $thread_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_name thread_title thread_type thread_abstract thread_cloud thread_image thread_visits thread_nosearch thread_nocloud thread_nocomment thread_nomorecomment thread_novote thread_nomorevote thread_created thread_modified */ $thread_search = !$thread_nosearch; $thread_tag = !$thread_nocloud; $thread_comment = !$thread_nocomment; $thread_morecomment = !$thread_nomorecomment; $thread_vote = !$thread_novote; $thread_morevote = !$thread_nomorevote; $thread_contents = array(); $r = thread_get_contents($lang, $thread_id, false); if ($r) { $thread_url = url('thread', $lang) . '/' . $thread_id; foreach ($r as $c) { extract($c); /* node_id node_name node_title node_number node_ignored */ $node_url = $thread_url . '/' . $node_id . '?' . 'slang=' . $slang; $thread_contents[] = compact('node_id', 'node_title', 'node_url', 'node_ignored'); } } $headline_text = translate('threadall:title', $slang); $headline_url = url('thread', $lang) . '?' . 'slang=' . $slang; $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('title')); head('title', $thread_title ? $thread_title : $thread_id); head('description', $thread_abstract); head('keywords', $thread_cloud); head('robots', 'noindex, nofollow'); $edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/' . $thread_id . '?' . 'clang=' . $lang : false; $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'edit')); $scroll = true; $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false; $content = view('threadsummary', $slang, compact('thread_id', 'thread_title', 'thread_abstract', 'thread_cloud', 'thread_image', 'thread_visits', 'thread_search', 'thread_tag', 'thread_comment', 'thread_morecomment', 'thread_vote', 'thread_morevote', 'thread_ilike', 'thread_tweet', 'thread_plusone', 'thread_linkedin', 'thread_pinit', 'thread_created', 'thread_modified', 'thread_contents')); $output = layout('viewing', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
function suggest($lang, $arglist = false) { global $search_all, $rss_thread; $cloud = false; if (is_array($arglist)) { if (isset($arglist[0])) { $cloud = $arglist[0]; } } $cloud_id = false; if ($cloud) { $cloud_id = cloud_id($cloud); if (!$cloud_id) { header('HTTP/1.1 404 Not Found'); return false; } if ($cloud_id == $rss_thread) { if (!user_has_role('administrator')) { header('HTTP/1.1 401 Unauthorized'); return false; } } $r = thread_get($lang, $cloud_id); if (!$r) { header('HTTP/1.1 404 Not Found'); return false; } extract($r); /* thread_type thread_nosearch */ if ($thread_type == 'thread' or $thread_nosearch) { header('HTTP/1.1 404 Not Found'); return false; } } else { if ($search_all !== true) { header('HTTP/1.1 404 Not Found'); return false; } } $term = isset($arglist['term']) ? $arglist['term'] : false; if (!$term) { header('HTTP/1.1 400 Bad Request'); return false; } $r = cloud_suggest($lang, $cloud_id, $term); if (!$r) { header('HTTP/1.1 404 Not Found'); return false; } $taglist = array(); foreach ($r as $tag) { $taglist[] = $tag['tag_name']; } return json_encode($taglist); }
function foldersummary($lang, $folder) { global $with_toolbar; $folder_id = thread_id($folder); if (!$folder_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $folder_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud */ if ($thread_type != 'folder') { return run('error/notfound', $lang); } $folder_name = $thread_name; $folder_title = $thread_title; $folder_abstract = $thread_abstract; $folder_cloud = $thread_cloud; if ($folder_title) { head('title', $folder_title); } if ($folder_abstract) { head('description', $folder_abstract); } if ($folder_cloud) { head('keywords', $folder_cloud); } $folder_contents = array(); $r = thread_get_contents($lang, $folder_id); if ($r) { $folder_url = url('folder', $lang) . '/' . $folder_name; foreach ($r as $c) { extract($c); /* node_name node_title */ if (!$node_title) { continue; } $page_title = $node_title; $page_url = $folder_url . '/' . $node_name; $folder_contents[] = compact('page_title', 'page_url'); } } $content = view('foldersummary', false, compact('folder_id', 'folder_title', 'folder_contents')); $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '?' . 'clang=' . $lang : false; $validate = url('folder', $lang) . '/' . $folder_name; $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false; $output = layout('standard', compact('toolbar', 'banner', 'content')); return $output; }
function email_send_folder_subscription($fuid, $fid, $tid, $pid, $modified, &$exclude_user_array) { // Validate function arguments if (!is_numeric($fuid)) { return false; } if (!is_numeric($fid)) { return false; } if (!is_numeric($tid)) { return false; } if (!is_numeric($pid)) { return false; } if (!is_numeric($modified)) { return false; } // Check the thread is valid if (!($thread = thread_get($tid))) { return false; } // Get the from user details if (!($from_user = user_get($fuid))) { return false; } // Get the forum details. if (!($table_prefix = get_table_prefix())) { return false; } if (!($forum_fid = get_forum_fid())) { return false; } // Get the Swift Mailer Transport if (!($transport = Swift_TransportFactory::get())) { return false; } //Create the Mailer using the returned Transport $mailer = Swift_Mailer::newInstance($transport); // Create a new message $message = Swift_MessageBeehive::newInstance(); // Database connection. if (!($db = db::get())) { return false; } // Make sure $exclude_user_array is an array. if (!is_array($exclude_user_array)) { $exclude_user_array = array(); } // Add the $fuid to it. array_push($exclude_user_array, $fuid); // Make sure it only contains numbers and implode it. $exclude_user_list = implode(",", array_filter($exclude_user_array, 'is_numeric')); // Get the forum webtag $webtag = get_webtag(); // Only send the email to people who logged after the thread was modified. $last_visit_datetime = date(MYSQL_DATETIME, $modified); $sql = "SELECT USER_FOLDER.UID, USER.LOGON, USER.NICKNAME, USER.EMAIL "; $sql .= "FROM `{$table_prefix}USER_FOLDER` USER_FOLDER "; $sql .= "LEFT JOIN USER ON (USER.UID = USER_FOLDER.UID) "; $sql .= "LEFT JOIN USER_FORUM ON (USER_FORUM.UID = USER_FOLDER.UID "; $sql .= "AND USER_FORUM.FID = '{$forum_fid}') WHERE USER_FOLDER.FID = '{$fid}' "; $sql .= "AND USER_FORUM.LAST_VISIT > CAST('{$last_visit_datetime}' AS DATETIME) "; $sql .= "AND USER_FOLDER.INTEREST = 1 AND USER_FOLDER.UID NOT IN ({$exclude_user_list})"; if (!($result = $db->query($sql))) { return false; } if ($result->num_rows < 1) { return false; } while ($to_user = $result->fetch_assoc()) { // Validate the email address before we continue. if (!email_address_valid($to_user['EMAIL'])) { continue; } // Add the uid to exclude array array_push($exclude_user_array, $to_user['UID']); // Get the required variables (forum name, subject, recipient, etc.) and // pass them all through the recipient's word filter. $forum_name = word_filter_apply(forum_get_setting('forum_name', null, 'A Beehive Forum'), $to_user['UID'], true); $subject = word_filter_apply(sprintf(gettext("Subscription Notification from %s"), $forum_name), $to_user['UID'], true); $recipient = word_filter_apply(format_user_name($to_user['LOGON'], $to_user['NICKNAME']), $to_user['UID'], true); $message_author = word_filter_apply(format_user_name($from_user['LOGON'], $from_user['NICKNAME']), $to_user['UID'], true); $thread_title = word_filter_apply($thread['TITLE'], $to_user['UID'], true); // Generate link to the forum itself $forum_link = html_get_forum_uri("index.php?webtag={$webtag}&fid={$fid}"); // Generate the message link. $message_link = html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.{$pid}"); // Generate the message body. $message_body = wordwrap(sprintf(gettext("Hello %s,\r\n\r\n%s posted a message in a folder you are subscribed to on %s.\r\n\r\nThe subject is: %s.\r\n\r\nTo read that message and others in the same discussion, go to:\r\n%s\r\n\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nNote: If you do not wish to receive email notifications of new messages in this thread, go to: %s and adjust your Interest level by clicking on the folder's icon at the top of page."), $recipient, $message_author, $forum_name, $thread_title, $message_link, $forum_link)); // Add the recipient $message->setTo($to_user['EMAIL'], $recipient); // Set the subject $message->setSubject($subject); // Set the message body $message->setBody($message_body); // Send the email $mailer->send($message); } return true; }
function booksummary($lang, $book) { global $with_toolbar; $book_id = thread_id($book); if (!$book_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $book_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_name thread_title thread_abstract thread_cloud thread_image thread_nocloud thread_nosearch */ if ($thread_type != 'book') { return run('error/notfound', $lang); } $book_name = $thread_name; $book_title = $thread_title; $book_abstract = $thread_abstract; $book_cloud = $thread_cloud; $book_modified = $thread_modified; $book_nocloud = $thread_nocloud; $book_nosearch = $thread_nosearch; $book_novote = $thread_novote; $book_nomorevote = $thread_nomorevote; if ($book_title) { head('title', $book_title); } if ($book_abstract) { head('description', $book_abstract); } if ($book_cloud) { head('keywords', $book_cloud); } head('date', $book_modified); $book_contents = array(); $r = thread_get_contents($lang, $book_id); if ($r) { $book_url = url('book', $lang) . '/' . $book_name; foreach ($r as $c) { extract($c); /* node_id node_name node_title node_number */ $page_id = $node_id; $page_title = $node_title; $page_url = $book_url . '/' . $node_name; $book_contents[] = compact('page_id', 'page_title', 'page_url'); } } $vote = false; if (!$book_novote) { $nomore = (!$book_contents or $book_nomorevote) ? true : false; $vote = build('vote', $lang, $book_id, 'thread', $nomore); } $besocial = $sharebar = false; if ($book_contents) { $ilike = $thread_ilike; $tweetit = $thread_tweet; $plusone = $thread_plusone; $linkedin = $thread_linkedin; $pinit = $thread_pinit; if ($tweetit) { $tweet_text = $thread_abstract ? $thread_abstract : $thread_title; $tweetit = $tweet_text ? compact('tweet_text') : true; } if ($pinit) { $pinit_text = $thread_abstract ? $thread_abstract : $thread_title; $pinit_image = $thread_image; $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false; } list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit')); } $content = view('booksummary', false, compact('book_id', 'book_title', 'book_abstract', 'book_contents', 'besocial', 'vote')); $search = false; if (!$book_nosearch) { $search_text = ''; $search_url = url('search', $lang, $book_name); $suggest_url = url('suggest', $lang, $book_name); $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url')); } $cloud = false; if (!$book_nocloud) { $cloud_url = url('search', $lang, $book_name); $byname = $bycount = $index = true; $cloud = build('cloud', $lang, $cloud_url, $book_id, false, 30, compact('byname', 'bycount', 'index')); } $headline_text = translate('bookall:title', $lang); $headline_url = url('book', $lang); $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('search', 'cloud', 'title')); $search = !$book_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false; $edit = user_has_role('writer') ? url('bookedit', $_SESSION['user']['locale']) . '/' . $book_id . '?' . 'clang=' . $lang : false; $validate = url('book', $lang) . '/' . $book_name; $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false; $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'sidebar', 'content')); return $output; }
function thread_split($tid, $spid, $split_type, &$error_str) { if (!($db = db::get())) { return false; } if (!is_numeric($tid)) { return false; } if (!is_numeric($spid)) { return false; } if (!in_array($split_type, array(THREAD_SPLIT_REPLIES, THREAD_SPLIT_FOLLOWING))) { return false; } if (!($table_prefix = get_table_prefix())) { return thread_split_error(THREAD_SPLIT_FORUM_ERROR, $error_str); } if (!($thread_data = thread_get($tid))) { return thread_split_error(THREAD_SPLIT_THREAD_ERROR, $error_str); } if (!($forum_fid = get_forum_fid())) { return thread_split_error(THREAD_SPLIT_THREAD_ERROR, $error_str); } if (!is_numeric($spid) || $spid < 2 || $spid > $thread_data['LENGTH']) { return thread_split_error(THREAD_SPLIT_INVALID_ARGS, $error_str); } if (!is_numeric($split_type)) { return thread_split_error(THREAD_SPLIT_INVALID_ARGS, $error_str); } thread_set_closed($tid, true); $pid_array = array(); switch ($split_type) { case THREAD_SPLIT_REPLIES: $pid_array = thread_split_get_replies($tid, $spid, $pid_array); break; case THREAD_SPLIT_FOLLOWING: $pid_array = thread_split_get_following($tid, $spid, $pid_array); break; } if (!is_array($pid_array) || sizeof($pid_array) < 1) { thread_split_error(THREAD_SPLIT_POST_ERROR, $error_str); thread_set_closed($tid, $thread_data['CLOSED'] > 0); return false; } if (!($new_tid = post_create_thread($thread_data['FID'], $thread_data['BY_UID'], $thread_data['TITLE'], 'N', 'N', true))) { thread_split_error(THREAD_SPLIT_CREATE_ERROR, $error_str); thread_set_closed($tid, $thread_data['CLOSED'] > 0); return false; } if (!($thread_new = thread_get($new_tid, true, true))) { thread_split_error(THREAD_SPLIT_CREATE_ERROR, $error_str); thread_set_closed($tid, $thread_data['CLOSED'] > 0); return false; } $pid_list = implode(',', $pid_array); $sql = "INSERT INTO `{$table_prefix}POST` (TID, REPLY_TO_PID, "; $sql .= "FROM_UID, TO_UID, VIEWED, CREATED, STATUS, APPROVED, APPROVED_BY, "; $sql .= "EDITED, EDITED_BY, IPADDRESS, MOVED_TID, MOVED_PID) "; $sql .= "SELECT '{$new_tid}', REPLY_TO_PID, FROM_UID, TO_UID, NULL, NOW(), "; $sql .= "STATUS, APPROVED, APPROVED_BY, EDITED, EDITED_BY, IPADDRESS, TID, "; $sql .= "PID FROM `{$table_prefix}POST` WHERE TID = {$tid} "; $sql .= "AND PID IN ({$pid_list}) ORDER BY CREATED"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_split_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Copy the post contents to the new thread $sql = "INSERT INTO `{$table_prefix}POST_CONTENT` (TID, PID, CONTENT) "; $sql .= "SELECT POST.TID, POST.PID, POST_CONTENT.CONTENT FROM `{$table_prefix}POST` POST "; $sql .= "LEFT JOIN `{$table_prefix}POST_CONTENT` POST_CONTENT "; $sql .= "ON (POST_CONTENT.TID = POST.MOVED_TID AND POST_CONTENT.PID = MOVED_PID) "; $sql .= "WHERE POST.TID = '{$new_tid}'"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_split_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Insert the new Sphinx Search IDs. $sql = "INSERT INTO `{$table_prefix}POST_SEARCH_ID` (TID, PID) "; $sql .= "SELECT {$new_tid}, POST.PID FROM `{$table_prefix}POST` POST "; $sql .= "WHERE POST.TID = '{$new_tid}'"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_MERGE_QUERY_ERROR, $error_str); } // Update the REPLY_TO_PIDs in the new thread $sql = "INSERT INTO `{$table_prefix}POST` (TID, PID, REPLY_TO_PID) "; $sql .= "SELECT TARGET_POST.TID, TARGET_POST.PID, SOURCE_POST.PID "; $sql .= "FROM `{$table_prefix}POST` TARGET_POST "; $sql .= "INNER JOIN `{$table_prefix}POST` SOURCE_POST "; $sql .= "ON (SOURCE_POST.MOVED_TID = TARGET_POST.MOVED_TID "; $sql .= "AND TARGET_POST.REPLY_TO_PID = SOURCE_POST.MOVED_PID) "; $sql .= "WHERE TARGET_POST.TID = '{$new_tid}' AND TARGET_POST.PID > 1 "; $sql .= "ON DUPLICATE KEY UPDATE REPLY_TO_PID = VALUES(REPLY_TO_PID) "; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Remove the first post in the thread's REPLY_TO_PID $sql = "UPDATE `{$table_prefix}POST` POST SET REPLY_TO_PID = NULL "; $sql .= "WHERE POST.TID = '{$new_tid}' AND POST.PID = 1"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Update the old thread's post MOVED_TID and MOVED_PID $sql = "INSERT INTO `{$table_prefix}POST` (TID, PID, MOVED_TID, MOVED_PID) "; $sql .= "SELECT {$tid}, MOVED_PID, {$new_tid}, PID FROM `{$table_prefix}POST` POST "; $sql .= "WHERE POST.TID = {$new_tid} ON DUPLICATE KEY UPDATE MOVED_TID = VALUES(MOVED_TID), "; $sql .= "MOVED_PID = VALUES(MOVED_PID)"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Link the attachments to the new thread. $sql = "INSERT INTO POST_ATTACHMENT_IDS (FID, TID, PID, AID) "; $sql .= "SELECT {$forum_fid}, TARGET_POST.TID, TARGET_POST.PID, "; $sql .= "SOURCE_POST_ATTACHMENT_IDS.AID "; $sql .= "FROM `{$table_prefix}POST` TARGET_POST "; $sql .= "INNER JOIN `{$table_prefix}POST` SOURCE_POST "; $sql .= "ON (SOURCE_POST.MOVED_TID = TARGET_POST.MOVED_TID "; $sql .= "AND TARGET_POST.REPLY_TO_PID = SOURCE_POST.MOVED_PID) "; $sql .= "INNER JOIN POST_ATTACHMENT_IDS SOURCE_POST_ATTACHMENT_IDS "; $sql .= "ON (SOURCE_POST_ATTACHMENT_IDS.TID = SOURCE_POST.TID "; $sql .= "AND SOURCE_POST_ATTACHMENT_IDS.PID = SOURCE_POST.PID) "; $sql .= "WHERE TARGET_POST.TID = '{$new_tid}'"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } // Now we unset the MOVED_TID and MOVED_PIDs for the new thread // so the posts appear in the new thread. $sql = "UPDATE `{$table_prefix}POST` SET MOVED_TID = NULL, "; $sql .= "MOVED_PID = NULL WHERE TID = '{$new_tid}'"; if (!$db->query($sql)) { // Unlock the original thread if it wasn't originally locked. thread_set_closed($tid, $thread_data['CLOSED'] > 0); // Return error message. return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str); } thread_set_split($tid, $new_tid); thread_set_length($new_tid, sizeof($pid_array)); thread_set_closed($tid, $thread_data['CLOSED'] > 0); thread_set_closed($new_tid, $thread_data['CLOSED'] > 0); return array($tid, $spid, $new_tid, $thread_new['TITLE']); }
exit; } header('Content-Type: application/json'); $content = json_encode(array('success' => true, 'font_size' => $user_prefs['FONT_SIZE'], 'html' => messages_fontsize_form($tid, $pid, true, $user_prefs['FONT_SIZE']))); break; case 'post_options': if (!session::logged_in()) { break; } cache_disable(); if (!isset($_GET['msg']) || !validate_msg($_GET['msg'])) { header_status(500, 'Internal Server Error'); exit; } list($tid, $pid) = explode('.', $_GET['msg']); if (!($thread_data = thread_get($tid, session::check_perm(USER_PERM_ADMIN_TOOLS, 0)))) { header_status(500, 'Internal Server Error'); exit; } if (!($content = message_get_post_options_html($tid, $pid, $thread_data['FID']))) { header_status(500, 'Internal Server Error'); exit; } break; case 'poll_add_question': if (!session::logged_in()) { break; } cache_disable(); if (!isset($_GET['question_number']) || !is_numeric($_GET['question_number'])) { header_status(500, 'Internal Server Error');
function message_get_meta_content($msg, &$meta_keywords, &$meta_description) { if (!validate_msg($msg)) { return; } list($tid, $pid) = explode('.', $msg); if (($thread_data = thread_get($tid)) && ($message_content = message_get_content($tid, $pid))) { $meta_keywords_array = search_extract_keywords(strip_tags(htmlentities_decode_array($message_content))); $meta_description = $thread_data['TITLE']; $meta_keywords = htmlentities_array(implode(',', $meta_keywords_array['keywords_array'])); } }
function folderpage($lang, $folder, $page) { global $with_toolbar; $folder_id = thread_id($folder); if (!$folder_id) { return run('error/notfound', $lang); } $page_id = thread_node_id($folder_id, $page, $lang); if (!$page_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $folder_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image */ if (!($thread_type == 'folder' or $thread_type == 'book' or $thread_type == 'story')) { return run('error/notfound', $lang); } $folder_name = $thread_name; $folder_title = $thread_title; $folder_abstract = $thread_abstract; $folder_cloud = $thread_cloud; $r = thread_get_node($lang, $folder_id, $page_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* node_number node_ignored node_name node_title node_abstract node_cloud node_image node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin node_pinit */ if ($node_ignored) { return run('error/notfound', $lang); } $page_user_id = $node_user_id; $page_name = $node_name; $page_title = $node_title; $page_abstract = $node_abstract; $page_cloud = $node_cloud; $page_modified = $node_modified; if ($page_title) { head('title', $page_title); } else { if ($folder_title) { head('title', $folder_title); } } if ($page_abstract) { head('description', $page_abstract); } else { if ($folder_abstract) { head('description', $folder_abstract); } } if ($page_cloud) { head('keywords', $page_cloud); } else { if ($folder_cloud) { head('keywords', $folder_cloud); } } head('date', $page_modified); $page_contents = build('nodecontent', $lang, $page_id); $page_comment = false; if (!($thread_nocomment or $node_nocomment)) { $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false; $page_url = url('folder', $lang) . '/' . $folder_name . '/' . $page_name; $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore); } $vote = false; if (!($thread_novote or $node_novote)) { $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false; $vote = build('vote', $lang, $page_id, 'node', $nomore); } $visits = false; if ($thread_visits and $node_visits) { $nomore = user_has_role('writer'); $visits = build('visits', $lang, $page_id, $nomore); } $besocial = $sharebar = false; if ($page_contents or $page_comment) { $ilike = $thread_ilike && $node_ilike; $tweetit = $thread_tweet && $node_tweet; $plusone = $thread_plusone && $node_plusone; $linkedin = $thread_linkedin && $node_linkedin; $pinit = $thread_pinit && $node_pinit; if ($tweetit) { $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title); $tweetit = $tweet_text ? compact('tweet_text') : true; } if ($pinit) { $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title); $pinit_image = $node_image; $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false; } list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit')); } $content = view('folderpage', false, compact('page_title', 'page_contents', 'page_comment', 'besocial', 'vote', 'visits')); $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '/' . $page_id . '?' . 'clang=' . $lang : false; $validate = url('folder', $lang) . '/' . $folder_name . '/' . $page_name; $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false; $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'content')); return $output; }
<?php $array = thread_get('mySharedVar'); print_r($array); sleep(5); echo 'Done';
echo " <table width=\"95%\">\n"; } if (sizeof($selected_array) > 0) { foreach ($selected_array as $selected_option) { if ($type == SEARCH_LOGON && ($user_data = user_get_by_logon($selected_option))) { if ($multi === 'Y') { echo " <tr>\n"; echo " <td align=\"left\">", form_checkbox("selected[]", htmlentities_array($user_data['LOGON']), '', true), " <a href=\"user_profile.php?webtag={$webtag}&uid={$user_data['UID']}\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags(format_user_name($user_data['LOGON'], $user_data['NICKNAME']), true), "</a></td>\n"; echo " </tr>\n"; } else { echo " <tr>\n"; echo " <td align=\"left\">", form_radio("selected", htmlentities_array($user_data['LOGON']), '', true), " <a href=\"user_profile.php?webtag={$webtag}&uid={$user_data['UID']}\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags(format_user_name($user_data['LOGON'], $user_data['NICKNAME']), true), "</a></td>\n"; echo " </tr>\n"; } } else { if ($thread_data = thread_get($selected_option)) { echo " <tr>\n"; echo " <td align=\"left\">", form_radio("selected", $thread_data['TID'], '', true), " <a href=\"messages.php?webtag={$webtag}&msg={$thread_data['TID']}.1\" target=\"_blank\">", word_filter_add_ob_tags($thread_data['TITLE'], true), "</a></td>\n"; echo " </tr>\n"; } } } if (isset($search_results_array['results_array']) && sizeof($search_results_array['results_array']) > 0) { echo " <tr>\n"; echo " <td align=\"left\"><hr /></td>\n"; echo " </tr>\n"; } } if (isset($search_results_array['results_array']) && sizeof($search_results_array['results_array']) > 0) { foreach ($search_results_array['results_array'] as $search_result) { if ($type == SEARCH_LOGON && !in_array($search_result['LOGON'], $selected_array)) {
function threadeditsummary($lang, $clang, $thread) { global $supported_threads, $with_toolbar; if (!user_has_role('writer')) { return run('error/unauthorized', $lang); } $confirmed = false; $thread_id = thread_id($thread); if (!$thread_id) { return run('error/notfound', $lang); } $action = 'init'; if (isset($_POST['thread_edit'])) { $action = 'edit'; } else { if (isset($_POST['thread_reorder'])) { $action = 'reorder'; } else { if (isset($_POST['node_create'])) { $action = 'create'; } else { if (isset($_POST['node_copy'])) { $action = 'copy'; } else { if (isset($_POST['node_delete'])) { $action = 'delete'; } else { if (isset($_POST['node_confirmdelete'])) { $action = 'delete'; $confirmed = true; } else { if (isset($_POST['node_hide'])) { $action = 'hide'; } else { if (isset($_POST['node_show'])) { $action = 'show'; } } } } } } } } $thread_type = $thread_name = $thread_title = $thread_abstract = $thread_cloud = $thread_image = false; $thread_search = $thread_tag = false; $thread_comment = $thread_morecomment = $thread_vote = $thread_morevote = false; $thread_ilike = $thread_tweet = $thread_plusone = $thread_linkedin = $thread_pinit = false; $thread_visits = false; $thread_nosearch = $thread_nocloud = $thread_nocomment = $thread_nomorecomment = $thread_novote = $thread_nomorevote = true; $new_node_name = $new_node_title = $new_node_number = false; $old_node_number = false; $p = false; switch ($action) { case 'init': case 'reset': $r = thread_get($clang, $thread_id, false); if ($r) { extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image thread_visits thread_nosearch thread_nocloud thread_nocomment thread_nomorecomment thread_novote thread_nomorevote */ } $thread_search = !$thread_nosearch; $thread_tag = !$thread_nocloud; $thread_comment = !$thread_nocomment; $thread_morecomment = !$thread_nomorecomment; $thread_vote = !$thread_novote; $thread_morevote = !$thread_nomorevote; break; case 'edit': case 'create': case 'copy': case 'delete': case 'hide': case 'show': case 'reorder': if (isset($_POST['thread_type'])) { $thread_type = readarg($_POST['thread_type']); } if (isset($_POST['thread_title'])) { $thread_title = readarg($_POST['thread_title']); } if (isset($_POST['thread_name'])) { $thread_name = strtofname(readarg($_POST['thread_name'])); } if (!$thread_name and $thread_title) { $thread_name = strtofname($thread_title); } if (isset($_POST['thread_abstract'])) { $thread_abstract = readarg($_POST['thread_abstract']); } if (isset($_POST['thread_image'])) { $thread_image = readarg($_POST['thread_image']); } if (isset($_POST['thread_cloud'])) { $thread_cloud = readarg($_POST['thread_cloud'], true, false); // trim but DON'T strip! preg_match_all('/(\\S+)/', $thread_cloud, $r); $thread_cloud = implode(' ', array_unique($r[0])); } if (isset($_POST['thread_search'])) { $thread_search = readarg($_POST['thread_search']) == 'on' ? true : false; $thread_nosearch = !$thread_search; } if (isset($_POST['thread_tag'])) { $thread_tag = readarg($_POST['thread_tag']) == 'on' ? true : false; $thread_nocloud = !$thread_tag; } if (isset($_POST['thread_visits'])) { $thread_visits = readarg($_POST['thread_visits']) == 'on' ? true : false; } if (isset($_POST['thread_comment'])) { $thread_comment = readarg($_POST['thread_comment']) == 'on' ? true : false; $thread_nocomment = !$thread_comment; } if (isset($_POST['thread_morecomment'])) { $thread_morecomment = readarg($_POST['thread_morecomment']) == 'on' ? true : false; $thread_nomorecomment = !$thread_morecomment; } if (isset($_POST['thread_vote'])) { $thread_vote = readarg($_POST['thread_vote']) == 'on' ? true : false; $thread_novote = !$thread_vote; } if (isset($_POST['thread_morevote'])) { $thread_morevote = readarg($_POST['thread_morevote']) == 'on' ? true : false; $thread_nomorevote = !$thread_morevote; } if (isset($_POST['thread_ilike'])) { $thread_ilike = readarg($_POST['thread_ilike'] == 'on' ? true : false); } if (isset($_POST['thread_tweet'])) { $thread_tweet = readarg($_POST['thread_tweet'] == 'on' ? true : false); } if (isset($_POST['thread_plusone'])) { $thread_plusone = readarg($_POST['thread_plusone'] == 'on' ? true : false); } if (isset($_POST['thread_linkedin'])) { $thread_linkedin = readarg($_POST['thread_linkedin'] == 'on' ? true : false); } if (isset($_POST['thread_pinit'])) { $thread_pinit = readarg($_POST['thread_pinit'] == 'on' ? true : false); } if (isset($_POST['new_node_title'])) { $new_node_title = readarg($_POST['new_node_title']); $new_node_name = strtofname($new_node_title); } if (isset($_POST['new_node_number'])) { $new_node_number = readarg($_POST['new_node_number']); } if (isset($_POST['old_node_number'])) { $old_node_number = readarg($_POST['old_node_number']); } if (isset($_POST['p'])) { $p = $_POST['p']; // DON'T readarg! } break; default: break; } $thread_contents = array(); $r = thread_get_contents($clang, $thread_id, false); /* node_id node_number node_ignored node_name node_title node_cloud thread_image */ if (!$r or count($r) != count($p)) { $p = false; } if ($r) { $pos = 1; $thread_url = url('threadedit', $lang) . '/' . $thread_id; foreach ($r as $c) { $c['node_url'] = $thread_url . '/' . $c['node_id']; $c['pos'] = $p ? $p[$pos] : $pos; $thread_contents[$pos] = $c; $pos++; } } $missing_thread_name = false; $bad_thread_name = false; $missing_thread_type = false; $bad_thread_type = false; $missing_new_node_title = false; $bad_new_node_title = false; $bad_new_node_number = false; $missing_old_node_number = false; $bad_old_node_number = false; switch ($action) { case 'edit': if (!$thread_name) { $missing_thread_name = true; } else { if (!preg_match('#^\\w+(-\\w+)*$#', $thread_name)) { $bad_thread_name = true; } } if (!$thread_type) { $missing_thread_type = true; } else { if (!in_array($thread_type, $supported_threads)) { $bad_thread_type = true; } } break; case 'create': case 'copy': if (!$new_node_title) { $missing_new_node_title = true; } else { if (!$new_node_name) { $bad_new_node_title = true; } else { if (!preg_match('#^\\w+(-\\w+)*$#', $new_node_name)) { $bad_new_node_title = true; } } } if (!$new_node_number) { $new_node_number = false; } else { if (!is_numeric($new_node_number)) { $bad_new_node_number = true; } else { if ($new_node_number < 1 or $new_node_number > count($thread_contents) + 1) { $bad_new_node_number = true; } } } if ($action == 'create') { break; } /* fall thru */ /* fall thru */ case 'delete': case 'hide': case 'show': if (!$old_node_number) { $missing_old_node_number = true; } else { if (!is_numeric($old_node_number)) { $bad_old_node_number = true; } else { if ($old_node_number < 1 or $old_node_number > count($thread_contents)) { $bad_old_node_number = true; } } } break; case 'reorder': break; default: break; } $confirm_delete_node = false; switch ($action) { case 'edit': if ($missing_thread_name or $bad_thread_name or $missing_thread_type or $bad_thread_type) { break; } $r = thread_set($clang, $thread_id, $thread_name, $thread_title, $thread_type, $thread_abstract, $thread_cloud, $thread_image, $thread_visits, $thread_nosearch, $thread_nocloud, $thread_nocomment, $thread_nomorecomment, $thread_novote, $thread_nomorevote, $thread_ilike, $thread_tweet, $thread_plusone, $thread_linkedin, $thread_pinit); if (!$r) { break; } break; case 'create': case 'copy': if ($missing_new_node_title or $bad_new_node_title or $bad_new_node_number or $action == 'copy' and ($missing_old_node_number or $bad_old_node_number)) { break; } $user_id = user_profile('id'); if ($action == 'copy') { $node_id = $thread_contents[$old_node_number]['node_id']; $np = thread_copy_node($clang, $user_id, $thread_id, $node_id, $new_node_name, $new_node_title, $new_node_number); } else { $np = thread_create_node($clang, $user_id, $thread_id, $new_node_name, $new_node_title, $new_node_number); } if (!$np) { break; } extract($np); /* node_id node_number node_ignored */ $node_ignored = false; $node_title = $new_node_title; $node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $node_id; $pos = $node_number; if ($thread_contents) { foreach ($thread_contents as &$c) { if ($c['node_number'] >= $pos) { $c['node_number']++; } if ($c['pos'] >= $pos) { $c['pos']++; } } array_splice($thread_contents, $pos - 1, 0, array(compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos'))); } else { $pos = 1; $thread_contents = array($pos => compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos')); } $new_node_name = $new_node_title = false; $new_node_number = $node_number + 1; $old_node_number = false; break; case 'delete': if ($missing_old_node_number or $bad_old_node_number) { break; } if (!$confirmed) { $confirm_delete_node = true; break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_delete_node($thread_id, $node_id); if (!$r) { break; } unset($thread_contents[$old_node_number]); $thread_contents = array_values($thread_contents); foreach ($thread_contents as &$c) { if ($c['node_number'] >= $old_node_number) { $c['node_number']--; } if ($c['pos'] >= $old_node_number) { $c['pos']--; } } $new_node_number = $old_node_number = false; break; case 'hide': if ($missing_old_node_number or $bad_old_node_number) { break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_set_node_ignored($thread_id, $node_id, true); if (!$r) { break; } $thread_contents[$old_node_number]['node_ignored'] = true; break; case 'show': if ($missing_old_node_number or $bad_old_node_number) { break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_set_node_ignored($thread_id, $node_id, false); if (!$r) { break; } $thread_contents[$old_node_number]['node_ignored'] = false; break; case 'reorder': if (!$p) { break; } $neworder = range(1, count($p)); array_multisort($p, SORT_NUMERIC, $neworder); $number = 1; $nc = array(); foreach ($neworder as $i) { $c =& $thread_contents[$i]; if ($c['node_number'] != $number) { thread_set_node_number($thread_id, $c['node_id'], $number); $c['node_number'] = $number; } $c['pos'] = $number; $nc[$number++] = $c; } $thread_contents = $nc; break; default: break; } head('title', $thread_title ? $thread_title : $thread_id); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $headline_text = translate('threadall:title', $lang); $headline_url = url('threadedit', $lang) . '?' . 'clang=' . $clang; $headline = compact('headline_text', 'headline_url'); $view = $thread_name ? url('thread', $clang) . '/' . $thread_id . '?' . 'slang=' . $lang : false; $scroll = true; $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false; $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('title')); $inlanguages = view('inlanguages', false, compact('clang')); $errors = compact('missing_thread_name', 'bad_thread_name', 'missing_thread_type', 'bad_thread_type', 'missing_new_node_title', 'bad_new_node_title', 'bad_new_node_number', 'missing_old_node_number', 'bad_old_node_number'); $content = view('editing/threadeditsummary', $lang, compact('clang', 'inlanguages', 'supported_threads', 'thread_id', 'thread_type', 'thread_title', 'thread_name', 'thread_abstract', 'thread_cloud', 'thread_image', 'thread_visits', 'thread_search', 'thread_tag', 'thread_comment', 'thread_morecomment', 'thread_vote', 'thread_morevote', 'thread_ilike', 'thread_tweet', 'thread_plusone', 'thread_linkedin', 'thread_pinit', 'thread_contents', 'new_node_name', 'new_node_title', 'new_node_number', 'old_node_number', 'confirm_delete_node', 'errors')); $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
} else { if (isset($_POST['msg']) && validate_msg($_POST['msg'])) { $msg = $_POST['msg']; list($tid, $pid) = explode(".", $_POST['msg']); } else { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } } // Get the folder ID for the current message if (!($fid = thread_get_folder($tid))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } // UID of the current user. $uid = session::get_value('UID'); // Get the existing thread data. if (!($thread_data = thread_get($tid, true))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } // Array to hold error messages $error_msg_array = array(); // Array of valid thread deletion types $thread_delete_valid_types = array(THREAD_DELETE_PERMENANT, THREAD_DELETE_NON_PERMENANT); // Back button clicked. if (isset($_POST['back'])) { header_redirect("messages.php?webtag={$webtag}&msg={$msg}"); exit; } // Code for handling functionality from messages.php if (isset($_GET['markasread']) && is_numeric($_GET['markasread'])) { if (in_range($_GET['markasread'], 0, $thread_data['LENGTH'])) { $mark_as_read = $_GET['markasread'];
header_redirect("messages.php?webtag={$webtag}&msg={$msg}"); } } } // Number of posts per page if (isset($_SESSION['POSTS_PER_PAGE']) && is_numeric($_SESSION['POSTS_PER_PAGE'])) { $posts_per_page = max(min($_SESSION['POSTS_PER_PAGE'], 30), 10); } else { $posts_per_page = 20; } $high_interest = isset($_SESSION['MARK_AS_OF_INT']) && $_SESSION['MARK_AS_OF_INT'] == 'Y' ? 'Y' : 'N'; if (!($folder_data = thread_get_folder($tid))) { html_draw_error(gettext("The requested folder could not be found or access was denied.")); } $perm_folder_moderate = session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_data['FID']); if (!($thread_data = thread_get($tid, $perm_folder_moderate, false, $perm_folder_moderate))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } if (!($messages = messages_get($tid, $pid, $posts_per_page))) { html_draw_error(gettext("That post does not exist in this thread!")); } html_draw_top(array('title' => $thread_data['TITLE'], 'class' => 'window_title', 'js' => array('js/post.js', 'js/poll.js', 'js/messages.js', 'ckeditor/ckeditor.js'), 'base_target' => '_blank')); if (isset($thread_data['STICKY']) && isset($thread_data['STICKY_UNTIL'])) { if ($thread_data['STICKY'] == "Y" && $thread_data['STICKY_UNTIL'] != 0 && time() > $thread_data['STICKY_UNTIL']) { thread_set_sticky($tid, false); $thread_data['STICKY'] = "N"; } } $show_sigs = session::show_sigs(); $page_prefs = session::get_post_page_prefs(); $msg_count = count($messages);
} else { if (isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page']; if (($search_results_array = search_fetch_results($page, $sort_by, $sort_dir)) !== false) { html_draw_top(array('js' => array('js/search.js', 'js/search_popup.js', 'js/thread_list.js'))); thread_list_draw_top(SEARCH_RESULTS); echo "<br />\n"; echo "<h1>", gettext("Search Results"), "</h1>\n"; echo "", html_style_image('search', gettext("Found")), " ", gettext("Found"), ": {$search_results_array['result_count']} ", gettext("matches"), "<br />\n"; if ($page > 1) { echo "", html_style_image('current_thread', gettext("Previous page")), " <a href=\"search.php?webtag={$webtag}&page=", $page - 1, "&sort_by={$sort_by}&sort_dir={$sort_dir}\">", gettext("Previous page"), "</a>\n"; } echo "<ol start=\"", $page * 20 - 20 + 1, "\">\n"; foreach ($search_results_array['result_array'] as $search_result) { if (($message = messages_get($search_result['TID'], $search_result['PID'], 1)) !== false) { if (($thread_data = thread_get($search_result['TID'])) !== false) { $message['TITLE'] = trim($thread_data['TITLE']); // Fetch the messaage content, strip the signature and remove HTML. $message['CONTENT'] = message_get_content($search_result['TID'], $search_result['PID']); $message['CONTENT'] = message_apply_formatting($message['CONTENT'], true); $message['CONTENT'] = trim(strip_tags($message['CONTENT'])); // Limit thread title to 20 characters. if (mb_strlen($message['TITLE']) > 20) { $message['TITLE'] = word_filter_add_ob_tags(mb_substr($message['TITLE'], 0, 20), true) . "…"; } else { $message['TITLE'] = word_filter_add_ob_tags($message['TITLE'], true); } // Limit displayed post content to 35 characters if (mb_strlen($message['CONTENT']) > 70) { $message['CONTENT'] = word_filter_add_ob_tags(fix_html(mb_substr($message['CONTENT'], 0, 70)), true) . "…"; } else {
html_draw_error(gettext("There are no folders available.")); } // Get total number of messages for each folder $folder_msgs = threads_get_folder_msgs(); // Check that the folder order is a valid array. if (!is_array($folder_order)) { $folder_order = array(); } // Check the folder display order. if (isset($_SESSION['THREADS_BY_FOLDER']) && $_SESSION['THREADS_BY_FOLDER'] == 'Y') { $folder_order = array_keys($folder_info); } // Check for a message to display and re-order the thread list. if (isset($_REQUEST['msg']) && validate_msg($_REQUEST['msg'])) { list($selected_tid) = explode('.', $_REQUEST['msg']); if (($thread = thread_get($selected_tid)) !== false) { if (!isset($thread['RELATIONSHIP'])) { $thread['RELATIONSHIP'] = 0; } // Check the folder display order / user is a guest. if (!isset($_SESSION['THREADS_BY_FOLDER']) || $_SESSION['THREADS_BY_FOLDER'] != 'Y' || !session::logged_in()) { // Remove the folder from the list of folders. if (in_array($thread['FID'], $folder_order)) { array_splice($folder_order, array_search($thread['FID'], $folder_order), 1); } // Re-add it at the top of the list. array_unshift($folder_order, $thread['FID']); } // Check $thread_info is an array. if (!is_array($thread_info)) { $thread_info = array();
function threadeditnode($lang, $clang, $thread, $node) { global $with_toolbar, $supported_contents, $limited_contents; if (!user_has_role('writer')) { return run('error/unauthorized', $lang); } $thread_id = thread_id($thread); if (!$thread_id) { return run('error/notfound', $lang); } $node_id = thread_node_id($thread_id, $node, $clang); if (!$node_id) { return run('error/notfound', $lang); } $thread_name = $thread_title = $thread_abstract = $thread_cloud = $thread_type = false; $r = thread_get($clang, $thread_id, false); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_name thread_title thread_abstract thread_cloud thread_type */ $content_types = $supported_contents; if ($thread_type and $limited_contents and array_key_exists($thread_type, $limited_contents)) { $content_types = $limited_contents[$thread_type]; } $node_editor = build('nodeeditor', $lang, $clang, $node_id, $content_types); $node_name = $node_title = false; $r = thread_get_node($clang, $thread_id, $node_id, false); if ($r) { extract($r); /* node_name node_title */ } head('title', $thread_title ? $thread_title : $thread_id); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $banner = $toolbar = false; $headline_text = $thread_title ? $thread_title : $thread_id; $headline_url = url('threadedit', $lang) . '/' . $thread_id . '?' . 'clang=' . $clang; $headline = compact('headline_text', 'headline_url'); $view = $node_name ? url('thread', $clang) . '/' . $thread_id . '/' . $node_id . '?' . 'slang=' . $lang : false; $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view')); $scroll = true; $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false; $prev_node_label = $prev_node_url = false; $r = thread_node_prev($clang, $thread_id, $node_id, false); if ($r) { extract($r); $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_id; $prev_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $prev_node_id . '?' . 'clang=' . $clang; } $next_node_label = $next_node_url = false; $r = thread_node_next($clang, $thread_id, $node_id, false); if ($r) { extract($r); $next_node_label = $next_node_title ? $next_node_title : $next_node_id; $next_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $next_node_id . '?' . 'clang=' . $clang; } $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('title')); $content = view('editing/threadeditnode', $lang, compact('node_editor', 'node_id', 'node_title', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label')); $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
if (isset($_GET['maxResults']) && is_numeric($_GET['maxResults']) && $_GET['maxResults'] >= 1) { $maxResults = round($_GET['maxResults']); } $optParams['maxResults'] = $maxResults; // echo "<pre>"; // print_r($optParams); // echo "</pre>"; $result = null; switch ($search) { case 'thread': // Get Threads if ($method == "list") { $result = thread_list($service, $optParams); } else { if ($method == "get") { $result = thread_get($service, $userId, $id); } } break; case 'message': if ($method == "list") { $result = message_list($service, $maxResults); } else { if ($method == "get") { $result = message_get($service, $userId, $id); } } break; case 'label': if ($method == "list") { $result = label_list($service, $userId);
function search($lang, $arglist = false) { global $search_all, $search_pertinence, $rss_thread; $cloud = false; if (is_array($arglist)) { if (isset($arglist[0])) { $cloud = $arglist[0]; } } $cloud_id = $cloud_name = false; $thread_nocloud = $thread_nosearch = false; if ($cloud) { $cloud_id = cloud_id($cloud); if (!$cloud_id) { return run('error/notfound', $lang); } if ($cloud_id == $rss_thread) { if (!user_has_role('administrator')) { return run('error/unauthorized', $lang); } } $r = cloud_get($lang, $cloud_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* cloud_name cloud_title cloud_action */ $r = thread_get($lang, $cloud_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_type thread_nocloud thread_nosearch */ if ($thread_type == 'thread' or $thread_nosearch and $thread_nocloud) { return run('error/notfound', $lang); } } else { if ($search_all === false) { return run('error/notfound', $lang); } if ($search_all !== true) { $thread_nosearch = true; } } $action = 'none'; if (isset($_POST['search'])) { $action = 'search'; } $searchtext = $taglist = false; $rsearch = false; switch ($action) { case 'none': if (!empty($arglist['q'])) { $searchtext = $arglist['q']; $taglist = explode(' ', $searchtext); } break; case 'search': if (isset($_POST['searchtext'])) { $searchtext = readarg($_POST['searchtext'], true, false); // trim but DON'T strip! if ($searchtext) { global $search_distance, $search_closest; $taglist = cloud_match($lang, $cloud_id, $searchtext, $search_distance, $search_closest); } } break; default: break; } if ($taglist) { $rsearch = cloud_search($lang, $cloud_id, $taglist, $search_pertinence); } $search_title = translate('search:title', $lang); $search_url = false; $search = $cloud = $title = false; if ($rsearch) { if (!$thread_nosearch) { $search_url = url('search', $lang, $cloud_name); } if (!$thread_nocloud) { $cloud_url = url('search', $lang, $cloud_name); $byname = $bycount = $index = true; $cloud = build('cloud', $lang, $cloud_url, $cloud_id, false, 30, compact('byname', 'bycount', 'index')); } $headline_text = $search_title; $headline_url = false; $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $content = build('searchlist', $lang, $rsearch, $taglist); } else { $headline_text = $cloud_id ? $cloud_title : $search_title; $headline_url = false; if (!$thread_nosearch) { $search_url = url('search', $lang, $cloud_name); } $cloud_url = url('search', $lang, $cloud_name); $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $byname = true; $bycount = $index = false; $content = build('cloud', $lang, $cloud_url, $cloud_id, false, false, compact('byname', 'bycount', 'index')); } if ($search_url) { $search_text = $searchtext; $suggest_url = url('suggest', $lang, $cloud_name); $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url')); } $sidebar = view('sidebar', false, compact('search', 'cloud', 'title')); if ($search) { $search = compact('search_url', 'search_text', 'suggest_url'); } $banner = build('banner', $lang, compact('headline', 'search')); head('title', $cloud_id ? $cloud_title : $search_title); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $output = layout('standard', compact('banner', 'content', 'sidebar')); return $output; }
function light_draw_thread_list($mode = ALL_DISCUSSIONS, $folder = false, $page = 1) { $webtag = get_webtag(); forum_check_webtag_available($webtag); $error_msg_array = array(); $available_views = thread_list_available_views(); $visible_threads_array = array(); if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) { return; } light_thread_list_draw_top($mode, $folder); switch ($mode) { case UNREAD_DISCUSSIONS: list($thread_info, $folder_order, $thread_count) = threads_get_unread($_SESSION['UID'], $folder, $page); break; case UNREAD_DISCUSSIONS_TO_ME: list($thread_info, $folder_order, $thread_count) = threads_get_unread_to_me($_SESSION['UID'], $folder, $page); break; case TODAYS_DISCUSSIONS: list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 1); break; case UNREAD_TODAY: list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_days($_SESSION['UID'], $folder, $page); break; case TWO_DAYS_BACK: list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 2); break; case SEVEN_DAYS_BACK: list($thread_info, $folder_order, $thread_count) = threads_get_by_days($_SESSION['UID'], $folder, $page, 7); break; case HIGH_INTEREST: list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_INTERESTED); break; case UNREAD_HIGH_INTEREST: list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_interest($_SESSION['UID'], $folder, $page, THREAD_INTERESTED); break; case RECENTLY_SEEN: list($thread_info, $folder_order, $thread_count) = threads_get_recently_viewed($_SESSION['UID'], $folder, $page); break; case IGNORED_THREADS: list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_IGNORED); break; case BY_IGNORED_USERS: list($thread_info, $folder_order, $thread_count) = threads_get_by_relationship($_SESSION['UID'], $folder, $page, USER_IGNORED_COMPLETELY); break; case SUBSCRIBED_TO: list($thread_info, $folder_order, $thread_count) = threads_get_by_interest($_SESSION['UID'], $folder, $page, THREAD_SUBSCRIBED); break; case STARTED_BY_FRIEND: list($thread_info, $folder_order, $thread_count) = threads_get_by_relationship($_SESSION['UID'], $folder, $page, USER_FRIEND); break; case UNREAD_STARTED_BY_FRIEND: list($thread_info, $folder_order, $thread_count) = threads_get_unread_by_relationship($_SESSION['UID'], $folder, $page, USER_FRIEND); break; case STARTED_BY_ME: list($thread_info, $folder_order, $thread_count) = threads_get_started_by_me($_SESSION['UID'], $folder, $page); break; case POLL_THREADS: list($thread_info, $folder_order, $thread_count) = threads_get_polls($_SESSION['UID'], $folder, $page); break; case STICKY_THREADS: list($thread_info, $folder_order, $thread_count) = threads_get_sticky($_SESSION['UID'], $folder, $page); break; case MOST_UNREAD_POSTS: list($thread_info, $folder_order, $thread_count) = threads_get_longest_unread($_SESSION['UID'], $folder, $page); break; case DELETED_THREADS: list($thread_info, $folder_order, $thread_count) = threads_get_deleted($_SESSION['UID'], $folder, $page); break; default: list($thread_info, $folder_order, $thread_count) = threads_get_all($_SESSION['UID'], $folder, $page); break; } // Now, the actual bit that displays the threads... // Get folder FIDs and titles if (!($folder_info = threads_get_folders())) { light_html_display_error_msg(gettext("There are no folders available.")); return; } // Get total number of messages for each folder $folder_msgs = threads_get_folder_msgs(); // Check that the folder order is a valid array. if (!is_array($folder_order)) { $folder_order = array(); } // Check the folder display order. if (isset($_SESSION['THREADS_BY_FOLDER']) && $_SESSION['THREADS_BY_FOLDER'] == 'Y') { $folder_order = array_keys($folder_info); } // Check for a message to display and re-order the thread list. if (isset($_REQUEST['msg']) && validate_msg($_REQUEST['msg'])) { list($selected_tid) = explode('.', $_REQUEST['msg']); if (($thread = thread_get($selected_tid)) !== false) { if (!isset($thread['RELATIONSHIP'])) { $thread['RELATIONSHIP'] = 0; } // Check the folder display order / user is a guest. if (!isset($_SESSION['THREADS_BY_FOLDER']) || $_SESSION['THREADS_BY_FOLDER'] != 'Y' || !session::logged_in()) { // Remove the folder from the list of folders. if (in_array($thread['FID'], $folder_order)) { array_splice($folder_order, array_search($thread['FID'], $folder_order), 1); } // Re-add it at the top of the list. array_unshift($folder_order, $thread['FID']); } // Check $thread_info is an array. if (!is_array($thread_info)) { $thread_info = array(); } // Check to see if the thread is already in the list. // If it is remove it, otherwise take the last thread // off the list so we always only have 50 threads on display. if (isset($thread_info[$selected_tid])) { unset($thread_info[$selected_tid]); } else { $thread_info = array_slice($thread_info, 0, 50, true); } // Add the requested thread to the top of the list of threads. array_unshift($thread_info, $thread); } } // Check for a specified folder and move it to the top of the thread list. if (isset($folder) && is_numeric($folder)) { if (in_array($folder, $folder_order)) { array_splice($folder_order, array_search($folder, $folder_order), 1); } array_unshift($folder_order, $folder); } if ($_SESSION['UID'] > 0) { // Array to hold our ignored folders in. $ignored_folders = array(); // Loop through the list of folders and check their status. // If they're ignored and not already set to be on display // they need to be added to $ignored_folders so that they // appear at the bottom of the thread list. foreach ($folder_info as $fid => $folder_data) { if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) { if ($folder_data['INTEREST'] != FOLDER_IGNORED || isset($folder) && $folder == $fid) { array_push($folder_order, $fid); } else { array_push($ignored_folders, $fid); } } } // Append ignored folders onto the end of the folder list. // This will make them appear at the bottom of the thread list. $folder_order = array_merge($folder_order, $ignored_folders); } else { foreach ($folder_info as $fid => $folder_data) { if (!in_array($fid, $folder_order)) { $folder_order[] = $fid; } } } // If no threads are returned, say something to that effect if (isset($_REQUEST['mark_read_success'])) { light_html_display_success_msg(gettext("Successfully marked selected threads as read")); } else { if (!is_array($thread_info)) { if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) { $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&folder={$folder}&mode=0\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("No "%s" in "%s" folder. Please select another folder, or %s for all threads."), $available_views[$mode], $folder_title, $all_discussions_link)); } else { $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&mode=0\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("No "%s" available. Please %s for all threads."), $available_views[$mode], $all_discussions_link)); } } else { if (isset($error_msg_array) && sizeof($error_msg_array) > 0) { light_html_display_error_array($error_msg_array); } else { if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) { $all_folders_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("Viewing "%s" in "%s" only. To view threads in all folders %s."), $available_views[$mode], $folder_title, $all_folders_link)); } } } } if ($page > 1 && !is_numeric($folder)) { echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n"; } // Unread cut-off $thread_unread_cutoff = threads_get_unread_cutoff(); // Iterate through the information we've just got and display it in the right order foreach ($folder_order as $folder_number) { if (isset($folder_info[$folder_number]) && is_array($folder_info[$folder_number])) { echo "<div class=\"folder\">\n"; echo " <h3>", html_style_image('folder'), "<a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder_number}\">", word_filter_add_ob_tags($folder_info[$folder_number]['TITLE'], true), "</a></h3>"; echo " <div class=\"folder_inner\">\n"; if (!session::logged_in() || $folder_info[$folder_number]['INTEREST'] > FOLDER_IGNORED || $mode == UNREAD_DISCUSSIONS_TO_ME || isset($folder) && $folder == $folder_number) { if (is_array($thread_info)) { echo " <div class=\"folder_info\">"; if (isset($folder_msgs[$folder_number])) { echo $folder_msgs[$folder_number]; } else { echo "0"; } echo " ", gettext("threads"), ""; if (is_null($folder_info[$folder_number]['STATUS']) || $folder_info[$folder_number]['STATUS'] & USER_PERM_THREAD_CREATE) { if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) { echo "<span><a href=\"lpost.php?webtag={$webtag}&fid={$folder_number}\">", gettext("Post New"), "</a></span>"; } } echo " </div>\n"; if ($page > 1 && is_numeric($folder) && $folder_number == $folder) { echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder}&page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n"; } $folder_list_start = false; $folder_list_end = false; foreach ($thread_info as $thread) { if (!in_array($thread['TID'], $visible_threads_array)) { $visible_threads_array[] = $thread['TID']; } if ($thread['FID'] == $folder_number) { if ($folder_list_start === false) { echo "<ul>\n"; $folder_list_start = true; } echo "<li>"; if (!session::logged_in() || ($thread['LAST_READ'] == 0 || $thread['LAST_READ'] < $thread['LENGTH']) && $thread['MODIFIED'] > $thread_unread_cutoff) { $new_posts = $thread['LENGTH'] - $thread['LAST_READ']; if ($new_posts == $thread['LENGTH']) { $number = "[{$thread['LENGTH']} new]"; } else { $number = "[{$new_posts} new of {$thread['LENGTH']}]"; } $latest_post = $thread['LAST_READ'] + 1; } else { $number = "[{$thread['LENGTH']}]"; $latest_post = 1; } // work out how long ago the thread was posted and format the time to display $thread_time = format_date_time($thread['MODIFIED']); echo "<span class=\"thread_icon\">", html_style_image('bullet'), "</span>"; echo "<span class=\"thread_title\">"; echo "<a href=\"lmessages.php?webtag={$webtag}&msg={$thread['TID']}.{$latest_post}\" "; echo "title=\"", sprintf(gettext("Thread #%s Started by %s. Viewed %s"), $thread['TID'], word_filter_add_ob_tags(format_user_name($thread['LOGON'], $thread['NICKNAME']), true), $thread['VIEWCOUNT'] == 1 ? gettext("1 time") : sprintf(gettext("%d times"), $thread['VIEWCOUNT'])), "\">"; echo word_filter_add_ob_tags($thread['TITLE'], true), "</a> "; echo "<span class=\"thread_detail\">"; if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_INTERESTED) { echo html_style_image('high_interest', gettext("High Interest")); } if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_SUBSCRIBED) { echo html_style_image('subscribe', gettext("Subscribed")); } if (isset($thread['POLL_FLAG']) && $thread['POLL_FLAG'] == 'Y') { echo html_style_image('poll', gettext("Poll")); } if (isset($thread['STICKY']) && $thread['STICKY'] == 'Y') { echo html_style_image('sticky', gettext("Sticky")); } if (isset($thread['RELATIONSHIP']) && $thread['RELATIONSHIP'] & USER_FRIEND) { echo html_style_image('friend', gettext("Friend")); } if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_SPLIT) { echo html_style_image('split_thread', gettext("Thread has been split")); } if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_MERGE) { echo html_style_image('merge_thread', gettext("Thread has been merged")); } if (isset($thread['ATTACHMENT_COUNT']) && $thread['ATTACHMENT_COUNT'] > 0) { echo html_style_image('attach', gettext("Attachment")); } echo "<span class=\"thread_length\">{$number}</span>"; echo "</span>"; echo "</span>"; echo "<span class=\"thread_time\">{$thread_time}</span>"; echo "</li>\n"; } } if ($folder_list_end === false && $folder_list_start === true) { echo "</ul>\n"; } if (is_numeric($folder) && $folder_number == $folder && $thread_count >= 50) { echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder}&page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n"; } } else { if ($folder_info[$folder_number]['INTEREST'] != FOLDER_IGNORED) { echo "<div class=\"folder_info\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder_number}\">"; if (isset($folder_msgs[$folder_number])) { echo $folder_msgs[$folder_number]; } else { echo "0"; } echo " ", gettext("threads"), "</a>"; if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) { echo "<span><a href=\"lpost.php?webtag={$webtag}&fid={$folder_number}\">", gettext("Post New"), "</a></span>"; } echo "</div>\n"; } } } echo " </div>\n"; echo "</div>\n"; if (is_array($thread_info)) { reset($thread_info); } } } if (!is_numeric($folder) && $thread_count >= 50) { echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n"; } if (session::logged_in()) { echo "<div id=\"thread_mark_read\">\n"; echo "<h3>", gettext("Mark as Read"), "</h3>\n"; echo "<form accept-charset=\"utf-8\" name=\"f_mark\" method=\"post\" action=\"lthread_list.php\">\n"; echo " ", form_csrf_token_field(), "\n"; echo form_input_hidden("webtag", htmlentities_array($webtag)), "\n"; echo form_input_hidden("mode", htmlentities_array($mode)), "\n"; echo form_input_hidden("page", htmlentities_array($page)), "\n"; echo form_input_hidden("mark_read_confirm", 'N'), "\n"; $labels = array(gettext("All Discussions"), gettext("Next 50 discussions")); $selected_option = THREAD_MARK_READ_ALL; if (sizeof($visible_threads_array) > 0) { $labels[] = gettext("Visible discussions"); $selected_option = THREAD_MARK_READ_VISIBLE; $visible_threads = implode(',', array_filter($visible_threads_array, 'is_numeric')); echo form_input_hidden("mark_read_threads", htmlentities_array($visible_threads)), "\n"; } if (isset($_GET['folder']) && is_numeric($_GET['folder'])) { echo form_input_hidden('folder', htmlentities_array($folder)), "\n"; $labels[] = gettext("Selected folder"); $selected_option = THREAD_MARK_READ_FOLDER; } echo "<ul>\n"; echo "<li>", light_form_dropdown_array("mark_read_type", $labels, $selected_option), "</li>\n"; echo "<li class=\"right_col\">", light_form_submit("mark_read_submit", gettext("Go!")), "</li>\n"; echo "</ul>\n"; echo "</form>\n"; echo "</div>\n"; } }
function html_draw_top(array $options = array()) { $title = null; $class = null; $base_target = null; $robots = null; $main_css = null; $images_css = null; $inline_css = null; $emoticons = null; $frame_set_html = false; $pm_popup_disabled = false; $js = array(); $css = array(); $webtag = get_webtag(); forum_check_webtag_available($webtag); $forum_name = forum_get_setting('forum_name', null, 'A Beehive Forum'); foreach ($options as $key => $value) { switch ($key) { case 'title': case 'class': case 'base_target': case 'robots': case 'main_css': case 'images_css': case 'inline_css': case 'emoticons': ${$key} = !isset(${$key}) && isset($value) ? $value : ${$key}; break; case 'frame_set_html': case 'pm_popup_disabled': ${$key} = is_bool($value) ? $value : ${$key}; break; case 'js': case 'css': if (!is_array($value) || count(array_filter($value, 'is_string')) != count($value)) { throw new InvalidArgumentException(sprintf('Expecting html_draw_top argument %s to be an array of strings', $key)); } ${$key} = $value; break; default: throw new InvalidArgumentException(sprintf('Unknown html_draw_top argument "%s"', $key)); break; } } if (!isset($main_css)) { $main_css = 'style.css'; } if (!isset($images_css)) { $images_css = 'images.css'; } if ($frame_set_html === false) { echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; } else { echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n"; } echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"", gettext('en-gb'), "\" lang=\"", gettext('en-gb'), "\" dir=\"", gettext('ltr'), "\">\n"; echo "<head>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; // Default Meta keywords and description. $meta_keywords = html_get_forum_keywords(); $meta_description = html_get_forum_description(); if (isset($_GET['msg']) && validate_msg($_GET['msg'])) { list($tid, $pid) = explode('.', $_GET['msg']); message_get_meta_content($_GET['msg'], $meta_keywords, $meta_description); if (isset($_SESSION['POSTS_PER_PAGE']) && is_numeric($_SESSION['POSTS_PER_PAGE'])) { $posts_per_page = max(min($_SESSION['POSTS_PER_PAGE'], 30), 10); } else { $posts_per_page = 20; } if (($thread_data = thread_get($tid)) !== false) { echo "<title>", word_filter_add_ob_tags($thread_data['TITLE'], true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n"; echo "<link rel=\"canonical\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.1"), "\" />\n"; if ($thread_data['LENGTH'] > $posts_per_page) { $prev_page = $pid - $posts_per_page > 0 ? $pid - $posts_per_page : 1; $next_page = $pid + $posts_per_page < $thread_data['LENGTH'] ? $pid + $posts_per_page : $thread_data['LENGTH']; $last_page = floor($thread_data['LENGTH'] / $posts_per_page) * $posts_per_page + 1; echo "<link rel=\"first\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.1"), "\" />\n"; echo "<link rel=\"last\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.{$last_page}"), "\" />\n"; if ($pid + $posts_per_page < $thread_data['LENGTH']) { echo "<link rel=\"next\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.{$next_page}"), "\" />\n"; } if ($pid > 1) { echo "<link rel=\"prev\" href=\"", html_get_forum_uri("index.php?webtag={$webtag}&msg={$tid}.{$prev_page}"), "\" />\n"; } } } else { if (isset($title)) { echo "<title>", word_filter_add_ob_tags($title, true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n"; } else { echo "<title>", word_filter_add_ob_tags($forum_name, true), "</title>\n"; } } } else { if (isset($title)) { echo "<title>", word_filter_add_ob_tags($title, true), " - ", htmlentities_array($forum_name), "</title>\n"; } else { echo "<title>", htmlentities_array($forum_name), "</title>\n"; } } $forum_content_rating = html_get_forum_content_rating(); echo "<meta name=\"generator\" content=\"Beehive Forum ", BEEHIVE_VERSION, "\" />\n"; echo "<meta name=\"keywords\" content=\"", word_filter_add_ob_tags($meta_keywords, true), "\" />\n"; echo "<meta name=\"description\" content=\"", word_filter_add_ob_tags($meta_description, true), "\" />\n"; echo "<meta name=\"rating\" content=\"{$forum_content_rating}\" />\n"; if (forum_get_setting('allow_search_spidering', 'N') || isset($pid) && $pid > 1) { echo "<meta name=\"robots\" content=\"noindex,nofollow\" />\n"; } else { if (isset($robots)) { echo "<meta name=\"robots\" content=\"", htmlentities_array($robots), "\" />\n"; } } printf("<meta name=\"application-name\" content=\"%s\" />\n", htmlentities_array(word_filter_add_ob_tags($forum_name, true))); printf("<meta name=\"msapplication-tooltip\" content=\"%s\" />\n", htmlentities_array(word_filter_add_ob_tags($meta_description, true))); if (forum_check_webtag_available($webtag)) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Messages'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=discussion.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/unread_thread.ico', true)); if (forum_get_setting('show_links', 'Y')) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Links'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=links.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/link.ico', true)); } } if (forum_get_setting('show_pms', 'Y')) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Inbox'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=pm.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/pm_unread.ico', true)); } if (forum_check_webtag_available($webtag)) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('My Controls'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=user.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/user_controls.ico', true)); } if (session::logged_in() && (session::check_perm(USER_PERM_FORUM_TOOLS, 0) || session::check_perm(USER_PERM_ADMIN_TOOLS, 0) || session::get_folders_by_perm(USER_PERM_FOLDER_MODERATE))) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", gettext('Admin'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=admin.php%3Fwebtag%3D{$webtag}")), html_get_style_file('images/msie/admin_tool.ico', true)); } printf("<meta name=\"msapplication-starturl\" content=\"%s\" />\n", htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}"))); $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}"); printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array(gettext('RSS Feed')), htmlentities_array($rss_feed_path)); if (($folders_array = folder_get_available_details()) !== false) { foreach ($folders_array as $folder) { $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}&fid={$folder['FID']}"); printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($folder['TITLE']), htmlentities_array(gettext('RSS Feed')), htmlentities_array($rss_feed_path)); } } if (($user_style_path = html_get_user_style_path()) !== false) { printf("<link rel=\"apple-touch-icon\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-57x57.png', $user_style_path)))); printf("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-72x72.png', $user_style_path)))); printf("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-114x114.png', $user_style_path)))); printf("<link rel=\"apple-touch-icon\" sizes=\"144x144\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-144x144.png', $user_style_path)))); printf("<link rel=\"shortcut icon\" type=\"image/ico\" href=\"%s\" />\n", htmlentities_array(html_get_forum_file_path(sprintf('styles/%s/images/favicon.ico', $user_style_path)))); } $opensearch_path = html_get_forum_uri(sprintf('search.php?webtag=%s&opensearch', $webtag)); printf("<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"%s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($opensearch_path)); if (($style_sheet = html_get_style_file($main_css)) !== false) { echo html_include_css($style_sheet); } if (($emoticon_style_sheet = html_get_emoticon_style_sheet($emoticons)) !== false) { echo html_include_css($emoticon_style_sheet, 'print, screen'); } if (($images_style_sheet = html_get_style_file($images_css)) !== false) { echo html_include_css($images_style_sheet); } if (isset($inline_css)) { echo "<style type=\"text/css\">\n"; echo "<!--\n\n", $inline_css, "\n\n//-->\n"; echo "</style>\n"; } // Font size (not for Guests) if (session::logged_in()) { echo html_include_css(html_get_forum_file_path(sprintf('font_size.php?webtag=%s', $webtag)), 'screen', 'user_font'); } if ($base_target) { echo "<base target=\"", htmlentities_array($base_target), "\" />\n"; } echo html_include_javascript(html_get_forum_file_path('js/jquery.min.js')); echo html_include_javascript(html_get_forum_file_path('js/jquery.placeholder.min.js')); echo html_include_javascript(html_get_forum_file_path('js/jquery.ui.autocomplete.min.js')); echo html_include_javascript(html_get_forum_file_path('js/jquery.parsequery.min.js')); echo html_include_javascript(html_get_forum_file_path('js/jquery.sprintf.min.js')); echo html_include_javascript(html_get_forum_file_path('js/jquery.url.min.js')); echo html_include_javascript(html_get_forum_file_path('js/general.js')); if ($frame_set_html === false) { // Check for any new PMs. if (session::logged_in()) { // Check to see if the PM popup is disabled on the current page. if ($pm_popup_disabled === false) { // Pages we don't want the popup to appear on $pm_popup_disabled_pages = get_pm_popup_disabled_files(); // Check that we're not on one of the pages. if (!in_array(basename($_SERVER['PHP_SELF']), $pm_popup_disabled_pages)) { echo html_include_javascript(html_get_forum_file_path('js/pm.js')); } } // Overflow auto-resize functionality. $resize_images_page = get_image_resize_files(); if (in_array(basename($_SERVER['PHP_SELF']), $resize_images_page)) { if (isset($_SESSION['USE_OVERFLOW_RESIZE']) && $_SESSION['USE_OVERFLOW_RESIZE'] == 'Y') { echo html_include_javascript(html_get_forum_file_path('js/overflow.js')); } } // Mouseover spoiler pages $message_display_pages = get_message_display_files(); if (in_array(basename($_SERVER['PHP_SELF']), $message_display_pages)) { echo html_include_javascript(html_get_forum_file_path('js/spoiler.js')); } } // Stats Display pages $stats_display_pages = array('messages.php'); if (in_array(basename($_SERVER['PHP_SELF']), $stats_display_pages)) { echo html_include_javascript(html_get_forum_file_path('js/stats.js')); } } foreach ($css as $css_file) { echo html_include_css(html_get_forum_file_path($css_file)); } foreach ($js as $js_file) { echo html_include_javascript(html_get_forum_file_path($js_file)); } echo html_include_javascript(html_get_forum_file_path("json.php?webtag={$webtag}")); if ($frame_set_html === true && ($google_analytics_code = html_get_google_analytics_code())) { echo "<script type=\"text/javascript\">\n\n"; echo " var _gaq = _gaq || [];\n"; echo " _gaq.push(['_setAccount', '{$google_analytics_code}']);\n"; echo " _gaq.push(['_trackPageview']);\n\n"; echo " (function() {\n"; echo " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n"; echo " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n"; echo " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n"; echo " })();\n\n"; echo "</script>\n"; } echo "</head>\n\n"; if ($frame_set_html === false) { $classes = array(basename($_SERVER['PHP_SELF'], '.php')); if ($class) { $classes[] = $class; } printf("<body class=\"%s\">\n", implode(' ', htmlentities_array($classes))); if (html_output_adsense_settings() && adsense_check_user() && adsense_check_page()) { adsense_output_html(); echo "<br />\n"; } echo '<div id="fb-root"></div>'; } }
function story($lang, $arglist = false) { global $request_path, $with_toolbar; $story = $page = false; if (is_array($arglist)) { if (isset($arglist[0])) { $story = $arglist[0]; } if (isset($arglist[1])) { $page = $arglist[1]; } } if (!$story) { return run('error/notfound', $lang); } $story_id = thread_id($story); if (!$story_id) { return run('error/notfound', $lang); } $page_id = thread_node_id($story_id, $page, $lang); if (!$page_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $story_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud thread_nocloud thread_nosearch thread_nocomment thread_nomorecomment */ if ($thread_type != 'story') { return run('error/notfound', $lang); } $story_name = $thread_name; $story_title = $thread_title; $story_abstract = $thread_abstract; $story_cloud = $thread_cloud; $story_nocloud = $thread_nocloud; $story_nosearch = $thread_nosearch; $r = thread_get_node($lang, $story_id, $page_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* node_number node_ignored node_name node_title node_abstract node_cloud node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin */ if ($node_ignored) { return run('error/notfound', $lang); } $page_user_id = $node_user_id; $page_name = $node_name; $page_title = $node_title; $page_abstract = $node_abstract; $page_cloud = $node_cloud; $page_number = $node_number; $page_modified = $node_modified; if (!$page) { $request_path .= '/' . $page_name; } if ($story_title) { head('title', $story_title); } if ($page_abstract) { head('description', $page_abstract); } else { if ($story_abstract) { head('description', $story_abstract); } } if ($page_cloud) { head('keywords', $page_cloud); } else { if ($story_cloud) { head('keywords', $story_cloud); } } head('date', $page_modified); $page_contents = build('nodecontent', $lang, $page_id); $page_comment = false; if (!($thread_nocomment or $node_nocomment)) { $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false; $page_url = url('story', $lang) . '/' . $story_name . '/' . $page_name; $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore); } $vote = false; if (!($thread_novote or $node_novote)) { $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false; $vote = build('vote', $lang, $page_id, 'node', $nomore); } $visits = false; if ($thread_visits and $node_visits) { $nomore = user_has_role('writer'); $visits = build('visits', $lang, $page_id, $nomore); } $besocial = $sharebar = false; if ($page_contents or $page_comment) { $ilike = $thread_ilike && $node_ilike; $tweetit = $thread_tweet && $node_tweet; $plusone = $thread_plusone && $node_plusone; $linkedin = $thread_linkedin && $node_linkedin; $pinit = $thread_pinit && $node_pinit; if ($tweetit) { $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title); $tweetit = $tweet_text ? compact('tweet_text') : true; } if ($pinit) { $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title); $pinit_image = $node_image; $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false; } list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit')); } $content = view('storycontent', false, compact('page_id', 'page_title', 'page_contents', 'page_comment', 'page_number', 'besocial', 'vote', 'visits')); $search = false; if (!$story_nosearch) { $search_text = ''; $search_url = url('search', $lang, $story_name); $suggest_url = url('suggest', $lang, $story_name); $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url')); } $cloud = false; if (!$story_nocloud) { $cloud_url = url('search', $lang, $story_name); $byname = $bycount = $index = true; $cloud = build('cloud', $lang, $cloud_url, $story_id, false, 30, compact('byname', 'bycount', 'index')); } $summary = array(); $r = thread_get_contents($lang, $story_id); if ($r) { $story_url = url('story', $lang) . '/' . $story_name; foreach ($r as $c) { extract($c); /* node_id node_name node_title node_number */ $summary_page_id = $node_id; $summary_page_title = $node_title; $summary_page_url = $story_url . '/' . $node_name; $summary[] = compact('summary_page_id', 'summary_page_title', 'summary_page_url'); } } $title = false; if ($story_title) { $headline_text = $story_title; $headline_url = false; $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); } $sidebar = view('sidebar', false, compact('search', 'cloud', 'title', 'summary')); $search = !$story_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false; $edit = user_has_role('writer') ? url('storyedit', $_SESSION['user']['locale']) . '/' . $story_id . '/' . $page_id . '?' . 'clang=' . $lang : false; $validate = url('story', $lang) . '/' . $story_name . '/' . $page_name; $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false; $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'sidebar', 'content')); return $output; }
function html_draw_top() { $arg_array = func_get_args(); $title = null; $body_class = null; $base_target = null; $stylesheet_array = array(); $meta_refresh = array('delay' => null, 'url' => null); $robots = null; $frame_set_html = false; $pm_popup_disabled = false; $inline_css = null; $emoticons = null; $webtag = get_webtag(); $forum_name = forum_get_setting('forum_name', null, 'A Beehive Forum'); $func_matches = array(); foreach ($arg_array as $key => $func_args) { if (preg_match('/^title=(.+)?$/Disu', $func_args, $func_matches) > 0) { $title = !isset($title) && isset($func_matches[1]) ? $func_matches[1] : $title; unset($arg_array[$key]); } if (preg_match('/^class=(.+)?$/Disu', $func_args, $func_matches) > 0) { $body_class = !isset($body_class) && isset($func_matches[1]) ? $func_matches[1] : $body_class; unset($arg_array[$key]); } if (preg_match('/^basetarget=(.+)?$/Disu', $func_args, $func_matches) > 0) { $base_target = !isset($base_target) && isset($func_matches[1]) ? $func_matches[1] : $base_target; unset($arg_array[$key]); } if (preg_match('/^stylesheet=([^:]+)(:(.+))?$/Disu', $func_args, $func_matches) > 0) { $stylesheet_array[] = array('filename' => $func_matches[1], 'media' => isset($func_matches[3]) ? $func_matches[3] : 'screen'); unset($arg_array[$key]); } if (preg_match('/^refresh=([^:]+):(.+)$/Disu', $func_args, $func_matches) > 0) { $meta_refresh['delay'] = isset($func_matches[1]) ? $func_matches[1] : null; $meta_refresh['url'] = isset($func_matches[2]) ? $func_matches[2] : null; unset($arg_array[$key]); } if (preg_match('/^robots=(.+)?$/Disu', $func_args, $func_matches) > 0) { $robots = !isset($robots) && isset($func_matches[1]) ? $func_matches[1] : $robots; unset($arg_array[$key]); } if (preg_match('/^frame_set_html$/Disu', $func_args, $func_matches) > 0) { $frame_set_html = true; unset($arg_array[$key]); } if (preg_match('/^pm_popup_disabled$/Disu', $func_args, $func_matches) > 0) { $pm_popup_disabled = true; unset($arg_array[$key]); } if (preg_match('/^inline_css=(.+)/Disu', $func_args, $func_matches) > 0) { $inline_css = !isset($inline_css) && isset($func_matches[1]) ? $func_matches[1] : $inline_css; unset($arg_array[$key]); } if (preg_match('/^emoticons=(.+)?$/Disu', $func_args, $func_matches) > 0) { $emoticons = !isset($emoticons) && isset($func_matches[1]) ? $func_matches[1] : $emoticons; unset($arg_array[$key]); } } echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; if ($frame_set_html === false) { echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; } else { echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n"; } echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"", _('en-gb'), "\" lang=\"", _('en-gb'), "\" dir=\"", _('ltr'), "\">\n"; echo "<head>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; // Default Meta keywords and description. $meta_keywords = html_get_forum_keywords(); $meta_description = html_get_forum_description(); if (isset($_GET['msg']) && validate_msg($_GET['msg'])) { message_get_meta_content($_GET['msg'], $meta_keywords, $meta_description); list($tid, $pid) = explode('.', $_GET['msg']); if ($thread_data = thread_get($tid)) { $prev_page = $pid - 10 > 0 ? $pid - 10 : 1; $next_page = $pid + 10 < $thread_data['LENGTH'] ? $pid + 10 : $thread_data['LENGTH']; echo "<link rel=\"first\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&msg={$tid}.1"), "\" />\n"; echo "<link rel=\"previous\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&msg={$tid}.{$thread_data['LENGTH']}"), "\" />\n"; echo "<link rel=\"next\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&msg={$tid}.{$next_page}"), "\" />\n"; echo "<link rel=\"last\" href=\"", html_get_forum_file_path("index.php?webtag={$webtag}&msg={$tid}.{$prev_page}"), "\" />\n"; echo "<title>", word_filter_add_ob_tags($thread_data['TITLE'], true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n"; } else { if (isset($title)) { echo "<title>", word_filter_add_ob_tags($title, true), " - ", word_filter_add_ob_tags($forum_name, true), "</title>\n"; } else { echo "<title>", word_filter_add_ob_tags($forum_name, true), "</title>\n"; } } } else { if (isset($title)) { echo "<title>", word_filter_add_ob_tags($title, true), " - ", htmlentities_array($forum_name), "</title>\n"; } else { echo "<title>", htmlentities_array($forum_name), "</title>\n"; } } $forum_content_rating = html_get_forum_content_rating(); echo "<meta name=\"generator\" content=\"Beehive Forum ", BEEHIVE_VERSION, "\" />\n"; echo "<meta name=\"keywords\" content=\"", word_filter_add_ob_tags($meta_keywords, true), "\" />\n"; echo "<meta name=\"description\" content=\"", word_filter_add_ob_tags($meta_description, true), "\" />\n"; echo "<meta name=\"rating\" content=\"{$forum_content_rating}\" />\n"; if (forum_get_setting('allow_search_spidering', 'N')) { echo "<meta name=\"robots\" content=\"noindex,nofollow\" />\n"; } else { if (isset($robots)) { echo "<meta name=\"robots\" content=\"{$robots}\" />\n"; } } if (isset($meta_refresh['url'], $meta_refresh['delay'])) { echo "<meta http-equiv=\"refresh\" content=\"{$meta_refresh['delay']}; url={$meta_refresh['url']}\" />\n"; } printf("<meta name=\"application-name\" content=\"%s\" />\n", word_filter_add_ob_tags($forum_name, true)); printf("<meta name=\"msapplication-tooltip\" content=\"%s\" />\n", word_filter_add_ob_tags($meta_description, true)); if (forum_check_webtag_available($webtag)) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Messages'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=discussion.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/unread_thread.ico', true, true)); if (forum_get_setting('show_links', 'Y')) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Links'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=links.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/link.ico', true, true)); } } if (forum_get_setting('show_pms', 'Y')) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Inbox'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=pm.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/pmunread.ico', true, true)); } if (forum_check_webtag_available($webtag)) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('My Controls'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=user.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/user_controls.ico', true, true)); } if (session::logged_in() && (session::check_perm(USER_PERM_FORUM_TOOLS, 0) || session::check_perm(USER_PERM_ADMIN_TOOLS, 0) || session::get_folders_by_perm(USER_PERM_FOLDER_MODERATE))) { printf("<meta name=\"msapplication-task\" content=\"name=%s;action-uri=%s;icon-uri=%s\" />\n", _('Admin'), htmlentities_array(html_get_forum_file_path("index.php?webtag={$webtag}&final_uri=admin.php%3Fwebtag%3D{$webtag}")), html_style_image('msie/admintool.ico', true, true)); } printf("<meta name=\"msapplication-starturl\" content=\"%s\" />\n", html_get_forum_file_path("index.php?webtag={$webtag}")); $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}"); printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array(_('RSS Feed')), $rss_feed_path); if ($folders_array = folder_get_available_details()) { foreach ($folders_array as $folder) { $rss_feed_path = html_get_forum_file_path("threads_rss.php?webtag={$webtag}&fid={$folder['FID']}"); printf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s - %s - %s\" href=\"%s\" />\n", htmlentities_array($forum_name), htmlentities_array($folder['TITLE']), htmlentities_array(_('RSS Feed')), $rss_feed_path); } } if ($user_style_path = html_get_user_style_path()) { printf("<link rel=\"apple-touch-icon\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-57x57.png', $user_style_path))); printf("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-72x72.png', $user_style_path))); printf("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/apple-touch-icon-114x114.png', $user_style_path))); printf("<link rel=\"shortcut icon\" type=\"image/ico\" href=\"%s\" />\n", html_get_forum_file_path(sprintf('styles/%s/images/favicon.ico', $user_style_path))); } $opensearch_path = html_get_forum_file_path(sprintf('search.php?webtag=%s&opensearch', $webtag)); printf("<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"%s\" href=\"%s\" />\n", $forum_name, $opensearch_path); if ($style_sheet = html_get_style_sheet()) { html_include_css($style_sheet); } if ($script_style_sheet = html_get_script_style_sheet()) { html_include_css($script_style_sheet); } if ($emoticon_style_sheet = html_get_emoticon_style_sheet($emoticons)) { html_include_css($emoticon_style_sheet, 'print, screen'); } if (isset($stylesheet_array) && is_array($stylesheet_array)) { foreach ($stylesheet_array as $stylesheet) { if (isset($stylesheet['filename']) && isset($stylesheet['media'])) { html_include_css($stylesheet['filename'], $stylesheet['media']); } } } if ($style_path_ie6 = html_get_style_sheet('style_ie6.css')) { echo "<!--[if IE 6]>\n"; html_include_css($style_path_ie6); echo "<![endif]-->\n"; } if (isset($inline_css)) { echo "<style type=\"text/css\">\n"; echo "<!--\n\n", $inline_css, "\n\n//-->\n"; echo "</style>\n"; } // Font size (not for Guests) if (session::logged_in()) { html_include_css(html_get_forum_file_path(sprintf('font_size.php?webtag=%s', $webtag)), 'screen', 'user_font'); } if ($base_target) { echo "<base target=\"{$base_target}\" />\n"; } html_include_javascript(html_get_forum_file_path('js/jquery-1.7.1.min.js')); html_include_javascript(html_get_forum_file_path('js/jquery-ui-1.8.22.autocomplete.min.js')); html_include_javascript(html_get_forum_file_path('js/jquery.parsequery.js')); html_include_javascript(html_get_forum_file_path('js/jquery.sprintf.js')); html_include_javascript(html_get_forum_file_path('js/jquery.url.js')); html_include_javascript(html_get_forum_file_path('js/general.js')); if ($frame_set_html === false) { // Check for any new PMs. if (session::logged_in()) { // Check to see if the PM popup is disabled on the current page. if ($pm_popup_disabled === false) { // Pages we don't want the popup to appear on $pm_popup_disabled_pages = array('admin.php', 'attachments.php', 'change_pw.php', 'confirm_email.php', 'dictionary.php', 'discussion.php', 'display_emoticons.php', 'edit_attachments.php', 'email.php', 'font_size.php', 'forgot_pw.php', 'get_attachment.php', 'index.php', 'mods_list.php', 'nav.php', 'pm.php', 'pm_edit.php', 'pm_folders.php', 'pm_messages.php', 'pm_options.php', 'poll_results.php', 'start.php', 'search_popup.php', 'threads_rss.php', 'user.php', 'user_font.php', 'user_profile.php', 'user_stats.php'); // Check that we're not on one of the pages. if (!in_array(basename($_SERVER['PHP_SELF']), $pm_popup_disabled_pages)) { html_include_javascript(html_get_forum_file_path('js/pm.js')); } } // Overflow auto-resize functionality. $resize_images_page = array('admin_post_approve.php', 'create_poll.php', 'delete.php', 'display.php', 'edit.php', 'edit_poll.php', 'edit_signature.php', 'messages.php', 'post.php', 'pm_write.php', 'pm_edit.php', 'pm_messages.php'); if (in_array(basename($_SERVER['PHP_SELF']), $resize_images_page)) { if (session::get_value('USE_OVERFLOW_RESIZE') == 'Y') { html_include_javascript(html_get_forum_file_path('js/overflow.js')); } } // Mouseover spoiler pages $message_display_pages = array('admin_post_approve.php', 'create_poll.php', 'delete.php', 'display.php', 'edit.php', 'edit_poll.php', 'edit_signature.php', 'ldisplay.php', 'lmessages.php', 'lpost.php', 'messages.php', 'post.php'); if (in_array(basename($_SERVER['PHP_SELF']), $message_display_pages)) { html_include_javascript(html_get_forum_file_path('js/spoiler.js')); } } // Stats Display pages $stats_display_pages = array('messages.php'); if (in_array(basename($_SERVER['PHP_SELF']), $stats_display_pages)) { html_include_javascript(html_get_forum_file_path('js/stats.js')); } } reset($arg_array); foreach ($arg_array as $func_args) { html_include_javascript(html_get_forum_file_path("js/{$func_args}")); } html_include_javascript(html_get_forum_file_path("ckeditor/ckeditor.js")); html_include_javascript(html_get_forum_file_path("ckeditor/adapters/jquery.js")); html_include_javascript(html_get_forum_file_path("json.php?webtag={$webtag}")); if ($frame_set_html === true && ($google_analytics_code = html_get_google_analytics_code())) { echo "<script type=\"text/javascript\">\n\n"; echo " var _gaq = _gaq || [];\n"; echo " _gaq.push(['_setAccount', '{$google_analytics_code}']);\n"; echo " _gaq.push(['_trackPageview']);\n\n"; echo " (function() {\n"; echo " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n"; echo " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n"; echo " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n"; echo " })();\n\n"; echo "</script>\n"; } if ($frame_set_html === false && forum_get_setting('show_share_links', 'Y') && session::get_value('SHOW_SHARE_LINKS') == 'Y') { echo "<script type=\"text/javascript\" src=\"https://apis.google.com/js/plusone.js\">\n"; echo "{lang: 'en-GB'}\n"; echo "</script>\n"; echo "<script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script>\n"; } echo "</head>\n\n"; if ($frame_set_html === false) { echo "<body", $body_class ? " class=\"{$body_class}\">\n" : ">\n"; if (html_output_adsense_settings() && adsense_check_user() && adsense_check_page()) { adsense_output_html(); echo "<br />\n"; } if (forum_get_setting('show_share_links', 'Y') && session::get_value('SHOW_SHARE_LINKS') == 'Y') { echo '<div id="fb-root"></div>'; } } }
} if (isset($fid) && sizeof($attachments) > 0 && !session::check_perm(USER_PERM_POST_ATTACHMENTS | USER_PERM_POST_READ, $fid)) { $error_msg_array[] = gettext("You cannot post attachments in this folder. Remove attachments to continue."); $valid = false; } if (sizeof($attachments) > 0 && !attachments_check_post_space($_SESSION['UID'], $attachments)) { $error_msg_array[] = gettext(sprintf("You have too many files attached to this post. Maximum attachment space per post is %s", format_file_size($max_post_attachment_space))); $valid = false; } } } if (!$new_thread) { if (!($reply_message = messages_get($tid, $reply_to_pid))) { light_html_draw_error(gettext("That post does not exist in this thread!")); } if (!($thread_data = thread_get($tid))) { light_html_draw_error(gettext("The requested thread could not be found or access was denied.")); } $reply_message['CONTENT'] = message_get_content($tid, $reply_to_pid); if (perm_get_user_permissions($reply_message['FROM_UID']) & USER_PERM_WORMED && !session::check_perm(USER_PERM_FOLDER_MODERATE, $fid) || (!isset($reply_message['CONTENT']) || $reply_message['CONTENT'] == "") && $thread_data['POLL_FLAG'] != 'Y' && $reply_to_pid != 0) { light_html_draw_error(gettext("Message not found. Check that it hasn't been deleted.")); } } if (isset($_POST['to_logon'])) { if (strlen(trim($_POST['to_logon'])) > 0) { $to_logon_array = preg_split('/,\\s*/u', trim($_POST['to_logon'], ', ')); $to_logon_array = array_filter(array_map('trim', $to_logon_array), 'strlen'); foreach ($to_logon_array as $key => $recipient) { $to_logon = trim($recipient); unset($to_logon_array[$key]); if (($to_user = user_get_by_logon($to_logon)) !== false) {
function newsletterpage($lang, $newsletter, $page) { global $with_toolbar; $newsletter_id = thread_id($newsletter); if (!$newsletter_id) { return run('error/notfound', $lang); } $page_id = thread_node_id($newsletter_id, $page, $lang); if (!$page_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $newsletter_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud thread_nocloud thread_nosearch thread_nocomment thread_nomorecomment */ $newsletter_name = $thread_name; $newsletter_title = $thread_title; $newsletter_nocloud = $thread_nocloud; $newsletter_nosearch = $thread_nosearch; $r = thread_get_node($lang, $newsletter_id, $page_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* node_number node_ignored node_name node_title node_abstract node_cloud node_modified */ if ($node_ignored) { return run('error/notfound', $lang); } $page_name = $node_name; $page_title = $node_title; $page_abstract = $node_abstract; $page_cloud = $node_cloud; $page_modified = $node_modified; if ($newsletter_title and $page_title) { head('title', $newsletter_title . ' - ' . $page_title); } else { if ($page_title) { head('title', $page_title); } else { if ($newsletter_title) { head('title', $newsletter_title); } } } head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $message_title = $message_html = $message_text = false; $r = newsletter_get_message($newsletter_id, $page_id, $lang); if ($r) { list($message_title, $message_html, $message_text) = $r; } $postnews = false; $with_mail = false; $mailto = false; $missing_mail = false; $bad_mail = false; $email_sent = false; if (user_has_role('administrator') and $message_title and ($message_html or $message_text)) { require_once 'userprofile.php'; $mailto = user_profile('mail'); $with_mail = true; if (isset($_POST['newsletterpage_send'])) { if (isset($_POST['newsletterpage_mailto'])) { $mailto = strtolower(strflat(readarg($_POST['newsletterpage_mailto']))); if (!$mailto) { $missing_mail = true; } else { if (!validate_mail($mailto)) { $bad_mail = true; } } } if (!($missing_mail or $bad_mail)) { require_once 'emailhtml.php'; $cssfile = ROOT_DIR . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'newsletter.css'; $css = @file_get_contents($cssfile); $r = emailhtml($message_text, $message_html, $css, $mailto, $message_title); if ($r) { $email_sent = true; } } } $postnews = build('postnews', $lang, $newsletter_id, $page_id); } $prev_page_label = $prev_page_url = false; $r = thread_node_prev($lang, $newsletter_id, $page_id); if ($r) { extract($r); /* prev_node_id prev_node_name prev_node_title prev_node_number */ $prev_page_label = $prev_node_title ? $prev_node_title : $prev_node_number; $prev_page_url = url('newsletter', $lang) . '/' . ($prev_node_name ? $prev_node_name : $prev_node_id); } $next_page_label = $next_page_url = false; $r = thread_node_next($lang, $newsletter_id, $page_id); if ($r) { extract($r); /* next_node_id next_node_name next_node_title next_node_number */ $next_page_label = $next_node_title ? $next_node_title : $next_node_number; $next_page_url = url('newsletter', $lang) . '/' . ($next_node_name ? $next_node_name : $next_node_id); } $content = view('newsletterpage', $lang, compact('page_id', 'page_title', 'page_modified', 'message_title', 'message_text', 'message_html', 'prev_page_url', 'prev_page_label', 'next_page_url', 'next_page_label', 'postnews', 'with_mail', 'mailto', 'missing_mail', 'bad_mail', 'email_sent')); $search = false; if (!$newsletter_nosearch) { $search_text = ''; $search_url = url('search', $lang, $newsletter_name); $suggest_url = url('suggest', $lang, $newsletter_name); $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url')); } $cloud = false; if (!$newsletter_nocloud) { $cloud_url = url('search', $lang, $newsletter_name); $byname = $bycount = $index = true; $cloud = build('cloud', $lang, $cloud_url, $newsletter_id, false, 15, compact('byname', 'bycount', 'index')); } $headline_text = $newsletter_title ? $newsletter_title : $newsletter_id; $headline_url = url('newsletter', $lang); $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('search', 'cloud', 'title')); $search = !$newsletter_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false; $edit = user_has_role('writer') ? url('newsletteredit', $_SESSION['user']['locale']) . '/' . $newsletter_id . '/' . $page_id . '?' . 'clang=' . $lang : false; $validate = url('newsletter', $lang) . '/' . $page_name; $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false; $output = layout('standard', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
$allow_sig = true; if (isset($t_fid) && !session::check_perm(USER_PERM_HTML_POSTING, $t_fid)) { $allow_html = false; } if (isset($t_fid) && !session::check_perm(USER_PERM_SIGNATURE, $t_fid)) { $allow_sig = false; } if ($allow_html == false) { $t_content = htmlentities_array($t_content); $t_sig = htmlentities_array($t_sig); } if (!$new_thread) { if (!($reply_message = messages_get($reply_to_tid, $reply_to_pid))) { html_draw_error(gettext("That post does not exist in this thread!")); } if (!($thread_data = thread_get($reply_to_tid))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } $reply_message['CONTENT'] = message_get_content($reply_to_tid, $reply_to_pid); if (perm_get_user_permissions($reply_message['FROM_UID']) & USER_PERM_WORMED && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid) || (!isset($reply_message['CONTENT']) || $reply_message['CONTENT'] == "") && $thread_data['POLL_FLAG'] != 'Y' && $reply_to_pid != 0) { html_draw_error(gettext("Message not found. Check that it hasn't been deleted.")); } } if ($valid && isset($_POST['post'])) { if (post_check_frequency()) { if (post_check_ddkey($t_dedupe)) { if ($new_thread) { if (session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) { $t_closed = isset($_POST['t_closed']) && $_POST['t_closed'] == 'Y' ? true : false; $t_sticky = isset($_POST['t_sticky']) && $_POST['t_sticky'] == 'Y' ? 'Y' : 'N'; } else {
function light_draw_thread_list($mode = ALL_DISCUSSIONS, $folder = false, $page = 1) { $webtag = get_webtag(); $error_msg_array = array(); $available_views = thread_list_available_views(); $visible_threads_array = array(); if (($uid = session::get_value('UID')) === false) { return; } echo "<div id=\"thread_view\">\n"; echo "<form accept-charset=\"utf-8\" name=\"f_mode\" method=\"get\" action=\"lthread_list.php\">\n"; echo form_input_hidden("webtag", htmlentities_array($webtag)); if (is_numeric($folder) && in_array($folder, folder_get_available_array())) { echo form_input_hidden('folder', htmlentities_array($folder)), "\n"; } echo "<ul>\n"; echo "<li>", light_threads_draw_discussions_dropdown($mode), "</li>\n"; echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n"; echo "</ul>\n"; echo "</form>\n"; echo "</div>\n"; // Get the right threads for whichever mode is selected switch ($mode) { case UNREAD_DISCUSSIONS: list($thread_info, $folder_order) = threads_get_unread($uid, $folder, $page); break; case UNREAD_DISCUSSIONS_TO_ME: list($thread_info, $folder_order) = threads_get_unread_to_me($uid, $folder, $page); break; case TODAYS_DISCUSSIONS: list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 1); break; case UNREAD_TODAY: list($thread_info, $folder_order) = threads_get_unread_by_days($uid, $folder, $page); break; case TWO_DAYS_BACK: list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 2); break; case SEVEN_DAYS_BACK: list($thread_info, $folder_order) = threads_get_by_days($uid, $folder, $page, 7); break; case HIGH_INTEREST: list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, 1); break; case UNREAD_HIGH_INTEREST: list($thread_info, $folder_order) = threads_get_unread_by_interest($uid, $folder, $page, 1); break; case RECENTLY_SEEN: list($thread_info, $folder_order) = threads_get_recently_viewed($uid, $folder, $page); break; case IGNORED_THREADS: list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, -1); break; case BY_IGNORED_USERS: list($thread_info, $folder_order) = threads_get_by_relationship($uid, $folder, $page, USER_IGNORED_COMPLETELY); break; case SUBSCRIBED_TO: list($thread_info, $folder_order) = threads_get_by_interest($uid, $folder, $page, 2); break; case STARTED_BY_FRIEND: list($thread_info, $folder_order) = threads_get_by_relationship($uid, $folder, $page, USER_FRIEND); break; case UNREAD_STARTED_BY_FRIEND: list($thread_info, $folder_order) = threads_get_unread_by_relationship($uid, $folder, $page, USER_FRIEND); break; case STARTED_BY_ME: list($thread_info, $folder_order) = threads_get_started_by_me($uid, $folder, $page); break; case POLL_THREADS: list($thread_info, $folder_order) = threads_get_polls($uid, $folder, $page); break; case STICKY_THREADS: list($thread_info, $folder_order) = threads_get_sticky($uid, $folder, $page); break; case MOST_UNREAD_POSTS: list($thread_info, $folder_order) = threads_get_longest_unread($uid, $folder, $page); break; case DELETED_THREADS: list($thread_info, $folder_order) = threads_get_deleted($uid, $folder, $page); break; default: list($thread_info, $folder_order) = threads_get_all($uid, $folder, $page); break; } // Now, the actual bit that displays the threads... // Get folder FIDs and titles if (!($folder_info = threads_get_folders())) { light_html_display_error_msg(gettext("There are no folders available.")); return; } // Get total number of messages for each folder $folder_msgs = threads_get_folder_msgs(); // Check that the folder order is a valid array. // While we're here we can also check to see how the user // has decided to display the thread list. if (!is_array($folder_order) || session::get_value('THREADS_BY_FOLDER') == 'Y') { $folder_order = array_keys($folder_info); } // Sort the folders and threads correctly as per the URL query for the TID if (isset($_GET['msg']) && validate_msg($_GET['msg'])) { list($tid) = explode('.', $_GET['msg']); if ($thread = thread_get($tid)) { if (!isset($thread['RELATIONSHIP'])) { $thread['RELATIONSHIP'] = 0; } if (session::get_value('THREADS_BY_FOLDER') == 'N' || !session::logged_in()) { if (in_array($thread['FID'], $folder_order)) { array_splice($folder_order, array_search($thread['FID'], $folder_order), 1); } array_unshift($folder_order, $thread['FID']); } if (!is_array($thread_info)) { $thread_info = array(); } if (isset($thread_info[$tid])) { unset($thread_info[$tid]); } else { array_pop($thread_info); } array_unshift($thread_info, $thread); } } // Work out if any folders have no messages and add them. // Seperate them by INTEREST level if (session::get_value('UID') > 0) { if (isset($_GET['msg']) && validate_msg($_GET['msg'])) { list($tid) = explode('.', $_GET['msg']); if ($thread = thread_get($tid)) { $selected_folder = $thread['FID']; } } else { if (isset($_GET['folder'])) { $selected_folder = $_GET['folder']; } else { $selected_folder = 0; } } $ignored_folders = array(); while (list($fid, $folder_data) = each($folder_info)) { if ($folder_data['INTEREST'] == FOLDER_NOINTEREST || isset($selected_folder) && $selected_folder == $fid) { if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) { $folder_order[] = $fid; } } else { if (!in_array($fid, $folder_order) && !in_array($fid, $ignored_folders)) { $ignored_folders[] = $fid; } } } // Append ignored folders onto the end of the folder list. // This will make them appear at the bottom of the thread list. $folder_order = array_merge($folder_order, $ignored_folders); } else { while (list($fid, $folder_data) = each($folder_info)) { if (!in_array($fid, $folder_order)) { $folder_order[] = $fid; } } } // If no threads are returned, say something to that effect if (isset($_REQUEST['mark_read_success'])) { light_html_display_success_msg(gettext("Successfully marked selected threads as read"), '100%', 'left'); } else { if (!is_array($thread_info)) { if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) { $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&folder={$folder}&mode=0\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("No "%s" in "%s" folder. Please select another folder, or %s for all threads."), $available_views[$mode], $folder_title, $all_discussions_link), '100%', 'left'); } else { $all_discussions_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&mode=0\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("No "%s" available. Please %s for all threads."), $available_views[$mode], $all_discussions_link), '100%', 'left'); } } else { if (isset($error_msg_array) && sizeof($error_msg_array) > 0) { light_html_display_error_array($error_msg_array, '100%', 'left'); } else { if (is_numeric($folder) && ($folder_title = folder_get_title($folder))) { $all_folders_link = sprintf("<a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}\">%s</a>", gettext("click here")); light_html_display_warning_msg(sprintf(gettext("Viewing "%s" in "%s" only. To view threads in all folders %s."), $available_views[$mode], $folder_title, $all_folders_link), '100%', 'left'); } } } } if ($page > 1 && !is_numeric($folder)) { echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n"; } // Iterate through the information we've just got and display it in the right order foreach ($folder_order as $folder_number) { if (isset($folder_info[$folder_number]) && is_array($folder_info[$folder_number])) { echo "<div class=\"folder\">\n"; echo " <h3><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder_number}\">", word_filter_add_ob_tags($folder_info[$folder_number]['TITLE'], true), "</a></h3>"; echo " <div class=\"folder_inner\">\n"; if (!session::logged_in() || $folder_info[$folder_number]['INTEREST'] > FOLDER_IGNORED || $mode == UNREAD_DISCUSSIONS_TO_ME || isset($selected_folder) && $selected_folder == $folder_number) { if (is_array($thread_info)) { echo " <div class=\"folder_info\">"; if (isset($folder_msgs[$folder_number])) { echo $folder_msgs[$folder_number]; } else { echo "0"; } echo " ", gettext("threads"), ""; if (is_null($folder_info[$folder_number]['STATUS']) || $folder_info[$folder_number]['STATUS'] & USER_PERM_THREAD_CREATE) { if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) { echo "<span><a href=\"lpost.php?webtag={$webtag}&fid={$folder_number}\">", gettext("Post New"), "</a></span>"; } } echo " </div>\n"; if ($page > 1 && is_numeric($folder) && $folder_number == $folder) { echo "<div class=\"folder_navigation\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder}&page=", $page - 1, "\">", gettext("Previous 50 threads"), "</a></div>\n"; } $folder_list_start = false; $folder_list_end = false; foreach ($thread_info as $thread) { if (!in_array($thread['TID'], $visible_threads_array)) { $visible_threads_array[] = $thread['TID']; } if ($thread['FID'] == $folder_number) { if ($folder_list_start === false) { echo "<ul>\n"; $folder_list_start = true; } echo "<li>\n"; if ($thread['LAST_READ'] == 0) { $number = "[{$thread['LENGTH']} new]"; $latest_post = 1; } else { if ($thread['LAST_READ'] < $thread['LENGTH']) { $new_posts = $thread['LENGTH'] - $thread['LAST_READ']; $number = "[{$new_posts} new of {$thread['LENGTH']}]"; $latest_post = $thread['LAST_READ'] + 1; } else { $number = "[{$thread['LENGTH']}]"; $latest_post = 1; } } // work out how long ago the thread was posted and format the time to display $thread_time = format_time($thread['MODIFIED']); echo "<span class=\"thread_title\">"; echo "<a href=\"lmessages.php?webtag={$webtag}&msg={$thread['TID']}.{$latest_post}\" "; echo "title=\"", sprintf(gettext("Thread #%s Started by %s. Viewed %s"), $thread['TID'], word_filter_add_ob_tags(format_user_name($thread['LOGON'], $thread['NICKNAME']), true), $thread['VIEWCOUNT'] == 1 ? gettext("1 time") : sprintf(gettext("%d times"), $thread['VIEWCOUNT'])), "\">"; echo word_filter_add_ob_tags($thread['TITLE'], true), "</a> "; echo "<span class=\"thread_detail\">"; if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_INTERESTED) { echo "<span class=\"thread_high_interest\" title=\"", gettext("High Interest"), "\">[H]</span>"; } if (isset($thread['INTEREST']) && $thread['INTEREST'] == THREAD_SUBSCRIBED) { echo "<span class=\"thread_subscribed\" title=\"", gettext("Subscribed"), "\">[S]</span>"; } if (isset($thread['POLL_FLAG']) && $thread['POLL_FLAG'] == 'Y') { echo "<span class=\"thread_poll\" title=\"", gettext("Poll"), "\">[P]</span>"; } if (isset($thread['STICKY']) && $thread['STICKY'] == 'Y') { echo "<span class=\"thread_sticky\" title=\"", gettext("Sticky"), "\">[ST]</span>"; } if (isset($thread['RELATIONSHIP']) && $thread['RELATIONSHIP'] & USER_FRIEND) { echo "<span class=\"thread_friend\" title=\"", gettext("Friend"), "\">[F]</span>"; } if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_SPLIT) { echo "<span class=\"thread_split\" title=\"", gettext("Thread has been split"), "\">[TS]</span>"; } if (isset($thread['TRACK_TYPE']) && $thread['TRACK_TYPE'] == THREAD_TYPE_MERGE) { echo "<span class=\"thread_merge\" title=\"", gettext("Thread has been merged"), "\">[TM]</span>"; } if (isset($thread['AID']) && is_md5($thread['AID'])) { echo "<span class=\"thread_attachment\" title=\"", gettext("Attachment"), "\">[A]</span>"; } echo "<span class=\"thread_length\">{$number}</span>"; echo "</span>"; echo "</span>"; echo "<span class=\"thread_time\">{$thread_time}</span>"; echo "</li>\n"; } } if ($folder_list_end === false && $folder_list_start === true) { echo "</ul>\n"; $folder_list_end = true; } if (is_numeric($folder) && $folder_number == $folder) { echo "<div class=\"folder_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder}&page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n"; } } else { if ($folder_info[$folder_number]['INTEREST'] != -1) { echo "<div class=\"folder_info\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&folder={$folder_number}\">"; if (isset($folder_msgs[$folder_number])) { echo $folder_msgs[$folder_number]; } else { echo "0"; } echo " ", gettext("threads"), "</a>"; if ($folder_info[$folder_number]['ALLOWED_TYPES'] & FOLDER_ALLOW_NORMAL_THREAD) { echo "<span><a href=\"lpost.php?webtag={$webtag}&fid={$folder_number}\">", gettext("Post New"), "</a></span>"; } echo "</div>\n"; } } } echo " </div>\n"; echo "</div>\n"; if (is_array($thread_info)) { reset($thread_info); } } } if ($mode == ALL_DISCUSSIONS && !isset($folder)) { echo "<div class=\"thread_pagination\"><a href=\"lthread_list.php?webtag={$webtag}&mode={$mode}&page=", $page + 1, "\">", gettext("Next 50 threads"), "</a></div>\n"; } if (session::logged_in()) { echo "<div id=\"thread_mark_read\">\n"; echo "<h3>", gettext("Mark as Read"), "</h3>\n"; echo "<form accept-charset=\"utf-8\" name=\"f_mark\" method=\"post\" action=\"lthread_list.php\">\n"; echo form_input_hidden("webtag", htmlentities_array($webtag)), "\n"; echo form_input_hidden("mode", htmlentities_array($mode)), "\n"; echo form_input_hidden("page", htmlentities_array($page)), "\n"; echo form_input_hidden("mark_read_confirm", 'N'), "\n"; $labels = array(gettext("All Discussions"), gettext("Next 50 discussions")); $selected_option = THREAD_MARK_READ_ALL; if (sizeof($visible_threads_array) > 0) { $labels[] = gettext("Visible discussions"); $selected_option = THREAD_MARK_READ_VISIBLE; $visible_threads = implode(',', array_filter($visible_threads_array, 'is_numeric')); echo form_input_hidden("mark_read_threads", htmlentities_array($visible_threads)), "\n"; } if (isset($_GET['folder']) && is_numeric($_GET['folder'])) { echo form_input_hidden('folder', htmlentities_array($folder)), "\n"; $labels[] = gettext("Selected folder"); $selected_option = THREAD_MARK_READ_FOLDER; } echo "<ul>\n"; echo "<li>", light_form_dropdown_array("mark_read_type", $labels, $selected_option), "</li>\n"; echo "<li class=\"right_col\">", light_form_submit("mark_read_submit", gettext("Go!")), "</li>\n"; echo "</ul>\n"; echo "</form>\n"; echo "</div>\n"; } }
html_draw_error(gettext("There are no folders available.")); } // Get total number of messages for each folder $folder_msgs = threads_get_folder_msgs(); // Check that the folder order is a valid array. if (!is_array($folder_order)) { $folder_order = array(); } // Check the folder display order. if (session::get_value('THREADS_BY_FOLDER') == 'Y') { $folder_order = array_keys($folder_info); } // Check for a message to display and re-order the thread list. if (isset($_REQUEST['msg']) && validate_msg($_REQUEST['msg'])) { list($selected_tid) = explode('.', $_REQUEST['msg']); if ($thread = thread_get($selected_tid)) { if (!isset($thread['RELATIONSHIP'])) { $thread['RELATIONSHIP'] = 0; } // Check the folder display order / user is a guest. if (session::get_value('THREADS_BY_FOLDER') != 'Y' || !session::logged_in()) { // Remove the folder from the list of folders. if (in_array($thread['FID'], $folder_order)) { array_splice($folder_order, array_search($thread['FID'], $folder_order), 1); } // Re-add it at the top of the list. array_unshift($folder_order, $thread['FID']); } // Check $thread_info is an array. if (!is_array($thread_info)) { $thread_info = array();
echo " <table width=\"95%\">\n"; } if (sizeof($selected_array) > 0) { foreach ($selected_array as $selected_option) { if ($type == SEARCH_LOGON && ($user_data = user_get_by_logon($selected_option))) { if ($multi === 'Y') { echo " <tr>\n"; echo " <td align=\"left\">", form_checkbox("selected[]", htmlentities_array($user_data['LOGON']), null, true), " <a href=\"user_profile.php?webtag={$webtag}&uid={$user_data['UID']}\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags(format_user_name($user_data['LOGON'], $user_data['NICKNAME']), true), "</a></td>\n"; echo " </tr>\n"; } else { echo " <tr>\n"; echo " <td align=\"left\">", form_radio("selected", htmlentities_array($user_data['LOGON']), null, true), " <a href=\"user_profile.php?webtag={$webtag}&uid={$user_data['UID']}\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags(format_user_name($user_data['LOGON'], $user_data['NICKNAME']), true), "</a></td>\n"; echo " </tr>\n"; } } else { if (($thread_data = thread_get($selected_option)) !== false) { echo " <tr>\n"; echo " <td align=\"left\">", form_radio("selected", $thread_data['TID'], null, true), " <a href=\"messages.php?webtag={$webtag}&msg={$thread_data['TID']}.1\" target=\"_blank\">", word_filter_add_ob_tags($thread_data['TITLE'], true), "</a></td>\n"; echo " </tr>\n"; } } } if (isset($search_results_array['results_array']) && sizeof($search_results_array['results_array']) > 0) { echo " <tr>\n"; echo " <td align=\"left\"><hr /></td>\n"; echo " </tr>\n"; } } if (isset($search_results_array['results_array']) && sizeof($search_results_array['results_array']) > 0) { foreach ($search_results_array['results_array'] as $search_result) { if ($type == SEARCH_LOGON && !in_array($search_result['LOGON'], $selected_array)) {