예제 #1
0
 /**
  * Update currency cache
  */
 private function __update_cache($force = False)
 {
     if (!is_null($this->_cache) && !$force) {
         return;
     }
     $filename = $this->path . 'data/iso_currencies.xml';
     if (file_exists($filename)) {
         // get XML file
         $data = file_get_contents($filename);
         $xml = new XMLParser($data, $filename);
         $xml->Parse();
         $currencies = array();
         // create list with unique data
         foreach ($xml->document->tagChildren as $iso_currency) {
             // extract data
             $entity = $iso_currency->tagChildren[0]->tagData;
             $currency = $iso_currency->tagChildren[1]->tagData;
             $alphabetic_code = $iso_currency->tagChildren[2]->tagData;
             $numeric_code = $iso_currency->tagChildren[3]->tagData;
             $minor_unit = $iso_currency->tagChildren[4]->tagData;
             if ($numeric_code == '' || $alphabetic_code == 'XXX') {
                 continue;
             }
             $currencies[] = array('entity' => $entity, 'currency' => $currency, 'alphabetic_code' => $alphabetic_code, 'numeric_code' => $numeric_code, 'minor_unit' => $minor_unit);
             // update cache
             $this->_cache = $currencies;
         }
     }
 }
예제 #2
0
	function thor_build_display_values()
	{
		$form = new entity($this->form_id);
		$form->get_values();
		if ($form->get_value('type') != id_of('form'))
		{
			trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
		}
		else
		{
			$form_xml_obj = new XMLParser($form->get_value('thor_content'));
			$form_xml_obj->Parse();
			$display_values = array();
			foreach ($form_xml_obj->document->tagChildren as $k=>$v)
			{
				$tagname = is_object($v) ? $v->tagName : '';
				if (method_exists($this, '_build_display_'.$tagname))
				{
					$build_function = '_build_display_'.$tagname;
					$display_values = array_merge($display_values, $this->$build_function($v));
				}
			}
		}
		foreach ($this->extra_fields as $field_name)
		{
			$display_values[$field_name]['label'] = prettify_string($field_name);
			$display_values[$field_name]['type'] = 'text';
		}
		$this->_display_values = (isset($display_values)) ? $display_values : array();
	}
예제 #3
0
 /**
  * 测试XML解析类
  */
 function testXml()
 {
     $xml = file_get_contents('temp.xml');
     $this->load->library('XMLParserLib');
     $parser = new XMLParser($xml);
     $parser->Parse();
     print_r($parser->document->globalinfo);
     //echo $parser->GenerateXML();
 }
예제 #4
0
 /**
  * Load all modules in specified path
  *
  * @param boolean $include_only
  */
 function loadModules($include_only = false)
 {
     global $db_use, $data_path;
     $preload_list = array();
     $normal_list = array();
     if ($db_use) {
         // database available, form module list from database entries
         $manager = ModuleManager::getInstance();
         // get priority module list
         $preload_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 1), array('order'));
         // get normal module list
         $normal_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 0), array('order'));
         foreach ($preload_raw as $preload_item) {
             $preload_list[] = $preload_item->name;
         }
         foreach ($normal_raw as $normal_item) {
             $normal_list[] = $normal_item->name;
         }
     } else {
         // no database available use system initialization file
         $file = $data_path . 'system_init.xml';
         if (file_exists($file)) {
             $xml = new XMLParser(@file_get_contents($file), $file);
             $xml->Parse();
             foreach ($xml->document->tagChildren as $xml_tag) {
                 if ($xml_tag->tagName == 'module') {
                     $normal_list[] = $xml_tag->tagAttrs['name'];
                 }
             }
         }
     }
     // load modules
     if (count($preload_list) > 0) {
         foreach ($preload_list as $module_name) {
             $this->_loadModule($module_name);
         }
     }
     if (count($normal_list) > 0) {
         if ($include_only) {
             foreach ($normal_list as $module_name) {
                 $this->_includeModule($module_name);
             }
         } else {
             foreach ($normal_list as $module_name) {
                 $this->_loadModule($module_name);
             }
         }
     }
 }
