function __construct($masterstyleid = -1) { // Set initial stuff $this->dateline = time(); $this->assertor = vB::getDbAssertor(); $this->productlist = vB::get_datastore()->get_value('products'); $this->masterstyleid = $masterstyleid; $this->styles[] = $this->masterstyleid; $styles = $this->assertor->getRows('getStylesForMaster', array('masterid' => $this->masterstyleid)); foreach ($styles as $style) { $this->styles[] = $style['styleid']; } }
function do_online() { $userinfo = vB_Api::instance('user')->fetchUserInfo(); $result = vB_Api::instance('wol')->fetchAll(); $options = vB::get_datastore()->get_value('options'); if (is_null($result) || isset($result['errors'])) { return json_error(ERR_NO_PERMISSION); } $user_counts = vB_Api::instance('wol')->fetchCounts(); if (is_null($user_counts) || isset($user_counts['errors'])) { return json_error(ERR_NO_PERMISSION); } $users = array(); foreach ($result as $user) { $user_final = array('username' => $user['username'], 'userid' => $user['userid'], 'avatarurl' => $options['bburl'] . '/' . $user['avatarpath']); if (!empty($userinfo) && $user['userid'] === $userinfo['userid']) { $user_final['me'] = true; } $users[] = $user_final; } return array('users' => $users, 'num_guests' => $user_counts['guests']); }
function fr_register_info() { $options = vB::get_datastore()->get_value('options'); $rules = (string) new vB_Phrase('global', 'site_terms_and_rules', $options['webmasteremail']); $birthday = $options['usecoppa']; return array('rules' => $rules, 'birthday' => $birthday); }
function exec_digest($type = 2) { // type = 2 : daily // type = 3 : weekly $lastdate = mktime(0, 0); // midnight today if ($type == 2) { // daily // yesterday midnight $lastdate -= 24 * 60 * 60; } else { // weekly // last week midnight $lastdate -= 7 * 24 * 60 * 60; } if (trim(vB::getDatastore()->getOption('globalignore')) != '') { $coventry = preg_split('#\\s+#s', vB::getDatastore()->getOption('globalignore'), -1, PREG_SPLIT_NO_EMPTY); } else { $coventry = array(); } require_once DIR . '/includes/class_bbcode_alt.php'; $vbulletin =& vB::get_registry(); $plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list()); vB_Mail::vbmailStart(); $bf_misc_useroptions = vB::get_datastore()->get_value('bf_misc_useroptions'); $bf_ugp_genericoptions = vB::get_datastore()->get_value('bf_ugp_genericoptions'); $bf_ugp_forumpermissions = vB::get_datastore()->get_value('bf_ugp_forumpermissions'); // we want to fetch all language records at once and using cache if possible $defaultLanguage = false; $languageIds = array(); // get new threads (Topic Subscription) $threads = vB::getDbAssertor()->getRows('getNewThreads', array('dstonoff' => $bf_misc_useroptions['dstonoff'], 'hasaccessmask' => $bf_misc_useroptions['hasaccessmask'], 'isnotbannedgroup' => $bf_ugp_genericoptions['isnotbannedgroup'], 'lastdate' => intval($lastdate))); // grab all forums / subforums for given subscription (Channel Subscription) $forums = vB::getDbAssertor()->assertQuery('getNewForums', array('dstonoff' => $bf_misc_useroptions['dstonoff'], 'hasaccessmask' => $bf_misc_useroptions['hasaccessmask'], 'type' => intval($type), 'lastdate' => intval($lastdate), 'channelcontenttype' => vB_Api::instanceInternal('contenttype')->fetchContentTypeIdFromClass('Channel'), 'isnotbannedgroup' => $bf_ugp_genericoptions['isnotbannedgroup'])); // Let's see which languageids we wanna fetch foreach ($threads as $thread) { if ($thread['languageid'] == 0) { if (!$defaultLanguage) { $defaultLanguage = intval(vB::getDatastore()->getOption('languageid')); $languageIds[] = $defaultLanguage; } } else { $languageIds[] = $thread['languageid']; } } foreach ($forums as $forum) { if ($forum['languageid'] == 0) { if (!$defaultLanguage) { $defaultLanguage = intval(vB::getDatastore()->getOption('languageid')); $languageIds[] = $defaultLanguage; } } else { $languageIds[] = $forum['languageid']; } } // fetch languages $languages = vB_Library::instance('language')->fetchLanguages($languageIds); // process threads foreach ($threads as $thread) { $postbits = ''; // Make sure user have correct email notification settings. if ($thread['emailnotification'] != $type) { continue; } if ($thread['lastauthorid'] != $thread['userid'] and in_array($thread['lastauthorid'], $coventry)) { continue; } $usercontext = vB::getUserContext($thread['userid']); if (!$usercontext->getChannelPermission('forumpermissions', 'canview', $thread['nodeid']) or !$usercontext->getChannelPermission('forumpermissions', 'canviewthreads', $thread['nodeid']) or $thread['lastauthorid'] != $thread['userid'] and !$usercontext->getChannelPermission('forumpermissions', 'canviewothers', $thread['nodeid'])) { continue; } $langInfo =& $languages[$thread['languageid']]; $userinfo = array('lang_locale' => $langInfo['locale'], 'dstonoff' => $thread['dstonoff'], 'timezoneoffset' => $thread['timezoneoffset']); $thread['lastreplydate'] = vbdate($langInfo['dateoverride'] ? $langInfo['dateoverride'] : vB::getDatastore()->getOption('dateformat'), $thread['lastcontent'], false, true, true, false, $userinfo); $thread['lastreplytime'] = vbdate($langInfo['timeoverride'] ? $langInfo['timeoverride'] : vB::getDatastore()->getOption('timeformat'), $thread['lastcontent'], false, true, true, false, $userinfo); $thread['htmltitle'] = unhtmlspecialchars($thread['htmltitle']); $thread['username'] = unhtmlspecialchars($thread['username']); $thread['postusername'] = unhtmlspecialchars($thread['authorname']); $thread['lastposter'] = unhtmlspecialchars($thread['lastcontentauthor']); $thread['newposts'] = 0; //not currently used and probably needs rethinking, but don't want to remove until this code gets rewritten //$thread['auth'] = md5($thread['userid'] . $thread['subscribediscussionid'] . $thread['secret'] . vB_Request_Web::$COOKIE_SALT); if ($thread['prefixid']) { // need prefix in correct language $phraseAux = vB_Api::instanceInternal('phrase')->fetch(array("prefix_{$thread['prefixid']}_title_plain")); $thread['prefix_plain'] = $phraseAux["prefix_{$thread['prefixid']}_title_plain"] . ' '; } else { $thread['prefix_plain'] = ''; } // Note: closure.depth = 1 on the where clause means getNewPosts only grabs replies, not comments. // get posts $posts = vB::getDbAssertor()->getRows('getNewPosts', array('threadid' => intval($thread['nodeid']), 'lastdate' => intval($lastdate))); // compile $haveothers = false; foreach ($posts as $post) { if ($post['userid'] != $thread['userid'] and in_array($post['userid'], $coventry)) { continue; } if ($post['userid'] != $thread['userid']) { $haveothers = true; } $thread['newposts']++; $post['htmltitle'] = unhtmlspecialchars($post['htmltitle']); $post['postdate'] = vbdate($langInfo['dateoverride'] ? $langInfo['dateoverride'] : vB::getDatastore()->getOption('dateformat'), $post['publishdate'], false, true, true, false, $userinfo); $post['posttime'] = vbdate($langInfo['timeoverride'] ? $langInfo['timeoverride'] : vB::getDatastore()->getOption('timeformat'), $post['publishdate'], false, true, true, false, $userinfo); $post['postusername'] = unhtmlspecialchars($post['authorname']); $plaintext_parser->set_parsing_language($thread['languageid']); $contentAPI = vB_Library_Content::getContentApi($post['contenttypeid']); $contents = $contentAPI->getContent($post['nodeid']); $post['pagetext'] = $plaintext_parser->parse($contents[$post['nodeid']]['rawtext'], $thread['parentid']); $postlink = vB5_Route::buildUrl($post['routeid'] . '|bburl', array('nodeid' => $post['nodeid'])); /*$postlink = fetch_seo_url('thread|nosession|bburl', array('threadid' => $thread['nodeid'], 'title' => htmlspecialchars_uni($thread['title']))) . "#post$post[nodeid]";*/ // Legacy Hook 'digest_thread_post' Removed // $phrases = vB_Api::instanceInternal('phrase')->fetch('digestpostbit', $thread['languageid']); $postbits .= sprintf($phrases['digestpostbit'], $post['htmltitle'], $postlink, $post['postusername'], $post['postdate'], $post['posttime'], $post['pagetext']); } // Legacy Hook 'digest_thread_process' Removed // // Don't send an update if the subscriber is the only one who posted in the thread. if ($haveothers) { // make email // magic vars used by the phrase eval $threadlink = vB5_Route::buildUrl($thread['routeid'] . '|fullurl', array('nodeid' => $thread['nodeid'])); //$threadlink = fetch_seo_url('thread|nosession|bburl', array('threadid' => $thread['threadid'], 'title' => htmlspecialchars_uni($thread['title']))); //this link probably doesn't do what the author thinks it does, need to validate. $unsubscribelink = vB5_Route::buildUrl('subscription|fullurl', array('tab' => 'subscriptions', 'userid' => $thread['userid'])); $maildata = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('digestthread', array($thread['username'], $thread['prefix_plain'], $thread['htmltitle'], $thread['postusername'], $thread['newposts'], $thread['lastposter'], $threadlink, $postbits, vB::getDatastore()->getOption('bbtitle'), $unsubscribelink), array($thread['prefix_plain'], $thread['htmltitle']), $thread['languageid']); vB_Mail::vbmail($thread['email'], $maildata['subject'], $maildata['message']); } } unset($plaintext_parser); // process forums foreach ($forums as $forum) { $langInfo =& $languages[$forum['languageid']]; $userinfo = array('lang_locale' => $langInfo['locale'], 'dstonoff' => $forum['dstonoff'], 'timezoneoffset' => $forum['timezoneoffset']); $newthreadbits = ''; $newthreads = 0; $updatedthreadbits = ''; $updatedthreads = 0; $forum['username'] = unhtmlspecialchars($forum['username']); $forum['title_clean'] = unhtmlspecialchars($forum['title_clean']); //not currently used and probably needs rethinking, but don't want to remove until this code gets rewritten //$forum['auth'] = md5($forum['userid'] . $forum['subscribeforumid'] . $forum['secret'] . vB_Request_Web::$COOKIE_SALT); $threads = vB::getDbAssertor()->assertQuery('fetchForumThreads', array('forumid' => intval($forum['forumid']), 'lastdate' => intval($lastdate))); foreach ($threads as $thread) { if ($thread['postuserid'] != $forum['userid'] and in_array($thread['postuserid'], $coventry)) { continue; } // allow those without canviewthreads to subscribe/receive forum updates as they contain not post content $usercontext = vB::getUserContext($thread['userid']); if (!$usercontext->getChannelPermission('forumpermissions', 'canview', $thread['nodeid']) or $thread['lastauthorid'] != $thread['userid'] and !$usercontext->getChannelPermission('forumpermissions', 'canviewothers', $thread['nodeid'])) { continue; } $thread['forumhtmltitle'] = unhtmlspecialchars($thread['forumhtmltitle']); $thread['lastreplydate'] = vbdate($langInfo['dateoverride'] ? $langInfo['dateoverride'] : vB::getDatastore()->getOption('dateformat'), $thread['lastpost'], false, true, true, false, $userinfo); $thread['lastreplytime'] = vbdate($langInfo['timeoverride'] ? $langInfo['timeoverride'] : vB::getDatastore()->getOption('timeformat'), $thread['lastpost'], false, true, true, false, $userinfo); $thread['htmltitle'] = unhtmlspecialchars($thread['htmltitle']); $thread['postusername'] = unhtmlspecialchars($thread['postusername']); $thread['lastposter'] = unhtmlspecialchars($thread['lastposter']); if ($thread['prefixid']) { // need prefix in correct language $phraseAux = vB_Api::instanceInternal('phrase')->fetch(array("prefix_{$thread['prefixid']}_title_plain")); $thread['prefix_plain'] = $phraseAux["prefix_{$thread['prefixid']}_title_plain"] . ' '; } else { $thread['prefix_plain'] = ''; } $threadlink = vB5_Route::buildUrl($thread['routeid'] . '|fullurl', array('nodeid' => $thread['threadid'])); // Legacy Hook 'digest_forum_thread' Removed // $maildata = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('digestthreadbit', array($thread['prefix_plain'], $thread['htmltitle'], $threadlink, $thread['forumhtmltitle'], $thread['postusername'], $thread['lastreplydate'], $thread['lastreplytime']), array(), $forum['languageid']); if ($thread['dateline'] > $lastdate) { // new thread $newthreads++; $newthreadbits .= $maildata['message']; } else { $updatedthreads++; $updatedthreadbits .= $maildata['message']; } } // Legacy Hook 'digest_forum_process' Removed // if (!empty($newthreads) or !empty($updatedthreadbits)) { // make email // magic vars used by the phrase eval //$forumlink = fetch_seo_url('forum|nosession|bburl', $forum); $forumlink = vB5_Route::buildUrl($forum['routeid'] . '|fullurl', array('nodeid' => $forum['forumid'])); //this link probably doesn't do what the author thinks it does. Need to validate. $unsubscribelink = vB5_Route::buildUrl('subscription|fullurl', array('tab' => 'subscriptions', 'userid' => $forum['userid'])); $maildata = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('digestforum', array($forum['username'], $forum['title_clean'], $newthreads, $updatedthreads, $forumlink, $newthreadbits, $updatedthreadbits, vB::getDatastore()->getOption('bbtitle'), $unsubscribelink), array($forum['title_clean']), $forum['languageid']); vB_Mail::vbmail($forum['email'], $maildata['subject'], $maildata['message'], true); } } // ******* Social Group Digests ********** $bf_misc_socnet = vB::get_datastore()->get_value('bf_misc_socnet'); if (vB::getDatastore()->getOption('socnet') & $bf_misc_socnet['enable_groups']) { require_once DIR . '/includes/functions_socialgroup.php'; /** @todo review this part*/ /** @todo if we reenable this code, we need to prefetch language records as for threads and forums */ /* $groups = vB::getDbAssertor()->assertQuery('fetchSocialGroupDigests', array( 'dstonoff' => $bf_misc_useroptions['dstonoff'], 'hasaccessmask' => $bf_misc_useroptions['hasaccessmask'], 'languageid' => intval(vB::getDatastore()->getOption('languageid')), 'type' => $type == 2 ? 'daily' : 'weekly', 'lastdate' => intval($lastdate), 'isnotbannedgroup' => $bf_ugp_genericoptions['isnotbannedgroup'] )); foreach ($groups as $group) { $userperms = cache_permissions($group, false); if (!($userperms['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($userperms['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canviewgroups']) ) { continue; } if ($group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view'] AND $vbulletin->options['sg_allow_join_to_view']) { if ($group['membertype'] != 'member' AND !($userperms['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canalwayspostmessage']) AND !($userperms['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canalwascreatediscussion']) ) { continue; } } $userinfo = array( 'lang_locale' => $group['lang_locale'], 'dstonoff' => $group['dstonoff'], 'timezoneoffset' => $group['timezoneoffset'], ); $new_discussion_bits = ''; $new_discussions = 0; $updated_discussion_bits = ''; $updated_discussions = 0; $group['username'] = unhtmlspecialchars($group['username']); $group['name'] = unhtmlspecialchars($group['name']); $discussions = vB::getDbAssertor()->assertQuery('fetchGroupDiscussions', array( 'groupid' => $group['groupid'], 'lastdate' => intval($lastdate) )); foreach ($discussions as $discussion) { $discussion['lastreplydate'] = vbdate($group['lang_dateoverride'] ? $group['lang_dateoverride'] : $vbulletin->options['default_dateformat'], $discussion['lastpost'], false, true, true, false, $userinfo); $discussion['lastreplytime'] = vbdate($group['lang_timeoverride'] ? $group['lang_timeoverride'] : $vbulletin->options['default_timeformat'], $discussion['lastpost'], false, true, true, false, $userinfo); $discussion['title'] = unhtmlspecialchars($discussion['title']); $discussion['postusername'] = unhtmlspecialchars($discussion['postusername']); $discussion['lastposter'] = unhtmlspecialchars($discussion['lastposter']); // Legacy Hook 'digest_group_discussion' Removed // //magic variables that will be picked up by the phrase eval $discussionlink = fetch_seo_url('groupdiscussion', $discussion); $maildata = vB_Api::instanceInternal('phrase') ->fetchEmailPhrases('digestgroupbit', array($discussion['htmltitle'], $discussionlink, $group['name'], $discussion['postusername'], $discussion['lastreplydate'], $discussion['lastreplytime']), array(), $group['languageid']); if ($discussion['dateline'] > $lastdate) { // new discussion $new_discussions++; $new_discussion_bits .= $maildata['message']; } else { $updated_discussions++; $updated_discussion_bits .= $maildata['message']; } } // Legacy Hook 'digest_group_process' Removed // if (!empty($new_discussion_bits) OR !empty($updated_discussion_bits)) { //magic variables that will be picked up by the phrase eval $grouplink = fetch_seo_url('group|nosession|bburl', $group); // make email $maildata = vB_Api::instanceInternal('phrase') ->fetchEmailPhrases('digestgroup', array($group['username'], $group['name'], $new_discussions, $updated_discussions, $grouplink, $new_discussion_bits, $updated_discussion_bits, $vbulletin->options['bbtitle']), array($group['name']), $group['languageid']); vB_Mail::vbmail($group['email'], $maildata['subject'], $maildata['message']); } } */ } vB_Mail::vbmailEnd(); }
\*========================================================================*/ // ######################## SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // ######################################################################## // ######################### START MAIN SCRIPT ############################ // ######################################################################## require_once DIR . '/includes/functions_newpost.php'; require_once DIR . '/includes/class_rss_poster.php'; require_once DIR . '/includes/functions_wysiwyg.php'; if (($current_memory_limit = vB_Utilities::ini_size_to_bytes(@ini_get('memory_limit'))) < 256 * 1024 * 1024 and $current_memory_limit > 0) { @ini_set('memory_limit', 256 * 1024 * 1024); } @set_time_limit(0); // ############################################################################# // slurp all enabled feeds from the database $bf_misc_feedoptions = vB::get_datastore()->get_value('bf_misc_feedoptions'); $feeds_result = vB::getDbAssertor()->assertQuery('fetchFeeds', array('bf_misc_feedoptions_enabled' => $bf_misc_feedoptions['enabled'])); foreach ($feeds_result as $feed) { // only process feeds that are due to be run (lastrun + TTL earlier than now) if ($feed['lastrun'] < vB::getRequest()->getTimeNow() - $feed['ttl']) { // counter for maxresults $feed['counter'] = 0; // add to $feeds slurp array $feeds["{$feed['rssfeedid']}"] = $feed; } } // ############################################################################# // extract items from feeds $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('x_unable_to_open_url', 'x_xml_error_y_at_line_z', 'rss_feed_manager', 'announcement', 'thread')); if (!empty($feeds)) { // array of items to be potentially inserted into the database
require_once DIR . '/includes/functions_calendar.php'; // ######################################################################## // ######################### START MAIN SCRIPT ############################ // ######################################################################## $vb5_config =& vB::getConfig(); $timenow = vB::getRequest()->getTimeNow(); $beginday = $timenow - 86400; $endday = $timenow + 345600; # 4 Days $eventlist = array(); $eventcache = array(); $userinfo = array(); $events = vB::getDbAssertor()->assertQuery('fetchEvents', array('beginday' => $beginday, 'endday' => $endday)); $updateids = array(); $usergroupcache = vB::get_datastore()->get_value('usergroupcache'); $bf_ugp_genericoptions = vB::get_datastore()->get_value('bf_ugp_genericoptions'); foreach ($events as $event) { if (!($usergroupcache["{$event['usergroupid']}"]['genericoptions'] & $bf_ugp_genericoptions['isnotbannedgroup'])) { continue; } $offset = $event['utc'] ? 0 : ($event['dstonoff'] ? 3600 : 0); $event['dateline_from_user'] = $event['dateline_from'] + $offset; $event['dateline_to_user'] = $event['dateline_to'] + $offset; if ($vb5_config['Misc']['debug'] and VB_AREA == 'AdminCP') { echo "<br>{$event['title']} {$event['username']}<br>"; echo "-GM Start: " . gmdate('Y-m-d h:i:s a', $event['dateline_from']); echo "<br />User Start: " . gmdate('Y-m-d h:i:s a', $event['dateline_from_user']); } if (empty($userinfo["{$event['userid']}"])) { $userinfo["{$event['userid']}"] = array('username' => $event['username'], 'email' => $event['email'], 'languageid' => $event['languageid']); }
/** * Determine if we send the content length header * * @return boolean */ function fetch_send_content_length_header() { if (VB_AREA == 'Install' or VB_AREA == 'Upgrade') { return strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false; } else { $vboptions = vB::get_datastore()->get_value('options'); switch ($vboptions['ajaxheader']) { case 0: return true; case 1: return false; case 2: default: return strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false; } } }
function fr_parse_post($node, $signature = true, $html = true) { $userinfo = vB_Api::instance('user')->fetchUserinfo($node['userid']); $options = vB::get_datastore()->get_value('options'); $post = array('post_id' => $node['nodeid'], 'thread_id' => $node['starter'], 'post_timestamp' => fr_date($node['created']), 'forum_id' => $node['content']['channelid'], 'forum_title' => html_entity_decode($node['content']['channeltitle']), 'title' => html_entity_decode($node['title']), 'username' => $node['userid'] > 0 ? $node['authorname'] : (string) new vB_Phrase('global', 'guest'), 'userid' => $node['userid'], 'joindate' => fr_date($userinfo['joindate']), 'usertitle' => $userinfo['usertitle'], 'numposts' => $userinfo['posts'], 'online' => fr_get_user_online($userinfo['lastactivity']), 'text' => strip_bbcode($node['content']['rawtext']), 'quotable' => $node['content']['rawtext'], 'edittext' => $node['content']['rawtext'], 'canedit' => $node['content']['permissions']['canedit'], 'candelete' => $node['content']['permissions']['canmoderate'], 'canlike' => $node['content']['permissions']['canuserep'] > 0, 'likes' => $node['content']['nodeVoted'] ? true : false); if (!empty($node['deleteuserid'])) { $post['deleted'] = true; $del_userinfo = vB_Api::instance('user')->fetchUserInfo($node['deleteuserid']); $post['del_username'] = $del_userinfo['username']; $post['del_reason'] = $node['deletereason']; } if ($avatarurl = fr_find_avatarurl($node)) { $post['avatarurl'] = $options['bburl'] . '/' . $avatarurl; } $inline_images = array(); if ($signature || $html) { $bbcode = fr_post_to_bbcode($node, $html); if ($signature) { $post['signature'] = $bbcode['signature']; } if ($html) { $post['text'] = $bbcode['html']; $post['html'] = $bbcode['html']; } $inline_images = $bbcode['images']; } if (!empty($node['content']['attach'])) { $fr_images = array(); foreach ($node['content']['attach'] as $attachment) { if ($attachment['visible'] > 0) { $image = fr_base_url() . 'filedata/fetch?id=' . $attachment['nodeid']; $fr_images[] = array('img' => $image); if (!in_array($image, $inline_images)) { $post['text'] .= "<img src=\"{$image}\"/>"; $post['html'] .= "<img src=\"{$image}\"/>"; } } } $post['fr_images'] = $fr_images; } return $post; }
function forumrunner_ad($default) { $options = vB::get_datastore()->get_value('options'); $agent = strtolower($_SERVER['HTTP_USER_AGENT']); if (strpos($agent, 'iphone') === false && strpos($agent, 'ipad') === false && strpos($agent, 'ipod') === false && strpos($agent, 'android') === false) { die; } $kw = $options['keywords'] . ' ' . $options['description']; echo "<html><head><style>* {margin:0; padding:0;}</style></head><body>\n\t\t\t<span style='display:none'>{$kw}</span>\n\t\t\t<center>"; echo $options['forumrunner_googleads_javascript']; echo "</center>\n\t\t\t</body></html>"; }
/** * Constructor */ protected function __construct() { parent::__construct(); //The table for the type-specific data. $this->assertor = vB::getDbAssertor(); $this->nodeApi = vB_Api::instanceInternal('node'); // TODO remove this when the previewFields var is removed $this->previewFields = $this->nodeApi->fetchPreviewFields(); // TODO remove this when the nodeFields var is removed $this->nodeFields = $this->nodeApi->getNodeFields(); $this->options = vB::get_datastore()->get_value('options'); }
function fr_get_and_parse_forum($forumid, $foruminfo = false) { $userinfo = vB_Api::instance('user')->fetchUserInfo(); $options = vB::get_datastore()->get_value('options'); if (!$foruminfo) { $foruminfo = vB_Api::instance('node')->getFullContentforNodes(array($forumid)); if (empty($foruminfo)) { return null; } $foruminfo = $foruminfo[0]; } if (!$foruminfo) { return null; } $type = 'old'; if ($options['threadmarking'] and $userinfo['userid']) { $userlastvisit = !empty($foruminfo['readtime']) ? $foruminfo['readtime'] : vB::getRequest()->getTimeNow() - $options['markinglimit'] * 86400; } else { $lastvisit = vB5_Cookie::get('lastvisit', vB5_Cookie::TYPE_UINT); $forumview = fr_fetch_bbarray_cookie('channel_view', $foruminfo['nodeid']); //use which one produces the highest value, most likely cookie $userlastvisit = $forumview > $lastvisit ? $forumview : $lastvisit; } if ($foruminfo['lastcontent'] and $userlastvisit < $foruminfo['lastcontent']) { $type = 'new'; } else { $type = 'old'; } $out = array('id' => $foruminfo['nodeid'], 'new' => $type == 'new' ? true : false, 'name' => html_entity_decode(strip_tags($foruminfo['title'])), 'password' => false); $icon = fr_get_forum_icon($foruminfo['nodeid'], $foruminfo == 'new'); if ($icon) { $out['icon'] = $icon; } if ($foruminfo['description'] != '') { $desc = strip_tags($foruminfo['description']); if (strlen($desc) > 0) { $out['desc'] = $desc; } } return $out; }
/** * Removes user subscription * * @param int The id of the subscription * @param int The userid the subscription is to be removed from * @param int The id of the sub-subscriptionid * @param bool Update user.adminoptions from subscription.adminoption (keep avatars) * */ function delete_user_subscription($subscriptionid, $userid, $subid = -1, $adminoption = false) { $subscriptionid = intval($subscriptionid); $userid = intval($userid); $this->cache_user_subscriptions(); $sub =& $this->subscriptioncache["{$subscriptionid}"]; $user = vB::getDbAssertor()->getRow('fetchUsersSubscriptions', array('userid' => $userid, 'subscriptionid' => $subscriptionid, 'adminoption' => $adminoption)); if ($user['userid'] and $sub['subscriptionid']) { $this->cache_user_subscriptions(); $sub =& $this->subscriptioncache["{$subscriptionid}"]; $tmp = unserialize($sub['cost']); if ($subid != -1 and is_array($tmp["{$subid}"])) { $sub = array_merge($sub, $tmp["{$subid}"]); $units_full = array('D' => 'day', 'W' => 'week', 'M' => 'month', 'Y' => 'year'); switch ($sub['units']) { case 'D': $new_expires = mktime(date('H', $user['expirydate']), date('i', $user['expirydate']), date('s', $user['expirydate']), date('n', $user['expirydate']), date('j', $user['expirydate']) - $sub['length'], date('Y', $user['expirydate'])); break; case 'W': $new_expires = mktime(date('H', $user['expirydate']), date('i', $user['expirydate']), date('s', $user['expirydate']), date('n', $user['expirydate']), date('j', $user['expirydate']) - $sub['length'] * 7, date('Y', $user['expirydate'])); break; case 'M': $new_expires = mktime(date('H', $user['expirydate']), date('i', $user['expirydate']), date('s', $user['expirydate']), date('n', $user['expirydate']) - $sub['length'], date('j', $user['expirydate']), date('Y', $user['expirydate'])); break; case 'Y': $new_expires = mktime(date('H', $user['expirydate']), date('i', $user['expirydate']), date('s', $user['expirydate']), date('n', $user['expirydate']), date('j', $user['expirydate']), date('Y', $user['expirydate']) - $sub['length']); break; } if ($new_expires > TIMENOW) { // new expiration is still after today so just decremement and return vB::getDbAssertor()->update('vBForum:subscriptionlog', array('expirydate' => $new_expires), array('subscriptionid' => $subscriptionid, 'userid' => $userid)); return; } } unset($tmp); $userdm = new vB_Datamanager_User($this->registry, vB_DataManager_Constants::ERRTYPE_SILENT); $userdm->set_existing($user); if ($adminoption) { if ($user['hascustomavatar'] and $sub['adminavatar']) { $userdm->set_bitfield('adminoptions', 'adminavatar', 1); } if ($user['hasprofilepic'] and $sub['adminprofilepic']) { $userdm->set_bitfield('adminoptions', 'adminprofilepic', 1); } } //access masks if (!empty($sub['forums'])) { if ($old_sub_masks = @unserialize($sub['forums']) and is_array($old_sub_masks)) { // old format is serialized array with forumids for keys $access_forums = array_keys($old_sub_masks); } else { // new format is comma-delimited string $access_forums = explode(',', $sub['forums']); } if ($access_forums) { vB::getDbAssertor()->delete('access', array('nodeid' => $access_forums, 'userid' => $userid)); } } // TODO: Restore the line when Access Masks is implemented // $countaccess = vB::getDbAssertor()->getRow('masks', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_COUNT, 'userid' => $userid)); $membergroupids = array_diff(fetch_membergroupids_array($user, false), fetch_membergroupids_array($sub, false)); $update_userban = false; if ($sub['nusergroupid'] == $user['usergroupid'] and $user['usergroupid'] != $user['pusergroupid']) { // check if there are other active subscriptions that set the same primary usergroup $subids = array(0); foreach ($this->subscriptioncache as $subcheck) { if ($subcheck['nusergroupid'] == $user['usergroupid'] and $subcheck['subscriptionid'] != $subscriptionid) { $subids[] = $subcheck['subscriptionid']; } } if (!empty($subids)) { $activesub = vB::getDbAssertor()->getRow('vBForum:subscriptionlog', array('userid' => $userid, 'subscriptionid' => $subids), array('field' => 'expirydate', 'direction' => vB_dB_Query::SORT_DESC)); } if ($activesub) { // there is at least one active subscription with the same primary usergroup, so alter its resetgroup vB::getDbAssertor()->update('vBForum:subscriptionlog', array('pusergroupid' => $user['pusergroupid']), array('subscriptionlogid' => $activesub['subscriptionlogid'])); // don't touch usertitle/displaygroup $user['pusergroupid'] = $user['usergroupid']; $sub['nusergroupid'] = 0; } else { $userdm->set('usergroupid', $user['pusergroupid']); } } else { if ($user['isbanned'] and $user['busergroupid'] == $sub['nusergroupid']) { $update_userban = true; $userbansql['usergroupid'] = $user['pusergroupid']; } } $groups = iif(!empty($sub['membergroupids']), $sub['membergroupids'] . ',') . $sub['nusergroupid']; if (in_array($user['displaygroupid'], explode(',', $groups))) { // they're displaying as one of the usergroups in the subscription $user['displaygroupid'] = 0; } else { if ($user['isbanned'] and in_array($user['bandisplaygroupid'], explode(',', $groups))) { $update_userban = true; $userbansql['displaygroupid'] = 0; } } // do their old groups still allow custom titles? $reset_title = false; if ($user['customtitle'] == 2) { $groups = empty($membergroupids) ? array() : $membergroupids; $groups[] = $user['pusergroupid']; $bf_ugp_genericpermissions = vB::get_datastore()->get_value('bf_ugp_genericpermissions'); $usergroup = vB::getDbAssertor()->getRow('usergroup', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'usergroupid', 'value' => $groups, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ), array('field' => 'genericpermissions', 'value' => $bf_ugp_genericpermissions['canusecustomtitle'], vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_AND)))); if (empty($usergroup['usergroupid'])) { // no custom group any more lets set it back to the default $reset_title = true; } } if ($sub['nusergroupid'] > 0 and $user['customtitle'] == 0 or $reset_title) { // they need a default title $usergroup = vB::getDbAssertor()->getRow('usergroup', array('usergroupid' => $user['pusergroupid'])); if (empty($usergroup['usertitle'])) { // should be a title based on minposts it seems then $usergroup = vB::getDbAssertor()->getRow('usertitle', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'minposts', 'value' => $user[posts], vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_LTE))), array('field' => 'minposts', 'direction' => vB_dB_Query::SORT_DESC)); } if ($user['isbanned']) { $update_userban = true; $userbansql['customtitle'] = 0; $userbansql['usertitle'] = $usergroup['usertitle']; } else { $userdm->set('customtitle', 0); $userdm->set('usertitle', $usergroup['usertitle']); } } $userdm->set('membergroupids', implode($membergroupids, ',')); // $userdm->set_bitfield('options', 'hasaccessmask', ($countaccess['count'] ? true : false)); $userdm->set('displaygroupid', $user['displaygroupid']); $userdm->save(); unset($userdm); vB::getDbAssertor()->update('vBForum:subscriptionlog', array('status' => 0), array('subscriptionid' => $subscriptionid, 'userid' => $userid)); if ($update_userban) { vB::getDbAssertor()->update('userban', $userbansql, array('subscriptionid' => $subscriptionid, 'userid' => $user['userid'])); } $mysubs = vB::getDbAssertor()->assertQuery('vBForum:subscriptionlog', array('status' => 1, 'userid' => $userid)); foreach ($mysubs as $mysub) { $this->build_user_subscription($mysub['subscriptionid'], -1, $userid, $mysub['regdate'], $mysub['expirydate']); } // Legacy Hook 'paidsub_delete' Removed // } }