Example #1
0
 function buildRequestHeader($requestParams)
 {
     $session = new SimpleXMLElement('<session></session>');
     $sessionId = $session->addchild('id');
     $clec = $session->addchild('clec');
     $clec->addchild('overrides');
     $id = $clec->addchild('id');
     $id[0] = $requestParams->id;
     $user = $clec->addchild('user');
     $firstName = $user->addChild('firstName');
     $firstName[0] = $requestParams->firstName;
     $lastName = $user->addChild('lastName');
     $lastName[0] = $requestParams->lastName;
     return $session;
 }
Example #2
0
 /**
  * Encode a variable value into the parameters of the XML tree
  *
  * @param SimpleXMLElement $params The parameter to add the value elements to.
  * @param mixed $arg The value to encode
  */
 public static function encode_arg($params, $arg)
 {
     switch (true) {
         case is_array($arg):
             $data = $params->addchild('value')->addchild('array')->addchild('data');
             foreach ($arg as $element) {
                 self::encode_arg($data, $element);
             }
             break;
         case $arg instanceof XMLRPCDate:
             $params->addchild('value')->addchild('dateTime.iso8601', date('c', $arg->date));
             break;
         case $arg instanceof XMLRPCBinary:
             $params->addchild('value')->addchild('base64', base64_encode($arg->data));
             break;
         case $arg instanceof XMLRPCStruct:
             $struct = $params->addchild('value')->addchild('struct');
             $object_vars = $arg->get_fields();
             foreach ($object_vars as $field) {
                 $member = $struct->addchild('member');
                 $member->addchild('name', $field);
                 self::encode_arg($member, $arg->{$field});
             }
             break;
         case is_object($arg):
             $struct = $params->addchild('value')->addchild('struct');
             $object_vars = get_object_vars($arg);
             foreach ($object_vars as $key => $value) {
                 $member = $struct->addchild('member');
                 $member->addchild('name', $key);
                 self::encode_arg($member, $value);
             }
             break;
         case is_integer($arg):
             $params->addchild('value')->addchild('i4', $arg);
             break;
         case is_bool($arg):
             $params->addchild('value')->addchild('boolean', $arg ? '1' : '0');
             break;
         case is_string($arg):
             $params->addchild('value')->addchild('string', $arg);
             break;
         case is_float($arg):
             $params->addchild('value')->addchild('double', $arg);
             break;
     }
 }
Example #3
0
 /**
  * Allow method overloading for this class.
  * This method allows any method name to be called on this object.  The method
  * called is the method called via RPC, within the scope defined in $this->scope.
  *
  * @param string $fname The function name to call
  * @param array $args An array of arguments that were called with the function
  * @return array The result array
  */
 public function __call($fname, $args)
 {
     if ($this->scope != '') {
         $rpc_method = "{$this->scope}.{$fname}";
     } else {
         $rpc_method = $fname;
     }
     $rpx = new SimpleXMLElement('<methodCall/>');
     $rpx->addChild('methodName', $rpc_method);
     if (count($args) > 0) {
         $params = $rpx->addchild('params');
         foreach ($args as $arg) {
             $param = $params->addchild('param');
             XMLRPCUtils::encode_arg($param, $arg);
         }
     }
     $request = new RemoteRequest($this->entrypoint, 'POST');
     $request->add_header('Content-Type: text/xml;charset=utf-8');
     $request->set_body($rpx->asXML());
     $request->execute();
     if ($request->executed()) {
         $response = $request->get_response_body();
         // @todo this should use the MultiByte class, not directly call mb_string functions
         $enc = mb_detect_encoding($response);
         $responseutf8 = mb_convert_encoding($response, 'UTF-8', $enc);
         try {
             // @todo this should use libxml_use_internal_errors() instead of trying to hide the PHP warning see the plugin info parsing code for an example
             $bit = ini_get('error_reporting');
             error_reporting($bit && !E_WARNING);
             $responsexml = new SimpleXMLElement($responseutf8);
             error_reporting($bit);
             $tmp = $responsexml->xpath('//params/param/value');
             if (!($responsestruct = reset($tmp))) {
                 $tmp = $responsexml->xpath('//fault/value');
                 if (!($responsestruct = reset($tmp))) {
                     throw new Exception(_t('Invalid XML response.'));
                 }
             }
             return XMLRPCUtils::decode_args($responsestruct);
         } catch (Exception $e) {
             //Utils::debug( $response, $e );
             error_reporting($bit);
             return false;
         }
     }
 }
