Load local page contents, parse HTML anchor tags, find permalinks,
and send XML-RPC calls to corresponding pingback servers
@return NULL
@param $source string
193547
function inspect($source) {
		$fw=Base::instance();
		$web=Web::instance();
		$parts=parse_url($source);
		if (empty($parts['scheme']) || empty($parts['host']) ||
			$parts['host']==$fw->get('HOST')) {
			$req=$web->request($source);
			$doc=new DOMDocument('1.0',$fw->get('ENCODING'));
			$doc->stricterrorchecking=FALSE;
			$doc->recover=TRUE;
			if ($req && @$doc->loadhtml($req['body'])) {
				// Parse anchor tags
				$links=$doc->getelementsbytagname('a');
				foreach ($links as $link) {
					$permalink=$link->getattribute('href');
					// Find pingback-enabled resources
					if ($permalink && $found=$this->enabled($permalink)) {
						$req=$web->request($found,
							array(
								'method'=>'POST',
								'header'=>'Content-Type: application/xml',
								'content'=>xmlrpc_encode_request(
									'pingback.ping',
									array($source,$permalink),
									array('encoding'=>$fw->get('ENCODING'))
								)
							)
						);
						if ($req && $req['body'])
							$this->log.=date('r').' '.
								$permalink.' [permalink:'.$found.']'.PHP_EOL.
								$req['body'].PHP_EOL;
					}
				}
			}
			unset($doc);
		}
	}
637216
public function moveFrom(string $source): ?string
    {
        $ret = $this->handle->rpoplpush($source, $this->name);
        return (false === $ret) ? null : $ret;
    }
1082990
public static function load($source) {

		if(false === is_string($source) && false === $source instanceof Viewmodel) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or instance of sFire\MVC\Viewmodel, "%s" given', __METHOD__, gettype($source)), E_USER_ERROR);
		}

		$file = $source;

		if($source instanceof Viewmodel) {

			$path 			= Path :: get('modules') . Router :: getRoute() -> getModule() . DIRECTORY_SEPARATOR;
			$views 			= $path . Application :: get(['directory', 'view']);
			$translations 	= $path . Application :: get(['directory', 'translation']);
			$extension 		= Application :: get(['extensions', 'view']);
			$file  			= preg_replace('#^'. preg_quote($views) .'#', '', $source -> getFile());
			$file  			= preg_replace('#'. preg_quote($extension) .'$#', '', $file);
		}

		$module 	= Router :: getRoute() -> getModule();
		$extension 	= Application :: get(['extensions', 'translation']);
		$file 		= str_replace('.', DIRECTORY_SEPARATOR, $file);
		$file 		= Path :: get('modules') . $module . DIRECTORY_SEPARATOR . Application :: get(['directory', 'translation']) . $file . $extension;
		$file 		= new File($file);
		$identifier = md5($file -> entity() -> getBasepath());
		$cache 		= new File(Path :: get('cache-translation') . $identifier);

		if(false === $file -> exists() && false === $source instanceof Viewmodel) {
			return trigger_error(sprintf('Translation file "%s" used in %s() does not exists', $file -> entity() -> getBasepath(), __METHOD__), E_USER_ERROR);
		}

		static :: cache($cache, $file);

		return $identifier;
	}
1001834
public static function load($source)
    {
        self::$variables = is_array($source) ? $source : require $source;
        self::$isLoaded = true;

        self::checkRequiredVariables();
    }
639632
protected XmlPullParser loadXml(String source) throws UnsupportedEncodingException, XmlPullParserException, IOException {
		return loadXml(new ByteArrayInputStream(source.getBytes("UTF-8")));
	}
1230547
public function fromSource($source, $limit = Pagination::DEFAULT_LIMIT)
    {
        $data = ['domain' => $source];

        return $this->paginate(UrlBuilder::RESOURCE_DOMAIN_FEED, $data, $limit);
    }
78889
public function parse($source)
    {
        $document = $this->documentFactory->createDocumentFromSource($source);
        $context = clone $this->context;
        $iterator = new DOMIterator($document->childNodes, $context, $this->elementProcessor);

        // Iterate through all $node
        foreach ($iterator->getRecursiveIterator() as $node) {
            $node || true;
        }

        return $context->getChildren();
    }
