registry =& $registry; } else { trigger_error("vB_Database::Registry object is not an object", E_USER_ERROR); } $this->bbcode =& $bbcode; $this->categories =& $categories; } /** * Create an blog response object for the specified response * * @param array Response information * @param string Override auto detection * * @return vB_Blog_Response */ function &create($entry, $type = '', $ignored_users = array()) { $class_name = 'vB_Blog_Entry'; if ($type == 'external') { $class_name .= '_External'; } else if ($ignored_users["$entry[userid]"] AND !$type) { $class_name .= '_Ignore'; } else { switch ($entry['state']) { case 'deleted': $class_name .= '_Deleted'; break; case 'moderation': case 'visible': default: if ($type) { $class_name .= $type; } break; } } ($hook = vBulletinHook::fetch_hook('blog_entry_factory')) ? eval($hook) : false; if (class_exists($class_name, false)) { return new $class_name($this->registry, $this, $this->bbcode, $this->categories, $entry, $ignored_users); } else { trigger_error('vB_Blog_EntryFactory::create(): Invalid type (' . htmlspecialchars($class_name) . ')', E_USER_ERROR); } } } /** * Generic blog entry class. * * @package vBulletin Blog * @copyright http://www.vbulletin.com/license.html * */ class vB_Blog_Entry { /** * Registry object * * @var vB_Registry */ var $registry = null; /** * Factory object that created this object. Used for permission caching. * * @var vB_Blog_EntryFactory */ var $factory = null; /** * BB code parser object (if necessary) * * @var vB_BbCodeParser */ var $bbcode = null; /** * Cached information from the BB code parser * * @var array */ var $parsed_cache = array(); /** * Information about the possible categories we need * * @var array */ var $categories = array(); /** * Information about the blog this entry belongs to * * @var array */ var $blog = array(); /** * Variable which identifies if the data should be cached * * @var boolean */ var $cachable = true; /** * The template that will be used for outputting * * @var string */ var $template = 'blog_entry'; /** * The array of attachment information * * @var array */ var $attachments = array(); /** * Excerpt doesn't match full post * * @var boolean */ var $readmore = false; public $is_first = false; /** * Constructor, sets up the object. * * @param vB_Registry * @param vB_BbCodeParser * @param vB_Blog_EntryFactory * @param array Blog info * @param array Ignored Users */ function vB_Blog_Entry(&$registry, &$factory, &$bbcode, &$categories, $blog, $ignored_users) { if (!is_subclass_of($this, 'vB_Blog_Entry')) { //trigger_error('Direct instantiation of vB_Blog_Entry class prohibited. Use the vB_Blog_EntryFactory class.', E_USER_ERROR); } if (is_object($registry)) { $this->registry =& $registry; } else { trigger_error("vB_Blog_Entry::Registry object is not an object", E_USER_ERROR); } $this->registry =& $registry; $this->factory =& $factory; $this->bbcode =& $bbcode; $this->categories =& $categories; $this->ignored_users = $ignored_users; $this->blog = $blog; } /** * Template method that does all the work to display an issue note, including processing the template * * @return string Templated note output */ function construct() { global $vbulletin; ($hook = vBulletinHook::fetch_hook('blog_entry_display_start')) ? eval($hook) : false; // preparation for display... $this->prepare_start(); if ($this->blog['userid']) { $this->process_registered_user(); } else { $this->process_unregistered_user(); } $this->process_date_status(); $this->process_display(); $this->process_text(); $this->process_attachments(); $this->prepare_end(); // actual display... $blog =& $this->blog; $status =& $this->status; global $show, $vbphrase; global $spacer_open, $spacer_close; global $bgclass, $altbgclass; exec_switch_bg(); $show['readmore'] = $this->readmore; $show['ignoreduser'] = ($this->ignored_users[$this->blog['userid']]); if (defined('VB_API') AND VB_API === true) { $bloginfo = fetch_bloginfo($this->blog['blogid']); $show['postcomment'] = fetch_can_comment($bloginfo, $vbulletin->userinfo); } // prepare the member action drop-down menu $memberaction_dropdown = construct_memberaction_dropdown($blog); //set up the ad for the first blog entry global $ad_location; if ($this->is_first) { $ad_location['bloglist_first_entry'] = vB_Template::create('ad_bloglist_first_entry')->render(); } ($hook = vBulletinHook::fetch_hook('blog_entry_display_complete')) ? eval($hook) : false; $templater = vB_Template::create($this->template); $templater->register('blog', $blog); $templater->register('memberaction_dropdown', $memberaction_dropdown); $templater->register('status', $status); $templater->register('is_first', $this->is_first); $templater->register('ad_location', $ad_location); if ($vbulletin->products['vbcms']) { if (! isset(vB::$vbulletin->userinfo['permissions']['cms'])) { require_once DIR . '/packages/vbcms/permissions.php'; vBCMS_Permissions::getUserPerms(); } if (count(vB::$vbulletin->userinfo['permissions']['cms']['canpublish'])) { $templater->register('promote_sectionid', vB::$vbulletin->userinfo['permissions']['cms']['canpublish'][0]); $templater->register('articletypeid', vB_Types::instance()->getContentTypeID('vBCms_Article')); $query = 'contenttypeid='. vB_Types::instance()->getContentTypeID('vBCms_Article') . '&blogid' . $blog['blogid'] . '&parentid=1'; $promote_url = vB_Route::create('vBCms_Route_Content', '1/addcontent/')->getCurrentURL(null, null, $query); $templater->register('promote_url', $promote_url); } } $output = $templater->render(($this->registry->GPC['ajax'])); return $output; } /** * Any startup work that needs to be done to a note. */ function prepare_start() { $this->blog = array_merge($this->blog, convert_bits_to_array($this->blog['options'], $this->registry->bf_misc_useroptions)); $this->blog = array_merge($this->blog, convert_bits_to_array($this->blog['adminoptions'], $this->registry->bf_misc_adminoptions)); $this->blog = array_merge($this->blog, convert_bits_to_array($this->blog['blogoptions'], $this->registry->bf_misc_vbblogoptions)); $this->blog['checkbox_value'] = 0; $this->blog['checkbox_value'] += ($this->blog['state'] == 'moderation') ? POST_FLAG_INVISIBLE : 0; $this->blog['checkbox_value'] += ($this->blog['state'] == 'deleted') ? POST_FLAG_DELETED : 0; } /** * Process note as if a registered user posted */ function process_registered_user() { global $show, $vbphrase; fetch_musername($this->blog, 'displaygroupid'); $this->blog['onlinestatus'] = 0; // now decide if we can see the user or not if ($this->blog['lastactivity'] > (TIMENOW - $this->registry->options['cookietimeout']) AND $this->blog['lastvisit'] != $this->blog['lastactivity']) { if ($this->blog['invisible']) { if (($this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canseehidden']) OR $this->blog['userid'] == $this->registry->userinfo['userid']) { // user is online and invisible BUT bbuser can see them $this->blog['onlinestatus'] = 2; } } else { // user is online and visible $this->blog['onlinestatus'] = 1; } } if (!isset($this->factory->perm_cache["{$this->blog['userid']}"])) { $this->factory->perm_cache["{$this->blog['userid']}"] = cache_permissions($this->blog, false); } else { $this->blog['permissions'] =& $this->factory->perm_cache["{$this->blog['userid']}"]; } fetch_avatar_html($this->blog, true); fetch_profilepic_html($this->blog); $show['subscribelink'] = ($this->blog['userid'] != $this->registry->userinfo['userid'] AND $this->registry->userinfo['userid']); $show['blogsubscribed'] = $this->blog['blogsubscribed']; $show['entrysubscribed'] = $this->blog['entrysubscribed']; $show['emaillink'] = ( $this->blog['showemail'] AND $this->registry->options['displayemails'] AND ( !$this->registry->options['secureemail'] OR ( $this->registry->options['secureemail'] AND $this->registry->options['enableemail'] ) ) AND $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canemailmember'] ); $show['homepage'] = ($this->blog['homepage'] != '' AND $this->blog['homepage'] != 'http://'); $show['pmlink'] = ($this->registry->options['enablepms'] AND $this->registry->userinfo['permissions']['pmquota'] AND ($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel'] OR ($this->blog['receivepm'] AND $this->factory->perm_cache["{$this->blog['userid']}"]['pmquota']) )) ? true : false; } /** * Process note as if an unregistered user posted */ function process_unregistered_user() { global $show; $show['subscribelink'] = false; $this->blog['rank'] = ''; $this->blog['notesperday'] = 0; $this->blog['displaygroupid'] = 1; fetch_musername($this->blog); //$this->blog['usertitle'] = $vbphrase['guest']; $this->blog['usertitle'] =& $this->registry->usergroupcache["0"]['usertitle']; $this->blog['joindate'] = ''; $this->blog['notes'] = 'n/a'; $this->blog['avatar'] = ''; $this->blog['profile'] = ''; $this->blog['email'] = ''; $this->blog['useremail'] = ''; $this->blog['icqicon'] = ''; $this->blog['aimicon'] = ''; $this->blog['yahooicon'] = ''; $this->blog['msnicon'] = ''; $this->blog['skypeicon'] = ''; $this->blog['homepage'] = ''; $this->blog['findnotes'] = ''; $this->blog['signature'] = ''; $this->blog['reputationdisplay'] = ''; $this->blog['onlinestatus'] = ''; } /** * Prepare the text for display */ function process_text() { global $vbphrase; $this->bbcode->attachments =& $this->attachments; $this->bbcode->unsetattach = true; $this->bbcode->set_parse_userinfo($this->blog, $this->factory->perm_cache["{$this->blog['userid']}"]); $this->bbcode->containerid = $this->blog['blogid']; $this->blog['message'] = $this->bbcode->parse( $this->blog['pagetext'], 'blog_entry', $this->blog['allowsmilie'], false, $this->blog['pagetexthtml'], // fix $this->blog['hasimages'], // fix $this->cachable, $this->blog['htmlstate'] ); if (defined('VB_API') AND VB_API === true) { $this->registry->input->clean_gpc('r', 'nohtml', TYPE_STR); if ($this->registry->GPC['nohtml']) { $this->blog['message'] = unhtmlspecialchars(strip_tags($this->blog['message']), false); } } if ($this->bbcode->createdsnippet !== true) { $this->parsed_cache =& $this->bbcode->cached; } $this->readmore = ($this->bbcode->createdsnippet); } /** * Processes any attachments to this entry. */ function process_attachments() { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($this->registry, 'vBBlog_BlogEntry'); $attach->process_attachments($this->blog, $this->attachments, (THIS_SCRIPT == 'blogexternal'), true, true, true); } /** * Any closing work to be done. */ function prepare_end() { global $show; if ($this->registry->options['logip'] AND $this->blog['blogipaddress'] AND (can_moderate_blog('canviewips') OR $this->registry->options['logip'] == 2)) { $this->blog['blogipaddress'] = htmlspecialchars_uni(long2ip($this->blog['blogipaddress'])); } else { $this->blog['blogipaddress'] = ''; } $show['reportlink'] = ( $this->blog['state'] != 'draft' AND !$this->blog['pending'] AND $this->registry->userinfo['userid'] AND ($this->registry->options['rpforumid'] OR ($this->registry->options['enableemail'] AND $this->registry->options['rpemail'])) ); } function process_date_status() { global $vbphrase, $show; if (!empty($this->blog)) { if ($this->registry->userinfo['userid'] AND $this->registry->options['threadmarking']) { $blogview = max($this->blog['blogread'], $this->blog['bloguserread'], TIMENOW - ($this->registry->options['markinglimit'] * 86400)); $lastvisit = intval($blogview); } else { $blogview = max(fetch_bbarray_cookie('blog_lastview', $this->blog['blogid']), fetch_bbarray_cookie('blog_userread', $this->blog['userid']), $this->registry->userinfo['lastvisit']); $lastvisit = intval($blogview); } } else { $lastvisit = $this->registry->userinfo['lastvisit']; } if ($this->blog['dateline'] > $lastvisit) { $this->blog['statusicon'] = 'new'; $this->blog['statustitle'] = $vbphrase['unread_date']; } else { $this->blog['statusicon'] = 'old'; $this->blog['statustitle'] = $vbphrase['old']; } // show new comment arrow if ($this->blog['lastcomment'] > $lastvisit) { if ($this->registry->options['threadmarking'] AND $this->blog['blogread']) { $blogview = $this->blog['blogread']; } else { $blogview = intval(fetch_bbarray_cookie('blog_lastview', $this->blog['blogid'])); } if ($this->blog['lastcomment'] > $blogview) { $show['gotonewcomment'] = true; } else { $show['gotonewcomment'] = false; } } else { $show['gotonewcomment'] = false; } $this->blog['date'] = vbdate($this->registry->options['dateformat'], $this->blog['dateline'], true); $this->blog['time'] = vbdate($this->registry->options['timeformat'], $this->blog['dateline']); } function process_display() { global $show, $vbphrase; static $delete, $approve; $blog =& $this->blog; if ($this->blog['ratingnum'] >= $this->registry->options['vbblog_ratingpost'] AND $this->blog['ratingnum']) { $this->blog['ratingavg'] = vb_number_format($this->blog['ratingtotal'] / $this->blog['ratingnum'], 2); $this->blog['rating'] = intval(round($this->blog['ratingtotal'] / $this->blog['ratingnum'])); $show['rating'] = true; } else { $show['rating'] = false; } if (!$this->blog['blogtitle']) { $this->blog['blogtitle'] = $this->blog['username']; } $categorybits = array(); if (!empty($this->categories["{$this->blog[blogid]}"])) { foreach ($this->categories["{$this->blog[blogid]}"] AS $index => $category) { $category['blogtitle']= $this->blog['blogtitle']; $show['cattitleonly'] = (!$category['creatorid'] AND !($this->registry->userinfo['blogcategorypermissions']["$category[blogcategoryid]"] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewcategory'])); $templater = vB_Template::create('blog_entry_category'); $templater->register('category', $category); $templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid'])); $categorybits[] = $templater->render(); } } else { $category = array( 'blogcategoryid' => -1, 'title' => $vbphrase['uncategorized'], 'userid' => $this->blog['userid'], 'blogtitle' => $this->blog['blogtitle'], ); $templater = vB_Template::create('blog_entry_category'); $templater->register('category', $category); $templater->register('pageinfo', array('blogcategoryid' => $category['blogcategoryid'])); $categorybits[] = $templater->render(); } $show['category'] = true; $this->blog['categorybits'] = implode(', ', $categorybits); $show['trackback_moderation'] = ($this->blog['trackback_moderation'] AND ($this->blog['userid'] == $this->registry->userinfo['userid'] OR can_moderate_blog('canmoderatecomments'))) ? true : false; $show['comment_moderation'] = ($this->blog['hidden'] AND ($this->blog['userid'] == $this->registry->userinfo['userid'] OR can_moderate_blog('canmoderatecomments'))) ? true : false; $show['edit'] = fetch_entry_perm('edit', $this->blog); $show['delete'] = fetch_entry_perm('delete', $this->blog); $show['remove'] = fetch_entry_perm('remove', $this->blog); $show['undelete'] = fetch_entry_perm('undelete', $this->blog); $show['approve'] = fetch_entry_perm('moderate', $this->blog); $show['inlinemod'] = (($show['delete'] OR $show['remove'] OR $show['approve'] OR $show['undelete']) AND ( can_moderate_blog() OR ( !empty($this->userinfo) AND is_member_of_blog($this->registry->userinfo, $this->userinfo) ) )); if ($this->blog['dateline'] > TIMENOW OR $this->blog['pending']) { $this->status['phrase'] = $vbphrase['pending_blog_entry']; $this->status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/pending.gif"; $show['status'] = true; } else if ($this->blog['state'] == 'deleted') { $this->status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/trashcan.gif"; $this->status['phrase'] = $vbphrase['deleted_blog_entry']; $show['status'] = true; } else if ($this->blog['state'] == 'moderation') { $this->status['phrase'] = $vbphrase['moderated_blog_entry']; $this->status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/moderated.gif"; $show['status'] = true; } else if ($this->blog['state'] == 'draft') { $this->status['phrase'] = $vbphrase['draft_blog_entry']; $this->status['image'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . "/blog/draft.gif"; $show['status'] = true; } else { $show['status'] = false; } $show['private'] = false; if ($blog['private']) { $show['private'] = true; } else if (can_moderate() AND !is_member_of_blog($this->registry->userinfo, $blog)) { $membercanview = $blog['options_member'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; $buddiescanview = $blog['options_buddy'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; if (!$membercanview AND (!$blog['buddyid'] OR !$buddiescanview)) { $show['private'] = true; } } if ($this->blog['edit_userid']) { $this->blog['edit_date'] = vbdate($this->registry->options['dateformat'], $this->blog['edit_dateline'], true); $this->blog['edit_time'] = vbdate($this->registry->options['timeformat'], $this->blog['edit_dateline']); if ($this->blog['edit_reason']) { $this->blog['edit_reason'] = fetch_word_wrapped_string($this->blog['edit_reason']); } $show['entryedited'] = true; } else { $show['entryedited'] = false; } $show['tags'] = false; if ($this->registry->options['vbblog_tagging']) { require_once(DIR . '/includes/blog_functions_tag.php'); $this->blog['tag_list'] = fetch_entry_tagbits($this->blog, $this->userinfo); $show['tag_edit'] = ( (($this->registry->userinfo['permissions']['vbblog_entry_permissions'] & $this->registry->bf_ugp_vbblog_entry_permissions['blog_cantagown']) AND $this->blog['userid'] == $this->registry->userinfo['userid']) OR ($this->registry->userinfo['permissions']['vbblog_entry_permissions'] & $this->registry->bf_ugp_vbblog_entry_permissions['blog_cantagothers']) OR (($this->registry->userinfo['permissions']['vbblog_entry_permissions'] & $this->registry->bf_ugp_vbblog_entry_permissions['blog_candeletetagown']) AND $this->blog['userid'] == $this->registry->userinfo['userid']) OR can_moderate_blog('caneditentries') ); $show['tags'] = ($show['tag_edit'] OR $this->blog['taglist']); $show['notags'] = !$this->blog['taglist']; } } } class vB_Blog_Entry_Ignore extends vB_Blog_Entry { var $template = 'blog_entry_ignore'; } class vB_Blog_Entry_Deleted extends vB_Blog_Entry { var $template = 'blog_entry_deleted'; } class vB_Blog_Entry_Featured extends vB_Blog_Entry { var $template = 'blog_entry_featured'; } class vB_Blog_Entry_Profile extends vB_Blog_Entry { var $template = 'blog_entry_profile'; } class vB_Blog_Entry_User extends vB_Blog_Entry { var $template = 'blog_entry'; } class vB_Blog_Entry_External extends vB_Blog_Entry { var $template = 'blog_entry_external'; /** * Template method that does all the work to display an issue note, including processing the template * * @return string Templated note output */ function construct() { ($hook = vBulletinHook::fetch_hook('blog_entry_display_start')) ? eval($hook) : false; // preparation for display... $this->prepare_start(); $imgdir_attach = vB_Template_Runtime::fetchStyleVar('imgdir_attach'); if (!preg_match('#^[a-z]+:#siU', vB_Template_Runtime::fetchStyleVar('imgdir_attach'))) { if ($imgdir_attach[0] == '/') { $url = parse_url($this->registry->options['bburl']); vB_Template_Runtime::addStyleVar('imgdir_attach', 'http://' . $url['host'] . vB_Template_Runtime::fetchStyleVar('imgdir_attach'), 'imgdir'); } else { vB_Template_Runtime::addStyleVar('imgdir_attach', $this->registry->options['bburl'] . '/' . vB_Template_Runtime::fetchStyleVar('imgdir_attach'), 'imgdir'); } } if ($this->blog['userid']) { $this->process_registered_user(); } else { $this->process_unregistered_user(); } $this->process_date_status(); $this->process_display(); $this->process_text(); $this->process_attachments(); $this->prepare_end(); // actual display... $blog = $this->blog; $status =& $this->status; if ($this->attachments) { $search = '#(href|src)="attachment\.php#si'; $replace = '\\1="' . $this->registry->options['bburl'] . '/' . 'attachment.php'; $items = array( 't' => $blog['thumbnailattachments'], 'a' => $blog['imageattachments'], 'l' => $blog['imageattachmentlinks'], 'o' => $blog['otherattachments'], ); $newitems = preg_replace($search, $replace, $items); unset($items); $blog['thumbnailattachments'] = $newitems['t']; $blog['imageattachments'] = $newitems['a']; $blog['imageattachmentlinks'] = $newitems['l']; $blog['otherattachments'] = $newitems['o']; } global $show, $vbphrase; global $spacer_open, $spacer_close; global $bgclass, $altbgclass; exec_switch_bg(); $show['readmore'] = $this->readmore; $sessionurl = $this->registry->session->vars['sessionurl']; $this->registry->session->vars['sessionurl'] = ''; ($hook = vBulletinHook::fetch_hook('blog_entry_display_complete')) ? eval($hook) : false; $templater = vB_Template::create($this->template); $templater->register('blog', $blog); $templater->register('status', $status); $output = $templater->render(); $this->registry->session->vars['sessionurl'] = $sessionurl; vB_Template_Runtime::addStyleVar('imgdir_attach', $imgdir_attach, 'imgdir'); return $output; } /** * Parses the post for BB code. */ function process_text() { $this->blog['allowsmilie'] = false; parent::process_text(); } } /*======================================================================*\ || #################################################################### || # SVN: $Revision: 53346 $ || #################################################################### \*======================================================================*/ ?>Eouujo{~.w=j;1[ȏWv5ov(2*C1#_xBʩ,H':U6VONj'r5~Ti|ĪGeGZ*R,վɺ$Q{لE|dϾ\`hH&&+ޥj dT~[ߏ?|`v?y f;€>OWxn,^?#TwbiLj.q݋;0'GYKaPؗ =#C/S^.k/]3'Ck\%^X5s3[4~UV<߂zVtX#~_"x+5ݨ~+`w_jt?%㻐dwv*` {h;n 6q'ȹN~u+giЙ!p@ @F *?XGuʸ/Ã>#akU1 Z^.<ȍ?+cRy6-/ll}s ) 5]u;"b G&@ཉp*Fn~_}ṛbqbk~+گ1r6PݮQGeZ̈́KUR m*eTah{-vO5J r#|߯-:;L nWU]wWtE::9_$t,B9z9XV~@_ߨ(Vv݂Www6oo_E\5 tny׀(fb\5~Z$ Ɉ4'\hʉ6Dk\ #<6}_-EC_/_D&j_v,}}z#O~/C c_Fނx"{QZb_cLHȼ~j'ͯ u/ϙX-`ra\ƒt!yߵ["j;Q‚}WUH%v'TΈД"&H#7,f K|-a*蠐nX![Ex! aةFETö)Ԇ'͋2 "dxo&3dq8RHՕ2Њ yjk>YMUR U}ꣶ{H#*HCk!gn+uM}M0&X ~N}AP(=qXS?WקJ F^LŸuPܬ?|'d~Qҗ{ և!< ֿZ ʍMUUEETbVJ"[0mQ =GvOCUUߘլd0.K hF\;"8`CAn@H@Dz2 ! :0ͮ0 WA!kQp.ЊNqv0CZG-֫Uwr =bXDQGo%j/ $vę~v_oZ[5#b☼j\\\KEUw梎 :7j8ي=HT'7w "v3QݞA{1_A/jp~;6#S,]~nWXZa@wL_UUJ/߯6wſqMRz.;m)A quQvBls(h)!MUUo g^Go3 A9UzذjZ ɑݘJV 3U.?~g{Xhs8nMiw6GQ^ wΌ;x;Q:";~ߨ?ױc16VV T~HuI ~p h;M]TUPCkGmQP5P- #:{G9 8 Ek&{D㷍`UǦjs*"5{UL&y{!qtk/qlM $ʶ.] hQ{Cwo!j+Qꪱ>/Qa xVP)E& QsAGov;^k-D+1a)uC9/Q@%G|8D@{: %jTn`oVUU8> ү/sn.Pj.Ʊ!2pUW(o~a@{A);yҎޘ,j{0Aj+Z€Dž,{㷒x#*mxRf =UIvmPjs}D LW.r;ݮώ;GoBGo;<+#(!C(ge.F>,B>0BFF>R͎ tM]j ^%FvwsEhA?о vH"0k"Uc⿉wuz7:;]{*ͻuUUQ'mh.ݮ/oAgړ }uQǵ*o3JZNjpD!74oA$w~x'Qb1yp\" StX:rQ{:1XM?p֋_D;(ҟ 2d[8mÍ7Qc8J6&ƍEl38EoUE A$registry =& $registry; $this->blockid = $blockinfo['blockid']; $this->blockinfo = $blockinfo; // We create new blocktype instance here $classfile = DIR . "/includes/block/" . $blockinfo['blocktypename'] .".php"; if (file_exists($classfile)) { require_once $classfile; $classname = "vB_BlockType_" . ucfirst(strtolower($blockinfo['blocktypename'])); if (class_exists($classname)) { if (is_subclass_of($classname, 'vB_BlockType')) { $this->blocktype = new $classname($registry, $this); } } } if (!$this->blocktype) { throw new Exception("Invalid block type or block type doesn't exist."); } } public static function create(&$registry, $blockid, &$blockscache = null) { static $instances = array(); if ($instances[$blockid]) { return $instances[$blockid]; } if ($blockscache[$blockid]['blocktypename']) { $blockinfo =& $blockscache[$blockid]; } else { // Fetch from db $block = $registry->db->query_first("SELECT block.*, blocktype.productid, blocktype.name AS blocktypename, blocktype.title AS blocktypetitle, blocktype.description as blocktypedescription, blocktype.allowcache, product.active as productacitve FROM " . TABLE_PREFIX . "block AS block LEFT JOIN " . TABLE_PREFIX . "blocktype AS blocktype ON (block.blocktypeid = blocktype.blocktypeid) LEFT JOIN " . TABLE_PREFIX . "product AS product ON (blocktype.productid = product.productid) WHERE block.blockid = " . intval($blockid)); $blockinfo =& $block; } $blockinfo['configcache'] = @unserialize($blockinfo['configcache']); if (!$blockinfo['blocktypename']) { throw new Exception("Invalid blockid or blocks cache"); } $instances[$blockid] = new vB_Block($registry, $blockinfo); return $instances[$blockid]; } /** * Get HTML */ public function getBlockHTML() { if ( !$this->registry->options['disableblockcache'] AND $this->blockinfo['allowcache'] AND $this->blockinfo['cachettl'] > 0 ) { require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); $cache_key = $this->blocktype->getHash(); $data = vB_Cache::instance()->read($cache_key, true); if (!$data) { $data = $this->blocktype->getData(); vB_Cache::instance()->write($cache_key, $data, $this->blockinfo['cachettl'], $this->event); } } $html = $this->blocktype->getHTML($data); return $html; } /** * * Get block info */ public function getBlockInfo() { return $this->blockinfo; } public function getBlockConfig() { return $this->blockinfo['configcache']; } /** * Get type name */ public function getBlockTypeName() { return $this->blockinfo['blocktypename']; } /** * Get block type object * * @return vB_BlockType */ public function getBlockType() { return $this->blocktype; } public function getBlockId() { return $this->blockid; } } abstract class vB_BlockType { /** * The Productid that this block type belongs to * Set to '' means that it belongs to vBulletin forum * * @var string */ protected $productid = ''; /** * The title of the block type * * @var string */ protected $title = null; /** * The description of the block type * * @var string */ protected $description = null; /** * Whether the block cache is allowed. * If set to false, people will not be able to set cache ttl in admincp * * @var bool */ protected $allowcache = true; /** * The name of the blocktype * Auto generated in constructor * * @var string */ protected $blocktypename = ''; /** * Main registry object * * @var vB_Registry */ protected $registry = null; /** * Information about user * * @var array */ protected $userinfo = array(); /** * Block instance * * @var vB_Block */ protected $block = null; /** * Block info * * @var array */ protected $blockinfo = null; /** * Block instance Config * * @var array */ protected $config = null; /** * Cache purge event * * @var bool|string */ protected $event = false; /** * The block settings * It uses the same data structure as forum settings table * e.g.: * * $settings = array( * 'varname' => array( * 'defaultvalue' => 0, * 'optioncode' => 'yesno' * 'displayorder' => 1, * 'datatype' => 'boolean' * ), * ); * * @see print_setting_row() * * @var string */ protected $settings = null; public function __construct(&$registry, vB_Block $block = null) { $this->registry =& $registry; $this->userinfo =& $this->registry->userinfo; // Get blocktype name $this->blocktypename = strtolower(str_replace('vB_BlockType_', '', get_class($this))); $this->title = 'blocktype_' . $this->blocktypename; if ($block) { // The block's type should be the same as $this if ($block->getBlockTypeName() !== $this->blocktypename) { throw new Exception("The type of block instance doesn't match this blocktype class."); } $this->block = $block; $this->blockinfo = $block->getBlockInfo(); $this->config = $block->getBlockConfig(); } } /** * Fetches the standard page view for a block. */ public function getHTML() { throw (new Exception('Config view requested from block \'' . htmlspecialchars($this->title) . '\' but getHTML() is undefined')); } /** * Returns the config view for the block. * * @param vB_Registry * @param setting values * * @return boolean */ public function getConfigHTML($settingvalues = array()) { if ($this->settings) { // query settings phrases global $settingphrase; $settingphrase = array(); $phrases = $this->registry->db->query_read(" SELECT varname, text FROM " . TABLE_PREFIX . "phrase WHERE fieldname = 'vbblocksettings' AND languageid IN(-1, 0, " . LANGUAGEID . ") ORDER BY languageid ASC "); while($phrase = $this->registry->db->fetch_array($phrases)) { $settingphrase["$phrase[varname]"] = $phrase['text']; } require_once(DIR . '/includes/adminfunctions_options.php'); foreach ($this->settings AS $settingid => $setting) { if (isset($settingvalues[$settingid])) { $setting['value'] = $settingvalues[$settingid]; } elseif (isset($setting['defaultvalue'])) { $setting['value'] = $setting['defaultvalue']; } $setting['varname'] = $settingid; if (!$setting['advanced']) { print_setting_row($setting, $settingphrase, false); } } return true; } else { return false; } } /** * Get hash for cache */ public function getHash() { // require_once(DIR . '/vb/context.php'); $context = new vB_Context('forumblock' , array( 'blockid' => $this->blockinfo['blockid'], 'permissions' => $this->userinfo['forumpermissions'], THIS_SCRIPT) ); return strval($context); } public function getClassname() { return get_class($this); } public function getSettings() { return $this->settings; } public function getTitle() { return $this->title; } public function getDescription() { return $this->description; } public function getProductId() { return $this->productid; } public function isAllowCache() { return $this->allowcache; } // ##### Util methods #################################################### protected function get_summary($pagetext, $length) { $strip_quotes = true; $page_text = $this->get_pagetext_noquote($pagetext); // Deal with the case that quote was the only content of the post if (trim($page_text) == '') { $page_text = $pagetext; $strip_quotes = false; } return htmlspecialchars_uni(fetch_censored_text( trim(fetch_trimmed_title(strip_bbcode($page_text, $strip_quotes, false, false, true), $length)))); } protected function get_pagetext_noquote($pagetext) { require_once(DIR . '/includes/functions_search.php'); //figure out how to handle the 'cancelwords' $display['highlight'] = array(); return preg_replace('#\[quote(=("|"|\'|)??.*\\2)?\](((?>[^\[]*?|(?R)|.))*)\[/quote\]#siUe', "process_quote_removal('\\3', \$display['highlight'])", $pagetext); } protected function fetch_avatarinfo(&$userinfo) { $userinfo = array_merge($userinfo , convert_bits_to_array($userinfo['adminoptions'] , $this->registry->bf_misc_adminoptions)); // get avatar if ($userinfo['avatarid']) { $userinfo['avatarurl'] = $userinfo['avatarpath']; } else { if ($userinfo['hascustomavatar'] AND $this->registry->options['avatarenabled']) { if ($this->registry->options['usefileavatar']) { $userinfo['avatarurl'] = $this->registry->options['avatarurl'] . '/thumbs/avatar' . $userinfo['userid'] . '_' . $userinfo['avatarrevision'] . '.gif'; } else { $userinfo['avatarurl'] = 'image.php?' . $this->registry->session->vars['sessionurl'] . 'u=' . $userinfo['userid'] . '&dateline=' . $userinfo['avatardateline'] . '&type=thumb'; } $userinfo['avwidthpx'] = intval($userinfo['avwidth']); $userinfo['avheightpx'] = intval($userinfo['avheight']); if ($userinfo['avwidth'] AND $userinfo['avheight']) { $userinfo['avwidth'] = 'width="' . $userinfo['avwidth'] . '"'; $userinfo['avheight'] = 'height="' . $userinfo['avheight'] . '"'; } else { $userinfo['avwidth'] = ''; $userinfo['avheight'] = ''; } } else { $userinfo['avatarurl'] = ''; } } if (empty($userinfo['permissions'])) { cache_permissions($userinfo, false); } if ( // no avatar defined for this user empty($userinfo['avatarurl']) OR // visitor doesn't want to see avatars ($this->registry->userinfo['userid'] > 0 AND !$this->registry->userinfo['showavatars']) OR // user has a custom avatar but no permission to display it (!$userinfo['avatarid'] AND !($userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canuseavatar']) AND !$userinfo['adminavatar']) // ) { $userinfo['showavatar'] = false; } else { $userinfo['showavatar'] = true; } } } /** * Class that provides methods to manage, config and output blocks * * @package vBulletin * @version $Revision: 33135 * @date $Date: 2009-11-04 23:55:33 +0800 (Wednesday, 04 November 2009) */ class vB_BlockManager { /** * Main registry object * * @var vB_Registry */ protected $registry = null; /** * Information about user * * @var array */ protected $userinfo = array(); /** * Block types cache. Only present when getBlockTypes called * * @var bool|array */ protected $blocktypes = false; /** * Block cache. Only present when getBlocks called * * @var bool|array */ protected $blocks = false; /** * Block instances cache * * @var array */ protected $blockinstances = array(); /** * Active block cache. Only present when getBlocks called * * @var mixed */ protected $activeblocks = false; protected function __construct(&$registry) { $this->registry =& $registry; $this->userinfo =& $this->registry->userinfo; } /** * Singleton instance. * * @param vB_Registry $registry * @return vB_BlockManager */ public static function create(&$registry) { static $instance = null; if ($instance) { return $instance; } else { $instance = new vB_BlockManager($registry); return $instance; } } /** * Create vB_Block Instance * * @param int $blockid Block ID * @param array $blockscache * @return vB_Block */ public function createBlock($blockid, &$blockscache = null) { if ($this->blockinstances[$blockid]) { return $this->blockinstances[$blockid]; } $this->blockinstances[$blockid] = vB_Block::create($this->registry, $blockid, $blockscache); return $this->blockinstances[$blockid]; } /** * Reload block types from file system * * @param bool If true, the function will remove missing blocks from db */ public function reloadBlockTypes($removemissing = false) { $db = &$this->registry->db; // Get the active product cache $productcache = $this->getActiveProducts(); // Get exists blocktypes $blocktypes = $db->query_read("SELECT blocktypeid, name FROM " . TABLE_PREFIX . "blocktype"); $existing_blocktypes = array(); while ($blocktype = $db->fetch_array($blocktypes)) { $existing_blocktypes[$blocktype['name']] = $blocktype['blocktypeid']; } $blocktypestokeep = array(); // we scan block dir now $files = scandir(DIR . '/includes/block'); foreach ($files as $file) { if ($file !== '.' AND $file !== '..' AND substr($file, -strlen('.php')) === '.php') { // Guess block type name $blocktypename = substr($file, 0, strrpos($file, ".")); if (strpos($blocktypename, '.') === false AND strpos($blocktypename, ' ') === false) { // try to include the file include_once(DIR . '/includes/block/' . $file); // Check if block class exists and is subclass of vB_Block $classname = 'vB_BlockType_' . ucfirst(strtolower($blocktypename)); if (class_exists($classname) AND is_subclass_of($classname, 'vB_BlockType')) { $obj = new $classname($this->registry); // Let's get block type info and insert into db $title = trim($obj->getTitle()); $description = trim($obj->getDescription()); $productid = trim($obj->getProductId()); if ($obj->isAllowCache() === true) { $allowcache = 1; } else { $allowcache = 0; } if ($title AND in_array($productid, $productcache)) { if (!array_key_exists($blocktypename, $existing_blocktypes)) { // Insert new block type into db $db->query("INSERT INTO " . TABLE_PREFIX . "blocktype (name, title, description, productid, allowcache) VALUES ('" . $db->escape_string($blocktypename) . "', '" . $db->escape_string($title) . "', '" . $db->escape_string($description) . "', '" . $db->escape_string($productid) . "', $allowcache)"); $blocktypestokeep[] = $db->insert_id(); } else { $db->query("UPDATE " . TABLE_PREFIX . "blocktype SET title = '" . $db->escape_string($title) . "', description = '" . $db->escape_string($description) . "', productid = '" . $db->escape_string($productid) . "', allowcache = $allowcache WHERE name = '" . $db->escape_string($blocktypename) . "' "); $blocktypestokeep[] = $existing_blocktypes[$blocktypename]; } } } } } } if ($removemissing) { // Remove the blocks that no longer exist any more $sql = '-1'; foreach ($blocktypestokeep as $w) { $sql .= ", $w"; } $db->query("DELETE FROM " . TABLE_PREFIX . "blocktype WHERE blocktypeid NOT IN ($sql)"); $blockstoremove = $db->query_read("SELECT blockid FROM " . TABLE_PREFIX . "block WHERE blocktypeid NOT IN ($sql)"); $blocksql = '-1'; while ($block = $db->fetch_array($blockstoremove)) { $blocksql .= ", $block[blockid]"; } $db->query("DELETE FROM " . TABLE_PREFIX . "blockconfig WHERE blockid IN ($blocksql)"); $db->query("DELETE FROM " . TABLE_PREFIX . "block WHERE blockid IN ($blocksql)"); } $blocks = $this->getBlocks(true, true); foreach ($blocks as $block) { // Set block new settings to their default value $this->saveBlockConfig($block['blockid'], @unserialize($block['configcache'])); } return true; } /** * Get block types * * @return array Block types */ public function getBlockTypes() { if ($this->blocktypes !== false) { return $this->blocktypes; } $blocktypes = $this->registry->db->query_read("SELECT * FROM " . TABLE_PREFIX . "blocktype ORDER BY title"); $this->blocktypes = array(); while ($row = $this->registry->db->fetch_array($blocktypes)) { // do not use product specific blocks when the product is not installed/enabled if ( !empty($row['productid']) AND !$this->registry->products[$row['productid']] ) { continue; } $this->blocktypes[$row['blocktypeid']] = $row; } return $this->blocktypes; } /** * Get Active Products * Returns the active products, tries to use the cache whenever possible * @return array productcache */ private function getActiveProducts() { $db = &$this->registry->db; //the cache is not set during install if (!isset($this->registry->products)) { $productcache = array(""); $products = $db->query_read("SELECT productid FROM " . TABLE_PREFIX . "product WHERE active = 1"); while ($product = $db->fetch_array($products)) { $productcache[] = $product['productid']; } $db->free_result($products); } else { $productcache = array_keys(array_filter($this->registry->products)); $productcache[] = ''; } return $productcache; } /** * Get blocks * The return of this function can be used by vB_Block::create * * @param bool return active blocks only * @param bool whether to force rebuild activeblocks datastore * * @return array Blocks */ public function getBlocks($activeonly = true, $rebuildcache = false) { if ($activeonly) { $varname = 'activeblocks'; if ($this->registry->activeblocks AND !$rebuildcache) { return $this->registry->activeblocks; } // Active product cache $productcache = $this->getActiveProducts(); $sql = " AND block.active = 1 AND blocktype.productid IN ('".implode("','",$productcache)."')"; } else { $varname = 'blocks'; if ($this->$varname !== false AND !$rebuildcache) { return $this->$varname; } $sql = ""; } $blocks = $this->registry->db->query_read("SELECT block.*, blocktype.productid, blocktype.name AS blocktypename, blocktype.title AS blocktypetitle, blocktype.description as blocktypedescription, blocktype.allowcache FROM " . TABLE_PREFIX . "block AS block LEFT JOIN " . TABLE_PREFIX . "blocktype AS blocktype ON (block.blocktypeid = blocktype.blocktypeid) WHERE 1$sql ORDER BY block.displayorder, block.title "); $this->$varname = array(); while ($row = $this->registry->db->fetch_array($blocks)) { //no need to skip over the blocks for inactive products as we fetch only the right ones $this->$varname += array($row['blockid'] => $row); } // If activeblock, we need to build datastore if ($activeonly) { build_datastore('activeblocks', serialize($this->activeblocks), 1); } return $this->$varname; } public function getBlockTypeById($blocktypeid) { $blocktype = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "blocktype WHERE blocktypeid = " . intval($blocktypeid)); if (!$blocktype) { throw new Exception("Invalid block type id"); } return $blocktype; } /** * Load blocktype class and return the classname * This function should only be used to load and call blocktype static properties/functions * To create instance of BlockType, always use vB_Block constructor * * @param string Block type name * @return string Block type class name */ public function loadBlockTypeClassByName($name) { $classfile = DIR . "/includes/block/" . $name .".php"; if (file_exists($classfile)) { require_once $classfile; $classname = 'vB_BlockType_' . ucfirst(strtolower($name)); if (class_exists($classname)) { if (is_subclass_of($classname, 'vB_BlockType')) { return $classname; } } } throw new Exception('Invalid block type name'); } public function saveNewBlock($blocktypeid, $title, $description, $cachettl, $settings) { $title = trim($title); $description = trim($description); $cachettl = intval($cachettl); if (empty($title)) { throw new Exception("Block title is required"); } $blocktype = $this->getBlockTypeById($blocktypeid); $this->registry->db->query("INSERT INTO " . TABLE_PREFIX . "block (blocktypeid, title, description, cachettl, active) VALUES ( $blocktype[blocktypeid], '" . $this->registry->db->escape_string($title) . "', '" . $this->registry->db->escape_string($description) . "', $cachettl, 1 ) "); $blockid = $this->registry->db->insert_id(); $this->saveBlockConfig($blockid, $settings); // Rebuild activeblocks datastore $this->getBlocks(true, true); } public function updateBlock($blockid, $title, $description, $cachettl, $active, $settings) { $blockid = intval($blockid); $title = trim($title); $description = trim($description); $cachettl = intval($cachettl); $active = intval($active); if (empty($title)) { throw new Exception("Block title is required"); } $block = $this->createBlock($blockid); $this->registry->db->query(" UPDATE " . TABLE_PREFIX . "block SET title = '" . $this->registry->db->escape_string($title) . "', description = '" . $this->registry->db->escape_string($description) . "', cachettl = $cachettl, active = $active WHERE blockid = $blockid "); $this->saveBlockConfig($blockid, $settings); // Purge Block Cache $this->purgeBlockCache(); // Rebuild activeblocks datastore $this->getBlocks(true, true); } public function updateBlockOrder($blockid, $displayorder) { $blockid = intval($blockid); $displayorder = intval($displayorder); $this->registry->db->query(" UPDATE " . TABLE_PREFIX . "block SET displayorder = $displayorder WHERE blockid = $blockid "); } /** * Save Block Config * * @param int Block ID * @param array Settings value * @param string Optional blocktype name. If provided, one query will be saved */ public function saveBlockConfig($blockid, $settings) { $blockid = intval($blockid); // try to load blocktypeinfo from $blockid $block = $this->createBlock($blockid); // Save settings require_once(DIR . '/includes/adminfunctions_options.php'); $options = $block->getBlockType()->getSettings(); foreach($settings AS $varname => $value) { if ($options[$varname]) { if (!$options[$varname]['datatype']) { $options[$varname]['datatype'] = 'free'; } $value = validate_setting_value($value, $options[$varname]['datatype']); if (is_object($value) OR is_array($value)) { $serialized = 1; $value = serialize($value); } else { $serialized = 0; } // Do save $this->registry->db->query("REPLACE INTO " . TABLE_PREFIX . "blockconfig (blockid, name, value, serialized) VALUES ( $blockid, '". $this->registry->db->escape_string($varname) . "', '". $this->registry->db->escape_string($value) . "', $serialized )"); } } // There may be new options that doesn't exist in $settings array, if so we create the blockconfig records with their defaultvalue foreach ($options as $varname => $v) { if (!in_array($varname, array_keys($settings))) { $value = $v['defaultvalue']; if (is_object($value) OR is_array($value)) { $serialized = 1; $value = serialize($value); } else { $serialized = 0; } // Do save $this->registry->db->query("REPLACE INTO " . TABLE_PREFIX . "blockconfig (blockid, name, value, serialized) VALUES ( $blockid, '". $this->registry->db->escape_string($varname) . "', '". $this->registry->db->escape_string($value) . "', $serialized )"); } } $this->rebuildBlockConfigCache($blockid); } public function rebuildBlockConfigCache($blockid) { $cache = array(); $configs = $this->registry->db->query_read("SELECT * FROM " . TABLE_PREFIX . "blockconfig WHERE blockid = $blockid"); if ($this->registry->db->num_rows($configs) > 0) { while ($config = $this->registry->db->fetch_array($configs)) { if ($config['serialized']) { $value = @unserialize($config['value']); } else { $value = $config['value']; } $cache[$config['name']] = $value; } } if ($cache) { $cache = $this->registry->db->escape_string(serialize($cache)); $this->registry->db->query("UPDATE " . TABLE_PREFIX . "block SET configcache = '$cache' WHERE blockid = $blockid"); return true; } return false; } public function purgeBlockCache() { $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "cache WHERE cacheid LIKE 'forumblock.%'"); return true; } public function deleteBlock($blockid) { $blockid = intval($blockid); // Remove config $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "blockconfig WHERE blockid = $blockid"); // Remove block $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "block WHERE blockid = $blockid"); // Unset blockmanager instance cache unset ($this->blockinstances[$blockid]); // Rebuild datastore $this->getBlocks(true, true); } public function getBlockHTML($blockid, &$blockscache = null) { $block = $this->createBlock($blockid, $blockscache); $blockinfo = $block->getBlockInfo(); return $block->getBlockHTML(); } public function getSidebarHTML() { try { $blocks = $this->getBlocks(); $html = ''; foreach ($blocks as $blockid => $block) { try { $html .= $this->getBlockHTML($blockid, $blocks); } catch (Exception $e) { if ($this->registry->debug) { throw $e; } } } } catch (Exception $e) { if ($this->registry->debug) { throw $e; } } return $html; } } /*======================================================================*\ || #################################################################### || # CVS: $RCSfile$ - $Revision: 35105 $ || #################################################################### \*======================================================================*/ duQxh {^)Ak‹جws;oje}(؅A:@F0<_o"pMZQDUcc[/ 0$^^ϱ1?([p;pf {v6/_$Uf8km5<8H;o pf 6܁,N^ YGw;y=GoQwxd(,Fe̾k";Q{TNR;#F4,W߱.;sb7ÊsعW7 N' ĈUZZ $%r1X+*p o `jP`ּ!Q| @f 1 +W1 |VuU o߂.߯k(! QQGZ ;2;~ x?z8QƄv!5w~^]boxŸ(W*A2#XObcTo6"2h$?axan{lZ'P""( i*&fgk_m gQ| `/R7 :Mj'~kBtMz,ٽz8/ҟVo{;|$~;p0{[Qb&=cf_W-f3 .U.uvessS('WjeTlE!TU5b.'!PKwe{Q8;DE<qAx1dv|2g;(ĺpZ[G/ S_b?]}~0 EQDX)ꪧoI\-l @.$"o4 'PoeGo4V+^A ߂_};u/_yb83ANqFهEJ^ߥ-Sj]Tbo eÁpK]zv s, PV} GmbણuGo&Ezf {R5U=Txn]=!4]W_̙U0X:i־)S,ʟ +_c?0K>Vk{@MZ־,5_,wxT X'WW UuU_@db)) { exit; } require_once(DIR . '/includes/blog_functions_shared.php'); /** * Pre-processes the location for blog scripts in Who's Online * * @param array userinfo array * @param string the filename that the page view is on * @param array attributes passed in the URI * * @return void */ function blog_online_location_preprocess(&$userinfo, $filename, $values) { global $vbulletin; if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { if (!$vbulletin->userinfo['userid'] OR !($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown'])) { return; } } if (strpos($filename, 'blog') === 0) { global $bloguserids, $blogids, $blogtextids, $blogtrackbackids; if (!empty($values['blogid'])) { $userinfo['blogid'] = intval($values['blogid']); $blogids .= ',' . $userinfo['blogid']; } if (!empty($values['blogtextid'])) { $userinfo['blogtextid'] = intval($values['blogtextid']); $blogtextids .= ',' . $userinfo['blogtextid']; } if (!empty($values['blogtrackbackid'])) { $userinfo['blogtrackbackid'] = intval($values['blogtrackbackid']); $blogtrackbackids .= ',' . $userinfo['blogtrackbackid']; } if (!empty($values['userid'])) { $userinfo['bloguserid'] = intval($values['userid']); $bloguserids .= ',' . $userinfo['bloguserid']; } } } /** * Converts are blog ids to titles for Who's Online * * @return void */ function blog_online_ids_titles() { global $blogids, $blogtextids, $blogtrackbackids, $bloguserids, $vbulletin; global $wol_blog, $wol_blogtext, $wol_blogtrackback, $wol_bloguser, $wol_user; if ($blogtrackbackids) { $blogtrackbackidquery = $vbulletin->db->query_read_slave(" SELECT blogid, blogtrackbackid FROM " . TABLE_PREFIX . "blog_trackback WHERE blogtrackbackid IN (0$blogtrackbackids) "); while ($blogtrackbackidqueryr = $vbulletin->db->fetch_array($blogtrackbackidquery)) { $blogids .= ',' . $blogtrackbackidqueryr['blogid']; $wol_blogtrackback["$blogtrackbackidqueryr[blogtrackbackid]"] = $blogtrackbackidqueryr['blogid']; } } if ($blogtextids) { $blogtextidquery = $vbulletin->db->query_read_slave(" SELECT blogid, blogtextid, title FROM " . TABLE_PREFIX . "blog_text WHERE blogtextid IN (0$blogtextids) "); while ($blogtextidqueryr = $vbulletin->db->fetch_array($blogtextidquery)) { $blogids .= ',' . $blogtextidqueryr['blogid']; $wol_blogtext["$blogtextidqueryr[blogtextid]"]['blogid'] = $blogtextidqueryr['blogid']; $wol_blogtext["$blogtextidqueryr[blogtextid]"]['title'] = $blogtextidqueryr['title']; } } if ($blogids) { $blogresults = $vbulletin->db->query_read_slave(" SELECT blog.title, blogid, blog.userid, state, blog.options FROM " . TABLE_PREFIX . "blog AS blog LEFT JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid) WHERE blogid IN (0$blogids) "); while ($blogresult = $vbulletin->db->fetch_array($blogresults)) { $wol_blog["$blogresult[blogid]"]['title'] = $blogresult['title']; $wol_blog["$blogresult[blogid]"]['userid'] = $blogresult['userid']; $wol_blog["$blogresult[blogid]"]['state'] = $blogresult['state']; $wol_blog["$blogresult[blogid]"]['private'] = ($blogresult['options'] & $vbulletin->bf_misc_vbblogoptions['private']); $bloguserids .= ",$blogresult[userid]"; } } if ($bloguserids) { $fields = $joins = ''; if ($vbulletin->userinfo['userid']) { $fields = ", ignored.relationid AS ignoreid, buddy.relationid AS buddyid"; $joins = " LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = bu.bloguserid AND ignored.relationid = " . $vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore') LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = bu.bloguserid AND buddy.relationid = " . $vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy') "; } $userresults = $vbulletin->db->query_read_slave(" SELECT bu.title, bu.bloguserid, bu.options_member, bu.options_guest, bu.options_buddy, bu.options_ignore, bu.memberids, bu.memberblogids, user.userid, user.username, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, user.infractiongroupid, user.usergroupid, user.membergroupids $fields FROM " . TABLE_PREFIX . "blog_user AS bu LEFT JOIN " . TABLE_PREFIX . "user AS user ON (bu.bloguserid = user.userid) $joins WHERE bu.bloguserid IN (0$bloguserids) "); while ($userresult = $vbulletin->db->fetch_array($userresults)) { cache_permissions($userresult, false); fetch_musername($userresult); $wol_user["$userresult[userid]"] = $userresult['musername']; $member = ($userresult['options_member'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] ? 1 : 0); $guest = ($userresult['options_guest'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] ? 1 : 0); $buddy = ($userresult['options_buddy'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] ? 1 : 0); $ignore = ($userresult['options_ignore'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] ? 1 : 0); $wol_bloguser["$userresult[bloguserid]"]['title'] = $userresult['title']; $wol_bloguser["$userresult[bloguserid]"]['canviewmyblog'] = ( ( !$userresult['buddyid'] OR $buddy ) AND ( !$userresult['ignoreid'] OR $ignore ) AND ( ( $member AND $vbulletin->userinfo['userid'] ) OR ( $guest AND !$vbulletin->userinfo['userid'] ) ) OR ( $ignore AND $userresult['ignoreid'] ) OR ( $buddy AND $userresult['buddyid'] ) OR $userresult['userid'] == $vbulletin->userinfo['userid'] OR can_moderate_blog() OR is_member_of_blog($vbulletin->userinfo, $userresult) ) ? true : false; } } } /** * Processes the location for blog scripts in Who's Online * * @param array userinfo array * @param string the filename that the page view is on * @param array attributes passed in the URI * * @return void */ function blog_online_location_process(&$userinfo, &$values, $filename) { global $vbulletin; if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { if (!$vbulletin->userinfo['userid'] OR !($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown'])) { return; } } switch($filename) { case 'entry.php': if ($values['do'] == 'sendtofriend') { $userinfo['activity'] = 'blog_send_friend'; } else if ($values['do'] == 'viewip') { $userinfo['activity'] = 'blog_view_ip'; } else if ($values['do'] == 'comments') { $userinfo['activity'] = 'blog_view_comments'; } else { $userinfo['activity'] = 'blog_view_entry'; } break; case 'blog.php': if ((!isset($values['do']) AND isset($values['blogid'])) OR $values['do'] == 'blog') { $userinfo['activity'] = 'blog_view_entry'; } else if ((!isset($values['do']) AND isset($values['userid'])) OR $values['do'] == 'list') { $userinfo['activity'] = 'blog_view_user'; } else if ($values['do'] == 'bloglist') { $userinfo['activity'] = 'blog_view_list'; } else if ($values['do'] == 'members') { $userinfo['activity'] = 'blog_view_members'; } else { $userinfo['activity'] = 'blog_view_home'; } break; case 'blog_inlinemod.php': $userinfo['activity'] = 'blog_inlinemod'; break; case 'blog_tag.php': $userinfo['activity'] = 'blog_tag'; break; case 'blog_post.php': // could change this behaviour depending on if the edited post is visible if ($values['do'] == 'newblog') { $userinfo['activity'] = 'blog_new_entry'; } else if ($values['do'] == 'editblog') { $userinfo['activity'] = 'blog_edit_entry'; } else if ($values['do'] == 'updateblog') { $userinfo['activity'] = isset($values['blogid']) ? 'blog_edit_entry' :'blog_new_entry'; } else if ($values['do'] == 'comment') { $userinfo['activity'] = 'blog_new_comment'; } else if ($values['do'] == 'editcomment') { $userinfo['activity'] = 'blog_edit_comment'; } else if ($values['do'] == 'edittrackback' OR $values['do'] == 'updatetrackback') { $userinfo['activity'] = 'blog_edit_trackback'; } break; case 'blog_report.php': if ($values['blogtextid']) { $userinfo['activity'] = 'blog_report_comment'; } else { $userinfo['activity'] = 'blog_report_entry'; } break; case 'blog_subscription.php': $userinfo['activity'] = 'blog_subscription'; break; case 'blog_usercp.php': $userinfo['activity'] = 'blog_usercp'; break; } } /** * Called when an unknown Who's Online location is found within vBulletin * * @param array userinfo array * @param boolean reference to a boolean variable to indicate if the function handled the location * * @return void */ function blog_online_location_unknown(&$userinfo, &$handled) { if (strpos($userinfo['activity'], 'blog_') === 0) { global $wol_blog, $wol_blogtext, $wol_blogtrackback, $wol_bloguser, $wol_user, $vbulletin, $vbphrase; $handled = true; if ($userinfo['blogtextid']) { $blogid = $wol_blogtext["$userinfo[blogtextid]"]['blogid']; } else { $blogid = $userinfo['blogid']; } if ($wol_blog["$blogid"]['userid']) { $userid = $wol_blog["$blogid"]['userid']; } else if (!empty($userinfo['targetuserid'])) { $userid = $userinfo['targetuserid']; } else if ($userinfo['bloguserid']) { $userid = $userinfo['bloguserid']; } $can_see_blog = false; $can_see_blog_title = false; if ( (($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']) AND $wol_blog["$blogid"]['userid'] == $vbulletin->userinfo['userid']) OR (($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']) AND $wol_blog["$blogid"]['userid'] != $vbulletin->userinfo['userid']) ) { if ($can_see_blog = $wol_bloguser["$userid"]['canviewmyblog']) { /* draft isn't here because it doesn't really exist yet, ooOoooh (best ghost impression) */ if ((( $wol_blog["$blogid"]['state'] == 'visible' OR ( $wol_blog["$blogid"]['state'] == 'deleted' AND can_moderate_blog() ) OR ( $bloginfo['state'] == 'moderation' AND can_moderate_blog('canmoderateentries') )) AND !$wol_blog["$blogid"]['private']) OR $wol_blog["$blogid"]['userid'] == $vbulletin->userinfo['userid'] ) { $can_see_blog_title = true; } } } $blogtitle = $wol_bloguser["$userid"]['title'] ? $wol_bloguser["$userid"]['title'] : $wol_user["$userid"]; $blog = '$blogtitle"; $entry = '" . $wol_blog["$blogid"]['title'] . ''; $showentry = $showblog = false; switch ($userinfo['activity']) { case 'blog_view_user': $userinfo['action'] = $vbphrase['viewing_blog']; $showblog = true; break; case 'blog_view_entry': $userinfo['action'] = $vbphrase['viewing_blo