/**
	* Rebuilds the Count of the pictures in a group
	*
	*/
	function rebuild_picturecount()
	{
		if ($this->fetch_field('groupid'))
		{
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();
		$contenttypeid = intval($types->getContentTypeID('vBForum_SocialGroup'));

			$picturecount = $this->registry->db->query_first("
				SELECT COUNT(*) AS count
				FROM " . TABLE_PREFIX . "attachment AS a
				INNER JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON
					(socialgroupmember.userid = a.userid AND socialgroupmember.groupid = " . $this->fetch_field('groupid') . " AND socialgroupmember.type = 'member')
				WHERE
					a.contentid = " . $this->fetch_field('groupid') . "
						AND
					a.contenttypeid = $contenttypeid
			");
			$this->set('picturecount', $picturecount['count']);
			$this->set('lastupdate', TIMENOW);
		}
	}
Exemple #2
0
	/**
	* Parses the post for BB code.
	*/
	function parse_bbcode()
	{
		$this->bbcode_parser->attachments =& $this->post['attachments'];
		$this->bbcode_parser->unsetattach = true;
		//If the pagetext_html is not set, we need to see whether this is a
		// cms comment thread. If so, we need to set the comment link information.

		if (empty($this->post['pagetext_html']) AND $this->registry->products['vbcms']
			 AND isset($this->registry->options['vbcmsforumid']))
		{
			//We need to see if this post is for a forum article;
			if (!isset($this->post['nodeid']))
			{
				$associatedinfo = $this->registry->db->query_first("SELECT node.nodeid, node.url FROM " .
					TABLE_PREFIX . "cms_nodeinfo AS info INNER JOIN " .
					TABLE_PREFIX . "cms_node AS node ON node.nodeid = info.nodeid
					WHERE info.associatedthreadid = " . $this->post['threadid']);
				$this->post['nodeid'] = $associatedinfo['nodeid'];
				$this->post['url'] = $associatedinfo['url'];
				
			}
			if (intval($this->post['nodeid']))
			{
				//we need to set the parser to render this quotes as a links to the article
				// rather than showthread.

				//We need the router, which requires the boot.
				require_once(DIR . '/includes/class_bootstrap_framework.php');
				vB_Bootstrap_Framework::init();

				$nodeinfo = $this->post['nodeid'] . (empty($this->post['url']) ? '' :
					'-' . $this->post['url']);
				$page_url =  vBCms_Route_Content::getURL(array('node' => $nodeinfo, 'action' =>'view'));
				$this->bbcode_parser->set_quote_template('vbcms_bbcode_quote');
				$this->bbcode_parser->set_quote_vars(array('page_url' => $page_url .
					(strpos($page_url, '?') == false ? '?' : '&')));
			}
		}
		
		$this->post['message'] = $this->bbcode_parser->parse(
			$this->post['pagetext'],
			$this->forum['forumid'],
			$this->post['allowsmilie'],
			false,
			$this->post['pagetext_html'],
			$this->post['hasimages'],
			$this->cachable,
			$this->post['htmlstate']
		);
		$this->post_cache =& $this->bbcode_parser->cached;
		
		//Unset the flags we set above if necessary.
		if (isset($nodeinfo))
		{
			$this->bbcode_parser->set_quote_template('bbcode_quote');
			$this->bbcode_parser->set_quote_vars(false);
		}
	}
Exemple #3
0
	function delete()
	{
		global $vbulletin;
		if ($blogid = $this->existing['blogid'])
		{
			$db =& $this->registry->db;
			require_once(DIR . '/includes/blog_functions_log_error.php');

			if ($this->info['hard_delete'])
			{
				require_once(DIR . '/vb/search/indexcontroller/queue.php');
				vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogEntry', 'delete', $blogid);
				vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogComment', 'delete_group', $blogid);

				/* NOTE: There queries are all used in the post delete function in class_dm_blog_user.php, if you add another please add it there too */
				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_categoryuser WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_deletionlog WHERE primaryid = $blogid AND type = 'blogid'
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid'
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_pinghistory WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_rate WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_read WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_tachyentry WHERE blogid = $blogid
				");

				// 4.0 doesn't like aliases, 4.1 requires the alias be used :rolleyes:!!!
				$db->query_write("
					DELETE " . TABLE_PREFIX . "blog_text, " . TABLE_PREFIX . "blog_textparsed, " . TABLE_PREFIX . "blog_editlog, " . TABLE_PREFIX . "blog_moderation, " . TABLE_PREFIX . "blog_deletionlog
					FROM " . TABLE_PREFIX . "blog_text
					LEFT JOIN " . TABLE_PREFIX . "blog_textparsed ON (" . TABLE_PREFIX . "blog_textparsed.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid)
					LEFT JOIN " . TABLE_PREFIX . "blog_editlog ON (" . TABLE_PREFIX . "blog_editlog.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid)
					LEFT JOIN " . TABLE_PREFIX . "blog_moderation ON (" . TABLE_PREFIX . "blog_moderation.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_moderation.type = 'blogtextid')
					LEFT JOIN " . TABLE_PREFIX . "blog_deletionlog ON (" . TABLE_PREFIX . "blog_deletionlog.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_deletionlog.type = 'blogtextid')
					WHERE " . TABLE_PREFIX . "blog_text.blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_trackback WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_views WHERE blogid = $blogid
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_hash
					WHERE blogid = $blogid AND
						blogtextid = " . intval($this->fetch_field('firstblogtextid'))
				);

				require_once(DIR . '/includes/class_taggablecontent.php');
				$content = vB_Taggable_Content_Item::create($vbulletin, "vBBlog_BlogEntry", $blogid);
				$content->delete_tag_attachments();

				require_once(DIR . '/includes/class_bootstrap_framework.php');
				require_once(DIR . '/vb/types.php');
				vB_Bootstrap_Framework::init();
				$contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry');

				$attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment');
				$attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid);
				$attachdata->delete(true, false);

				$db->query_write("
					DELETE  FROM " . TABLE_PREFIX . "blog WHERE blogid = $blogid
				");

				if (!$this->info['skip_moderator_log'])
				{
					blog_moderator_action($this->existing, 'blogentry_removed');
					$db->query_write("
						UPDATE " . TABLE_PREFIX . "moderatorlog
						SET threadtitle = '". $db->escape_string($this->existing['title']) ."'
						WHERE id2 = $blogid
					");
				}
			}
			else
			{
				$this->set('state', 'deleted');
				$this->save();

				if (!$this->info['skip_moderator_log'])
				{
					blog_moderator_action($this->existing, 'blogentry_softdeleted');
				}

				// soft delete
				$db->query_write("
					REPLACE INTO " . TABLE_PREFIX . "blog_deletionlog
						(primaryid, type, userid, username, reason, dateline)
					VALUES
						($blogid,
						'blogid',
						" . $this->registry->userinfo['userid'] . ",
						'" . $db->escape_string($this->registry->userinfo['username']) . "',
						'" . $db->escape_string($this->info['reason']) . "',
						" . TIMENOW . ")
				");

				$db->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid'
				");

				if (!$this->info['keep_attachments'])
				{
					require_once(DIR . '/includes/class_bootstrap_framework.php');
					require_once(DIR . '/vb/types.php');
					vB_Bootstrap_Framework::init();
					$contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry');

					$attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment');
					$attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid);
					$attachdata->delete(true, false);
				}
			}

			if (!$this->info['skip_build_blog_counters'])
			{
				build_blog_user_counters($this->fetch_field('userid'));
				build_blog_stats();
			}

			($hook = vBulletinHook::fetch_hook('blog_data_delete')) ? eval($hook) : false;
			return true;
		}
		return false;
	}
 function step_21($data = null)
 {
     /*
      * Can't display checkbox options in the cli without a lot of mess so just skip
      */
     if ($this->caller == 'cli') {
         $this->skip_message();
     } else {
         if ($data['htmlsubmit']) {
             require_once DIR . '/includes/class_bootstrap_framework.php';
             vB_Bootstrap_Framework::init('../');
             $expire = intval($data['htmldata']['expire']);
             if ($expire > 180) {
                 $expire = 180;
             }
             if ($expire < 1) {
                 $expire = 1;
             }
             vB::$vbulletin->options['as_expire'] = $expire;
             unset($data['htmldata']['expire']);
             $this->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "activitystreamtype\n\t\t\t\tSET enabled = 0\n\t\t\t");
             foreach (array_keys($data['htmldata']) as $type) {
                 $values = explode('_', $type);
                 $section = $values[0];
                 $type = $values[1];
                 $this->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "activitystreamtype\n\t\t\t\t\tSET enabled = 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tsection = '{$section}'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\ttype = '{$type}'\n\t\t\t\t");
                 vB::$vbulletin->options['as_content'] = vB::$vbulletin->options['as_content'] | vB::$vbulletin->bf_misc_ascontent[$type];
             }
             build_activitystream_datastore();
             vB_ActivityStream_Manage::rebuild();
             // build_options() is executed after each version step of the upgrade so this will be processed before the final settings import
             $this->run_query(sprintf($this->phrase['vbphrase']['update_table'], TABLE_PREFIX . "setting"), "REPLACE INTO " . TABLE_PREFIX . "setting\n\t\t\t\t\t(varname, value, grouptitle, defaultvalue, optioncode, displayorder, volatile, datatype, product)\n\t\t\t\tVALUES\n\t\t\t\t\t('as_expire', {$expire}, 'activitystream', '30', '', 10, 1, 'number', 'vbulletin')\n\t\t\t");
         } else {
             $row = $this->db->query_first("\n\t\t\t\tSELECT COUNT(*) AS count\n\t\t\t\tFROM " . TABLE_PREFIX . "activitystream\n\t\t\t");
             if ($row['count'] == 0) {
                 return $this->asform();
             } else {
                 $this->skip_message();
             }
         }
     }
 }
Exemple #5
0
/**
 * Ensures the framework is bootstrapped.
 * TODO: We're getting to a point where we may as well always bootstrap it during init.
 */
function bootstrap_framework()
{
	if (!class_exists('vB_Bootstrap_Framework'))
	{
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		vB_Bootstrap_Framework::init();
	}
}
Exemple #6
0
	public function getBlockHTML($blockid, &$blockscache = null)
	{
		$block = $this->createBlock($blockid, $blockscache);
		$blockinfo = $block->getBlockInfo();
		
		if (!$this->registry->options['disableblockcache'] AND $blockinfo['allowcache'] AND $blockinfo['cachettl'] > 0)
		{
			// We need vB_Cache so we need to bootstrap framework
			require_once(DIR . '/includes/class_bootstrap_framework.php');
			vB_Bootstrap_Framework::init();
		}

		return $block->getBlockHTML();
	}
Exemple #7
0
			case 'editwidget':
				window.location = \"cms_admin.php?". $vbulletin->session->vars['sessionurl_js'] . "do=editwidget&widgetid=\" + id; break;
			case 'deletewidget':
				window.location = \"cms_admin.php?". $vbulletin->session->vars['sessionurl_js'] . "do=deletewidget&widgetid=\" + id; break;
			default:
				return false;
		}
	}
	</script>
