Example #1
2
 function decodeGz64()
 {
     $contentNodes = $this->xpath->query("//content");
     foreach ($contentNodes as $contentNode) {
         if ($contentNode->getAttribute("contentType") == "application/x-gzip" && $contentNode->getAttribute('contentTransferEncoding') == "base64") {
             $contentDOM = new \DOMDocument();
             $contentDOM->loadXML(gzdecode(base64_decode($contentNode->nodeValue)));
             $xmlns = "http://schemas.ogf.org/nml/2013/05/base#";
             $tagName = "Topology";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $netNode) {
                 $node = $this->xml->importNode($netNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
             $xmlns = "http://schemas.ogf.org/nsi/2014/02/discovery/nsa";
             $tagName = "nsa";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $nsaNode) {
                 $node = $this->xml->importNode($nsaNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
         }
     }
 }
Example #2
0
	/**
	 * Cria o nó XML que representa o objeto ou conjunto de objetos na composição
	 * @return	string
	 * @see		Cielo::createXMLNode()
	 * @throws	BadMethodCallException Se a URL de retorno não tiver sido especificada
	 * @throws	BadMethodCallException Se os dados do pedido não tiver sido especificado
	 */
	public function createXMLNode() {
		if (  !empty( $this->tid ) ) {
			$dom = new DOMDocument( '1.0' , 'UTF-8' );
			$dom->loadXML( parent::createXMLNode() );
			$dom->encoding = 'UTF-8';

			$namespace = $this->getNamespace();
			$query = $dom->getElementsByTagNameNS( $namespace , $this->getRootNode() )->item( 0 );
			$EcData = $dom->getElementsByTagNameNS( $namespace , 'dados-ec' )->item( 0 );

			if ( $EcData instanceof DOMElement ) {
				$tid = $dom->createElement( 'tid' , $this->tid );
				$query->insertBefore( $tid , $EcData );

				if (  !is_null( $this->value ) ) {
					$value = $dom->createElement( 'valor' , $this->value );
					$query->insertBefore( $value , $EcData );
				}

				if (  !is_null( $this->annex ) ) {
					$annex = $dom->createElement( 'anexo' );
					$query->insertBefore( $annex , $EcData );
				}
			} else {
				throw new BadMethodCallException( 'O nó dados-ec precisa ser informado.' );
			}

			return $dom->saveXML();
		} else {
			throw new BadMethodCallException( 'O ID da transação deve ser informado.' );
		}
	}
 /**
  * Private Error handler logic
  */
 private function _handleError(&$result, &$headers, &$xmlPayLoad, &$HTTPHeaders)
 {
     // Fallback error messages
     $ErrorCode = 'Errorcode unavailable as there was no content received from the server.';
     $ErrorMsg = 'Errormessage unavailable as there was no content received from the server.';
     if (strlen($result) > 0) {
         $xmlError = new \DOMDocument();
         $xmlError->loadXML($result);
         try {
             $ErrorCode = $xmlError->getElementsByTagNameNS('http://config.services.bol.com/schemas/serviceerror-1.5.xsd', 'errorCode');
             $ErrorCode = $ErrorCode->item(0)->nodeValue;
             $ErrorMsg = $xmlError->getElementsByTagNameNS('http://config.services.bol.com/schemas/serviceerror-1.5.xsd', 'errorMessage');
             $ErrorMsg = $ErrorMsg->item(0)->nodeValue;
         } catch (Exception $e) {
             echo 'An error occurred while parsing the XML Error Message. Raw XML printed below<br>';
         }
     }
     // @TODO: Dit netjes oplossen. Mooie custom Exception definieren en deze data in stoppen.
     echo 'XML Payload: "' . (strlen($xmlPayLoad) > 0 ? $xmlPayLoad : 'No XML data received, so there\'s nothing to parse!') . "\"\n<br>";
     echo "<pre>Curl header info:\n";
     print_r($headers);
     echo "HTTP Headers:\n";
     print_r($HTTPHeaders);
     echo "</pre>";
     if ($this->debug) {
         trigger_error($ErrorCode . ' - ' . $ErrorMsg, E_USER_ERROR);
     } else {
         throw new \Exception($ErrorCode . ' - ' . $ErrorMsg);
     }
 }
 /**
  * @dataProvider dataValidateSchemaFiles
  * @param string $file
  */
 public function testValidateSchema($file)
 {
     $found = false;
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->load($file);
     $dbalElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($dbalElements->length) {
         $dbalDom = new \DOMDocument('1.0', 'UTF-8');
         $dbalNode = $dbalDom->importNode($dbalElements->item(0));
         $dbalDom->appendChild($dbalNode);
         $ret = $dbalDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $ormElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($ormElements->length) {
         $ormDom = new \DOMDocument('1.0', 'UTF-8');
         $ormNode = $ormDom->importNode($ormElements->item(0));
         $ormDom->appendChild($ormNode);
         $ret = $ormDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $this->assertTrue($found, "Neither <doctrine:orm> nor <doctrine:dbal> elements found in given XML. Are namespaces configured correctly?");
 }
Example #5
0
 function decodeStream($request, $stream)
 {
     $dom = new DOMDocument("1.0");
     $success = $dom->loadXML($this->stripHTTPHeader($stream));
     $this->DOMDocument = $dom;
     if ($success && !empty($dom)) {
         // check for fault
         $response = $dom->getElementsByTagNameNS(eZSOAPEnvelope::ENV, 'Fault');
         if ($response->length == 1) {
             $this->IsFault = 1;
             foreach ($dom->getElementsByTagName("faultstring") as $faultNode) {
                 $this->FaultString = $faultNode->textContent;
                 break;
             }
             foreach ($dom->getElementsByTagName("faultcode") as $faultNode) {
                 $this->FaultCode = $faultNode->textContent;
                 break;
             }
             return;
         }
         // get the response
         $response = $dom->getElementsByTagNameNS($request->ns(), $request->name() . "Response");
         /* Some protocols do not use namespaces, and do not work with an empty namespace.
            So, if we get no response, try again without namespace.
            */
         if ($response->length == 0) {
             $response = $dom->getElementsByTagName($request->name() . "Response");
         }
         $response = $response->item(0);
         if (!empty($response)) {
             /* Cut from the SOAP spec:
                             The method response is viewed as a single struct containing an accessor
                             for the return value and each [out] or [in/out] parameter.
                             The first accessor is the return value followed by the parameters
                             in the same order as in the method signature.
             
                             Each parameter accessor has a name corresponding to the name
                             of the parameter and type corresponding to the type of the parameter.
                             The name of the return value accessor is not significant.
                             Likewise, the name of the struct is not significant.
                             However, a convention is to name it after the method name
                             with the string "Response" appended.
                             */
             $responseAccessors = $response->getElementsByTagName('return');
             if ($responseAccessors->length > 0) {
                 $returnObject = $responseAccessors->item(0);
                 $this->Value = $this->decodeDataTypes($returnObject);
             }
         } else {
             eZDebug::writeError("Got error from server");
         }
     } else {
         eZDebug::writeError("Could not process XML in response");
     }
 }
Example #6
0
 /**
  * Parses a validation response from a CAS server to see if the returning CAS request is valid
  *
  * @param string $results		xml or plain text response from cas server
  * @return bool						true if valid, false otherwise
  * @exception 						throws exception if cannot parse response or invalid version
  */
 private function isValid()
 {
     // values from the request
     $ticket = $this->request->getParam("ticket");
     // configuration settings
     $configCasValidate = $this->registry->getConfig("CAS_VALIDATE", true);
     $configCasValidate = rtrim($configCasValidate, '/');
     // figure out which type of response this is based on the service url
     $arrURL = explode("/", $configCasValidate);
     $service = array_pop($arrURL);
     // now get it!
     $url = $configCasValidate . "?ticket=" . $ticket . "&service=" . urlencode($this->validate_url);
     $http_client = Factory::getHttpClient();
     $http_client->setUri($url);
     $results = $http_client->send()->getBody();
     // validate is plain text
     if ($service == "validate") {
         $message_array = explode("\n", $results);
         if (count($message_array) >= 2) {
             if ($message_array[0] == "yes") {
                 return $message_array[1];
             }
         } else {
             throw new \Exception("Could not parse CAS validation response.");
         }
     } elseif ($service == "serviceValidate" || $service == "proxyValidate") {
         // these are XML based
         $xml = new \DOMDocument();
         $xml->loadXML($results);
         $cas_namespace = "http://www.yale.edu/tp/cas";
         $user = $xml->getElementsByTagNameNS($cas_namespace, "user")->item(0);
         $failure = $xml->getElementsByTagNameNS($cas_namespace, "authenticationFailure")->item(0);
         if ($user != null) {
             if ($user->nodeValue != "") {
                 return $user->nodeValue;
             } else {
                 throw new \Exception("CAS validation response missing username value");
             }
         } elseif ($failure != null) {
             // see if error, rather than failed authentication
             if ($failure->getAttribute("code") == "INVALID_REQUEST") {
                 throw new \Exception("Invalid request to CAS server: " . $failure->nodeValue);
             }
         } else {
             throw new \Exception("Could not parse CAS validation response.");
         }
     } else {
         throw new \Exception("Unsupported CAS version.");
     }
     // if we got this far, the request was invalid
     return false;
 }
 /**
  * @return DOMElement
  * @throws Exception
  */
 private function getCleanDomTable()
 {
     $dom_tables = $this->doc->getElementsByTagNameNS(static::$NS_TABLE, 'table');
     if ($dom_tables->length != 1) {
         throw new Exception("Could not parse ODS template");
     }
     $this->dom_table = $dom_tables->item(0);
     $children = $this->dom_table->childNodes;
     for ($i = $children->length - 1; $i >= 0; $i--) {
         $this->dom_table->removeChild($children->item($i));
     }
     return $this->dom_table;
 }
Example #8
0
 /**
  * Parses a validation response from a CAS server to see if the returning CAS request is valid
  *
  * @param string $strResults		xml or plain text response from cas server
  * @return bool						true if valid, false otherwise
  * @exception 						throws exception if cannot parse response or invalid version
  */
 private function isValid()
 {
     // values from the request
     $strTicket = $this->request->getProperty("ticket");
     // configuration settings
     $configCasValidate = $this->registry->getConfig("CAS_VALIDATE", true);
     // figure out which type of response this is based on the service url
     $arrURL = explode("/", $configCasValidate);
     $service = array_pop($arrURL);
     // now get it!
     $strUrl = $configCasValidate . "?ticket=" . $strTicket . "&service=" . urlencode($this->validate_url);
     $strResults = Xerxes_Framework_Parser::request($strUrl);
     // validate is plain text
     if ($service == "validate") {
         $arrMessage = explode("\n", $strResults);
         if (count($arrMessage) >= 2) {
             if ($arrMessage[0] == "yes") {
                 return $arrMessage[1];
             }
         } else {
             throw new Exception("Could not parse CAS validation response.");
         }
     } elseif ($service == "serviceValidate" || $service == "proxyValidate") {
         // these are XML based
         $objXml = new DOMDocument();
         $objXml->loadXML($strResults);
         $strCasNamespace = "http://www.yale.edu/tp/cas";
         $objUser = $objXml->getElementsByTagNameNS($strCasNamespace, "user")->item(0);
         $objFailure = $objXml->getElementsByTagNameNS($strCasNamespace, "authenticationFailure")->item(0);
         if ($objUser != null) {
             if ($objUser->nodeValue != "") {
                 return $objUser->nodeValue;
             } else {
                 throw new Exception("CAS validation response missing username value");
             }
         } elseif ($objFailure != null) {
             // see if error, rather than failed authentication
             if ($objFailure->getAttribute("code") == "INVALID_REQUEST") {
                 throw new Exception("Invalid request to CAS server: " . $objFailure->nodeValue);
             }
         } else {
             throw new Exception("Could not parse CAS validation response.");
         }
     } else {
         throw new Exception("Unsupported CAS version.");
     }
     // if we got this far, the request was invalid
     return false;
 }
 /**
  * @param string $style_name
  * @param array $cellAttributes
  * @param array $textAttributes
  */
 protected function appendCellStyleNode($style_name, $cellAttributes, $textAttributes)
 {
     $node = $this->doc->createElementNS(static::$NS_STYLE, "style");
     $node->setAttribute("style:name", $style_name);
     $node->setAttribute("style:family", 'table-cell');
     $node->setAttribute("style:parent-style-name", "Default");
     if (count($cellAttributes) > 0) {
         $style = $this->doc->createElementNS(static::$NS_STYLE, 'table-cell-properties');
         foreach ($cellAttributes as $att_name => $att_val) {
             $style->setAttribute($att_name, $att_val);
         }
         $node->appendChild($style);
     }
     if (count($textAttributes) > 0) {
         $style = $this->doc->createElementNS(static::$NS_STYLE, 'text-properties');
         foreach ($textAttributes as $att_name => $att_val) {
             $style->setAttribute($att_name, $att_val);
         }
         $node->appendChild($style);
     }
     foreach ($this->doc->getElementsByTagNameNS(static::$NS_OFFICE, 'automatic-styles') as $element) {
         /** @var DOMElement $element */
         $element->appendChild($node);
     }
 }
Example #10
0
File: SOAP.php Project: sitya/saml2
 /**
  * Send a SAML 2 message using the SOAP binding.
  *
  * Note: This function never returns.
  *
  * @param SAML2_Message $message The message we should send.
  */
 public function send(SAML2_Message $message)
 {
     $envelope = '<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">' . '<soap-env:Header/><soap-env:Body /></soap-env:Envelope>';
     $doc = new DOMDocument();
     $doc->loadXML($envelope);
     $soapHeader = $doc->getElementsByTagNameNS('http://schemas.xmlsoap.org/soap/envelope/', 'Header');
     $soapBody = $doc->getElementsByTagNameNS('http://schemas.xmlsoap.org/soap/envelope/', 'Body');
     if ($message->toSignedXML()->localName === 'Response') {
         $response = new SAML2_XML_ecp_Response();
         $response->AssertionConsumerServiceURL = $this->getDestination();
         $response->toXML($soapHeader->item(0));
     }
     $soapBody->item(0)->appendChild($doc->importNode($message->toSignedXML(), true));
     print $doc->saveXML();
     exit(0);
 }
Example #11
0
 /**
  * Loads the service class
  *
  * @access private
  */
 private function loadService()
 {
     $name = $this->dom->getElementsByTagNameNS('*', 'service')->item(0)->getAttribute('name');
     $this->log($this->display('Starting to load service ') . $name);
     $this->service = new Service($name, $this->types, $this->documentation->getServiceDescription());
     $functions = $this->client->__getFunctions();
     foreach ($functions as $function) {
         $matches = array();
         if (preg_match('/^(\\w[\\w\\d_]*) (\\w[\\w\\d_]*)\\(([\\w\\$\\d,_ ]*)\\)$/', $function, $matches)) {
             $returns = $matches[1];
             $function = $matches[2];
             $params = $matches[3];
         } else {
             if (preg_match('/^(list\\([\\w\\$\\d,_ ]*\\)) (\\w[\\w\\d_]*)\\(([\\w\\$\\d,_ ]*)\\)$/', $function, $matches)) {
                 $returns = $matches[1];
                 $function = $matches[2];
                 $params = $matches[3];
             } else {
                 // invalid function call
                 throw new Exception('Invalid function call: ' . $function);
             }
         }
         $this->log($this->display('Loading function ') . $function);
         $this->service->addOperation($function, $params, $this->documentation->getFunctionDescription($function));
     }
     $this->log($this->display('Done loading service ') . $name);
 }
Example #12
0
 /**
  * Short description of method extract
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @return mixed
  */
 public function extract()
 {
     foreach ($this->getPaths() as $path) {
         // In the RDFExtractor, we expect the paths to points directly to the file.
         if (!file_exists($path)) {
             throw new tao_helpers_translation_TranslationException("No RDF file to parse at '{$path}'.");
         } else {
             if (!is_readable($path)) {
                 throw new tao_helpers_translation_TranslationException("'{$path}' is not readable. Please check file system rights.");
             } else {
                 try {
                     $tus = array();
                     $rdfNS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
                     $rdfsNS = 'http://www.w3.org/2000/01/rdf-schema#';
                     $xmlNS = 'http://www.w3.org/XML/1998/namespace';
                     // http://www.w3.org/TR/REC-xml-names/#NT-NCName
                     $translatableProperties = $this->translatableProperties;
                     // Try to parse the file as a DOMDocument.
                     $doc = new DOMDocument('1.0', 'UTF-8');
                     $doc->load(realpath($path));
                     if ($doc->documentElement->hasAttributeNS($xmlNS, 'base')) {
                         $this->xmlBase[$path] = $doc->documentElement->getAttributeNodeNS($xmlNS, 'base')->value;
                     }
                     $descriptions = $doc->getElementsByTagNameNS($rdfNS, 'Description');
                     foreach ($descriptions as $description) {
                         if ($description->hasAttributeNS($rdfNS, 'about')) {
                             $about = $description->getAttributeNodeNS($rdfNS, 'about')->value;
                             // At the moment only get rdfs:label and rdfs:comment
                             // c.f. array $translatableProperties
                             // In the future, this should be configured in the constructor
                             // or by methods.
                             $children = array();
                             foreach ($translatableProperties as $prop) {
                                 $uri = explode('#', $prop);
                                 if (count($uri) == 2) {
                                     $uri[0] .= '#';
                                     $nodeList = $description->getElementsByTagNameNS($uri[0], $uri[1]);
                                     for ($i = 0; $i < $nodeList->length; $i++) {
                                         $children[] = $nodeList->item($i);
                                     }
                                 }
                             }
                             foreach ($children as $child) {
                                 // Only process if it has a language attribute.
                                 $tus = $this->processUnit($child, $xmlNS, $about, $tus);
                             }
                         } else {
                             // Description about nothing.
                             continue;
                         }
                     }
                     $this->setTranslationUnits($tus);
                 } catch (DOMException $e) {
                     throw new tao_helpers_translation_TranslationException("Unable to parse RDF file at '{$path}'. DOM returns '" . $e->getMessage() . "'.");
                 }
             }
         }
     }
 }
Example #13
0
 protected function firstElementByTagNSString(\DOMDocument $doc, $namespace, $tagName)
 {
     $elements = $doc->getElementsByTagNameNS($namespace, $tagName);
     if ($elements->length > 0) {
         return $elements->item(0)->nodeValue;
     }
     throw new \Exception("Tag " . $namespace . ':' . $tagName . " not found");
 }
 /**
  * This returns true if the input string is KML.
  *
  * @param string $coverage The text data from the coverage field.
  *
  * @return bool $isKml Whether the string is KML.
  * @author Eric Rochester
  **/
 public static function isKml($coverage)
 {
     $isKml = false;
     $kmlNs = 'http://earth.google.com/kml/2.0';
     $names = array('Point', 'Polygon', 'LineString');
     try {
         $doc = new DOMDocument();
         @$doc->loadXML($coverage);
         $nodes = $doc->getElementsByTagNameNS($kmlNs, 'kml');
         if ($nodes->length === 1) {
             foreach ($names as $name) {
                 $isKml = $isKml || $doc->getElementsByTagNameNS($kmlNs, $name)->length > 0;
             }
         }
     } catch (Exception $e) {
     }
     return $isKml;
 }
Example #15
0
 function XmpInformation($stream)
 {
     $this->stream = $stream;
     $doc_root = new DOMDocument();
     $doc_root->loadXML($this->stream->get_data());
     $rdf_els = $doc_root->getElementsByTagNameNS($RDF_NAMESPACE, 'RDF');
     $this->rdf_root = $rdf_els[0];
     $this->cache = array();
 }
Example #16
0
 /**
  * Detects namespaces and prefixes from a DOM document
  *
  * @param DOMDocument $document
  */
 public function detectNamespacesFromDocument(DOMDocument $document)
 {
     $nodes = $document->getElementsByTagNameNS('*', '*');
     foreach ($nodes as $node) {
         if (!isset($this->_namespaces[$node->prefix])) {
             $this->_namespaces[$node->prefix] = $node->namespaceURI;
         }
     }
 }
Example #17
0
 /**
  * Assert service node is present in xml.
  *
  * @return DOMElement
  */
 protected function _assertServiceNode()
 {
     /** @var DOMElement $service */
     $service = $this->_dom->getElementsByTagNameNS(Wsdl::WSDL_NS_URI, 'service')->item(0);
     $this->assertNotNull($service, 'service node not found in WSDL.');
     $this->assertTrue($service->hasAttribute('name'));
     $this->assertEquals($this->_autoDiscover->getServiceName($this->_resourceName), $service->getAttribute('name'));
     $this->_assertPortNode($service, $this->_resourceName);
 }
 /**
  * Needed to move attributes out into elements which is what the SoapClient seems to expect.
  */
 public function reJig($response)
 {
     $responseDom = new DOMDocument('1.0');
     $responseDom->loadXML($response);
     // Don't rejig SOAP Fault responses.
     if ($responseDom->getElementsByTagNameNS(self::SOAP_ENV_NS_URI, 'Fault')->length > 0) {
         return $response;
     }
     $this->reJigNode($responseDom, $responseDom->documentElement);
     return $responseDom->saveXML();
 }
 public function preparefindAllCalendarsRequest($request)
 {
     $doc = new DOMDocument();
     $doc->loadXML($request);
     //$bulk = $doc->createElementNS('http://me.com/_namespace/', 'osxme:bulk-requests');
     $color = $doc->createElementNS('http://apple.com/ns/ical/', 'osxical:calendar-color');
     $prop = $doc->getElementsByTagNameNS('DAV:', 'prop')->item(0);
     //$prop->appendChild($bulk);
     $prop->appendChild($color);
     return $doc->saveXML();
 }
 public function convertXmlToPhp(SoapRequest $request, $data)
 {
     $doc = new \DOMDocument();
     $doc->loadXML($data);
     $includes = $doc->getElementsByTagNameNS('http://www.w3.org/2004/08/xop/include', 'Include');
     $include = $includes->item(0);
     $ref = $include->getAttribute('href');
     if (String::startsWith($ref, 'cid:')) {
         $cid = urldecode(substr($ref, 4));
         return $request->getSoapAttachments()->get($cid)->getContent();
     }
     return $data;
 }
Example #21
0
 /**
  * @param \DOMDocument $responseDoc
  *
  * @throws \Exception
  */
 public function __construct(\DOMDocument $responseDoc)
 {
     $actionResponse = $responseDoc->getElementsByTagNameNS(OrderService::NAMESPACE_N3, 'IPGApiActionResponse');
     $success = $this->firstElementByTagNSString($responseDoc, OrderService::NAMESPACE_N3, 'successfully');
     if ($actionResponse->length > 0) {
         $this->wasSuccessful = $success === 'true';
         if (false === $this->wasSuccessful) {
             $this->errorMessage = $this->firstElementByTagNSString($responseDoc, OrderService::NAMESPACE_N2, 'ErrorMessage');
         }
     } else {
         throw new \Exception("Validate Call failed " . $responseDoc->saveXML());
     }
 }
Example #22
0
 /**
  * @param string $user
  * @param string $pass
  * @throws Net_EPP_Exception
  */
 function login($user, $pass)
 {
     if (!$this->connected) {
         throw new Net_EPP_Exception("Not connected");
     }
     $frame = new Net_EPP_Frame_Command_Login();
     $frame->clID->appendChild($frame->createTextNode($user));
     $frame->pw->appendChild($frame->createTextNode($pass));
     $frame->eppVersion->appendChild($frame->createTextNode($this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'version')->item(0)->textContent));
     $frame->eppLang->appendChild($frame->createTextNode($this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'lang')->item(0)->textContent));
     $els = $this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'objURI');
     for ($i = 0; $i < $els->length; $i++) {
         $frame->svcs->appendChild($frame->importNode($els->item($i), true));
     }
     $els = $this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'svcExtension');
     if (1 == $els->length) {
         $frame->svcs->appendChild($frame->importNode($els->item(0), true));
     }
     $response = $this->request($frame);
     $status = $this->evaluateResponseCode($response);
     return $status;
 }
 public function getEmbed($url)
 {
     $urlArray = array();
     if (preg_match("/(www.)?youtube.com\\/watch\\?v=([\\w-]+)/", $url, $matches)) {
         $video_id = $matches[2];
     }
     $myEmbed = new VideoEmbed();
     $myEmbed->type = 'video';
     $myEmbed->version = '1.0';
     $myEmbed->provider_name = "Youtube";
     $myEmbed->provider_url = "http://youtube.com";
     $myEmbed->resource_url = $url;
     $xml = new DOMDocument();
     if (@$xml->load('http://gdata.youtube.com/feeds/api/videos/' . $video_id)) {
         $guid = $xml->getElementsByTagName("guid")->item(0)->nodeValue;
         $link = str_replace("http://www.youtube.com/watch?v=", "http://bergengocia.net/indavideobombyoutubemashup/view.php?id=", $guid);
         $myEmbed->title = $xml->getElementsByTagName("title")->item(0)->nodeValue;
         $myEmbed->description = $xml->getElementsByTagNameNS("*", "description")->item(0)->nodeValue;
         $myEmbed->author_name = $xml->getElementsByTagName("author")->item(0)->getElementsByTagName("name")->item(0)->nodeValue;
         $myEmbed->author_url = $xml->getElementsByTagName("author")->item(0)->getElementsByTagName("uri")->item(0)->nodeValue;
         $myEmbed->thumbnail_url = $xml->getElementsByTagNameNS("*", "thumbnail")->item(0)->getAttribute("url");
         $myEmbed->thumbnail_width = $xml->getElementsByTagNameNS("*", "thumbnail")->item(0)->getAttribute("width");
         $myEmbed->thumbnail_height = $xml->getElementsByTagNameNS("*", "thumbnail")->item(0)->getAttribute("height");
         $med_content_url = $xml->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "content")->item(0)->getAttribute("url");
         $myEmbed->html = '<object width="425" height="350">' . "\n" . ' <param name="movie" value="' . $med_content_url . '"></param>' . "\n" . ' <embed src="' . $med_content_url . '"' . '  type="application/x-shockwave-flash" width="425" height="350">' . "\n" . ' </embed>' . "\n" . '</object>';
         // according to http://code.google.com/apis/youtube/developers_guide_protocol.html#Displaying_information_about_a_video
         $myEmbed->width = "425";
         $myEmbed->height = "350";
         // same as in the html
         //$myEmbed->duration=$xml->getElementsByTagNameNS($xml->lookupNamespaceURI("*"),"content")->item(0)->getAttribute("duration");
         //$time = floor($duration / 60) . ":" . $duration % 60;
         return $myEmbed;
     } else {
         throw new Exception404("xxx");
     }
 }
	/**
	 * Cria o nó XML que representa o objeto ou conjunto de objetos na composição
	 * @return	string
	 * @see		Cielo::createXMLNode()
	 * @throws	BadMethodCallException Se a URL de retorno não tiver sido especificada
	 * @throws	BadMethodCallException Se os dados do pedido não tiver sido especificado
	 */
	public function createXMLNode() {
		if (  !empty( $this->tid ) ) {
			$dom = new DOMDocument( '1.0' , 'UTF-8' );
			$dom->loadXML( parent::createXMLNode() );
			$dom->encoding = 'UTF-8';

			$namespace = $this->getNamespace();
			$query = $dom->getElementsByTagNameNS( $namespace , $this->getRootNode() )->item( 0 );
			$EcData = $dom->getElementsByTagNameNS( $namespace , 'dados-ec' )->item( 0 );

			if ( $EcData instanceof DOMElement ) {
				$tid = $dom->createElement( 'tid' , $this->tid );
				$query->insertBefore( $tid , $EcData );

				$dom->childNodes->item( 0 )->appendChild( $dom->createElement( 'capturar-automaticamente' , $this->capture ? 'true' : 'false' ) );
			} else {
				throw new BadMethodCallException( 'O nó dados-ec precisa ser informado.' );
			}

			return $dom->saveXML();
		} else {
			throw new BadMethodCallException( 'O ID da transação deve ser informado.' );
		}
	}
