当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Xml_Security类代码示例

本文整理汇总了PHP中Zend_Xml_Security的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Xml_Security类的具体用法?PHP Zend_Xml_Security怎么用?PHP Zend_Xml_Security使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Xml_Security类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _loadTranslationData

 /**
  * Load translation data (TBX file reader)
  *
  * @param  string  $filename  TBX file to add, full path must be given for access
  * @param  string  $locale    Locale has no effect for TBX because TBX defines all languages within
  *                            the source file
  * @param  array   $option    OPTIONAL Options to use
  * @throws Zend_Translation_Exception
  * @return array
  */
 protected function _loadTranslationData($filename, $locale, array $options = array())
 {
     $this->_data = array();
     if (!is_readable($filename)) {
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception('Translation file \'' . $filename . '\' is not readable.');
     }
     $encoding = $this->_findEncoding($filename);
     $this->_file = xml_parser_create($encoding);
     xml_set_object($this->_file, $this);
     xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($this->_file, "_startElement", "_endElement");
     xml_set_character_data_handler($this->_file, "_contentElement");
     try {
         Zend_Xml_Security::scanFile($filename);
     } catch (Zend_Xml_Exception $e) {
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception($e->getMessage());
     }
     if (!xml_parse($this->_file, file_get_contents($filename))) {
         $ex = sprintf('XML error: %s at line %d of file %s', xml_error_string(xml_get_error_code($this->_file)), xml_get_current_line_number($this->_file), $filename);
         xml_parser_free($this->_file);
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception($ex);
     }
     return $this->_data;
 }
开发者ID:conectapb,项目名称:sysagroweb,代码行数:37,代码来源:Tbx.php

