/** * @return bool */ protected function LoadXML() { if (@file_exists(INI_DIR . '/settings/' . self::FILE_NAME)) { $return = file_get_contents(INI_DIR . '/settings/' . self::FILE_NAME); if (false !== $return) { $xmlDocument = new XmlDocument(); if ($xmlDocument->LoadFromString($return)) { return $this->initFromXmlRoot($xmlDocument->XmlRoot); } } return false; } return true; }
/** * @return bool */ protected function LoadXML() { if (@file_exists(INI_DIR . '/settings/filters.xml')) { $return = file_get_contents(INI_DIR . '/settings/filters.xml'); if (false !== $return) { $xmlDocument = new XmlDocument(); if ($xmlDocument->LoadFromString($return)) { return $this->initFromXmlRoot($xmlDocument->XmlRoot, $this->_main); } } return false; } return true; }
public function query($expression, \DOMNode $contextNode = null, $registerNodeNs = true) { // if no context node has been given, assume <root> if (null === $contextNode) { $contextNode = $this->getXpath()->query('/root')->item(0); // make sure the query is relative to the context node if ($contextNode && '' !== $expression && '.' !== $expression[0]) { $expression = '.' . $expression; } } return parent::query($expression, $contextNode, $registerNodeNs); }
curl_close($ch); /*/ $source = ' <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss" > <channel> <title>LyricWiki.org</title> <atom:link href="http://lyricwiki.wordpress.com/feed/" rel="self" type="application/rss+xml" /> </channel> </rss> '; //*/ #echo $source; $xml = new XmlDocument(); $xml->parse($source); $items = $xml->getItem("/rss/channel/item[*]"); if ($items) { foreach ($items as $item) { echo "=================================\n"; #var_dump($item["TITLE"]); echo implode($item["TITLE"][0]) . "\n"; } } //*/
/** * @param XmlDocument $_xmlObj */ function PrintXML(&$_xmlObj, $_startTime = null) { global $BackgroundXmlParam; if ($_xmlObj) { if (isset($_SESSION[ISINFOERROR], $_SESSION[INFORMATION]) && $_SESSION[ISINFOERROR]) { $_xmlNode = new XmlDomNode('error', $_SESSION[INFORMATION], true); $_xmlObj->XmlRoot->AppendChild($_xmlNode); unset($_SESSION[ISINFOERROR], $_SESSION[INFORMATION]); } if ($BackgroundXmlParam === 1) { $_xmlObj->XmlRoot->AppendAttribute('background', 1); } echo $_xmlObj->ToString(); if (null !== $_startTime) { $_log =& CLog::CreateInstance(); $_log->WriteLine('XML Time: ' . (getmicrotime() - $_startTime)); } exit; } exit; }
/** * @param XmlDocument $xmlObj */ function printXML(&$xmlObj) { if (isset($_SESSION[ISINFOERROR], $_SESSION[INFORMATION]) && $_SESSION[ISINFOERROR]) { $xmlNode =& new XmlDomNode('error'); $xmlNode->Value = $_SESSION[INFORMATION]; $xmlObj->XmlRoot->AppendChild($xmlNode); unset($_SESSION[ISINFOERROR], $_SESSION[INFORMATION]); } exit($xmlObj->ToString()); }
function _initSettings() { $_path = $this->GetCfg('adminpanel_data_path'); $_xml = new XmlDocument(); if ($_path === false || !@file_exists($_path . '/settings/' . AP_XML_CFG_FILE)) { $this->_ge(ap_Utils::TakePhrase('AP_LANG_FILE_ERROR_OCCURRED')); exit; } if ($_xml->LoadFromFile($_path . '/settings/' . AP_XML_CFG_FILE)) { $_advanced_options =& $_xml->XmlRoot->GetChildNodeByTagName('advancedoptions'); if ($_advanced_options) { $this->_cfg['advancedoptions'] = (bool) $_advanced_options->Value; } $_license_node =& $_xml->XmlRoot->GetChildNodeByTagName('licensekey'); if ($_license_node) { $this->_cfg[AP_TEST_P] = trim(ap_Utils::DecodeSpecialXmlChars($_license_node->Value)); } $_plugins =& $_xml->XmlRoot->GetChildNodeByTagName('plugins'); if ($_plugins) { $this->_cfg['plugins'] = array(); if (!$_plugins->Children) { $_plugins->Children = array(); } foreach ($_plugins->Children as $_node) { if ($_node->TagName == 'plugin') { $_ipath = CAdminPanel::RootPath() . '/plugins/' . trim($_node->Value) . '/index.php'; if (@file_exists($_ipath)) { $this->_cfg['plugins'][] = trim(ap_Utils::DecodeSpecialXmlChars($_node->Value)); } } } if (@file_exists(CAdminPanel::RootPath() . '/plugins/common/index.php')) { $this->_cfg['plugins'][] = 'common'; } } $_login_node =& $_xml->XmlRoot->GetChildNodeByTagName('login'); if ($_login_node && $_login_node->Children && is_array($_login_node->Children)) { foreach ($_login_node->Children as $_node) { $this->_cfg['login'][trim($_node->TagName)] = trim(ap_Utils::DecodeSpecialXmlChars($_node->Value)); } } $_resp = $this->ValidateCfg($this->_cfg); if ($_resp !== true) { $this->_ge($_resp); } } }
foreach ($suggest as $suggestWord) { $sug = new XmlDomNode('param', ''); $sug->AppendAttribute('name', 'word'); $sug->AppendAttribute('value', $suggestWord); $node->AppendChild($sug); unset($sug); } $node->AppendAttribute('action', 'suggest'); $response->XmlRoot->AppendChild($node); break; } } print $response->ToString(); } else { // if error ocured $response = new XmlDocument(); $response->CreateElement('webmail'); $node = new XmlDomNode('spellcheck'); $node->AppendAttribute('action', 'error'); $node->AppendAttribute('errorstr', $sp->_error); $node->AppendChild($err); $response->XmlRoot->AppendChild($node); print $response->ToString(); } /** * @param string $string * @return string */ function obLogResponse($string) { global $log;
/** * @access private */ function Settings($param = true) { if (!is_null($param)) { die('can\'t call Settings class.'); } $this->UseDsn = false; $this->WmServerHost = '127.0.0.1'; $this->AllowUsersChangeAccountsDef = false; $this->WmAllowManageXMailAccounts = false; $this->AllowContacts = true; $this->AllowCalendar = true; $this->UseCaptcha = true; $this->Cal_DefaultTimeFormat = 1; $this->Cal_DefaultTimeZone = 38; $this->Cal_DefaultDateFormat = 1; $this->Cal_ShowWeekends = true; $this->Cal_WorkdayStarts = 9; $this->Cal_WorkdayEnds = 18; $this->Cal_ShowWorkDay = 1; $this->Cal_WeekStartsOn = 0; $this->Cal_DefaultTab = 2; $this->Cal_DefaultCountry = 'US'; $this->Cal_AllTimeZones = false; $this->Cal_AllowReminders = false; $this->Cal_AutoAddInvitation = 0; $this->Imap4DeleteLikePop3 = true; $this->AllowLanguageOnLogin = true; $this->AllowInsertImage = true; $this->AllowBodySize = false; $this->MaxBodySize = 600; $this->MaxSubjectSize = 255; $this->AllowRegistration = false; $this->AllowPasswordReset = false; $this->GlobalAddressBook = GLOBAL_ADDRESS_BOOK_OFF; $this->EnableMobileSync = false; $this->MobileSyncUrl = ''; $this->MobileSyncContactDataBase = 'card'; $this->MobileSyncCalendarDataBase = 'cal'; $this->FlagsLangSelect = false; $this->ViewMode = 1; $this->SaveInSent = 0; $this->isLoad = false; $this->_langIsInclude = false; $this->Dev = null; $settingsCacher = new SettingsCacher(); $settingsRaw = $settingsCacher->Load(); if (false === $settingsRaw) { $settingsRaw = $settingsCacher->LoadRoot(); if ($settingsRaw == false) { setGlobalError($settingsCacher->GetError()); } else { $settingsCacher->Save($settingsRaw); } } else { if (is_array($settingsRaw)) { $this->_loadFromArray($settingsRaw); $this->isLoad = true; } } if (is_string($settingsRaw)) { $xmlDocument = new XmlDocument(); if ($xmlDocument->LoadFromString($settingsRaw)) { $this->_loadFromXML($xmlDocument->XmlRoot); $this->isLoad = true; } } if ($this->isLoad) { if (!@function_exists('imagecreatefrompng')) { $this->UseCaptcha = false; } $xmlDomainSettings =& DomainSettings::CreateInstance(); $xmlDomainSettings->UpdateSettingsByDomain($this); /* custom class */ wm_Custom::StaticUseMethod('ChangeSettingsAfterLoad', array(&$this)); } }
/** * @return bool */ function SaveToXml() { $xmlDocument = new XmlDocument(); $xmlDocument->CreateElement('Settings'); $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $common = new XmlDomNode('Common'); $this->AddNode($common, 'SiteName', $this->WindowTitle); $this->AddNode($common, 'LicenseKey', $this->LicenseKey); $this->AddNode($common, 'AdminPassword', $this->AdminPassword); $this->AddNode($common, 'DBType', (int) $this->DbType); $this->AddNode($common, 'DBLogin', $this->DbLogin); $this->AddNode($common, 'DBPassword', $this->DbPassword); $this->AddNode($common, 'DBName', $this->DbName); $this->AddNode($common, 'UseDsn', (int) $this->UseDsn); $this->AddNode($common, 'DBDSN', $this->DbDsn); $this->AddNode($common, 'DBHost', $this->DbHost); $this->AddNode($common, 'UseCustomConnectionString', (int) $this->UseCustomConnectionString); $this->AddNode($common, 'DBCustomConnectionString', $this->DbCustomConnectionString); $this->AddNode($common, 'DBPrefix', ap_Utils::ClearPrefix($this->DbPrefix)); $this->AddNode($common, 'DefaultSkin', $this->DefaultSkin); $this->AddNode($common, 'AllowUsersChangeSkin', (int) $this->AllowUsersChangeSkin); $this->AddNode($common, 'DefaultLanguage', $this->DefaultLanguage); $this->AddNode($common, 'AllowUsersChangeLanguage', (int) $this->AllowUsersChangeLanguage); $this->AddNode($common, 'EnableMobileSync', (bool) $this->EnableMobileSync); $this->AddNode($common, 'MobileSyncUrl', $this->MobileSyncUrl); $this->AddNode($common, 'MobileSyncContactDataBase', $this->MobileSyncContactDataBase); $this->AddNode($common, 'MobileSyncCalendarDataBase', $this->MobileSyncCalendarDataBase); $xmlDocument->XmlRoot->AppendChild($common); $webmail = new XmlDomNode('WebMail'); $this->AddNode($webmail, 'IncomingMailProtocol', (int) $this->IncomingMailProtocol); $this->AddNode($webmail, 'IncomingMailServer', $this->IncomingMailServer); $this->AddNode($webmail, 'IncomingMailPort', (int) $this->IncomingMailPort); $this->AddNode($webmail, 'OutgoingMailServer', $this->OutgoingMailServer); $this->AddNode($webmail, 'OutgoingMailPort', (int) $this->OutgoingMailPort); $this->AddNode($webmail, 'ReqSmtpAuth', (int) $this->ReqSmtpAuth); $this->AddNode($webmail, 'AllowAdvancedLogin', (int) $this->AllowAdvancedLogin); $this->AddNode($webmail, 'HideLoginMode', (int) $this->HideLoginMode); $this->AddNode($webmail, 'DefaultDomainOptional', $this->DefaultDomainOptional); $this->AddNode($webmail, 'UseMultipleDomainsSelection', (int) $this->UseMultipleDomainsSelection); $this->AddNode($webmail, 'UseCaptcha', (int) $this->UseCaptcha); $this->AddNode($webmail, 'ShowTextLabels', (int) $this->ShowTextLabels); $this->AddNode($webmail, 'AutomaticCorrectLoginSettings', (int) $this->AutomaticCorrectLoginSettings); $EnableLogging = (int) $this->EnableLogging; if ($this->LoggingSpecialUsers) { $EnableLogging++; } $this->AddNode($webmail, 'EnableLogging', (int) $EnableLogging); $this->AddNode($webmail, 'LogLevel', (int) $this->LogLevel); $this->AddNode($webmail, 'EnableEventsLogging', (int) $this->EnableEventsLogging); $this->AddNode($webmail, 'DisableErrorHandling', (int) $this->DisableErrorHandling); $this->AddNode($webmail, 'AllowAjax', (int) $this->AllowAjax); $this->AddNode($webmail, 'MailsPerPage', (int) $this->MailsPerPage); $this->AddNode($webmail, 'EnableAttachmentSizeLimit', (int) $this->EnableAttachmentSizeLimit); $this->AddNode($webmail, 'AttachmentSizeLimit', GetGoodBigInt($this->AttachmentSizeLimit)); $this->AddNode($webmail, 'EnableMailboxSizeLimit', (int) $this->EnableMailboxSizeLimit); $this->AddNode($webmail, 'MailboxSizeLimit', GetGoodBigInt($this->MailboxSizeLimit)); $this->AddNode($webmail, 'TakeImapQuota', (int) $this->TakeImapQuota); $this->AddNode($webmail, 'DefaultTimeZone', $this->DefaultTimeZone); $this->AddNode($webmail, 'AllowUsersChangeTimeZone', (int) $this->AllowUsersChangeTimeZone); $this->AddNode($webmail, 'DefaultUserCharset', (int) CWebMail_Plugin::GetCodePageNumber($this->DefaultUserCharset)); $this->AddNode($webmail, 'AllowUsersChangeCharset', (int) $this->AllowUsersChangeCharset); $this->AddNode($webmail, 'AllowDHTMLEditor', (int) $this->AllowDhtmlEditor); $this->AddNode($webmail, 'AllowUsersChangeEmailSettings', (int) $this->AllowUsersChangeEmailSettings); $this->AddNode($webmail, 'AllowDirectMode', (int) $this->AllowDirectMode); $this->AddNode($webmail, 'DirectModeIsDefault', (int) $this->DirectModeIsDefault); $this->AddNode($webmail, 'AllowNewUsersRegister', (int) $this->AllowNewUsersRegister); $this->AddNode($webmail, 'AllowUsersAddNewAccounts', (int) $this->AllowUsersAddNewAccounts); $this->AddNode($webmail, 'AllowUsersChangeAccountsDef', (int) $this->AllowUsersChangeAccountsDef); $this->AddNode($webmail, 'StoreMailsInDb', (int) $this->StoreMailsInDb); $this->AddNode($webmail, 'AllowContacts', (int) $this->AllowContacts); $this->AddNode($webmail, 'AllowCalendar', (int) $this->AllowCalendar); $this->AddNode($webmail, 'AllowLanguageOnLogin', (int) $this->AllowLanguageOnLogin); $this->AddNode($webmail, 'Imap4DeleteLikePop3', (int) $this->Imap4DeleteLikePop3); $this->AddNode($webmail, 'AllowInsertImage', (int) $this->AllowInsertImage); $this->AddNode($webmail, 'AllowBodySize', (int) $this->AllowBodySize); $this->AddNode($webmail, 'MaxBodySize', (int) $this->MaxBodySize); $this->AddNode($webmail, 'MaxSubjectSize', (int) $this->MaxSubjectSize); $this->AddNode($webmail, 'EnableWmServer', (int) $this->EnableWmServer); $this->AddNode($webmail, 'WmServerRootPath', $this->WmServerRootPath); $this->AddNode($webmail, 'WmServerHost', $this->WmServerHost); $this->AddNode($webmail, 'WmAllowManageXMailAccounts', (int) $this->WmAllowManageXMailAccounts); $this->AddNode($webmail, 'IdleSessionTimeout', (int) $this->IdleSessionTimeout); $this->AddNode($webmail, 'AllowRegistration', (int) $this->AllowRegistration); $this->AddNode($webmail, 'AllowPasswordReset', (int) $this->AllowPasswordReset); $this->AddNode($webmail, 'GlobalAddressBook', $this->GlobalAddressBook); $this->AddNode($webmail, 'FlagsLangSelect', (int) $this->FlagsLangSelect); $this->AddNode($webmail, 'ViewMode', (int) $this->ViewMode); $this->AddNode($webmail, 'SaveInSent', (int) $this->SaveInSent); $xmlDocument->XmlRoot->AppendChild($webmail); $calendar = new XmlDomNode('Calendar'); $this->AddNode($calendar, 'DefaultTimeFormat', (int) $this->Cal_DefaultTimeFormat); $this->AddNode($calendar, 'DefaultDateFormat', (int) $this->Cal_DefaultDateFormat); $this->AddNode($calendar, 'ShowWeekends', (int) $this->Cal_ShowWeekends); $this->AddNode($calendar, 'WorkdayStarts', (int) $this->Cal_WorkdayStarts); $this->AddNode($calendar, 'WorkdayEnds', (int) $this->Cal_WorkdayEnds); $this->AddNode($calendar, 'ShowWorkDay', (int) $this->Cal_ShowWorkDay); $this->AddNode($calendar, 'WeekStartsOn', (int) $this->Cal_WeekStartsOn); $this->AddNode($calendar, 'DefaultTab', (int) $this->Cal_DefaultTab); $this->AddNode($calendar, 'DefaultCountry', $this->Cal_DefaultCountry); $this->AddNode($calendar, 'DefaultTimeZone', (int) $this->Cal_DefaultTimeZone); $this->AddNode($calendar, 'AllTimeZones', (int) $this->Cal_AllTimeZones); $this->AddNode($calendar, 'AllowReminders', (int) $this->Cal_AllowReminders); $this->AddNode($calendar, 'AutoAddInvitation', (int) $this->Cal_AutoAddInvitation); $xmlDocument->XmlRoot->AppendChild($calendar); if (strlen($this->Dev) > 0) { $xmlDocument->XmlRoot->AppendChild(new XmlDomNode('Dev', ap_Utils::EncodeSpecialXmlChars($this->Dev))); } if (AP_USE_XML_CACHE) { $out = array(); foreach ($this as $key => $value) { if (strlen($key) > 0) { if ($key[0] === '_' || $key === 'isLoad') { continue; } if (is_int($value)) { $out[] = '\'' . $key . '\'=>' . $value; } else { $out[] = '\'' . $key . '\'=>\'' . ap_Utils::ClearStringValue(ap_Utils::EncodeSpecialXmlChars($value), '\'') . '\''; } } } file_put_contents($this->_path . '/settings/settings.xml.cache', '<?php return array(' . implode(",\r\n", $out) . ');'); } return $xmlDocument->SaveToFile($this->_path . '/settings/settings.xml'); }
/** * @param string $_licenseKey * @return bool */ function _saveLicenseKeyData($_licenseKey) { $_ap =& $this->GetAp(); $_path = $_ap->GetCfg('adminpanel_data_path'); $_xml = new XmlDocument(); if ($_path !== false && $_xml->LoadFromFile($_path . '/settings/' . AP_XML_CFG_FILE)) { $_license_node =& $_xml->XmlRoot->GetChildNodeByTagName('licensekey'); if ($_license_node) { $_license_node->Value = ap_Utils::EncodeSpecialXmlChars($_licenseKey); } else { $_plugins = new XmlDomNode('licensekey', ap_Utils::EncodeSpecialXmlChars($_licenseKey)); $_xml->XmlRoot->AppendChild($_plugins); } if ($_xml->SaveToFile($_path . '/settings/' . AP_XML_CFG_FILE)) { return true; } } else { $_ap->GlobalError(ap_Utils::TakePhrase('CM_FILE_ERROR_OCCURRED')); } return false; }
function renderXML($input, $argv, $parser) { // parameters $feedURL = $argv["feed"]; $escapedFeedURL = urlencode($argv["feed"]); $maxItems = (int) $argv["maxitems"]; $addLineFeed = $argv["linefeed"]; // retrieve the xml source from the cache before trying to fetch it // limits possible stress on other people's servers, reduces chance of DOS attacks global $wgMemc; $cachedSource = false; if (debugSwitch("forceload")) { $wgMemc->get($escapedFeedURL); } if (!$cachedSource) { // Uses Http::get which is the prefered method to make requests from MediaWiki since it handles going through proxies, etc. $timeout = 5; // set to zero for no timeout $source = Http::get($feedURL, $timeout, array(CURLOPT_FOLLOWLOCATION => 1)); if (!$source) { return wfMsgExt("xml-feedfailed", array('parseinline')); } // only cache newly fetched sources $wgMemc->set($escapedFeedURL, $source, strtotime("+2 hour")); } else { $source = $cachedSource; } if (debugSwitch("source")) { echo $source . "\n"; } // parse $feed = new XmlDocument(); if (!$feed->parse($source)) { return wfMsg("xml-parseerror", $feed->getError()); } // fill in the template with the fields from the xml file preg_match_all("#<item path=\"(.*?)\">(.*?)</item>#", filter($input), $matches); $result = ""; foreach ($matches[0] as $i => $text) { $path = $matches[1][$i]; $template = filter(trim(unfilter($matches[2][$i]))); $items = $feed->getItem($path); $count = min(count($items), $maxItems); if (!$items) { $result .= wfMsg("xml-pathnotfound", $path); } for ($i = 0; $i < $count; ++$i) { $item = $items[$i]; // fill in the template (use standard template parameter format) $text = $template; if (preg_match_all("/{{{([a-zA-Z:]*)}}}/", $text, $fields)) { foreach (array_unique($fields[1]) as $field) { // SWC 20061113 - Broke the accessing into two lines so that it parses $tempArray = $item[strtoupper($field)]; $currValue = implode("", $tempArray[0]); $text = str_replace("{{{{$field}}}}", $currValue, $text); } } // conditially add a line feed to the end of each item if ($addLineFeed) { $result .= $text . "\n"; } else { $result .= $text; } } } return sandboxParse($result); }
/** * @param string $_string * @return string */ function Qitsra($_string) { $_log =& CLog::CreateInstance(); if ($_log->Enabled && strlen(trim($_string)) > 0) { if (!USE_FULLPARSE_XML_LOG) { $_log->WriteLine('>>>[server_xml]>>>' . "\r\n" . $_string); } else { $_xmlTemp = new XmlDocument(); $_xmlTemp->ParseFromString($_string); $_log->WriteLine('>>>[server_xml]>>>' . "\r\n" . $_xmlTemp->ToString(true)); } } if (USE_PROCESSING_GZIP) { $_string = obStartGzip($_string); } return $_string; }