Пример #1
0
function embedImageURL($url)
{
    $url .= "/details/xs";
    // PHP5 befigyel!!!
    $doc = new DOMDocument();
    $opts = array('http' => array('max_redirects' => 100));
    $resource = stream_context_get_default($opts);
    $context = stream_context_create($opts);
    libxml_set_streams_context($context);
    // Pattogna kulonben a cookie miatt, kenytelenek vagyunk curl-t hasznalni
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile");
    curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile");
    # SAME cookiefile
    if (@$doc->loadHTML(curl_exec($curl))) {
        if ($retnode = $doc->getElementById("textfield-url")) {
            echo "megy";
            return "<img src=\"{$retnode->nodeValue}\">";
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 public function __construct(ConfigInterface $config, $xsdUrl)
 {
     $this->url = $xsdUrl;
     // Generate a stream context used by libxml to access external resources.
     // This will allow DOMDocument to load XSDs through a proxy.
     $streamContextFactory = new StreamContextFactory();
     libxml_set_streams_context($streamContextFactory->create($config));
     $document = new DOMDocument();
     $loaded = $document->load($xsdUrl);
     if (!$loaded) {
         throw new Exception('Unable to load XML from ' . $xsdUrl);
     }
     parent::__construct($document, $document->documentElement);
     // Register the schema to avoid cyclic imports.
     self::$loadedUrls[] = $xsdUrl;
     // Locate and instantiate schemas which are referenced by the current schema.
     // A reference in this context can either be
     // - an import from another namespace: http://www.w3.org/TR/xmlschema-1/#composition-schemaImport
     // - an include within the same namespace: http://www.w3.org/TR/xmlschema-1/#compound-schema
     $this->referereces = array();
     foreach ($this->xpath('//wsdl:import/@location|' . '//s:import/@schemaLocation|' . '//s:include/@schemaLocation') as $reference) {
         $referenceUrl = $reference->value;
         if (strpos($referenceUrl, '//') === false) {
             $referenceUrl = dirname($xsdUrl) . '/' . $referenceUrl;
         }
         if (!in_array($referenceUrl, self::$loadedUrls)) {
             $this->referereces[] = new SchemaDocument($config, $referenceUrl);
         }
     }
 }
 public function createStream()
 {
     // Register Stream Wrapper
     stream_wrapper_register("efm", "XslTemplateLoaderStream");
     $exsl = $this->getFunctions();
     $opts = array('efm' => array('namespaces' => $exsl['declarations'], 'functions' => $exsl['functions']));
     $streamContext = stream_context_create($opts);
     libxml_set_streams_context($streamContext);
 }
Пример #4
0
 public function retrieveDefinitions()
 {
     Utils::log(LOG_DEBUG, "Retreiving definitions from the " . OvalRedHat::getName() . " OVAL", __FILE__, __LINE__);
     $defs = array();
     foreach ($this->getSubSourceDefs() as $subSourceDef) {
         # Loading the defined file
         $oval = new DOMDocument();
         libxml_set_streams_context(Utils::getStreamContext());
         $oval->load($subSourceDef->getUri());
         if ($oval === FALSE) {
             Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
             throw new Exception("Cannot load OVAL [source URI=" . $subSourceDef->getUri() . "]");
         }
         # Get the XPath
         $this->_xpath = new DOMXPath($oval);
         $this->_xpath->registerNamespace("def", "http://oval.mitre.org/XMLSchema/oval-definitions-5");
         $xDefinitions = $this->_xpath->query("/def:oval_definitions/def:definitions/def:definition");
         # Go through all definitions
         foreach ($xDefinitions as $xDefinition) {
             $def = array();
             $def['subSourceDefId'] = $subSourceDef->getId();
             $def['definition_id'] = $xDefinition->attributes->item(0)->value;
             $el_severity = $xDefinition->getElementsByTagName('severity')->item(0);
             if (!empty($el_severity)) {
                 $def['severity'] = $el_severity->nodeValue;
             } else {
                 $def['severity'] = "n/a";
             }
             $def['title'] = rtrim($xDefinition->getElementsByTagName('title')->item(0)->nodeValue);
             $def['ref_url'] = $xDefinition->getElementsByTagName('reference')->item(0)->getAttribute('ref_url');
             // Get associated CVEs
             $cve_query = 'def:metadata/def:advisory/def:cve';
             $cves = $this->_xpath->query($cve_query, $xDefinition);
             $def['cves'] = array();
             $def['os'] = array();
             foreach ($cves as $cve) {
                 array_push($def['cves'], $cve->nodeValue);
             }
             // Processing criteria
             $root_criterias_query = 'def:criteria';
             $root_criterias = $this->_xpath->query($root_criterias_query, $xDefinition);
             foreach ($root_criterias as $root_criteria) {
                 $os = null;
                 $package = array();
                 $this->processCriterias($this->_xpath, $root_criteria, $def, $os, $package);
             }
             array_push($defs, $def);
         }
         $this->updateSubSourceLastChecked($subSourceDef);
     }
     return $defs;
 }
Пример #5
0
 /**	Load the page, parse for iconic links, and add them to icon list if
 		they are valid.
 	*/
 protected function links_from_site()
 {
     /*
     	Quietly fetch the site contents into a DOM
     */
     $dom = new DOMDocument();
     $dom->recover = true;
     $dom->strictErrorChecking = false;
     $default_context = stream_context_get_default();
     $stream_context = stream_context_create($this->stream_context_options);
     libxml_set_streams_context($stream_context);
     $libxml_err_state = libxml_use_internal_errors(true);
     $dom_result = @$dom->loadHTMLFile($this->site_url);
     libxml_clear_errors();
     libxml_use_internal_errors($libxml_err_state);
     libxml_set_streams_context($default_context);
     if ($dom_result === false) {
         $status = self::header_findr($http_response_header, null);
         @(list(, $status, ) = explode(' ', $status, 3));
         $status = (int) $status;
         trigger_error('site \'' . $this->site_url . '\' returned ' . $status, E_USER_NOTICE);
         return false;
     }
     /*
     	If we followed any redirects, rewrite the site_url with the current
     	location, so that relative urls may be correctly converted into
     	their absolute form.
     */
     $location = self::header_findr($http_response_header, 'Location');
     if ($location !== null) {
         $this->site_url = $location;
     }
     /* check all the links which relate to icons */
     foreach ($dom->getElementsByTagName('link') as $link) {
         $relations = explode(' ', $link->getAttribute('rel'));
         if (in_array('icon', array_map('strtolower', $relations))) {
             $href = $link->getAttribute('href');
             $href_absolute = $this->absolutize_url($href);
             $icon = $this->validate_icon($href_absolute);
             if ($icon !== null) {
                 if (empty($icon['type'])) {
                     $icon['type'] = $link->getAttribute('type');
                 }
                 if (empty($icon['sizes'])) {
                     $icon['sizes'] = $link->getAttribute('sizes');
                 }
                 $this->favicons[] = $icon;
             }
         }
     }
 }
Пример #6
0
 function __construct()
 {
     require_once 'constants.php';
     if (PROXY) {
         // Define the default, system-wide context.
         $r_default_context = stream_context_get_default(array('http' => array('proxy' => PROXY_IP . ":" . PROXY_PORT, 'request_fulluri' => True, 'timeout' => 8)));
         // Though we said system wide, some extensions need a little coaxing.
         libxml_set_streams_context($r_default_context);
     } else {
         // Define the default, system-wide context.
         $r_default_context = stream_context_get_default(array('http' => array('timeout' => 8)));
         // Though we said system wide, some extensions need a little coaxing.
         libxml_set_streams_context($r_default_context);
     }
 }
Пример #7
0
 public function loadSettings()
 {
     libxml_set_streams_context($this->ctx);
     libxml_use_internal_errors(true);
     $this->setCommand(['trigger' => 'c', 'action' => 'c', 'arguments' => -1, 'determiter' => ',', 'help' => 'Randomize arguments. Determiter is set as ",". Example: "!c apple, banana, oranges".']);
     $this->setCommand(['trigger' => 'iroha', 'action' => 'iroha', 'arguments' => 1, 'channels' => ['#bodzio', '#xandros'], 'help' => 'Sending a link to episode. Just type "!iroha <nr of episode>" to get link.']);
     $this->setCommand(['trigger' => 'kier', 'channels' => ['#bodzio', '#xandros'], 'action' => 'kier']);
     $this->setCommand(['trigger' => 'random', 'action' => 'random', 'arguments' => -1, 'help' => '"!random" default search loli, but you can find anything you want. ' . 'You can change rating by adding safe|nsfw|ques to arguments and change ' . 'image server by adding yan (yande.re).', 'ban' => ['nick' => 'Thebassa']]);
     $this->setCommand(['trigger' => 'biba', 'reply' => 'Biba dance: https://www.youtube.com/watch?v=kpJcgkEdMRg']);
     $this->setCommand(['trigger' => 'hubi1', 'channels' => ['#bodzio'], 'reply' => '[10:31pm] <+hubi1> k-on byl fajny']);
     $this->setCommand(['trigger' => 'maido', 'reply' => 'Maido dance: https://www.youtube.com/watch?v=a-7_XdPktgc']);
     $this->setCommand(['trigger' => 'mikuluka', 'reply' => 'https://www.youtube.com/watch?v=ZllY2wBLYN4']);
     $this->setCommand(['trigger' => 'okusama04', 'channels' => ['#bodzio'], 'notice' => 'prosze: https://mega.co.nz/#!HplkQaCZ!gTgt_BjzpEoUe6-5_ObXke_PDM-S9Me6xz8aW_cVD0A']);
     $this->setCommand(['trigger' => 'nonnon11', 'channels' => ['#bodzio'], 'notice' => 'prosze: https://mega.nz/#!qolFGZpb!T3Ic5DDJKOy4TBp1xHnDtT4T9ctzianr-ofW_EZ9eT0']);
     $this->setCommand(['trigger' => 'rolypoly', 'reply' => 'Roly-poly: http://www.youtube.com/watch?v=3Xolk2cFzlo']);
     $this->setCommand(['trigger' => 'weaboo', 'reply' => 'Weaboo song: https://www.youtube.com/watch?v=TBfWKmRFTjM']);
     $this->setCommand(['trigger' => 'xandros', 'reply' => '[9:58pm] <Inkwizytor> xandros, kup sobie slownik']);
     $this->setCommand(['trigger' => 'cycki', 'action' => 'cycki']);
     parent::loadSettings();
 }
Пример #8
0
 /**
  * checkPSVersion ask to prestashop.com if there is a new version. return an array if yes, false otherwise
  * 
  * @return mixed
  */
 public function checkPSVersion($force = false)
 {
     if (class_exists('Configuration')) {
         $last_check = Configuration::get('PS_LAST_VERSION_CHECK');
     } else {
         $last_check = 0;
     }
     // if we use the autoupgrade process, we will never refresh it
     // except if no check has been done before
     if ($force || $last_check < time() - 3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS) {
         libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3))));
         if ($feed = @simplexml_load_file($this->rss_version_link)) {
             $this->version_name = (string) $feed->version->name;
             $this->version_num = (string) $feed->version->num;
             $this->link = (string) $feed->download->link;
             $this->md5 = (string) $feed->download->md5;
             $this->changelog = (string) $feed->download->changelog;
             $this->autoupgrade = (int) $feed->autoupgrade;
             $this->autoupgrade_module = (int) $feed->autoupgrade_module;
             $this->autoupgrade_last_version = (string) $feed->autoupgrade_last_version;
             $this->autoupgrade_module_link = (string) $feed->autoupgrade_module_link;
             $this->desc = (string) $feed->desc;
             $config_last_version = array('name' => $this->version_name, 'num' => $this->version_num, 'link' => $this->link, 'md5' => $this->md5, 'autoupgrade' => $this->autoupgrade, 'autoupgrade_module' => $this->autoupgrade_module, 'autoupgrade_last_version' => $this->autoupgrade_last_version, 'autoupgrade_module_link' => $this->autoupgrade_module_link, 'changelog' => $this->changelog, 'desc' => $this->desc);
             if (class_exists('Configuration')) {
                 Configuration::updateValue('PS_LAST_VERSION', serialize($config_last_version));
                 Configuration::updateValue('PS_LAST_VERSION_CHECK', time());
             }
         }
     } else {
         $this->loadFromConfig();
     }
     // retro-compatibility :
     // return array(name,link) if you don't use the last version
     // false otherwise
     if (version_compare(_PS_VERSION_, $this->version_num, '<')) {
         $this->need_upgrade = true;
         return array('name' => $this->version_name, 'link' => $this->link);
     } else {
         return false;
     }
 }
