Example #1
0
 public function testParseWithIntegerIndexedArray()
 {
     $testXml = simplexml_load_file('./tests/raw/test_feed.xml');
     $parser = new XmlParser($testXml);
     $results = $parser->parse();
     $this->assertTrue(isset($results['rss']['channel']));
 }
 /**
  * @brief 위젯의 실행 부분
  *
  * ./widgets/위젯/conf/info.xml 에 선언한 extra_vars를 args로 받는다
  * 결과를 만든후 print가 아니라 return 해주어야 한다
  **/
 function proc($args)
 {
     // 위젯 자체적으로 설정한 변수들을 체크
     $title = $args->title;
     $PAGE_LIMIT = $args->page_limit ? $args->page_limit : 10;
     // 날짜 형태
     $DATE_FORMAT = $args->date_format ? $args->date_format : "Y-m-d H:i:s";
     $buff = $this->rss_request($args->rss_url);
     if (!is_string($buff) or !$buff) {
         return Context::getLang('msg_fail_to_request_open');
     }
     $encoding = preg_match("/<\\?xml.*encoding=\"(.+)\".*\\?>/i", $buff, $matches);
     if ($encoding && !preg_match("/UTF-8/i", $matches[1])) {
         $buff = trim(iconv($matches[1] == "ks_c_5601-1987" ? "EUC-KR" : $matches[1], "UTF-8", $buff));
     }
     $buff = preg_replace("/<\\?xml.*\\?>/i", "", $buff);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse($buff);
     $rss->title = $xml_doc->rss->channel->title->body;
     $rss->link = $xml_doc->rss->channel->link->body;
     $items = $xml_doc->rss->channel->item;
     if (!$items) {
         return Context::getLang('msg_invalid_format');
     }
     if ($items && !is_array($items)) {
         $items = array($items);
     }
     $rss_list = array();
     foreach ($items as $key => $value) {
         if ($key >= $PAGE_LIMIT) {
             break;
         }
         unset($item);
         foreach ($value as $key2 => $value2) {
             if (is_array($value2)) {
                 $value2 = array_shift($value2);
             }
             $item->{$key2} = $value2->body;
         }
         $date = $item->pubdate;
         $item->date = $date ? date($DATE_FORMAT, strtotime($date)) : '';
         $array_date[$key] = strtotime($date);
         $item->description = preg_replace('!<a href=!is', '<a onclick="window.open(this.href);return false" href=', $item->description);
         $rss_list[$key] = $item;
     }
     array_multisort($array_date, SORT_DESC, $rss_list);
     $widget_info->rss = $rss;
     $widget_info->rss_list = $rss_list;
     $widget_info->title = $title;
     $widget_info->rss_height = $args->rss_height ? $args->rss_height : 200;
     $widget_info->subject_cut_size = $args->subject_cut_size;
     Context::set('widget_info', $widget_info);
     // 템플릿의 스킨 경로를 지정 (skin, colorset에 따른 값을 설정)
     $tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
     Context::set('colorset', $args->colorset);
     // 템플릿 컴파일
     $oTemplate =& TemplateHandler::getInstance();
     $output = $oTemplate->compile($tpl_path, 'list');
     return $output;
 }
 /**
  *  Block Send XML order to Moulton
  *  @author Oleg D.
  */
 function send_order()
 {
     $result = array();
     $xml_order = $this->build_order_xml();
     $xml_order = preg_replace("/(\\s+)?(\\<.+\\>)(\\s+)?/", "\$2", $xml_order);
     $xml_order = str_replace('&', '&amp;', $xml_order);
     echo $xml_order;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_order);
     if ($this->testing) {
         curl_setopt($ch, CURLOPT_URL, $this->send_order_url_test);
     } else {
         curl_setopt($ch, CURLOPT_URL, $this->send_order_url);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
     $moulton_answer = curl_exec($ch);
     curl_close($ch);
     include 'xmlparser.class.php';
     $Parser = new XmlParser();
     $result = $Parser->xml2array($moulton_answer);
     return $result;
 }