예제 #5
0
function get_links_from_rss_string($rss)
{
    require_once INCLUDE_PATH . 'xml/xmlparser.php';
    $xml_parse = new XMLParser($rss);
    $xml_parse->Parse();
    $links = array();
    if (isset($xml_parse->document->channel[0]->item)) {
        foreach ($xml_parse->document->channel[0]->item as $k => $item) {
            if (isset($item->link[0]->tagData)) {
                $links[] = trim(str_replace('&', '&', $item->link[0]->tagData));
            }
        }
    }
    return $links;
}
예제 #6
0
파일: language.php 프로젝트: tareqy/Caracal
 /**
  * Constructor
  *
  * @return LanguageHandler
  */
 public function __construct($file = '')
 {
     global $data_path;
     $this->active = false;
     $file = empty($file) ? $data_path . 'system_language.xml' : $file;
     // make sure language file exists
     if (!file_exists($file)) {
         return;
     }
     // parse language file
     $engine = new XMLParser(@file_get_contents($file), $file);
     $engine->Parse();
     $this->active = true;
     // make sure language file is not empty
     if (!isset($engine->document) || !isset($engine->document->language)) {
         return;
     }
     foreach ($engine->document->language as $xml_language) {
         $short_name = $xml_language->tagAttrs['short'];
         $full_name = isset($xml_language->tagAttrs['name']) ? $xml_language->tagAttrs['name'] : '';
         $is_rtl = isset($xml_language->tagAttrs['rtl']) && $xml_language->tagAttrs['rtl'] == 'yes';
         $default = isset($xml_language->tagAttrs['default']);
         // add to language list
         $this->languages[$short_name] = $full_name;
         // create storage for constants
         $this->data[$short_name] = array();
         // mark as RTL
         if ($is_rtl) {
             $this->rtl_languages[] = $short_name;
         }
         // set as default
         if (is_null($this->default) && $default) {
             $this->default = $short_name;
         }
         // parse language constants
         foreach ($xml_language->constant as $xml_constant) {
             $constant_name = $xml_constant->tagAttrs['name'];
             $value = $xml_constant->tagData;
             $this->data[$short_name][$constant_name] = $value;
         }
     }
     // remove parser
     unset($engine);
 }