Пример #9
0
 /**
  * This is added to fix a bug with remote DTDs that are blocking automated php request on some domains:
  * @link http://stackoverflow.com/questions/4062792/domdocumentvalidate-problem
  * @link https://bugs.php.net/bug.php?id=48080
  */
 private function registerXmlStreamContext()
 {
     libxml_set_streams_context(stream_context_create(array('http' => array('user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0'))));
 }
Пример #10
0
 /**
  * Execute the code generation
  */
 public function generate()
 {
     /*
      * PROXY CONFIGURATION
      */
     $proxy = current(array_filter(array(getenv('HTTP_PROXY'), getenv('http_proxy')), 'strlen'));
     if ($proxy) {
         $parsedWsdlPath = Url::createFromUrl($this->config->getWsdlDocumentPath());
         // if not fetching the wsdl file from filesystem and a proxy has been set
         if ($parsedWsdlPath->getScheme()->get() !== 'file') {
             $proxy = Url::createFromUrl($proxy);
             libxml_set_streams_context(stream_context_get_default(array($proxy->getScheme()->get() => array('proxy' => 'tcp://' . $proxy->getAuthority() . $proxy->getRelativeUrl(), 'request_fulluri' => true))));
         }
     }
     unset($proxy);
     /*
      * LOAD THE WSDL DOCUMENT
      */
     $wsdlDocument = SimpleXMLElement::loadFile($this->config->getWsdlDocumentPath());
     $wsdlDocument->registerXPathNamespace('wsdl', static::WSDL_NS);
     $schemaReader = new SchemaReader();
     /* @var \Goetas\XML\XSDReader\Schema\Schema[] $schemas */
     $schemas = array();
     /* @var \Goetas\XML\XSDReader\Schema\Type\Type[] $types */
     $types = array();
     /*
      * LOAD THE XML SCHEMAS
      */
     // read the schemas included in the wsdl document
     foreach ($wsdlDocument->xpath('/wsdl:definitions/wsdl:types/xsd:schema') as $schemaNode) {
         $schemas[] = $schemaReader->readNode(dom_import_simplexml($schemaNode));
     }
     // exclude the schemas having the following namespaces
     $unusedSchemaNamespaces = array(SchemaReader::XML_NS, SchemaReader::XSD_NS);
     // recursively read all the schema chain
     $processedSchemas = array();
     while (!empty($schemas)) {
         /* @var \Goetas\XML\XSDReader\Schema\Schema $currentSchema */
         $currentSchema = array_shift($schemas);
         if (!in_array($currentSchema, $processedSchemas) and !in_array($currentSchema->getTargetNamespace(), $unusedSchemaNamespaces)) {
             $processedSchemas[] = $currentSchema;
             $schemas = array_merge($schemas, $currentSchema->getSchemas());
         }
     }
     $schemas = $processedSchemas;
     // cleanup
     unset($currentSchema);
     unset($processedSchemas);
     unset($unusedSchemaNamespaces);
     unset($schemaNode);
     unset($schemaReader);
     /*
      * LOAD THE DEFINED TYPES
      */
     // get the complete list of defined types
     foreach ($schemas as $schema) {
         $types = array_merge($types, $schema->getTypes());
     }
     /*
      * LOAD THE SERVICES
      */
     $services = $wsdlDocument->xpath('/wsdl:definitions/wsdl:portType');
     /*
      * CODE GENERATION
      */
     $classFactory = new ClassFactory($this->config, $schemas, $types);
     foreach ($types as $type) {
         if ($type instanceof SimpleType) {
             // build the inheritance chain of the current SimpleType
             /* @var \Goetas\XML\XSDReader\Schema\Type\SimpleType[] $inheritanceChain */
             $inheritanceChain = array($type->getRestriction());
             // loop through the type inheritance chain untill the base type
             while (end($inheritanceChain) !== null) {
                 $inheritanceChain[] = end($inheritanceChain)->getBase()->getParent();
             }
             // remove the null value
             array_pop($inheritanceChain);
             // remove the 'anySimpleType'
             array_pop($inheritanceChain);
             // now the last element of the chain is the base simple type
             // enums are built only of string enumerations
             if (end($inheritanceChain)->getBase()->getName() === 'string' and array_key_exists('enumeration', $type->getRestriction()->getChecks())) {
                 $className = $classFactory->createEnum($type);
                 $this->eventDispatcher->dispatch(Event::ENUM_CREATE, new Event($className));
             }
         } elseif ($type instanceof ComplexType) {
             $className = $classFactory->createDTO($type);
             $this->eventDispatcher->dispatch(Event::DTO_CREATE, new Event($className));
         }
     }
     foreach ($services as $service) {
         $className = $classFactory->createService($service);
         $this->eventDispatcher->dispatch(Event::SERVICE_CREATE, new Event($className));
     }
     $className = $classFactory->createClassmap();
     $this->eventDispatcher->dispatch(Event::CLASSMAP_CREATE, new Event($className));
     /*
      * GENERATED CODE FIX
      */
     // create the coding standards fixer
     $fixer = new Fixer();
     $config = new FixerConfig();
     $config->setDir($this->config->getOutputPath());
     // register all the existing fixers
     $fixer->registerBuiltInFixers();
     $config->fixers(array_filter($fixer->getFixers(), function (FixerInterface $fixer) {
         return $fixer->getLevel() === FixerInterface::PSR2_LEVEL;
     }));
     // fix the generated code
     $fixer->fix($config);
 }
 /**
  * Parses the target wsdl and loads the interpretation into object members
  *
  * @param string $wsdl the URI of the wsdl to interpret
  * @param string $soapClientClassName the class name which the generated
  *     client will extend
  * @param array $classmap the class map to use when generating classes
  * @param string $serviceName the name of the service being worked on
  * @param string $version the version of the service
  * @param string $author the author to be placed in the file header
  * @param string $package the package to be placed in the file header
  * @param string $soapClientClassPath the class path to require for the
  *     SOAP client
  * @param string $proxy the proxy URL to use when downloading WSDLs
  * @throws WSDLInterpreterException container for all WSDL interpretation
  *     problems
  * @todo Create plug in model to handle extendability of WSDL files
  */
 public function __construct($wsdl, $soapClientClassName, $classmap, $conflictClassmap, $serviceName, $version, $author, $package, $soapClientClassPath, $proxy, $enablePseudoNamespaces, $skipClassNameCheckTypes)
 {
     try {
         $this->_wsdl = $wsdl;
         $this->_soapClientClassName = $soapClientClassName;
         $this->_serviceName = $serviceName;
         $this->_version = $version;
         $this->_author = $author;
         $this->_package = $package;
         if (isset($classmap)) {
             $this->_classmap = $classmap;
         }
         $this->_enablePseudoNamespaces = isset($enablePseudoNamespaces) ? $enablePseudoNamespaces : false;
         if (!$this->_enablePseudoNamespaces) {
             // Only use if pseudo-namespaces aren't enabled.
             if (isset($conflictClassmap)) {
                 $this->_classmap = array_merge($this->_classmap, $conflictClassmap);
             }
             if (isset($skipClassNameCheckTypes)) {
                 $this->_skipClassNameCheckTypes = $skipClassNameCheckTypes;
             }
         }
         $this->_soapClientClassPath = $soapClientClassPath;
         // Set proxy.
         if (!empty($proxy)) {
             $opts = array('http' => array('proxy' => $proxy, 'request_fulluri' => TRUE));
             $context = stream_context_get_default($opts);
             libxml_set_streams_context($context);
         }
         $this->_dom = new DOMDocument();
         $this->_dom->load($wsdl, LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NOENT | LIBXML_XINCLUDE);
         $xpath = new DOMXPath($this->_dom);
         // Service namespace.
         $this->_serviceNamespace = $this->_dom->documentElement->getAttribute('targetNamespace');
         /**
          * wsdl:import
          */
         $query = "//*[local-name()='import' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']";
         $entries = $xpath->query($query);
         foreach ($entries as $entry) {
             $parent = $entry->parentNode;
             $wsdl = new DOMDocument();
             $wsdl->load($entry->getAttribute("location"), LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NOENT | LIBXML_XINCLUDE);
             foreach ($wsdl->documentElement->childNodes as $node) {
                 $newNode = $this->_dom->importNode($node, true);
                 $parent->insertBefore($newNode, $entry);
             }
             $parent->removeChild($entry);
         }
         /**
          * xsd:import
          */
         $query = "//*[local-name()='import' and namespace-uri()='http://www.w3.org/2001/XMLSchema']";
         $entries = $xpath->query($query);
         foreach ($entries as $entry) {
             $parent = $entry->parentNode;
             $xsd = new DOMDocument();
             $result = @$xsd->load(dirname($this->_wsdl) . "/" . $entry->getAttribute("schemaLocation"), LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NOENT | LIBXML_XINCLUDE);
             if ($result) {
                 foreach ($xsd->documentElement->childNodes as $node) {
                     $newNode = $this->_dom->importNode($node, true);
                     $parent->insertBefore($newNode, $entry);
                 }
                 $parent->removeChild($entry);
             }
         }
         $this->_loadNamespaces($xpath);
         $this->_dom->formatOutput = true;
     } catch (Exception $e) {
         throw new WSDLInterpreterException("Error loading WSDL document (" . $e->getMessage() . ")");
     }
     try {
         $xsl = new XSLTProcessor();
         $xslDom = new DOMDocument();
         $xslDom->load(dirname(__FILE__) . "/wsdl2php.xsl");
         $xsl->registerPHPFunctions();
         $xsl->importStyleSheet($xslDom);
         $this->_dom = $xsl->transformToDoc($this->_dom);
         $this->_dom->formatOutput = true;
         //$this->_dom->save("dom.xml");
     } catch (Exception $e) {
         throw new WSDLInterpreterException("Error interpreting WSDL document (" . $e->getMessage() . ")");
     }
     $this->_loadClassAndFunctionNames();
     $this->_loadClasses();
     $this->_loadServices();
 }