Example #4
0
 function init()
 {
     // forbit access if the user is not an administrator
     if (!$this->grant->manager && !$this->grant->is_admin) {
         return $this->stop("msg_is_not_administrator");
     }
     // change into administration layout
     //$this->setTemplatePath('./modules/cympusadmin/tpl');
     $this->setLayoutPath('./modules/cympusadmin/tpl');
     $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
     Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/');
     if ($this->grant->is_admin) {
         // parse admin menu
         $oXmlParser = new XmlParser();
         $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
         $admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
         Context::set('cympusadmin_menu', $admin_menu);
     } else {
         $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu);
         if (!$output->toBool()) {
             return $output;
         }
         Context::set('cympusadmin_menu', $manager_menu);
     }
     $news = getNewsFromAgency();
     Context::set('news', $news);
     Context::set('admin_bar', 'false');
     $oModuleModel =& getModel('module');
     $module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
     Context::set('cympus_modinfo', $module_info);
     return new Object();
 }
Example #5
0
 /**
  * check easy install
  * @return void
  */
 function checkEasyinstall()
 {
     $lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile);
     if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) {
         return;
     }
     $oAutoinstallModel = getModel('autoinstall');
     $params = array();
     $params["act"] = "getResourceapiLastupdate";
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     $xml_lUpdate = new XmlParser();
     $lUpdateDoc = $xml_lUpdate->parse($buff);
     $updateDate = $lUpdateDoc->response->updatedate->body;
     if (!$updateDate) {
         $this->_markingCheckEasyinstall();
         return;
     }
     $item = $oAutoinstallModel->getLatestPackage();
     if (!$item || $item->updatedate < $updateDate) {
         $oController = getAdminController('autoinstall');
         $oController->_updateinfo();
     }
     $this->_markingCheckEasyinstall();
 }
Example #6
0
function getNewsFromAgency()
{
    //Retrieve recent news and set them into context
    $newest_news_url = sprintf("http://www.xeshoppingmall.com/?module=newsagency&act=getNewsagencyArticle&inst=notice&top=6&loc=%s", _XE_LOCATION_);
    $cache_file = sprintf("%sfiles/cache/nstore_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
    if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) {
        // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page
        // Ensure to access the textmessageistration page even though news cannot be displayed
        FileHandler::writeFile($cache_file, '');
        FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl('')));
    }
    if (file_exists($cache_file)) {
        $oXml = new XmlParser();
        $buff = $oXml->parse(FileHandler::readFile($cache_file));
        $item = $buff->zbxe_news->item;
        if ($item) {
            if (!is_array($item)) {
                $item = array($item);
            }
            foreach ($item as $key => $val) {
                $obj = null;
                $obj->title = $val->body;
                $obj->date = $val->attrs->date;
                $obj->url = $val->attrs->url;
                $news[] = $obj;
            }
            return $news;
        }
    }
}
Example #7
0
 function init()
 {
     // forbit access if the user is not an administrator
     $oMemberModel =& getModel('member');
     $logged_info = $oMemberModel->getLoggedInfo();
     if ($logged_info->is_admin != 'Y') {
         return $this->stop("msg_is_not_administrator");
     }
     // change into administration layout
     //$this->setTemplatePath('./modules/cympusadmin/tpl');
     $this->setLayoutPath('./modules/cympusadmin/tpl');
     $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
     // parse admin menu
     $act = Context::get('act');
     $oXmlParser = new XmlParser();
     $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
     $admin_menu = array();
     $admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
     Context::set('cympusadmin_menu', $admin_menu);
     $oModuleModel =& getModel('module');
     $module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
     Context::set('cympus_modinfo', $module_info);
     $news = getNewsFromAgency();
     Context::set('news', $news);
     Context::set('admin_bar', 'false');
 }
 /**
  * get logs of the log file
  * @param $type string of log direcroty, like store
  * @param $logFile - log files name like 12.27.2009.xml
  * @param $userID
  * @author Oleg D.
  */
 function getLogs($type, $logFile, $userID = null)
 {
     $logFile .= '.xml';
     $date = explode('.', $logFile);
     $year = $date[2];
     $month = $date[0];
     App::import('Vendor', 'XmlParser', array('file' => 'xmlparser.class.php'));
     $XmlParser = new XmlParser();
     $file = file_get_contents(ROOT . DS . 'app' . DS . 'logs' . DS . $type . DS . $year . DS . $month . DS . $logFile);
     $file = str_replace('&', 'and', $file);
     if (!$file) {
         echo 'file error';
         exit;
     }
     $file = '<All>' . $file . '</All>';
     $logsParse = $XmlParser->xml2array($file);
     $logs = array();
     if (isset($logsParse['All']['Log'])) {
         $logs = $logsParse['All']['Log'];
     }
     if ($userID) {
         $myLogs = array();
         foreach ($logs as $log) {
             if ($log['Uid'] == $userID) {
                 $myLogs[] = $log;
             }
         }
     } else {
         $myLogs = $logs;
     }
     $myLogs = array_reverse($myLogs);
     //echo "<pre>";
     //print_r($myLogs);
     return $myLogs;
 }