Example #25
0
 /**
  * @param string $styleName
  * @param string $family
  * @param string $element
  * @param string[] $attributes
  */
 protected function appendStyleNode($styleName, $family, $element, $attributes)
 {
     $node = $this->doc->createElementNS(static::NS_STYLE, 'style');
     $node->setAttribute('style:name', $styleName);
     $node->setAttribute('style:family', $family);
     $style = $this->doc->createElementNS(static::NS_STYLE, $element);
     foreach ($attributes as $att_name => $att_val) {
         $style->setAttribute($att_name, $att_val);
     }
     $node->appendChild($style);
     foreach ($this->doc->getElementsByTagNameNS(static::NS_OFFICE, 'automatic-styles') as $element) {
         /** @var \DOMElement $element */
         $element->appendChild($node);
     }
 }
Example #26
0
 /**
  * Add new soap body element.
  *
  * @param \DOMElement $node DOMElement to add
  *
  * @return void
  */
 public function addBodyElement(\DOMElement $node)
 {
     $root = $this->domDocument->documentElement;
     $namespace = $root->namespaceURI;
     $prefix = $root->prefix;
     $nodeList = $this->domDocument->getElementsByTagNameNS($namespace, 'Body');
     // add body if not there
     if ($nodeList->length == 0) {
         // new body element
         $body = $this->domDocument->createElementNS($namespace, $prefix . ':Body');
         $root->appendChild($body);
         $body->appendChild($node);
     } else {
         $nodeList->item(0)->appendChild($node);
     }
 }