";
}
else
{
	// Bootstrap to the vB Framework
	require_once(DIR . '/includes/class_bootstrap_framework.php');
	vB_Bootstrap_Framework::init('../');

	// Check widget id
	$widgetid = $vbulletin->input->clean_gpc('r', 'widgetid', TYPE_UINT);

	if ($widgetid)
	{
		$widgets = new vBCms_Collection_Widget($widgetid);

		if (isset($widgets[$widgetid]))
		{
			$widget = $widgets[$widgetid];
		}
		else
		{
			print_stop_message('invalid_x_specified', 'widgetid');
	/**
	*
	* @param	boolean	Do the query?
	*/
	function post_delete($doquery = true)
	{
		// A user's blog entries can only be found from searching after the user is deleted.
		if (!$this->info['skip_blog_entries'])
		{
			$blogids = array();
			$blogs = $this->dbobject->query_read_slave("
				SELECT *
				FROM " . TABLE_PREFIX . "blog
				WHERE userid = " . intval($this->fetch_field('bloguserid')
			));
			while ($blog = $this->dbobject->fetch_array($blogs))
			{
				$blogids[] = intval($blog['blogid']);
			}

			if (sizeof($blogids))
			{
				$blogids = implode(',', $blogids);

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_deletionlog WHERE primaryid IN ($blogids) AND type = 'blogid'
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid IN ($blogids) AND type = 'blogid'
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_pinghistory WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_rate WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_read WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_tachyentry WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE " . TABLE_PREFIX . "blog_text, " . TABLE_PREFIX . "blog_textparsed, " . TABLE_PREFIX . "blog_editlog, " . TABLE_PREFIX . "blog_moderation, " . TABLE_PREFIX . "blog_deletionlog
					FROM " . TABLE_PREFIX . "blog_text
					LEFT JOIN " . TABLE_PREFIX . "blog_textparsed ON (" . TABLE_PREFIX . "blog_textparsed.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid)
					LEFT JOIN " . TABLE_PREFIX . "blog_editlog ON (" . TABLE_PREFIX . "blog_editlog.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid)
					LEFT JOIN " . TABLE_PREFIX . "blog_moderation ON (" . TABLE_PREFIX . "blog_moderation.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_moderation.type = 'blogtextid')
					LEFT JOIN " . TABLE_PREFIX . "blog_deletionlog ON (" . TABLE_PREFIX . "blog_deletionlog.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_deletionlog.type = 'blogtextid')
					WHERE " . TABLE_PREFIX . "blog_text.blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_trackback WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_views WHERE blogid IN ($blogids)
				");

				$this->dbobject->query_write("
					DELETE FROM " . TABLE_PREFIX . "blog_hash
					WHERE blogid IN ($blogids)
				");

				require_once(DIR . '/includes/class_taggablecontent.php');
				vB_Taggable_Content_Item::delete_tag_attachments_list("vBBlog_BlogEntry", explode(',', $blogids));

				$attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT);
				$attachdata->condition = "a.contentid IN ($blogids)";
				$attachdata->delete();

				require_once(DIR . '/includes/class_bootstrap_framework.php');
				require_once(DIR . '/vb/types.php');
				vB_Bootstrap_Framework::init();
				$contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry');

				$attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment');
				$attachdata->condition = "a.contentid IN ($blogids) AND a.contenttypeid = " . intval($contenttypeid);
				$attachdata->delete(true, false);

				$this->dbobject->query_write("
					DELETE  FROM " . TABLE_PREFIX . "blog WHERE blogid IN ($blogids)
				");
			}
		}
		else
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "blog SET
					username = '******'verifyuser']['username']) . "',
					userid = 0
				WHERE userid = " . intval($this->fetch_field('bloguserid'))
			);
		}

		// User's comments
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog_text SET
				username = '******'verifyuser']['username']) . "',
				userid = 0
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Deleted items belonging to user
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog_deletionlog
			SET username = '******'verifyuser']['username']) . "'
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's category to post list
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_categoryuser
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's categories
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_category
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's read status
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_read
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's search records
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_search
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Blog Subscriptions
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Post Subscriptions
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeuser
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_subscribeuser
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		// User's read status for blogs and anyone for they're blog
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_userread
			WHERE userid = " . intval($this->fetch_field('bloguserid')) . " OR bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		// Groups
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "blog
			SET
				postedby_userid = userid,
				postedby_username = username
			WHERE postedby_userid = " . intval($this->fetch_field('bloguserid'))
		);

		$users = $this->dbobject->query_read_slave("
			SELECT userid
			FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE bloguserid = " . intval($this->fetch_field('bloguserid'))
		);

		while ($user = $this->dbobject->fetch_array($users))
		{
			build_blog_memberblogids($user['userid']);
		}

		$groups = $this->dbobject->query_read_slave("
			SELECT bloguserid
			FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_groupmembership
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		// Blog Customizations
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_usercss
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "blog_usercsscache
			WHERE userid = " . intval($this->fetch_field('bloguserid'))
		);

		while ($group = $this->dbobject->fetch_array($groups))
		{
			build_blog_memberids($group['bloguserid']);
		}

		($hook = vBulletinHook::fetch_hook('blog_userdata_delete')) ? eval($hook) : false;
	}
Exemple #9
0
 	public static function getPermissionString($userid = false)
 	{
 		if (($userid === false) AND ($userid !== 0))
 		{
 			$userid = vB::$vbulletin->userinfo['userid'];
 		}

 		if (($userid == vB::$vbulletin->userinfo['userid']) AND self::$permission_string)
 		{
 			return self::$permission_string;
 		}


 		require_once DIR . '/includes/class_bootstrap_framework.php' ;
 		vB_Bootstrap_Framework::init();

 		$can_view = array();
 		$blocked = array();
 		$perms = self::getPerms($userid);

 		//We need to block out unpublished sections.
		$sections = vBCms_ContentManager::getSections();
 		foreach($sections as $section)
 		{
 			$can_view_this = (intval($section['setpublish']) > 0) && ($section['publishdate'] < TIMENOW);
 			if (!$can_view_this)
 			{
 				$blocked[$section['nodeid']] = 1;
 				if (isset($can_view[$section['nodeid']]))
 				{
 					unset($can_view[$section['nodeid']]);
 				}
 			}
 			else if (!isset($can_view[$section['nodeid']]) AND ! isset($blocked[$section['nodeid']]))
 			{
 				$can_view[$section['nodeid']] = 1;
 			}
 		}

 		$canedit = array_unique(array_merge($perms['canedit'],
 				$perms['canpublish']));
 		self::$permission_string = "( (node.permissionsfrom IN (" . implode(',', $canedit) .
			"))";

 		if (intval($userid))
 		{
 			self::$permission_string .= " OR (node.userid =" . vB::$vbulletin->userinfo['userid'] . ") ";
 		}

 		if (!empty($can_view))
 		{
 			self::$permission_string .= " OR ( node.permissionsfrom in (" .
 				implode(',', $perms['canview']) . ") AND (node.parentnode IN (" .
				implode(',', array_keys($can_view)) . ")" .
				(isset($can_view[1]) ? " OR node.nodeid = 1" : "") . "))";
 		}

 		self::$permission_string .= ")";
 		return self::$permission_string;
 	}
 /** 
  * Write postponed URLs to table.
  * If the post was edited - skip successfully checked and check-in-progress URLs.
  *
  * @param array $ci_postponed_urls URLs list
  * @param int $message_id Content ID.
  * @param string $c_type Content type (Post, Comment, etc.).
  */
 function ci_queue_url_check($ci_postponed_urls, $message_id, $c_type)
 {
     global $vbulletin;
     // Exit if nothing to save
     if (empty($ci_postponed_urls)) {
         return;
     }
     // ensure that the framework is initialized
     require_once DIR . '/includes/class_bootstrap_framework.php';
     vB_Bootstrap_Framework::init();
     require_once DIR . '/vb/types.php';
     $c_type_id = vB_Types::instance()->getContentTypeID($c_type);
     // If we have checked (or checking) URLs in queue - do not add them again
     $resource = $vbulletin->db->query("\n                                    SELECT url\n                                    FROM " . TABLE_PREFIX . "rcd_imagequeue\n                                    WHERE `contentid` = " . $message_id . " AND\n                                          `contenttypeid` = " . $c_type_id . " AND\n                                          `status` IN ('SUCCESS', 'PROCESSING')\n        ");
     $already_checked_url = array();
     while ($data = $vbulletin->db->fetch_array($resource)) {
         $already_checked_url[] = $data['url'];
     }
     $vbulletin->db->free_result($resource);
     // Remove URL from postponed URLs list if it in queue already
     if (!empty($already_checked_url)) {
         foreach ($ci_postponed_urls as $key => $url) {
             if (in_array($url, $already_checked_url)) {
                 unset($ci_postponed_urls[$key]);
             }
         }
     }
     // Exit if nothing is left to save
     if (empty($ci_postponed_urls)) {
         return;
     }
     // Save URL with status PROCESSING, it will be checked later by cron job
     foreach ($ci_postponed_urls as $url) {
         $ci_sql_values[] = "('" . $vbulletin->db->escape_string($url) . "',\n                                " . $message_id . ",\n                                " . $c_type_id . ",\n                                '" . $vbulletin->db->escape_string(parse_url($url, PHP_URL_HOST)) . "')";
     }
     $vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "rcd_imagequeue\n                                     (`url`, `contentid`, `contenttypeid`, `domain`)\n                                     VALUES\n                                     " . implode(',', $ci_sql_values) . "\n                                    ");
 }
Exemple #11
0
	/**
	* post_delete function - extend if the contenttype needs to do anything
	*
	* @return	void
	*/
	public function post_delete()
	{
		// Update attach in the post table
		if (!empty($this->lists['postlist']))
		{
			require_once(DIR . '/includes/class_bootstrap_framework.php');
			require_once(DIR . '/vb/types.php');
			vB_Bootstrap_Framework::init();
			$types = vB_Types::instance();
			$contenttypeid = intval($types->getContentTypeID('vBForum_Post'));

			// COALASCE() used here due to issue in 5.1.30 (at least) where mysql reports COLUMN CANNOT BE NULL error
			// when the subquery returns a null
			$this->registry->db->query_write("
				UPDATE " . TABLE_PREFIX . "post AS p
				SET p.attach = COALESCE((
					SELECT COUNT(*)
					FROM " . TABLE_PREFIX . "attachment AS a
					WHERE
						p.postid = a.contentid
							AND
						a.contenttypeid = $contenttypeid
					GROUP BY a.contentid
				), 0)
				WHERE p.postid IN (" . implode(", ", array_keys($this->lists['postlist'])) . ")
			");
		}

		// Update attach in the thread table
		if (!empty($this->lists['threadlist']))
		{
			$this->registry->db->query_write("
				UPDATE " . TABLE_PREFIX . "thread AS t
				SET t.attach = (
					SELECT SUM(attach)
					FROM " . TABLE_PREFIX . "post AS p
					WHERE p.threadid = t.threadid
					GROUP BY p.threadid
				)
				WHERE t.threadid IN (" . implode(", ", array_keys($this->lists['threadlist'])) . ")
			");
		}
	}
Exemple #12
0
 /**
  * Create the core search object
  *
  * Registers default indexers and search result classes for core searchable items
  */
 public function __construct()
 {
     //ensure that the framework is initialized.
     require_once DIR . '/includes/class_bootstrap_framework.php';
     vB_Bootstrap_Framework::init();
 }
Exemple #13
0
	/**
	 * load the existing data
	 *
	 */
	private function load_data()
	{
		//See if we need to bootstrap
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		vB_Bootstrap_Framework::init();

		$sections = vBCms_ContentManager::getSections();
		$perms = vBCMS_Permissions::getPerms(0);
		$this->custom_priority['cms'] = array();
		$level = array();

		foreach ($sections as $nodeid => $section)
		{
			if ((!$section['hidden']) AND (in_array($section['permissionsfrom'], $perms['canview'])))
			{
				$section['priority'] = false;
				$this->custom_priority['cms'][$section['nodeid']] = $section;
			}
		}

		$this->set_priorities('cms');

	}
 /**
  * Verifies the an image property. Must come from this user's album and the album must be public/profile.
  *
  * @param	string	Value to verfiy. May be modified.
  *
  * @return	boolean	True if value.
  */
 function verify_image(&$value)
 {
     $options = vB5_vB::get_datastore()->get_value('options');
     $bf_misc_socnet = vB5_vB::get_datastore()->get_value('bf_misc_socnet');
     if (!($options['socnet'] & $bf_misc_socnet['enable_albums'])) {
         $value = '';
         return true;
     }
     $foundalbum = preg_match('#albumid=([0-9]+)#', $value, $albumid);
     $foundpicture = preg_match('#attachmentid=([0-9]+)#', $value, $attachmentid);
     require_once DIR . '/includes/class_bootstrap_framework.php';
     require_once DIR . '/vb/types.php';
     vB_Bootstrap_Framework::init();
     $types = vB_Types::instance();
     $contenttypeid = intval($types->getContentTypeID('vBForum_Album'));
     if ($foundalbum and $foundpicture and $picture = $this->assertor->getRow('getUserPictures', array('attachmentid' => intval($attachmentid[1]), 'contenttypeid' => $contenttypeid, 'state' => array('profile', 'public'), 'userid' => $this->userid, 'albumid' => intval($albumid[1])))) {
         $value = $albumid[1] . "," . $attachmentid[1];
         return true;
     } else {
         return false;
     }
 }
Exemple #15
0
function upgrade_product_step($productid)
{
	global $vbulletin;
	global $upgrade_phrases;

	$product_file = DIR . "/includes/xml/product-$productid.xml";
	$exists = file_exists($product_file);
	if (!$exists)
	{
		$upgrade_phrases['finalupgrade.php']['product_not_found'];
		return false;
	}

	require_once(DIR . "/includes/adminfunctions_plugin.php");
	require_once(DIR . "/includes/adminfunctions_template.php");
	require_once(DIR . '/includes/class_bootstrap_framework.php');
	vB_Bootstrap_Framework::init();

	echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['installing_product'] . "</p>");
	$xml = file_read($product_file);

	try
	{
		install_product($xml, true);
	}
	catch(vB_Exception_AdminStopMessage $e)
	{
		$args = $e->getParams();
		$message = fetch_phrase($args[0], 'error', '', false);

		if (sizeof($args) > 1)
		{
			$args[0] = $message;
			$message = call_user_func_array('construct_phrase', $args);
		}

		echo "<p>$message</p>\n";
		echo "<p>" . $upgrade_phrases['finalupgrade.php']['product_not_installed'] . "</p>";
		return false;
	}

	echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['product_installed'] . "</p>");
	return true;
}
function autoexport_route_update($id, $product, $vb_func)
{
	if ($id == -1)
	{	
		//inits classloader -- required to make vB_Cache work
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		vB_Bootstrap_Framework::init();	
//		$timer = vB_Timer::get('timer');
//		$timer->start();

		if (is_array($product))
		{
			//makes sure that if we are passed a list of products
			//that we only process each product a single time.  
			//More is unnecesary and possibly counterproductive.
			//We will actually rely on the fact that we'll only
			//process a product once to avoid having to check if
			//products are the same before adding them to the list.
			$products = array_unique($product);
		}
		else 
		{
			$products = array($product);
		}

		foreach ($products AS $product)
		{
			if ($product == "vbulletin")
			{
				if (!is_array($vb_func))
				{
					$vb_func();
				}
				else 
				{
					//allow multiple callbacks for operations that 
					//touch multiple files.
					foreach($vb_func as $func)
					{
						$func();
					}
				}
			}
			else if (in_array($product, array('vbcms', 'vbblog'))) 
			{
				autoexport_write_product($product);
			}
		}

		
//		var_dump($timer->stop());
	}
}
Exemple #17
0
	public static function construct_section_chooser_options($topname = null)
	{
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/packages/vbcms/contentmanager.php');
		vB_Bootstrap_Framework::init();

		$selectoptions = array();

		if ($topname)
		{
			$selectoptions['-1'] = $topname;
		}

		// get category options
		$nodelist = vBCms_ContentManager::getNodes(1,
				array('contenttypeid' => 'node2.contenttypeid = ' . vb_Types::instance()->getContentTypeID("vBCms_Section")));


		foreach ($nodelist as $section)
		{
			$selectoptions[$section['nodeid']] = str_replace('&gt;', '>', $section['parent']) . $section['leaf'];
		}

		return $selectoptions;
	}