Example #9
0
 function getLicenseFromAgency($prodid, &$has_license = TRUE, &$expiration = NULL)
 {
     $has_license = TRUE;
     $oLicenseModel =& getModel('license');
     $config = $oLicenseModel->getModuleConfig();
     if ($prodid == 'nstore') {
         $user_id = $config->user_id;
         $serial_number = $config->serial_number;
     } else {
         if ($prodid == 'nstore_digital') {
             $user_id = $config->d_user_id;
             $serial_number = $config->d_serial_number;
         } else {
             $user_id = $config->e_user_id;
             $serial_number = $config->e_serial_number;
         }
     }
     $cache_file = $this->checkLicense($prodid, $user_id, $serial_number);
     if (file_exists($cache_file)) {
         $oXml = new XmlParser();
         $buff = $oXml->parse(FileHandler::readFile($cache_file));
         // user
         $userObj = $buff->drm->user;
         if ($userObj) {
             $user = $userObj->body;
             if ($user != $user_id) {
                 $this->checkLicense($prodid, $user_id, $serial_number, TRUE);
                 return TRUE;
             }
         }
         // serial
         $serialObj = $buff->drm->serial;
         if ($serialObj) {
             $serial = $serialObj->body;
             if ($serial != $serial_number) {
                 $this->checkLicense($prodid, $user_id, $serial_number, TRUE);
                 return TRUE;
             }
         }
         // license
         $licenseObj = $buff->drm->license;
         if ($licenseObj) {
             $license = $licenseObj->body;
             if ($license == 'none') {
                 $url = getUrl('act', 'dispLicenseAdminConfig');
                 Context::set(sprintf('%s_MESSAGE_TYPE', strtoupper($prodid)), 'error');
                 Context::set(sprintf('%s_MESSAGE', strtoupper($prodid)), Context::getLang('not_registered'));
                 $has_license = FALSE;
             }
         }
         // expiration
         $expirationObj = $buff->drm->expiration;
         if ($expirationObj) {
             $expiration = $expirationObj->body;
         }
     }
     return FALSE;
 }
Example #10
0
 /**
  * Load a xml file specified by a filename and parse it to Return the resultant data object
  * @param string $filename a file path of file
  * @return array Returns a data object containing data extracted from a xml file or NULL if a specified file does not exist
  */
 function loadXmlFile($filename)
 {
     if (!file_exists($filename)) {
         return;
     }
     $buff = FileHandler::readFile($filename);
     $oXmlParser = new XmlParser();
     return $oXmlParser->parse($buff);
 }