Пример #12
0
function fetchBingResults($query, $querysize, $msnsoapkey, $culture_info)
{
    // set proxy enviroment
    global $CFG;
    if (!empty($CFG->proxyhost)) {
        $r_default_context = stream_context_get_default(array('http' => array('proxy' => $CFG->proxyhost . ':' . $CFG->proxyport, 'request_fulluri' => True)));
        // Though we said system wide, some extensions need a little coaxing.
        libxml_set_streams_context($r_default_context);
    }
    $results = array();
    $request = 'http://api.bing.net/xml.aspx?Appid=' . $msnsoapkey . '&sources=web&Query=' . urlencode($query) . '&culture=' . $culture_info . '&Web.Options=DisableHostCollapsing+DisableQueryAlterations' . '&Options=DisableLocationDetection&Version=2.2';
    $response = new DOMDocument();
    $response->load($request);
    $webResults = $response->getElementsByTagName("WebResult");
    if ($webResults->length != 0) {
        foreach ($webResults as $value) {
            $results[] = $value->childNodes->item(2)->nodeValue;
        }
    }
    return $results;
}
Пример #13
0
<?php

class TestWrapper
{
    function stream_open($path, $mode, $options, &$opened_path)
    {
        if ($this->context) {
            print_r(stream_context_get_options($this->context));
        }
        return false;
    }
    function url_stat($path, $flags)
    {
        return array();
    }
}
stream_wrapper_register("test", "TestWrapper") or die("Failed to register protocol");
$ctx1 = stream_context_create(array('test' => array('test' => 'test 1')));
$ctx2 = stream_context_create(array('test' => array('test' => 'test 2')));
stream_context_set_default(stream_context_get_options($ctx1));
@simplexml_load_file('test://sdfsdf');
libxml_set_streams_context($ctx2);
@simplexml_load_file('test://sdfsdf');
Пример #14
0
            }
        }
        rmdir($directory);
    }
}
$installer = new Installer();
try {
    $installer->log('phpDocumentor installer for manual installations');
    // An IP was provided thus we set up proxying
    if (isset($argv[1]) && $argv[1] != 'dev') {
        // All HTTP requests are passed through the local NTLM proxy server.
        $r_default_context = stream_context_get_default(array('http' => array('proxy' => $argv[1], 'request_fulluri' => true)));
        // remove the second item in the array and reindex the keys
        array_splice($argv, 1, 1);
        // Though we said system wide, some extensions need a little coaxing.
        libxml_set_streams_context($r_default_context);
    }
    if (isset($argv[1]) && $argv[1] == 'dev') {
        $installer->log('> Downloading development application from Github');
        $installer->downloadDevelopmentPhpDocumentorArchive();
    } else {
        $installer->log('> Downloading application from Github');
        $installer->downloadLatestPhpDocumentorArchive();
    }
    $installer->log('> Extracting application');
    $installer->extractPhpDocumentorToCurrentDirectory();
    $installer->log('> Preparing dependencies');
    $composer_location = '';
    if (!$installer->testForComposer()) {
        // composer is not installed, install it to a temporary directory
        $composer_location = sys_get_temp_dir();
Пример #15
0
 public static function checkOpenSiVersion($version)
 {
     libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3))));
     if ($feed = @simplexml_load_file('http://www.opensi.fr/connect/version.xml') and $version < $feed->version->num) {
         return array('name' => $feed->version->name, 'link' => $feed->download->link);
     }
     return false;
 }
