Esempio n. 1
0
 function __construct($gmlSource)
 {
     parent::__construct();
     include_once "libs/class_xml_check.php";
     $check = new XML_check();
     if ($check->check_string($gmlSource)) {
         print "GML is well-formed\n";
         //print("Elements      : ".$check->get_xml_elements());
         //print("Attributes    : ".$check->get_xml_attributes());
         //print("Size          : ".$check->get_xml_size());
         //print("Text sections : ".$check->get_xml_text_sections());
         //print("Text size     : ".$check->get_xml_text_size());
     } else {
         print "GML is not well-formed. ";
         print $check->get_full_error() . "\n";
         print "Script terminated\n";
         die;
     }
     $this->gmlSource = $gmlSource;
     $this->gmlCon = new gmlConverter();
     require_once "XML/Unserializer.php";
     $unserializer_options = array('parseAttributes' => TRUE);
     $unserializer = new XML_Unserializer($unserializer_options);
     // Serialize the data structure
     $status = $unserializer->unserialize($this->gmlSource);
     $this->gmlArray = $unserializer->getUnserializedData();
     print date('l jS \\of F Y h:i:s A') . " GML serialized\n";
     // Check if XML is a ServiceException
     if ($unserializer->getRootName() == "ServiceExceptionReport") {
         print "The server returned an exception:\n";
         print $this->gmlSource . "\n";
         print "Script terminated\n";
         die;
     }
 }
Esempio n. 2
0
 function fetchData($username, $password)
 {
     switch ($this->options['cryptType']) {
         case 'blowfish':
             include_once 'Crypt/Blowfish.php';
             $bf = new Crypt_Blowfish($this->options['cryptKey']);
             $password = $bf->encrypt($password);
             $password = base64_encode($password);
             break;
         default:
             if (function_exists($this->options['cryptType'])) {
                 $password = $this->options['cryptType']($password);
             }
             break;
     }
     $req = new HTTP_Request();
     $req->setURL($this->options['URL']);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     $req->addQueryString($this->options['usernameKey'], $username);
     $req->addQueryString($this->options['passwordKey'], $password);
     if (!PEAR::isError($req->sendRequest())) {
         $response = $req->getResponseBody();
     } else {
         return false;
     }
     $unserializer = new XML_Unserializer();
     if ($unserializer->unserialize($response)) {
         $this->result_value = $unserializer->getUnserializedData();
         if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
             return true;
         }
     }
     return false;
 }
 /**
  * Test extracting the root name
  */
 public function testRootName()
 {
     $u = new XML_Unserializer();
     $xml = '<xml>data</xml>';
     $u->unserialize($xml);
     $this->assertEquals('xml', $u->getRootName());
 }
function _loadAcronymList()
{
    $unser = new XML_Unserializer(array('parseAttributes' => TRUE, 'attributesArray' => '_attrs'));
    $unser->unserialize(PATH_INCLUDE . "xslt/inc/acronyms.xml", true);
    $dat = $unser->getUnserializedData();
    return $dat['word'];
}
 protected function read($filename)
 {
     $xml = file_get_contents($filename);
     $unserializer = new XML_Unserializer();
     $unserializer->unserialize($xml);
     return $unserializer->getUnserializedData();
 }
 /**
  * Test unserializing an indexed array
  */
 public function testIndexed()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'array');
     $xml = '<xml><foo>bar</foo><foo>tomato</foo></xml>';
     $u->unserialize($xml);
     $this->assertEquals(array('foo' => array('bar', 'tomato')), $u->getUnserializedData());
 }