Example #11
0
 public static function decompressFile($file, $destination = NULL)
 {
     if (!is_file($file)) {
         throw new Exception("{$file} is not a regular file");
     }
     $parser = new XmlParser(new Stream(fopen($file, 'rd')));
     //TODO : write a method in this class, ->saveToFile();
     file_put_contents($destination === NULL ? $file : $destination, $parser->getXmlString());
 }
 function _setGrantByWidgetSequence($matches)
 {
     $buff = trim($matches[0]);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse(trim($buff));
     $widget_sequence = $vars->widget_sequence;
     if ($widget_sequence) {
         $_SESSION['magic_content_grant'][$widget_sequence] = true;
     }
 }
Example #13
0
 /**
  * Request data to server and returns result
  *
  * @param array $params Request data
  * @return object
  */
 function getXmlDoc(&$params)
 {
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     if (!$buff) {
         return;
     }
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     return $xmlDoc;
 }
Example #14
0
 /**
  * Request data to server and returns result
  *
  * @param array $params Request data
  * @return object
  */
 function getXmlDoc(&$params)
 {
     $body = XmlGenerater::generate($params);
     $request_config = array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml", array(), array(), array(), $request_config);
     if (!$buff) {
         return;
     }
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     return $xmlDoc;
 }
Example #15
0
 /**
  * @brief naver map open api에서 주소를 찾는 함수
  **/
 function search_address()
 {
     $address = Context::get('address');
     if (!$address) {
         return new Object(-1, 'msg_not_exists_addr');
     }
     Context::loadLang($this->component_path . "lang");
     // 지정된 서버에 요청을 시도한다
     $address = urlencode(iconv("UTF-8", "EUC-KR", $address));
     $query_string = sprintf('/api/geocode.php?key=%s&query=%s', $this->api_key, $address);
     $fp = fsockopen('maps.naver.com', 80, $errno, $errstr);
     if (!$fp) {
         return new Object(-1, 'msg_fail_to_socket_open');
     }
     fputs($fp, "GET {$query_string} HTTP/1.0\r\n");
     fputs($fp, "Host: maps.naver.com\r\n\r\n");
     $buff = '';
     while (!feof($fp)) {
         $str = fgets($fp, 1024);
         if (trim($str) == '') {
             $start = true;
         }
         if ($start) {
             $buff .= trim($str);
         }
     }
     fclose($fp);
     $buff = trim(iconv("EUC-KR", "UTF-8", $buff));
     $buff = str_replace('<?xml version="1.0" encoding="euc-kr" ?>', '', $buff);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse($buff);
     //If a Naver OpenApi Error message exists.
     if ($xml_doc->error->error_code->body || $xml_doc->error->message->body) {
         return new Object(-1, 'NAVER OpenAPI Error' . "\n" . 'Code : ' . $xml_doc->error->error_code->body . "\n" . 'Message : ' . $xml_doc->error->message->body);
     }
     if ($xml_doc->geocode->total->body == 0) {
         return new Object(-1, 'msg_no_result');
     }
     $addrs = $xml_doc->geocode->item;
     if (!is_array($addrs)) {
         $addrs = array($addrs);
     }
     $addrs_count = count($addrs);
     $address_list = array();
     for ($i = 0; $i < $addrs_count; $i++) {
         $item = $addrs[$i];
         $address_list[] = sprintf("%s,%s,%s", $item->point->x->body, $item->point->y->body, $item->address->body);
     }
     $this->add("address_list", implode("\n", $address_list));
 }
Example #16
0
 function init($module = null)
 {
     // change into administration layout
     $config = getModel('cympusadmin')->getConfig();
     $args = new stdClass();
     $args->module = 'cympusadmin';
     $module_list = getModel('module')->getModuleSrlList($args);
     if (!empty($module_list)) {
         foreach ($module_list as $module_info) {
             $cympus_module_info = $module_info;
         }
     }
     $module_path = './modules/cympusadmin/';
     $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin);
     if (!is_dir($template_path) || !$cympus_module_info->skin) {
         $config->admin_skins = 'default';
         $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin);
     }
     if ($module) {
         $module->setLayoutPath($template_path);
         $module->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
     } else {
         $this->setLayoutPath($template_path);
         $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_);
     }
     Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/');
     $logged_info = Context::get('logged_info');
     if ($logged_info->is_admin == 'Y') {
         // parse admin menu
         $oXmlParser = new XmlParser();
         $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_);
         $admin_menu = cympusadmin::getMenu($xml_obj->menu->item);
         Context::set('cympusadmin_menu', $admin_menu);
     } else {
         $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu);
         if (!$output->toBool()) {
             return $output;
         }
         Context::set('cympusadmin_menu', $manager_menu);
     }
     $news = getNewsFromAgency();
     Context::set('news', $news);
     Context::set('admin_bar', 'false');
     $oModuleModel = getModel('module');
     $module_info = $oModuleModel->getModuleInfoXml('cympusadmin');
     Context::set('cympus_modinfo', $module_info);
     return new Object();
 }