예제 #7
0
파일: WebSearch.php 프로젝트: igez/gaiaehr
            } else {
                $args .= '&mainSearchCriteria.v.c=' . strtolower($_SESSION['web_search_q']);
            }
        }
        break;
}
//********************************************************************************
// build the URL using the baseUrl and the appended arguments from the if/else
//********************************************************************************
$url = $baseUrl . $args;
//********************************************************************************
// XML parser... PFM!
//********************************************************************************
$xml = file_get_contents($url);
$parser = new XMLParser($xml);
$parser->Parse();
$rows = array();
//--------------------------------------------------------------------------------
// get the total value form the xml
//--------------------------------------------------------------------------------
switch ($_SESSION['search_type']) {
    case 'health_topics':
        if (isset($parser->document->list[0]->document)) {
            $totals = $parser->document->count[0]->tagData;
            //----------------------------------------------------------------------------
            // store file value for pager, if need it
            //----------------------------------------------------------------------------
            $_SESSION['web_search_file'] = $parser->document->file[0]->tagData;
            //****************************************************************************
            // now lets work the xml file to push stuff into the $rows array()
            //****************************************************************************
	/**
	 * Returns an existing or new XML_Parser object for the thor content of a reason form.
	 * @param reason form id
	 * @return object XML_Parser
	 */
	function &getXMLParser()
	{
		static $xml_parsers;
		
		$id = $this->get_table_id();
		if (isset($xml_parsers[$id])) return $xml_parsers[$id];
		else
		{
			$table_entity = new entity($id);
			$table_xml = $table_entity->get_value('thor_content');
			$xml_parser = new XMLParser($table_xml);
			$xml_parser->Parse();
			$xml_parsers[$id] =& $xml_parser;
		}
		return $this->getXMLParser();
	}
예제 #9
0
/**
 * Load the data from the response as xml
 *
 */
function ipl_core_load_xml($xmlDataString)
{
    global $ipl_core_error_code;
    global $ipl_core_error_msg;
    global $ipl_core_api_error_code;
    global $ipl_core_api_customer_message;
    global $ipl_core_api_merchant_message;
    switch (IPL_CORE_XML_PARSER) {
        case 'simpleXml':
            if (!function_exists('simplexml_load_string')) {
                $ipl_core_error_code = 15;
                $ipl_core_error_msg = 'simpleXml lib has not been loaded';
                return false;
            }
            $xml = simplexml_load_string($xmlDataString);
            if (!$xml) {
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = 'Invalid XML reponse received';
                return false;
            } else {
                $attr = $xml->attributes();
                $ipl_core_api_error_code = (int) $attr->error_code;
                $ipl_core_api_customer_message = (string) $attr->customer_message;
                $ipl_core_api_merchant_message = (string) $attr->merchant_message;
            }
            break;
        case 'preg':
            $errorCode = ipl_core_get_xml_attribute_value('data', 'error_code', $xml);
            if ($errorCode === false) {
                return false;
            }
            if ($errorCode > 0) {
                $ipl_core_api_customer_message = ipl_core_get_xml_attribute_value('data', 'customer_message', $xml);
                $ipl_core_api_merchant_message = ipl_core_get_xml_attribute_value('data', 'merchant_message', $xml);
            }
            break;
        case 'xmlParser':
            $parser = new XMLParser($xmlDataString);
            if ($parser->Parse() == false) {
                $xmlError = $parser->getError();
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = "Invalid XML reponse received: {$xmlError}";
                return false;
            }
            $xml = $parser->document;
            if (!$xml) {
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = 'Invalid XML reponse received';
                return false;
            } else {
                $ipl_core_api_error_code = (int) $xml->tagAttrs['error_code'];
                $ipl_core_api_customer_message = ipl_core_decode((string) $xml->tagAttrs['customer_message']);
                $ipl_core_api_merchant_message = ipl_core_decode((string) $xml->tagAttrs['merchant_message']);
            }
            break;
        default:
            $ipl_core_error_code = 9;
            $ipl_core_error_msg = 'Unknown XML parser lib: ' . IPL_CORE_XML_PARSER;
            return false;
            break;
    }
    return $xml;
}
예제 #10
0
 function _ResponseResultToResponseArray($SomeResult)
 {
     $this->responsearray = array();
     if (empty($SomeResult)) {
         // $SomeArray
         // we have an error
         $this->responsearray['status'] = 'Error';
         $this->responsearray['statusCode'] = '500';
         $this->responsearray['errorDescription'] = 'No Response';
         return;
     }
     //echo '<br>$this->ContentType='.$this->ContentType.'<br>';
     if ($this->ContentType != 'JSON' && $this->ContentType != 'PHPSERIAL' && $this->ContentType != 'XML') {
         $this->ContentType = 'JSON';
     }
     //echo '<br>$this->ContentType='.$this->ContentType.'<br>';
     if ($this->ContentType == 'JSON') {
         if (class_exists('Services_JSON')) {
             //$JSONObj = new Services_JSON();
             //return $JSONObj->encode($SomeArray);
             $JSONObj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
             $this->responsearray = $JSONObj->decode($SomeResult);
         } else {
             // throw error
             trigger_error("ERROR: Services_JSON class not available", E_USER_ERROR);
         }
     } else {
         if ($this->ContentType == 'XML') {
             if (class_exists('XMLParser')) {
                 $parser = new XMLParser($SomeResult, false, false);
                 $parser->Parse();
                 $this->responsearray = $parser->ReturnArray();
                 $this->responsearray = $this->responsearray['root'];
                 // this forces the 'results' response to always have a child 0, xml can omit this
                 if (isset($this->responsearray['results']) && is_array($this->responsearray['results']) && !isset($this->responsearray['results']['0']) && count($this->responsearray['results'] > 0)) {
                     $temparray = $this->responsearray['results'];
                     unset($this->responsearray['results']);
                     $this->responsearray['results']['0'] = $temparray;
                     unset($temparray);
                 }
                 //$XMLObj = new ArrayXML( $SomeArray );
                 //return  '<'.'?'.'xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<root>'."\n".$XMLObj->ReturnXML().'</root>';
             } else {
                 // throw error
                 trigger_error("ERROR: XMLParser class not available", E_USER_ERROR);
             }
         } else {
             if ($this->ContentType == 'PHPSERIAL') {
                 //return serialize($SomeArray);
                 $this->responsearray = unserialize($SomeResult);
                 //if ( is_array( $this->xmlarray ) )
                 //{
                 //	$this->xmlarray['root'] = array_changekeycase_r( $this->xmlarray['root'], CASE_LOWER );
                 //}
             }
         }
     }
     if (!empty($this->responsearray['status'])) {
         $this->Status = $this->responsearray['status'];
     }
     if (!empty($this->responsearray['statusCode'])) {
         $this->StatusCode = $this->responsearray['statusCode'];
     }
     if (!empty($this->responsearray['errorDescription'])) {
         $this->ErrorDescription = $this->responsearray['errorDescription'];
     }
     // $this->responsearray['status'] = 'Success'
     // $this->responsearray['statusCode'] = '200'
     //}
     // default
     //$JSONObj = new Services_JSON();
     //return $JSONObj->encode($SomeArray);
 }
예제 #11
0
/**
 * Return authentication credentials for the specified database connection.
 *
 * @param string $conn_name The name of the db connection you want to retrieve
 * @param boolean $lack_of_creds_is_fatal defaults to true for historical purposes
 * @return array Array with all the db connection info defined for the specified named connection.
 */
function _legacy_get_db_credentials($conn_name, $lack_of_creds_is_fatal = true)
{
    static $db_info;
    // if db_info has not been set, this is the first time this function has been run.
    if (!isset($db_info)) {
        trigger_warning('Using _legacy_get_db_credentials - please upgrade to PHP 5.1 or later to use faster XML functions.');
        if (!defined('DB_CREDENTIALS_FILEPATH')) {
            trigger_fatal_error('The DB_CREDENTIALS_FILEPATH constant is not defined.');
        }
        $db_info = array();
        require_once INCLUDE_PATH . 'xml/xmlparser.php';
        if (file_exists(DB_CREDENTIALS_FILEPATH) && ($xml = trim(file_get_contents(DB_CREDENTIALS_FILEPATH)))) {
            $xml_parse = new XMLParser($xml);
            $parse = $xml_parse->Parse();
            if (isset($xml_parse->document->database)) {
                foreach ($xml_parse->document->database as $database) {
                    $tmp = array();
                    $db_conn_name = isset($database->connection_name[0]->tagData) ? $database->connection_name[0]->tagData : false;
                    $tmp['db'] = isset($database->db[0]->tagData) ? $database->db[0]->tagData : false;
                    $tmp['user'] = isset($database->user[0]->tagData) ? $database->user[0]->tagData : false;
                    $tmp['password'] = isset($database->password[0]->tagData) ? $database->password[0]->tagData : false;
                    $tmp['host'] = isset($database->host[0]->tagData) ? $database->host[0]->tagData : false;
                    if ($db_conn_name && $tmp['db'] !== false && $tmp['user'] !== false && $tmp['password'] !== false && $tmp['host'] !== false) {
                        $db_info[$db_conn_name] = $tmp;
                    } else {
                        $invalid_entries[] = $db_conn_name;
                    }
                }
            }
            if (isset($invalid_entries)) {
                $invalid_str = $invalid_entries == 1 ? $invalid_entries . ' entry appears' : $invalid_entries . ' entries appear';
                turn_carl_util_error_context_off();
                foreach ($invalid_entries as $conn_name) {
                    if (!empty($conn_name)) {
                        trigger_error('The connection ' . $conn_name . ' in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ') appears to have missing or invalid values.', WARNING);
                    } else {
                        trigger_error('An entry without a connection name is defined in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ')', WARNING);
                    }
                }
                turn_carl_util_error_context_on();
            }
            if (empty($db_info)) {
                trigger_error('Check the xml in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ') - no valid database connection information could be built.', WARNING);
            }
        } else {
            trigger_fatal_error('The DB_CREDENTIALS_FILEPATH (' . DB_CREDENTIALS_FILEPATH . ') refers to a file that is missing or does not have any content.');
        }
    }
    // if this was the first time, the code above should have run successfully so db_info is populated.
    // if this is not the first time, then the code above should have been skipped since it was populated the first
    // run of the function.
    if (isset($db_info[$conn_name])) {
        return $db_info[$conn_name];
    } else {
        // disable context display so we do not show passwords on screen.
        turn_carl_util_error_context_off();
        if ($lack_of_creds_is_fatal) {
            trigger_fatal_error('Unable to use database connection ' . $conn_name . ' - No credential information found for the connection named ' . $conn_name . ' in database credential file (' . DB_CREDENTIALS_FILEPATH . ').', 2);
        } else {
            trigger_warning('Unable to use database connection ' . $conn_name . ' - No credential information found for the connection named ' . $conn_name . ' in database credential file (' . DB_CREDENTIALS_FILEPATH . ').', 2);
        }
        turn_carl_util_error_context_on();
    }
    return false;
}
예제 #12
0
 function get_file_upload_summary_data()
 {
     $rawXml = $this->get_form_entity()->get_value('thor_content');
     $formXml = new XMLParser($rawXml);
     $formXml->Parse();
     $attachmentData = array();
     foreach ($formXml->document->tagChildren as $node) {
         if ($node->tagName == 'upload') {
             $col_id = $node->tagAttrs['id'];
             $col_label = $node->tagAttrs['label'];
             $upload_data = $_FILES[$col_id];
             if ($upload_data["tmp_name"] != "") {
                 $disco_el = $this->get_view()->get_element($col_id);
                 if ($disco_el->state == "received") {
                     $attachmentData[$col_id] = array("label" => $col_label, "filename" => $upload_data["name"]);
                     if ($this->should_save_form_data()) {
                         $tc = $this->get_thor_core_object();
                         $attachmentData[$col_id]["path"] = $tc->construct_file_storage_location($this->get_form_id(), $col_id, $upload_data["name"]);
                     } else {
                         $attachmentData[$col_id]["path"] = $disco_el->tmp_full_path;
                     }
                 }
             }
         }
     }
     return $attachmentData;
 }
예제 #13
0
        foreach (FoxydataUtils::$CustomerAddressFieldMap as $feed_field => $db_field) {
            $rtn[$prefix . $db_field] = $address_fields[$feed_field];
        }
        $country = $this->osc->findCountryByCode($address_fields['country']);
        $rtn[$prefix . 'country_id'] = $country['countries_id'];
        $zone = $this->osc->findZoneByNameAndCountryID($address_fields['state'], $rtn[$prefix . 'country_id']);
        $rtn[$prefix . 'zone_id'] = $zone['zone_id'];
        return $rtn;
    }
}
$utils = new FoxydataUtils($osc);
$decryptor = new rc4crypt();
$FoxyData = $decryptor->decrypt(DATAFEED_KEY, urldecode($_POST["FoxyData"]));
$data = new XMLParser($FoxyData);
// Parse that XML.
$data->Parse();
/**
 * Wrapper class to make retrieving name / value pairs from an XML feed much
 *  more concise.  Create with an XMLTag (the result of parsing an XML
 *  file), then retrieve properties with, e.g., $wrapper->customers_email_address.
 */