Esempio n. 7
0
 function readData()
 {
     require_once 'XML/Unserializer.php';
     $xmlEngine = new XML_Unserializer();
     if ($xmlEngine->unserialize($this->getFile())) {
         return $xmlEngine->getUnserializedData();
     }
     return false;
 }
 /**
  * Test unserializing from UTF-8 to ISO-8859-1
  */
 public function testUtf8ToIso()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_SOURCE, 'UTF-8');
     $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_TARGET, 'ISO-8859-1');
     $xml = '<xml>' . utf8_encode('A string containing ü ä Ãê') . '</xml>';
     $u->unserialize($xml);
     $this->assertEquals('A string containing ü ä Ãê', $u->getUnserializedData());
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_reserved_driver_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $options = array('complexType' => 'array', 'parseAttributes' => TRUE);
     $Unserializer = new XML_Unserializer($options);
     //$Unserializer->setOption('parseAttributes', TRUE);
     $status = $Unserializer->unserialize($b->getResponseText());
     $this->list = $Unserializer->getUnserializedData();
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new sfForm();
     //xmlを連想配列に変換
     $options = array('complexType' => 'array');
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('m_id')));
     $Unserializer = new XML_Unserializer($options);
     $status = $Unserializer->unserialize($b->getResponseText());
     $this->profile = $Unserializer->getUnserializedData();
 }
 /**
  * Unpack definition procedure
  *
  * @return array
  * @author Sergey Startsev
  */
 protected function doUnpack($definition)
 {
     $unserializer = new XML_Unserializer($this->unserialize_options);
     // check unserialize status
     $status = $unserializer->unserialize(trim($definition), false);
     if (!$status) {
         throw new afsXmlDefinitionException($status->getMessage());
     }
     // get unserialized data
     return $unserializer->getUnserializedData();
 }
 /**
  * Test unserializing with a setter method
  */
 public function testSetterMethod()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
     $u->setOption(XML_UNSERIALIZER_OPTION_DEFAULT_CLASS, 'Foo');
     $xml = '<SetterExample><foo>tomato</foo></SetterExample>';
     $u->unserialize($xml);
     $result = new SetterExample();
     $result->setFoo('tomato');
     $this->assertEquals($result, $u->getUnserializedData());
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $b = new sfWebBrowser();
     $b->get(sfConfig::get('sf_takutomo_get_attend_event_url'), array('guid' => 'DEBUG,sample_member_001'));
     //xmlを連想配列に変換
     $options = array('complexType' => 'array');
     $Unserializer = new XML_Unserializer($options);
     $status = $Unserializer->unserialize($b->getResponseText());
     //if ($status === true) {
     $this->get_attend_event_list = $Unserializer->getUnserializedData();
 }
 private function setEventDetail()
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_event_detail_url'), array('event_id' => $this->getRequestParameter('event_id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $Unserializer = new XML_Unserializer($this->options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->event_detail = $Unserializer->getUnserializedData();
     }
 }