Example #17
0
 function parseText($xml)
 {
     $document = parent::parseText($xml);
     $document->getContext()->init($this->documentSize);
     $document->setMaxWidth($document->getContext()->getWidth());
     return $document;
 }
Example #18
0
 /**
  * General armory fetch class
  * Returns XML, HTML or an array of the parsed XML page
  *
  * @param int $type
  * @param string $character
  * @param string $guild
  * @param string $realm
  * @param int $item_id
  * @param string $fetch_type
  * @return array
  */
 function fetchArmory($type = false, $character = false, $guild = false, $realm = false, $item_id = false, $fetch_type = 'array')
 {
     global $roster;
     $url = $this->_makeUrl($type, false, $item_id, $character, $realm, $guild);
     if ($fetch_type == 'html') {
         $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)');
     }
     if ($this->_requestXml($url)) {
         if ($fetch_type == 'array') {
             // parse and return array
             $this->_initXmlParser();
             $this->xmlParser->Parse($this->xml);
             $data = $this->xmlParser->getParsedData();
         } elseif ($fetch_type == 'simpleClass') {
             // parse and return SimpleClass object
             $this->_initSimpleParser();
             $data = $this->simpleParser->parse($this->xml);
         } else {
             // unparsed fetches
             return $this->xml;
         }
         return $data;
     } else {
         trigger_error('RosterArmory:: Failed to fetch ' . $url);
         return false;
     }
 }
 public static function renderUI($action)
 {
     $action->user_id = $action->getUser()->getAppFlowerUser()->getId();
     if (class_exists("GraphUtil")) {
         $setting = GraphUtil::getDefaultSettingByName($action->name);
     }
     $action->id = '';
     $c = new Criteria();
     $c->add(afWidgetSettingPeer::USER, $action->user_id);
     $c->add(afWidgetSettingPeer::NAME, $action->name);
     $obj = afWidgetSettingPeer::doSelectOne($c);
     if ($obj) {
         $action->id = $obj->getId();
         $setting = json_decode($obj->getSetting(), true);
     }
     $varHolder = array();
     if (is_array($setting)) {
         foreach ($setting as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $kk => $vv) {
                     $varHolder[$k . "_" . $kk] = $vv;
                 }
             } else {
                 $varHolder[$k] = $v;
             }
         }
     }
     $action->getVarHolder()->add($varHolder);
     return XmlParser::layoutExt($action);
 }
Example #20
0
 /**
  * Returns table information
  *
  * Used for finding column type info (string/numeric) <br />
  * Obtains the table info from XE's XML schema files
  *
  * @param object $query_id
  * @param bool $table_name
  * @return array
  */
 function getTableInfo($query_id, $table_name)
 {
     $column_type = array();
     $module = '';
     $id_args = explode('.', $query_id);
     if (count($id_args) == 2) {
         $target = 'modules';
         $module = $id_args[0];
         $id = $id_args[1];
     } else {
         if (count($id_args) == 3) {
             $target = $id_args[0];
             $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1);
             if (!isset($targetList[$target])) {
                 return;
             }
             $module = $id_args[1];
             $id = $id_args[2];
         }
     }
     // get column properties from the table
     $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
     if (!file_exists($table_file)) {
         $searched_list = FileHandler::readDir(_XE_PATH_ . 'modules');
         $searched_count = count($searched_list);
         for ($i = 0; $i < $searched_count; $i++) {
             $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name);
             if (file_exists($table_file)) {
                 break;
             }
         }
     }
     if (file_exists($table_file)) {
         $table_xml = FileHandler::readFile($table_file);
         $xml_parser = new XmlParser();
         $table_obj = $xml_parser->parse($table_xml);
         if ($table_obj->table) {
             if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) {
                 $table_obj->table->column = array($table_obj->table->column);
             }
             foreach ($table_obj->table->column as $k => $v) {
                 $column_type[$v->attrs->name] = $v->attrs->type;
             }
         }
     }
     return $column_type;
 }
