function build_notice_datastore() { global $vbulletin; $notice_cache = array(); $notice_result = $vbulletin->db->query_read("\n\t\tSELECT notice.noticeid, notice.persistent, notice.dismissible,\n\t\t\t noticecriteria.criteriaid, noticecriteria.condition1, \n\t\t\t noticecriteria.condition2, noticecriteria.condition3\n\t\tFROM " . TABLE_PREFIX . "notice AS notice\n\t\tLEFT JOIN " . TABLE_PREFIX . "noticecriteria AS noticecriteria USING(noticeid)\n\t\tWHERE notice.active = 1\n\t\tORDER BY notice.displayorder, notice.title\n\t"); $tmp_notice = false; $counter = 1; $num_rows = $vbulletin->db->num_rows($notice_result); while ($notice = $vbulletin->db->fetch_array($notice_result)) { if ($tmp_notice !== false and $tmp_notice['noticeid'] != $notice['noticeid']) { $notice_cache["{$tmp_notice['noticeid']}"]['persistent'] = $tmp_notice['persistent']; $notice_cache["{$tmp_notice['noticeid']}"]['dismissible'] = $tmp_notice['dismissible']; } if ($notice['criteriaid']) { foreach (array('condition1', 'condition2', 'condition3') as $condition) { $notice_cache["{$notice['noticeid']}"]["{$notice['criteriaid']}"][] = $notice["{$condition}"]; } } if ($counter == $num_rows) { $notice_cache["{$notice['noticeid']}"]['persistent'] = $notice['persistent']; $notice_cache["{$notice['noticeid']}"]['dismissible'] = $notice['dismissible']; } else { $tmp_notice = $notice; ++$counter; } } $vbulletin->db->free_result($notice_result); build_datastore('noticecache', serialize($notice_cache), 1); }
function build_profilefield_cache() { global $vbulletin; $fields = $vbulletin->db->query_read(" SELECT profilefieldid, hidden, required, editable, form FROM " . TABLE_PREFIX . "profilefield AS profilefield WHERE hidden = 1 OR (required = 3 AND editable IN (1,2) AND form = 0) "); $hiddenfields = ''; $requiredfields = array(); while ($field = $vbulletin->db->fetch_array($fields)) { if ($field['hidden'] == 1) { $hiddenfields .= ", '' AS field$field[profilefieldid]"; } if ($field['form'] == 0 AND $field['required'] == 3 AND ($field['editable'] == 1 OR $field['editable'] == 2)) { $requiredfields['field' . $field['profilefieldid']] = $field['profilefieldid']; } } $item = array( 'hidden' => $hiddenfields, 'required' => $requiredfields, ); build_datastore('profilefield', serialize($item), 1); }
/** * Builds the languages datastore item * * @return array The data inserted into datastore */ function build_language_datastore() { global $vbulletin; $languagecache = array(); $languages = $vbulletin->db->query_read("\n\t\tSELECT languageid, title, userselect\n\t\tFROM " . TABLE_PREFIX . "language\n\t\tORDER BY title\n\t"); while ($language = $vbulletin->db->fetch_array($languages)) { $languagecache["{$language['languageid']}"] = $language; } build_datastore('languagecache', serialize($languagecache), 1); return $languagecache; }
function build_navigation_datastore() { global $db, $vbulletin; $result = array(); $data = $db->query_read_slave("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "navigation\n\t\tWHERE state & " . $vbulletin->bf_misc_navstate['deleted'] . " = 0\n\t\tORDER BY navtype, displayorder\n\t"); while ($row = $db->fetch_array($data)) { $result[] = $row; } build_datastore('navdata', serialize($result), 1); return $result ? $result : false; }
function &build_ranks() { global $vbulletin; $ranks = $vbulletin->db->query_read_slave("\n\t\tSELECT ranklevel AS l, minposts AS m, rankimg AS i, type AS t, stack AS s, display AS d, ranks.usergroupid AS u\n\t\tFROM " . TABLE_PREFIX . "ranks AS ranks\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING (usergroupid)\n\t\tORDER BY ranks.usergroupid DESC, minposts DESC\n\t"); $rankarray = array(); while ($rank = $vbulletin->db->fetch_array($ranks)) { $rankarray[] = $rank; } build_datastore('ranks', serialize($rankarray), 1); return $rankarray; }
/** * Builds the languages datastore item * * @return array The data inserted into datastore */ function build_language_datastore() { $languagecache = array(); $languages = vB::getDbAssertor()->assertQuery('language', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_Db_Query::COLUMNS_KEY => array('languageid', 'title', 'userselect', 'charset', 'options')), 'title'); $bf_misc_languageoptions = vB::getDatastore()->getValue('bf_misc_languageoptions'); foreach ($languages as $language) { $language['direction'] = $language['options'] & $bf_misc_languageoptions['direction'] ? 'ltr' : 'rtl'; $languagecache["{$language['languageid']}"] = $language; } build_datastore('languagecache', serialize($languagecache), 1); return $languagecache; }
/** * Caches social bookmark site data to the datastore */ function build_bookmarksite_datastore() { global $vbulletin; $vbulletin->bookmarksitecache = array(); $bookmarksitelist = $vbulletin->db->query_read("\n\t\tSELECT * \n\t\tFROM " . TABLE_PREFIX . "bookmarksite AS bookmarksite\n\t\tWHERE active = 1\n\t\tORDER BY displayorder ASC, bookmarksiteid ASC\n\t"); if ($bookmarksitelist) { while ($bookmarksite = $vbulletin->db->fetch_array($bookmarksitelist)) { $vbulletin->bookmarksitecache["{$bookmarksite['bookmarksiteid']}"] = $bookmarksite; } } // store the cache array into the database build_datastore('bookmarksitecache', serialize($vbulletin->bookmarksitecache), 1); }
function build_attachment_permissions() { $data = array(); $types = vB::getDbAssertor()->assertQuery('vBForum:fetchAllAttachPerms'); foreach ($types as $type) { if (empty($data["{$type['extension']}"])) { $contenttypes = unserialize($type['contenttypes']); $data["{$type['extension']}"] = array('size' => $type['default_size'], 'width' => $type['default_width'], 'height' => $type['default_height'], 'contenttypes' => $contenttypes); } if (!empty($type['usergroupid'])) { $data["{$type['extension']}"]['custom']["{$type['usergroupid']}"] = array('size' => $type['custom_size'], 'width' => $type['custom_width'], 'height' => $type['custom_height'], 'permissions' => $type['custom_permissions']); } } build_datastore('attachmentcache', serialize($data), true); }
function build_attachment_permissions() { global $vbulletin; $data = array(); $types = $vbulletin->db->query_read("\n\t\tSELECT atype.extension, atype.thumbnail, atype.newwindow, aperm.usergroupid,\n\t\t\tatype.height AS default_height, atype.width AS default_width, atype.size AS default_size,\n\t\t\taperm.height AS custom_height, aperm.width AS custom_width, aperm.size AS custom_size,\n\t\t\taperm.attachmentpermissions AS custom_permissions\n\t\tFROM " . TABLE_PREFIX . "attachmenttype AS atype\n\t\tLEFT JOIN " . TABLE_PREFIX . "attachmentpermission AS aperm USING (extension)\n\t\tWHERE enabled = 1\n\t\tORDER BY extension\n\t"); while ($type = $vbulletin->db->fetch_array($types)) { if (empty($data["{$type['extension']}"])) { $data["{$type['extension']}"] = array('size' => $type['default_size'], 'width' => $type['default_width'], 'height' => $type['default_height'], 'thumbnail' => $type['thumbnail'], 'newwindow' => $type['newwindow']); } if (!empty($type['usergroupid'])) { $data["{$type['extension']}"]['custom']["{$type['usergroupid']}"] = array('size' => $type['custom_size'], 'width' => $type['custom_width'], 'height' => $type['custom_height'], 'permissions' => $type['custom_permissions']); } } build_datastore('attachmentcache', serialize($data), 1); }
/** * Caches social bookmark site data to the datastore */ function build_bookmarksite_datastore() { global $vbulletin; $assertor = vB::getDbAssertor(); $vbulletin->bookmarksitecache = array(); $bookmarksitelist = $assertor->assertQuery('vBForum:bookmarksite', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'active' => 1), array('field' => array('displayorder', 'bookmarksiteid'), 'direction' => array(vB_dB_Query::SORT_ASC, vB_dB_Query::SORT_ASC))); //if ($bookmarksitelist) if ($bookmarksitelist and $bookmarksitelist->valid()) { //while ($bookmarksite = $vbulletin->db->fetch_array($bookmarksitelist)) foreach ($bookmarksitelist as $bookmarksite) { $vbulletin->bookmarksitecache["{$bookmarksite['bookmarksiteid']}"] = $bookmarksite; } } // store the cache array into the database build_datastore('bookmarksitecache', serialize($vbulletin->bookmarksitecache), 1); }
/** * Stores a cache of various data for ACP Home Quick Stats into the datastore. */ function build_acpstats_datastore() { global $vbulletin, $starttime, $mysqlversion; $data = $vbulletin->db->query_first("SELECT SUM(filesize) AS size FROM " . TABLE_PREFIX . "filedata"); $vbulletin->acpstats['attachsize'] = $data['size']; $data = $vbulletin->db->query_first("SELECT SUM(filesize) AS size FROM " . TABLE_PREFIX . "customavatar"); $vbulletin->acpstats['avatarsize'] = $data['size']; $data = $vbulletin->db->query_first("SELECT SUM(filesize) AS size FROM " . TABLE_PREFIX . "customprofilepic"); $vbulletin->acpstats['profilepicsize'] = $data['size']; $data = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "user WHERE joindate >= $starttime"); $vbulletin->acpstats['newusers'] = $data['count']; $data = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "user WHERE lastactivity >= $starttime"); $vbulletin->acpstats['userstoday'] = $data['count']; $data = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "post WHERE dateline >= $starttime"); $vbulletin->acpstats['newposts'] = $data['count']; $vbulletin->acpstats['indexsize'] = 0; $vbulletin->acpstats['datasize'] = 0; if ($mysqlversion['version'] >= '3.23') { $vbulletin->db->hide_errors(); $tables = $vbulletin->db->query_write("SHOW TABLE STATUS"); $errno = $vbulletin->db->errno; $vbulletin->db->show_errors(); if (!$errno) { while ($table = $vbulletin->db->fetch_array($tables)) { $vbulletin->acpstats['datasize'] += $table['Data_length']; $vbulletin->acpstats['indexsize'] += $table['Index_length']; } } } if (!$vbulletin->acpstats['indexsize']) { $vbulletin->acpstats['indexsize'] = -1; } if (!$vbulletin->acpstats['datasize']) { $vbulletin->acpstats['datasize'] = -1; } $vbulletin->acpstats['lastupdate'] = TIMENOW; build_datastore('acpstats', serialize($vbulletin->acpstats), 1); }
/** */ function build_notice_datastore() { global $vbulletin; $notice_cache = array(); $notices_result = $vbulletin->db->query_read("\n\t\tSELECT noticeid, persistent\n\t\tFROM " . TABLE_PREFIX . "notice\n\t\tWHERE active = 1\n\t\tORDER BY displayorder, title\n\t"); while ($notice = $vbulletin->db->fetch_array($notices_result)) { $notice_cache["{$notice['noticeid']}"] = array('persistent' => $notice['persistent']); } $vbulletin->db->free_result($notices_result); $criteria_result = $vbulletin->db->query_read("\n\t\tSELECT noticecriteria.*\n\t\tFROM " . TABLE_PREFIX . "noticecriteria AS noticecriteria\n\t\tINNER JOIN " . TABLE_PREFIX . "notice AS notice USING(noticeid)\n\t\tWHERE notice.active = 1\n\t"); while ($criteria = $vbulletin->db->fetch_array($criteria_result)) { $notice_cache["{$criteria['noticeid']}"]["{$criteria['criteriaid']}"] = array(); foreach (array('condition1', 'condition2', 'condition3') as $condition) { $notice_cache["{$criteria['noticeid']}"]["{$criteria['criteriaid']}"][] = $criteria["{$condition}"]; } } $vbulletin->db->free_result($criteria_result); build_datastore('noticecache', serialize($notice_cache), 1); }
function build_profilefield_cache() { global $vbulletin; $fields = $vbulletin->db->query_read("\n\t\tSELECT profilefieldid, hidden, required, editable, form\n\t\tFROM " . TABLE_PREFIX . "profilefield AS profilefield\n\t\tWHERE hidden = 1\n\t\t\tOR (required = 3 AND editable IN (1,2) AND form = 0)\n\t"); $hiddenfields = ''; $requiredfields = array(); while ($field = $vbulletin->db->fetch_array($fields)) { if ($field['hidden'] == 1) { $hiddenfields .= ", '' AS field{$field['profilefieldid']}"; } if ($field['form'] == 0 and $field['required'] == 3 and ($field['editable'] == 1 or $field['editable'] == 2)) { $requiredfields['field' . $field['profilefieldid']] = $field['profilefieldid']; } } $item = array('hidden' => $hiddenfields, 'required' => $requiredfields); //Add cached value to prevent running the fetchCustomProfileFields query- see VBV-10767 $item['all'] = vB::getDbAssertor()->getRows('vBForum:fetchCustomProfileFields', array('hidden' => array(0, 1))); build_datastore('profilefield', serialize($item), 1); }
/** * Stores a cache of various data for ACP Home Quick Stats into the datastore. */ function build_acpstats_datastore() { global $vbulletin; $assertor = vB::getDbAssertor(); $starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $mysqlversion = $assertor->getRow('mysqlVersion'); $data = $assertor->getRow('vBForum:getFiledataFilesizeSum'); $vbulletin->acpstats['attachsize'] = $data['size']; $data = $assertor->getRow('getCustomAvatarFilesizeSum'); $vbulletin->acpstats['avatarsize'] = $data['size']; $data = $assertor->getRow('vBForum:getCustomProfilePicFilesizeSum'); $vbulletin->acpstats['profilepicsize'] = $data['size']; $data = $assertor->getRow('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_COUNT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'joindate', 'value' => $starttime, vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_GTE)))); $vbulletin->acpstats['newusers'] = $data['count']; $data = $assertor->getRow('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_COUNT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'lastactivity', 'value' => $starttime, vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_GTE)))); $vbulletin->acpstats['userstoday'] = $data['count']; $data = $assertor->getRow('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_COUNT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'created', 'value' => $starttime, vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_GTE)))); $vbulletin->acpstats['newposts'] = $data['count']; $vbulletin->acpstats['indexsize'] = 0; $vbulletin->acpstats['datasize'] = 0; try { $tables = $assertor->getRows('getTableStatus', array()); } catch (Exception $ex) { $tables = array(); } if ($tables and !isset($table['errors'])) { foreach ($tables as $table) { $vbulletin->acpstats['datasize'] += $table['Data_length']; $vbulletin->acpstats['indexsize'] += $table['Index_length']; } } if (!$vbulletin->acpstats['indexsize']) { $vbulletin->acpstats['indexsize'] = -1; } if (!$vbulletin->acpstats['datasize']) { $vbulletin->acpstats['datasize'] = -1; } $vbulletin->acpstats['lastupdate'] = vB::getRequest()->getTimeNow(); build_datastore('acpstats', serialize($vbulletin->acpstats), 1); }
function build_notice_datastore() { global $vbulletin; $notice_cache = array(); $notices_result = $vbulletin->db->query_read(" SELECT noticeid, persistent, dismissible FROM " . TABLE_PREFIX . "notice WHERE active = 1 ORDER BY displayorder, title "); while ($notice = $vbulletin->db->fetch_array($notices_result)) { $notice_cache["$notice[noticeid]"] = array('persistent' => $notice['persistent'], 'dismissible' => $notice['dismissible']); } $vbulletin->db->free_result($notices_result); $criteria_result = $vbulletin->db->query_read(" SELECT noticecriteria.* FROM " . TABLE_PREFIX . "noticecriteria AS noticecriteria INNER JOIN " . TABLE_PREFIX . "notice AS notice USING(noticeid) WHERE notice.active = 1 "); while ($criteria = $vbulletin->db->fetch_array($criteria_result)) { $notice_cache["$criteria[noticeid]"]["$criteria[criteriaid]"] = array(); foreach (array('condition1', 'condition2', 'condition3') AS $condition) { $notice_cache["$criteria[noticeid]"]["$criteria[criteriaid]"][] = $criteria["$condition"]; } } $vbulletin->db->free_result($criteria_result); build_datastore('noticecache', serialize($notice_cache), 1); }
/** * Builds the datastore for the hooks into the database. */ public static function build_datastore(&$dbobject) { $code = array(); $admincode = array(); $adminlocations = array(); require_once DIR . '/includes/class_xml.php'; $handle = opendir(DIR . '/includes/xml/'); while (($file = readdir($handle)) !== false) { if (!preg_match('#^hooks_(.*).xml$#i', $file, $matches)) { continue; } $xmlobj = new vB_XML_Parser(false, DIR . "/includes/xml/{$file}"); $xml = $xmlobj->parse(); if (!is_array($xml['hooktype'][0])) { $xml['hooktype'] = array($xml['hooktype']); } foreach ($xml['hooktype'] as $key => $hooktype) { if (!is_numeric($key)) { continue; } if (!is_array($hooktype['hook'])) { $hooktype['hook'] = array($hooktype['hook']); } foreach ($hooktype['hook'] as $hook) { if (is_array($hook) and !empty($hook['admin']) or !empty($hooktype['admin'])) { $adminlocations[is_string($hook) ? $hook : $hook['value']] = true; } } } } $plugins = $dbobject->query_read("\n\t\t\tSELECT plugin.*,\n\t\t\t\tIF(product.productid IS NULL, 0, 1) AS foundproduct,\n\t\t\t\tIF(plugin.product = 'vbulletin', 1, product.active) AS productactive\n\t\t\tFROM " . TABLE_PREFIX . "plugin AS plugin\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "product AS product ON(product.productid = plugin.product)\n\t\t\tWHERE plugin.active = 1\n\t\t\t\tAND plugin." . "phpcode <> ''\n\t\t\tORDER BY plugin.executionorder ASC\n\t\t"); while ($plugin = $dbobject->fetch_array($plugins)) { if ($plugin['foundproduct'] and !$plugin['productactive']) { continue; } else { if (!empty($adminlocations["{$plugin['hookname']}"])) { $admincode["{$plugin['hookname']}"] .= "{$plugin['phpcode']}\r\n"; } else { $code["{$plugin['hookname']}"] .= "{$plugin['phpcode']}\r\n"; } } } $dbobject->free_result($plugins); build_datastore('pluginlist', serialize($code), 1); build_datastore('pluginlistadmin', serialize($admincode), 1); return true; }
/** * Fetches newest groups from datastore or rebuilds the cache. * * @param boolean $force_rebuild Force the cache to be rebuilt * @param boolean $without_icons Fetch groups that have no icon * @return array Array of groupinfos */ function fetch_socialgroup_newest_groups($force_rebuild = false, $without_icons = false, $listview = false) { global $vbulletin; $groups = $vbulletin->sg_newest_groups; // Legacy Hook 'group_fetch_newest' Removed // if ($force_rebuild or !is_array($groups)) { $sql = "SELECT\n\t\t\t\t\tsocialgroup.*, socialgroup.dateline AS createdate, sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid,\n\t\t\t\t\tsocialgroup.groupid, socialgroup.name, socialgroup.description, socialgroup.dateline, sgicon.dateline AS icondateline,\n\t\t\t\t\tsocialgroupmember.type AS membertype, socialgroupmember.dateline AS joindate,\n\t\t\t\t\tsgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\t\t\t\tON (socialgroup.groupid = socialgroupmember.groupid AND socialgroupmember.userid = " . $vbulletin->userinfo['userid'] . ")\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON (sgicon.groupid = socialgroup.groupid)\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)\n\t\t\t\tORDER BY socialgroup.dateline DESC\n\t\t\t\tLIMIT 0, " . ($vbulletin->options['sg_newgroups_count'] ? intval($vbulletin->options['sg_newgroups_count']) : 5) . "\n\t\t"; $newgroups = $vbulletin->db->query_read_slave($sql); $groups = array(); while ($group = $vbulletin->db->fetch_array($newgroups)) { $groups[] = $group; } $vbulletin->db->free_result($newgroups); build_datastore('sg_newest_groups', serialize($groups), 1); } return $groups; }
//check for valid zone switch ($zone) { case 'post': case 'blog': case 'vm': case 'group': case 'sig': break; default: print_stop_message('ame_invalid_zone_specified'); } if ($start < 2 && !$cont) { $settings = !is_array($vbulletin->AME_settings) ? unserialize($vbulletin->AME_settings) : $vbulletin->AME_settings; $start = 0; $limitstart = "0"; build_datastore('AME_settings', serialize(array('length' => $length, 'perpage' => $perpage, 'seconds' => $seconds, 'verbose' => $verbose, 'test' => $test, 'codes' => $settings['codes'], 'conversions' => $settings['conversions']))); } else { $limitstart = $start * $perpage; } $return = false; $x = 0; require_once DIR . "/includes/ame_prep.php"; if ($length) { switch ($zone) { case 'post': $and .= " AND p.dateline >= " . (TIMENOW - $length); break; case 'blog': case 'group': case 'vm': $and .= " AND dateline >= " . (TIMENOW - $length);
/** * Fetches newest groups from datastore or rebuilds the cache. * * @param boolean $force_rebuild Force the cache to be rebuilt * @param boolean $without_icons Fetch groups that have no icon * @return array Array of groupinfos */ function fetch_socialgroup_newest_groups($force_rebuild = false, $without_icons = false, $listview = false) { global $vbulletin; if ($listview) { $without_icons = true; } $groups = $vbulletin->sg_newest_groups; $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('group_fetch_newest')) ? eval($hook) : false; if ($force_rebuild or !is_array($groups)) { $sql = "SELECT " . ($listview ? "socialgroup.*, socialgroup.dateline AS createdate, sgc.title AS categoryname, sgc.socialgroupcategoryid AS categoryid," : "socialgroup.groupid, socialgroup.name, socialgroup.description, socialgroup.dateline, sgicon.dateline AS icondateline,") . "\n\t\t\t\t\tsgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height\n\t\t\t\t{$hook_query_fields}\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroup AS socialgroup " . ($without_icons ? 'LEFT' : 'INNER') . ' JOIN ' . TABLE_PREFIX . 'socialgroupicon AS sgicon ON (sgicon.groupid = socialgroup.groupid) ' . ($listview ? 'INNER JOIN ' . TABLE_PREFIX . 'socialgroupcategory AS sgc ON (sgc.socialgroupcategoryid = socialgroup.socialgroupcategoryid)' : '') . "\n\t\t\t\t{$hook_query_joins}\n\t\t\t\t{$hook_query_where}\n\t\t\t\tORDER BY socialgroup.dateline DESC\n\t\t\t\tLIMIT 0, " . ($vbulletin->options['sg_newgroups_count'] ? intval($vbulletin->options['sg_newgroups_count']) : ($listview ? 20 : 15)) . "\n\t\t"; $newgroups = $vbulletin->db->query_read_slave($sql); $groups = array(); while ($group = $vbulletin->db->fetch_array($newgroups)) { $groups[] = $group; } $vbulletin->db->free_result($newgroups); build_datastore('sg_newest_groups', serialize($groups), 1); } if (sizeof($groups) < 4 and !$without_icons) { return fetch_socialgroup_newest_groups(true, true); } return $groups; }
/** * Execute install code for product * */ public function install() { $vbulletin =& $this->registry; $vbphrase =& $this->vbphrase; $db =& $vbulletin->db; // ############## import install/uninstall code if (is_array($this->productobj['codes']['code'])) { $codes =& $this->productobj['codes']['code']; if (!isset($codes[0])) { $codes = array($codes); } require_once DIR . "/includes/functions.php"; // run each of the codes foreach ($codes as $code) { // Run if: code version is * (meaning always run), no version // previously installed, or if the code is for a newer version // than is currently installed if ($code['version'] == '*' or $this->installed_version === null or is_newer_version($code['version'], $this->installed_version)) { eval($code['installcode']); } } // Clear routes from datastore build_datastore('routes', serialize(array()), 1); //assume that the product may have installed content types and purge the content type cache vB_Cache::instance()->purge('vb_types.types'); } }
$numberguests = 0; if (is_array($guests)) { foreach ($guests as $key => $val) { if ($val['activity'] == 'logout' and $val['badlocation'] == 0) { continue; } $numberguests++; $onlinebits .= construct_online_bit($val, 1); } } $totalonline = $numbervisible + $numberguests; // ### MAX LOGGEDIN USERS ################################ if (intval($vbulletin->maxloggedin['maxonline']) <= $totalonline) { $vbulletin->maxloggedin['maxonline'] = $totalonline; $vbulletin->maxloggedin['maxonlinedate'] = TIMENOW; build_datastore('maxloggedin', serialize($vbulletin->maxloggedin), 1); } $recordusers = $vbulletin->maxloggedin['maxonline']; $recorddate = vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], true); $recordtime = vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']); $currenttime = vbdate($vbulletin->options['timeformat']); $metarefresh = ''; $show['refresh'] = false; if ($vbulletin->options['WOLrefresh']) { $show['refresh'] = true; $refreshargs = ($vbulletin->GPC['who'] ? '&who=' . $vbulletin->GPC['who'] : '') . ($vbulletin->GPC['ua'] ? '&ua=1' : ''); $refreshargs_js = ($vbulletin->GPC['who'] ? '&who=' . $vbulletin->GPC['who'] : '') . ($vbulletin->GPC['ua'] ? '&ua=1' : ''); $refreshtime = $vbulletin->options['WOLrefresh'] * 10; } $frmjmpsel['wol'] = ' selected="selected" class="fjsel"'; construct_forum_jump();
/** * Stores the list of currently installed products into the datastore. */ function build_product_datastore() { global $vbulletin; $products_list = $vbulletin->db->query_read("\n\t\tSELECT productid, active\n\t\tFROM " . TABLE_PREFIX . "product\n\t"); $products = array(); while ($product = $vbulletin->db->fetch_array($products_list)) { $products["{$product['productid']}"] = $product['active']; } $products['vbulletin'] = '1'; $vbulletin->products = $products; build_datastore('products', serialize($products), 1); }
/** * Builds the stylecache and saves it into the datastore * * @return array $stylecache */ function build_style_datastore() { global $stylecache, $vbulletin; if (!is_array($stylecache)) { cache_styles(); // this should not ever be needed unless the user has edited the database if (STYLECOUNT != sizeof($stylecache)) { trigger_error('Invalid row in the style table', E_USER_ERROR); } } $localstylecache = array(); foreach ($stylecache as $styleid => $style) { $localstyle = array(); $localstyle['styleid'] = $style['styleid']; $localstyle['title'] = $style['title']; $localstyle['parentid'] = $style['parentid']; $localstyle['displayorder'] = $style['displayorder']; $localstyle['userselect'] = $style['userselect']; ($hook = vBulletinHook::fetch_hook('admin_style_datastore')) ? eval($hook) : false; $datastorecache["{$localstyle['parentid']}"]["{$localstyle['displayorder']}"][] = $localstyle; } build_datastore('stylecache', serialize($datastorecache), 1); return $datastorecache; }
/** * Updates the LoadAverage DataStore */ function update_loadavg() { global $vbulletin; if (!isset($vbulletin->loadcache)) { $vbulletin->loadcache = array(); } if (function_exists('exec') AND $stats = @exec('uptime 2>&1') AND trim($stats) != '' AND preg_match('#: ([\d.,]+),?\s+([\d.,]+),?\s+([\d.,]+)$#', $stats, $regs)) { $vbulletin->loadcache['loadavg'] = $regs[2]; } else if (@file_exists('/proc/loadavg') AND $filestuff = @file_get_contents('/proc/loadavg')) { $loadavg = explode(' ', $filestuff); $vbulletin->loadcache['loadavg'] = $loadavg[1]; } else { $vbulletin->loadcache['loadavg'] = 0; } $vbulletin->loadcache['lastcheck'] = TIMENOW; build_datastore('loadcache', serialize($vbulletin->loadcache), 1); }
/** * Fetches the HTML for the tag cloud. * * @param string Type of cloud. Supports search, usage * * @return string Tag cloud HTML (nothing if no cloud) */ function fetch_tagcloud($type = 'usage') { global $vbulletin, $stylevar, $vbphrase, $show, $template_hook; if ($vbulletin->options['tagcloud_usergroup'] > 0 and !isset($vbulletin->usergroupcache[$vbulletin->options['tagcloud_usergroup']])) { // handle a usergroup being deleted: default to live permission checking $vbulletin->options['tagcloud_usergroup'] = -1; } $cacheable = $vbulletin->options['tagcloud_usergroup'] != -1; if (!$cacheable) { $cloud = null; } else { switch ($type) { case 'search': $cloud = $vbulletin->searchcloud; break; case 'usage': default: $cloud = $vbulletin->tagcloud; break; } } if (!is_array($cloud) or $cloud['dateline'] < TIMENOW - 60 * $vbulletin->options['tagcloud_cachetime']) { if ($type == 'search') { $tags_result = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT tagsearch.tagid, tag.tagtext, COUNT(*) AS searchcount\n\t\t\t\tFROM " . TABLE_PREFIX . "tagsearch AS tagsearch\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagsearch.tagid = tag.tagid)\n\t\t\t\t" . ($vbulletin->options['tagcloud_searchhistory'] ? "WHERE tagsearch.dateline > " . (TIMENOW - 60 * 60 * 24 * $vbulletin->options['tagcloud_searchhistory']) : '') . "\n\t\t\t\tGROUP BY tagsearch.tagid, tag.tagtext\n\t\t\t\tORDER BY searchcount DESC\n\t\t\t\tLIMIT " . $vbulletin->options['tagcloud_tags']); } else { if (!$vbulletin->options['tagcloud_usergroup']) { $perm_limit = false; } else { $forums = array(); $perm_limit = true; foreach ($vbulletin->forumcache as $forumid => $forum) { // -1 for live permission checking $perm_array = $vbulletin->options['tagcloud_usergroup'] == -1 ? $vbulletin->userinfo['forumpermissions']["{$forumid}"] : $forum['permissions'][$vbulletin->options['tagcloud_usergroup']]; if ($perm_array & $vbulletin->bf_ugp_forumpermissions['canview'] and $perm_array & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and $perm_array & $vbulletin->bf_ugp_forumpermissions['canviewothers']) { $forums[] = intval($forumid); } } } if (!$perm_limit or $forums) { $tags_result = $vbulletin->db->query_read_slave("\n\t\t\t\t\tSELECT tagthread.tagid, tag.tagtext, COUNT(*) AS searchcount\n\t\t\t\t\tFROM " . TABLE_PREFIX . "tagthread AS tagthread\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagthread.tagid = tag.tagid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "thread AS thread ON (tagthread.threadid = thread.threadid)\n\t\t\t\t\tWHERE thread.open <> 10\n\t\t\t\t\t\tAND thread.visible = 1\n\t\t\t\t\t" . ($perm_limit ? "AND thread.forumid IN (" . implode(',', $forums) . ")" : '') . "\n\t\t\t\t\t" . ($vbulletin->options['tagcloud_usagehistory'] ? "AND tagthread.dateline > " . (TIMENOW - 60 * 60 * 24 * $vbulletin->options['tagcloud_usagehistory']) : '') . "\n\t\t\t\t\tGROUP BY tagthread.tagid, tag.tagtext\n\t\t\t\t\tORDER BY searchcount DESC\n\t\t\t\t\tLIMIT " . $vbulletin->options['tagcloud_tags']); } } $total = 0; $count = 0; if (!empty($tags_result)) { $count = $vbulletin->db->num_rows($tags_result); while ($currenttag = $vbulletin->db->fetch_array($tags_result)) { $tags["{$currenttag['tagtext']}"] = $currenttag; $total += $currenttag['searchcount']; } $vbulletin->db->free_result($tags_result); } $final_tags = array(); if ($count > 0) { // calculate the standard deviation $mean = $total / $count; $summation = 0; foreach ($tags as $tagtext => $tagvalue) { $summation += pow($tagvalue['searchcount'] - $mean, 2); } $sd = sqrt($summation / $count); uksort($tags, 'strnatcasecmp'); if ($sd) { $sdtags = array(); $lowestsds = 0; $highestsds = 0; // find the max and min standard deviations foreach ($tags as $tagtext => $currenttag) { $tags["{$tagtext}"]['deviation'] = $currenttag['searchcount'] - $mean; $tags["{$tagtext}"]['sds'] = $tags["{$tagtext}"]['deviation'] / $sd; $sdtags[] = $tags["{$tagtext}"]; if ($tags["{$tagtext}"]['sds'] < $lowestsds) { $lowestsds = $tags["{$tagtext}"]['sds']; } if ($tags["{$tagtext}"]['sds'] > $highestsds) { $highestsds = $tags["{$tagtext}"]['sds']; } } $levels = $vbulletin->options['tagcloud_levels']; foreach ($sdtags as $thistag) { // normalize the std devs to 0 - 1, then map back to 1 - #levls $thistag['level'] = round(($thistag['sds'] - $lowestsds) / ($highestsds - $lowestsds) * ($levels - 1)) + 1; $thistag['tagtext_url'] = urlencode(unhtmlspecialchars($thistag['tagtext'])); $final_tags[] = $thistag; } } else { foreach ($tags as $tagtext => $tagarr) { $final_tags[] = array('tagid' => $tagarr['tagid'], 'tagtext' => $tagtext, 'tagtext_url' => urlencode(unhtmlspecialchars($tagtext)), 'level' => round($vbulletin->options['tagcloud_levels'] / 2)); } } } $cloud = array('tags' => $final_tags, 'count' => sizeof($final_tags), 'dateline' => TIMENOW); if ($cacheable) { if ($type == 'search') { $vbulletin->searchcloud = $cloud; build_datastore('searchcloud', serialize($cloud), 1); } else { $vbulletin->tagcloud = $cloud; build_datastore('tagcloud', serialize($cloud), 1); } } } if (empty($cloud['tags'])) { return ''; } $cloud['links'] = ''; foreach ($cloud['tags'] as $thistag) { ($hook = vBulletinHook::fetch_hook('tag_cloud_bit')) ? eval($hook) : false; eval('$cloud[\'links\'] .= "' . fetch_template('tag_cloud_link') . '";'); } $cloud['count'] = vb_number_format($cloud['count']); if ($type == 'search') { eval('$cloud_html .= "' . fetch_template('tag_cloud_box_search') . '";'); } else { eval('$cloud_html .= "' . fetch_template('tag_cloud_box') . '";'); } return $cloud_html; }
function tagkill() { global $vbulletin, $vbphrase; $taglist = tagcp_fetch_tag_list(); if (sizeof($taglist)) { foreach ($taglist as $killtagid) { $killtagdm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY); if ($killtagdm->fetch_by_id($killtagid)) { $killtagdm->delete(); } } // need to invalidate the search and tag cloud caches build_datastore('tagcloud', '', 1); build_datastore('searchcloud', '', 1); } setcookie('vbulletin_inlinetag', '', TIMENOW - 3600, '/'); print_cp_header($vbphrase['tag_manager']); print_stop_message('tags_deleted_successfully'); }
foreach ($productcodes_grouped['*'] as $productcode) { eval($productcode['uninstallcode']); } } foreach ($productcodes_versions as $version) { foreach ($productcodes_grouped["{$version}"] as $productcode) { eval($productcode['uninstallcode']); } } //remove some common resources that a product may have registered. //tags $db->query_write("\r\n\t\tDELETE tagcontent\r\n\t\tFROM " . TABLE_PREFIX . "package AS package JOIN\r\n\t\t\t" . TABLE_PREFIX . "contenttype AS contenttype ON\r\n\t\t\t\tcontenttype.packageid = package.packageid JOIN\r\n\t\t\t" . TABLE_PREFIX . "tagcontent AS tagcontent ON\r\n\t\t\t\tcontenttype.contenttypeid = tagcontent.contenttypeid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t"); // Packages, routes, actions, contenttypes $db->query_write("\r\n\t\tDELETE package, route, action, contenttype\r\n\t\tFROM " . TABLE_PREFIX . "package AS package\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "route AS route\r\n\t\t\tON route.packageid = package.packageid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "action AS action\r\n\t\t\tON action.routeid = route.routeid\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "contenttype AS contenttype\r\n\t\t\tON contenttype.packageid = package.packageid\r\n\t\tWHERE productid = '{$safe_productid}'\r\n\t"); // Clear routes from datastore build_datastore('routes', serialize(array()), 1); //clear the type cache. vB_Cache::instance()->purge('vb_types.types'); // need to remove the language columns for this product as well require_once DIR . '/includes/class_dbalter.php'; $db_alter = new vB_Database_Alter_MySQL($db); if ($db_alter->fetch_table_info('language')) { $phrasetypes = $db->query_read("\r\n\t\t\tSELECT fieldname\r\n\t\t\tFROM " . TABLE_PREFIX . "phrasetype\r\n\t\t\tWHERE product = '" . $db->escape_string($vbulletin->GPC['productid']) . "'\r\n\t\t"); while ($phrasetype = $db->fetch_array($phrasetypes)) { $db_alter->drop_field("phrasegroup_{$phrasetype['fieldname']}"); } } delete_product($vbulletin->GPC['productid']); build_all_styles(); vBulletinHook::build_datastore($db); require_once DIR . '/includes/adminfunctions_language.php';
print_submit_row($vbphrase['photoplog_yes'], '', 2, $vbphrase['photoplog_no']); } if ($_REQUEST['do'] == 'dodelete') { $vbulletin->input->clean_array_gpc('p', array('catid' => TYPE_UINT)); $photoplog_catid = $vbulletin->GPC['catid']; $photoplog_dscatopts = $photoplog_ds_catopts; $photoplog_child_list = array(); $photoplog_parent_list = array(); photoplog_child_list($photoplog_child_list, $photoplog_parent_list, $photoplog_catid); $photoplog_catids_array = array_merge(array($photoplog_catid), $photoplog_child_list, $photoplog_parent_list); $photoplog_sql = "WHERE catid = " . intval($photoplog_catid); unset($photoplog_dscatopts["{$photoplog_catid}"]); if (!empty($photoplog_child_list)) { $photoplog_sql = "WHERE catid IN (" . intval($photoplog_catid) . "," . implode(",", $photoplog_child_list) . ")"; foreach ($photoplog_child_list as $photoplog_childid) { unset($photoplog_dscatopts["{$photoplog_childid}"]); } } if ($db->query_write("UPDATE " . PHOTOPLOG_PREFIX . "photoplog_fileuploads\r\n\t\t\tSET catid = 0\r\n\t\t\t{$photoplog_sql}\r\n\t\t") && $db->query_write("UPDATE " . PHOTOPLOG_PREFIX . "photoplog_ratecomment\r\n\t\t\tSET catid = 0\r\n\t\t\t{$photoplog_sql}\r\n\t\t") && $db->query_write("DELETE FROM " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\t\t{$photoplog_sql}\r\n\t\t") && $db->query_write("DELETE FROM " . PHOTOPLOG_PREFIX . "photoplog_catcounts\r\n\t\t\t{$photoplog_sql}\r\n\t\t")) { $db->query_write("ALTER TABLE " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\t\tORDER BY parentid, displayorder, catid\r\n\t\t"); // not approved: 0, approved: 1, declined: 2, cat deleted: 3 $db->query_write("UPDATE " . PHOTOPLOG_PREFIX . "photoplog_suggestedcats\r\n\t\t\tSET approve = 3\r\n\t\t\t{$photoplog_sql}\r\n\t\t"); // photoplog_regenerate_counts_table_v2($photoplog_catids_array); photoplog_custom_field_delete_category($photoplog_catid, $photoplog_child_list); build_datastore('photoplog_dscat', serialize($photoplog_dscatopts)); print_cp_redirect("photoplog_category.php?" . $vbulletin->session->vars['sessionurl'] . "do=modify", 1); } else { print_stop_message('generic_error_x', $vbphrase['photoplog_bad_cat_delete']); } } print_cp_footer();
function build_events() { global $vbulletin, $vbphrase, $_CALENDAROPTIONS; if (!$vbulletin->options['showevents']) { return false; } $storeevents = array(); // Store timestamp 48 hours before the current time and 48 hours after the showevent period $beginday = TIMENOW - 172800; $endday = TIMENOW + 86400 + 86400 * $vbulletin->options['showevents']; $storeevents['date'] = gmdate('n-j-Y', $endday); // check if we have at least one calendar with holidays enabled if ($vbulletin->options['showholidays']) { $holiday_calendarids = array(); $holiday_calendars = $vbulletin->db->query_read_slave("\n\t\t\tSELECT calendarid\n\t\t\tFROM " . TABLE_PREFIX . "calendar\n\t\t\tWHERE options & " . intval($_CALENDAROPTIONS['showholidays'])); while ($holiday_calendar = $vbulletin->db->fetch_array($holiday_calendars)) { $holiday_calendarids[] = $holiday_calendar['calendarid']; } $holidays = $vbulletin->db->query_read_slave("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "holiday\n\t\t"); while ($holiday = $vbulletin->db->fetch_array($holidays)) { $holiday['dateline_from'] = $beginday; $holiday['dateline_to'] = $endday; $holiday['visible'] = 1; $holiday['eventid'] = 'h' . $holiday['holidayid']; $holiday['holiday_calendarids'] = $holiday_calendarids; $storeevents["{$holiday['eventid']}"] = $holiday; } } $events = $vbulletin->db->query_read_slave("\n\t\tSELECT eventid, userid, event.title, recurring, recuroption, dateline_from, dateline_to, event.calendarid, IF (dateline_to = 0, 1, 0) AS singleday, customfields,\n\t\t\tdateline_from AS dateline_from_user, dateline_to AS dateline_to_user, utc, dst\n\t\tFROM " . TABLE_PREFIX . "event AS event\n\t\tINNER JOIN " . TABLE_PREFIX . "calendar AS calendar USING (calendarid)\n\t\tWHERE ((dateline_to >= {$beginday} AND dateline_from < {$endday}) OR (dateline_to = 0 AND dateline_from >= {$beginday} AND dateline_from <= {$endday} ))\n\t\t\tAND visible = 1\n\t\t\tAND calendar.options & " . intval($_CALENDAROPTIONS['showupcoming']) . "\n\t\tORDER BY dateline_from\n\t"); while ($event = $vbulletin->db->fetch_array($events)) { $event['title'] = htmlspecialchars_uni($event['title']); $storeevents["{$event['eventid']}"] = $event; } build_datastore('eventcache', serialize($storeevents), 1); return $storeevents; }
/** * Saves Data into database * * @return boolean */ function save($dbobject) { $obj =& vB_Bitfield_Builder::init(); if (vB_Bitfield_Builder::build_datastore() === false) { return false; } // save build_datastore('bitfields', serialize($obj->datastore), 1); return true; }