public function getXmlHooks() { if (!$this->hasPermission()) { return false; } $typelist = array(); $hooklocations = array(); require_once DIR . '/includes/class_xml.php'; $types = $this->assertor->getRows('getHooktypePhrases'); $hookfiles = vB_Api_Product::loadProductXmlList('hooks'); foreach ($types as $type) { $typelist[] = $type['varname']; } $vbphrase = vB_Api::instanceInternal('phrase')->fetch($typelist); foreach ($hookfiles as $file) { if (!preg_match('#hooks_(.*).xml$#i', $file, $matches)) { continue; } $product = $matches[1]; $phrased_product = $products[$product ? $product : 'vbulletin']; if (!$phrased_product) { $phrased_product = $product; } $xmlobj = new vB_XML_Parser(false, $location . $file); $xml = $xmlobj->parse(); if (!is_array($xml['hooktype'][0])) { $xml['hooktype'] = array($xml['hooktype']); } foreach ($xml['hooktype'] as $key => $hooks) { if (!is_numeric($key)) { continue; } $phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type']; $hooktype = $phrased_type; $hooklocations["#{$hooktype}#"] = $hooktype; if (!is_array($hooks['hook'])) { $hooks['hook'] = array($hooks['hook']); } foreach ($hooks['hook'] as $hook) { $hookid = trim(is_string($hook) ? $hook : $hook['value']); if ($hookid !== '') { $hooklocations[$hookid] = '--- ' . $hookid . ($product != 'vbulletin' ? " ({$phrased_product})" : ''); } } } } return $hooklocations; }
unset($admindm); $_NAVPREFS = preg_split('#,#', $vbulletin->GPC['navprefs'], -1, PREG_SPLIT_NO_EMPTY); $_REQUEST['do'] = 'nav'; } // ################################ NAVIGATION FRAME ############################# if ($_REQUEST['do'] == 'nav') { require_once DIR . '/includes/adminfunctions_navpanel.php'; print_cp_header(); echo "\n\n" . iif(is_demo_mode(), "<div align=\"center\"><b>DEMO MODE</b></div>\n\n") . "<div id=\"acp-nav-wrapper\">\n"; // cache nav prefs can_administer(); $GLOBALS['_NAV'] .= '<div class="nav-spacer-wide"></div>'; $navigation = array(); // [displayorder][phrase/text] = array([group], [options][disporder][]) require_once DIR . '/includes/class_xml.php'; $navfiles = vB_Api_Product::loadProductXmlList('cpnav', true); if (empty($navfiles['vbulletin'])) { echo construct_phrase($vbphrase['could_not_open_x'], DIR . '/includes/xml/cpnav_vbulletin.xml'); exit; } $userContext = vB::getUserContext(); foreach ($navfiles as $nav_file => $file) { $xmlobj = new vB_XML_Parser(false, $file); $xml =& $xmlobj->parse(); if ($xml['product'] and empty($vbulletin->products["{$xml['product']}"])) { // attached to a specific product and that product isn't enabled continue; } if (!is_array($xml['navgroup'][0])) { $xml['navgroup'] = array($xml['navgroup']); }
/** * Search for bitfield xml files, merge together and search for collisions * * @param boolean layout Moves intperm entries into ['misc']['intperm'] * @param boolean Process disabled products? * * @return boolean */ static function build($layout = true, $include_disabled = false) { $obj =& vB_Bitfield_Builder::init(); $obj->data = array(); $obj->datastore = array(); $obj->datastore_total = array(); $temp = array(); $files = vB_Api_Product::loadProductXmlList('bitfield'); foreach ($files as $file) { if (!preg_match('#bitfield_(.*).xml$#i', $file, $matches)) { continue; } $data = $obj->fetch($file, $layout, $include_disabled); if ($data !== false) { // no error parsing at least $temp[$matches[1]] = $data; } } // opendir failed or bitfield_vbulletin.xml is missing or it has a parse error if (empty($temp['vbulletin'])) { if (is_readable(DIR . '/includes/xml/bitfield_vbulletin.xml')) { if ($data = $obj->fetch(DIR . '/includes/xml/bitfield_vbulletin.xml', $layout, $include_disabled)) { $temp['vbulletin'] = $data; } else { trigger_error('Could not parse ' . DIR . '/includes/xml/bitfield_vbulletin.xml', E_USER_ERROR); } } else { trigger_error('Could not open ' . DIR . '/includes/xml/bitfield_vbulletin.xml', E_USER_ERROR); } } // products foreach ($temp as $product => $bitfields) { // main group (usergroup, misc, etc) foreach ($bitfields as $title => $permgroup) { // subgroups such as forumpermissions foreach ($permgroup as $subtitle => $permissions) { if (is_array($permissions)) { foreach ($permissions as $permtitle => $permvalue) { if ((is_array($permvalue) and isset($permvalue['intperms']) or $permtitle == 'intperms') and $layout) { if ($permtitle == 'intperms') { $obj->data['misc']["intperms"]["{$subtitle}"] = $permvalue; } else { $obj->data['misc']["intperms"]["{$permtitle}"] = $permvalue['intperms']; } continue; } else { if (!$layout and $title == 'layout') { $obj->data['layout']["{$subtitle}"]["{$permtitle}"] = $permvalue; continue; } else { if (is_array($permvalue) and !$layout) { if (empty($obj->datastore_total["{$title}"]["{$subtitle}"]) and !isset($permvalue['intperm'])) { $obj->datastore_total["{$title}"]["{$subtitle}"] = true; } $obj->data["{$title}"]["{$subtitle}"]["{$permtitle}"] = $permvalue; continue; } } } $obj->data["{$title}"]["{$subtitle}"]["{$permtitle}"] = $permvalue; } // check that all entries in subtitle have unique bitfield if ($title != 'layout' and $layout and is_array($obj->data["{$title}"]["{$subtitle}"]) and sizeof($obj->data["{$title}"]["{$subtitle}"]) != sizeof(array_unique($obj->data["{$title}"]["{$subtitle}"]))) { $uarray = array_unique($obj->data["{$title}"]["{$subtitle}"]); $collision = array_diff(array_keys($obj->data["{$title}"]["{$subtitle}"]), array_keys($uarray)); foreach ($collision as $key) { if (!$layout and is_array($obj->data["{$title}"]["{$subtitle}"]["{$key}"]) and isset($obj->data["{$title}"]["{$subtitle}"]["{$key}"]['intperms'])) { continue; } $bitfield_collision_value = $obj->data["{$title}"]["{$subtitle}"]["{$key}"]; $obj->errors[] = "Bitfield Collision: {$key} = " . array_search($bitfield_collision_value, $uarray); } if (!empty($obj->errors)) { $obj->data = array(); return false; } } } else { if (is_array($obj->data["{$title}"])) { foreach ($obj->data["{$title}"] as $checktitle => $value) { if (is_array($value)) { continue; } if ($value == $permissions) { $obj->errors[] = "Bitfield Collision: {$checktitle} = {$subtitle}"; $obj->data = array(); return false; } } } $obj->data["{$title}"]["{$subtitle}"] = $permissions; } } } } return true; }
public static function buildSpiderList() { $spiders = array(); require_once DIR . '/includes/class_xml.php'; $files = vB_Api_Product::loadProductXmlList('spiders'); foreach ($files as $file) { $xmlobj = new vB_XML_Parser(false, $file); $spiderdata = $xmlobj->parse(); if (is_array($spiderdata['spider'])) { foreach ($spiderdata['spider'] as $spiderling) { $addresses = array(); $identlower = strtolower($spiderling['ident']); $spiders['agents']["{$identlower}"]['name'] = $spiderling['name']; $spiders['agents']["{$identlower}"]['type'] = $spiderling['type']; if (is_array($spiderling['addresses']['address']) and !empty($spiderling['addresses']['address'])) { if (empty($spiderling['addresses']['address'][0])) { $addresses[0] = $spiderling['addresses']['address']; } else { $addresses = $spiderling['addresses']['address']; } foreach ($addresses as $key => $address) { if (in_array($address['type'], array('range', 'single', 'CIDR'))) { $address['type'] = strtolower($address['type']); switch ($address['type']) { case 'single': $ip2long = ip2long($address['value']); if ($ip2long != -1 and $ip2long !== false) { $spiders['agents']["{$identlower}"]['lookup'][] = array('startip' => $ip2long); } break; case 'range': $ips = explode('-', $address['value']); $startip = ip2long(trim($ips[0])); $endip = ip2long(trim($ips[1])); if ($startip != -1 and $startip !== false and $endip != -1 and $endip !== false and $startip <= $endip) { $spiders['agents']["{$identlower}"]['lookup'][] = array('startip' => $startip, 'endip' => $endip); } break; case 'cidr': $ipsplit = explode('/', $address['value']); $startip = ip2long($ipsplit[0]); $mask = $ipsplit[1]; if ($startip != -1 and $startip !== false and $mask <= 31 and $mask >= 0) { $hostbits = 32 - $mask; $hosts = pow(2, $hostbits) - 1; // Number of specified IPs $endip = $startip + $hosts; $spiders['agents']["{$identlower}"]['lookup'][] = array('startip' => $startip, 'endip' => $endip); } break; } } } } $spiders['spiderstring'] .= ($spiders['spiderstring'] ? '|' : '') . preg_quote($spiderling['ident'], '#'); } } unset($spiderdata, $xmlobj); } vB::getDatastore()->build('spiders', serialize($spiders), 1); return vB::getDatastore()->getValue('spiders'); }
function fetch_xml_data() { $navigation = array(); $navfiles = vB_Api_Product::loadProductXmlList('cpnav', true); if (empty($navfiles['vbulletin'])) { echo construct_phrase($vbphrase['could_not_open_x'], DIR . '/includes/xml/cpnav_vbulletin.xml'); exit; } foreach ($navfiles as $nav_file => $file) { $xmlobj = new vB_XML_Parser(false, $file); $xml =& $xmlobj->parse(); if (!is_array($xml['navgroup'][0])) { $xml['navgroup'] = array($xml['navgroup']); } foreach ($xml['navgroup'] as $navgroup) { if (!is_array($navgroup['navoption'][0])) { $navgroup['navoption'] = array($navgroup['navoption']); } foreach ($navgroup['navoption'] as $navoption) { $navoption['link'] = str_replace(array('{$vbulletin->config[Misc][modcpdir]}', '{$vbulletin->config[Misc][admincpdir]}'), array($vb5_config['Misc']['modcpdir'], 'admincp'), $navoption['link']); $navoption['text'] = fetch_nav_text($navoption); if ($navoption['phrase'] and (!isset($navigation[$navoption['phrase']]) or $xml['master'])) { $navigation[$navoption['phrase']] = array('text' => $navoption['text'], 'link' => $navoption['link']); } } } $xmlobj = null; unset($xml); } return $navigation; }
/** * Writes style css directory on disk * * @param int $styleid * @param string $parentlist -- csv list of ancestors for this style * @param string $dir -- the "direction" of the css to write. Either 'ltr' or 'rtl' (there are actually two directories per style) */ function write_style_css_directory($styleid, $parentlist, $dir = 'ltr') { //verify that we have or can create a style directory $styledir = DIR . vB_Api::instanceInternal('style')->fetchCssLocation() . '/style' . str_pad($styleid, 5, '0', STR_PAD_LEFT) . ($dir == 'ltr' ? 'l' : 'r'); //if we have a file that's not a directory or not writable something is wrong. if (file_exists($styledir) and (!is_dir($styledir) or !is_writable($styledir))) { return false; } //clear any old files. if (file_exists($styledir)) { delete_style_css_directory($styleid, $dir, true); } //create the directory -- if it still exists try to continue with the existing dir if (!file_exists($styledir)) { if (!@mkdir($styledir)) { return false; } } //check for success. if (!is_dir($styledir) or !is_writable($styledir)) { return false; } //write out the files for this style. $parentlistarr = explode(',', $parentlist); $set = vB::getDbAssertor()->assertQuery('vBForum:fetchParentTemplates', array('parentlist' => $parentlistarr)); //collapse the list. $css_templates = array(); foreach ($set as $row) { $css_templates[] = $row['title']; } $stylelib = vB_Library::instance('Style'); $stylelib->switchCssStyle($styleid, $css_templates); if ($dir == 'ltr') { vB_Template_Runtime::addStyleVar('left', 'left'); vB_Template_Runtime::addStyleVar('right', 'right'); vB_Template_Runtime::addStyleVar('textdirection', 'ltr'); } else { vB_Template_Runtime::addStyleVar('left', 'right'); vB_Template_Runtime::addStyleVar('right', 'left'); vB_Template_Runtime::addStyleVar('textdirection', 'rtl'); } // Get new css cache bust $stylelib->setCssFileDate($styleid); $cssfiledate = $stylelib->getCssFileDate($styleid); $base = get_base_url_for_css(); if ($base === false) { return false; } $templates = array(); foreach ($css_templates as $title) { //I'd call this a hack but there probably isn't a cleaner way to do this. //The css is published to a different directory than the css.php file //which means that relative urls that works for css.php won't work for the //published directory. Unfortunately urls from the webroot don't work //because the forum often isn't located at the webroot and we can only //specify urls from the forum root. And css doens't provide any way //of setting a base url like html does. So we are left to "fixing" //any relative urls in the published css. // //We leave alone any urls starting with '/', 'http', and 'https:' //there are other valid urls, but nothing that people should be //using in our css files. $text = vB_Template::create($title)->render(true); //update image urls to be fully qualified. $re = '#url\\(\\s*["\']?(?!/|http:|https:|"/|\'/)#'; $text = preg_replace($re, "\$0{$base}", $text); $text = vB_String::getCssMinifiedText($text); $templates[$title] = $text; if (!write_css_file("{$styledir}/{$cssfiledate}-{$title}", $text)) { return false; } } static $vbdefaultcss = array(), $cssfiles = array(); if (empty($vbdefaultcss)) { require_once DIR . '/includes/class_xml.php'; $cssfilelist = vB_Api_Product::loadProductXmlList('cssrollup', true); if (empty($cssfilelist['vbulletin'])) { $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('could_not_open_x')); echo construct_phrase($vbphrase['could_not_open_x'], DIR . '/includes/xml/cssrollup_vbulletin.xml'); exit; } else { $mainfile = array_shift($cssfilelist); } $xmlobj = new vB_XML_Parser(false, $mainfile); $data = $xmlobj->parse(); if (!is_array($data['rollup'][0])) { $data['rollup'] = array($data['rollup']); } foreach ($data['rollup'] as $file) { foreach ($file['template'] as $name) { $vbdefaultcss["{$file['name']}"] = $file['template']; } } foreach ($cssfilelist as $css_file => $file) { $xmlobj = new vB_XML_Parser(false, $file); $data = $xmlobj->parse(); $products = vB::getDatastore()->getValue('products'); if ($data['product'] and empty($products["{$data['product']}"])) { // attached to a specific product and that product isn't enabled continue; } if (!is_array($data['rollup'][0])) { $data['rollup'] = array($data['rollup']); } $cssfiles[$css_file]['css'] = $data['rollup']; } } foreach ($cssfiles as $css_file => $files) { if (is_array($files['css'])) { foreach ($files['css'] as $file) { if (process_css_rollup_file($file['name'], $file['template'], $templates, $styleid, $styledir, $vbdefaultcss) === false) { return false; } } } } foreach ($vbdefaultcss as $xmlfile => $files) { if (process_css_rollup_file($xmlfile, $files, $templates, $styleid, $styledir) === false) { return false; } } return true; }