class PropertyWrapper
{
    public function __construct(XMLTag $data)
    {
        $this->data = $data;
    }
    public function __get($field)
    {
        $rtn = '';
        if (isset($this->data->{$field})) {
 private static function getXmlDoc($path)
 {
     if (file_exists($path)) {
         $xml = file_get_contents($path);
         $xmlParser = new XMLParser($xml);
         $xmlParser->Parse();
         return $xmlParser;
     } else {
         throw new MashapeException(sprintf(EXCEPTION_CONFIGURATION_FILE_NOTFOUND, $path), EXCEPTION_XML_CODE);
     }
 }
예제 #15
0
function verify_mysql($db_conn_name, $constant_name, $constant_location, $check_for_tables = false)
{
    include_once INCLUDE_PATH . 'xml/xmlparser.php';
    // we have verified this exists already
    $db_file = DB_CREDENTIALS_FILEPATH;
    // we have verified this exists
    $xml = file_get_contents($db_file);
    if (!empty($xml)) {
        $xml_parse = new XMLParser($xml);
        $xml_parse->Parse();
        foreach ($xml_parse->document->database as $database) {
            $tmp = array();
            $tmp['db'] = $database->db[0]->tagData;
            $tmp['user'] = $database->user[0]->tagData;
            $tmp['password'] = $database->password[0]->tagData;
            $tmp['host'] = $database->host[0]->tagData;
            $db_info_all[$database->connection_name[0]->tagData] = $tmp;
        }
    } else {
        return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - the db connection xml file does not appear to have any contents', false);
    }
    $db_info = isset($db_info_all[$db_conn_name]) ? $db_info_all[$db_conn_name] : false;
    if ($db_info === false) {
        return msg('mysql check failed - ' . $db_conn_name . ' is an invalid connection name.
		<p>Make sure the constant ' . $constant_name . ' in ' . $constant_location . ' maps to the connection name in your db connection xml file</p>', false);
    }
    if (empty($db_info['db']) || empty($db_info['user']) || empty($db_info['password']) || empty($db_info['host'])) {
        return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - the db connection xml file for does not have full information for the connection named ' . $db_conn_name . '.
		<p>Check the constant ' . $constant_name . ' in ' . $constant_location . ' to make sure it matches the connection name in your db connection xml file.</p>', false);
    }
    $db = mysql_connect($db_info['host'], $db_info['user'], $db_info['password']);
    if (empty($db)) {
        return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - count not connect to server - could be one of the following
					<ul>
					<li>Improper username and/or password in the db credentials file</li>
					<li>Improper mysql hostname - currently set to ' . $db_info['host'] . '</li>
					<li>The user ' . $db_info['user'] . ' needs to have been granted permission to connect to ' . $db_info['host'] . ' from the web server</li>
					</ul>', false);
    } else {
        if (!mysql_select_db($db_info['db'], $db)) {
            return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - connected to host as user ' . $db_info['user'] . ' but could not select database ' . $db_info['db'] . '. Check the db credential xml file and user privileges', false);
        }
    }
    // check_for_tables
    if ($check_for_tables) {
        $result = db_query('show tables');
        $table_count = mysql_num_rows($result);
        if ($table_count == 0) {
            return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - 
				   The database ' . $db_info['db'] . ' does not appear to have any tables.<p><a href="./install.htm#database_setup">Consult the reason install documentation</a> 
				   for information on how to import the reason database.</p>', false);
        }
    }
    return msg('<span class="success">mysql connection ' . $constant_name . '(' . $db_conn_name . ') check passed</span>', true);
}
예제 #16
0
 function set_thor_xml($xml)
 {
     $xml = new XMLParser($xml);
     $xml->Parse();
     $this->_xml = $xml;
 }
예제 #17
0
 /**
  * Grab the Jaiku presence message and location for a given user.
  * @param string $screenname the "Jaiku name" (for lack of a better work) of the user -- the XXX part of their XXX.jaiku.com personal URL.
  */
 function GetPresence($username = null)
 {
     if (!$username) {
         $username = $this->username;
     }
     require_once "parser_php5.php";
     $url = $username . ".jaiku.com/presence/xml";
     $xml = $this->SendToJaiku(null, $url);
     $parser = new XMLParser($xml);
     $parser->Parse();
     $p = new Presence($username);
     $p->line = $parser->document->line[0]->tagData;
     $p->city = $parser->document->location[0]->tagChildren[0]->tagData;
     $p->country = $parser->document->location[0]->tagChildren[1]->tagData;
     return $p;
 }
예제 #18
0
<?php

include "x12_parser.inc.php";
include "x12_validator.inc.php";
include "../XMLParser/XMLParser.inc.php";
$x12 = new x12parse_4010();
$vx12 = new x12valid_837_4010();
$data = file_get_contents('x12files/MC174.TXT');
$x12->setX12($data);
$vx12->setX12($data);
// Get the account information for this plugin
$xml = file_get_contents("ansix12_4010.dicc.xml");
$pluginXML = new XMLParser($xml);
$pluginXML->Parse();
echo "<pre>";
$x12->setDicc($pluginXML);
echo "</pre>";
echo "Document Type: " . $x12->docType() . "<br>";
echo "Document Control Number: " . $x12->docControlNumber() . "<br>";
echo "<br>";
echo "Document Interchange Information <br>";
echo "--------------------------------------------------------------------------------------------------<br>";
echo "<pre>";
print_r($x12->docISA());
echo "</pre>";
echo "<br>";
echo "<br>";
echo "Functional Group Information <br>";
echo "--------------------------------------------------------------------------------------------------<br>";
echo "<pre>";
print_r($x12->docGS());
예제 #19
0
 /**
  * 线下活动结算同步
  * @param int $year 年份
  * @param int $month 月份
  * @param number $listNumber 返回的最大行数(获取条数)
  * @param number $beginNumber 开始行数(表示页码,三观已毁)
  * @param string $state 项目状态(08为默认值,表示已申请结算,RMP这边只获取这个状态的数据)
  * @param number $sign 获取标识(0:待同步,1:已同步)
  * @return Ambigous <number, multitype:number string multitype: , string, unknown>
  */
 function settleOfflineSync($year, $month, $listNumber = 10, $beginNumber = 1, $state = '08', $sign = 0)
 {
     $param = "<?xml version='1.0' encoding='UTF-8' ?><XMLInfo>" . "<listNumber>{$listNumber}</listNumber><beginNumber>{$beginNumber}</beginNumber>" . "<param><activityMonth>{$month}</activityMonth><activityState>{$state}</activityState><activitySign>{$sign}</activitySign>" . "</param></XMLInfo>";
     $result = $this->client->call('offlineActivityClearing', array("in0" => base64_encode($param)));
     $err = $this->client->getError();
     if ($err) {
         $this->setError($err);
     } else {
         $xml = str_replace('&', '&amp;', $result['out']);
         $parser = new XMLParser($xml);
         $parser->Parse();
         //echo json_encode($parser->document);exit();
         if ($parser->document->globalinfo[0]->code[0]->tagData == 0 && $parser->document->return[0]->offlineactivitycost) {
             $total = 0;
             //接口数据总数
             $updateCount = 0;
             //查询到的活动数据
             foreach ($parser->document->return[0]->offlineactivitycost as $offlineActivityCost) {
                 $total++;
                 //活动数据
                 $projectData = $this->xProjectModel->getData(array('activityId' => $offlineActivityCost->activityid[0]->tagData));
                 //若没有对于的项目数据,则跳过同步
                 if (!$projectData) {
                     continue;
                 }
                 //时间段
                 $timeStamp = strtotime($year . '-' . $offlineActivityCost->activitymonth[0]->tagData . '-1 23:59:59');
                 $timeUnit = $this->timeUnitModel->getTimeUnit($timeStamp);
                 $where = array('costNo' => (string) $offlineActivityCost->costno[0]->tagData, 'activityId' => (string) $offlineActivityCost->activityid[0]->tagData);
                 $data = array('storeId' => isset($projectData['storeId']) ? $projectData['storeId'] : 0, 'year' => $year, 'timeUnit' => $timeUnit, 'procId' => isset($projectData['procId']) ? $projectData['procId'] : 0, 'activityAddress' => (string) $offlineActivityCost->activityaddress[0]->tagData, 'activityTime' => (string) $offlineActivityCost->activitytime[0]->tagData, 'budgetApply' => (double) $offlineActivityCost->activitybudgetcost[0]->tagData, 'settleApply' => (double) $offlineActivityCost->activityclearingcost[0]->tagData);
                 $offlineData = $this->xPOfflineModel->getData($where);
                 if ($offlineData) {
                     $offlineData['settleAuditRs'] == -1 && ($data['settleAuditRs'] = 0);
                     //结算变成申请状态
                     //如果已审核通过,则直接将审核申请金额变成审核通过金额
                     in_array($offlineData['settleAuditRs'], array(1, 4)) && ($data['settleAudit'] = $data['settleApply']);
                     $data['updateTime'] = time();
                     $this->xPOfflineModel->edit($where, $data);
                 } else {
                     $data['settleAuditRs'] = 0;
                     //结算变成申请状态
                     $data['createTime'] = time();
                     $this->xPOfflineModel->add(array_merge($where, $data));
                 }
                 //线下活动明细
                 if (isset($offlineActivityCost->activityclearingcostdetaillist[0]->activityclearingcostdetail)) {
                     $data['detailData'] = array();
                     foreach ((array) $offlineActivityCost->activityclearingcostdetaillist[0]->activityclearingcostdetail as $offlineDetail) {
                         $detailArr = explode('|', (string) $offlineDetail->tagData);
                         $detailData = array('storeId' => isset($projectData['storeId']) ? $projectData['storeId'] : 0, 'year' => $year, 'timeUnit' => $timeUnit, 'offlineCostNo' => $where['costNo'], 'detailType' => isset($detailArr[0]) ? (int) $detailArr[0] : '', 'detailName' => isset($detailArr[1]) ? (int) $detailArr[1] : '', 'budgetApply' => isset($detailArr[2]) ? (double) $detailArr[2] : 0, 'settleApply' => isset($detailArr[3]) ? (double) $detailArr[3] : 0, 'detailTime' => isset($detailArr[4]) ? (string) $detailArr[4] : '', 'createTime' => time());
                         $data['detailData'][] = $detailData;
                     }
                     if ($data['detailData']) {
                         $this->xPODetailModel->del(array('offlineCostNo' => $where['costNo']), '*');
                         //删除旧数据
                         foreach ($data['detailData'] as $k => $v) {
                             if ($v['detailType'] || $v['detailName'] || $v['budgetApply'] || $v['settleApply']) {
                                 $this->xPODetailModel->add($v);
                             }
                         }
                     }
                 }
                 //重新计算线下活动金额
                 $this->xPOfflineModel->updateMoney($where['costNo']);
                 //若同步未同步过的数据,则记录同步日志
                 if ($sign == 0) {
                     $this->recordLog(6, $where['activityId'], $where['costNo'], $projectData['orderId'], 1, $data);
                 }
                 $updateCount++;
                 //usleep(1000);
             }
             $this->setSuccess('更新成功', array('total' => $total, 'updateCount' => $updateCount));
         } else {
             $this->setSuccess("数据为空:" . $parser->document->globalinfo[0]->message[0]->tagData);
         }
     }
     return $this->json;
 }