Example #21
0
 /**
  * Converts XML into an array, respecting namespaces, attributes, and text values.
  *
  * @return array
  */
 public function parse()
 {
     $namespaces = $this->xml->getDocNamespaces();
     $namespaces[''] = null;
     //add base (empty) namespace
     $attributes = $this->getAttributes($namespaces);
     //get child nodes from all namespaces
     $tags = array();
     foreach ($namespaces as $prefix => $namespace) {
         foreach ($this->xml->children($namespace) as $childXml) {
             $new_parser = new XmlParser($childXml, $this->options);
             $child = $new_parser->parse();
             list($childTag, $childProperties) = each($child);
             //add namespace prefix, if any
             if ($prefix) {
                 $childTag = $prefix . $this->namespaceSeparator . $childTag;
             }
             if (!isset($tags[$childTag])) {
                 $alwaysArray = $this->options['alwaysArray'];
                 $autoArray = $this->options['autoArray'];
                 $tags[$childTag] = $childProperties;
                 if (in_array($childTag, $alwaysArray) || !$autoArray) {
                     $tags[$childTag] = [$childProperties];
                 }
             } elseif ($this->isIntegerIndexedArray($tags[$childTag])) {
                 $tags[$childTag][] = $childProperties;
             } else {
                 //key exists so convert to integer indexed array with previous value in position 0
                 $tags[$childTag] = array($tags[$childTag], $childProperties);
             }
         }
     }
     //get text content of node
     $textContent = array();
     $plainText = trim((string) $this->xml);
     if ($plainText !== '') {
         $textContent[$this->options['textContent']] = $plainText;
     }
     //stick it all together
     $properties = $plainText;
     if (!$this->options['autoText'] || $attributes || $tags || $plainText === '') {
         $properties = array_merge($attributes, $tags, $textContent);
     }
     //return node as array
     return array($this->xml->getName() => $properties);
 }
 private function init()
 {
     if (sfContext::getInstance()->has('profiler')) {
         $timer = sfTimerManager::getTimer('afRead');
         // this time will be stopeed inside XmlParser constructor
     }
     $parser = new XmlParser();
     $this->type = $parser->getType();
     $this->layout = $parser->getLayout();
     if (method_exists($this->layout, 'beforeEnd')) {
         $this->layout->beforeEnd();
     }
     if (sfContext::getInstance()->has('profiler')) {
         $timer = sfTimerManager::getTimer('afRender');
         $timer->addTime();
         // this one closes afRender timer that was started inside XmlParser constructor
     }
 }
 public function request($request, $hash_config = NULL, $useSimpleXml)
 {
     $response = Communication::httpRequest($request, $hash_config);
     if ($useSimpleXml) {
         $respObj = simplexml_load_string($response);
     } else {
         $respObj = XmlParser::domParser($response);
     }
     return $respObj;
 }
 protected function layoutExtIfNeeded($actionInstance)
 {
     $viewName = sfView::SUCCESS;
     if (XmlParser::isLayoutStarted()) {
         return $viewName;
     }
     if ($this->isAppFlowerAction($actionInstance)) {
         $viewName = XmlParser::layoutExt($actionInstance);
     }
     return $viewName;
 }
 function editPost($postid, $oDocument, $category = null)
 {
     $oXmlParser = new XmlParser();
     $output = $this->getUsersBlogs();
     if (!$output->toBool()) {
         return $output;
     }
     $this->blogid = $output->get('blogid');
     $input = sprintf('<?xml version="1.0"?>' . '<methodcall>' . '<methodname>blogger.editPost</methodname>' . '<params>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s<string></value></param>' . '<param><value><boolean>1</boolean></value></param>' . '</params>' . '</methodcall>', '0123456789ABCDEF', $postid, $this->user_id, $this->password, str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $oDocument->get('content')));
     $output = $this->_request($this->url, $input, 'application/octet-stream', 'POST');
     $xmlDoc = $oXmlParser->parse($output);
     if (isset($xmlDoc->methodresponse->fault)) {
         $code = $xmlDoc->methodresponse->fault->value->struct->member[0]->value->int->body;
         $message = $xmlDoc->methodresponse->fault->value->struct->member[1]->value->string->body;
         return new Object($code, $message);
     }
     $output = new Object();
     $output->add('postid', $postid);
     return $output;
 }