Пример #16
0
if (!defined("PATH_SEPARATOR")) {
    define("PATH_SEPARATOR", getenv("COMSPEC") ? ";" : ":");
}
define('PROJECT_PATH', dirname(__FILE__));
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . PROJECT_PATH);
/*function __autoload($class_name) {

    $class = PROJECT_PATH.'/lib/'.strtolower($class_name).'.class.php';

    if (!file_exists($class)){
        throw new Exception('Class file for "'.$class_name.'" not found');
    }
    
    require $class;
}*/
require "lib/splclassloader.class.php";
$classLoader = new SplClassLoader(null, PROJECT_PATH . DIRECTORY_SEPARATOR . 'lib');
$classLoader->setFileExtension('.class.php');
$classLoader->setExcludeNs('Stalker\\Lib');
$classLoader->register();
if (Config::exist('default_timezone')) {
    date_default_timezone_set(Config::get('default_timezone'));
}
if (Config::exist('http_proxy')) {
    $default_context = array('http' => array('proxy' => Config::get('http_proxy'), 'request_fulluri' => true));
    if (Config::exist('http_proxy_login') && Config::exist('http_proxy_password')) {
        $default_context['http']['header'] = "Proxy-Authorization: Basic " . base64_encode(Config::get('http_proxy_login') . ":" . Config::get('http_proxy_password')) . "\r\n";
    }
    stream_context_set_default($default_context);
    libxml_set_streams_context(stream_context_create($default_context));
}
Пример #17
0
function checkPSVersion()
{
    libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3))));
    if ($feed = @simplexml_load_file('http://www.prestashop.com/xml/version.xml') and _PS_VERSION_ < $feed->version->num) {
        return array('name' => $feed->version->name, 'link' => $feed->download->link);
    }
    return false;
}
 /**
  *
  * @param string $titre
  * @param string $langue
  */
 function __construct($titre, $langue = 'fr-fr')
 {
     $titre = strval($titre);
     $langue = strval($langue);
     //    if($typeDTD != $this::TYPE_DTD_XHTML_TRANSITIONAL
     //    || $typeDTD != $this::TYPE_DTD_XHTML_STRICT)
     //    {
     //      $typeDTD = $this::TYPE_DTD_XHTML_TRANSITIONAL;
     //    }
     $typeDTD = $this::TYPE_DTD_XHTML_TRANSITIONAL;
     $this->implementation = new DOMImplementation();
     $this->dtd = $this->implementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 ' . $typeDTD . '//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-' . strtolower($typeDTD) . '.dtd');
     // DOC: La solution au problème de validation DOMDocument::validate()
     // http://stackoverflow.com/questions/4062792/domdocumentvalidate-problem
     $opts = array('http' => array('user_agent' => 'PHP libxml agent; ' . 'qyy-php-misc; GabaritXhtmlTransitional'));
     $context = stream_context_create($opts);
     libxml_set_streams_context($context);
     $this->document = $this->implementation->createDocument('', '', $this->dtd);
     $this->init($titre, $langue);
 }
