function getInfo() { //retrieve Data from the DB $id = db_escape_string($_REQUEST['id']); $result = db_query("SELECT title, link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']); if (db_num_rows($result) != 0) { $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...'); $article_link = db_fetch_result($result, 0, 'link'); } $consumer_key = $this->host->get($this, "pocket_consumer_key"); $pocket_access_token = $this->host->get($this, "pocket_access_token"); //Call Pocket API if (function_exists('curl_init')) { $postfields = array('consumer_key' => $consumer_key, 'access_token' => $pocket_access_token, 'url' => $article_link, 'title' => $title); $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, 'https://getpocket.com/v3/add'); curl_setopt($cURL, CURLOPT_HEADER, 1); curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded;charset=UTF-8')); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_TIMEOUT, 5); curl_setopt($cURL, CURLOPT_POST, 4); curl_setopt($cURL, CURLOPT_POSTFIELDS, http_build_query($postfields)); $apicall = curl_exec($cURL); curl_close($cURL); //Store error code in $status $status = preg_match('/^X-Error: .*$/m', $apicall, $matches) ? $matches[0] : 1; } else { $status = 'For the plugin to work you need to <strong>enable PHP extension CURL</strong>!'; } //Return information on article and status print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "status" => $status)); }
/** * Display zodiac on viewing user profile * * @param object $event The event object * @return null * @access public */ public function memberlist_view_profile($event) { $user_id = $event['member']['user_id']; $this->user->add_lang_ext('rmcgirr83/topicsbyuser', 'common'); // get all topics started by the user and make sure they are visible $sql = 'SELECT t.*, p.post_visibility FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . POSTS_TABLE . ' p ON t.topic_first_post_id = p.post_id WHERE t.topic_poster = ' . $user_id . ' ORDER BY t.topic_time ASC'; $result = $this->db->sql_query($sql); $count = 0; $topic_options = '<option value="">' . $this->user->lang['CHOOSE_A_TOPIC'] . '</option>'; while ($row = $this->db->sql_fetchrow($result)) { if (!$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } if ($row['post_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) { continue; } ++$count; $topic_color = $row['post_visibility'] != ITEM_APPROVED ? 'class="error"' : ''; $topic_options .= '<option value="' . append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']) . '" ' . $topic_color . '> ' . truncate_string($row['topic_title'], 30, 255, false, $this->user->lang['ELLIPSIS']) . '</option>'; } $this->db->sql_freeresult($result); if (!empty($count)) { $this->template->assign_vars(array('HAS_TOPICS' => true, 'S_TOPIC_OPTIONS' => $topic_options)); } }
function filter_test($filter_type, $reg_exp, $action_id, $action_param, $filter_param, $inverse, $feed_id, $cat_id, $cat_filter) { $result = db_query($this->link, "SELECT name FROM ttrss_filter_types WHERE\n\t\t\tid = " . $filter_type); $type_name = db_fetch_result($result, 0, "name"); $result = db_query($this->link, "SELECT name FROM ttrss_filter_actions WHERE\n\t\t\tid = " . $action_id); $action_name = db_fetch_result($result, 0, "name"); $filter["reg_exp"] = $reg_exp; $filter["action"] = $action_name; $filter["type"] = $type_name; $filter["action_param"] = $action_param; $filter["filter_param"] = $filter_param; $filter["inverse"] = $inverse; $filters[$type_name] = array($filter); if ($feed_id) { $feed = $feed_id; } else { $feed = -4; } $regexp_valid = preg_match('/' . $filter['reg_exp'] . '/', $filter['reg_exp']) !== FALSE; print __("Articles matching this filter:"); print "<div class=\"filterTestHolder\">"; print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">"; if ($regexp_valid) { $feed_title = getFeedTitle($this->link, $feed); $qfh_ret = queryFeedHeadlines($this->link, $cat_filter ? $cat_id : $feed, 30, "", $cat_filter, false, false, false, "date_entered DESC", 0, $_SESSION["uid"], $filter); $result = $qfh_ret[0]; $articles = array(); $found = 0; while ($line = db_fetch_assoc($result)) { $entry_timestamp = strtotime($line["updated"]); $entry_tags = get_article_tags($this->link, $line["id"], $_SESSION["uid"]); $content_preview = truncate_string(strip_tags($line["content_preview"]), 100, '...'); if ($line["feed_title"]) { $feed_title = $line["feed_title"]; } print "<tr>"; print "<td width='5%' align='center'><input\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" checked=\"1\"\n\t\t\t\t\tdisabled=\"1\" type=\"checkbox\"></td>"; print "<td>"; print $line["title"]; print " ("; print "<b>" . $feed_title . "</b>"; print "): "; print "<span class=\"insensitive\">" . $content_preview . "</span>"; print " " . mb_substr($line["date_entered"], 0, 16); print "</td></tr>"; $found++; } if ($found == 0) { print "<tr><td align='center'>" . __("No articles matching this filter has been found.") . "</td></tr>"; } } else { print "<tr><td align='center' class='error'>" . __("Invalid regular expression.") . "</td></tr>"; } print "</table>"; print "</div>"; }
function getInfo() { $id = db_escape_string($_REQUEST['id']); $result = db_query($this->link, "SELECT title, link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']); if (db_num_rows($result) != 0) { $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...'); $article_link = db_fetch_result($result, 0, 'link'); } print json_encode(array("title" => $title, "link" => $article_link, "id" => $id)); }
function getShaarli() { $id = db_escape_string($_REQUEST['id']); $result = $this->dbh->query("SELECT title, link\n FROM ttrss_entries, ttrss_user_entries\n WHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']); if (db_num_rows($result) != 0) { $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...'); $article_link = db_fetch_result($result, 0, 'link'); } $shaarli_url = $this->host->get($this, "shaarli"); print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "shaarli_url" => $shaarli_url)); }
function seo_create_meta_keywords($str, $length = 200) { // Strip HTML and Truncate to create a META keywords, Google doesn't care about META tags. $exclude = array('description', 'save', 'month', 'year', 'hundreds', 'dollars', 'per', "a", "ii", "about", "above", "according", "across", "39", "actually", "ad", "adj", "ae", "af", "after", "afterwards", "ag", "again", "against", "ai", "al", "all", "almost", "alone", "along", "already", "also", "although", "always", "am", "among", "amongst", "an", "and", "another", "any", "anyhow", "anyone", "anything", "anywhere", "ao", "aq", "ar", "are", "aren", "aren't", "around", "arpa", "as", "at", "au", "aw", "az", "b", "ba", "bb", "bd", "be", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "beginning", "behind", "being", "below", "beside", "besides", "between", "beyond", "bf", "bg", "bh", "bi", "billion", "bj", "bm", "bn", "bo", "both", "br", "bs", "bt", "but", "buy", "bv", "bw", "by", "bz", "c", "ca", "can", "can't", "cannot", "caption", "cc", "cd", "cf", "cg", "ch", "ci", "ck", "cl", "click", "cm", "cn", "co", "co.", "com", "copy", "could", "couldn", "couldn't", "cr", "cs", "cu", "cv", "cx", "cy", "cz", "d", "de", "did", "didn", "didn't", "dj", "dk", "dm", "do", "does", "doesn", "doesn't", "don", "don't", "down", "during", "dz", "e", "each", "ec", "edu", "ee", "eg", "eh", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "er", "es", "et", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "f", "few", "fi", "fifty", "find", "first", "five", "fj", "fk", "fm", "fo", "for", "former", "formerly", "forty", "found", "four", "fr", "free", "from", "further", "fx", "g", "ga", "gb", "gd", "ge", "get", "gf", "gg", "gh", "gi", "gl", "gm", "gmt", "gn", "go", "gov", "gp", "gq", "gr", "gs", "gt", "gu", "gw", "gy", "h", "had", "has", "hasn", "hasn't", "have", "haven", "haven't", "he", "he'd", "he'll", "he's", "help", "hence", "her", "here", "here's", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "hk", "hm", "hn", "home", "homepage", "how", "however", "hr", "ht", "htm", "html", "http", "hu", "hundred", "i", "i'd", "i'll", "i'm", "i've", "i.e.", "id", "ie", "if", "il", "im", "in", "inc", "inc.", "indeed", "information", "instead", "int", "into", "io", "iq", "ir", "is", "isn", "isn't", "it", "it's", "its", "itself", "j", "je", "jm", "jo", "join", "jp", "k", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "l", "la", "last", "later", "latter", "lb", "lc", "least", "less", "let", "let's", "li", "like", "likely", "lk", "ll", "lr", "ls", "lt", "ltd", "lu", "lv", "ly", "m", "ma", "made", "make", "makes", "many", "maybe", "mc", "md", "me", "meantime", "meanwhile", "mg", "mh", "microsoft", "might", "mil", "million", "miss", "mk", "ml", "mm", "mn", "mo", "more", "moreover", "most", "mostly", "mp", "mq", "mr", "mrs", "ms", "msie", "mt", "mu", "much", "must", "mv", "mw", "mx", "my", "myself", "mz", "n", "na", "namely", "nc", "ne", "neither", "net", "netscape", "never", "nevertheless", "new", "next", "nf", "ng", "ni", "nine", "ninety", "nl", "no", "nobody", "none", "nonetheless", "noone", "nor", "not", "nothing", "now", "nowhere", "np", "nr", "nu", "nz", "o", "of", "off", "often", "om", "on", "once", "one", "one's", "only", "onto", "or", "org", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "overall", "own", "p", "pa", "page", "pe", "per", "perhaps", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "pt", "pw", "py", "q", "qa", "r", "rather", "re", "recent", "recently", "reserved", "ring", "ro", "ru", "rw", "s", "sa", "same", "sb", "sc", "sd", "se", "seem", "seemed", "seeming", "seems", "seven", "seventy", "several", "sg", "sh", "she", "she'd", "she'll", "she's", "should", "shouldn", "shouldn't", "si", "since", "site", "six", "sixty", "sj", "sk", "sl", "sm", "sn", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "sr", "st", "still", "stop", "su", "such", "sv", "sy", "sz", "t", "taking", "tc", "td", "ten", "text", "tf", "tg", "test", "th", "than", "that", "that'll", "that's", "the", "their", "them", "themselves", "then", "thence", "there", "there'll", "there's", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "they'd", "they'll", "they're", "they've", "thirty", "this", "those", "though", "thousand", "three", "through", "throughout", "thru", "thus", "tj", "tk", "tm", "tn", "to", "together", "too", "toward", "towards", "tp", "tr", "trillion", "tt", "tv", "tw", "twenty", "two", "tz", "u", "ua", "ug", "uk", "um", "under", "unless", "unlike", "unlikely", "until", "up", "upon", "us", "use", "used", "using", "uy", "uz", "v", "va", "vc", "ve", "very", "vg", "vi", "via", "vn", "vu", "w", "was", "wasn", "wasn't", "we", "we'd", "we'll", "we're", "we've", "web", "webpage", "website", "welcome", "well", "were", "weren", "weren't", "wf", "what", "what'll", "what's", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "who'd", "who'll", "who's", "whoever", "NULL", "whole", "whom", "whomever", "whose", "why", "will", "with", "within", "without", "won", "won't", "would", "wouldn", "wouldn't", "ws", "www", "x", "y", "ye", "yes", "yet", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves", "yt", "yu", "z", "za", "zm", "zr", "10", "z"); $splitstr = @explode(" ", truncate_string(seo_simple_strip_tags(str_replace(array(",", "."), " ", $str)), $length)); $new_splitstr = array(); foreach ($splitstr as $spstr) { if (strlen($spstr) > 2 && !in_array(strtolower($spstr), $new_splitstr) && !in_array(strtolower($spstr), $exclude)) { $new_splitstr[] = strtolower($spstr); } } return @implode(",", $new_splitstr); }
function seo_create_meta_keywords($str, $length = 2000) { // Strip HTML and Truncate to create a META keywords, Google doesn't care about META tags. $exclude = array('description', 'save', '$ave', 'month!', 'year!', 'hundreds', 'dollars', 'per', 'month', 'year', 'and', 'or', 'but', 'at', 'in', 'on', 'to', 'from', 'is', 'a', 'an', 'am', 'for', 'of', 'the'); $splitstr = @explode(" ", truncate_string(seo_simple_strip_tags(str_replace(array(",", "."), " ", $str)), $length)); $new_splitstr = array(); foreach ($splitstr as $spstr) { if (strlen($spstr) > 2 && !in_array(strtolower($spstr), $new_splitstr) && !in_array(strtolower($spstr), $exclude)) { $new_splitstr[] = strtolower($spstr); } } return @implode(", ", $new_splitstr); }
function zenphoto_recent_comments() { //////////////////////////////////////////////////////////////////// /*------------------- START OF CONFIGURATION ---------------------*/ /*MySQL Settings*/ $zen_db = ''; //The name of the database $zen_username = ''; //Your MySQL username $zen_password = ''; //...and password $zen_host = 'localhost'; //99% chance you won't need to change this value $mysql_prefix = ''; //Zen Database Tables prefix (if any) /*More...*/ $num_of_comments = '10'; //Number of comments you want to show up. $mods_rewrite = true; //If you have Apache mod_rewrite, put true here, and you'll get nice cruft-free URLs. $gallery_folder = 'zenphoto'; //eg. http://mysite.com/zenphoto /*--------------------- END OF CONFIGURATION ---------------------*/ //////////////////////////////////////////////////////////////////// //we will try to connect to the database @($mysql_connection = mysql_connect($zen_host, $zen_username, $zen_password)) or die('Could not connect to database.'); //selecting zenphoto database @mysql_select_db($zen_db) or die('Could not select database.'); $sql = "SELECT c.id, i.title, i.filename, a.folder, a.title AS albumtitle, c.name, c.website," . " c.date, c.comment FROM " . prefix('comments') . " AS c, " . prefix('images') . " AS i, " . prefix('albums') . " AS a " . " WHERE c.imageid = i.id AND i.albumid = a.id ORDER BY c.id DESC LIMIT 10"; $result = mysql_query($sql, $mysql_connection) or die('MySQL Query ( ' . $sql . ' ) Failed. Error: ' . mysql_error()); $allrows = array(); while ($row = mysql_fetch_assoc($result)) { $allrows[] = $row; } foreach ($allrows as $comment) { $author = $comment['name']; $album = $comment['folder']; $image = $comment['filename']; $albumtitle = $comment['albumtitle']; if ($comment['title'] == "") { $title = $image; } else { $title = $comment['title']; } $website = $comment['website']; $comment = truncate_string($comment['comment'], 123); echo "<li><div>{$author} on <a href=\"" . ($mods_rewrite ? "../{$gallery_folder}/{$album}/{$image}" : "../{$gallery_folder}/index.php?album=" . urlencode($album) . "&image=" . urlencode($image)) . "\">{$albumtitle} / {$title}</a>:</div><div>{$comment}</div></li>"; } }
function dashboard_incoming_display($dashletid) { global $sit, $CONFIG, $iconset; global $dbUpdates, $dbTempIncoming; // extract updates (query copied from review_incoming_email.php) $sql = "SELECT u.id AS id, u.bodytext AS bodytext, ti.emailfrom AS emailfrom, ti.subject AS subject, "; $sql .= "u.timestamp AS timestamp, ti.incidentid AS incidentid, ti.id AS tempid, ti.locked AS locked, "; $sql .= "ti.reason AS reason, ti.contactid AS contactid, ti.`from` AS fromaddr "; $sql .= "FROM `{$dbUpdates}` AS u, `{$dbTempIncoming}` AS ti "; $sql .= "WHERE u.incidentid = 0 AND ti.updateid = u.id "; $sql .= "ORDER BY timestamp ASC, id ASC"; $result = mysql_query($sql); if (mysql_error()) { trigger_error(mysql_error(), E_USER_WARNING); } if (user_permission($sit[2], 42)) { //echo "<div class='window'>"; if (mysql_num_rows($result) >= 1) { echo "<table align='center' width='100%'>"; echo "<tr>"; # echo colheader('from', $GLOBALS['strFrom']); echo colheader('subject', $GLOBALS['strSubject']); echo colheader('message', $GLOBALS['strMessage']); echo "</tr>\n"; $shade = 'shade1'; while ($incoming = mysql_fetch_object($result)) { $date = mysql2date($incoming->date); echo "<tr class='{$shade}'>"; # echo "<td><a href='holding_queue.php' class='info'>".truncate_string($incoming->emailfrom, 15); # echo "</a></td>"; echo "<td><a href='holding_queue.php' class='info'>" . truncate_string($incoming->subject, 25); echo "</a></td>"; echo "<td><a href='holding_queue.php' class='info'>" . truncate_string($incoming->reason, 25); echo "</a></td>"; echo "</tr>\n"; if ($shade == 'shade1') { $shade = 'shade2'; } else { $shade = 'shade1'; } } echo "</table>\n"; } else { echo "<p align='center'>{$GLOBALS['strNoRecords']}</p>"; } } else { echo "<p class='error'>{$GLOBALS['strPermissionDenied']}</p>"; } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $inputs = Input::all(); $type = Message::getIntegerTypeBy($inputs['name']); $to = $inputs['pk']; $from = $inputs['sentby_id']; $body = $inputs['value']; $subject = truncate_string($body, 24, '...'); $msg = new Message(); $msg->from = $from; $msg->to = $to; $msg->type = $type; $msg->subject = $subject; $msg->body = $body; $msg->save(); $data['status'] = 'success'; $data['message'] = 'Sent successfully'; return Response::json($data); }
function makeArticle($class, $text) { global $unique; $unique++; $i = strpos($text, '</a>'); $j = strpos($text, '</h4>'); $h4 = substr($text, $i + 4, $j - $i - 4); $text = substr($text, $j + 5); $text = str_replace('<hr />', '', $text); $text = str_replace('<hr/>', '', $text); $ts_news = new ZenpageNews(seoFriendly($class . '_' . trim(truncate_string(strip_tags($h4), 30, '')) . '_' . $unique), true); $ts_news->setShow(0); $ts_news->setDateTime(date('Y-m-d H:i:s')); $ts_news->setAuthor('TSGenerator'); $ts_news->setTitle($h4); $ts_news->setContent($text); $ts_news->setCategories(array()); $ts_news->setCategories(array('troubleshooting', 'troubleshooting-' . $class)); $ts_news->save(); }
function getInfo() { $id = db_escape_string($_REQUEST['id']); $result = db_query("SELECT title, link\r\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\r\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']); if (db_num_rows($result) != 0) { $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...'); $article_link = db_fetch_result($result, 0, 'link'); } $yourls_url = $this->host->get($this, "Yourls_URL"); $yourls_api = $this->host->get($this, "Yourls_API"); curl_setopt($curl_yourls, CURLOPT_URL, "{$yourls_url}/yourls-api.php?signature={$yourls_api}&action=shorturl&format=simple&url=" . urlencode($article_link) . "&title=" . urlencode($title)); curl_setopt($curl_yourls, CURLOPT_RETURNTRANSFER, true); if (!ini_get('safe_mode') && !ini_get('open_basedir')) { curl_setopt($curl_yourls, CURLOPT_FOLLOWLOCATION, true); } $short_url = curl_exec($curl_yourls); curl_setopt($this->curl_yourls, CURLOPT_URL, "{$yourls_url}/yourls-api.php?signature={$yourls_api}&action=shorturl&format=simple&url=" . urlencode($article_link) . "&title=" . urlencode($title)); $short_url = curl_exec($this->curl_yourls); print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "yourlsurl" => $yourls_url, "yourlsapi" => $yourls_api, "shorturl" => $short_url)); }
?> " title="<?php echo gettext('View album:'); ?> <?php printBareAlbumTitle(); ?> "><?php printAlbumTitle(); ?> </a></h3> <?php printAlbumDate(""); ?> <p><?php echo truncate_string(getAlbumDesc(), 45); ?> </p> </div> </div> <?php } ?> </div> <?php } ?> <?php if (getNumImages() > 0) { ?> <div id="images">
/** * Submit PM */ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) { global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $request; // We do not handle erasing pms here if ($mode == 'delete') { return false; } $current_time = time(); /** * Get all parts of the PM that are to be submited to the DB. * * @event core.submit_pm_before * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit * @var string subject Subject of the private message * @var array data The whole row data of the PM. * @since 3.1.0-b3 */ $vars = array('mode', 'subject', 'data'); extract($phpbb_dispatcher->trigger_event('core.submit_pm_before', compact($vars))); // Collect some basic information about which tables and which rows to update/insert $sql_data = array(); $root_level = 0; // Recipient Information $recipients = $to = $bcc = array(); if ($mode != 'edit') { // Build Recipient List // u|g => array($user_id => 'to'|'bcc') $_types = array('u', 'g'); foreach ($_types as $ug_type) { if (isset($data['address_list'][$ug_type]) && sizeof($data['address_list'][$ug_type])) { foreach ($data['address_list'][$ug_type] as $id => $field) { $id = (int) $id; // Do not rely on the address list being "valid" if (!$id || $ug_type == 'u' && $id == ANONYMOUS) { continue; } $field = $field == 'to' ? 'to' : 'bcc'; if ($ug_type == 'u') { $recipients[$id] = $field; } ${$field}[] = $ug_type . '_' . $id; } } } if (isset($data['address_list']['g']) && sizeof($data['address_list']['g'])) { // We need to check the PM status of group members (do they want to receive PM's?) // Only check if not a moderator or admin, since they are allowed to override this user setting $sql_allow_pm = !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') ? ' AND u.user_allow_pm = 1' : ''; $sql = 'SELECT u.user_type, ug.group_id, ug.user_id FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . ' AND ug.user_pending = 0 AND u.user_id = ug.user_id AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . $sql_allow_pm; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $field = $data['address_list']['g'][$row['group_id']] == 'to' ? 'to' : 'bcc'; $recipients[$row['user_id']] = $field; } $db->sql_freeresult($result); } if (!sizeof($recipients)) { trigger_error('NO_RECIPIENT'); } } // First of all make sure the subject are having the correct length. $subject = truncate_string($subject); $db->sql_transaction('begin'); $sql = ''; switch ($mode) { case 'reply': case 'quote': $root_level = $data['reply_from_root_level'] ? $data['reply_from_root_level'] : $data['reply_from_msg_id']; // Set message_replied switch for this user $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' SET pm_replied = 1 WHERE user_id = ' . $data['from_user_id'] . ' AND msg_id = ' . $data['reply_from_msg_id']; // no break // no break case 'forward': case 'post': case 'quotepost': $sql_data = array('root_level' => $root_level, 'author_id' => $data['from_user_id'], 'icon_id' => $data['icon_id'], 'author_ip' => $data['from_user_ip'], 'message_time' => $current_time, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'message_subject' => $subject, 'message_text' => $data['message'], 'message_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'to_address' => implode(':', $to), 'bcc_address' => implode(':', $bcc), 'message_reported' => 0); break; case 'edit': $sql_data = array('icon_id' => $data['icon_id'], 'message_edit_time' => $current_time, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'message_subject' => $subject, 'message_text' => $data['message'], 'message_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid']); break; } if (sizeof($sql_data)) { $query = ''; if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward') { $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data)); $data['msg_id'] = $db->sql_nextid(); } else { if ($mode == 'edit') { $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . ' WHERE msg_id = ' . $data['msg_id']; $db->sql_query($sql); } } } if ($mode != 'edit') { if ($sql) { $db->sql_query($sql); } unset($sql); $sql_ary = array(); foreach ($recipients as $user_id => $type) { $sql_ary[] = array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $user_id, 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_NO_BOX, 'pm_new' => 1, 'pm_unread' => 1, 'pm_forwarded' => $mode == 'forward' ? 1 : 0); } $db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . ' WHERE ' . $db->sql_in_set('user_id', array_keys($recipients)); $db->sql_query($sql); // Put PM into outbox if ($put_in_outbox) { $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $data['from_user_id'], 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_OUTBOX, 'pm_new' => 0, 'pm_unread' => 0, 'pm_forwarded' => $mode == 'forward' ? 1 : 0))); } } // Set user last post time if ($mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward' || $mode == 'post') { $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_lastpost_time = {$current_time}\n\t\t\tWHERE user_id = " . $data['from_user_id']; $db->sql_query($sql); } // Submit Attachments if (!empty($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward'))) { $space_taken = $files_added = 0; $orphan_rows = array(); foreach ($data['attachment_data'] as $pos => $attach_row) { $orphan_rows[(int) $attach_row['attach_id']] = array(); } if (sizeof($orphan_rows)) { $sql = 'SELECT attach_id, filesize, physical_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' AND in_message = 1 AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $orphan_rows = array(); while ($row = $db->sql_fetchrow($result)) { $orphan_rows[$row['attach_id']] = $row; } $db->sql_freeresult($result); } foreach ($data['attachment_data'] as $pos => $attach_row) { if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) { continue; } if (!$attach_row['is_orphan']) { // update entry in db if attachment already stored in db and filespace $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tSET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . ' AND is_orphan = 0'; $db->sql_query($sql); } else { // insert attachment into db if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) { continue; } $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; $files_added++; $attach_sql = array('post_msg_id' => $data['msg_id'], 'topic_id' => 0, 'is_orphan' => 0, 'poster_id' => $data['from_user_id'], 'attach_comment' => $attach_row['attach_comment']); $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . $attach_row['attach_id'] . ' AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $db->sql_query($sql); } } if ($space_taken && $files_added) { $config->increment('upload_dir_size', $space_taken, false); $config->increment('num_files', $files_added, false); } } // Delete draft if post was loaded... $draft_id = $request->variable('draft_loaded', 0); if ($draft_id) { $sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND user_id = " . $data['from_user_id']; $db->sql_query($sql); } $db->sql_transaction('commit'); // Send Notifications $pm_data = array_merge($data, array('message_subject' => $subject, 'recipients' => $recipients)); /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); if ($mode == 'edit') { $phpbb_notifications->update_notifications('notification.type.pm', $pm_data); } else { $phpbb_notifications->add_notifications('notification.type.pm', $pm_data); } /** * Get PM message ID after submission to DB * * @event core.submit_pm_after * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit * @var string subject Subject of the private message * @var array data The whole row data of the PM. * @var array pm_data The data sent to notification class * @since 3.1.0-b5 */ $vars = array('mode', 'subject', 'data', 'pm_data'); extract($phpbb_dispatcher->trigger_event('core.submit_pm_after', compact($vars))); return $data['msg_id']; }
/** * Prints the statistics Zenpage items as an unordered list * * @param int $number The number of news items to get * @param string $option "all" pages and articles * "news" for news articles * "pages" for pages * @param string $mode "popular" most viewed for pages, news articles and categories * "mostrated" for news articles and pages * "toprated" for news articles and pages * "random" for pages, news articles and categories * @param bool $showstats if the value should be shown * @param bool $showtype if the type should be shown * @param bool $showdate if the date should be shown (news articles and pages only) * @param bool $showcontent if the content should be shown (news articles and pages only) * @param bool $contentlength The shortened lenght of the content * @param string $sortdir "asc" for ascending or "desc" for descending (default) */ function printZenpageStatistic($number = 10, $option = "all", $mode = "popular", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40, $sortdir = 'desc') { $stats = getZenpageStatistic($number, $option, $mode); $contentlength = sanitize_numeric($contentlength); switch ($mode) { case 'popular': $cssid = "'zenpagemostpopular'"; break; case 'mostrated': $cssid = "'zenpagemostrated'"; break; case 'toprated': $cssid = "'zenpagetoprated'"; break; case 'random': $cssid = "'zenpagerandom'"; break; } echo "<ul id={$cssid}>"; foreach ($stats as $item) { switch ($mode) { case 'popular': $statsvalue = $item['hitcounter']; break; case 'mostrated': $statsvalue = $item['total_votes']; break; case 'toprated': $statsvalue = $item['rating']; break; } switch ($item['type']) { case 'Page': $titlelink = html_encode(getPageURL($item['titlelink'])); case 'News': $titlelink = html_encode(getNewsURL($item['titlelink'])); break; case 'Category': $titlelink = html_encode(getNewsCategoryURL($item['titlelink'])); break; } echo '<li><a href = "' . $titlelink . '" title = "' . html_encode(getBare($item['title'])) . '"><h3>' . $item['title']; echo '<small>'; if ($showtype) { echo ' [' . $item['type'] . ']'; } if ($showstats && ($item['type'] != 'Category' && $mode != 'mostrated' && $mode != 'toprated')) { echo ' (' . $statsvalue . ')'; } echo '</small>'; echo '</h3></a>'; if ($showdate && $item['type'] != 'Category') { echo "<p>" . zpFormattedDate(DATE_FORMAT, strtotime($item['date'])) . "</p>"; } if ($showcontent && $item['type'] != 'Category') { echo '<p>' . truncate_string($item['content'], $contentlength) . '</p>'; } echo '</li>'; } echo '</ul>'; }
/** * Submit Post * @todo Split up and create lightweight, simple API for this. */ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; /** * Modify the data for post submitting * * @event core.modify_submit_post_data * @var string mode Variable containing posting mode value * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value * @var array poll Array with the poll data for the post * @var array data Array with the data for the post * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 */ $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index'); extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); // We do not handle erasing posts here if ($mode == 'delete') { return false; } if (!empty($data['post_time'])) { $current_time = $data['post_time']; } else { $current_time = time(); } if ($mode == 'post') { $post_mode = 'post'; $update_message = true; } else { if ($mode != 'edit') { $post_mode = 'reply'; $update_message = true; } else { if ($mode == 'edit') { $post_mode = $data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1 ? 'edit_topic' : ($data['topic_first_post_id'] == $data['post_id'] ? 'edit_first_post' : ($data['topic_last_post_id'] == $data['post_id'] ? 'edit_last_post' : 'edit')); } } } // First of all make sure the subject and topic title are having the correct length. // To achieve this without cutting off between special chars we convert to an array and then count the elements. $subject = truncate_string($subject, 120); $data['topic_title'] = truncate_string($data['topic_title'], 120); // Collect some basic information about which tables and which rows to update/insert $sql_data = $topic_row = array(); $poster_id = $mode == 'edit' ? $data['poster_id'] : (int) $user->data['user_id']; // Retrieve some additional information if not present if ($mode == 'edit' && (!isset($data['post_visibility']) || !isset($data['topic_visibility']) || $data['post_visibility'] === false || $data['topic_visibility'] === false)) { $sql = 'SELECT p.post_visibility, t.topic_type, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_visibility FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id = p.topic_id AND p.post_id = ' . $data['post_id']; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $data['topic_visibility'] = $topic_row['topic_visibility']; $data['post_visibility'] = $topic_row['post_visibility']; } // This variable indicates if the user is able to post or put into the queue $post_visibility = ITEM_APPROVED; // Check the permissions for post approval. // Moderators must go through post approval like ordinary users. if (!$auth->acl_get('f_noapprove', $data['forum_id'])) { // Post not approved, but in queue $post_visibility = ITEM_UNAPPROVED; switch ($post_mode) { case 'edit_first_post': case 'edit': case 'edit_last_post': case 'edit_topic': $post_visibility = ITEM_REAPPROVE; break; } } // MODs/Extensions are able to force any visibility on posts if (isset($data['force_approved_state'])) { $post_visibility = in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE)) ? (int) $data['force_approved_state'] : $post_visibility; } if (isset($data['force_visibility'])) { $post_visibility = in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE)) ? (int) $data['force_visibility'] : $post_visibility; } // Start the transaction here $db->sql_transaction('begin'); // Collect Information switch ($post_mode) { case 'post': case 'reply': $sql_data[POSTS_TABLE]['sql'] = array('forum_id' => $data['forum_id'], 'poster_id' => (int) $user->data['user_id'], 'icon_id' => $data['icon_id'], 'poster_ip' => $user->ip, 'post_time' => $current_time, 'post_visibility' => $post_visibility, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'post_username' => !$user->data['is_registered'] ? $username : '', 'post_subject' => $subject, 'post_text' => $data['message'], 'post_checksum' => $data['message_md5'], 'post_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'post_postcount' => $auth->acl_get('f_postcount', $data['forum_id']) ? 1 : 0, 'post_edit_locked' => $data['post_edit_locked']); break; case 'edit_first_post': case 'edit': case 'edit_last_post': case 'edit_topic': // If edit reason is given always display edit info // If editing last post then display no edit info // If m_edit permission then display no edit info // If normal edit display edit info // Display edit info if edit reason given or user is editing his post, which is not the last within the topic. if ($data['post_edit_reason'] || !$auth->acl_get('m_edit', $data['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post')) { $data['post_edit_reason'] = truncate_string($data['post_edit_reason'], 255, 255, false); $sql_data[POSTS_TABLE]['sql'] = array('post_edit_time' => $current_time, 'post_edit_reason' => $data['post_edit_reason'], 'post_edit_user' => (int) $data['post_edit_user']); $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; } else { if (!$data['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data['forum_id'])) { $sql_data[POSTS_TABLE]['sql'] = array('post_edit_reason' => ''); } } // If the person editing this post is different to the one having posted then we will add a log entry stating the edit // Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods if ($user->data['user_id'] != $poster_id) { $log_subject = $subject ? $subject : $data['topic_title']; $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array('forum_id' => $data['forum_id'], 'topic_id' => $data['topic_id'], 'post_id' => $data['post_id'], $log_subject, !empty($username) ? $username : $user->lang['GUEST'], $data['post_edit_reason'])); } if (!isset($sql_data[POSTS_TABLE]['sql'])) { $sql_data[POSTS_TABLE]['sql'] = array(); } $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('forum_id' => $data['forum_id'], 'poster_id' => $data['poster_id'], 'icon_id' => $data['icon_id'], 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'post_username' => $username && $data['poster_id'] == ANONYMOUS ? $username : '', 'post_subject' => $subject, 'post_checksum' => $data['message_md5'], 'post_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'post_edit_locked' => $data['post_edit_locked'])); if ($update_message) { $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message']; } break; } $topic_row = array(); // And the topic ladies and gentlemen switch ($post_mode) { case 'post': $sql_data[TOPICS_TABLE]['sql'] = array('topic_poster' => (int) $user->data['user_id'], 'topic_time' => $current_time, 'topic_last_view_time' => $current_time, 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_posts_approved' => $post_visibility == ITEM_APPROVED ? 1 : 0, 'topic_posts_softdeleted' => $post_visibility == ITEM_DELETED ? 1 : 0, 'topic_posts_unapproved' => $post_visibility == ITEM_UNAPPROVED ? 1 : 0, 'topic_visibility' => $post_visibility, 'topic_delete_user' => $post_visibility != ITEM_APPROVED ? (int) $user->data['user_id'] : 0, 'topic_title' => $subject, 'topic_first_poster_name' => !$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : ''), 'topic_first_poster_colour' => $user->data['user_colour'], 'topic_type' => $topic_type, 'topic_time_limit' => $topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE ? $data['topic_time_limit'] * 86400 : 0, 'topic_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'topic_status' => isset($data['topic_status']) ? $data['topic_status'] : ITEM_UNLOCKED); if (isset($poll['poll_options']) && !empty($poll['poll_options'])) { $poll_start = $poll['poll_start'] ? $poll['poll_start'] : $current_time; $poll_length = $poll['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; if ($poll_start < 0) { $poll_start = 0; } $poll_length = 1; } $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array('poll_title' => $poll['poll_title'], 'poll_start' => $poll_start, 'poll_max_options' => $poll['poll_max_options'], 'poll_length' => $poll_length, 'poll_vote_change' => $poll['poll_vote_change'])); } $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = {$current_time}" . ($auth->acl_get('f_postcount', $data['forum_id']) && $post_visibility == ITEM_APPROVED ? ', user_posts = user_posts + 1' : ''); if ($post_visibility == ITEM_APPROVED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_approved = forum_topics_approved + 1'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; } else { if ($post_visibility == ITEM_UNAPPROVED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_unapproved = forum_topics_unapproved + 1'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; } else { if ($post_visibility == ITEM_DELETED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_softdeleted = forum_topics_softdeleted + 1'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; } } } break; case 'reply': $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', topic_bumped = 0, topic_bumper = 0' . ($post_visibility == ITEM_APPROVED ? ', topic_posts_approved = topic_posts_approved + 1' : '') . ($post_visibility == ITEM_UNAPPROVED ? ', topic_posts_unapproved = topic_posts_unapproved + 1' : '') . ($post_visibility == ITEM_DELETED ? ', topic_posts_softdeleted = topic_posts_softdeleted + 1' : '') . (!empty($data['attachment_data']) || isset($data['topic_attachment']) && $data['topic_attachment'] ? ', topic_attachment = 1' : ''); $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = {$current_time}" . ($auth->acl_get('f_postcount', $data['forum_id']) && $post_visibility == ITEM_APPROVED ? ', user_posts = user_posts + 1' : ''); if ($post_visibility == ITEM_APPROVED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; } else { if ($post_visibility == ITEM_UNAPPROVED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; } else { if ($post_visibility == ITEM_DELETED) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; } } } break; case 'edit_topic': case 'edit_first_post': if (isset($poll['poll_options'])) { $poll_start = $poll['poll_start'] || empty($poll['poll_options']) ? $poll['poll_start'] : $current_time; $poll_length = $poll['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; if ($poll_start < 0) { $poll_start = 0; } $poll_length = 1; } } $sql_data[TOPICS_TABLE]['sql'] = array('forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, 'topic_time_limit' => $topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE ? $data['topic_time_limit'] * 86400 : 0, 'poll_title' => isset($poll['poll_options']) ? $poll['poll_title'] : '', 'poll_start' => isset($poll['poll_options']) ? $poll_start : 0, 'poll_max_options' => isset($poll['poll_options']) ? $poll['poll_max_options'] : 1, 'poll_length' => isset($poll['poll_options']) ? $poll_length : 0, 'poll_vote_change' => isset($poll['poll_vote_change']) ? $poll['poll_vote_change'] : 0, 'topic_last_view_time' => $current_time, 'topic_attachment' => !empty($data['attachment_data']) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0)); break; } /** * Modify sql query data for post submitting * * @event core.submit_post_modify_sql_data * @var array data Array with the data for the post * @var array poll Array with the poll data for the post * @var string post_mode Variable containing posting mode value * @var bool sql_data Array with the data for the posting SQL query * @var string subject Variable containing post subject value * @var int topic_type Variable containing topic type value * @var string username Variable containing post author name * @since 3.1.3-RC1 */ $vars = array('data', 'poll', 'post_mode', 'sql_data', 'subject', 'topic_type', 'username'); extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); // Submit new topic if ($post_mode == 'post') { $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); $db->sql_query($sql); $data['topic_id'] = $db->sql_nextid(); $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id'])); unset($sql_data[TOPICS_TABLE]['sql']); } // Submit new post if ($post_mode == 'post' || $post_mode == 'reply') { if ($post_mode == 'reply') { $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id'])); } $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); $db->sql_query($sql); $data['post_id'] = $db->sql_nextid(); if ($post_mode == 'post' || $post_visibility == ITEM_APPROVED) { $sql_data[TOPICS_TABLE]['sql'] = array('topic_last_post_id' => $data['post_id'], 'topic_last_post_time' => $current_time, 'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'], 'topic_last_poster_name' => $user->data['user_id'] == ANONYMOUS ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'], 'topic_last_poster_colour' => $user->data['user_colour'], 'topic_last_post_subject' => (string) $subject); } if ($post_mode == 'post') { $sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data['post_id']; } // Update total post count and forum information if ($post_visibility == ITEM_APPROVED) { if ($post_mode == 'post') { $config->increment('num_topics', 1, false); } $config->increment('num_posts', 1, false); $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(!$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : '')) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'"; } unset($sql_data[POSTS_TABLE]['sql']); } // Update the topics table if (isset($sql_data[TOPICS_TABLE]['sql'])) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' WHERE topic_id = ' . $data['topic_id']; $db->sql_query($sql); unset($sql_data[TOPICS_TABLE]['sql']); } // Update the posts table if (isset($sql_data[POSTS_TABLE]['sql'])) { $sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' WHERE post_id = ' . $data['post_id']; $db->sql_query($sql); unset($sql_data[POSTS_TABLE]['sql']); } // Update Poll Tables if (isset($poll['poll_options'])) { $cur_poll_options = array(); if ($mode == 'edit') { $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id = ' . $data['topic_id'] . ' ORDER BY poll_option_id'; $result = $db->sql_query($sql); $cur_poll_options = array(); while ($row = $db->sql_fetchrow($result)) { $cur_poll_options[] = $row; } $db->sql_freeresult($result); } $sql_insert_ary = array(); for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++) { if (strlen(trim($poll['poll_options'][$i]))) { if (empty($cur_poll_options[$i])) { // If we add options we need to put them to the end to be able to preserve votes... $sql_insert_ary[] = array('poll_option_id' => (int) sizeof($cur_poll_options) + 1 + sizeof($sql_insert_ary), 'topic_id' => (int) $data['topic_id'], 'poll_option_text' => (string) $poll['poll_options'][$i]); } else { if ($poll['poll_options'][$i] != $cur_poll_options[$i]) { $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . "\n\t\t\t\t\t\tSET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "'\n\t\t\t\t\t\tWHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } } } } $db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) { $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' WHERE poll_option_id > ' . sizeof($poll['poll_options']) . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option if ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options)) { $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data['topic_id']); $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data['topic_id']); } } // Submit Attachments if (!empty($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) { $space_taken = $files_added = 0; $orphan_rows = array(); foreach ($data['attachment_data'] as $pos => $attach_row) { $orphan_rows[(int) $attach_row['attach_id']] = array(); } if (sizeof($orphan_rows)) { $sql = 'SELECT attach_id, filesize, physical_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $orphan_rows = array(); while ($row = $db->sql_fetchrow($result)) { $orphan_rows[$row['attach_id']] = $row; } $db->sql_freeresult($result); } foreach ($data['attachment_data'] as $pos => $attach_row) { if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) { continue; } if (!$attach_row['is_orphan']) { // update entry in db if attachment already stored in db and filespace $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tSET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . ' AND is_orphan = 0'; $db->sql_query($sql); } else { // insert attachment into db if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) { continue; } $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; $files_added++; $attach_sql = array('post_msg_id' => $data['post_id'], 'topic_id' => $data['topic_id'], 'is_orphan' => 0, 'poster_id' => $poster_id, 'attach_comment' => $attach_row['attach_comment']); $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . $attach_row['attach_id'] . ' AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $db->sql_query($sql); } } if ($space_taken && $files_added) { $config->increment('upload_dir_size', $space_taken, false); $config->increment('num_files', $files_added, false); } } $first_post_has_topic_info = $post_mode == 'edit_first_post' && ($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1 || $post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1 || $post_visibility == ITEM_REAPPROVE && $data['topic_posts_unapproved'] == 1 || $post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1); // Fix the post's and topic's visibility and first/last post information, when the post is edited if ($post_mode != 'post' && $post_mode != 'reply' && $data['post_visibility'] != $post_visibility) { // If the post was not approved, it could also be the starter, // so we sync the starter after approving/restoring, to ensure that the stats are correct // Same applies for the last post $is_starter = $post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED; $is_latest = $post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED; /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } else { if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_has_topic_info) { if ($post_visibility == ITEM_APPROVED || $data['topic_visibility'] == $post_visibility) { // only the subject can be changed from edit $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; // Maybe not only the subject, but also changing anonymous usernames. ;) if ($data['poster_id'] == ANONYMOUS) { $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; } if ($post_visibility == ITEM_APPROVED) { // this does not _necessarily_ mean that we must update the info again, // it just means that we might have to $sql = 'SELECT forum_last_post_id, forum_last_post_subject FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // this post is the latest post in the forum, better update if ($row['forum_last_post_id'] == $data['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data['poster_id'] == ANONYMOUS)) { // the post's subject changed if ($row['forum_last_post_subject'] !== $subject) { $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; } // Update the user name if poster is anonymous... just in case a moderator changed it if ($data['poster_id'] == ANONYMOUS) { $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; } } } } } } // Update forum stats $where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $poster_id); foreach ($sql_data as $table => $update_ary) { if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) { $sql = "UPDATE {$table} SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]; $db->sql_query($sql); } } // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement if ($topic_type == POST_GLOBAL) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = ' . $data['topic_id']; $db->sql_query($sql); } // Committing the transaction before updating search index $db->sql_transaction('commit'); // Delete draft if post was loaded... $draft_id = $request->variable('draft_loaded', 0); if ($draft_id) { $sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND user_id = {$user->data['user_id']}"; $db->sql_query($sql); } // Index message contents if ($update_search_index && $data['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised $search_type = $config['search_type']; if (!class_exists($search_type)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } $error = false; $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); if ($error) { trigger_error($error); } $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $data['forum_id']); } // Topic Notification, do not change if moderator is changing other users posts... if ($user->data['user_id'] == $poster_id) { if (!$data['notify_set'] && $data['notify']) { $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')'; $db->sql_query($sql); } else { if (($config['email_enable'] || $config['jab_enable']) && $data['notify_set'] && !$data['notify']) { $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } } } if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') { // Mark this topic as posted to markread('post', $data['forum_id'], $data['topic_id']); } // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) markread('topic', $data['forum_id'], $data['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) { $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { $f_mark_time = false; } } if ($config['load_db_lastread'] && $user->data['is_registered'] || $config['load_anon_lastread'] || $user->data['is_registered']) { // Update forum info $sql = 'SELECT forum_last_post_time FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); } // If a username was supplied or the poster is a guest, we will use the supplied username. // Doing it this way we can use "...post by guest-username..." in notifications when // "guest-username" is supplied or ommit the username if it is not. $username = $username !== '' || !$user->data['is_registered'] ? $username : $user->data['username']; // Send Notifications $notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => $poster_id, 'post_text' => $data['message'], 'post_time' => $current_time, 'post_subject' => $subject)); /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); if ($post_visibility == ITEM_APPROVED) { switch ($mode) { case 'post': $phpbb_notifications->add_notifications(array('notification.type.quote', 'notification.type.topic'), $notification_data); break; case 'reply': case 'quote': $phpbb_notifications->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post'), $notification_data); break; case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': $phpbb_notifications->update_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.topic', 'notification.type.post'), $notification_data); break; } } else { if ($post_visibility == ITEM_UNAPPROVED) { switch ($mode) { case 'post': $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); break; case 'reply': case 'quote': $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); break; case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': // Nothing to do here break; } } else { if ($post_visibility == ITEM_REAPPROVE) { switch ($mode) { case 'edit_topic': case 'edit_first_post': $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); // Delete the approve_post notification so we can notify the user again, // when his post got reapproved $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); break; case 'edit': case 'edit_last_post': $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); // Delete the approve_post notification so we can notify the user again, // when his post got reapproved $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); break; case 'post': case 'reply': case 'quote': // Nothing to do here break; } } else { if ($post_visibility == ITEM_DELETED) { switch ($mode) { case 'post': case 'reply': case 'quote': case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': // Nothing to do here break; } } } } } $params = $add_anchor = ''; if ($post_visibility == ITEM_APPROVED) { $params .= '&t=' . $data['topic_id']; if ($mode != 'post') { $params .= '&p=' . $data['post_id']; $add_anchor = '#p' . $data['post_id']; } } else { if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') { $params .= '&t=' . $data['topic_id']; } } $url = !$params ? "{$phpbb_root_path}viewforum.{$phpEx}" : "{$phpbb_root_path}viewtopic.{$phpEx}"; $url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; /** * This event is used for performing actions directly after a post or topic * has been submitted. When a new topic is posted, the topic ID is * available in the $data array. * * The only action that can be done by altering data made available to this * event is to modify the return URL ($url). * * @event core.submit_post_end * @var string mode Variable containing posting mode value * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value * @var array poll Array with the poll data for the post * @var array data Array with the data for the post * @var int post_visibility Variable containing up to date post visibility * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @var string url The "Return to topic" URL * * @since 3.1.0-a3 * @change 3.1.0-RC3 Added vars mode, subject, username, topic_type, * poll, update_message, update_search_index */ $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'post_visibility', 'update_message', 'update_search_index', 'url'); extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); return $url; }
function getFeedCounters($active_feed = false) { $ret_arr = array(); $query = "SELECT ttrss_feeds.id,\n\t\t\t\tttrss_feeds.title,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(ttrss_feeds.last_updated,1,19) AS last_updated,\n\t\t\t\tlast_error, value AS count\n\t\t\tFROM ttrss_feeds, ttrss_counters_cache\n\t\t\tWHERE ttrss_feeds.owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tAND ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid\n\t\t\t\tAND ttrss_counters_cache.feed_id = id"; $result = db_query($query); while ($line = db_fetch_assoc($result)) { $id = $line["id"]; $count = $line["count"]; $last_error = htmlspecialchars($line["last_error"]); $last_updated = make_local_datetime($line['last_updated'], false); $has_img = feed_has_icon($id); if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2) { $last_updated = ''; } $cv = array("id" => $id, "updated" => $last_updated, "counter" => (int) $count, "has_img" => (int) $has_img); if ($last_error) { $cv["error"] = $last_error; } // if (get_pref('EXTENDED_FEEDLIST')) // $cv["xmsg"] = getFeedArticles($id)." ".__("total"); if ($active_feed && $id == $active_feed) { $cv["title"] = truncate_string($line["title"], 30); } array_push($ret_arr, $cv); } return $ret_arr; }
/** * Transfers the relevant configuration information from the source forum * The mapping of fields is specified in $config_schema, see convert_phpbb20.php for more details */ function restore_config($schema) { global $db, $config; $convert_config = get_config(); foreach ($schema['settings'] as $config_name => $src) { if (preg_match('/(.*)\\((.*)\\)/', $src, $m)) { $var = empty($m[2]) || empty($convert_config[$m[2]]) ? "''" : "'" . addslashes($convert_config[$m[2]]) . "'"; $exec = '$config_value = ' . $m[1] . '(' . $var . ');'; // @codingStandardsIgnoreStart eval($exec); // @codingStandardsIgnoreEnd } else { if ($schema['table_format'] != 'file' || empty($schema['array_name'])) { $config_value = isset($convert_config[$src]) ? $convert_config[$src] : ''; } else { if (!empty($schema['array_name'])) { $src_ary = $schema['array_name']; $config_value = isset($convert_config[$src_ary][$src]) ? $convert_config[$src_ary][$src] : ''; } } } if ($config_value !== '') { // Most are... if (is_string($config_value)) { $config_value = truncate_string(utf8_htmlspecialchars($config_value), 255, 255, false); } set_config($config_name, $config_value); } } }
/** * Censor title, return short title * * @param $title string title to censor * @param $limit int short title character limit * */ function character_limit(&$title, $limit = 0) { $title = censor_text($title); if ($limit > 0) { return utf8_strlen(utf8_decode($title)) > $limit + 3 ? truncate_string($title, $limit) . '...' : $title; } else { // return the result return $title; } }
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false) { if (isset($_REQUEST["DevForceUpdate"])) { header("Content-Type: text/plain; charset=utf-8"); } $disable_cache = false; $reply = array(); $rgba_cache = array(); $timing_info = microtime(true); $topmost_article_ids = array(); if (!$offset) { $offset = 0; } if ($method == "undefined") { $method = ""; } $method_split = explode(":", $method); if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { // Update the feed if required with some basic flood control $result = $this->dbh->query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'"); if ($this->dbh->num_rows($result) != 0) { $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated")); $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images")); if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) { include "rssfuncs.php"; update_rss_feed($feed, true, true); } else { $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\n\t\t\t\t\t\t\tWHERE id = '{$feed}'"); } } } if ($method_split[0] == "MarkAllReadGR") { catchup_feed($method_split[1], false); } // FIXME: might break tag display? if (is_numeric($feed) && $feed > 0 && !$cat_view) { $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1"); if ($this->dbh->num_rows($result) == 0) { $reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>"; } } @($search = $this->dbh->escape_string($_REQUEST["query"])); if ($search) { $disable_cache = true; } @($search_mode = $this->dbh->escape_string($_REQUEST["search_mode"])); if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H0", $timing_info); } // error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]"); if ($search_mode == '' && $method != '') { $search_mode = $method; } // error_log("search_mode: " . $search_mode); if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { $handler = PluginHost::getInstance()->get_feed_handler(PluginHost::feed_to_pfeed_id($feed)); // function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) { if ($handler) { $options = array("limit" => $limit, "view_mode" => $view_mode, "cat_view" => $cat_view, "search" => $search, "search_mode" => $search_mode, "override_order" => $override_order, "offset" => $offset, "owner_uid" => $_SESSION["uid"], "filter" => false, "since_id" => 0, "include_children" => $include_children); $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $options); } } else { $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order, $offset, 0, false, 0, $include_children); } $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6; if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H1", $timing_info); } $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; $feed_site_url = $qfh_ret[2]; $last_error = $qfh_ret[3]; $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? make_local_datetime($qfh_ret[4], false) : __("Never"); $highlight_words = $qfh_ret[5]; $vgroup_last_feed = $vgr_last_feed; $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $search_mode, $view_mode, $last_error, $last_updated); $headlines_count = $this->dbh->num_rows($result); /* if (get_pref('COMBINED_DISPLAY_MODE')) { $button_plugins = array(); foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) { $pclass = "button_" . trim($p); if (class_exists($pclass)) { $plugin = new $pclass(); array_push($button_plugins, $plugin); } } } */ if ($offset == 0) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) { $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret); } } if ($this->dbh->num_rows($result) > 0) { $lnum = $offset; $num_unread = 0; $cur_feed_title = ''; if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("PS", $timing_info); } $expand_cdm = get_pref('CDM_EXPANDED'); while ($line = $this->dbh->fetch_assoc($result)) { $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 250, false); } if (get_pref('SHOW_CONTENT_PREVIEW')) { $content_preview = $line["content_preview"]; } $id = $line["id"]; $feed_id = $line["feed_id"]; $label_cache = $line["label_cache"]; $labels = false; if ($label_cache) { $label_cache = json_decode($label_cache, true); if ($label_cache) { if ($label_cache["no-labels"] == 1) { $labels = array(); } else { $labels = $label_cache; } } } if (!is_array($labels)) { $labels = get_article_labels($id); } $labels_str = "<span class=\"HLLCTR-{$id}\">"; $labels_str .= format_article_labels($labels, $id); $labels_str .= "</span>"; if (count($topmost_article_ids) < 3) { array_push($topmost_article_ids, $id); } $class = ""; if (sql_bool_to_bool($line["unread"])) { $class .= " Unread"; ++$num_unread; } if (sql_bool_to_bool($line["marked"])) { $marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_set.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>"; $class .= " marked"; } else { $marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_unset.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>"; } if (sql_bool_to_bool($line["published"])) { $published_pic = "<img src=\"images/pub_set.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\t\talt=\"Unpublish article\" onclick='togglePub({$id})'>"; $class .= " published"; } else { $published_pic = "<img src=\"images/pub_unset.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\talt=\"Publish article\" onclick='togglePub({$id})'>"; } # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" . # $line["title"] . "</a>"; # $content_link = "<a # href=\"" . htmlspecialchars($line["link"]) . "\" # onclick=\"view($id,$feed_id);\">" . # $line["title"] . "</a>"; # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" . # $line["title"] . "</a>"; $updated_fmt = make_local_datetime($line["updated"], false); $date_entered_fmt = T_sprintf("Imported at %s", make_local_datetime($line["date_entered"], false)); $score = $line["score"]; $score_pic = "images/" . get_score_pic($score); /* $score_title = __("(Click to change)"); $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\" onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */ $score_pic = "<img class='hlScorePic' score='{$score}' onclick='changeScore({$id}, this)' src=\"{$score_pic}\"\n\t\t\t\t\ttitle=\"{$score}\">"; if ($score > 500) { $hlc_suffix = "high"; } else { if ($score < -100) { $hlc_suffix = "low"; } else { $hlc_suffix = ""; } } $entry_author = $line["author"]; if ($entry_author) { $entry_author = " — {$entry_author}"; } $has_feed_icon = feed_has_icon($feed_id); if ($has_feed_icon) { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">"; } else { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">"; } $entry_site_url = $line["site_url"]; //setting feed headline background color, needs to change text color based on dark/light $fav_color = $line['favicon_avg_color']; require_once "colors.php"; if ($fav_color && $fav_color != 'fail') { if (!isset($rgba_cache[$feed_id])) { $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); } } if (!get_pref('COMBINED_DISPLAY_MODE')) { if ($vfeed_group_enabled) { if ($feed_id != $vgroup_last_feed && $line["feed_title"]) { $cur_feed_title = $line["feed_title"]; $vgroup_last_feed = $feed_id; $cur_feed_title = htmlspecialchars($cur_feed_title); $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark feed as read') . "</a>"; $reply['content'] .= "<div id='FTITLE-{$feed_id}' class='cdmFeedTitle'>" . "<div style='float : right'>{$feed_icon_img}</div>" . "<a class='title' href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>\n\t\t\t\t\t\t\t\t{$vf_catchup_link}</div>"; } } $mouseover_attrs = "onmouseover='postMouseIn(event, {$id})'\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'"; $reply['content'] .= "<div class='hl {$class}' orig-feed-id='{$feed_id}' id='RROW-{$id}' {$mouseover_attrs}>"; $reply['content'] .= "<div class='hlLeft'>"; $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\" onclick=\"toggleSelectRow2(this)\"\n\t\t\t\t\t\t\tclass='rchk'>"; $reply['content'] .= "{$marked_pic}"; $reply['content'] .= "{$published_pic}"; $reply['content'] .= "</div>"; $reply['content'] .= "<div onclick='return hlClicked(event, {$id})'\n\t\t\t\t\t\tclass=\"hlTitle\"><span class='hlContent {$hlc_suffix}'>"; $reply['content'] .= "<a id=\"RTITLE-{$id}\" class=\"title {$hlc_suffix}\"\n\t\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\"\n\t\t\t\t\t\tonclick=\"\">" . truncate_string($line["title"], 200); if (get_pref('SHOW_CONTENT_PREVIEW')) { $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>"; } $reply['content'] .= "</a></span>"; $reply['content'] .= $labels_str; $reply['content'] .= "</div>"; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba({$rgba}, 0.3)\" href=\"#\" onclick=\"viewfeed({$feed_id})\">" . truncate_string($line["feed_title"], 30) . "</a></span>"; } } $reply['content'] .= "<span class=\"hlUpdated\">"; $reply['content'] .= "<div title='{$date_entered_fmt}'>{$updated_fmt}</div>\n\t\t\t\t\t\t</span>"; $reply['content'] .= "<div class=\"hlRight\">"; $reply['content'] .= $score_pic; if ($line["feed_title"] && !$vfeed_group_enabled) { $reply['content'] .= "<span onclick=\"viewfeed({$feed_id})\"\n\t\t\t\t\t\t\tstyle=\"cursor : pointer\"\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['feed_title']) . "\">\n\t\t\t\t\t\t\t{$feed_icon_img}</span>"; } $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; } else { if ($line["tag_cache"]) { $tags = explode(",", $line["tag_cache"]); } else { $tags = false; } $line["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { $line = $p->hook_render_article_cdm($line); } if ($vfeed_group_enabled && $line["feed_title"]) { if ($feed_id != $vgroup_last_feed) { $cur_feed_title = $line["feed_title"]; $vgroup_last_feed = $feed_id; $cur_feed_title = htmlspecialchars($cur_feed_title); $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark feed as read') . "</a>"; $has_feed_icon = feed_has_icon($feed_id); if ($has_feed_icon) { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">"; } else { //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">"; } $reply['content'] .= "<div id='FTITLE-{$feed_id}' class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" class='title' onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>"; } } $mouseover_attrs = "onmouseover='postMouseIn(event, {$id})'\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'"; $expanded_class = $expand_cdm ? "expanded" : "expandable"; $reply['content'] .= "<div class=\"cdm {$hlc_suffix} {$expanded_class} {$class}\"\n\t\t\t\t\t\tid=\"RROW-{$id}\" orig-feed-id='{$feed_id}' {$mouseover_attrs}>"; $reply['content'] .= "<div class=\"cdmHeader\">"; $reply['content'] .= "<div style=\"vertical-align : middle\">"; $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"\n\t\t\t\t\t\t\tclass='rchk'>"; $reply['content'] .= "{$marked_pic}"; $reply['content'] .= "{$published_pic}"; $reply['content'] .= "</div>"; if ($highlight_words && count($highlight_words > 0)) { foreach ($highlight_words as $word) { $line["title"] = preg_replace("/(\\Q{$word}\\E)/i", "<span class=\"highlight\">\$1</span>", $line["title"]); } } $reply['content'] .= "<span id=\"RTITLE-{$id}\"\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\n\t\t\t\t\t\tclass=\"titleWrap {$hlc_suffix}\">\n\t\t\t\t\t\t<a class=\"title {$hlc_suffix}\"\n\t\t\t\t\t\ttarget=\"_blank\" href=\"" . htmlspecialchars($line["link"]) . "\">" . $line["title"] . "</a> <span class=\"author\">{$entry_author}</span>"; $reply['content'] .= $labels_str; $reply['content'] .= "<span class='collapseBtn' style='display : none'>\n\t\t\t\t\t\t<img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, {$id})\"\n\t\t\t\t\t\ttitle=\"" . __("Collapse article") . "\"/></span>"; if (!$expand_cdm) { $content_hidden = "style=\"display : none\""; } else { $excerpt_hidden = "style=\"display : none\""; } $reply['content'] .= "<span {$excerpt_hidden} id=\"CEXC-{$id}\" class=\"cdmExcerpt\">" . $content_preview . "</span>"; $reply['content'] .= "</span>"; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; $reply['content'] .= "<div class=\"hlFeed\">\n\t\t\t\t\t\t\t\t<a href=\"#\" style=\"background-color: rgba({$rgba},0.3)\"\n\t\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">" . truncate_string($line["feed_title"], 30) . "</a>\n\t\t\t\t\t\t\t</div>"; } } $reply['content'] .= "<span class='updated' title='{$date_entered_fmt}'>\n\t\t\t\t\t\t{$updated_fmt}</span>"; $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">"; $reply['content'] .= "{$score_pic}"; if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { $reply['content'] .= "<span style=\"cursor : pointer\"\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line["feed_title"]) . "\"\n\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">{$feed_icon_img}</span>"; } $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "<div class=\"cdmContent\" {$content_hidden}\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\n\t\t\t\t\t\tid=\"CICD-{$id}\">"; $reply['content'] .= "<div id=\"POSTNOTE-{$id}\">"; if ($line['note']) { $reply['content'] .= format_article_note($id, $line['note']); } $reply['content'] .= "</div>"; if (!$line['lang']) { $line['lang'] = 'en'; } $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"" . $line['lang'] . "\">"; if ($line["orig_feed_id"]) { $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]); if ($this->dbh->num_rows($tmp_result) != 0) { $reply['content'] .= "<div clear='both'>"; $reply['content'] .= __("Originally from:"); $reply['content'] .= " "; $tmp_line = $this->dbh->fetch_assoc($tmp_result); $reply['content'] .= "<a target='_blank'\n\t\t\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>"; $reply['content'] .= " "; $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>"; $reply['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_unset.png'></a>"; $reply['content'] .= "</div>"; } } $reply['content'] .= "<span id=\"CWRAP-{$id}\">"; // if (!$expand_cdm) { $reply['content'] .= "<span id=\"CENCW-{$id}\" style=\"display : none\">"; $reply['content'] .= htmlspecialchars($line["content"]); $reply['content'] .= "</span."; // } else { // $reply['content'] .= $line["content"]; // } $reply['content'] .= "</span>"; $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]); $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"])); $reply['content'] .= "</div>"; $reply['content'] .= "<div class=\"cdmFooter\">"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { $reply['content'] .= $p->hook_article_left_button($line); } $tags_str = format_tags_string($tags, $id); $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>\n\t\t\t\t\t\t<span id=\"ATSTR-{$id}\">{$tags_str}</span>\n\t\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\n\t\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id})\">(+)</a>"; $num_comments = $line["num_comments"]; $entry_comments = ""; if ($num_comments > 0) { if ($line["comments"]) { $comments_url = htmlspecialchars($line["comments"]); } else { $comments_url = htmlspecialchars($line["link"]); } $entry_comments = "<a class=\"postComments\"\n\t\t\t\t\t\t\ttarget='_blank' href=\"{$comments_url}\">{$num_comments} " . _ngettext("comment", "comments", $num_comments) . "</a>"; } else { if ($line["comments"] && $line["link"] != $line["comments"]) { $entry_comments = "<a class=\"postComments\" target='_blank' href=\"" . htmlspecialchars($line["comments"]) . "\">" . __("comments") . "</a>"; } } if ($entry_comments) { $reply['content'] .= " ({$entry_comments})"; } $reply['content'] .= "<div style=\"float : right\">"; // $reply['content'] .= "$marked_pic"; // $reply['content'] .= "$published_pic"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { $reply['content'] .= $p->hook_article_button($line); } $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; } ++$lnum; } if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("PE", $timing_info); } } else { $message = ""; switch ($view_mode) { case "unread": $message = __("No unread articles found to display."); break; case "updated": $message = __("No updated articles found to display."); break; case "marked": $message = __("No starred articles found to display."); break; default: if ($feed < LABEL_BASE_INDEX) { $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); } else { $message = __("No articles found to display."); } } if (!$offset && $message) { $reply['content'] .= "<div class='whiteBox'>{$message}"; $reply['content'] .= "<p><span class=\"insensitive\">"; $result = $this->dbh->query("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION['uid']); $last_updated = $this->dbh->fetch_result($result, 0, "last_updated"); $last_updated = make_local_datetime($last_updated, false); $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); $result = $this->dbh->query("SELECT COUNT(id) AS num_errors\n\t\t\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]); $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { $reply['content'] .= "<br/>"; $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>"; } $reply['content'] .= "</span></p></div>"; } } if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H2", $timing_info); } return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $vgroup_last_feed, $reply); }
static function api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100, $check_first_id = false) { if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { // Update the feed if required with some basic flood control $result = db_query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed_id}'"); if (db_num_rows($result) != 0) { $last_updated = strtotime(db_fetch_result($result, 0, "last_updated")); $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); if (!$cache_images && time() - $last_updated > 120) { include "rssfuncs.php"; update_rss_feed($feed_id, true, true); } else { db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\n\t\t\t\t\t\t\tWHERE id = '{$feed_id}'"); } } } /*$qfh_ret = queryFeedHeadlines($feed_id, $limit, $view_mode, $is_cat, $search, false, $order, $offset, 0, false, $since_id, $include_nested);*/ //function queryFeedHeadlines($feed, $limit, // $view_mode, $cat_view, $search, $search_mode, // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) { $params = array("feed" => $feed_id, "limit" => $limit, "view_mode" => $view_mode, "cat_view" => $is_cat, "search" => $search, "override_order" => $order, "offset" => $offset, "since_id" => $since_id, "include_children" => $include_nested, "check_first_id" => $check_first_id, "api_request" => true); $qfh_ret = queryFeedHeadlines($params); $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; $first_id = $qfh_ret[6]; $headlines = array(); $headlines_header = array('id' => $feed_id, 'first_id' => $first_id, 'is_cat' => $is_cat); if (!is_numeric($result)) { while ($line = db_fetch_assoc($result)) { $line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, $excerpt_length, true); } $is_updated = $line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1"); $tags = explode(",", $line["tag_cache"]); $label_cache = $line["label_cache"]; $labels = false; if ($label_cache) { $label_cache = json_decode($label_cache, true); if ($label_cache) { if ($label_cache["no-labels"] == 1) { $labels = array(); } else { $labels = $label_cache; } } } if (!is_array($labels)) { $labels = get_article_labels($line["id"]); } //if (!$tags) $tags = get_article_tags($line["id"]); //if (!$labels) $labels = get_article_labels($line["id"]); $headline_row = array("id" => (int) $line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "updated" => (int) strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], "tags" => $tags); if ($include_attachments) { $headline_row['attachments'] = get_article_enclosures($line['id']); } if ($show_excerpt) { $headline_row["excerpt"] = $line["content_preview"]; } if ($show_content) { if ($sanitize_content) { $headline_row["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]); } else { $headline_row["content"] = $line["content"]; } } // unify label output to ease parsing if ($labels["no-labels"] == 1) { $labels = array(); } $headline_row["labels"] = $labels; $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title; $headline_row["comments_count"] = (int) $line["num_comments"]; $headline_row["comments_link"] = $line["comments"]; $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]); $headline_row["author"] = $line["author"]; $headline_row["score"] = (int) $line["score"]; $headline_row["note"] = $line["note"]; $headline_row["lang"] = $line["lang"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); } array_push($headlines, $headline_row); } } else { if (is_numeric($result) && $result == -1) { $headlines_header['first_id_changed'] = true; } } return array($headlines, $headlines_header); }
/** * Transfers the relevant configuration information from the source forum * The mapping of fields is specified in $config_schema, see convert_phpbb20.php for more details */ function restore_config($schema) { global $db, $config; $convert_config = get_config(); foreach ($schema['settings'] as $config_name => $src) { if (preg_match('/(.*)\\((.*)\\)/', $src, $m)) { $var = empty($m[2]) || empty($convert_config[$m[2]]) ? "''" : "'" . addslashes($convert_config[$m[2]]) . "'"; $exec = '$config_value = ' . $m[1] . '(' . $var . ');'; eval($exec); } else { $config_value = isset($convert_config[$src]) ? $convert_config[$src] : ''; } if ($config_value !== '') { // Most are... if (is_string($config_value)) { $config_value = truncate_string(utf8_htmlspecialchars($config_value), 255, 255, false); } set_config($config_name, $config_value); } } }
function format_tags_string($tags, $id) { $tags_str = ""; $tags_nolinks_str = ""; $num_tags = 0; $tag_limit = 6; $formatted_tags = array(); foreach ($tags as $tag) { $num_tags++; $tag_escaped = str_replace("'", "\\'", $tag); if (mb_strlen($tag) > 30) { $tag = truncate_string($tag, 30); } $tag_str = "<a href=\"javascript:viewfeed('{$tag_escaped}')\">{$tag}</a>"; array_push($formatted_tags, $tag_str); $tmp_tags_str = implode(", ", $formatted_tags); if ($num_tags == $tag_limit || mb_strlen($tmp_tags_str) > 150) { break; } } $tags_str = implode(", ", $formatted_tags); if ($num_tags < count($tags)) { $tags_str .= ", …"; } if ($num_tags == 0) { $tags_str = __("no tags"); } return $tags_str; }
/** * Options to pick a timezone and date/time * * @param \phpbb\template\template $template phpBB template object * @param \phpbb\user $user Object of the current user * @param string $default A timezone to select * @param boolean $truncate Shall we truncate the options text * * @return array Returns an array containing the options for the time selector. */ function phpbb_timezone_select($template, $user, $default = '', $truncate = false) { static $timezones; $default_offset = ''; if (!isset($timezones)) { $unsorted_timezones = phpbb_get_timezone_identifiers($default); $timezones = array(); foreach ($unsorted_timezones as $timezone) { $tz = new DateTimeZone($timezone); $dt = $user->create_datetime('now', $tz); $offset = $dt->getOffset(); $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true); $offset_string = phpbb_format_timezone_offset($offset, true); $timezones['UTC' . $offset_string . ' - ' . $timezone] = array('tz' => $timezone, 'offset' => $offset_string, 'current' => $current_time); if ($timezone === $default) { $default_offset = 'UTC' . $offset_string; } } unset($unsorted_timezones); uksort($timezones, 'phpbb_tz_select_compare'); } $tz_select = $opt_group = ''; foreach ($timezones as $key => $timezone) { if ($opt_group != $timezone['offset']) { // Generate tz_select for backwards compatibility $tz_select .= $opt_group ? '</optgroup>' : ''; $tz_select .= '<optgroup label="' . $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']) . '">'; $opt_group = $timezone['offset']; $template->assign_block_vars('timezone_select', array('LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), 'VALUE' => $key . ' - ' . $timezone['current'])); $selected = !empty($default_offset) && strpos($key, $default_offset) !== false ? ' selected="selected"' : ''; $template->assign_block_vars('timezone_date', array('VALUE' => $key . ' - ' . $timezone['current'], 'SELECTED' => !empty($selected), 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']))); } $label = $timezone['tz']; if (isset($user->lang['timezones'][$label])) { $label = $user->lang['timezones'][$label]; } $title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label); if ($truncate) { $label = truncate_string($label, 50, 255, false, '...'); } // Also generate timezone_select for backwards compatibility $selected = $timezone['tz'] === $default ? ' selected="selected"' : ''; $tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>'; $template->assign_block_vars('timezone_select.timezone_options', array('TITLE' => $title, 'VALUE' => $timezone['tz'], 'SELECTED' => !empty($selected), 'LABEL' => $label)); } $tz_select .= '</optgroup>'; return $tz_select; }
/** * Submit Post * @todo Split up and create lightweight, simple API for this. */ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path; // We do not handle erasing posts here if ($mode == 'delete') { return false; } $current_time = time(); if ($mode == 'post') { $post_mode = 'post'; $update_message = true; } else { if ($mode != 'edit') { $post_mode = 'reply'; $update_message = true; } else { if ($mode == 'edit') { $post_mode = $data['topic_replies_real'] == 0 ? 'edit_topic' : ($data['topic_first_post_id'] == $data['post_id'] ? 'edit_first_post' : ($data['topic_last_post_id'] == $data['post_id'] ? 'edit_last_post' : 'edit')); } } } // First of all make sure the subject and topic title are having the correct length. // To achieve this without cutting off between special chars we convert to an array and then count the elements. $subject = truncate_string($subject); $data['topic_title'] = truncate_string($data['topic_title']); // Collect some basic information about which tables and which rows to update/insert $sql_data = $topic_row = array(); $poster_id = $mode == 'edit' ? $data['poster_id'] : (int) $user->data['user_id']; // Retrieve some additional information if not present if ($mode == 'edit' && (!isset($data['post_approved']) || !isset($data['topic_approved']) || $data['post_approved'] === false || $data['topic_approved'] === false)) { $sql = 'SELECT p.post_approved, t.topic_type, t.topic_replies, t.topic_replies_real, t.topic_approved FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id = p.topic_id AND p.post_id = ' . $data['post_id']; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $data['topic_approved'] = $topic_row['topic_approved']; $data['post_approved'] = $topic_row['post_approved']; } // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval // The variable name should be $post_approved, because it indicates if the post is approved or not $post_approval = 1; // Check the permissions for post approval. Moderators are not affected. if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) { // Post not approved, but in queue $post_approval = 0; } // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved if (isset($data['force_approved_state'])) { $post_approval = $data['force_approved_state'] ? 1 : 0; } // Start the transaction here $db->sql_transaction('begin'); // Collect Information switch ($post_mode) { case 'post': case 'reply': $sql_data[POSTS_TABLE]['sql'] = array('forum_id' => $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], 'poster_id' => (int) $user->data['user_id'], 'icon_id' => $data['icon_id'], 'poster_ip' => $user->ip, 'post_time' => $current_time, 'post_approved' => $post_approval, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'post_username' => !$user->data['is_registered'] ? $username : '', 'post_subject' => $subject, 'post_text' => $data['message'], 'post_checksum' => $data['message_md5'], 'post_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'post_postcount' => $auth->acl_get('f_postcount', $data['forum_id']) ? 1 : 0, 'post_edit_locked' => $data['post_edit_locked']); break; case 'edit_first_post': case 'edit': case 'edit_last_post': case 'edit_topic': // If edit reason is given always display edit info // If editing last post then display no edit info // If m_edit permission then display no edit info // If normal edit display edit info // Display edit info if edit reason given or user is editing his post, which is not the last within the topic. if ($data['post_edit_reason'] || !$auth->acl_get('m_edit', $data['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post')) { $data['post_edit_reason'] = truncate_string($data['post_edit_reason'], 255, 255, false); $sql_data[POSTS_TABLE]['sql'] = array('post_edit_time' => $current_time, 'post_edit_reason' => $data['post_edit_reason'], 'post_edit_user' => (int) $data['post_edit_user']); $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; } else { if (!$data['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data['forum_id'])) { $sql_data[POSTS_TABLE]['sql'] = array('post_edit_reason' => ''); } } // If the person editing this post is different to the one having posted then we will add a log entry stating the edit // Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods if ($user->data['user_id'] != $poster_id) { $log_subject = $subject ? $subject : $data['topic_title']; add_log('mod', $data['forum_id'], $data['topic_id'], 'LOG_POST_EDITED', $log_subject, !empty($username) ? $username : $user->lang['GUEST']); } if (!isset($sql_data[POSTS_TABLE]['sql'])) { $sql_data[POSTS_TABLE]['sql'] = array(); } $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('forum_id' => $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], 'poster_id' => $data['poster_id'], 'icon_id' => $data['icon_id'], 'post_approved' => !$post_approval ? 0 : $data['post_approved'], 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], 'enable_sig' => $data['enable_sig'], 'post_username' => $username && $data['poster_id'] == ANONYMOUS ? $username : '', 'post_subject' => $subject, 'post_checksum' => $data['message_md5'], 'post_attachment' => !empty($data['attachment_data']) ? 1 : 0, 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'post_edit_locked' => $data['post_edit_locked'])); if ($update_message) { $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message']; } break; } $post_approved = $sql_data[POSTS_TABLE]['sql']['post_approved']; $topic_row = array(); // And the topic ladies and gentlemen switch ($post_mode) { case 'post': $sql_data[TOPICS_TABLE]['sql'] = array('topic_poster' => (int) $user->data['user_id'], 'topic_time' => $current_time, 'topic_last_view_time' => $current_time, 'forum_id' => $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => $post_approval, 'topic_title' => $subject, 'topic_first_poster_name' => !$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : ''), 'topic_first_poster_colour' => $user->data['user_colour'], 'topic_type' => $topic_type, 'topic_time_limit' => $topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE ? $data['topic_time_limit'] * 86400 : 0, 'topic_attachment' => !empty($data['attachment_data']) ? 1 : 0); if (isset($poll['poll_options']) && !empty($poll['poll_options'])) { $poll_start = $poll['poll_start'] ? $poll['poll_start'] : $current_time; $poll_length = $poll['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; if ($poll_start < 0) { $poll_start = 0; } $poll_length = 1; } $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array('poll_title' => $poll['poll_title'], 'poll_start' => $poll_start, 'poll_max_options' => $poll['poll_max_options'], 'poll_length' => $poll_length, 'poll_vote_change' => $poll['poll_vote_change'])); } $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = {$current_time}" . ($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval ? ', user_posts = user_posts + 1' : ''); if ($topic_type != POST_GLOBAL) { if ($post_approval) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . ($post_approval ? ', forum_topics = forum_topics + 1' : ''); } break; case 'reply': $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . ($post_approval ? ', topic_replies = topic_replies + 1' : '') . (!empty($data['attachment_data']) || isset($data['topic_attachment']) && $data['topic_attachment'] ? ', topic_attachment = 1' : ''); $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = {$current_time}" . ($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval ? ', user_posts = user_posts + 1' : ''); if ($post_approval && $topic_type != POST_GLOBAL) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } break; case 'edit_topic': case 'edit_first_post': if (isset($poll['poll_options'])) { $poll_start = $poll['poll_start'] || empty($poll['poll_options']) ? $poll['poll_start'] : $current_time; $poll_length = $poll['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; if ($poll_start < 0) { $poll_start = 0; } $poll_length = 1; } } $sql_data[TOPICS_TABLE]['sql'] = array('forum_id' => $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => !$post_approval ? 0 : $data['topic_approved'], 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, 'topic_time_limit' => $topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE ? $data['topic_time_limit'] * 86400 : 0, 'poll_title' => isset($poll['poll_options']) ? $poll['poll_title'] : '', 'poll_start' => isset($poll['poll_options']) ? $poll_start : 0, 'poll_max_options' => isset($poll['poll_options']) ? $poll['poll_max_options'] : 1, 'poll_length' => isset($poll['poll_options']) ? $poll_length : 0, 'poll_vote_change' => isset($poll['poll_vote_change']) ? $poll['poll_vote_change'] : 0, 'topic_last_view_time' => $current_time, 'topic_attachment' => !empty($data['attachment_data']) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0)); // Correctly set back the topic replies and forum posts... only if the topic was approved before and now gets disapproved if (!$post_approval && $data['topic_approved']) { // Do we need to grab some topic informations? if (!sizeof($topic_row)) { $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $data['topic_id']; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); } // If this is the only post remaining we do not need to decrement topic_replies. // Also do not decrement if first post - then the topic_replies will not be adjusted if approving the topic again. // If this is an edited topic or the first post the topic gets completely disapproved later on... $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics = forum_topics - 1'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1); set_config_count('num_topics', -1, true); set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * -1, true); // Only decrement this post, since this is the one non-approved now if ($auth->acl_get('f_postcount', $data['forum_id'])) { $sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1'; } } break; case 'edit': case 'edit_last_post': // Correctly set back the topic replies and forum posts... but only if the post was approved before. if (!$post_approval && $data['post_approved']) { $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1'; set_config_count('num_posts', -1, true); if ($auth->acl_get('f_postcount', $data['forum_id'])) { $sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1'; } } break; } // Submit new topic if ($post_mode == 'post') { $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); $db->sql_query($sql); $data['topic_id'] = $db->sql_nextid(); $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id'])); unset($sql_data[TOPICS_TABLE]['sql']); } // Submit new post if ($post_mode == 'post' || $post_mode == 'reply') { if ($post_mode == 'reply') { $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id'])); } $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); $db->sql_query($sql); $data['post_id'] = $db->sql_nextid(); if ($post_mode == 'post') { $sql_data[TOPICS_TABLE]['sql'] = array('topic_first_post_id' => $data['post_id'], 'topic_last_post_id' => $data['post_id'], 'topic_last_post_time' => $current_time, 'topic_last_poster_id' => (int) $user->data['user_id'], 'topic_last_poster_name' => !$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : ''), 'topic_last_poster_colour' => $user->data['user_colour'], 'topic_last_post_subject' => (string) $subject); } unset($sql_data[POSTS_TABLE]['sql']); } $make_global = false; // Are we globalising or unglobalising? if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic') { if (!sizeof($topic_row)) { $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $data['topic_id']; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); } // globalise/unglobalise? if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL || $topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) { if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat'])) { $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']); } $make_global = true; $sql_data[FORUMS_TABLE]['stat'] = array(); } // globalise if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) { // Decrement topic/post count $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies_real'] + 1); $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . ($topic_row['topic_approved'] ? ', forum_topics = forum_topics - 1' : ''); // Update forum_ids for all posts $sql = 'UPDATE ' . POSTS_TABLE . ' SET forum_id = 0 WHERE topic_id = ' . $data['topic_id']; $db->sql_query($sql); } else { if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) { // Increment topic/post count $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($topic_row['topic_replies_real'] + 1); $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . ($topic_row['topic_approved'] ? ', forum_topics = forum_topics + 1' : ''); // Update forum_ids for all posts $sql = 'UPDATE ' . POSTS_TABLE . ' SET forum_id = ' . $data['forum_id'] . ' WHERE topic_id = ' . $data['topic_id']; $db->sql_query($sql); } } } // Update the topics table if (isset($sql_data[TOPICS_TABLE]['sql'])) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' WHERE topic_id = ' . $data['topic_id']; $db->sql_query($sql); } // Update the posts table if (isset($sql_data[POSTS_TABLE]['sql'])) { $sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' WHERE post_id = ' . $data['post_id']; $db->sql_query($sql); } // Update Poll Tables if (isset($poll['poll_options'])) { $cur_poll_options = array(); if ($mode == 'edit') { $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id = ' . $data['topic_id'] . ' ORDER BY poll_option_id'; $result = $db->sql_query($sql); $cur_poll_options = array(); while ($row = $db->sql_fetchrow($result)) { $cur_poll_options[] = $row; } $db->sql_freeresult($result); } $sql_insert_ary = array(); for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++) { if (strlen(trim($poll['poll_options'][$i]))) { if (empty($cur_poll_options[$i])) { // If we add options we need to put them to the end to be able to preserve votes... $sql_insert_ary[] = array('poll_option_id' => (int) sizeof($cur_poll_options) + 1 + sizeof($sql_insert_ary), 'topic_id' => (int) $data['topic_id'], 'poll_option_text' => (string) $poll['poll_options'][$i]); } else { if ($poll['poll_options'][$i] != $cur_poll_options[$i]) { $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . "\n\t\t\t\t\t\tSET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "'\n\t\t\t\t\t\tWHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } } } } $db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) { $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' WHERE poll_option_id > ' . sizeof($poll['poll_options']) . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option if ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options)) { $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data['topic_id']); $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data['topic_id']); } } // Submit Attachments if (!empty($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) { $space_taken = $files_added = 0; $orphan_rows = array(); foreach ($data['attachment_data'] as $pos => $attach_row) { $orphan_rows[(int) $attach_row['attach_id']] = array(); } if (sizeof($orphan_rows)) { $sql = 'SELECT attach_id, filesize, physical_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $orphan_rows = array(); while ($row = $db->sql_fetchrow($result)) { $orphan_rows[$row['attach_id']] = $row; } $db->sql_freeresult($result); } foreach ($data['attachment_data'] as $pos => $attach_row) { if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) { continue; } if (!$attach_row['is_orphan']) { // update entry in db if attachment already stored in db and filespace $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tSET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . ' AND is_orphan = 0'; $db->sql_query($sql); } else { // insert attachment into db if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) { continue; } $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; $files_added++; $attach_sql = array('post_msg_id' => $data['post_id'], 'topic_id' => $data['topic_id'], 'is_orphan' => 0, 'poster_id' => $poster_id, 'attach_comment' => $attach_row['attach_comment']); $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . $attach_row['attach_id'] . ' AND is_orphan = 1 AND poster_id = ' . $user->data['user_id']; $db->sql_query($sql); } } if ($space_taken && $files_added) { set_config_count('upload_dir_size', $space_taken, true); set_config_count('num_files', $files_added, true); } } // we need to update the last forum information // only applicable if the topic is not global and it is approved // we also check to make sure we are not dealing with globaling the latest topic (pretty rare but still needs to be checked) if ($topic_type != POST_GLOBAL && !$make_global && ($post_approved || !$data['post_approved'])) { // the last post makes us update the forum table. This can happen if... // We make a new topic // We reply to a topic // We edit the last post in a topic and this post is the latest in the forum (maybe) // We edit the only post in the topic // We edit the first post in the topic and all the other posts are not approved if (($post_mode == 'post' || $post_mode == 'reply') && $post_approved) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(!$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : '')) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'"; } else { if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $post_mode == 'edit_first_post' && !$data['topic_replies']) { // this does not _necessarily_ mean that we must update the info again, // it just means that we might have to $sql = 'SELECT forum_last_post_id, forum_last_post_subject FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // this post is the latest post in the forum, better update if ($row['forum_last_post_id'] == $data['post_id']) { // If post approved and subject changed, or poster is anonymous, we need to update the forum_last* rows if ($post_approved && ($row['forum_last_post_subject'] !== $subject || $data['poster_id'] == ANONYMOUS)) { // the post's subject changed if ($row['forum_last_post_subject'] !== $subject) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_subject = \'' . $db->sql_escape($subject) . '\''; } // Update the user name if poster is anonymous... just in case an admin changed it if ($data['poster_id'] == ANONYMOUS) { $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; } } else { if ($data['post_approved'] !== $post_approved) { // we need a fresh change of socks, everything has become invalidated $sql = 'SELECT MAX(topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id'] . ' AND topic_approved = 1'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // any posts left in this forum? if (!empty($row['last_post_id'])) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . (int) $row['last_post_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // salvation, a post is found! jam it into the forums table $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; } else { // just our luck, the last topic in the forum has just been turned unapproved... $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = 0'; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = ''"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = 0'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = 0'; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = ''"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''"; } } } } } } } else { if ($make_global) { // somebody decided to be a party pooper, we must recalculate the whole shebang (maybe) $sql = 'SELECT forum_last_post_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id']; $result = $db->sql_query($sql); $forum_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // we made a topic global, go get new data if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id']) { // we need a fresh change of socks, everything has become invalidated $sql = 'SELECT MAX(topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id'] . ' AND topic_approved = 1'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // any posts left in this forum? if (!empty($row['last_post_id'])) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . (int) $row['last_post_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // salvation, a post is found! jam it into the forums table $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; } else { // just our luck, the last topic in the forum has just been globalized... $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = 0'; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = ''"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = 0'; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = 0'; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = ''"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''"; } } else { if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL && $forum_row['forum_last_post_id'] < $topic_row['topic_last_post_id']) { // this post has a higher id, it is newer $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . (int) $topic_row['topic_last_post_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // salvation, a post is found! jam it into the forums table $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; } } } } // topic sync time! // simply, we update if it is a reply or the last post is edited if ($post_approved) { // reply requires the whole thing if ($post_mode == 'reply') { $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $data['post_id']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) $user->data['user_id']; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape(!$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : '')) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . ($user->data['user_id'] != ANONYMOUS ? $db->sql_escape($user->data['user_colour']) : '') . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $current_time; } else { if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $post_mode == 'edit_first_post' && !$data['topic_replies']) { // only the subject can be changed from edit $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; // Maybe not only the subject, but also changing anonymous usernames. ;) if ($data['poster_id'] == ANONYMOUS) { $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; } } } } else { if (!$data['post_approved'] && ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $post_mode == 'edit_first_post' && !$data['topic_replies'])) { // like having the rug pulled from under us $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . (int) $data['topic_id'] . ' AND post_approved = 1'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // any posts left in this forum? if (!empty($row['last_post_id'])) { $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . (int) $row['last_post_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // salvation, a post is found! jam it into the topics table $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $row['post_id']; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $row['post_time']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) $row['poster_id']; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; } } } // Update total post count, do not consider moderated posts/topics if ($post_approval) { if ($post_mode == 'post') { set_config_count('num_topics', 1, true); set_config_count('num_posts', 1, true); } if ($post_mode == 'reply') { set_config_count('num_posts', 1, true); } } // Update forum stats $where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $poster_id); foreach ($sql_data as $table => $update_ary) { if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) { $sql = "UPDATE {$table} SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]; $db->sql_query($sql); } } // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement if ($make_global) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = ' . $data['topic_id']; $db->sql_query($sql); } // Committing the transaction before updating search index $db->sql_transaction('commit'); // Delete draft if post was loaded... $draft_id = request_var('draft_loaded', 0); if ($draft_id) { $sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND user_id = {$user->data['user_id']}"; $db->sql_query($sql); } // Index message contents if ($update_search_index && $data['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised $search_type = basename($config['search_type']); if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } if (!class_exists($search_type)) { include "{$phpbb_root_path}includes/search/{$search_type}.{$phpEx}"; } $error = false; $search = new $search_type($error); if ($error) { trigger_error($error); } $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $topic_type == POST_GLOBAL ? 0 : $data['forum_id']); } // Topic Notification, do not change if moderator is changing other users posts... if ($user->data['user_id'] == $poster_id) { if (!$data['notify_set'] && $data['notify']) { $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')'; $db->sql_query($sql); } else { if (($config['email_enable'] || $config['jab_enable']) && $data['notify_set'] && !$data['notify']) { $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND topic_id = ' . $data['topic_id']; $db->sql_query($sql); } } } if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') { // Mark this topic as posted to markread('post', $data['forum_id'], $data['topic_id']); } // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) markread('topic', $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], $data['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) { $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND forum_id = ' . ($topic_type == POST_GLOBAL ? 0 : $data['forum_id']); $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { $f_mark_time = false; } } if ($config['load_db_lastread'] && $user->data['is_registered'] || $config['load_anon_lastread'] || $user->data['is_registered']) { // Update forum info if ($topic_type == POST_GLOBAL) { $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time FROM ' . TOPICS_TABLE . ' WHERE forum_id = 0'; } else { $sql = 'SELECT forum_last_post_time FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $data['forum_id']; } $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); update_forum_tracking_info($topic_type == POST_GLOBAL ? 0 : $data['forum_id'], $forum_last_post_time, $f_mark_time, false); } // Send Notifications if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']); } $params = $add_anchor = ''; if ($post_approval) { $params .= '&t=' . $data['topic_id']; if ($mode != 'post') { $params .= '&p=' . $data['post_id']; $add_anchor = '#p' . $data['post_id']; } } else { if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') { $params .= '&t=' . $data['topic_id']; } } $url = !$params ? "{$phpbb_root_path}viewforum.{$phpEx}" : "{$phpbb_root_path}viewtopic.{$phpEx}"; $url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; return $url; }
public function sgp_checksize($txt, $len) { if (strlen($txt) > $len) { $txt = truncate_string($txt, $len); $txt .= '...'; } return $txt; }
echo getNumAlbums() . ' ' . gettext("subalbums"); } ?> <?php echo $divider; ?> <?php if (getNumImages() > 0) { echo getNumImages() . ' ' . gettext("images"); } ?> </li> </ul> </div> <p class="albumdesc"><?php echo strip_tags(truncate_string(getAlbumDesc(), 80, '...')); ?> </p> <hr /> </div> <?php $c++; if ($c == 3) { echo '<br class="clear" />'; $c = 0; } } ?> <?php } ?>
/** * Adds a new category * * @param string $category_name Name of the category to be added * @return bool True if the category was added successfully */ public function add_category_teampage($category_name) { if ($category_name === '') { return false; } $num_entries = $this->get_group_count(); $sql_ary = array('group_id' => 0, 'teampage_position' => $num_entries + 1, 'teampage_parent' => 0, 'teampage_name' => truncate_string($category_name, 255, 255)); $sql = 'INSERT INTO ' . TEAMPAGE_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $this->cache->destroy('sql', TEAMPAGE_TABLE); return true; }
/** * Pick a timezone */ function tz_select($default = '', $truncate = false) { global $user; $tz_select = ''; foreach ($user->lang['tz_zones'] as $offset => $zone) { if ($truncate) { $zone_trunc = truncate_string($zone, 50, 255, false, '...'); } else { $zone_trunc = $zone; } if (is_numeric($offset)) { $selected = $offset == $default ? ' selected="selected"' : ''; $tz_select .= '<option title="' . $zone . '" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>'; } } return $tz_select; }
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false) { $disable_cache = false; $reply = array(); $timing_info = getmicrotime(); $topmost_article_ids = array(); if (!$offset) { $offset = 0; } if ($method == "undefined") { $method = ""; } $method_split = explode(":", $method); if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) { include "rssfuncs.php"; update_rss_feed($this->link, $feed, true); } if ($method_split[0] == "MarkAllReadGR") { catchup_feed($this->link, $method_split[1], false); } // FIXME: might break tag display? if (is_numeric($feed) && $feed > 0 && !$cat_view) { $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1"); if (db_num_rows($result) == 0) { $reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>"; } } if (is_numeric($feed) && $feed > 0) { $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]); if (db_num_rows($result) == 1) { $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); } else { $rtl_content = false; } if ($rtl_content) { $rtl_tag = "dir=\"RTL\""; } else { $rtl_tag = ""; } } else { $rtl_tag = ""; $rtl_content = false; } @($search = db_escape_string($_REQUEST["query"])); if ($search) { $disable_cache = true; } @($search_mode = db_escape_string($_REQUEST["search_mode"])); @($match_on = db_escape_string($_REQUEST["match_on"])); if (!$match_on) { $match_on = "both"; } if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H0", $timing_info); } // error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]"); if ($search_mode == '' && $method != '') { $search_mode = $method; } // error_log("search_mode: " . $search_mode); $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order, $offset, 0, false, 0, $include_children); if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H1", $timing_info); } $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; $feed_site_url = $qfh_ret[2]; $last_error = $qfh_ret[3]; $vgroup_last_feed = $vgr_last_feed; // if (!$offset) { if (db_num_rows($result) > 0) { $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $match_on, $search_mode, $view_mode, $last_error); } // } $headlines_count = db_num_rows($result); if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) { $button_plugins = array(); foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) { $pclass = trim("button_{$p}"); if (class_exists($pclass)) { $plugin = new $pclass($link); array_push($button_plugins, $plugin); } } } if (db_num_rows($result) > 0) { $lnum = $offset; $num_unread = 0; $cur_feed_title = ''; $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60; if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("PS", $timing_info); } while ($line = db_fetch_assoc($result)) { $class = $lnum % 2 ? "even" : "odd"; $id = $line["id"]; $feed_id = $line["feed_id"]; $label_cache = $line["label_cache"]; $labels = false; if ($label_cache) { $label_cache = json_decode($label_cache, true); if ($label_cache) { if ($label_cache["no-labels"] == 1) { $labels = array(); } else { $labels = $label_cache; } } } if (!is_array($labels)) { $labels = get_article_labels($this->link, $id); } $labels_str = "<span id=\"HLLCTR-{$id}\">"; $labels_str .= format_article_labels($labels, $id); $labels_str .= "</span>"; if (count($topmost_article_ids) < 3) { array_push($topmost_article_ids, $id); } if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) { $update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/updated.png') . "\"\r\n\t\t\t\t\t\talt=\"Updated\">"; } else { $update_pic = "<img id='FUPDPIC-{$id}' src=\"images/blank_icon.gif\"\r\n\t\t\t\t\t\talt=\"Updated\">"; } if (sql_bool_to_bool($line["unread"]) && time() - strtotime($line["updated_noms"]) < $fresh_intl) { $update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/fresh_sign.png') . "\" alt=\"Fresh\">"; } if ($line["unread"] == "t" || $line["unread"] == "1") { $class .= " Unread"; ++$num_unread; $is_unread = true; } else { $is_unread = false; } if ($line["marked"] == "t" || $line["marked"] == "1") { $marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>"; } else { $marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>"; } if ($line["published"] == "t" || $line["published"] == "1") { $published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Unpublish article\" onclick='javascript:togglePub({$id})'>"; } else { $published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Publish article\" onclick='javascript:togglePub({$id})'>"; } # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" . # $line["title"] . "</a>"; # $content_link = "<a # href=\"" . htmlspecialchars($line["link"]) . "\" # onclick=\"view($id,$feed_id);\">" . # $line["title"] . "</a>"; # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" . # $line["title"] . "</a>"; $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false); if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) { $content_preview = truncate_string(strip_tags($line["content_preview"]), 100); } $score = $line["score"]; $score_pic = theme_image($this->link, "images/" . get_score_pic($score)); /* $score_title = __("(Click to change)"); $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\" onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */ $score_pic = "<img class='hlScorePic' src=\"{$score_pic}\"\r\n\t\t\t\t\ttitle=\"{$score}\">"; if ($score > 500) { $hlc_suffix = "H"; } else { if ($score < -100) { $hlc_suffix = "L"; } else { $hlc_suffix = ""; } } $entry_author = $line["author"]; if ($entry_author) { $entry_author = " - {$entry_author}"; } $has_feed_icon = feed_has_icon($feed_id); if ($has_feed_icon) { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">"; } else { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">"; } if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) { if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) { if ($feed_id != $vgroup_last_feed && $line["feed_title"]) { $cur_feed_title = $line["feed_title"]; $vgroup_last_feed = $feed_id; $cur_feed_title = htmlspecialchars($cur_feed_title); $vf_catchup_link = "(<a onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark as read') . "</a>)"; $reply['content'] .= "<div class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>"; } } $mouseover_attrs = "onmouseover='postMouseIn({$id})'\r\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'"; $reply['content'] .= "<div class='{$class}' id='RROW-{$id}' {$mouseover_attrs}>"; $reply['content'] .= "<div class='hlUpdPic'>{$update_pic}</div>"; $reply['content'] .= "<div class='hlLeft'>"; $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"\r\n\t\t\t\t\t\t\tid=\"RCHK-{$id}\">"; $reply['content'] .= "{$marked_pic}"; $reply['content'] .= "{$published_pic}"; $reply['content'] .= "</div>"; $reply['content'] .= "<div onclick='return hlClicked(event, {$id})'\r\n\t\t\t\t\t\tclass=\"hlTitle\"><span class='hlContent{$hlc_suffix}'>"; $reply['content'] .= "<a id=\"RTITLE-{$id}\"\r\n\t\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\"\r\n\t\t\t\t\t\tonclick=\"\">" . truncate_string($line["title"], 200); if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) { if ($content_preview) { $reply['content'] .= "<span class=\"contentPreview\"> - {$content_preview}</span>"; } } $reply['content'] .= "</a></span>"; $reply['content'] .= $labels_str; if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') && defined('_SHOW_FEED_TITLE_IN_VFEEDS')) { if (@$line["feed_title"]) { $reply['content'] .= "<span class=\"hlFeed\">\r\n\t\t\t\t\t\t\t\t(<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>)\r\n\t\t\t\t\t\t\t</span>"; } } $reply['content'] .= "</div>"; $reply['content'] .= "<span class=\"hlUpdated\">{$updated_fmt}</span>"; $reply['content'] .= "<div class=\"hlRight\">"; $reply['content'] .= $score_pic; if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) { $reply['content'] .= "<span onclick=\"viewfeed({$feed_id})\"\r\n\t\t\t\t\t\t\tstyle=\"cursor : pointer\"\r\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['feed_title']) . "\">\r\n\t\t\t\t\t\t\t{$feed_icon_img}<span>"; } $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; } else { if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) { if ($feed_id != $vgroup_last_feed) { $cur_feed_title = $line["feed_title"]; $vgroup_last_feed = $feed_id; $cur_feed_title = htmlspecialchars($cur_feed_title); $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup({$feed_id});' href='#'>" . __('mark as read') . "</a>)"; $has_feed_icon = feed_has_icon($feed_id); if ($has_feed_icon) { $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">"; } else { //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">"; } $reply['content'] .= "<div class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>"; } } $expand_cdm = get_pref($this->link, 'CDM_EXPANDED'); $mouseover_attrs = "onmouseover='postMouseIn({$id})'\r\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'"; $reply['content'] .= "<div class=\"{$class}\"\r\n\t\t\t\t\t\tid=\"RROW-{$id}\" {$mouseover_attrs}'>"; $reply['content'] .= "<div class=\"cdmHeader\">"; $reply['content'] .= "<div>"; $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,\r\n\t\t\t\t\t\t\t'RROW-{$id}')\" id=\"RCHK-{$id}\"/>"; $reply['content'] .= "{$marked_pic}"; $reply['content'] .= "{$published_pic}"; $reply['content'] .= "</div>"; $reply['content'] .= "<div id=\"PTITLE-FULL-{$id}\" style=\"display : none\">" . strip_tags($line['title']) . "</div>"; $reply['content'] .= "<span id=\"RTITLE-{$id}\"\r\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\r\n\t\t\t\t\t\tclass=\"titleWrap{$hlc_suffix}\">\r\n\t\t\t\t\t\t<a class=\"title\"\r\n\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['title']) . "\"\r\n\t\t\t\t\t\ttarget=\"_blank\" href=\"" . htmlspecialchars($line["link"]) . "\">" . truncate_string($line["title"], 100) . " {$entry_author}</a>"; $reply['content'] .= $labels_str; if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') && defined('_SHOW_FEED_TITLE_IN_VFEEDS')) { if (@$line["feed_title"]) { $reply['content'] .= "<span class=\"hlFeed\">\r\n\t\t\t\t\t\t\t\t(<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>)\r\n\t\t\t\t\t\t\t</span>"; } } if (!$expand_cdm) { $content_hidden = "style=\"display : none\""; } else { $excerpt_hidden = "style=\"display : none\""; } $reply['content'] .= "<span {$excerpt_hidden}\r\n\t\t\t\t\t\tid=\"CEXC-{$id}\" class=\"cdmExcerpt\"> - {$content_preview}</span>"; $reply['content'] .= "</span>"; $reply['content'] .= "<div>"; $reply['content'] .= "<span class='updated'>{$updated_fmt}</span>"; $reply['content'] .= "{$score_pic}"; if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) { $reply['content'] .= "<span style=\"cursor : pointer\"\r\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line["feed_title"]) . "\"\r\n\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">{$feed_icon_img}</span>"; } $reply['content'] .= "<div class=\"updPic\">{$update_pic}</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "<div class=\"cdmContent\" {$content_hidden}\r\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\r\n\t\t\t\t\t\tid=\"CICD-{$id}\">"; $reply['content'] .= "<div class=\"cdmContentInner\">"; if ($line["orig_feed_id"]) { $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds\r\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]); if (db_num_rows($tmp_result) != 0) { $reply['content'] .= "<div clear='both'>"; $reply['content'] .= __("Originally from:"); $reply['content'] .= " "; $tmp_line = db_fetch_assoc($tmp_result); $reply['content'] .= "<a target='_blank'\r\n\t\t\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>"; $reply['content'] .= " "; $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>"; $reply['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_set.png'></a>"; $reply['content'] .= "</div>"; } } $feed_site_url = $line["site_url"]; $article_content = sanitize($this->link, $line["content_preview"], false, false, $feed_site_url); $reply['content'] .= "<div id=\"POSTNOTE-{$id}\">"; if ($line['note']) { $reply['content'] .= format_article_note($id, $line['note']); } $reply['content'] .= "</div>"; $reply['content'] .= "<span id=\"CWRAP-{$id}\">"; $reply['content'] .= $expand_cdm ? $article_content : ''; $reply['content'] .= "</span>"; /* $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM ttrss_feeds WHERE id = ". (($line['feed_id'] == null) ? $line['orig_feed_id'] : $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]); $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result, 0, "always_display_enclosures")); */ $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]); $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures, $article_content); $reply['content'] .= "</div>"; $reply['content'] .= "<div class=\"cdmFooter\">"; $tag_cache = $line["tag_cache"]; $tags_str = format_tags_string(get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache), $id); $reply['content'] .= "<img src='" . theme_image($this->link, 'images/tag.png') . "' alt='Tags' title='Tags'>\r\n\t\t\t\t\t\t<span id=\"ATSTR-{$id}\">{$tags_str}</span>\r\n\t\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\r\n\t\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id}, {$feed_id}, true)\">(+)</a>"; $num_comments = $line["num_comments"]; $entry_comments = ""; if ($num_comments > 0) { if ($line["comments"]) { $comments_url = $line["comments"]; } else { $comments_url = $line["link"]; } $entry_comments = "<a target='_blank' href=\"{$comments_url}\">{$num_comments} comments</a>"; } else { if ($line["comments"] && $line["link"] != $line["comments"]) { $entry_comments = "<a target='_blank' href=\"" . $line["comments"] . "\">comments</a>"; } } if ($entry_comments) { $reply['content'] .= " ({$entry_comments})"; } $reply['content'] .= "<div style=\"float : right\">"; $reply['content'] .= "<img src=\"images/art-zoom.png\"\r\n\t\t\t\t\t\tonclick=\"zoomToArticle(event, {$id})\"\r\n\t\t\t\t\t\tstyle=\"cursor : pointer\"\r\n\t\t\t\t\t\talt='Zoom'\r\n\t\t\t\t\t\ttitle='" . __('Open article in new tab') . "'>"; //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); foreach ($button_plugins as $p) { $reply['content'] .= $p->render($id, $line); } $reply['content'] .= "<img src=\"images/digest_checkbox.png\"\r\n\t\t\t\t\t\tstyle=\"cursor : pointer\" style=\"cursor : pointer\"\r\n\t\t\t\t\t\tonclick=\"dismissArticle({$id})\"\r\n\t\t\t\t\t\ttitle='" . __('Close article') . "'>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; $reply['content'] .= "</div>"; } ++$lnum; } if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("PE", $timing_info); } } else { $message = ""; switch ($view_mode) { case "unread": $message = __("No unread articles found to display."); break; case "updated": $message = __("No updated articles found to display."); break; case "marked": $message = __("No starred articles found to display."); break; default: if ($feed < -10) { $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter."); } else { $message = __("No articles found to display."); } } if (!$offset && $message) { $reply['content'] .= "<div class='whiteBox'>{$message}"; $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">"; $result = db_query($this->link, "SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION['uid']); $last_updated = db_fetch_result($result, 0, "last_updated"); $last_updated = make_local_datetime($this->link, $last_updated, false); $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); $result = db_query($this->link, "SELECT COUNT(id) AS num_errors\r\n\t\t\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]); $num_errors = db_fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { $reply['content'] .= "<br/>"; $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>"; } $reply['content'] .= "</span></p></div>"; } } if ($_REQUEST["debug"]) { $timing_info = print_checkpoint("H2", $timing_info); } return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $vgroup_last_feed, $reply); }