示例2: scanFile

 /**
  * @param string $file
  * @return SimpleXMLElement
  * @throws XenForo_Exception
  */
 public static function scanFile($file)
 {
     $xml = Zend_Xml_Security::scanFile($file);
     if (!$xml) {
         throw new XenForo_Exception("Invalid XML in {$file}");
     }
     return $xml;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:13,代码来源:DevelopmentXml.php

示例3: loadXml

 /**
  * Load configuration XML
  * 
  * @param string $configurationXml Configuration XML
  */
 public function loadXml($configurationXml)
 {
     // Convert to SimpleXMLElement
     $configurationXml = Zend_Xml_Security::scan($configurationXml);
     // Assign general settings
     $this->DataSources->OverallQuotaInMB = (int) $configurationXml->DataSources->OverallQuotaInMB;
     // Assign Logs settings
     $this->DataSources->Logs->BufferQuotaInMB = (int) $configurationXml->DataSources->Logs->BufferQuotaInMB;
     $this->DataSources->Logs->ScheduledTransferPeriodInMinutes = (int) $configurationXml->DataSources->Logs->ScheduledTransferPeriodInMinutes;
     $this->DataSources->Logs->ScheduledTransferLogLevelFilter = (string) $configurationXml->DataSources->Logs->ScheduledTransferLogLevelFilter;
     // Assign DiagnosticInfrastructureLogs settings
     $this->DataSources->DiagnosticInfrastructureLogs->BufferQuotaInMB = (int) $configurationXml->DataSources->DiagnosticInfrastructureLogs->BufferQuotaInMB;
     $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferPeriodInMinutes = (int) $configurationXml->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferPeriodInMinutes;
     $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferLogLevelFilter = (string) $configurationXml->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferLogLevelFilter;
     // Assign PerformanceCounters settings
     $this->DataSources->PerformanceCounters->BufferQuotaInMB = (int) $configurationXml->DataSources->PerformanceCounters->BufferQuotaInMB;
     $this->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes = (int) $configurationXml->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes;
     if ($configurationXml->DataSources->PerformanceCounters->Subscriptions && $configurationXml->DataSources->PerformanceCounters->Subscriptions->PerformanceCounterConfiguration) {
         $subscriptions = $configurationXml->DataSources->PerformanceCounters->Subscriptions;
         if (count($subscriptions->PerformanceCounterConfiguration) > 1) {
             $subscriptions = $subscriptions->PerformanceCounterConfiguration;
         } else {
             $subscriptions = array($subscriptions->PerformanceCounterConfiguration);
         }
         foreach ($subscriptions as $subscription) {
             $this->DataSources->PerformanceCounters->addSubscription((string) $subscription->CounterSpecifier, (int) $subscription->SampleRateInSeconds);
         }
     }
     // Assign WindowsEventLog settings
     $this->DataSources->WindowsEventLog->BufferQuotaInMB = (int) $configurationXml->DataSources->WindowsEventLog->BufferQuotaInMB;
     $this->DataSources->WindowsEventLog->ScheduledTransferPeriodInMinutes = (int) $configurationXml->DataSources->WindowsEventLog->ScheduledTransferPeriodInMinutes;
     $this->DataSources->WindowsEventLog->ScheduledTransferLogLevelFilter = (string) $configurationXml->DataSources->WindowsEventLog->ScheduledTransferLogLevelFilter;
     if ($configurationXml->DataSources->WindowsEventLog->Subscriptions && $configurationXml->DataSources->WindowsEventLog->Subscriptions->string) {
         $subscriptions = $configurationXml->DataSources->WindowsEventLog->Subscriptions;
         if (count($subscriptions->string) > 1) {
             $subscriptions = $subscriptions->string;
         } else {
             $subscriptions = array($subscriptions->string);
         }
         foreach ($subscriptions as $subscription) {
             $this->DataSources->WindowsEventLog->addSubscription((string) $subscription);
         }
     }
     // Assign Directories settings
     $this->DataSources->Directories->BufferQuotaInMB = (int) $configurationXml->DataSources->Directories->BufferQuotaInMB;
     $this->DataSources->Directories->ScheduledTransferPeriodInMinutes = (int) $configurationXml->DataSources->Directories->ScheduledTransferPeriodInMinutes;
     if ($configurationXml->DataSources->Directories->Subscriptions && $configurationXml->DataSources->Directories->Subscriptions->DirectoryConfiguration) {
         $subscriptions = $configurationXml->DataSources->Directories->Subscriptions;
         if (count($subscriptions->DirectoryConfiguration) > 1) {
             $subscriptions = $subscriptions->DirectoryConfiguration;
         } else {
             $subscriptions = array($subscriptions->DirectoryConfiguration);
         }
         foreach ($subscriptions as $subscription) {
             $this->DataSources->Directories->addSubscription((string) $subscription->Path, (string) $subscription->Container, (int) $subscription->DirectoryQuotaInMB);
         }
     }
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:63,代码来源:ConfigurationInstance.php

示例4: scanXmlString

 public static function scanXmlString($xmlString)
 {
     if (self::callbackChecker('Zend_Xml_Security', 'scan')) {
         //Protected method
         $xmlObj = Zend_Xml_Security::scan($xmlString);
         if (!$xmlObj) {
             throw new XenForo_Exception("Invalid XML in {$xmlObj}");
         }
     } else {
         //Classic PHP method
         $xmlObj = simplexml_load_string($xmlString);
     }
     return $xmlObj;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:14,代码来源:Bbm.php

示例5: __construct

 /**
  * Constructor
  *
  * @param string $data XML Result
  * @return void
  */
 public function __construct($data)
 {
     set_error_handler(array($this, 'handleXmlErrors'));
     $this->_sxml = Zend_Xml_Security::scan($data);
     restore_error_handler();
     if ($this->_sxml === false) {
         if ($this->_errstr === null) {
             $message = "An error occured while parsing the REST response with simplexml.";
         } else {
             $message = "REST Response Error: " . $this->_errstr;
             $this->_errstr = null;
         }
         throw new Zend_Rest_Client_Result_Exception($message);
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:21,代码来源:Result.php

示例6: __construct

 /**
  * Class constructor.  Parse the XML response from a Nirvanix method
  * call into a decorated SimpleXMLElement element.
  *
  * @param string $xml  XML response string from Nirvanix
  * @throws Zend_Service_Nirvanix_Exception
  */
 public function __construct($xml)
 {
     $this->_sxml = Zend_Xml_Security::scan($xml);
     if (!$this->_sxml instanceof SimpleXMLElement) {
         $this->_throwException("XML could not be parsed from response: {$xml}");
     }
     $name = $this->_sxml->getName();
     if ($name != 'Response') {
         $this->_throwException("Expected XML element Response, got {$name}");
     }
     $code = (int) $this->_sxml->ResponseCode;
     if ($code != 0) {
         $msg = (string) $this->_sxml->ErrorMessage;
         $this->_throwException($msg, $code);
     }
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:23,代码来源:Response.php

示例7: getXmlFromFile

 /**
  * Returns a SimpleXML element from the provided file name (or XenForo_Upload object)
  * provided it is valid. If it is not valid, an error is thrown.
  *
  * @param string|XenForo_Upload $file
  *
  * @return SimpleXMLElement
  */
 public function getXmlFromFile($file)
 {
     if ($file instanceof XenForo_Upload) {
         $file = $file->getTempFile();
     }
     if (!file_exists($file)) {
         throw $this->_controller->responseException($this->_controller->responseError(new XenForo_Phrase('please_enter_valid_file_name_requested_file_not_read')));
     }
     try {
         $xml = Zend_Xml_Security::scanFile($file);
         if ($xml) {
             return $xml;
         }
     } catch (Exception $e) {
     }
     throw $this->_controller->responseException($this->_controller->responseError(new XenForo_Phrase('provided_file_was_not_valid_xml_file')));
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:25,代码来源:Xml.php

示例8: __construct

 /**
  * Zend_Feed_Entry_Abstract constructor
  *
  * The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
  * is part of, and optionally an XML construct (usually a
  * SimpleXMLElement, but it can be an XML string or a DOMNode as
  * well) that contains the contents of the entry.
  *
  * @param  string $uri
  * @param  SimpleXMLElement|DOMNode|string  $element
  * @return void
  * @throws Zend_Feed_Exception
  */
 public function __construct($uri = null, $element = null)
 {
     if (!$element instanceof DOMElement) {
         if ($element) {
             // Load the feed as an XML DOMDocument object
             @ini_set('track_errors', 1);
             $doc = new DOMDocument();
             $doc = @Zend_Xml_Security::scan($element, $doc);
             @ini_restore('track_errors');
             if (!$doc) {
                 // prevent the class to generate an undefined variable notice (ZF-2590)
                 if (!isset($php_errormsg)) {
                     if (function_exists('xdebug_is_enabled')) {
                         $php_errormsg = '(error message not available, when XDebug is running)';
                     } else {
                         $php_errormsg = '(error message not available)';
                     }
                 }
                 /**
                  * @see Zend_Feed_Exception
                  */
                 // require_once 'Zend/Feed/Exception.php';
                 throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
             }
             $element = $doc->getElementsByTagName($this->_rootElement)->item(0);
             if (!$element) {
                 /**
                  * @see Zend_Feed_Exception
                  */
                 // require_once 'Zend/Feed/Exception.php';
                 throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
             }
         } else {
             $doc = new DOMDocument('1.0', 'utf-8');
             if ($this->_rootNamespace !== null) {
                 $element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
             } else {
                 $element = $doc->createElement($this->_rootElement);
             }
         }
     }
     parent::__construct($element);
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:56,代码来源:Abstract.php

示例9: __construct

 /**
  * Create auth adapter
  *
  * @param string $rolefile File containing XML with users and roles
  */
 public function __construct($rolefile)
 {
     $this->_acl = new Zend_Acl();
     $xml = Zend_Xml_Security::scanFile($rolefile);
     /*
     Roles file format:
      <roles>
        <role id=”admin”>
             <user name=”user1” password=”pwd”/>
         </role>
        <role id=”hr”>
             <user name=”user2” password=”pwd2”/>
         </role>
     </roles>
     */
     foreach ($xml->role as $role) {
         $this->_acl->addRole(new Zend_Acl_Role((string) $role["id"]));
         foreach ($role->user as $user) {
             $this->_users[(string) $user["name"]] = array("password" => (string) $user["password"], "role" => (string) $role["id"]);
         }
     }
 }
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:27,代码来源:Auth.php

示例10: extractMetaData

 /**
  * Extract metadata from document
  *
  * @param ZipArchive $package    ZipArchive OpenXML package
  * @return array    Key-value pairs containing document meta data
  */
 protected function extractMetaData(ZipArchive $package)
 {
     // Data holders
     $coreProperties = array();
     // Read relations and search for core properties
     $relations = Zend_Xml_Security::scan($package->getFromName("_rels/.rels"));
     foreach ($relations->Relationship as $rel) {
         if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) {
             // Found core properties! Read in contents...
             $contents = Zend_Xml_Security::scan($package->getFromName(dirname($rel["Target"]) . "/" . basename($rel["Target"])));
             foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORE) as $child) {
                 $coreProperties[$child->getName()] = (string) $child;
             }
             foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) as $child) {
                 $coreProperties[$child->getName()] = (string) $child;
             }
             foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORETERMS) as $child) {
                 $coreProperties[$child->getName()] = (string) $child;
             }
         }
     }
     return $coreProperties;
 }
开发者ID:conectapb,项目名称:sysagroweb,代码行数:29,代码来源:OpenXml.php

示例11: readXmlString

 /**
  * Convert XML to SimpleXml
  * If user wants DomDocument they can use dom_import_simplexml
  *
  * @return SimpleXml Object
  */
 public function readXmlString()
 {
     $string = $this->_stream->readLongUTF();
     return Zend_Xml_Security::scan($string);
     //simplexml_load_string($string);
 }
开发者ID:Kliwer,项目名称:lms,代码行数:12,代码来源:Deserializer.php

示例12: _convertResponseAndCheckContent

 /**
  * Converts $response body to a DOM object and checks it.
  *
  * @param   Zend_Http_Response $response
  * @return  DOMDocument
  * @throws  Zend_Service_Technorati_Exception if response content contains an error message
  * @access  protected
  */
 protected function _convertResponseAndCheckContent(Zend_Http_Response $response)
 {
     $dom = new DOMDocument();
     $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
     self::_checkErrors($dom);
     return $dom;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:15,代码来源:Technorati.php

示例13: _updateInstanceCountInConfiguration

 /**
  * Updates instance count in configuration XML.
  *
  * @param string|array $roleName			The role name
  * @param string|array $instanceCount		The instance count
  * @param string $configuration             XML configuration represented as a string
  * @throws Zend_Service_WindowsAzure_Management_Exception
  */
 protected function _updateInstanceCountInConfiguration($roleName, $instanceCount, $configuration)
 {
     // Change variables
     if (!is_array($roleName)) {
         $roleName = array($roleName);
     }
     if (!is_array($instanceCount)) {
         $instanceCount = array($instanceCount);
     }
     $configuration = preg_replace('/(<\\?xml[^?]+?)utf-16/i', '$1utf-8', $configuration);
     //$configuration = '<?xml version="1.0">' . substr($configuration, strpos($configuration, '>') + 2);
     $xml = Zend_Xml_Security::scan($configuration);
     // http://www.php.net/manual/en/simplexmlelement.xpath.php#97818
     $namespaces = $xml->getDocNamespaces();
     $xml->registerXPathNamespace('__empty_ns', $namespaces['']);
     for ($i = 0; $i < count($roleName); $i++) {
         $elements = $xml->xpath('//__empty_ns:Role[@name="' . $roleName[$i] . '"]/__empty_ns:Instances');
         if (count($elements) == 1) {
             $element = $elements[0];
             $element['count'] = $instanceCount[$i];
         }
     }
     $configuration = $xml->asXML();
     //$configuration = preg_replace('/(<\?xml[^?]+?)utf-8/i', '$1utf-16', $configuration);
     return $configuration;
 }
开发者ID:Cryde,项目名称:sydney-core,代码行数:34,代码来源:Client.php

示例14: loadXml

 /**
  * Load a response from an XML response
  *
  * Attempts to load a response from an XMLRPC response, autodetecting if it
  * is a fault response.
  *
  * @param string $response
  * @return boolean True if a valid XMLRPC response, false if a fault
  * response or invalid input
  */
 public function loadXml($response)
 {
     if (!is_string($response)) {
         $this->_fault = new Zend_XmlRpc_Fault(650);
         $this->_fault->setEncoding($this->getEncoding());
         return false;
     }
     try {
         $xml = Zend_Xml_Security::scan($response);
     } catch (Zend_Xml_Exception $e) {
         // Not valid XML
         $this->_fault = new Zend_XmlRpc_Fault(651);
         $this->_fault->setEncoding($this->getEncoding());
         return false;
     }
     if (!empty($xml->fault)) {
         // fault response
         $this->_fault = new Zend_XmlRpc_Fault();
         $this->_fault->setEncoding($this->getEncoding());
         $this->_fault->loadXml($response);
         return false;
     }
     if (empty($xml->params)) {
         // Invalid response
         $this->_fault = new Zend_XmlRpc_Fault(652);
         $this->_fault->setEncoding($this->getEncoding());
         return false;
     }
     try {
         if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
             require_once 'Zend/XmlRpc/Value/Exception.php';
             throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
         }
         $valueXml = $xml->params->param->value->asXML();
         $value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
     } catch (Zend_XmlRpc_Value_Exception $e) {
         $this->_fault = new Zend_XmlRpc_Fault(653);
         $this->_fault->setEncoding($this->getEncoding());
         return false;
     }
     $this->setReturnValue($value->getValue());
     return true;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:53,代码来源:Response.php

示例15: unserialize

 /**
  * Unserialize from WDDX to PHP
  *
  * @param  string $wddx
  * @param  array $opts
  * @return mixed
  * @throws Zend_Serializer_Exception on wddx error
  */
 public function unserialize($wddx, array $opts = array())
 {
     $ret = wddx_deserialize($wddx);
     if ($ret === null) {
         // check if the returned NULL is valid
         // or based on an invalid wddx string
         try {
             $simpleXml = Zend_Xml_Security::scan($wddx);
             if (isset($simpleXml->data[0]->null[0])) {
                 return null;
                 // valid null
             }
             $errMsg = 'Can\'t unserialize wddx string';
         } catch (Zend_Xml_Exception $e) {
             $errMsg = $e->getMessage();
         }
         require_once 'Zend/Serializer/Exception.php';
         throw new Zend_Serializer_Exception($errMsg);
     }
     return $ret;
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:29,代码来源:Wddx.php


注:本文中的Zend_Xml_Security类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。