Пример #19
0
$libxml_errlvl = array(LIBXML_ERR_WARNING => 'Warning ', LIBXML_ERR_ERROR => 'Error ', LIBXML_ERR_FATAL => 'Fatal Error ');
$timeout = 30;
// seconds
$response = '';
$lasttip = null;
$current_tip = null;
$dayofyear = date('z');
$day = date('j');
$month = date('F');
/**
 * In case we use a proxy... just in case... */
$http_context = array('method' => 'GET');
if (totd_xml_proxy !== 'none') {
    $http_context = array('method' => 'GET', 'proxy' => totd_xml_proxy, 'request_fulluri' => TRUE);
}
libxml_set_streams_context(stream_context_get_default(array('http' => $http_context)));
/**
 * Check for errors... */
try {
    if (($xml = simplexml_load_file(totd_xml_url2)) === FALSE) {
        //$errors = libxml_get_errors();
        //$errstr = '';
        //foreach ($errors as $error)
        //{
        //	$errstr .= $libxml_errlvl[$error->level] . $error->code . ': ' . trim($error->message) . ', Line: ' . $error->line . ', Column: ' . $error->column;
        //	if ($error->file)
        //		$errstr .= ', File: ' . $error->file;
        //	$errstr .= "\n";
        //}
        //throw new Exception($errstr);
    }
Пример #20
0
 /**
  * Set Stream context options
  *
  * @param Array $options Stream context options
  *
  * @return boolean true on success, false on failure
  */
 public function setStreamContext(array $options)
 {
     if (!count($options)) {
         return FALSE;
     }
     $context = stream_context_create($options);
     libxml_set_streams_context($context);
     return TRUE;
 }
Пример #21
0
 /**
  * return an array of files
  * that the md5file does not match to the original md5file (provided by $rss_md5file_link_dir )
  * @return void
  */
 public function getChangedFilesList()
 {
     if (is_array($this->changed_files) && count($this->changed_files) == 0) {
         libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3))));
         $checksum = @simplexml_load_file($this->rss_md5file_link_dir . _PS_VERSION_ . '.xml');
         if ($checksum == false) {
             $this->changed_files = false;
         } else {
             $this->browseXmlAndCompare($checksum->ps_root_dir[0]);
         }
     }
     return $this->changed_files;
 }