803009
protected function parseSource(
        $source,
        DocumentFactoryInterface $documentFactory,
        ElementProcessorInterface $elementProcessor,
        ContextInterface $context
    ) {
        try {
            $parser = new Parser($documentFactory, $elementProcessor, $context);
            $things = $parser->parse($source);
            $gateway = new ThingGateway($this->iri);
            return (object)['items' => $gateway->export($things)];
        } catch (\OutOfBoundsException $e) {
            throw new OutOfBoundsException($e->getMessage(), $e->getCode());
        } catch (\RuntimeException $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode());
        }
    }
1064788
function listen($func,$path=NULL) {
		$fw=Base::instance();
		if (PHP_SAPI!='cli') {
			header('X-Powered-By: '.$fw->get('PACKAGE'));
			header('Content-Type: application/xml; '.
				'charset='.$charset=$fw->get('ENCODING'));
		}
		if (!$path)
			$path=$fw->get('BASE');
		$web=Web::instance();
		$args=xmlrpc_decode_request($fw->get('BODY'),$method,$charset);
		$options=array('encoding'=>$charset);
		if ($method=='pingback.ping' && isset($args[0],$args[1])) {
			list($source,$permalink)=$args;
			$doc=new DOMDocument('1.0',$fw->get('ENCODING'));
			// Check local page if pingback-enabled
			$parts=parse_url($permalink);
			if ((empty($parts['scheme']) ||
				$parts['host']==$fw->get('HOST')) &&
				preg_match('/^'.preg_quote($path,'/').'/'.
					($fw->get('CASELESS')?'i':''),$parts['path']) &&
				$this->enabled($permalink)) {
				// Check source
				$parts=parse_url($source);
				if ((empty($parts['scheme']) ||
					$parts['host']==$fw->get('HOST')) &&
					($req=$web->request($source)) &&
					$doc->loadhtml($req['body'])) {
					$links=$doc->getelementsbytagname('a');
					foreach ($links as $link) {
						if ($link->getattribute('href')==$permalink) {
							call_user_func_array($func,
								array($source,$req['body']));
							// Success
							die(xmlrpc_encode_request(NULL,$source,$options));
						}
					}
					// No link to local page
					die(xmlrpc_encode_request(NULL,0x11,$options));
				}
				// Source failure
				die(xmlrpc_encode_request(NULL,0x10,$options));
			}
			// Doesn't exist (or not pingback-enabled)
			die(xmlrpc_encode_request(NULL,0x21,$options));
		}
		// Access denied
		die(xmlrpc_encode_request(NULL,0x31,$options));
	}
263673
public function parsePoSource(string $source): void
    {
        /**
         * This is an incredibly ugly regex pattern that breaks a line of a po file into
         * pieces that can be analyzed and acted upon.
         *
         * The matches array in preg_match will break out like this:
         *  [0] full string
         *  [1] mostly useless broad match of initial token, including trailing space
         *  [2] bare token, or full msgstr[n] clause
         *  [3] 'n' of a msgstr[n] line
         *  [4] '"' if a data line
         *  [5] remaining line
         *  [6] a bare or malformed comment
         */
        $pattern = '/(^(#|#.|#;|#,|#\||msgid|msgid_plural|msgctxt|msgstr|msgstr\[([0-9]+)\])\s|(^"))(.+)|(^#.*)/';

        $source_lines = explode("\n", $source);

        $wsBreak = false;
        $inHeader = true;
        $headerEntry = new PoHeader;
        $entry = $headerEntry;
        $unrecognized = array();
        $lastKey = '';
        $currentPlural = 0;
        foreach ($source_lines as $line => $s) {
            $result = preg_match($pattern, $s, $matches);
            if (!$result) {
                $lastKey = '';
                if ($s=='' || ctype_space($s)) {
                    if ($inHeader) {
                        $this->setHeaderEntry($headerEntry);
                        $entry = null;
                        $inHeader = false;
                    }
                    if (!$wsBreak) {
                        if (!($entry === null)) {
                            $this->addEntry($entry);
                        }
                        $entry = null;
                        $wsBreak=true;
                    }
                } else {
                    $wsBreak=false;
                    $unrecognized[$line+1] = $s;
                }
            } else {
                if ($entry === null) {
                    $entry = new PoEntry;
                }
                $wsBreak=false;
                $currentKey = $matches[2];  // will be used to set last key
                switch ($matches[2]) {
                    case PoTokens::TRANSLATOR_COMMENTS:
                    case PoTokens::EXTRACTED_COMMENTS:
                    case PoTokens::REFERENCE:
                    case PoTokens::FLAG:
                    case PoTokens::OBSOLETE:
                    case PoTokens::PREVIOUS:
                        $entry->add($matches[2], $matches[5]);
                        break;
                    case PoTokens::CONTEXT:
                    case PoTokens::MESSAGE:
                    case PoTokens::PLURAL:
                    case PoTokens::TRANSLATED:
                        $entry->addQuoted($matches[2], $matches[5]);
                        break;
                    default:
                        if ($matches[4]==PoTokens::CONTINUED_DATA) {
                            $currentKey = $lastKey; // keep the previous key
                            if ($currentKey==PoTokens::TRANSLATED_PLURAL) {
                                $entry->addQuotedAtPosition(
                                    PoTokens::TRANSLATED,
                                    $currentPlural,
                                    '"' . $matches[5]
                                );
                            } else {
                                $entry->addQuoted($currentKey, '"' . $matches[5]);
                            }
                        } elseif (substr($matches[2], 0, 7)==PoTokens::TRANSLATED_PLURAL) {
                            $currentKey = PoTokens::TRANSLATED_PLURAL;
                            $currentPlural = $matches[3];
                            $entry->addQuotedAtPosition(
                                PoTokens::TRANSLATED,
                                $currentPlural,
                                $matches[5]
                            );
                        } elseif (isset($matches[6][0])
                            && $matches[6][0]==PoTokens::TRANSLATOR_COMMENTS) {
                            $value = substr($matches[6], 1);
                            $value = empty($value) ? '' : $value;
                            $entry->add(PoTokens::TRANSLATOR_COMMENTS, $value);
                        } else {
                            $unrecognized[$line+1] = $s;
                        }
                        break;
                }
                $lastKey = $currentKey;
            }
        }
        if (!($entry === null)) {
            $this->addEntry($entry);
        }

        // throw at the very end, anything recognized has been processed
        $this->unrecognizedInput = $unrecognized;
        if (count($unrecognized)) {
            throw new UnrecognizedInputException();
        }
    }