Example #4
0
 /**
  * Allow method overloading for this class.
  * This method allows any method name to be called on this object.  The method
  * called is the method called via RPC, within the scope defined in $this->scope.
  *
  * @param string $fname The function name to call
  * @param array $args An array of arguments that were called with the function
  * @return array The result array
  */
 public function __call($fname, $args)
 {
     if ($this->scope != '') {
         $rpc_method = "{$this->scope}.{$fname}";
     } else {
         $rpc_method = $fname;
     }
     $rpx = new SimpleXMLElement('<methodCall/>');
     $rpx->addChild('methodName', $rpc_method);
     if (count($args) > 0) {
         $params = $rpx->addchild('params');
         foreach ($args as $arg) {
             $param = $params->addchild('param');
             XMLRPCUtils::encode_arg($param, $arg);
         }
     }
     $request = new RemoteRequest($this->entrypoint, 'POST');
     $request->add_header('Content-Type: text/xml');
     $request->set_body($rpx->asXML());
     $request->execute();
     if ($request->executed()) {
         $response = $request->get_response_body();
         $enc = mb_detect_encoding($response);
         $responseutf8 = mb_convert_encoding($response, 'UTF-8', $enc);
         try {
             $bit = ini_get('error_reporting');
             error_reporting($bit && !E_WARNING);
             $responsexml = new SimpleXMLElement($responseutf8);
             error_reporting($bit);
             $tmp = $responsexml->xpath('//params/param/value');
             if (!($responsestruct = reset($tmp))) {
                 $tmp = $responsexml->xpath('//fault/value');
                 if (!($responsestruct = reset($tmp))) {
                     throw new Exception(_t('Invalid XML response.'));
                 }
             }
             return XMLRPCUtils::decode_args($responsestruct);
         } catch (Exception $e) {
             //Utils::debug($response, $e);
             error_reporting($bit);
             return false;
         }
     }
 }
Example #5
0
 public function actionIndex()
 {
     // 		$arrGoogle=array('google','Gmail','Chrome','Android');
     // //第一次使用each取得当前键值对,并且将指针移到下一个位置
     // $arrG=each($arrGoogle);
     // print_r($arrG);
     // $arrGmail=each($arrGoogle);
     // print_r($arrGmail);
     // $arrChrome=each($arrGoogle);
     // print_r($arrChrome);
     // $arrAndroid=each($arrGoogle);
     // print_r($arrAndroid);
     //当指针位于数组末尾再次执行函数each,如果是这样再次执行结果返回false
     // $empty=each($arrGoogle);die();
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="GBK"?><DOCUMENT />');
     header("Content-type: text/html; charset=utf-8");
     include "simple_html_dom.php";
     $html = file_get_html('http://www.ttpet.com/quanzhong/jinmao.html');
     $item = $xml->addchild("item");
     // Find all images
     foreach ($html->find('dl.qz_inft ') as $element) {
         /*echo $element;die();*/
         /*echo $element->children(2);echo $element->children(3);die()*/
         // $num1 = $item->addchild("name",$element->children(1)->plaintext);
         $num1 = $item->addchild("alias", $element->children(2)->plaintext);
     }
     $num1 = $item->addchild("ename", $element->children(3)->plaintext);
     // $num1 = $item->addchild("weight",$element->children(8)->plaintext);
     // $num1 = $item->addchild("years",$element->children(9)->plaintext);
     // $num1 = $item->addchild("place",$element->children(10)->plaintext);
     // $num1 = $item->addchild("shape",$element->children(4)->plaintext);
     // $num1 = $item->addchild("wool",$element->children(6)->plaintext);
     $num1 = $item->addchild("function", $element->children(5)->plaintext);
     // $num1 = $item->addchild("name",$element->plaintext);
     // unset($num1);continue;
     // $item->addchild("age",$element-next_sibling()->plaintext();
     header("Content-type: text/xml");
     echo $xml->asXml();
     $xml->asXml("student.xml");
     // die();
 }