Esempio n. 15
0
function randomPerson()
{
    $dir = 'collectedData';
    $files = glob($dir . '/*.*');
    $file = array_rand($files);
    $us = new XML_Unserializer();
    $options = array(XML_UNSERIALIZER_OPTION_TAG_MAP => array('util' => 'XML_Util'), XML_UNSERIALIZER_OPTION_ATTRIBUTE_CLASS => '_classname');
    $us->setOptions($options);
    $us->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
    $result = $us->unserialize($files[$file], true);
    return $us->_unserializedData;
}
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     //$mixi_persistence = $persistence->entry->{'mixi.jp:'.MixiAppMobileApi::$ownerId};
     $b = new sfWebBrowser();
     $b->get(sfConfig::get('sf_takutomo_get_attend_event_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     //xmlを連想配列に変換
     $options = array('complexType' => 'array');
     $Unserializer = new XML_Unserializer($options);
     $status = $Unserializer->unserialize($b->getResponseText());
     //if ($status === true) {
     $this->get_attend_event_list = $Unserializer->getUnserializedData();
 }
Esempio n. 17
0
 /**
  * 
  * @param string $xml
  * @return array
  */
 public static function unserialize($xml)
 {
     if ($xml instanceof ZendT_Type) {
         $xml = $xml->get();
     }
     $unserializer = new XML_Unserializer();
     $status = $unserializer->unserialize($xml);
     if ($status) {
         $array = $unserializer->getUnserializedData();
     }
     return $array;
 }
 /**
  * 相乗りリストを返す 
  * errorの場合 null
  */
 private function getAttendEventList()
 {
     $b = new sfWebBrowser();
     $b->get(sfConfig::get('sf_takutomo_get_attend_event_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     //xmlを連想配列に変換
     $options = array('complexType' => 'array');
     $Unserializer = new XML_Unserializer($options);
     $status = $Unserializer->unserialize($b->getResponseText());
     if ($status === true) {
         return $Unserializer->getUnserializedData();
     } else {
         return null;
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         //xmlを連想配列に変換
         $options = array('complexType' => 'array');
         $Unserializer = new XML_Unserializer($options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->member = $Unserializer->getUnserializedData();
     }
 }
Esempio n. 20
0
 function readData()
 {
     require_once 'XML/Unserializer.php';
     $xmlEngine = new XML_Unserializer();
     $file_data = $this->getFile();
     if (!$file_data) {
         return false;
     }
     $status = $xmlEngine->unserialize($file_data);
     if (!PEAR::isError($status)) {
         return $xmlEngine->getUnserializedData();
     }
     trigger_error($status->getMessage());
     return false;
 }
    /**
     * Test keep behaviour
     */
    public function testKeep()
    {
        $u = new XML_Unserializer();
        $u->setOption(XML_UNSERIALIZER_OPTION_WHITESPACE, XML_UNSERIALIZER_WHITESPACE_KEEP);
        $u->unserialize($this->xml);
        $expected = array('string' => '

    This XML
    document
    contains
    line breaks.

   ');
        $this->assertEquals($expected, $u->getUnserializedData());
    }
 private function getProFileMySelf()
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_myself_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $xml = new SimpleXMLElement($b->getResponseText());
     $this->profileForm = new sfForm();
     if ((int) $xml->status->code >= 1000) {
         $this->profileForm->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $options = array('complexType' => 'array');
         $Unserializer = new XML_Unserializer($options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->profile = $Unserializer->getUnserializedData();
     }
 }
 public static function Decode($XMLResponse, &$isFault)
 {
     $responseXML = null;
     try {
         if (empty($XMLResponse)) {
             throw new Exception("Given Response is not a valid SOAP response.");
         }
         $xmlDoc = new XMLReader();
         $res = $xmlDoc->XML($XMLResponse);
         if ($res) {
             $xmlDoc->read();
             $responseXML = $xmlDoc->readOuterXml();
             $xmlDOM = new DOMDocument();
             $xmlDOM->loadXML($responseXML);
             $isFault = trim(strtoupper($xmlDoc->localName)) == self::$FaultMessage;
             if ($isFault) {
                 $xmlDOM->loadXML($xmlDoc->readOuterXml());
             }
             switch ($xmlDoc->nodeType) {
                 case XMLReader::ELEMENT:
                     $nodeName = $xmlDoc->localName;
                     $prefix = $xmlDoc->prefix;
                     if (class_exists($nodeName)) {
                         $xmlNodes = $xmlDOM->getElementsByTagName($nodeName);
                         foreach ($xmlNodes as $xmlNode) {
                             //$xmlNode->prefix = "";
                             $xmlNode->setAttribute("_class", $nodeName);
                             $xmlNode->setAttribute("_type", "object");
                         }
                     }
                     break;
             }
             $responseXML = $xmlDOM->saveXML();
             $unserializer = new XML_Unserializer();
             $unserializer->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
             $res = $unserializer->unserialize($responseXML, false);
             if ($res) {
                 $responseXML = $unserializer->getUnserializedData();
             }
             $xmlDoc->close();
         } else {
             throw new Exception("Given Response is not a valid XML response.");
         }
     } catch (Exception $ex) {
         throw new Exception("Error occurred while XML decoding");
     }
     return $responseXML;
 }
Esempio n. 24
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $configArray;
     global $interface;
     // Load SOLR Statistics
     if ($configArray['Index']['engine'] == 'Solr') {
         $xml = @file_get_contents($configArray['Index']['url'] . '/admin/multicore');
         if ($xml) {
             $options = array('parseAttributes' => 'true', 'keyAttribute' => 'name');
             $unxml = new XML_Unserializer($options);
             $unxml->unserialize($xml);
             $data = $unxml->getUnserializedData();
             $interface->assign('data', $data['status']);
         }
     }
     $interface->setTemplate('home.tpl');
     $interface->setPageTitle('Home');
     $interface->display('layout-admin.tpl');
 }
function getEval($id)
{
    $result = null;
    $b = new sfWebBrowser();
    $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $id));
    $xml = new SimpleXMLElement($b->getResponseText());
    if ((int) $xml->status->code >= 1000) {
        return null;
    } else {
        //xmlを連想配列に変換
        $options = array('complexType' => 'array');
        $Unserializer = new XML_Unserializer($options);
        $status = $Unserializer->unserialize($b->getResponseText());
        if ($status) {
            $member = $Unserializer->getUnserializedData();
            return createStars(calculateEvaluate($member));
        }
        return null;
    }
}
Esempio n. 26
0
/**
 * Purpose:   
 * Function name: GetPageInfo
 * Parameters:
 */
function GetPageInfo($PageID, $Language)
{
    $_Result = array("CAPTIONS" => array());
    // Read XML language file
    $_LanguageFile = $_SERVER["DOCUMENT_ROOT"] . "/languages/" . $Language . ".xml";
    if (file_exists($_LanguageFile)) {
        $_XML = new XML_Unserializer(array("complexType" => "array", "parseAttributes" => TRUE));
        $_XML->unserialize($_LanguageFile, TRUE);
        $_Data = $_XML->getUnserializedData();
        $_Pages = $_Data["pages"];
        // Get page data
        $_Page = array();
        if (!is_array($_Pages["page"][0])) {
            if ($_Pages["page"]["name"] == $PageID) {
                $_Page = $_Pages["page"];
            }
        } else {
            $i = 0;
            $_Length = count($_Pages["page"]);
            while ($_Pages["page"][$i]["name"] != $PageID && $i < $_Length) {
                $i++;
            }
            if ($i < $_Length) {
                $_Page = $_Pages["page"][$i];
            }
        }
        // Get title data
        $_Result["TITLE"] = $_Page["title"];
        // Get caption data
        $_Captions = $_Page["captions"];
        if (!is_array($_Captions["caption"][0])) {
            $_Result["CAPTIONS"][$_Captions["caption"]["name"]] = $_Captions["caption"]["value"];
        } else {
            for ($i = 0; $i < count($_Captions["caption"]); $i++) {
                $_Result["CAPTIONS"][$_Captions["caption"][$i]["name"]] = $_Captions["caption"][$i]["value"];
            }
        }
    }
    // Return data
    return $_Result;
}
Esempio n. 27
0
 public function getInitUrl($returnUrl, $cancelUrl, $sale = true)
 {
     $router = ActiveRecordModel::getApplication()->getRouter();
     $completeUrl = $router->createFullUrl($router->createUrl(array('controller' => 'checkout', 'action' => 'completeExternal', 'id' => $this->order->getID())));
     $handler = $this->getHandler($cancelUrl, $completeUrl);
     $sandbox = $this->getConfigValue('sandbox') ? 'sandbox.' : '';
     $url = $sandbox ? 'https://sandbox.google.com/checkout/api/checkout/v2/merchantCheckout/Merchant/' : 'https://checkout.google.com/api/checkout/v2/merchantCheckout/Merchant/';
     $parsed = new XML_Unserializer();
     $cart = $handler->getCart();
     if (($response = $handler->_getCurlResponse($cart, $url . $this->getConfigValue('merchant_id'))) && $parsed->unserialize($response)) {
         $array = $parsed->getUnserializedData();
         if (empty($array['redirect-url'])) {
             return false;
         }
         $url = $array['redirect-url'];
         $url = str_replace('shoppingcartshoppingcart', 'shoppingcart&shoppingcart', $url);
         return $url;
     } else {
         return false;
     }
 }
Esempio n. 28
0
 function xml2array()
 {
     //converte dati xml in un array
     /**
      * uses PEAR error management
      */
     require_once 'PEAR.php';
     /**
      * uses XML_Parser to unserialize document
      */
     require_once "XML/Parser.php";
     /**
      * uses unserializer 
      */
     require_once "XML/Unserializer.php";
     $xml_data = $this->xml_data;
     $unserializer = new XML_Unserializer();
     $unserializer->unserialize($xml_data);
     $data = $unserializer->getUnserializedData();
     $this->data = $data;
 }
Esempio n. 29
0
 /**
  * execute処理
  *
  * @access  public
  */
 function execute()
 {
     $this->search_result = $this->session->getParameter(array("search_result", $this->block_id, $this->target_module));
     if (!isset($this->search_result)) {
         $this->search_result = array("module_id" => $this->module_obj['module_id'], "offset" => 0, "limit" => SEARCH_DEF_FIRST_LIMIT);
         $this->session->setParameter(array("search_result", $this->block_id, $this->target_module), $this->search_result);
     }
     $this->search_select = $this->session->getParameter(array("search_select", $this->block_id));
     $params = array("block_id" => $this->block_id, "keyword" => $this->search_select["keyword"], "select_kind" => $this->search_select["select_kind"], "handle" => $this->search_select["handle"], "fm_target_date" => $this->search_select["fm_target_date"], "to_target_date" => $this->search_select["to_target_date"], "target_module" => $this->search_result["module_id"], "target_room" => isset($this->search_result["room_id"]) ? $this->search_result["room_id"] : null, "offset" => $this->search_result["offset"], "limit" => $this->search_result["limit"], "_header" => _OFF, "_output" => _OFF);
     $xml = $this->preexecute->preExecute($this->module_obj["search_action"], $params);
     $xml = preg_replace("/nc_rss:/iu", "", $xml);
     $options = array(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE => 'parseAttributes');
     $unserializer = new XML_Unserializer($options);
     $unserializer->unserialize($xml);
     $this->xml_parse = $unserializer->getUnserializedData();
     if ($this->search_result["offset"] == 0) {
         $limit = SEARCH_DEF_FIRST_LIMIT;
     } else {
         $limit = SEARCH_DEF_NEXT_LIMIT;
     }
     $this->next_offset = $this->search_result["offset"] + $limit > $this->xml_parse["count"] ? $this->xml_parse["count"] : $this->search_result["offset"] + $limit;
     $this->prev_offset = $this->search_result["offset"] - $limit < 0 ? 0 : $this->search_result["offset"] - $limit;
     return 'success';
 }
Esempio n. 30
0
 /**
  * Get holdings information for the specified record.
  *
  * @param string $id Record to obtain holdings for.
  *
  * @return array
  * @access public
  */
 public function getHoldings($id)
 {
     $this->client->setMethod(HTTP_REQUEST_METHOD_POST);
     $this->client->setURL('http://www.worldcat.org/webservices/catalog/content/libraries/' . $id);
     $this->client->addRawQueryString("wskey={$this->_wskey}&servicelevel=full");
     if ($this->debug) {
         echo '<pre>Connect: ';
         print_r($this->client->getUrl(true));
         echo "</pre>\n";
     }
     $result = $this->client->sendRequest();
     if (!PEAR::isError($result)) {
         $xml = $this->client->getResponseBody();
         $unxml = new XML_Unserializer();
         $result = $unxml->unserialize($xml);
         if (!PEAR::isError($result)) {
             return $unxml->getUnserializedData();
         } else {
             PEAR::raiseError($result);
         }
     } else {
         return $result;
     }
 }