40367
public function url($source, $full = true)
    {
        $details = explode('?', $source);

        $path = $details[0];
        $path = $this->cleanPathInternal($path);
        $path = $this->getUrlPath($path, true);

        if (!empty($path)) {
            if (isset($details[1])) {
                $path .= '?' . $details[1];
            }

            $path = '/' . $path;
            return $full ? Url::root() . $path : $path;
        }

        return null;
    }
766506
public function resolveRoute($source = null)
    {
        return $this
            ->matcher
                ->match($this->getRouteCollection($source), $this->request);
    }
1003273
public static function parse($source) {
        $name = null;
        $value = null;

        if (preg_match_all('@(<\S*?'.'>)@', $source, $matches)) {
            $name = $matches[0][0];
        }
        if (preg_match_all('@\[default: (.*)\]@i', $source, $matches)) {
            $value = $matches[0][1];
        }
        return new static($name, $value);
    }
564145
public function parse($source)
    {
        $dom = new \DOMDocument();
        if (!$dom->loadXML($source, LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR)) {
            throw new \DOMException('Unable to parse source');
        }
        return $dom;
    }
907568
function loadString($source)
    {
        $this->setDimensions($this->max_x + 1, $this->max_y + 1);
        $this->appendString($source);
    }
818932
public static function load($source, string $contentType = 'text/xml', array $options = []): \FluentDOM\DOM\Document {
    if (NULL === self::$_loader) {
      self::$_loader = self::getDefaultLoaders();
    }
    $result = self::$_loader->load($source, $contentType, $options);
    return $result instanceof \DOMDocument ? $result : $result->getDocument();
  }
364044
protected static function parseTemplate($source)
    {
        $source =
            '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'.
            $source.
            '</msg>';
        $schema = dirname(__DIR__) .
                    DIRECTORY_SEPARATOR . 'data' .
                    DIRECTORY_SEPARATOR . 'styling.rng';
        $dom    =   new \Erebot\DOM();
        $dom->substituteEntities    = true;
        $dom->resolveExternals      = false;
        $dom->recover               = true;
        $ue     = libxml_use_internal_errors(true);
        $dom->loadXML($source);
        $valid  = $dom->relaxNGValidate($schema);
        $errors = $dom->getErrors();
        libxml_use_internal_errors($ue);

        if (!$valid || count($errors)) {
            // Some unpredicted error occurred,
            // show some (hopefully) useful information.
            if (class_exists('\\Plop\\Plop')) {
                $logger = \Plop\Plop::getInstance();
                $logger->error(print_r($errors, true));
            }
            throw new \InvalidArgumentException(
                'Error while validating the message'
            );
        }
        return $dom;
    }