Example #6
0
 /**
  * Creates the KML code from data given
  *
  * @access public
  * @return string
  */
 public function __toString()
 {
     // Set the xml version
     $xml_head = '<?xml version="1.0" encoding="UTF-8"?>';
     // Open a new KML doc
     $sxe = new SimpleXMLElement('<kml xmlns = "http://earth.google.com/kml/2.1"></kml>');
     // Put document in the kml
     $doc = $sxe->addchild('Document');
     // Set all the styles for the document
     foreach ($this->styles as $s) {
         $style = $doc->addChild('Style');
         $style->addAttribute('id', $s->getId());
         $iconStyle = $style->addChild('IconStyle');
         $iconStyle->addAttribute('id', $s->getIconId());
         $icon = $iconStyle->addChild('Icon');
         $icon->addChild('href', $s->getIconLink());
     }
     // Set all the folders and places in each folder
     foreach ($this->folders as $f => $places) {
         if ($f != '**[root]**') {
             // Set the folder and folder name
             $folder = $doc->addChild('Folder');
             $folder->addChild('name', $f);
             $folder->addChild('open', 0);
             // Set all the placemarks in this folder
             foreach ($places as $p) {
                 // Add all the placemark details
                 $place = $folder->addChild('Placemark');
                 $place->addAttribute('id', $p->getId());
                 $place->addChild('name', $p->getName());
                 $place->addChild('description', $p->getDesc());
                 $place->addChild('styleUrl', $p->getStyle());
                 // Add coordinates information
                 $point = $place->addChild('Point');
                 $point->addChild('coordinates', $p->getCoords());
             }
         }
     }
     // Set all the root placemarks so they are not in a folder
     foreach ($this->folders['**[root]**'] as $p) {
         // Add all the placemark details
         $place = $folder->addChild('Placemark');
         $place->addAttribute('id', $p->getId());
         $place->addChild('name', $p->getName());
         $place->addChild('description', $p->getDesc());
         $place->addChild('styleUrl', $p->getStyle());
         // Add coordinates information
         $point = $place->addChild('Point');
         $point->addChild('coordinates', $p->getCoords());
     }
     // Put the xml into a string
     $kml = $sxe->asXML();
     // Kill $sxe to save memory
     $sxe = null;
     // Check that xml was returned
     if ($kml != false) {
         // Return the xml
         return $xml_head . $kml;
     }
 }