Пример #22
0
<?php

$opts = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . "Cookie: foo=bar\r\n"), 'file' => array());
$context = stream_context_create($opts);
libxml_set_streams_context($context);
$d = domdocument::load('http://localhost/stream-example.xml');
print $d->saveXML();
Пример #23
0
 /**
  * A magic method that forwards all method calls
  * to the remote XML-RPC server and returns
  * that server's response on success or throws
  * an exception on failure.
  *
  * \param string $method
  *      The remote procedure to call.
  *
  * \param array $args
  *      A list of arguments to pass to the remote
  *      procedure.
  *
  * \retval mixed
  *      The remote server's response, as a native
  *      type (string, int, boolean, float or
  *      DateTime object).
  *
  * \throw fpoirotte::XRL::Exception
  *      Raised in case the remote server's response
  *      indicates some kind of error. You may use
  *      this exception's getCode() and getMessage()
  *      methods to find out more about the error.
  *
  * \throw RuntimeException
  *      Raised when this client wasn't able to query
  *      the remote server (such as when no connection
  *      could be established to it).
  */
 public function __call($method, array $args)
 {
     $newArgs = array_map('\\fpoirotte\\XRL\\NativeEncoder::convert', $args);
     $request = new \fpoirotte\XRL\Request($method, $newArgs);
     $xml = $this->encoder->encodeRequest($request);
     $options = array('http' => array('method' => 'POST', 'content' => $xml, 'header' => 'Content-Type: text/xml'));
     $context = stream_context_create(array_merge_recursive($this->options, $options));
     libxml_set_streams_context($context);
     return $this->decoder->decodeResponse($this->baseURL);
 }