Example #26
0
 /**
  * Convert a WMS GetCapabilities to Metador data object.
  * @param $xml
  * @param $conf
  * @return array
  */
 public function loadWMS($xml, $conf)
 {
     // read version
     $parser = new XmlParser($xml, new XmlParserFunctions());
     $parser->loadSchema(file_get_contents($conf['wmsimport']['path'] . 'wmsversion.json'));
     $version = $parser->parse();
     unset($parser);
     // read metadata
     $parser = new XmlParser($xml, new XmlParserFunctions());
     switch ($version["version"]) {
         case "1.1.1":
             $parser->loadSchema(file_get_contents($conf['wmsimport']['path'] . 'wms_1-1-1.json'));
             break;
         case "1.3.0":
             $parser->loadSchema(file_get_contents($conf['wmsimport']['path'] . 'wms_1-3-0.json'));
             break;
     }
     $array = $parser->parse();
     return isset($array['p']) ? $array['p'] : array();
 }
Example #27
0
 function SendServer2ServerCart($xml_cart, $die = true)
 {
     list($status, $body) = $this->SendReq($this->merchant_checkout, $this->GetAuthenticationHeaders(), $xml_cart);
     if ($status != 200) {
         return array($status, $body);
     } else {
         ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '.');
         require_once 'xml-processing/xmlparser.php';
         $xml_parser = new XmlParser($body);
         $root = $xml_parser->GetRoot();
         $data = $xml_parser->GetData();
         $this->log->logRequest("Redirecting to: " . $data[$root]['redirect-url']['VALUE']);
         header('Location: ' . $data[$root]['redirect-url']['VALUE']);
         if ($die) {
             die($data[$root]['redirect-url']['VALUE']);
         } else {
             return array(200, $data[$root]['redirect-url']['VALUE']);
         }
     }
 }
