header("Content-Type: text/html; charset=utf-8"); } else { header("Content-Type: text/plain; charset=utf-8"); } } if (!$op) { header("Content-Type: application/xml"); print_error_xml(7); exit; } if (SINGLE_USER_MODE) { authenticate_user($link, "admin", null); } if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread" && $op != "publish" && $op != "getProfiles") { if ($op == "rpc" || $op == "viewfeed" || $op == "view") { print_error_xml(6); die; } else { print "\n\t\t\t<html><body>\n\t\t\t\t<p>Error: Not logged in.</p>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tif (parent.window != 'undefined') {\n\t\t\t\t\t\tparent.window.location = \"tt-rss.php\";\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\twindow.location = \"tt-rss.php\";\n\t\t\t\t\t}\n\t\t\t\t</script>\n\t\t\t</body></html>\n\t\t\t"; } exit; } $purge_intervals = array(0 => __("Use default"), -1 => __("Never purge"), 5 => __("1 week old"), 14 => __("2 weeks old"), 31 => __("1 month old"), 60 => __("2 months old"), 90 => __("3 months old")); $update_intervals = array(0 => __("Default interval"), -1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly")); $update_intervals_nodefault = array(-1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly")); $update_methods = array(0 => __("Default"), 1 => __("Magpie"), 2 => __("SimplePie")); if (ENABLE_SIMPLEPIE) { $update_methods[0] .= ' (SimplePie)'; } else { $update_methods[0] .= ' (Magpie)'; }
function sanity_check($link) { error_reporting(0); $error_code = 0; $schema_version = get_schema_version($link); if ($schema_version != SCHEMA_VERSION) { $error_code = 5; } if (DB_TYPE == "mysql") { $result = db_query($link, "SELECT true", false); if (db_num_rows($result) != 1) { $error_code = 10; } } if (db_escape_string("testTEST") != "testTEST") { $error_code = 12; } error_reporting(DEFAULT_ERROR_LEVEL); if ($error_code != 0) { print_error_xml($error_code); return false; } else { return true; } }
function ListThreads($who, $forumid, $pagenumber, $perpage) { global $db, $vbulletin, $server, $structtypes, $lastpostarray; $result = RegisterService($who); if ($result['Code'] != 0) { $retval['Result'] = $result; return $retval; } // get the total threads count $threadcount = $db->query_first("SELECT threadcount FROM " . TABLE_PREFIX . "forum WHERE (forumid = {$forumid});"); if ($threadcount > 0) { $forumperms = fetch_permissions($forumid); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) { // TODO: handle this properly print_error_xml('no_permission_fetch_threadsxml'); } $userid = $vbulletin->userinfo['userid']; $limitlower = ($pagenumber - 1) * $perpage; $getthreadidssql = "\r\n SELECT \r\n thread.threadid, \r\n thread.lastpost, \r\n thread.lastposter, \r\n thread.lastpostid, \r\n thread.replycount, \r\n IF(thread.views<=thread.replycount, thread.replycount+1, thread.views) AS views\r\n FROM " . TABLE_PREFIX . "thread AS thread\r\n WHERE forumid = {$forumid}\r\n AND sticky = 0\r\n AND visible = 1\r\n ORDER BY \r\n lastpost DESC \r\n LIMIT {$limitlower}, {$perpage}\r\n "; $getthreadids = $db->query_read_slave($getthreadidssql); $ids = ''; while ($thread = $db->fetch_array($getthreadids)) { $ids .= ',' . $thread['threadid']; } $threadssql = "\r\n SELECT \r\n thread.threadid, \r\n thread.title AS threadtitle, \r\n thread.forumid, \r\n thread.lastpost, \r\n thread.lastposter, \r\n thread.lastpostid, \r\n thread.replycount,\r\n threadread.readtime AS threadread,\r\n forumread.readtime as forumread,\r\n subscribethread.subscribethreadid AS subscribethreadid\r\n FROM " . TABLE_PREFIX . "thread AS thread \r\n LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = {$userid}) \r\n LEFT JOIN " . TABLE_PREFIX . "forumread AS forumread ON (thread.forumid = forumread.forumid AND forumread.userid = {$userid}) \r\n LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON (thread.threadid = subscribethread.threadid AND subscribethread.userid = {$userid}) \r\n WHERE thread.threadid IN (0{$ids})\r\n ORDER BY lastpost DESC\r\n "; $threads = $db->query_read_slave($threadssql); $threadlist = array(); while ($thread = $db->fetch_array($threads)) { $thread['issubscribed'] = $thread['subscribethreadid'] > 0; $thread['isnew'] = true; if ($thread['forumread'] >= $thread['lastpost'] || $thread['threadread'] >= $thread['lastpost'] || TIMENOW - $vbulletin->options['markinglimit'] * 86400 > $thread['lastpost']) { $thread['isnew'] = false; } $thread['threadtitle'] = unhtmlspecialchars($thread['threadtitle'], true); $thread['title'] = unhtmlspecialchars($thread['threadtitle'], true); $thread['datelinetext'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], true, true, false) . " " . vbdate($vbulletin->options['timeformat'], $thread['lastpost']); $thread = ConsumeArray($thread, $structtypes['Thread']); array_push($threadlist, $thread); } } $result['RemoteUser'] = ConsumeArray($vbulletin->userinfo, $structtypes['RemoteUser']); $retval['Result'] = $result; $retval['ThreadList'] = $threadlist; $retval['ThreadCount'] = $threadcount['threadcount']; return $retval; }