} // hashes are only valid for 5 minutes $vbulletin->db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_hash WHERE dateline < " . (TIMENOW - 300) ); $mysqlversion = $vbulletin->db->query_first("SELECT version() AS version"); define('MYSQL_VERSION', $mysqlversion['version']); //searches expire after one hour $vbulletin->db->query_write(" DELETE blog_search, blog_searchresult FROM " . TABLE_PREFIX . "blog_search AS blog_search INNER JOIN " . TABLE_PREFIX . "blog_searchresult AS blog_searchresult ON (blog_searchresult.blogsearchid = blog_search.blogsearchid) WHERE blog_search.dateline < " . (TIMENOW - 3600) ); require_once(DIR . '/includes/blog_functions.php'); build_blog_stats(); log_cron_action('', $nextitem, 1); /*======================================================================*\ || #################################################################### || # || # CVS: $Revision: 37230 $ || #################################################################### \*======================================================================*/ ?>
/** * Constructs the blog overview sidebar * * @param integer The month to show the calendar for * @param integer The year to show the calendar for * * @return string HTML for sidebar */ function &build_overview_sidebar($month = 0, $year = 0) { global $vbulletin, $show, $vbphrase, $vbcollapse, $ad_location; ($hook = vBulletinHook::fetch_hook('blog_sidebar_generic_start')) ? eval($hook) : false; $month = ($month < 1 OR $month > 12) ? vbdate('n', TIMENOW, false, false) : $month; $year = ($year > 2037 OR $year < 1970) ? vbdate('Y', TIMENOW, false, false) : $year; if ($vbulletin->blogstats === NULL) { $vbulletin->blogstats = build_blog_stats(); } $blogstats = $vbulletin->blogstats; foreach ($blogstats AS $key => $value) { if (is_numeric($value)) { $blogstats["$key"] = vb_number_format($value); } } //########################### Get Category Bits ##################################### $categorybits = ''; if (!empty($vbulletin->blogcategorycache)) { $beenhere = $prevdepth = 0; foreach ($vbulletin->blogcategorycache AS $category) { $show['ul'] = false; $category['title'] = $vbphrase['category' . $category['blogcategoryid'] . '_title']; if (!($vbulletin->userinfo['blogcategorypermissions']["$category[blogcategoryid]"] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewcategory'])) { continue; } $indentbits = ''; if ($category['depth'] == $prevdepth AND $beenhere) { $indentbits = '</li>'; } else if ($category['depth'] > $prevdepth) { // Need an UL $show['ul'] = true; } else if ($category['depth'] < $prevdepth) { for ($x = ($prevdepth - $category['depth']); $x > 0; $x--) { $indentbits .= '</li></ul>'; } $indentbits .= '</li>'; } $show['catlink'] = ($vbulletin->GPC['blogcategoryid'] != $category['blogcategoryid']) ? true : false; $templater = vB_Template::create('blog_sidebar_category_link'); $templater->register('category', $category); $templater->register('blog', $blog); $templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid'])); $sidebar['categorybits'] .= $indentbits . $templater->render(); $prevdepth = $category['depth']; $beenhere = true; } if ($sidebar['categorybits']) { for ($x = $prevdepth; $x > 0; $x--) { $sidebar['categorybits'] .= '</li></ul>'; } $sidebar['categorybits'] .= '</li>'; } } $calendar = construct_calendar($month, $year); $tag_cloud = fetch_blog_tagcloud('usage', true); $show['postblog'] = ($vbulletin->userinfo['userid'] AND $vbulletin->userinfo['permissions']['vbblog_entry_permissions'] & $vbulletin->bf_ugp_vbblog_entry_permissions['blog_canpost'] AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']); $show['gotoblog'] = ($vbulletin->userinfo['userid'] AND $vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']); $show['rssfeed'] = ($vbulletin->usergroupcache['1']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']) ? true : false; $show['hidepostblogbutton'] = (THIS_SCRIPT == 'blog_post' AND in_array($_REQUEST['do'], array('editblog', 'newblog', 'comment'))); set_sidebar_ads($ad_location, $show); ($hook = vBulletinHook::fetch_hook('blog_sidebar_generic_end')) ? eval($hook) : false; $templater = vB_Template::create('blog_sidebar_generic'); $templater->register('ad_location', $ad_location); $templater->register('blogstats', $blogstats); $templater->register('sidebar', $sidebar); $templater->register('calendar', $calendar); $templater->register('month', $month); $templater->register('year', $year); $templater->register('tag_cloud', $tag_cloude); return $templater->render(); }
function post_save_each($doquery = true) { $blogid = intval($this->fetch_field('blogid')); $userid = intval($this->fetch_field('userid')); $blogtextid = $this->fetch_field('blogtextid'); $postedby_userid = intval($this->fetch_field('postedby_userid')); require_once(DIR . '/vb/search/indexcontroller/queue.php'); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogEntry', 'index', $blogid); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogComment', 'group_data_change', $blogid); if (!$condition AND $this->info['addtags']) { // invalidate users tag cloud $dataman =& datamanager_init('Blog_User', $this->registry, ERRTYPE_SILENT); $info = array('bloguserid' => $userid); $dataman->set_existing($info); $dataman->set('tagcloud', ''); $dataman->save(); } $this->build_category_counters(); build_blog_stats(); // Insert entry for moderation if ($this->fetch_field('state') == 'moderation') { /*insert query*/ $this->dbobject->query_write(" INSERT IGNORE INTO " . TABLE_PREFIX . "blog_moderation (primaryid, type, dateline) VALUES ($blogid, 'blogid', " . TIMENOW . ") "); } // Insert entry for moderation if (!$this->condition AND ($this->fetch_field('state') == 'moderation' OR $this->fetch_field('state') == 'draft') OR $this->fetch_field('pending')) { $userinfo = array('bloguserid' => $userid); $userdata =& datamanager_init('Blog_user', $this->registry, ERRTYPE_SILENT); $userdata->set_existing($userinfo); if ($this->fetch_field('state') == 'moderation' OR $this->fetch_field('state') == 'draft') { $userdata->set($this->fetch_field('state'), $this->fetch_field('state') . ' + 1', false); } if ($this->fetch_field('pending')) { $userdata->set('pending', 'pending + 1', false); } $userdata->save(); } // Send Email Notification if (((!$this->condition AND !$this->fetch_field('pending')) OR $this->info['send_notification']) AND ($this->fetch_field('state') == 'visible' OR $this->fetch_field('state') == 'moderation') AND $this->registry->options['enableemail']) { $lastposttime = $this->dbobject->query_first(" SELECT MAX(dateline) AS dateline FROM " . TABLE_PREFIX . "blog AS blog WHERE blogid = $blogid AND dateline < " . $this->fetch_field('dateline') . " AND state = 'visible' "); $entrytitle = unhtmlspecialchars($this->fetch_field('title')); if (defined('VBBLOG_PERMS') AND $this->registry->userinfo['userid'] == $this->fetch_field('userid')) { $blogtitle = unhtmlspecialchars($this->registry->userinfo['blog_title']); $username = unhtmlspecialchars($this->registry->userinfo['username']); $userinfo =& $this->registry->userinfo; } else { if (!defined('VBBLOG_PERMS')) { // Tell the fetch_userinfo plugin that we need the blog fields in case this class is being called by a non blog script define('VBBLOG_PERMS', true); } $userinfo = fetch_userinfo($this->fetch_field('userid'), 1); cache_permissions($userinfo, false); $blogtitle = unhtmlspecialchars($userinfo['blog_title']); if ($userinfo['userid'] != $this->fetch_field('userid')) { $userinfo2 = fetch_userinfo($this->fetch_field('userid'), 1); $username = unhtmlspecialchars($userinfo2['username']); } else { $username = unhtmlspecialchars($userinfo['username']); } } require_once(DIR . '/includes/class_bbcode_alt.php'); $plaintext_parser = new vB_BbCodeParser_PlainText($this->registry, fetch_tag_list()); $pagetext_cache = array(); // used to cache the results per languageid for speed $pagetext_orig =& $this->fetch_field('pagetext', 'blog_text'); ($hook = vBulletinHook::fetch_hook('blog_user_notification_start')) ? eval($hook) : false; $useremails = $this->dbobject->query_read_slave(" SELECT user.*, blog_subscribeuser.blogsubscribeuserid, bm.blogmoderatorid, ignored.relationid AS ignoreid, buddy.relationid AS buddyid, bu.isblogmoderator, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid FROM " . TABLE_PREFIX . "blog_subscribeuser AS blog_subscribeuser INNER JOIN " . TABLE_PREFIX . "user AS user ON (blog_subscribeuser.userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "blog_moderator AS bm ON (bm.userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = $userid AND buddy.relationid = user.userid AND buddy.type = 'buddy') LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = $userid AND ignored.relationid = user.userid AND ignored.type = 'ignore') LEFT JOIN " . TABLE_PREFIX . "blog_user AS bu ON (bu.bloguserid = user.userid) WHERE blog_subscribeuser.bloguserid = $userid AND " . ($userid == $postedby_userid ? "blog_subscribeuser.userid <> $userid AND" : "") . " blog_subscribeuser.type = 'email' AND user.usergroupid <> 3 AND user.lastactivity >= " . intval($lastposttime['dateline']) . " "); vbmail_start(); $setoptions = $this->fetch_field('options'); $evalemail = array(); while ($touser = $this->dbobject->fetch_array($useremails)) { cache_permissions($touser, false); // only send private entries to contacts and moderators if ($setoptions["{$this->bitfields['options']['private']}"] AND !$touser['buddyid'] AND !$touser['blogmoderatorid'] AND !is_member_of_blog($touser, $userinfo)) { continue; } if (!($this->registry->usergroupcache["$touser[usergroupid]"]['genericoptions'] & $this->registry->bf_ugp_genericoptions['isnotbannedgroup'])) { continue; } if ($this->fetch_field('state') == 'moderation') { if ($touser['userid'] != $userid AND !can_moderate_blog('canmoderateentries', $touser)) { continue; } } if (!empty($this->info['categories'])) { prepare_blog_category_permissions($touser); if (array_intersect($touser['blogcategorypermissions']['cantview'], $this->info['categories']) AND $userinfo['userid'] != $touser['userid']) { continue; } } if (!($touser['permissions']['vbblog_general_permissions'] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { continue; } else if ( !$touser['blogmoderatorid'] AND !($touser['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) AND !($touser['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['ismoderator']) AND (!$userinfo['ignore_canviewmyblog'] OR !$touser['ignoreid']) AND (!$userinfo['buddy_canviewmyblog'] OR !$touser['buddyid']) AND (!$userinfo['member_canviewmyblog'] OR (!$userinfo['buddy_canviewmyblog'] AND $touser['budyid']) OR (!$userinfo['ignore_canviewmyblog'] AND $touser['ignoreid'])) AND !is_member_of_blog($touser, $userinfo) ) { continue; } $touser['username'] = unhtmlspecialchars($touser['username']); $touser['languageid'] = iif($touser['languageid'] == 0, $this->registry->options['languageid'], $touser['languageid']); $touser['auth'] = md5($touser['userid'] . $touser['blogsubscribeuserid'] . $touser['salt'] . COOKIE_SALT); if (empty($evalemail)) { $email_texts = $this->dbobject->query_read_slave(" SELECT text, languageid, fieldname FROM " . TABLE_PREFIX . "phrase WHERE fieldname IN ('emailsubject', 'emailbody') AND varname = 'blog_user_notify' "); while ($email_text = $this->dbobject->fetch_array($email_texts)) { $emails["$email_text[languageid]"]["$email_text[fieldname]"] = $email_text['text']; } require_once(DIR . '/includes/functions_misc.php'); foreach ($emails AS $languageid => $email_text) { // lets cycle through our array of notify phrases $text_message = str_replace("\\'", "'", addslashes(iif(empty($email_text['emailbody']), $emails['-1']['emailbody'], $email_text['emailbody']))); $text_message = replace_template_variables($text_message); $text_subject = str_replace("\\'", "'", addslashes(iif(empty($email_text['emailsubject']), $emails['-1']['emailsubject'], $email_text['emailsubject']))); $text_subject = replace_template_variables($text_subject); $evalemail["$languageid"] = ' $message = "' . $text_message . '"; $subject = "' . $text_subject . '"; '; } } // parse the page text into plain text, taking selected language into account if (!isset($pagetext_cache["$touser[languageid]"])) { $plaintext_parser->set_parsing_language($touser['languageid']); $pagetext_cache["$touser[languageid]"] = $plaintext_parser->parse($pagetext_orig); } $pagetext = $pagetext_cache["$touser[languageid]"]; ($hook = vBulletinHook::fetch_hook('blog_user_notification_message')) ? eval($hook) : false; eval(iif(empty($evalemail["$touser[languageid]"]), $evalemail["-1"], $evalemail["$touser[languageid]"])); vbmail($touser['email'], $subject, $message); } unset($plaintext_parser, $pagetext_cache); vbmail_end(); } $this->post_save_each_blogtext($doquery); if ($this->fetch_field('dateline') <= TIMENOW) { $this->insert_dupehash($this->fetch_field('blogid')); } if ($this->condition AND $this->info['emailupdate'] == 'none' AND ($userid != $this->registry->userinfo['userid'] OR ($userid == $this->registry->userinfo['userid'] AND $this->existing['entrysubscribed']))) { $this->dbobject->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid = $blogid AND userid = $userid "); } else if ($this->info['emailupdate'] == 'email' OR $this->info['emailupdate'] == 'usercp') { $this->dbobject->query_write(" REPLACE INTO " . TABLE_PREFIX . "blog_subscribeentry (blogid, dateline, type, userid) VALUES ($blogid, " . TIMENOW . ", '" . $this->info['emailupdate'] . "', $userid) "); } ($hook = vBulletinHook::fetch_hook('blog_fpdata_postsave')) ? eval($hook) : false; }
function build_category_permissions() { global $vbulletin; require_once(DIR . '/includes/blog_functions_category.php'); fetch_ordered_categories(0); // query category permissions $categorypermissions = $vbulletin->db->query_read(" SELECT * FROM " . TABLE_PREFIX . "blog_categorypermission "); $permcache = array(); while ($cperm = $vbulletin->db->fetch_array($categorypermissions)) { $permcache["$cperm[blogcategoryid]"]["$cperm[usergroupid]"] = intval($cperm['categorypermissions']); } $grouppermissions = array(); $usergroups = $vbulletin->db->query_read("SELECT vbblog_general_permissions, usergroupid FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid"); while ($usergroup = $vbulletin->db->fetch_array($usergroups)) { $grouppermissions["$usergroup[usergroupid]"] = $usergroup['vbblog_general_permissions']; } $category = $vbulletin->vbblog['categorycache']["0"]; cache_category_permissions($category, $grouppermissions, $permcache); build_datastore('blogcategorycache', serialize($category), 1); // Update blog stats since category permission affects the latest entry build_blog_stats(); }