Exemple #18
0
/**
 * Ensures the framework is bootstrapped.
 */
function bootstrap_framework()
{
    if (VB_FRAMEWORK === true) {
        return;
    }
    require_once DIR . '/includes/class_bootstrap_framework.php';
    vB_Bootstrap_Framework::init();
}
function delete_post($postid, $countposts = true, $threadid = 0, $physicaldel = true, $delinfo = NULL, $dolog = true)
{
	global $vbulletin, $vbphrase, $threadinfo;

	$postid = intval($postid);
	$threadid = intval($threadid);

	if (!is_array($delinfo))
	{
		$delinfo = array(
			'userid'          => $vbulletin->userinfo['userid'],
			'username'        => $vbulletin->userinfo['username'],
			'reason'          => '',
			'keepattachments' => false
		);
	}
	else
	{
		if (!$delinfo['userid'])
		{
			$delinfo['userid'] = $vbulletin->userinfo['userid'];
		}
		if (!$delinfo['username'])
		{
			$delinfo['username'] = $vbulletin->userinfo['username'];
		}
	}

	if ($postinfo = fetch_postinfo($postid))
	{
		$threadinfo = fetch_threadinfo($postinfo['threadid']);

		if (!$physicaldel AND $postinfo['visible'] == 2)
		{	// post is already soft deleted
			return;
		}

		if ($threadinfo['firstpostid'] == $postid)
		{
			if (!$physicaldel AND $threadinfo['visible'] == 2)
			{	// thread is already soft deleted
				return;
			}

			// delete thread
			$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
			$threadman->set_existing($threadinfo);
			$threadman->delete($countposts, $physicaldel, $delinfo);
			unset($threadman);
			return;
		}

		if (can_moderate() AND $dolog)
		{
			fetch_phrase_group('threadmanage');

			if (!$physicaldel)
			{
				$type = 'post_x_by_y_softdeleted';
			}
			else
			{
				$type = 'post_x_by_y_removed';
			}

			$postinfo['forumid'] = $threadinfo['forumid'];
			require_once(DIR . '/includes/functions_log_error.php');
			log_moderator_action($postinfo, $type, array($postinfo['title'], $postinfo['username']));
		}

		if ($countposts AND $postinfo['visible'] == 1 AND $threadinfo['visible'] == 1 AND $postinfo['userid'])
		{	// deleted posts have already been decremented and hidden posts were never incremented (as of 3.5 at least)
			// init user data manager
			$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
			$userdata->set_existing($postinfo);
			$userdata->set('posts', 'IF(posts > 1, posts - 1, 0)', false);
			$userdata->set_ladder_usertitle_relative(-1);
			$userdata->save();
			unset($userdata);
		}

		if ($postinfo['attach'])
		{
			if ($physicaldel OR (!$delinfo['keepattachments'] AND can_moderate($threadinfo['forumid'], 'canremoveposts')))
			{
				require_once(DIR . '/includes/class_bootstrap_framework.php');
				require_once(DIR . '/vb/types.php');
				vB_Bootstrap_Framework::init();
				$types = vB_Types::instance();
				$contenttypeid = intval($types->getContentTypeID('vBForum_Post'));

				$attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_SILENT, 'attachment');
				$attachdata->condition = "a.contentid = " . intval($postinfo['postid']) . " AND a.contenttypeid = " . intval($contenttypeid);
				$attachdata->delete(true, false);
			}
		}

		if (!$physicaldel)
		{
			$deletionman =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
			$deletionman->set('primaryid', $postinfo['postid']);
			$deletionman->set('type', 'post');
			$deletionman->set('userid', $delinfo['userid']);
			$deletionman->set('username', $delinfo['username']);
			$deletionman->set('reason', $delinfo['reason']);
			$deletionman->save();
			unset($deletionman);

			$postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
			$postman->set_existing($postinfo);
			$postman->set('visible', 2);
			$postman->save();
			unset($postman);

			if (!$postinfo['visible'])
			{ // only posts that are already moderated need tidied up
				$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = $postinfo[postid] AND type = 'reply'");
				$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "spamlog WHERE postid = $postinfo[postid]");
			}

			return;
		}

		// Sending the cookie below in rapid fire fashion for 300 posts deleted via inline mod seems to blowup IE but we don't need to set this cookie when using inlinemod
		if (THIS_SCRIPT != 'inlinemod')
		{
			// Delete any postid entries from the inline moderation cookie
			$vbulletin->input->clean_array_gpc('c', array(
				'vbulletin_inlinepost' => TYPE_STR,
			));

			if (!empty($vbulletin->GPC['vbulletin_inlinepost']) AND !headers_sent())
			{
				$newcookie = array();
				$found = false;
				$temp = explode('-', $vbulletin->GPC['vbulletin_inlinepost']);
				foreach($temp AS $inlinepostid)
				{
					if ($inlinepostid == $postid)
					{
						$found = true;
					}
					else
					{
						$newcookie[] = $inlinepostid;
					}
				}

				// this post is in the inline post cookie so delete it by rewriting cookie without it
				if ($found)
				{
					setcookie('vbulletin_inlinepost', implode('-', $newcookie), TIMENOW + 3600, '/');
				}
			}
		}

		// delete post hash when physically deleting a post - last argument is type
		$dupehash = md5($threadinfo['forumid'] . $postinfo['title'] . $postinfo['pagetext'] . $postinfo['userid'] . 'reply');

		$vbulletin->db->query_write("
			DELETE FROM " . TABLE_PREFIX . "posthash
			WHERE userid = $postinfo[userid] AND
			dupehash = '" . $vbulletin->db->escape_string($dupehash) . "' AND
			dateline > " . (TIMENOW - 300)
		);

		// Hook this post's children up to it's parent so they aren't orphaned. Foster parents I guess.
		if ($postinfo['parentid'] == 0)
		{
			if ($firstchild = $vbulletin->db->query_first("
				SELECT *
				FROM " . TABLE_PREFIX . "post
				WHERE threadid = $postinfo[threadid] AND
				parentid = $postid
				ORDER BY dateline, postid
				LIMIT 1
			"))
			{
				$postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
				$postman->set_existing($firstchild);
				$postman->set('parentid', 0);
				$postman->save();
				unset($postman);

				$postinfo['parentid'] = $firstchild['postid'];
			}
		}

		$vbulletin->db->query_write("
			UPDATE " . TABLE_PREFIX . "post SET
				parentid = " . intval($postinfo['parentid']) . "
			WHERE threadid = $postinfo[threadid]
				AND parentid = $postid
		");

		$deletiondata =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
		$deletioninfo = array('type' => 'post', 'primaryid' => $postid);
		$deletiondata->set_existing($deletioninfo);
		$deletiondata->delete();
		unset($deletiondata, $deletioninfo);


		delete_post_index($postid);
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "post WHERE postid = $postid");
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postparsed WHERE postid = $postid");
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "editlog WHERE postid = $postid");
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "postedithistory WHERE postid = $postid");
		//$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "reputation WHERE postid = $postid");
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderation WHERE primaryid = $postid AND type = 'reply'");
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "spamlog WHERE postid = $postid");
	}
}
Exemple #20
0
	/**
	* post_delete function - extend if the contenttype needs to do anything
	*
	* @return	void
	*/
	public function post_delete()
	{
		// Update attach in the blog table
		if (!empty($this->lists['bloglist']))
		{
			require_once(DIR . '/includes/class_bootstrap_framework.php');
			require_once(DIR . '/vb/types.php');
			vB_Bootstrap_Framework::init();
			$contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry');

			$this->registry->db->query_write("
				UPDATE " . TABLE_PREFIX . "blog AS b
				SET b.attach = (
					SELECT COUNT(*)
					FROM " . TABLE_PREFIX . "attachment AS a
					WHERE
						b.blogid = a.contentid
							AND
						a.contenttypeid = $contenttypeid
					GROUP BY a.contentid
				)
				WHERE b.blogid IN (" . implode(", ", array_keys($this->lists['bloglist'])) . ")
			");
		}
	}
/**
* Rebuild the unviewed and unmoderated picture comment counters
*
* @param	integer		Userid of visitor message data to rebuild
*
* @return	void
*/
function build_picture_comment_counters($userid)
{
	global $vbulletin;

	$userid = intval($userid);
	if ($userid)
	{
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();
		$contenttypeid = intval($types->getContentTypeID('vBForum_Album'));

		$coventry = '';
		if ($vbulletin->options['globalignore'] != '')
		{
			require_once(DIR . '/includes/functions_bigthree.php');

			$coventry = fetch_coventry('string', true);

			$vbulletin->db->query_write("
				UPDATE " . TABLE_PREFIX . "attachment AS attachment
				INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid)
				SET
					picturecomment.messageread = 1
				WHERE
					attachment.contenttypeid = $contenttypeid
						AND
					attachment.userid = $userid
						AND
					picturecomment.postuserid IN ($coventry)
			");
		}

		list($unread) = $vbulletin->db->query_first("
			SELECT COUNT(*) AS unread
			FROM " . TABLE_PREFIX . "attachment AS attachment
			INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid)
			WHERE
				attachment.contenttypeid = $contenttypeid
					AND
				attachment.userid = $userid
					AND
				picturecomment.state = 'visible'
					AND
				picturecomment.messageread = 0", DBARRAY_NUM
		);

		list($moderated) = $vbulletin->db->query_first("
			SELECT COUNT(*) AS moderation
			FROM " . TABLE_PREFIX . "attachment AS attachment
			INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid)
			WHERE
				attachment.contenttypeid = $contenttypeid
					AND
				attachment.userid = $userid
					AND
				picturecomment.state = 'moderation'
			" . ($coventry ? "AND (picturecomment.postuserid NOT IN ($coventry) OR picturecomment.postuserid = $userid)" : '')
			, DBARRAY_NUM
		);

		$vbulletin->db->query_write("
			UPDATE " . TABLE_PREFIX . "user
			SET pcunreadcount = " . intval($unread) . ", pcmoderatedcount = " . intval($moderated) . "
			WHERE userid = $userid
		");

		($hook = vBulletinHook::fetch_hook('picture_comment_build_counters')) ? eval($hook) : false;
	}
}
Exemple #22
0
/**
* Fetches the overage value for total filesize of pictures for a user.
*
* @param	integer	User ID to look for
* @param	integer	Maximum total filesize allowed; 0 means no limit
* @param	integer	Number of bytes they are currently uploading that aren't in the DB yet
*
* @return	integer	Amount of overage; <= 0 means no overage
*/
function fetch_size_overage($userid, $maxsize, $upload_bytes = 0)
{
	global $vbulletin;

	if (!$maxsize)
	{
		// never over
		return -1;
	}

	require_once(DIR . '/includes/class_bootstrap_framework.php');
	require_once(DIR . '/vb/types.php');
	vB_Bootstrap_Framework::init();
	$types = vB_Types::instance();
	$contenttypeid = intval($types->getContentTypeID('vBForum_Album'));

	$size = $vbulletin->db->query_first("
		SELECT SUM(fd.filesize) AS totalsize
		FROM " . TABLE_PREFIX . "attachment AS a
		INNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (a.filedataid = fd.filedataid)
		WHERE
			a.userid = " . intval($userid) . "
				AND
			a.contenttypeid = $contenttypeid
	");

	return $size['totalsize'] + $upload_bytes - $maxsize;
}
Exemple #23
0
	/**
	 * Rebuilds counts for an album
	 *
	 */
	function rebuild_counts()
	{
		if (!$this->fetch_field('albumid'))
		{
			return;
		}

		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();
		$contenttypeid = intval($types->getContentTypeID('vBForum_Album'));

		$counts = $this->registry->db->query_first("
			SELECT
				SUM(IF(a.state = 'visible', 1, 0)) AS visible,
				SUM(IF(a.state = 'moderation', 1, 0)) AS moderation,
				MAX(IF(a.state = 'visible', a.dateline, 0)) AS lastpicturedate
			FROM " . TABLE_PREFIX . "attachment AS a
			WHERE
				a.contentid = " . $this->fetch_field('albumid') . "
					AND
				a.contenttypeid = $contenttypeid
		");

		$this->set('visible', $counts['visible']);
		$this->set('moderation', $counts['moderation']);
		$this->set('lastpicturedate', $counts['lastpicturedate']);
	}
Exemple #24
0
/**
* Fetches the HTML for the tag cloud.
*
* @param	string	Type of cloud. Supports search, usage
* @param	bool		Return full cloud box or just the links
* @param	int			Limit cloud to blog entries owned by a specific user
*
* @return	string	Tag cloud HTML (nothing if no cloud)
*/
function fetch_blog_tagcloud($type = 'usage', $links = false, $userid = 0)
{
	global $vbulletin, $vbphrase, $show, $template_hook;

	if (!$vbulletin->options['vbblog_tagging'])
	{
		return false;
	}

	$wheresql = array(
		"blog.dateline <= " . TIMENOW,
		"blog.pending = 0",
		"blog.state = 'visible'",
		"~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'],
	);

	if ($userid AND $type == 'usage')
	{
		$userinfo = fetch_userinfo($userid);
		$wheresql[] = "blog.userid = $userid";
		$cloud = @unserialize($userinfo['tagcloud']);
	}
	else
	{
		if ($vbulletin->options['vbblog_tagcloud_cachetype'] == 1)
		{
			$cloud = null;
		}
		else
		{
			switch ($type)
			{
				case 'search':
					$cloud = $vbulletin->blogsearchcloud;
					break;

				case 'usage':
				default:
					if ($userid)
					{
						$userinfo = fetch_userinfo($userid);
						$wheresql[] = "blog.userid = $userid";
					}
					else
					{
						$cloud = $vbulletin->blogtagcloud;
					}
					break;
			}
		}
	}

	if (!is_array($cloud) OR $cloud['dateline'] < (TIMENOW - (60 * $vbulletin->options['vbblog_tagcloud_cachetime'])))
	{
		if ($type == 'search')
		{
			$tags_result = $vbulletin->db->query_read_slave("
				SELECT tagsearch.tagid, tag.tagtext, COUNT(*) AS searchcount
				FROM " . TABLE_PREFIX . "blog_tagsearch AS tagsearch
				INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagsearch.tagid = tag.tagid)
				" . ($vbulletin->options['tagcloud_searchhistory'] ?
					"WHERE tagsearch.dateline > " . (TIMENOW - (60 * 60 * 24 * $vbulletin->options['vbblog_tagcloud_searchhistory'])) :
					'') . "
				GROUP BY tagsearch.tagid, tag.tagtext
				ORDER BY searchcount DESC
				LIMIT " . $vbulletin->options['vbblog_tagcloud_tags']
			);
		}
		else
		{
			$joinsql = array();

			if ($vbulletin->options['vbblog_tagcloud_cachetype'] == 1)
			{
				if ($vbulletin->userinfo['userid'])
				{
					$userlist_sql = array();
					$userlist_sql[] = "(options_ignore & " .
						$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] .
						" AND ignored.relationid IS NOT NULL)";
					$userlist_sql[] = "(options_buddy & " .
						$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] .
						" AND buddy.relationid IS NOT NULL)";
					$userlist_sql[] = "(options_member & " .
						$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] .
						" AND (options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] .
						" OR buddy.relationid IS NULL) AND (options_ignore & " .
						$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] .
						" OR ignored.relationid IS NULL))";
					$wheresql[] = "(" . implode(" OR ", $userlist_sql) . ")";

					$joinsql[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON
						(buddy.userid = blog.userid AND buddy.relationid = " . $vbulletin->userinfo['userid'] . "
							AND buddy.type = 'buddy')";
					$joinsql[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON
						(ignored.userid = blog.userid AND ignored.relationid = " . $vbulletin->userinfo['userid'] . "
						AND ignored.type = 'ignore')";
				}
				else
				{
					$wheresql[] = "options_guest & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
					$wheresql[] = "~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'];
				}

				if (!empty($vbulletin->userinfo['blogcategorypermissions']['cantview']) AND $userinfo['userid'] != $vbulletin->userinfo['userid'])
				{
					$joinsql[] = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $vbulletin->userinfo['blogcategorypermissions']['cantview']) . "))";
					$wheresql[] = "cu.blogcategoryid IS NULL";
				}

				// remove blog entries that don't interest us
				require_once(DIR . '/includes/functions_bigthree.php');
				if ($coventry = fetch_coventry('string'))
				{
					$wheresql[] = "blog.userid NOT IN ($coventry)";
				}
			}
			else
			{
				if (trim($vbulletin->options['globalignore']) != '')
				{
					if ($coventry = preg_split('#\s+#s', $vbulletin->options['globalignore'], -1, PREG_SPLIT_NO_EMPTY))
					{
						$wheresql[] = "blog.userid NOT IN (" . implode(',', $coventry) . ")";
					}
				}
			}

			//get autoloader hooked up.
			require_once(DIR . '/includes/class_bootstrap_framework.php');
			vB_Bootstrap_Framework::init();
			$contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry');

			$tags_result = $vbulletin->db->query_read_slave("
				SELECT tagcontent.tagid, tag.tagtext, COUNT(*) AS searchcount
				FROM " . TABLE_PREFIX . "tagcontent AS tagcontent
				INNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagcontent.tagid = tag.tagid)
				INNER JOIN " . TABLE_PREFIX . "blog AS blog ON (tagcontent.contenttypeid = $contenttypeid AND tagcontent.contentid = blog.blogid)
				INNER JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog.userid = blog_user.bloguserid)
				" . (!empty($joinsql) ? implode("\r\n", $joinsql) : "") . "
				WHERE " . implode(" AND ", $wheresql) . "
				" . ($vbulletin->options['vbblog_tagcloud_usagehistory'] ? "AND tagcontent.dateline > " . (TIMENOW - (60 * 60 * 24 * $vbulletin->options['vbblog_tagcloud_usagehistory'])) : "") . "
				GROUP BY tagcontent.tagid, tag.tagtext
				ORDER BY searchcount DESC
				LIMIT " . $vbulletin->options['vbblog_tagcloud_tags']
			);
		}

		$tags = array();
		$counts = array();
		if (!empty($tags_result))
		{
			while ($currenttag = $vbulletin->db->fetch_array($tags_result))
			{
				$tags["$currenttag[tagtext]"] = $currenttag;
				$counts[$currenttag['tagid']] = $currenttag['searchcount'];
			}
			$vbulletin->db->free_result($tags_result);

			// fetch the stddev levels
			$levels = fetch_standard_deviated_levels($counts, $vbulletin->options['vbblog_tagcloud_levels']);

			// assign the levels back to the tags
			$final_tags = array();
			foreach ($tags AS $tagtext => $thistag)
			{
				$thistag['level'] = $levels[$thistag['tagid']];
				$thistag['tagtext_url'] = urlencode(unhtmlspecialchars($thistag['tagtext']));
				$final_tags[] = $thistag;
			}

			uksort($tags, 'strnatcasecmp');
		}

		$cloud = array(
			'tags'     => $final_tags,
			'count'    => sizeof($final_tags),
			'dateline' => TIMENOW
		);

		if ($userid)
		{
			$dataman =& datamanager_init('Blog_User', $vbulletin, ERRTYPE_STANDARD);
			$info = array('bloguserid' => $userinfo['userid']);
			$dataman->set_existing($info);
			$dataman->set('tagcloud', $cloud);
			$dataman->save();
			unset($dataman);
		}
		else
		{
			if ($vbulletin->options['vbblog_tagcloud_cachetype'] == 2)
			{
				if ($type == 'search')
				{
					$vbulletin->blogsearchcloud = $cloud;
					build_datastore('blogsearchcloud', serialize($cloud), 1);
				}
				else
				{
					$vbulletin->blogtagcloud = $cloud;
					build_datastore('blogtagcloud', serialize($cloud), 1);
				}
			}
		}
	}

	if (empty($cloud['tags']))
	{
		return '';
	}

	$cloud['links'] = '';

	foreach ($cloud['tags'] AS $thistag)
	{
		($hook = vBulletinHook::fetch_hook('blog_tag_cloud_bit')) ? eval($hook) : false;
		$show['userlink'] = ($userid);
		$templater = vB_Template::create('blog_tag_cloud_link');
			$templater->register('thistag', $thistag);
			$templater->register('userinfo', $userinfo);
			$templater->register('pageinfo', array('tag' => $thistag['tagtext_url']));
		$cloud['links'] .= $templater->render();
	}

	if ($links)
	{
		$cloud_html = $cloud['links'];
	}
	else
	{
		$cloud['count'] = vb_number_format($cloud['count']);
		$templater = vB_Template::create('blog_tag_cloud_box');
			$templater->register('cloud', $cloud);
			$templater->register('userinfo', $userinfo);
		$cloud_html .= $templater->render();
	}

	if ($cloud_html)
	{
		$show['tagcloud_css'] = true;
	}
	return $cloud_html;
}
Exemple #25
0
function construct_online_bit($userinfo, $doall = 0)
{
	global $vbulletin, $limitlower, $limitupper, $vbphrase, $ipclass, $show;
	global $wol_album, $wol_attachment, $wol_calendar, $wol_event, $wol_inf, $wol_pm, $wol_post,
		$wol_search, $wol_socialgroup, $wol_thread, $wol_user;
	static $count;

	$count++;
	$show['nopermission'] = false;
	$show['lockedout'] = false;
	$show['errormessage'] = false;

	if ($doall == 1 AND ($count > $limitupper OR $count < $limitlower))
	{
		return '';
	}

	if ($userinfo['attachmentid'])
	{
		$postid = $wol_attachment["$userinfo[attachmentid]"];
	}
	else
	{
		$postid = $userinfo['postid'];
	}
	if ($postid)
	{
		$threadid = $wol_post["$postid"];
	}
	else
	{
		$threadid = $userinfo['threadid'];
	}
	$forumid = $userinfo['forumid'];
	$calendarid = $userinfo['calendarid'];
	$eventid = $userinfo['eventid'];
	$searchid = $userinfo['searchid'];
	$groupid = $userinfo['socialgroupid'];
	$albumid = $userinfo['albumid'];

	if ($albumid)
	{
		require_once(DIR . '/includes/functions_album.php');
		$albumname = fetch_censored_text($wol_album["$albumid"]['title']);
		$canviewalbum = true;
		if ($wol_album["$albumid"]['state'] == 'profile' AND !can_view_profile_albums($wol_album["$albumid"]['userid']))
		{
			$canviewalbum = false;
		}
		else if ($wol_album["$albumid"]['state'] == 'private' AND !can_view_private_albums($wol_album["$albumid"]['userid']))
		{
			$canviewalbum = false;
		}
	}

	if ($groupid)
	{
		$groupname = fetch_censored_text($wol_socialgroup["$groupid"]['name']);
		$canviewgroup = true;
	}

	if ($searchid)
	{
		$searchquery = $wol_search["$searchid"]['query'];
		$searchuser = $wol_search["$searchid"]['searchuser'];
		$searchuserid = $wol_search["$searchid"]['userid'];
	}
	if (!$forumid AND isset($wol_thread["$threadid"]['forumid']))
	{
		$forumid = $wol_thread["$threadid"]['forumid'];
	}
	else if (!$forumid AND isset($wol_thread["$wol_post[$postid]"]['forumid']))
	{
		$forumid = $wol_thread["$wol_post[$postid]"]['forumid'];
	}
	$threadtitle = fetch_censored_text($wol_thread["$threadid"]['title']);
	$threadprefix = ($wol_thread["$threadid"]['prefixid'] ? $vbphrase['prefix_' . $wol_thread["$threadid"]['prefixid'] . '_title_rich'] . ' ' : '');
	$canview = $vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canview'];
	$canviewothers = $vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canviewothers'];
	$canviewthreads = $vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canviewthreads'];
	$postuserid = $wol_thread["$threadid"]['postuserid'];
	$forumtitle = $vbulletin->forumcache["$forumid"]['title'];
	$threadpreview = $wol_thread["$threadid"]['preview'];

	if (!$calendarid AND isset($wol_event["$eventid"]['calendarid']))
	{
		$calendarid = $wol_event["$eventid"]['calendarid'];
	}
	$eventtitle = htmlspecialchars_uni($wol_event["$eventid"]['title']);
	$eventpostuserid = $wol_event["$eventid"]['postuserid'];
	$calendartitle = $wol_calendar["$calendarid"];
	$canviewcalendar = $vbulletin->userinfo['calendarpermissions']["$calendarid"] & $vbulletin->bf_ugp_calendarpermissions['canviewcalendar'];
	$canviewothersevent = $vbulletin->userinfo['calendarpermissions']["$calendarid"] & $vbulletin->bf_ugp_calendarpermissions['canviewothersevent'];

	if (($wol_thread["$threadid"]['isdeleted'] OR !$wol_thread["$threadid"]['visible']) AND !can_moderate($forumid))
	{
		$threadviewable = 0;
	}
	else
	{
		$threadviewable = 1;
	}

	if ($threadviewable AND $threadtitle AND $canview AND ($canviewothers OR $postuserid == $vbulletin->userinfo['userid']) AND verify_forum_password($forumid, $vbulletin->forumcache["$forumid"]['password'], false))
	{
		$seetitle = 1;
	}
	if ($forumtitle AND ($canview OR $vbulletin->forumcache["$forumid"]['showprivate'] > 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND $vbulletin->options['showprivateforums'])))
	{
		$seeforum = 1;
	}
	if ($eventtitle AND $canviewcalendar AND ($canviewothersevent OR $eventpostuserid == $vbulletin->userinfo['userid']))
	{
		$seeevent = 1;
	}
	if ($calendartitle AND $canviewcalendar)
	{
		$seecalendar = 1;
	}
	if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'])
	{
		if ($userinfo['pmid'])
		{
			$seeuserid = $wol_pm["$userinfo[pmid]"];
		}
		else if ($userinfo['searchid'])
		{
			$seeuserid = $wol_search["$searchid"]['targetuserid'];
		}
		else if ($userinfo['infractionid'])
		{
			$seeuserid = $wol_inf["$userinfo[infractionid]"]['userid'];
		}
		else
		{
			$seeuserid = $userinfo['targetuserid'];
		}
		$username = $wol_user["$seeuserid"]['musername'];
	}

	if (strpos($userinfo['location'], 'route:') === 0)
	{
		$handled = false;

		$location = substr($userinfo['location'], strlen('route:'));
		$location = explode('|', $location);

		if (sizeof($location) == 4)
		{
			try
			{
				if (!defined('VB_FRAMEWORK'))
				{
					require_once(DIR . '/includes/class_bootstrap_framework.php');
					vB_Bootstrap_Framework::init();
				}

				list($route_path, $phrasegroup, $phrasekey, $title) = $location;
				$route_path = urldecode($route_path);
				$title = urldecode($title);
				$route = vB_Router::createRoute($route_path);

				$userinfo['action'] = new vB_Phrase($phrasegroup, $phrasekey);
				$userinfo['where'] = '<a href="' . $route->getCurrentUrl() . '">' . htmlspecialchars_uni($title) . '</a>';

				if (vB::$vbulletin->session->vars['sessionhash'])
				{
					$userinfo['where'] .= '&amp;s=' . vB::$vbulletin->session->vars['sessionhash'];
				}

				$handled = true;
			}
			catch (vB_Exception $e){}
		}
	}

	if (!$handled)
	{
		switch($userinfo['activity'])
		{
			case 'visitormessage_posting':
				$userinfo['action'] = $vbphrase['posting_visitor_message'];
				break;
			case 'visitormessage_delete':
				$userinfo['action'] = $vbphrase['deleting_visitor_message'];
				break;
			case 'viewingipaddress':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</b></i>';
				if (can_moderate())
				{
					$userinfo['action'] = $vbphrase['viewing_ip_address'];
				}
				break;
			case 'visitormessage_reporting':
				$userinfo['action'] = $vbphrase['reporting_visitor_message'];
				break;

			case 'posthistory':
				$userinfo['action'] = $vbphrase['viewing_post_history'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title']), array('p' => $postid)) . "#post$postid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;

			case 'tags':
				$userinfo['action'] = $vbphrase['managing_tags'];
				break;

			case 'tag_list':
				$userinfo['action'] = $vbphrase['viewing_tag_list'];
				break;

			case 'socialgroups_join':
				$userinfo['action'] = $vbphrase['joining_social_group'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_leave':
				$userinfo['action'] = $vbphrase['leaving_social_group'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_edit':
				$userinfo['action'] = $vbphrase['editing_social_group'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_view':
				$userinfo['action'] = $vbphrase['viewing_social_group'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_memberlist':
				$userinfo['action'] = $vbphrase['viewing_social_group_memberlist'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=viewmembers&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_delete':
				$userinfo['action'] = $vbphrase['deleting_social_group'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=viewmembers&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_create':
				$userinfo['action'] = $vbphrase['creating_social_group'];
				break;
			case 'socialgroups_list':
				$userinfo['action'] = $vbphrase['viewing_social_group_list'];
				if ($canviewgroup)
				{
					$userinfo['where'] = '<a href="group.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;groupid=$groupid\">$groupname</a>";
				}
				break;
			case 'socialgroups_subscriptions':
				$userinfo['action'] = $vbphrase['viewing_social_group_subscriptions'];
				break;

			case 'group_inlinemod':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</i></b>';
				break;
			case 'showthread':
				$userinfo['action'] = $vbphrase['viewing_thread'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'showpost':
				$userinfo['action'] = $vbphrase['viewing_thread'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title']), array('p' => $postid)) . "#post$postid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'forumdisplay':
				$userinfo['action'] = $vbphrase['viewing_forum'];
				if ($seeforum)
				{
					if ($vbulletin->forumcache["$forumid"]['link'])
					{
						$userinfo['action'] = $vbphrase['followed_forum_link'];
					}
					$userinfo['where'] = '<a href="' . fetch_seo_url('forum', array('forumid' => $forumid, 'title' => $forumtitle)) . "\">$forumtitle</a>";
				}
				break;
			case 'newthread':
				$userinfo['action'] = $vbphrase['creating_thread'];
				if ($seeforum)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('forum', array('forumid' => $forumid, 'title' => $forumtitle)) . "\">$forumtitle</a>";
				}
				break;
			case 'newreply':
				$userinfo['action'] = $vbphrase['replying_to_thread'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'attachments':
			case 'manageattachment':
				$userinfo['action'] = $vbphrase['managing_attachments'];
				break;
			case 'attachment':
				$userinfo['action'] = $vbphrase['viewing_attachment'];
				break;
			case 'index':
				$userinfo['action'] = $vbphrase['viewing_index'];
				$userinfo['where'] = '<a href="' . $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . '</a>';
				break;
			case 'online':
				$userinfo['action'] = $vbphrase['viewing_whos_online'];
				break;
			case 'searchnew':
				$userinfo['action'] = $vbphrase['viewing_new_posts'];
				$userinfo['where'] = '<a href="search.php?' . $vbulletin->session->vars['sessionurl'] . "do=getnew\">$vbphrase[new_posts]</a>";
				break;
			case 'search':
				$userinfo['action'] = $vbphrase['searching_forums'];
				if ($searchid AND $vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'])
				{
					if ($searchquery)
					{
						$userinfo['where'] = construct_phrase($vbphrase['query_x'], htmlspecialchars_uni($searchquery));
					}
					if ($searchuser AND $wol_search["$searchid"]['targetuserid'])
					{
						if ($searchquery)
						{
							$userinfo['where'] .= '<br />';
						}
						$userinfo['where'] .= construct_phrase($vbphrase['user_x'], '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>");
					}
				}
				break;
			case 'mail':
				$userinfo['action'] = $vbphrase['emailing'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'getinfo':
				$userinfo['action'] = $vbphrase['viewing_user_profile'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'converse':
				$userinfo['action'] = $vbphrase['viewing_conversation'];
				if ($seeuserid AND $wol_user["{$userinfo['guestuserid']}"])
				{
					$userinfo['where'] = construct_phrase($vbphrase['x_and_y_converse'], '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>", '<a href="' . fetch_seo_url('member', array('userid' => $userinfo['guestuserid'], 'username' => $wol_user["{$userinfo['guestuserid']}"])) . "\">$username</a>");
				}
				break;
			case 'editprofile':
				$userinfo['action'] = $vbphrase['modifying_profile'];
				break;
			case 'editoptions':
				$userinfo['action'] = $vbphrase['modifying_options'];
				break;
			case 'lostpw':
			case 'editpassword':
				$userinfo['action'] = $vbphrase['modifying_password'];
				break;
			case 'editavatar':
				$userinfo['action'] = $vbphrase['modifying_avatar'];
				break;
			case 'editprofilepic':
				$userinfo['action'] = $vbphrase['modifying_profilepic'];
				break;
			case 'editsignature':
				$userinfo['action'] = $vbphrase['modifying_signature'];
				break;
			case 'markread':
				$userinfo['where'] = $vbphrase['marking_forums_read'];
				break;
			case 'whoposted':
				if ($seetitle)
				{
					$userinfo['action'] = $vbphrase['viewing_who_posted'];
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_thread'];
				}
				break;
			case 'showattachments':
				if ($seetitle)
				{
					$userinfo['action'] = $vbphrase['viewing_attachment_list'];
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_thread'];
				}
				break;
			case 'showgroups':
				$userinfo['action'] = $vbphrase['viewing_forum_leaders'];
				break;
			case 'login':
				$userinfo['action'] = $vbphrase['logging_in'];
				break;
			case 'logout':
				if ($userinfo['badlocation'])
				{
					$userinfo['action'] = $vbphrase['logging_out'];
				}
				break;
			case 'archive':
				$userinfo['action'] = $vbphrase['viewing_archives'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . "<a href=\"archive/index.php/t-$threadid.html\" title=\"$threadpreview\">$threadtitle</a>";
				}
				else if ($seeforum)
				{
					$userinfo['where'] = "<a href=\"archive/index.php/f-$forumid.html\">$forumtitle</a>";
				}
				break;
			case 'pm':
				$userinfo['action'] = $vbphrase['private_messaging'];
				if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'])
				{
					if ($seeuserid)
					{
						$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
					}
					if ($userinfo['values']['do'] == 'newpm' OR $userinfo['values']['do'] == 'insertpm' OR $userinfo['values']['do'] == 'newmessage')
					{
						$userinfo['action'] = $vbphrase['creating_private_message'];
					}
					else if ($userinfo['values']['do'] == 'editfolders' OR $userinfo['action']['do'] == 'updatefolders')
					{
						$userinfo['action'] = $vbphrase['modifying_private_message_folders'];
					}
					else if ($userinfo['values']['do'] == 'trackpm' OR $userinfo['values']['do'] == 'deletepmreceipt')
					{
						$userinfo['action'] = $vbphrase['tracking_private_messages'];
					}
					else if ($userinfo['values']['do'] == 'showpm')
					{
						$userinfo['action'] = $vbphrase['viewing_private_message'];
					}
					else if ($userinfo['values']['do'] == 'downloadpm')
					{
						$userinfo['action'] = $vbphrase['downloading_private_messages'];
					}

				}
				break;
			case 'addbuddy':
			case 'addignore':
			case 'buddyignore':
				$userinfo['action'] = $vbphrase['modifying_contact_ignore_list'];
				break;
			case 'subfolders':
				$userinfo['action'] = $vbphrase['modifying_subscription_folders'];
				break;
			case 'subscription':
				$userinfo['action'] = $vbphrase['viewing_subscribed_threads'];
				break;
			case 'addsubforum':
				$userinfo['action'] = $vbphrase['subscribing_to_forum'];
				if ($seeforum)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('forum', array('forumid' => $forumid, 'title' => $forumtitle)) . "\">$forumtitle</a>";
				}
				break;
			case 'addsubthread':
				$userinfo['action'] = $vbphrase['subscribing_to_thread'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'remsubthread':
				$userinfo['action'] = $vbphrase['deleting_subscribed_threads'];
				break;
			case 'remsubforum':
				$userinfo['action'] = $vbphrase['deleting_subscribed_forums'];
				break;
			case 'usercp':
				$userinfo['action'] = $vbphrase['viewing_user_control_panel'];
				break;
			case 'memberlistsearch':
				$userinfo['action'] = $vbphrase['searching_member_list'];
				break;
			case 'memberlist':
				$userinfo['action'] = $vbphrase['viewing_member_list'];
				break;

			case 'member_inlinemod':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</i></b>';
				if (can_moderate())
				{
					if ($seeuserid)
					{
						$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
					}
				}
			break;

			case 'inlinemod':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</i></b>';
				if (can_moderate())
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
					switch ($userinfo['values']['do'])
					{
						case 'open':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_opening_threads'] . '</i>';
							break;
						case 'close':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_closing_threads'] . '</i>';
							break;
						case 'stick':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_sticking_threads'] . '</i>';
							break;
						case 'unstick':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_unsticking_threads'] . '</i>';
							break;
						case 'deletethread':
						case 'dodeletethreads':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_deleting_threads'] . '</i>';
							break;
						case 'undeletethread':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_undeleting_threads'] . '</i>';
							break;
						case 'approvethread':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_approving_threads'] . '</i>';
							break;
						case 'unapprovethread':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_unapproving_threads'] . '</i>';
							break;

						case 'movethread':
						case 'domovethreads':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_moving_threads'] . '</i>';
							break;

						case 'mergethread':
						case 'domergethreads':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_merging_threads'] . '</i>';
							break;

						case 'deleteposts':
						case 'dodeleteposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_deleting_posts'] . '</i>';
							break;

						case 'undeleteposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_undeleting_posts'] . '</i>';
							break;
						case 'approveposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_approving_posts'] . '</i>';
							break;
						case 'unapproveposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_unapproving_posts'] . '</i>';
							break;

						case 'mergeposts':
						case 'domergeposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_merging_posts'] . '</i>';
							break;

						case 'moveposts':
						case 'domoveposts':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_moving_posts'] . '</i>';
							break;

						case 'clearthread':
						case 'clearpost':
							$userinfo['action'] = '<i>' . $vbphrase['inline_mod_clear'] . '</i>';
							break;
						case 'spampost':
						case 'dodeletespam':
						case 'spamconfirm':
							$userinfo['action'] = '<i>' . $vbphrase['managing_spam'] . '</i>';
							break;

					}
				}
				break;

			case 'postings':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</b></i>';
				if (can_moderate($forumid) AND $threadtitle AND $canview AND ($canviewothers OR $postuserid == $vbulletin->userinfo['userid']))
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) ."\" title=\"$threadpreview\">$threadtitle</a>";
					switch ($userinfo['values']['do'])
					{
						case 'editthread':
						case 'updatethread':
							$userinfo['action'] = '<i>' . $vbphrase['modifying_thread'] . '</i>';
							break;
						case 'openclosethread':
							$userinfo['action'] = '<i>' . $vbphrase['open_close_thread'] . '</i>';
							break;
						case 'movethread':
							$userinfo['action'] = '<i>' .$vbphrase['choosing_forum_to_move_thread_to'] . '</i>';
							break;
						case 'domovethread':
							switch($userinfo['values']['method'])
							{
								case 'copy':
									$userinfo['action'] = '<i>' . $vbphrase['copying_thread_to_forum'] . '</i>';
									break;
								case 'move':
									$userinfo['action'] = '<i>' . $vbphrase['moving_thread_to_forum'] . '</i>';
									break;
								case 'movered':
									$userinfo['action'] = '<i>' . $vbphrase['moving_thread_with_redirect_to_forum'] . '</i>';
									break;
							}
							$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a><br />" .
											'<a href="' . fetch_seo_url('forum', array('forumid' => $forumid, 'title' => $forumtitle)) . "\">$forumtitle</a>";
							break;
						case 'deletethread':
						case 'dodeletethread':
							$userinfo['action'] = '<i>' . $vbphrase['deleting_thread'] . '</i>';
							break;
						case 'deleteposts':
						case 'dodeleteposts':
							$userinfo['where'] = '<i>' . $vbphrase['deleting_posts'] . '</i>';
							break;
						case 'merge':
						case 'domergethread':
							$userinfo['where'] = '<i>' . $vbphrase['merging_threads'] . '</i>';
							break;
						case 'stick':
							$userinfo['where'] = '<i>' . $vbphrase['stick_unstick_thread'] . '</i>';
							break;
						case 'getip':
							$userinfo['where'] = '<i>' . $vbphrase['viewing_ip_address'] . '</i>';
							break;
						case 'removeredirect':
							$userinfo['where'] = '<i>' . $vbphrase['deleting_redirect'] . '</i>';
							break;
					}
				}
				break;
			case 'register':
				$userinfo['action'] = $vbphrase['registering'];
				break;
			case 'requestemail':
				$userinfo['action'] = $vbphrase['request_activation_code'];
				break;
			case 'activate':
				$userinfo['action'] = $vbphrase['activating_registration'];
				break;
			case 'announcement':
				$userinfo['action'] = $vbphrase['viewing_announcement'];
				if ($seeforum)
				{
					$userinfo['where'] = '<a href="announcement.php?' . $vbulletin->session->vars['sessionurl'] . "f=$forumid\">$forumtitle</a>";
				}
				break;
			case 'usergroup':
				$userinfo['action'] = $vbphrase['modifying_usergroups'];
				break;
			case 'polls':
				switch ($userinfo['values']['do'])
				{
					case 'showresults':
						$userinfo['action'] = $vbphrase['viewing_poll'];
						break;
					case '':
					case 'newpoll':
					case 'postpoll':
						$userinfo['action'] = $vbphrase['creating_poll'];
						if ($seeforum)
						{
							$userinfo['where'] = '<a href="' . fetch_seo_url('forum', array('forumid' => $forumid, 'title' => $forumtitle)) . "\">$forumtitle</a>";
						}
						break;
					case 'polledit':
					case 'updatepoll':
						$userinfo['action'] = $vbphrase['modifying_poll'];
						break;
					case 'pollvote':
						$userinfo['action'] = $vbphrase['voting'];
						break;
				}
				break;
			case 'showsmilies':
				$userinfo['action'] = $vbphrase['viewing_smilies'];
				break;
			case 'showavatars':
				$userinfo['action'] = $vbphrase['viewing_avatars'];
				break;
			case 'bbcode':
				$userinfo['action'] = $vbphrase['viewing_bb_code'];
				break;
			case 'faq':
				$userinfo['action'] = $vbphrase['viewing_faq'];
				break;
			case 'edit':
				$userinfo['action'] = $vbphrase['modifying_post'];
				if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'] AND $seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title']), array('p' => $postid)) ."#post$postid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'sendto':
				$userinfo['action'] = $vbphrase['sending_thread_to_friend'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="printthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$threadid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'contactus':
				$userinfo['action'] = $vbphrase['sending_forum_feedback'];
				break;
			case 'aim':
				$userinfo['action'] = $vbphrase['sending_aim_message'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'msn':
				$userinfo['action'] = $vbphrase['sending_msn_message'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'yahoo':
				$userinfo['action'] = $vbphrase['sending_yahoo_message'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'icq':
				$userinfo['action'] = $vbphrase['sending_icq_message'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'skype':
				$userinfo['action'] = $vbphrase['sending_skype_message'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
				}
				break;
			case 'report':
				if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'] AND $seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title']), array('p' => $postid)) ."#post$postid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				$userinfo['action'] = $vbphrase['reporting_post'];
				break;
			case 'printthread':
				$userinfo['action'] = $vbphrase['viewing_printable_version'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="printthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$threadid\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'calendarweek':
				$userinfo['action'] = $vbphrase['viewing_calendar'];
				if ($seecalendar)
				{
					if ($userinfo['week'])
					{
						$week = "&amp;week=$userinfo[week]";
					}
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=displayweek&amp;c=$calendarid$week\">$calendartitle</a>";

				}
				break;
			case 'calendarmonth';
				$userinfo['action'] = $vbphrase['viewing_calendar'];
				if ($seecalendar)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=displaymonth&amp;c=$calendarid&amp;month=$userinfo[month]&amp;year=$userinfo[year]\">$calendartitle</a>";
				}
				break;
			case 'calendaryear';
				$userinfo['action'] = $vbphrase['viewing_calendar'];
				if ($seecalendar)
				{
					if ($userinfo['year'])
					{
						$year = "&amp;year=$userinfo[year]";
					}
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=displayyear&amp;c=$calendarid$year\">$calendartitle</a>";
				}
				break;
			case 'calendarday':
				$userinfo['action'] = $vbphrase['viewing_calendar'];
				if ($seecalendar)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=getday&amp;c=$calendarid&amp;day=$userinfo[day]\">$calendartitle</a>";
				}
				break;
			case 'calendarevent':
				$userinfo['action'] = $vbphrase['viewing_event'];
				if ($seeevent)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=getinfo&amp;e=$eventid\">$eventtitle</a>";
				}
				break;
			case 'calendaradd':
			case 'calendaraddrecur':
				$userinfo['action'] = $vbphrase['creating_event'];
				if ($seecalendar)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "c=$calendarid\">$calendartitle</a>";
				}
				break;
			case 'calendaredit':
				$userinfo['action'] = $vbphrase['modifying_event'];
				if ($seeevent)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=getinfo&amp;e=$eventid\">$eventtitle</a>";
				}
				break;
			case 'calreminder':
				$userinfo['action'] = $vbphrase['managing_reminder'];
				if ($seeevent)
				{
					$userinfo['where'] = '<a href="calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=getinfo&amp;e=$eventid\">$eventtitle</a>";
				}
				break;
			case 'newusernote':
				$userinfo['action'] = $vbphrase['creating_user_note'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="usernote.php?' . $vbulletin->session->vars['sessionurl'] . "do=viewuser&amp;u=$seeuserid\">$username</a>";
				}
				break;
			case 'usernote':
				$userinfo['action'] = $vbphrase['viewing_user_note'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="usernote.php?' . $vbulletin->session->vars['sessionurl'] . "do=viewuser&amp;u=$seeuserid\">$username</a>";
				}
				break;
			case 'reputation':
				$userinfo['action'] = $vbphrase['giving_reputation'];
				if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'] AND $seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'joinrequests':
				$userinfo['action'] = $vbphrase['processing_joinrequests'];
				if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinefull'] AND $vbulletin->usergroupcache["$userinfo[usergroupid]"]['title'])
				{
					$userinfo['where'] = construct_phrase($vbphrase['viewing_x'], $vbulletin->usergroupcache["$userinfo[usergroupid]"]['title']);
				}
				break;
			case 'threadrate':
				$userinfo['action'] = $vbphrase['rating_thread'];
				if ($seetitle)
				{
					$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title'])) . "\" title=\"$threadpreview\">$threadtitle</a>";
				}
				break;
			case 'infractionreport':
				if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cangiveinfraction'] OR $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_wolpermissions['canreverseinfraction'])
				{
					$userinfo['action'] = $vbphrase['giving_infraction'];
					if ($seeuserid)
					{
						$userinfo['where'] = '<a href="' . fetch_seo_url('member', array('userid' => $seeuserid, 'username' => $wol_user["$seeuserid"]['username'])) . "\">$username</a>";
					}
					else if ($seetitle)
					{
						$userinfo['where'] = $threadprefix . '<a href="' . fetch_seo_url('thread', array('threadid' => $threadid, 'title' => $wol_thread["$threadid"]['title']), array('p' => $postid)) . "#post$postid\" title=\"$threadpreview\">$threadtitle</a>";
					}
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'infractionreverse':
				if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cangiveinfraction'] OR $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_wolpermissions['canreverseinfraction'])
				{
					$userinfo['action'] = $vbphrase['reversing_infraction'];
					if ($seeuserid)
					{
						$userinfo['where'] = '<a href="infraction.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;infractionid=$userinfo[infractionid]\">$username</a>";
					}
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'infractionview':
				if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cangiveinfraction'] OR $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_wolpermissions['canreverseinfraction'])
				{
					$userinfo['action'] = $vbphrase['viewing_infraction'];
					if ($seeuserid)
					{
						$userinfo['where'] = '<a href="infraction.php?' . $vbulletin->session->vars['sessionurl'] . "do=view&amp;infractionid=$userinfo[infractionid]\">$username</a>";
					}
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_deletedthreads':
				if (can_moderate())
				{
					$userinfo['action'] = $vbphrase['viewing_deleted_threads'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_deletedposts':
				if (can_moderate())
				{
					$userinfo['action'] = $vbphrase['viewing_deleted_posts'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_deletedvms':
				if (can_moderate(0,'canmoderatevisitormessages'))
				{
					$userinfo['action'] = $vbphrase['viewing_deleted_visitor_messages'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_deletedgms':
				if (can_moderate(0, 'canmoderategroupmessages'))
				{
					$userinfo['action'] = $vbphrase['viewing_deleted_social_group_messages'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_deletedpcs':
				if (can_moderate(0, 'canmoderatepicturecomments'))
				{
					$userinfo['action'] = $vbphrase['viewing_deleted_picture_comments'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedthreads':
				if (can_moderate(0, 'canmoderateposts'))
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_threads'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedposts':
				if (can_moderate(0, 'canmoderateposts'))
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_posts'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedvms':
				if (can_moderate(0, 'canmoderatevisitormessages'))
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_visitor_messages'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedgms':
				if (can_moderate(0, 'canmoderategroupmessages'))
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_social_group_messages'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedpcs':
				if (can_moderate(0, 'canmoderatepicturecomments'))
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_picture_comments'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'modcp_moderatedattachments':
				if (can_moderate())
				{
					$userinfo['action'] = $vbphrase['viewing_moderated_attachments'];
				}
				else
				{
					$userinfo['action'] = $vbphrase['viewing_index'];
				}
				break;
			case 'payments':
				$userinfo['action'] = $vbphrase['viewing_paid_subscriptions'];
				break;
			case 'spider':
				$userinfo['action'] = $vbphrase['search_engine_spider'];
				break;
			case 'admincp':
				$userinfo['action'] = $vbphrase['admin_control_panel'];
				break;
			case 'admincplogin':
				$userinfo['action'] = $vbphrase['admin_control_panel_login'];
				break;
			case 'modcp':
				$userinfo['action'] = $vbphrase['moderator_control_panel'];
				break;
			case 'modcplogin':
				$userinfo['action'] = $vbphrase['moderator_control_panel_login'];
				break;
			case 'album_delete':
				$userinfo['action'] = $vbphrase['deleting_album'];
				break;

			case 'album_edit_album':
			{
				$userinfo['action'] = $vbphrase['editing_album'];
				if ($canviewalbum)
				{
					$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid\">$albumname</a>";
				}
				break;
			}

			case 'album_new_album':
				$userinfo['action'] = $vbphrase['creating_album'];
				break;

			case 'album_edit_picture':
			{
				$userinfo['action'] = $vbphrase['editing_pictures'];
				if ($canviewalbum)
				{
					if (!empty($userinfo['attachmentid']))
					{
						$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid&amp;attachmentid=" . $userinfo['attachmentid'] ."\">$albumname</a>";
					}
					else
					{
						$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid\">$albumname</a>";
					}
				}
			}
			break;

			case 'album_upload':
			{
				$userinfo['action'] = $vbphrase['uploading_pictures'];
				if ($canviewalbum)
				{
					$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid\">$albumname</a>";
				}
			}
			break;

			case 'album_picture':
			{
				$userinfo['action'] = $vbphrase['viewing_picture'];
				if ($canviewalbum)
				{
					if (!empty($userinfo['attachmentid']))
					{
						$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid&amp;attachmentidid=" . $userinfo['attachmentid'] ."\">$albumname</a>";
					}
					else
					{
						$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid\">$albumname</a>";
					}
				}
			}
			break;

			case 'album_album':
			{
				$userinfo['action'] = $vbphrase['viewing_album'];
				if ($canviewalbum)
				{
					$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=$albumid\">$albumname</a>";
				}
			}
			break;

			case 'album_user':
			{
				$userinfo['action'] = $vbphrase['viewing_users_album'];
				if ($seeuserid)
				{
					$userinfo['where'] = '<a href="album.php?' . $vbulletin->session->vars['sessionurl'] . "userid=$seeuserid\">$username</a>";
				}
			}
			break;

			case 'album_unread_comments':
				$userinfo['action'] = $vbphrase['viewing_unread_picture_comments'];
				break;

			case 'album_moderated_comments':
				$userinfo['action'] = $vbphrase['viewing_picture_comments_awaiting_approval'];
				break;

			case 'picturecomment_posting':
				$userinfo['action'] = $vbphrase['posting_picture_comment'];
				break;

			case 'picturecomment_delete':
				$userinfo['action'] = $vbphrase['deleting_picture_comment'];
				break;

			case 'picturecomment_reporting':
				$userinfo['action'] = $vbphrase['reporting_picture_comment'];
				break;

			case 'picture_inlinemod':
				$userinfo['action'] = '<b><i>' . $vbphrase['moderating'] . '</i></b>';
				break;
				
			case 'viewing_cms_content':
				require_once(DIR . '/includes/functions_login.php');
				$userinfo['action'] = $vbphrase['viewing_cms_content']  ;
				$userinfo['location'] = fetch_replaced_session_url(stripslashes($userinfo['location']));
				$userinfo['where'] = "<a href=\"$userinfo[location]\">$userinfo[location]</a>";
				break;
				
			case 'viewing_cms_list':
				require_once(DIR . '/includes/functions_login.php');
				$userinfo['action'] =$vbphrase['viewing_cms_list'] ;
				$userinfo['location'] = fetch_replaced_session_url(stripslashes($userinfo['location']));
				$userinfo['where'] = "<a href=\"$userinfo[location]\">$userinfo[location]</a>";
				break;

			default:
				$handled = false;
				($hook = vBulletinHook::fetch_hook('online_location_unknown')) ? eval($hook) : false;

				if ($handled == false)
				{
					if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinebad'])
					{
						require_once(DIR . '/includes/functions_login.php');
						$userinfo['location'] = fetch_replaced_session_url(stripslashes($userinfo['location']));
						$userinfo['where'] = "<a href=\"$userinfo[location]\">$userinfo[location]</a>";
						$userinfo['action'] = '<b>' . $vbphrase['unknown_location'] . '</b>';
					}
					else
					{
						// We were unable to parse the location
						$userinfo['action'] = $vbphrase['viewing_index'];
						$userinfo['where'] = '<a href="' . $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . "</a>";
					}
				}
		}
	}

	if ($userinfo['badlocation'] == 1)
	{ // User received 'no permissions screen'
		if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinebad'] OR $userinfo['userid'] == $vbulletin->userinfo['userid'])
		{
			$show['nopermission'] = true;
		}
		else
		{
			$userinfo['action'] = $vbphrase['viewing_index'];
			$userinfo['where'] = '<a href="' . $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . "</a>";
		}
	}
	else if ($userinfo['badlocation'] == 2)
	{ // Forum is locked
		$show['lockedout'] = true;
	}
	else if ($userinfo['badlocation'] == 3)
	{ // User received error screen
		if ($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinebad'] OR $userinfo['userid'] == $vbulletin->userinfo['userid'])
		{
			$show['errormessage'] = true;
		}
		else
		{
			$userinfo['action'] = $vbphrase['viewing_index'];
			$userinfo['where'] = '<a href="' . $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . "</a>";
		}
	}
	if (!($vbulletin->userinfo['permissions']['wolpermissions'] & $vbulletin->bf_ugp_wolpermissions['canwhosonlinelocation']))
	{
		unset($userinfo['location']);
	}

	$userinfo['host_encoded'] = urlencode($userinfo['host']);

	if ($vbulletin->options['yestoday'] == 2)
	{
		$userinfo['time'] = vbdate($vbulletin->options['dateformat'], $userinfo['lastactivity'], 1);
	}
	else
	{
		$userinfo['time'] = vbdate($vbulletin->options['timeformat'], $userinfo['lastactivity']);
	}
	$wol_post['userid'] = $userinfo['userid'];
	$wol_post['username'] = $userinfo['realname'];

	($hook = vBulletinHook::fetch_hook('online_bit_complete')) ? eval($hook) : false;

	if ($doall)
	{
		$show['loggedinuser'] = iif($userinfo['userid'], true, false);
		$show['buddy'] = iif($userinfo['buddy'], true, false);
		if ($userinfo['spider'])
		{
			$show['spider'] = true;
			if (!$userinfo['spidertype'] OR !($spidertype = construct_phrase($vbphrase["x_spider_{$userinfo['spidertype']}"], $userinfo['spider'])))
			{
				$spidertype = construct_phrase($vbphrase['x_spider_searchspider'], $userinfo['spider']);
			}
		}
		else
		{
			$show['spider'] = false;
		}

		$show['reallocation'] = iif($userinfo['location'], true, false);
		$show['subscribed'] = iif($wol_thread["$threadid"]['issubscribed'] AND $seetitle, true, false);
		$show['where'] = iif($userinfo['where'], true, false);

		$templater = vB_Template::create('whosonlinebit');
			$templater->register('count', $count);
			$templater->register('ipclass', $ipclass);
			$templater->register('spidertype', $spidertype);
			$templater->register('userinfo', $userinfo);
		$onlinebits = $templater->render();
		return $onlinebits;
	}
	else
	{
		return $userinfo;
	}
}
 /**
  * Initializes the bootstrap and framework.
  */
 public static function init($relative_path = false)
 {
     if (!self::$initialized) {
         global $vbulletin;
         // Check datastore
         // Redundant, loaded by default when datastore is loaded
         //			if (!sizeof($vbulletin->routes) AND VBINSTALL !== true)
         //			{
         //				$vbulletin->datastore->fetch(array('routes'));
         //			}
         // Notify includes they are ok to run
         if (!defined('VB_ENTRY')) {
             define('VB_ENTRY', 1);
         }
         // Mark the framework as loaded
         if (!defined('VB_FRAMEWORK')) {
             define('VB_FRAMEWORK', true);
         }
         // Get the entry time
         if (!defined('VB_ENTRY_TIME')) {
             define('VB_ENTRY_TIME', microtime(true));
         }
         // vB core path
         if (!defined('VB_PATH')) {
             define('VB_PATH', realpath(dirname(__FILE__) . '/../vb') . '/');
         }
         // The package path
         if (!defined('VB_PKG_PATH')) {
             define('VB_PKG_PATH', realpath(VB_PATH . '../packages') . '/');
         }
         // Bootstrap to the new system
         require_once VB_PATH . 'vb.php';
         vB::init($relative_path);
     }
     self::$initialized = true;
 }
	/**
	 * Initializes the bootstrap and framework.
	 */
	public static function init($relative_path = false)
	{
		if (!self::$initialized)
		{
			global $vbulletin;

			// Check datastore
			// TODO: This should be redundant as all routes are accessed via vB_Router
			if (!sizeof($vbulletin->routes))
			{
				$vbulletin->datastore->fetch(array('routes'));
			}

			// Notify includes they are ok to run
			if (!defined('VB_ENTRY'))
			{
				define('VB_ENTRY', 1);
			}

			// Mark the framework as loaded
			if (!defined('VB_FRAMEWORK'))
			{
				define('VB_FRAMEWORK', 1);
			}

			// Get the entry time
			if (!defined('VB_ENTRY_TIME'))
			{
				define('VB_ENTRY_TIME', microtime(true));
			}

			// vB core path
			if (!defined('VB_PATH'))
			{
				define('VB_PATH', realpath(dirname(__FILE__) . '/../vb') . '/');
			}

			// The package path
			if (!defined('VB_PKG_PATH'))
			{
				define('VB_PKG_PATH', realpath(VB_PATH . '../packages') . '/');
			}

			// Bootstrap to the new system
			require_once(VB_PATH . 'vb.php');

			vB::init($relative_path);
		}

		self::$initialized = true;
	}
Exemple #28
0
	/**
	* Verifies the an image property. Must come from this user's album and the album must be public/profile.
	*
	* @param	string	Value to verfiy. May be modified.
	*
	* @return	boolean	True if value.
	*/
	function verify_image(&$value)
	{

		if (!($this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_albums']))
		{
			$value = '';
			return true;
		}

		$foundalbum = preg_match('#albumid=([0-9]+)#', $value, $albumid);
		$foundpicture = preg_match('#attachmentid=([0-9]+)#', $value, $attachmentid);

		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();
		$contenttypeid = intval($types->getContentTypeID('vBForum_Album'));

		if ($foundalbum AND $foundpicture AND $picture = $this->dbobject->query_first("
			SELECT album.userid
			FROM " . TABLE_PREFIX . "attachment AS a
			INNER JOIN " . TABLE_PREFIX . "album AS album ON (a.contentid = album.albumid)
			WHERE
				a.attachmentid = " . intval($attachmentid[1]) . "
	 				AND
	 			a.contenttypeid = $contenttypeid
	 				AND
	 			album.state IN ('profile', 'public')
	 				AND
	 			album.userid = " . $this->userid . "
	 				AND
	 			album.albumid = " . intval($albumid[1]) . "
	 	"))
	 	{
	 		$value = $albumid[1] . "," . $attachmentid[1];
	 		return true;
	 	}
	 	else
	 	{
	 		return false;
	 	}
	}
Exemple #29
0
error_reporting(E_ALL & ~E_NOTICE);
// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('CVS_REVISION', '$RCSfile$ - $Revision: 34205 $');
define('FORCE_HOOKS', true);
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('plugins');
$specialtemplates = array();
// ########################## REQUIRE BACK-END ############################
require_once './global.php';
require_once DIR . '/includes/class_hook.php';
require_once DIR . '/includes/class_block.php';
require_once DIR . '/includes/adminfunctions_plugin.php';
require_once DIR . '/includes/adminfunctions_template.php';
//inits classloader -- required to make vB_Cache work
require_once DIR . '/includes/class_bootstrap_framework.php';
vB_Bootstrap_Framework::init();
// ######################## CHECK ADMIN PERMISSIONS #######################
// don't allow demo version or admin with no permission to administer plugins
if (is_demo_mode() or !can_administer('canadminplugins')) {
    print_cp_no_permission();
}
$vbulletin->input->clean_array_gpc('r', array('pluginid' => TYPE_UINT));
// ############################# LOG ACTION ###############################
log_admin_action(iif($vbulletin->GPC['pluginid'] != 0, 'plugin id = ' . $vbulletin->GPC['pluginid']));
// #############################################################################
// ########################### START MAIN SCRIPT ###############################
// #############################################################################
if ($_REQUEST['do'] != 'download' and $_REQUEST['do'] != 'productexport') {
    print_cp_header($vbphrase['plugin_products_system']);
}
if (empty($_REQUEST['do'])) {
Exemple #30
0
	/**
	* Any code to run after deleting
	*
	* @param	Boolean Do the query?
	*/
	function post_delete($doquery = true)
	{
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "post SET
				username = '******'username']) . "',
				userid = 0
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "groupmessage SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "discussion SET
				lastposter = '" . $this->dbobject->escape_string($this->existing['username']) . "',
				lastposterid = 0
			WHERE lastposterid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "visitormessage SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "visitormessage
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			UPDATE " . TABLE_PREFIX . "usernote SET
				username = '******'username']) . "',
				posterid = 0
			WHERE posterid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "usernote
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "access
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "event
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "customavatar
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['avatarpath'] . '/avatar' . $this->existing['userid'] . '_' . $this->existing['avatarrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "customprofilepic
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['profilepicpath'] . '/profilepic' . $this->existing['userid'] . '_' . $this->existing['profilepicrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "sigpic
			WHERE userid = " . $this->existing['userid'] . "
		");
		@unlink($this->registry->options['sigpicpath'] . '/sigpic' . $this->existing['userid'] . '_' . $this->existing['sigpicrevision'] . '.gif');

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "moderator
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "reputation
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribeforum
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribethread
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribeevent
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscriptionlog
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "session
			WHERE userid = " . $this->existing['userid'] . "
		");
		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "userban
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "usergrouprequest
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "announcementread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "infraction
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "groupread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "discussionread
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribediscussion
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "subscribegroup
			WHERE userid = " . $this->existing['userid'] . "
		");

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "profileblockprivacy
			WHERE userid = " . $this->existing['userid'] . "
		");

		$pendingfriends = array();
		$currentfriends = array();

		$friendlist = $this->dbobject->query_read("
			SELECT relationid, friend
			FROM " . TABLE_PREFIX . "userlist
			WHERE userid = " . $this->existing['userid'] . "
				AND type = 'buddy'
				AND friend IN('pending','yes')
		");

		while ($friend = $this->dbobject->fetch_array($friendlist))
		{
			if ($friend['friend'] == 'yes')
			{
				$currentfriends[] = $friend['relationid'];
			}
			else
			{
				$pendingfriends[] = $friend['relationid'];
			}
		}

		if (!empty($pendingfriends))
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "user
				SET friendreqcount = IF(friendreqcount > 0, friendreqcount - 1, 0)
				WHERE userid IN (" . implode(", ", $pendingfriends) . ")
			");
		}

		if (!empty($currentfriends))
		{
			$this->dbobject->query_write("
				UPDATE " . TABLE_PREFIX . "user
				SET friendcount = IF(friendcount > 0, friendcount - 1, 0)
				WHERE userid IN (" . implode(", ", $currentfriends) . ")
			");
		}

		$this->dbobject->query_write("
			DELETE FROM " . TABLE_PREFIX . "userlist
			WHERE userid = " . $this->existing['userid'] . " OR relationid = " . $this->existing['userid']
		);

		$admindm =& datamanager_init('Admin', $this->registry, ERRTYPE_SILENT);
		$admindm->set_existing($this->existing);
		$admindm->delete();
		unset($admindm);

		$groups = $this->registry->db->query_read("
			SELECT *
			FROM " . TABLE_PREFIX . "socialgroup
			WHERE creatoruserid = " . $this->existing['userid']
		);

		$groupsowned = array();

		while ($group = $this->registry->db->fetch_array($groups))
		{
			$groupsowned[] = $group['groupid'];
		}
		$this->registry->db->free_result($groups);

		if (!empty($groupsowned))
		{
			require_once(DIR . '/includes/functions_socialgroup.php');
			foreach($groupsowned AS $groupowned)
			{
				$group = fetch_socialgroupinfo($groupowned);
				if (!empty($group))
				{
					// dm will have problem if the group is invalid, and in all honesty, at this situation,
					// if the group is no longer present, then we don't need to worry about it anymore.
					$socialgroupdm = datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT);
					$socialgroupdm->set_existing($group);
					$socialgroupdm->delete();
				}
			}
		}

		$groupmemberships = $this->registry->db->query_read("
			SELECT socialgroup.*
			FROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember
			INNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON
				(socialgroup.groupid = socialgroupmember.groupid)
			WHERE socialgroupmember.userid = " . $this->existing['userid']
		);

		$socialgroups = array();
		while ($groupmembership = $this->registry->db->fetch_array($groupmemberships))
		{
			$socialgroups["$groupmembership[groupid]"] = $groupmembership;
		}

		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();

		$picture_sql = $this->registry->db->query_read("
			SELECT a.attachmentid, a.filedataid, a.userid
			FROM " . TABLE_PREFIX . "attachment AS a
			WHERE
				a.userid = " . $this->existing['userid'] . "
					AND
				a.contenttypeid IN (" . intval($types->getContentTypeID('vBForum_SocialGroup')) . "," . intval($types->getContentTypeID('vBForum_Album')) . ")
		");
		$pictures = array();

		$attachdm =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment');
		while ($picture = $this->registry->db->fetch_array($picture_sql))
		{
			$attachdm->set_existing($picture);
			$attachdm->delete();
		}

		if (!empty($socialgroups))
		{
			$this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "socialgroupmember WHERE userid = "  . $this->existing['userid']);

			foreach ($socialgroups AS $group)
			{
				$groupdm =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_STANDARD);
				$groupdm->set_existing($group);
				$groupdm->rebuild_membercounts();
				$groupdm->rebuild_picturecount();
				$groupdm->save();

				list($pendingcountforowner) = $this->registry->db->query_first("
					SELECT SUM(moderatedmembers) FROM " . TABLE_PREFIX . "socialgroup
					WHERE creatoruserid = " . $group['creatoruserid']
				, DBARRAY_NUM);

				$this->registry->db->query_write("
					UPDATE " . TABLE_PREFIX . "user
					SET socgroupreqcount = " . intval($pendingcountforowner) . "
					WHERE userid = " . $group['creatoruserid']
				);
			}

			unset($groupdm);
		}

		$this->registry->db->query_write("
			UPDATE " . TABLE_PREFIX . "socialgroup
			SET transferowner = 0
			WHERE transferowner = " . $this->existing['userid']
		);

		$this->registry->db->query_write("DELETE FROM " . TABLE_PREFIX . "album WHERE userid = " . $this->existing['userid']);


		$this->registry->db->query_write("
			UPDATE " . TABLE_PREFIX . "picturecomment SET
				postusername = '******'username']) . "',
				postuserid = 0
			WHERE postuserid = " . $this->existing['userid'] . "
		");

		require_once(DIR . '/includes/adminfunctions.php');
		delete_user_pms($this->existing['userid'], false);

		require_once(DIR . '/includes/functions_databuild.php');

		($hook = vBulletinHook::fetch_hook('userdata_delete')) ? eval($hook) : false;

		build_user_statistics();
		build_birthdays();
	}