Example #27
0
function parseResult($result)
{
    //Format result;
    $res = substr($result, 4);
    //Get rid of 'OK :'
    $res = str_replace(array("\n", "\r", "\t"), '', $res);
    $res = trim(str_replace('"', "'", $res));
    $doc = new DOMDocument();
    $doc->loadXML($res);
    $rows = $doc->getElementsByTagNameNS('#RowsetSchema', 'row');
    $data = array();
    foreach ($rows as $row) {
        $date = $row->getAttribute('attenddate');
        $attend = $row->getAttribute('admissions');
        $data[$date] = $attend;
    }
    return $data;
}
Example #28
0
 /**
  * Specifiq method to insert the super user model,
  * by using a template RDF file
  * @param array $userData
  */
 public function insertSuperUser(array $userData)
 {
     if (empty($userData['login']) || empty($userData['password'])) {
         throw new tao_install_utils_Exception("To create a super user you must provide at least a login and a password");
     }
     $superUserOntology = dirname(__FILE__) . "/../ontology/superuser.rdf";
     if (!@is_readable($superUserOntology)) {
         throw new tao_install_utils_Exception("Unable to load ontology : {$superUserOntology}");
     }
     $doc = new DOMDocument();
     $doc->load($superUserOntology);
     foreach ($userData as $key => $value) {
         $tags = $doc->getElementsByTagNameNS('http://www.tao.lu/Ontologies/generis.rdf#', $key);
         foreach ($tags as $tag) {
             $tag->appendChild($doc->createCDATASection($value));
         }
     }
     return $this->insertLocalModel($doc->saveXML());
 }