Example #28
0
 /**
  * @brief Display Super Admin Dashboard
  **/
 function dispTextmessageAdminIndex()
 {
     $oTextmessageModel = getModel('textmessage');
     $config = $oTextmessageModel->getConfig();
     if (!$config) {
         Context::set('isSetupCompleted', false);
     } else {
         Context::set('isSetupCompleted', true);
     }
     Context::set('config', $config);
     //Retrieve recent news and set them into context
     $newest_news_url = sprintf("http://www.coolsms.co.kr/?module=newsagency&act=getNewsagencyArticle&inst=notice&loc=%s", _XE_LOCATION_);
     $cache_file = sprintf("%sfiles/cache/cool_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
     if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) {
         // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page
         // Ensure to access the textmessage registration page even though news cannot be displayed
         FileHandler::writeFile($cache_file, '');
         FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl('')));
     }
     if (file_exists($cache_file)) {
         $oXml = new XmlParser();
         $buff = $oXml->parse(FileHandler::readFile($cache_file));
         $item = $buff->zbxe_news->item;
         if ($item) {
             if (!is_array($item)) {
                 $item = array($item);
             }
             foreach ($item as $key => $val) {
                 $obj = new stdClass();
                 $obj->title = $val->body;
                 $obj->date = $val->attrs->date;
                 $obj->url = $val->attrs->url;
                 $news[] = $obj;
             }
             Context::set('news', $news);
         }
         Context::set('released_version', $buff->zbxe_news->attrs->released_version);
         Context::set('download_link', $buff->zbxe_news->attrs->download_link);
     }
     $this->setTemplateFile('index');
 }
 /**
  * Displays the list of existing job queues.
  * 
  * @param   array   $arguments    (optional)
  * @param   array   $options      (optional)
  */
 public function execute($arguments = array(), $options = array())
 {
     if ($arguments["src"] === "none") {
         $arguments["src"] = null;
     }
     if ($arguments["reporting"] != "full" && $arguments["reporting"] != "incremental" && $arguments["reporting"] != "cache" && $arguments["reporting"] != "file") {
         throw new Exception("Invalid value for argument: reporting. The value 'incremental', 'cache', 'file' or 'full' are expected, but '" . $arguments["reporting"] . "' is given!");
     } else {
         if ($arguments["rebuild"] != "yes" && $arguments["rebuild"] != "no") {
             throw new Exception("Invalid value for argument: rebuild. The value 'yes' or 'no' are expected, but '" . $arguments["rebuild"] . "' is given!");
         } else {
             if ($arguments["src"] != null && (!file_exists($arguments["src"]) || !is_readable($arguments["src"]))) {
                 throw new Exception("Invalid value for argument: src. The file '" . $arguments["src"] . "' doesn't exist or is not readable!");
             }
         }
     }
     $project = ProjectConfiguration::getActive();
     $this->basedir = $project->getRootDir();
     // Add plugin dirs..
     $this->dirs = XmlParser::getPluginDirs($this->basedir . "/plugins");
     // DB
     $this->dbmanager = new sfDatabaseManager($this->configuration);
     // XML Validator
     $this->validator = new XmlValidator(null, false, true, $arguments["reporting"] == "cache");
     // Truncating cache
     if ($arguments["rebuild"] == "yes") {
         afValidatorCachePeer::clearCache();
     }
     if ($arguments["log"] !== null) {
         $this->log = $arguments["log"];
     }
     $this->args = $arguments;
     $this->logSection("\nXML Config validation is starting.. (this may take a while)\n" . "Validation type: " . $arguments["reporting"] . "                                      \n" . "Will flush cache: " . $arguments["rebuild"] . "                                       ", null, null, "ERROR");
     if ($arguments["reporting"] != "file" && $arguments["src"] == null) {
         foreach ($this->dirs as $dir) {
             $scan = substr($dir, 0, 1) == "/" ? $dir : $this->basedir . "/apps/" . $arguments['application'] . "/" . $dir;
             $this->readConfigs($scan);
         }
     } else {
         $this->validator->readXmlDocument($arguments["src"], true);
         $result = $this->validator->validateXmlDocument(true);
         $this->logSection($result[1] === null ? "valid: " : "error: ", $arguments["src"], null, $result[0]);
         if ($result[1]) {
             echo Util::arrayToString(array("file" => $tmp, "message" => $result[1]->getMessage()));
             return true;
         }
     }
     if ($arguments["reporting"] == "full") {
         $this->printTotal();
     }
     return 0;
 }
Example #30
0
 public function extractTo($destination, $entries = NULL)
 {
     if ($extResult = parent::extractTo($destination, $entries)) {
         //TODO: ApkXmlParser can not parse the main.xml and others! only AndroidManifest.xml
         //return $extResult;
         $xmlFiles = $this->glob_recursive($destination . '/*.xml');
         foreach ($xmlFiles as $xmlFile) {
             // TODO : Remove this ifcheck , if ApkXml can parse! amk!
             if ($xmlFile == $destination . "/AndroidManifest.xml") {
                 XmlParser::decompressFile($xmlFile);
             }
         }
     }
     return $extResult;
 }