Example #7
0
 $colorImgUrls = $colorInfo['colorImgUrls'];
 //没有颜色
 if (count($colorNames) == 0) {
     $productXml = $xml->addchild("product");
     $idXml = $productXml->addAttribute("id", $index);
     $materialTypeXml = $productXml->addchild("materialType", $materialType);
     $matherialSubTypeXml = $productXml->addchild("matherialSubType", "");
     $brandXml = $productXml->addchild("brand", "");
     $producerXml = $productXml->addchild("producer", $producer);
     $ingredientXml = $productXml->addchild("ingredient", "");
     $priceXml = $productXml->addchild("price", $price);
     $priceUnit = $productXml->addChild("priceUnit", $priceUnit);
     $diameterXml = $productXml->addchild("diameter", $diameter);
     $diameterUnit = $productXml->addchild("diameterUnit", $diameterUnit);
     $colorXml = $productXml->addchild("color", '');
     $colorImgUrlXml = $productXml->addchild("colorImgUrl", '');
     $weightXml = $productXml->addchild("weight", $weight);
     $weightUnit = $productXml->addchild("weightUnit", $weightUnit);
     $packFormXml = $productXml->addchild("packForm", $packForm);
     $weightInKgXml = $productXml->addchild("weightInKg", $weightInKg);
     $imageUrlXml = $productXml->addchild("imageUrl", $imageUrl);
     $urlXml = $productXml->addchild("url", $url);
     $descriptionXml = $productXml->addchild("description", $description);
     $sellerXml = $productXml->addchild("seller", "Lulzbot");
     $sellerWebXml = $productXml->addchild("sellerWeb", "Lulzbot.com");
     $index++;
 } else {
     for ($i = 0; $i < count($colorNames); $i++) {
         $productXml = $xml->addchild("product");
         $idXml = $productXml->addAttribute("id", $index);
         $materialTypeXml = $productXml->addchild("materialType", $materialType);
         $matherialSubTypeXml = $productXml->addchild("matherialSubType", "");
Example #8
0
<?php

$srcxml = simplexml_load_string($HTTP_RAW_POST_DATA);
$card = $srcxml->QRY['CardCode'];
$xml = simplexml_load_file('in.xml');
$findcard = false;
$funcname = 'GetCardImageEx';
foreach ($xml->children() as $child) {
    if ($child->getName() == $funcname and $child["CardCode"] == (string) $card) {
        $imagesrc = 'images/' . $child["FileName"];
        $findcard = true;
        break;
    }
}
if ($findcard == true and file_exists($imagesrc)) {
    header('Content-Type: image/jpg');
    readfile($imagesrc);
    die;
} else {
    $findcard = false;
}
if ($findcard == false) {
    $newxml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><Root></Root>');
    $newxml->addchild($funcname);
    $newxml->{$funcname}->addattribute('ErrorText', 'Card or image not found');
    header('Content-Type: text/xml');
    echo $newxml->asXML();
}
Example #9
0
<?php

try {
    while (true) {
        sleep(10);
        $conn = new MongoClient();
        $db = $conn->selectDB('bilibili');
        $collection = new MongoCollection($db, 'videos');
        $cursor = $collection->find()->sort(array('aid' => -1))->limit(500);
        $arr = $cursor;
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><document />');
        $xml->addchild("webSite", "v.dingxiaoyue.com");
        $xml->addchild("webMaster", "wsc449@qq.com");
        $xml->addchild("updatePeri", "60");
        foreach ($cursor as $doc) {
            $item = $xml->addchild("item");
            $item->addchild("op", "add");
            $item->addchild("title", $doc["title"]);
            $item->addchild("category", $doc["typename"]);
            $item->addchild("playLink", 'http://v.dingxiaoyue.com/view/' . $doc["aid"]);
            $item->addchild("imageLink", $doc["pic"]);
            $item->addchild("comment", addslashes($doc["description"]));
            $item->addchild("pubDate", $doc["created_at"]);
        }
        $xml->asXml("public/video.xml");
        $content = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">';
        foreach ($arr as $doc) {
            $content .= "<url>\n";
            $content .= "<loc>" . 'http://v.dingxiaoyue.com/view/' . $doc["aid"] . "</loc>\n";
            $content .= "<video:video>";
            $content .= "<video:thumbnail_loc>" . $doc["pic"] . "</video:thumbnail_loc>\n";
Example #10
0
 /**
  *
  * This function set the xml to request rate
  * @param $productId
  * @param $checkinDate
  * @param $checkoutDate
  */
 function buildRateRequest($productId, $checkinDate, $checkoutDate)
 {
     $data = new SimpleXMLElement('<Data></Data>');
     $data->addChild("type", $this->productType);
     $data->addChild("method", "rates");
     $data->addChild("product_id", $productId);
     $data->addChild("checkin_date", $this->helper->setDateFormatToService($checkinDate));
     $data->addChild("checkout_date", $this->helper->setDateFormatToService($checkoutDate));
     //Set the currency id
     $currency = 0;
     if (isset($_SESSION["currentCurrency"]) && $_SESSION["currentCurrency"] != "") {
         $currency = $_SESSION["currentCurrency"];
     }
     $data->addchild("currency", $currency);
     return $data;
 }
function external_comments_saveconf()
{
    global $external_comments_conf;
    $configfile = GSDATAOTHERPATH . 'external_comments.xml';
    $xml_root = new SimpleXMLElement('<settings></settings>');
    $xml_root->addchild('provider', $external_comments_conf['provider']);
    $xml_root->addchild('developer', $external_comments_conf['developer']);
    $xml_root->addchild('shortname', $external_comments_conf['shortname']);
    if ($xml_root->asXML($configfile) === FALSE) {
        exit(i18n_r('external_comments/MSG_SAVEERROR') . ' ' . $configfile . ', ' . i18n_r('external_comments/MSG_CHECKPRIV'));
    }
}
Example #12
0
function simplecache_saveconf()
{
    global $simplecache_conf;
    $configfile = GSDATAOTHERPATH . 'simplecache.xml';
    $xml_root = new SimpleXMLElement('<simplecachesettings></simplecachesettings>');
    $xml_root->addchild('enabled', $simplecache_conf['enabled']);
    $xml_root->addchild('ttl', $simplecache_conf['ttl']);
    $nocache = $xml_root->addchild('nocache');
    foreach ($simplecache_conf['nocache'] as $slug) {
        $nocache->addchild('slug', $slug);
    }
    if ($xml_root->asXML($configfile) === FALSE) {
        exit('Unable to save ' . $configfile . ', check GetSimple privileges.');
    }
}
Example #13
0
function simpletumblr_saveconf()
{
    global $simpletumblr_conf;
    $configfile = GSDATAOTHERPATH . 'simpletumblr.xml';
    $xml_root = new SimpleXMLElement('<settings></settings>');
    $xml_root->addchild('name', $simpletumblr_conf['name']);
    $xml_root->addchild('count', $simpletumblr_conf['count']);
    $xml_root->addchild('imagesize', $simpletumblr_conf['imagesize']);
    $xml_root->addchild('type', $simpletumblr_conf['type']);
    if ($xml_root->asXML($configfile) === FALSE) {
        exit('Error saving ' . $configfile . ', check folder privlidges.');
    }
}