Example #29
0
 /**
  * {@inheritDoc}
  */
 public function convertXmlToPhp($data)
 {
     $doc = new \DOMDocument();
     $doc->loadXML($data);
     $includes = $doc->getElementsByTagNameNS(Helper::NS_XOP, 'Include');
     $include = $includes->item(0);
     // convert href -> myhref for external references as PHP throws exception in this case
     // http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/ext/soap/php_encoding.c?view=markup#l3436
     $ref = $include->getAttribute('myhref');
     if ('cid:' === substr($ref, 0, 4)) {
         $contentId = urldecode(substr($ref, 4));
         if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
             return $part->getContent();
         } else {
             return null;
         }
     }
     return $data;
 }
function fixProfile($uri)
{
    $oprofile = Ostatus_profile::getKV('uri', $uri);
    if (!$oprofile) {
        print "No OStatus remote profile known for URI {$uri}\n";
        return false;
    }
    echo "Before:\n";
    showProfileInfo($oprofile);
    $feedurl = $oprofile->feeduri;
    $client = new HttpClient();
    $response = $client->get($feedurl);
    if ($response->isOk()) {
        echo "Updating profile from feed: {$feedurl}\n";
        $dom = new DOMDocument();
        if ($dom->loadXML($response->getBody())) {
            $feed = $dom->documentElement;
            $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
            if ($entries->length) {
                $entry = $entries->item(0);
                $activity = new Activity($entry, $feed);
                $oprofile->checkAuthorship($activity);
                echo "  (ok)\n";
            } else {
                echo "  (no entry; skipping)\n";
                return false;
            }
        } else {
            echo "  (bad feed; skipping)\n";
            return false;
        }
    } else {
        echo "Failed feed fetch: {$response->getStatus()} for {$feedurl}\n";
        return false;
    }
    echo "After:\n";
    showProfileInfo($oprofile);
    return true;
}