protected function getPackageInfo() { $xmlPath = sfConfig::get('sf_plugins_dir') . '/' . $this->getName() . '/package.xml'; if (!is_readable($xmlPath)) { return false; } $content = file_get_contents($xmlPath); return opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement')); }
protected function execute($arguments = array(), $options = array()) { // Remove E_STRICT and E_DEPRECATED from error_reporting error_reporting(error_reporting() & ~(E_STRICT | E_DEPRECATED)); require_once 'Archive/Tar.php'; $pluginName = $arguments['name']; $packagePath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName; if (!is_readable($packagePath . '/package.xml')) { throw new sfException(sprintf('Plugin "%s" dosen\'t have a definition file.', $pluginName)); } $content = file_get_contents($packagePath . '/package.xml'); $infoXml = opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement')); $filename = sprintf('%s-%s.tgz', (string) $infoXml->name, (string) $infoXml->version->release); $dirPath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName; $tar = new Archive_Tar($arguments['dir'] . '/' . $filename, true); foreach ($infoXml->contents->dir->file as $file) { $attributes = $file->attributes(); $name = (string) $attributes['name']; $tar->addString($pluginName . '-' . (string) $infoXml->version->release . '/' . $name, file_get_contents($dirPath . '/' . $name)); } $tar->addString('package.xml', file_get_contents($dirPath . '/package.xml')); }
public function retrieveXml($url) { $content = $this->downloadHttp($url); $result = @opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement')); return $result; }
<?php include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(null, new lime_output_color()); $t->diag('opToolkit::loadXmlString()'); $path_to_feed = realpath(dirname(__FILE__) . '/../../fixtures/feeds/www.xss.feed.rss'); $xml = '<a id="root">ok</a>'; $xml_with_xxe = '<!DOCTYPE a [<!ENTITY xxe SYSTEM "file://' . $path_to_feed . '">]><a id="root">ok&xxe;</a>'; $t->comment('with no external entities'); $t->isa_ok(opToolkit::loadXmlString($xml), 'DOMDocument', 'returns an instance of "DOMDocument"'); $t->isa_ok(opToolkit::loadXmlString($xml, array('return' => 'SimpleXMLElement')), 'SimpleXMLElement', 'returns an instanceof "SimpleXMLElement"'); $t->comment('with external entities'); $t->isa_ok(opToolkit::loadXmlString($xml_with_xxe), 'DOMDocument', 'returns an instance of "DOMDocument"'); $t->isa_ok(opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement')), 'SimpleXMLElement', 'returns an instanceof "SimpleXMLElement"'); $t->is(opToolkit::loadXmlString($xml_with_xxe)->textContent, 'ok', 'generated XML string by "DOMDocument" does not have entitied value'); $t->is((string) opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement')), 'ok', 'generated XML string by "SimpleXMLElement" does not have entitied value'); $t->isnt(opToolkit::loadXmlString($xml_with_xxe, array('loadEntities' => true))->textContent, 'ok', 'generated XML string by "DOMDocument" has entitied value if "loadEntities" option is specified'); $t->isnt((string) opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement', 'loadEntities' => true)), 'ok', 'generated XML string by "SimpleXMLElement" has entitied value if "loadEntities" option is specified');