Пример #24
0
<?php

$ctxs = array(NULL, 'bogus', 123, new stdclass(), array('a'), stream_context_create(), stream_context_create(array('file')), stream_context_create(array('file' => array('some_opt' => 'aaa'))));
foreach ($ctxs as $ctx) {
    var_dump(libxml_set_streams_context($ctx));
    $dom = new DOMDocument();
    var_dump($dom->load(dirname(__FILE__) . '/test.xml'));
}
echo "Done\n";
Пример #25
0
<?php

$v2245023265ae4cf87d02c8b6ba991139 = mainConfiguration::getInstance();
$va10311459433adf322f2590a4987c423 = $v2245023265ae4cf87d02c8b6ba991139->get('streams', 'enable');
if (is_array($va10311459433adf322f2590a4987c423)) {
    foreach ($va10311459433adf322f2590a4987c423 as $v7984c499103be1baf2128dbd2684b68d) {
        umiBaseStream::registerStream($v7984c499103be1baf2128dbd2684b68d);
    }
}
if ($vfa71f997fa1a947459dc5495fdb40b0f = $v2245023265ae4cf87d02c8b6ba991139->get('streams', 'user-agent')) {
    $veb4112b6a6b76c8a84808a40baa94769 = array('http' => array('user_agent' => $vfa71f997fa1a947459dc5495fdb40b0f));
    $v5c18ef72771564b7f43c497dc507aeab = stream_context_create($veb4112b6a6b76c8a84808a40baa94769);
    libxml_set_streams_context($v5c18ef72771564b7f43c497dc507aeab);
}
Пример #26
0
 /**
  * @param Transpiler $transpiler
  * @param DOMDocument $styleSheet
  * @return DOMDocument
  */
 private function getTranspiledStyleSheet(Transpiler $transpiler, DOMDocument $styleSheet)
 {
     $this->boot();
     $streamContext = stream_context_create($this->createStreamOptions($transpiler));
     libxml_set_streams_context($streamContext);
     return $this->createTranspiledDocument($styleSheet);
 }
Пример #27
0
function get_price($card_name, $set_name, $foil = false)
{
    if ($foil) {
        $set_name = trim($set_name);
        //echo $set_name.'1<br>';
        $set_name .= ' Foil';
        //echo $set_name.'2<br>';
    }
    $link = fix_url_price(trim($card_name), trim($set_name));
    //echo $link;
    //var_dump($link);
    $opts = array('http' => array('user_agent' => 'PHP libxml agent'));
    $context = stream_context_create($opts);
    libxml_set_streams_context($context);
    $article = new DOMDocument();
    @$article->loadHTMLFile($link);
    @($node = $article->getElementById('card-name'));
    @($node = $node->nodeValue);
    //echo $node;
    $start = strpos($node, '$') + 1;
    $end = strpos($node, 'Set:');
    $length = $end - $start;
    $price = substr($node, $start, $length);
    //echo $price.'1<br>';
    $price = floatval($price);
    //echo $price.'2<br>';
    return $price;
}
Пример #28
0
 private function getXmlMd5File($filename, $node_name, $ps_version = false)
 {
     $filename = dirname(__FILE__) . '/config/' . $filename;
     if (is_file($filename)) {
         $checksum = @simplexml_load_file($filename);
     } else {
         if ($ps_version !== false) {
             $upgrader = new Upgrader();
             libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3))));
             $checksum = @simplexml_load_file($upgrader->rss_md5file_link_dir . $ps_version . '.xml');
             if ($checksum != false) {
                 $checksum->asXML($filename);
             }
         }
     }
     if (isset($checksum) && $checksum != false) {
         $fileslist_md5 = $this->md5FileAsFilesArray($checksum->{$node_name}[0]);
         return $fileslist_md5;
     }
     return false;
 }
 /**
  * Get the wsdl (download it).
  *
  * @param string $wsdlUri the wsdl URL
  * @param null|string $proxy the proxy string if required, null otherwise
  */
 protected function loadWsdl($wsdlUri, $proxy = null)
 {
     // Set proxy.
     if ($proxy) {
         $opts = array('http' => array('proxy' => $proxy, 'request_fulluri' => true));
         $context = stream_context_get_default($opts);
         libxml_set_streams_context($context);
     }
     $this->dom = new DOMDocument();
     $this->dom->load($wsdlUri, LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NOENT | LIBXML_XINCLUDE);
     $this->serviceNamespace = $this->dom->documentElement->getAttribute('targetNamespace');
 }
Пример #30
0
 /**
  * Run this CLI script.
  *
  * \param array $args
  *      A list of arguments passed to this script.
  *
  * \retval int
  *      Exit code. \c 0 is used to indicate a
  *      success, while any other code indicates
  *      an error.
  *
  * \note
  *      In case of an error, additional messages
  *      may be sent to \c STDERR by this script.
  */
 public function run(array $args)
 {
     $prog = array_shift($args);
     try {
         list($options, $params) = $this->parse($args);
     } catch (\Exception $e) {
         fprintf(STDERR, '%s: %s' . PHP_EOL, $prog, $e->getMessage());
         return 2;
     }
     // Show help.
     if ($options['h']) {
         $this->printUsage(new \fpoirotte\XRL\Output(STDOUT), $prog);
         return 0;
     }
     // Show version.
     if ($options['V']) {
         $version = self::getVersion();
         $license = self::getCopyrightAndLicense();
         echo 'XRL version ' . $version . PHP_EOL;
         echo PHP_EOL . $license . PHP_EOL;
         echo 'Visit https://github.com/fpoirotte/XRL for more!' . PHP_EOL;
         return 0;
     }
     // Do we have enough arguments to do something?
     if ($params['serverURL'] === null || $params['procedure'] === null) {
         $this->printUsage(new \fpoirotte\XRL\Output(STDERR), $prog);
         return 2;
     }
     // Then let's do it!
     $encoder = new \fpoirotte\XRL\NativeEncoder(new \fpoirotte\XRL\Encoder($options['t'], true));
     $decoder = new \fpoirotte\XRL\NativeDecoder(new \fpoirotte\XRL\Decoder($options['t'], $options['x']));
     $request = new \fpoirotte\XRL\Request($params['procedure'], $params['additional']);
     // Change verbosity as necessary.
     if (class_exists('\\Plop\\Plop')) {
         $logging = \Plop\Plop::getInstance();
         $logging->getLogger()->setLevel(40 - max(4, $options['v']) * 10);
     } else {
         $logging = null;
     }
     // Prepare the request.
     $xml = $encoder->encodeRequest($request);
     $logging and $logging->debug("Request:\n%(request)s", array('request' => $xml));
     if ($options['n']) {
         echo 'Not sending the actual query due to dry run mode.' . PHP_EOL;
         return 0;
     }
     // Prepare the context.
     $ctxOptions = array('http' => array('method' => 'POST', 'content' => $xml, 'header' => 'Content-Type: text/xml'));
     $context = stream_context_create($ctxOptions);
     libxml_set_streams_context($context);
     // Send the request and process the response.
     try {
         $result = $decoder->decodeResponse($params['serverURL']);
     } catch (\Exception $result) {
         // Nothing to do.
     }
     echo 'Result:' . PHP_EOL . print_r($result, true) . PHP_EOL;
     return 0;
 }