Пример #1
0
 protected function getRoomRate(array $post, array $room, $idx)
 {
     list($agentId, $currency) = explode('#', $post['AgentId']);
     $o_xml = parse_xml($post['response']);
     $query_xpath = '//Hotel' . '[@HotelId = "' . $post['HotelId'] . '"]' . '/RoomCateg' . '[@Code = "' . $post['RoomCatgWScode'] . '"]' . '[@BFType = "' . $post['BFType'] . '"]' . '[@avail = "True"]' . '/RoomType' . '[@TypeName = "' . $room['RoomTypeName'] . '"]' . '[Rate/RoomRate/RoomSeq/@AdultNum = ' . $room['AdultNum'] . ']' . '[Rate/RoomRate/RoomSeq/@ChildNum = ' . $room['NumChild'] . ']' . '[Rate/RoomRate/RoomSeq/@ChildAge1 =  ' . $room['Age1'] . ']' . '[Rate/RoomRate/RoomSeq/@ChildAge2 =  ' . $room['Age2'] . ']' . '';
     $total_price = doubleval(current($o_xml->xpath($query_xpath))->attributes()->TotalPrice);
     $num_rooms = intval(current($o_xml->xpath($query_xpath))->attributes()->NumRooms);
     $this->total_price[serialize($room) . $idx] = $total_price / $num_rooms;
     $strxml = '<RoomRates>' . '<RoomRate RoomTypeCode = "' . $post['RoomCatgWScode'] . '" RatePlanCode = "' . $post['BFType'] . '" NumberOfUnits = "1">' . '<Rates>' . '<Rate UnitMultiplier = "1" RateTimeUnit = "Day" EffectiveDate = "' . $post['FromDt'] . '" ExpireDate = "' . $post['ToDt'] . '">' . '<Base AmountAfterTax = "' . $this->total_price[serialize($room) . $idx] . '" CurrencyCode = "' . $currency . '"/>' . '</Rate>' . '</Rates>' . '</RoomRate>' . '</RoomRates>';
     return $strxml;
 }
Пример #2
0
 public function checkCancel($post)
 {
     $post['o_resp'] = parse_xml($post['response']['content'][0]);
     $post['o_resp']->registerXPathNamespace('ns', 'http://www.opentravel.org/OTA/2003/05');
     $errMsg = $post['o_resp']->xpath('//ns:Error');
     $err = '';
     if (!empty($errMsg)) {
         foreach ($errMsg as $msg) {
             $err .= 'Code : ' . $msg->attributes()->Code . ', Type : ' . $msg->attributes()->Type . ', Msg : ' . (string) $msg;
         }
         log_message('INFO', $err);
         unset($post['o_resp']);
         throw new Exception($err);
     }
     return TRUE;
 }
Пример #3
0
 public function getResponse($post)
 {
     $post['o_resp'] = parse_xml($post['response']['content'][0]);
     $post['o_resp']->registerXPathNamespace('ns', 'http://www.opentravel.org/OTA/2003/05');
     $errMsg = $post['o_resp']->xpath('//ns:Error');
     $err = '';
     if (!empty($errMsg)) {
         foreach ($errMsg as $msg) {
             $err .= 'Code : ' . $msg->attributes()->Code . ', Type : ' . $msg->attributes()->Type . ', Msg : ' . (string) $msg;
         }
         log_message('warning', $err);
         unset($post['o_resp']);
         throw new Exception($err);
     }
     $a_comp = $this->getCompleteService($post);
     $a_comp['RoomCatg'] = $this->getRoomCatg($post);
     $a_comp['RoomCatg'][0]['Room'] = $this->getRoomType($post);
     foreach ($a_comp['RoomCatg'][0]['Room'] as &$night) {
         $night['NightPrice'] = $this->getNightPrice($night['TotalPrice'], $post);
     }
     return $a_comp;
 }
Пример #4
0
<?php

require_once 'logic.php';
$xml_string = file_get_contents("php://input");
$error_message = "";
$ret = parse_xml($xml_string, $query_string, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response:" . $query_string . "err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$dao = new Dao($db_conf['host'], $db_conf['port'], $db_conf['user'], $db_conf['passwd'], $db_conf['db_name']);
$op_type = -1;
$para = array();
$ret = insert_log($dao, $query_string, XY, $op_type, $para, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response:" . $query_string . "err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$mo_data = array();
$mo_data['mobile_num'] = $para['mobile'];
$mo_data['content'] = $para['content'];
$mo_data['link_id'] = $para['linkid'];
$mo_data['parter_symbol'] = XY;
$mo_data['mo_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mo_data['submit_flag'] = 0;
Пример #5
0
            $parsed_chapter = parse_xml($xml . $_[$j] . '.xml');
            if ($_[$j] == $chapter) {
                // current chapter >>
                $menu .= '<li><p><strong>' . $parsed_chapter['chapter'] . '</strong><br>' . $parsed_chapter['annotation'] . "</p></li>\n";
                // define description meta tag for current page >>
                $description = $parsed_chapter['chapter'] . ' - ' . $parsed_chapter['annotation'];
            } else {
                // NOT current chapter >>
                $menu .= '<li><p><a href="/' . $_[$j] . '/" class="menu">' . $parsed_chapter['chapter'] . '</a><br>' . $parsed_chapter['annotation'] . "</p></li>\n";
            }
        }
    }
    $menu .= "</ul>\n";
}
// make content >>
$_ = parse_xml($target);
$title = $project_name;
$header = $_['chapter'];
$content = $_['content'];
if ($chapter != '') {
    if ($chapter_in_file[$target] === TRUE && $chapter_in_menu[$target] === TRUE) {
        // chapter exist and in menu >>
        $title = $header . ' - ' . $title;
    } else {
        // chapter NOT exist or NOT in menu >>
        $error = TRUE;
    }
}
// handle error >>
if ($error === TRUE) {
    $header = 'Error 404: file not found';
Пример #6
0
#SETUP TO PULL RESULTS
##########################################################################
$efetch = $utils . "/efetch.fcgi?" . "rettype=" . $report . "&retmode=" . $retMode . "&retstart=" . $retstart . "&retmax=" . $retmax . "&db=" . $db . "&query_key=" . $queryKey . "&WebEnv=" . $webEnv;
debug($efetch);
echo "<b><i>" . $_GET['db'] . " Results:</i></b><hr>";
$results = simplexml_load_file($efetch);
#echo "After Results";
#var_dump($results);
#foreach($results->PubmedArticle as $Article){
#  echo "hmms<br />";
#}
#$pattern = "/\n/";
#$replacement = "<br />";
#preg_replace($pattern, $replacement, $results);
//debug($results);
echo parse_xml($results, $db);
?>

    <?php 
##########################################################################
#FUNCTIONS
##########################################################################
##########################################################################
#DEBUGGING
##########################################################################
function debug($var)
{
    if ($_GET['debug'] == 1) {
        echo "<b><i>" . $var . "</i></b><br />";
    }
}
Пример #7
0
function process_state( $ps_state )
////////////////////////////////////////////
//
// A basic state machine.
//
// Given the $ps_state value passed, perform
// the action dictated by that state.
//
////////////////////////////////////////////
{
GLOBAL $argv;
GLOBAL $msg_log;
GLOBAL $db_host, $db_user, $db_pwd, $db_name;
GLOBAL $DEBUG;

	$done = FALSE;

// $cont_key is an integer 1 .. N of the contract number 
// we'll display.  It indexes the arrays $headers and $details

	$cont_key  = isset( $_SESSION[ 'cont_key'  ] ) ? $_SESSION[ 'cont_key'  ] : NULL;
	$campaigns = isset( $_SESSION[ 'campaigns' ] ) ? $_SESSION[ 'campaigns' ] : NULL;
	$headers   = isset( $_SESSION[ 'headers'   ] ) ? $_SESSION[ 'headers'   ] : NULL;
	$details   = isset( $_SESSION[ 'details'   ] ) ? $_SESSION[ 'details'   ] : NULL;

// loop until we reach a state where the user (web client)
// must perform an action to determine what the next state
// will be.

	output_style_header();
	do {

		message_log_reset( $msg_log );
		if ($DEBUG)
		{
			message_log_append( $msg_log, "database name is $db_name\n" );
		}
		if ($DEBUG)
		{
			message_log_append( $msg_log, "state is $ps_state\n" );
		}
		switch (TRUE) 
		{
/////////////////////////////////
//
//  Initial state is BEGIN
//
/////////////////////////////////
			case ($ps_state == 'BEGIN'):
//  Clear all keys in array $_SESSION
				foreach (array_keys( $_SESSION ) as $sess_key) 
				{
					unset( $_SESSION[ $sess_key ] );
				} // foreach
//  Proceed to a prompting state
				next_state( 'PROMPT_FOR_XML_INPUT' );
				break;
/////////////////////////////////
//
//  Prompt the user to provide an
//  XML file.
//
/////////////////////////////////
			case ($ps_state == 'PROMPT_FOR_XML_INPUT'):
// We are ready to prompt for an input file
				if (CLI) 
				{
					;
// In CLI mode, the input file name will be on the command line.
				} 
				else 
				{
					prompt_for_xml_input();
				}
//  The next step is to check the XML file for basic sanity checks
				next_state( 'CHECK_XML_FILENAME' );
//  But first we have to wait for the web client to upload the file
				$done = TRUE;
				if (CLI) 
				{
					$done = FALSE;
				}
				break;
/////////////////////////////////
//
//  Do some basic checking on the
//  XML file the user provided.
//
/////////////////////////////////
			case ($ps_state == 'CHECK_XML_FILENAME'):
				$input_nam = 'xmlfile'; // per the POST form
				$filnam = isset( $_FILES[ $input_nam ] ) ? 
						 $_FILES[ $input_nam ][ 'name' ] : NULL;
// The full path to where the file was uploaded on the server
				$filtmp = isset( $_FILES[ $input_nam ] ) ? 
						 $_FILES[ $input_nam ][ 'tmp_name' ] : NULL;
				if (is_null( $filnam ) || is_null( $filtmp ) ||
						(strlen( $filnam ) == 0) ||
						(strlen( $filtmp ) == 0)) 
				{
					next_state( 'BEGIN' );
				} 
				else 
				{
					next_state( 'CHECK_XML_UPLOAD' );
				}
				break;
			case ($ps_state == 'CHECK_XML_UPLOAD'):
				if (CLI) 
				{
					$filtmp = $argv[1];
					echo "input file is $filtmp\n";
				}
// The size of the file in bytes
				$filsiz = $_FILES[ $input_nam ][ 'size' ];
// The error code of the upload process
				$filerr = $_FILES[ $input_nam ][ 'error' ];
				if (CLI || $filerr == UPLOAD_ERR_OK) 
				{
					next_state( 'PARSE_XML_UPLOAD' );
				} 
				else 
				{
					message_log_append( $msg_log, "Upload error $filerr", MSG_LOG_ERROR );
					$done = TRUE;
					next_state( 'BEGIN' );	// start over
				}
				break;
/////////////////////////////////
//
//  Do a full parsing of the
//  XML file the user provided.
//
/////////////////////////////////

			case ($ps_state == 'PARSE_XML_UPLOAD'):
				open_mysql();
//  What is the path portion of the $filtmp filename?
				$_SESSION[ 'xmlfile' ] = $filtmp;
				if ($DEBUG) 
				{
					echo "calling parse_xml<br>\n";
					echo "parsing file: $filtmp<br>\n";
				}
//  Set state to start over, in case we fail before parse_xml
// returns.
				next_state( 'BEGIN' );
// parse the XML file, returning an array of contract headers,
// and an array of arrays of detail lines.  First-order indices of 
// headers and details arrays will be integers starting from 1.
				if (parse_xml( $filtmp, $campaigns, $headers, $details )) 
				{
					next_state( 'VERIFY_CAMPAIGN' );
				} 
				else 
				{
					message_log_append( $msg_log, "XML order parsing failed", MSG_LOG_ERROR );
					unset( $_SESSION[ 'campaigns' ] );
					unset( $_SESSION[ 'headers'   ] );
					unset( $_SESSION[ 'details'   ] );
					next_state( 'TRY_AGAIN' );
				}
				break;
/////////////////////////////////
//
//  Verify some basic integrity
//  checks on the data, and create
//  human-readable log messages for
//  problems that are identified.
//
/////////////////////////////////
			case ($ps_state == 'RE-VERIFY_CAMPAIGN'):
// unset all header row MSG_LOG values
				foreach (array_keys( $headers ) as $key)
				{
				    unset( $headers[ $key ][ 'MSG_LOG' ] );
				}
// unset all detail line MSG_LOG values
				foreach (array_keys( $details ) as $dkey)
				{
				    foreach (array_keys( $details[ $dkey ] ) as $ln)
					{
						unset( $details[ $dkey ][ $ln ][ 'MSG_LOG' ] );
					}
				}
// and fall through to VERIFY_CAMPAIGN:
			case ($ps_state == 'VERIFY_CAMPAIGN'):
				verify_campaign( $campaigns, $headers, $details );
				next_state( 'BEGIN' );	// as precaution
//echo "calling verify_all_contracts<br>";
				if (verify_all_contracts( $campaigns, $headers, $details )) 
				{
//echo "vac succeeded<br>";
				} 
				else 
				{
//echo "vac failed<br>";
				}
				next_state( ($ps_state == 'VERIFY_CAMPAIGN')
					? 'DISPLAY_CAMPAIGN'
					: 'DISPLAY_CONTRACT' );
				break;
			case ($ps_state == 'DISPLAY_CAMPAIGN'):
				unset( $cont_key );	// contract array key
				next_state( 'DISPLAY_CONTRACT' );
				break;
			case ($ps_state == 'DISPLAY_CONTRACT'):
//echo "$ps_state<br>";
				if (is_null( $campaigns ) ||
				    is_null( $headers   ) || is_null( $details   )) 
				{
				    next_state( 'BEGIN' );
				} 
				else 
				{
				    if (!isset( $cont_key ) || is_null( $cont_key )) 
					{
						$keys = array_keys( $headers );
						$cont_key = $keys[0];
				    } // if
				    if (is_null( $cont_key )) 
					{
						next_state( 'BEGIN' );
				    } 
					else 
					{
						echo html_campaign( $campaigns );
						echo nav_buttons( array_keys( $headers ), 
							  TRUE,
							  $headers,
							  $cont_key );
						echo html_order( $headers[$cont_key], $cont_key );
						echo html_detail( $details[$cont_key], $cont_key );
// set a safe next state.  form_handler ought to override, unless error.
						next_state( 'BEGIN' );
						$done = TRUE;
				    } //if
				} // if
				break;
			case ($ps_state == 'DISPLAY_NEXT'):
				$keys = array_keys( $headers );
				$cont_key = next_cont_key( $cont_key, $keys );
// we might someday use a better state than BEGIN here.  A NULL
// return from next_cont_key would mean that no contracts remain.
				next_state( is_null( $cont_key ) ? 'BEGIN' : 'DISPLAY_CONTRACT' );
				break;
			case ($ps_state == 'DISPLAY_PREV'):
				$keys = array_keys( $headers );
				$cont_key = prev_cont_key( $cont_key, $keys );
				next_state( is_null( $cont_key ) ? 'BEGIN' : 'DISPLAY_CONTRACT' );
				break;
/////////////////////////////////
//
//  Push SQL file out to
//  the web client for download.
//
/////////////////////////////////
			case ($ps_state == 'PUSH_SQL_FILE'):
				next_state( 'BEGIN' );
				if (CLI) 
				{
					echo "SQL output is in file $sql_file\n";
				} 
				else 
				{
					header( 'Content-type: application/force-download' );
    				header( 'Content-Transfer-Encoding: Binary' );
    				header( 'Content-length: ' . filesize( $sql_file ) );
    				header( 'Content-disposition: attachment; filename="' . basename( $sql_file ) . '"' );
    				readfile( $sql_file );
					unlink( $sql_file );   // delete
				}
				$done = TRUE;
				break;
/////////////////////////////////
//
//  Connect to the SQL server and
//  move the data into the database.
//
/////////////////////////////////
			case ($ps_state == 'IMPORT'):
				next_state( 'BEGIN' );
				open_mysql();
				insert_sql( $campaigns, $headers, $details );
				echo message_log_format( $msg_log );
				message_log_reset( $msg_log );
				break;
/////////////////////////////////
//
//  Delete a LineID from a contract
//
/////////////////////////////////
			case ($ps_state == 'DELETE_LINE'):
				$lineID	   = $_SESSION[ 'LineID'    ];  // XML LineID number
//message_log_append( $msg_log, 'You requested to delete LineID ' . $lineID . ' from contract key ' . $cont_key );

// Deleting detail lines will change the header spot and value totals.
// delete_detail_lineid is responsible for telling us how many spots
// were deleted, and what their total value was.
				$spots = 0;
				$value = 0;
				$details[ $cont_key ] = delete_detail_lineid( 
					$details[ $cont_key ], $lineID, $spots, $value );

// subtract deleted spots and value from header 'detail_*' totals
				$headers[ $cont_key ][ 'detail_spots' ] -= $spots;
				$v = $headers[ $cont_key ][ 'detail_cost' ];
				$v = bcsub( $v, $value, 2 );
				$headers[ $cont_key ][ 'detail_cost' ] = $v;

// subtract deleted spots and value from header 'total_*' totals
				$headers[ $cont_key ][ 'total_spots' ] -= $spots;
				$v = $headers[ $cont_key ][ 'total_cost' ];
				$v = bcsub( $v, $value, 2 );
				$headers[ $cont_key ][ 'total_cost' ] = $v;

// subtract deleted spots and value from campaign 'detail_*' totals
				$campaigns[0][ 'detail_spots' ] -= $spots;
				$v = $campaigns[0][ 'detail_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'detail_cost' ] = $v;

// subtract deleted spots and value from campaign 'total_*' totals
				$campaigns[0][ 'total_spots' ] -= $spots;
				$v = $campaigns[0][ 'total_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'total_cost' ] = $v;

// Now re-validate everything, and re-display this
// specific contract.
				next_state( 'RE-VERIFY_CAMPAIGN' );
				break;
/////////////////////////////////
//
//  Delete a Network from a contract
//
/////////////////////////////////
			case ($ps_state == 'DELETE_NETWORK'):
next_state( 'BEGIN' );
				$lineID	   = $_SESSION[ 'LineID'    ];  // XML LineID number
				$network   = NULL;
				foreach ($details[ $cont_key ] as $det) 
				{
					if ($det[ 'LineID' ] === $lineID) 
					{
						$network = $det[ 'Network' ];
//echo "<pre>"; var_dump( $det ); echo "</pre>";
						break;
					}
				}

				next_state( 'RE-VERIFY_CAMPAIGN' );
				if (is_null( $network)) 
				{
message_log_append( $msg_log, 'Invalid LineID: ' . $lineID . ' not found in contract key ' . $cont_key );
					break;
				}

// Deleting detail lines will change the header spot and value totals.
// delete_detail_network is responsible for telling us how many spots
// were deleted, and what their total value was.
				$spots = 0;
				$value = 0;
				$details[ $cont_key ] = delete_detail_network( 
					$details[ $cont_key ], $network, $spots, $value );

// subtract deleted spots and value from header 'detail_*' totals
				$headers[ $cont_key ][ 'detail_spots' ] -= $spots;
				$v = $headers[ $cont_key ][ 'detail_cost' ];
				$v = bcsub( $v, $value, 2 );
				$headers[ $cont_key ][ 'detail_cost' ] = $v;

// subtract deleted spots and value from header 'total_*' totals
				$headers[ $cont_key ][ 'total_spots' ] -= $spots;
				$v = $headers[ $cont_key ][ 'total_cost' ];
				$v = bcsub( $v, $value, 2 );
				$headers[ $cont_key ][ 'total_cost' ] = $v;

// subtract deleted spots and value from campaign 'detail_*' totals
				$campaigns[0][ 'detail_spots' ] -= $spots;
				$v = $campaigns[0][ 'detail_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'detail_cost' ] = $v;

// subtract deleted spots and value from campaign 'total_*' totals
				$campaigns[0][ 'total_spots' ] -= $spots;
				$v = $campaigns[0][ 'total_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'total_cost' ] = $v;

				message_log_append( $msg_log, 
					'Network ' . $network . 
					' deleted from contract ' . $cont_key );

// Now re-validate everything, and re-display this
// specific contract.
				next_state( 'RE-VERIFY_CAMPAIGN' );
				break;
/////////////////////////////////
//
//  Delete an entire contract
//
/////////////////////////////////
			case ($ps_state == 'DELETE_CONTRACT'):
//message_log_append( $msg_log, 'You requested to delete contract ' . $cont_key );

// Unset the individual detail lines for this contract.
				$dkeys = array_keys( $details[ $cont_key ] );
				foreach ($dkeys as $key) 
				{
					unset( $details[ $cont_key ][ $key ] );
				}
// subtract contract spots and value from campaign 'detail_*' totals
				$spots = $headers[ $cont_key ][ 'detail_spots' ];
				$value = $headers[ $cont_key ][ 'detail_cost'  ];
				$campaigns[0][ 'detail_spots' ] -= $spots;
				$v = $campaigns[0][ 'detail_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'detail_cost' ] = $v;

// subtract contract spots and value from campaign 'total_*' totals
				$spots = $headers[ $cont_key ][ 'total_spots' ];
				$value = $headers[ $cont_key ][ 'total_cost'  ];
				$campaigns[0][ 'total_spots' ] -= $spots;
				$v = $campaigns[0][ 'total_cost' ];
				$v = bcsub( $v, $value, 2 );
				$campaigns[0][ 'total_cost' ] = $v;

// Set the contract header to show 0 spots, 0 value.
				$spots = 0;
				$value = 0;
				$headers[ $cont_key ][ 'detail_spots' ] = $spots;
				$headers[ $cont_key ][ 'detail_cost'  ] = $value;
				$headers[ $cont_key ][ 'total_spots'  ] = $spots;
				$headers[ $cont_key ][ 'total_cost'   ] = $value;

// Unset the 'versionN' fields of deleted contracts so that version
// problems don't prevent the remaining contracts from being imported.
				$j = 0;
				$done = FALSE;
				while (!$done) 
				{
					$fld = 'version' . (++$j);
					$done = !isset( $headers[ $cont_key ][ $fld ] );
					unset( $headers[ $cont_key ][ $fld ] );
				} // while
// auto-advance to next contract
				$done = FALSE;
				$keys = array_keys( $headers );
				$cont_key = next_cont_key( $cont_key, $keys );
// we might someday use a better state than BEGIN here.  A NULL
// return from next_cont_key would mean that no contracts remain.
				next_state( is_null( $cont_key ) ? 'BEGIN' : 'RE-VERIFY_CAMPAIGN' );
				break;
/////////////////////////////////
//
//  Dummy stub.
//
/////////////////////////////////
			case ($ps_state == 'DEAD_END'):
			case ($ps_state == 'STOP'):
				echo $ps_state;
				next_state( 'BEGIN' );
				$done = TRUE;
				break;
/////////////////////////////////
//
//  Screen has error messages.
//  Force user to go back and retry.
//
/////////////////////////////////
			case ($ps_state == 'TRY_AGAIN'):
				next_state( 'BEGIN' );
				echo nav_buttons( NULL, FALSE );	// Cancel only
				$done = TRUE;
				break;
/////////////////////////////////
//
//  State is unknown or invalid.
//  Go back to BEGIN state.
//
/////////////////////////////////
			default:
				message_log_append( $msg_log, 'Invalid state label: ' . $ps_state, MSG_LOG_ERROR );
				next_state( 'BEGIN' );
				$done = TRUE;

		} // switch
		$ps_state = current_state();
//		echo message_log_format( $msg_log );
		echo message_log_table( $msg_log );
	} while (!$done);
	$_SESSION[ 'campaigns' ] = $campaigns;
	$_SESSION[ 'headers'   ] = $headers;
	$_SESSION[ 'details'   ] = $details;
	$_SESSION[ 'cont_key'  ] = $cont_key;
} // process_state
function parse_xml($context_node, $xpath)
{
    $function_process_string = '';
    // set to zero sized string before starting
    // Go through the various types of elements within generator_data.xml
    if ($context_node->nodeName == 'choice') {
        $how_many_options = $xpath->evaluate("count(option[not(@condition) or contains(@condition,'{$_GET['is_name']}') or contains(@condition,'{$_GET['has_category']}')])", $context_node);
        /* count number of available options whithin a choice element. An "option" element is available if it has no condition at all
         * or if it has the appropriate condition. i.e. if the current user input data meets the condition of the current option element:
         * i.e. if condition contains the value of the $_GET variables set based upon the DBpedia data.
         * 
         */
        $random_number = rand(1, $how_many_options);
        $option_taken = $xpath->evaluate("option[not(@condition) or contains(@condition,'{$_GET['is_name']}') or contains(@condition,'{$_GET['has_category']}')][{$random_number}]", $context_node);
        foreach ($option_taken->item(0)->childNodes as $parameter_for_parse) {
            $function_process_string .= parse_xml($parameter_for_parse, $xpath);
        }
    } else {
        if ($context_node->nodeName == 'determination') {
            $test_field = $context_node->getAttribute('field');
            $test_field_value = $_GET[$test_field];
            $determination_to_take = $xpath->evaluate("if[contains(@equal_to,'{$test_field_value}')]", $context_node);
            foreach ($determination_to_take->item(0)->childNodes as $parameter_for_parse) {
                $function_process_string .= parse_xml($parameter_for_parse, $xpath);
            }
        } else {
            if ($context_node->nodeName == 'replace') {
                $function_process_string .= replace_dangerous_chars($_GET[$context_node->getAttribute('with')]);
            } else {
                if ($context_node->nodeName == 'wiki_link') {
                    $function_process_string .= '<a href="' . $_GET['wikipedia_address'] . '">';
                    foreach ($context_node->childNodes as $parameter_for_parse) {
                        $function_process_string .= parse_xml($parameter_for_parse, $xpath);
                    }
                    $function_process_string .= '</a>';
                } else {
                    if ($context_node->nodeType == 3) {
                        $function_process_string .= $context_node->nodeValue;
                    }
                }
            }
        }
    }
    return $function_process_string;
}
Пример #9
0
            } else {
                $macro['uid'] = $props[2];
                $macro['name'] = $props[0];
                $macro['sort'] = $props[1];
                // $macro['uid'] = $props[3];
                $macro['match'] = strtolower($macro['name']);
            }
            // endif
            $macros[] = $macro;
        }
        // endforeach
    }
    // endforeach
    return $macros;
}
$macros = parse_xml();
if (!$macros) {
    $w->result('reeder.result', 'na', 'No results found', 'No search results found matching your query', 'icon.png', 'no');
} elseif ($filter) {
    // If keyword is given, do a filter
    foreach ($macros as $macro) {
        // Very simple filtering, but works quite well.
        // Real fuzzy matching would be nice, but thats a wishlist item.
        $match = strpos($macro['match'], $filter);
        if ($match !== false) {
            $w->result($macro['uid'], $macro['uid'], $macro['name'], $macro['name'], 'icon.png', 'yes');
        }
    }
    // If no matches, return this.
    if (!$w->results()) {
        $w->result('reeder.result', 'na', 'No results found', 'No macros matched your query', 'icon.png', 'no');
Пример #10
0
 * Time: 21:04
 */
/*
 * Dit script wacht telkens een uur, start zo nodig een retrieval job,
 */
chdir(__DIR__);
define("XML_FILE", __DIR__ . "/100m.xml");
define("MAX_SIZE_HOUR", 32 * 1024 * 1024);
// max 32mb per uur
require 'vendor/autoload.php';
require 'functions.php';
require 'Job.php';
use Aws\Glacier\GlacierClient;
define("VAULT", "Backups_Server");
$start_time = new \DateTime();
parse_xml(XML_FILE);
$running_jobs = get_running_jobs();
$most_recent_job = null;
// download running jobs
foreach ($running_jobs as $job) {
    $oResult = client()->describeJob(array('accountId' => '-', 'vaultName' => VAULT, 'jobId' => $job->get("jobId")));
    if ($oResult->get('StatusCode') == "Succeeded") {
        downloadJob($job);
    } elseif ($oResult->get('StatusCode') == "Failed") {
        $job->set('running', 0);
    }
}
// controleer of er een job gestart is in het afgelopen uur
foreach (parts() as $job) {
    if (!$job->get('start_time') instanceof \DateTime) {
        continue;
Пример #11
0
    $filters[$id] = unserialize(base64_decode($filter));
}
$host = "soylentnews.org";
$feed_uri = "/index.xml";
$port = 443;
$msg = chr(3) . "08" . "********** " . chr(3) . "03" . chr(2) . "SOYLENTNEWS COMMENT FEED" . chr(2) . chr(3) . "08" . " **********";
pm(MAIN_FEED_CHANNEL, $msg);
$last_cid = 87400;
if (file_exists(COMMENTS_CID_FILE) == True) {
    $last_cid = file_get_contents(COMMENTS_CID_FILE);
}
$msg = "last cid = {$last_cid}";
pm(MAIN_FEED_CHANNEL, $msg);
$response = wget($host, $feed_uri, $port, ICEWEASEL_UA, "", 60);
$html = strip_headers($response);
$items = parse_xml($html);
$topcomments = array();
if (file_exists(COMMENTS_TOP_FILE) == True) {
    $data = file_get_contents(COMMENTS_TOP_FILE);
    $topcomments = explode("\n", $data);
    delete_empty_elements($topcomments);
}
$cids = array();
$item_count = 20;
term_echo("*** comment_feed: {$item_count} feed stories to check");
$top_score_pub = 0;
$count_new = 0;
$count_top = 0;
for ($i = 0; $i < $item_count; $i++) {
    if (isset($items[$i]) == False) {
        continue;
// assign them to smarty
$smarty->assign('searches', $searches);
// if a query has been selected
$no_instand_submit = true;
if (isset($_GET['query'])) {
    $no_instand_submit = false;
    //smarty needs to now this for adding it to the link again
    $smarty->assign('query', $_GET['query']);
    // get xml string for that query
    $sql = "SELECT xml from {$config_vars['table_prefix']}custom_searches WHERE id={$_GET['query']}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, "Error in sql", '', __LINE__, __FILE__, $sql);
    }
    $row = $db->sql_fetchrow($result);
    // generate param array
    $query_sql = parse_xml($row[0]);
    //print_r($query_sql->entities);
    // generate info for template
    $x = 0;
    $y = -1;
    foreach ($query_sql->entities as $query_part) {
        $loops = 0;
        if (get_class($query_part) == 'custom_sql') {
            $no_instand_submit = true;
            $loops++;
            foreach ($query_part->entities as $value) {
                if (get_class($value) == 'sql_field') {
                    $y++;
                    field_param($value, $query_sql);
                }
            }
<?php

require_once 'wp-load.php';
require_once 'wp-content/plugins/lba-doorlinken-voorraad/class.xml-parser.php';
/**
 * Voorbeeld van een PHP script dat de voorraadmutaties (incrementele methode)
 * die Hexon vestuurt verwerkt
 *
 */
// if($_SERVER['REMOTE_ADDR'] != '82.94.237.8' && $_SERVER['REMOTE_ADDR'] != '82.94.240.8') {
//  // Aanvraag komt niet van Hexon Server
//  exit;
// }
define('__PREFIX__', 'occasion_');
$xmldoc = file_get_contents('php://input');
$state_xml = parse_xml($xmldoc);
$status = (string) $state_xml['actie'];
$result = XML2Array::createArray($xmldoc);
$xml = (object) $result['voertuig'];
$hexon_nr = addslashes((string) $xml->voertuignr_hexon);
// var_dump($xml->lease['contract']);
// var_dump($xml->meeneemprijs['@attributes']['bpm']);
// die;
// CUSTOM TAXONOMIES
$custom_tax = array();
$tax_args = array(__PREFIX__ . 'brand' => array(addslashes((string) $xml->merk) => array(addslashes((string) $xml->model))), __PREFIX__ . 'body' => array(addslashes((string) $xml->carrosserie)), __PREFIX__ . 'doors' => array(addslashes((string) $xml->aantal_deuren)), __PREFIX__ . 'fuel' => array(addslashes((string) $xml->brandstof)), __PREFIX__ . 'transmission' => array(addslashes((string) $xml->transmissie)), __PREFIX__ . 'year' => array(addslashes((string) $xml->bouwjaar)), __PREFIX__ . 'accessoires' => (array) $xml->accessoires);
/**
 * aaaaaaaaaaaaaaaaaa ->>>>>>>>>>>
 */
// var_dump(addslashes( (string) $xml->afbeeldingen['afbeelding'] ));die;
// var_dump($result);
Пример #14
0
<?php

include "xml_parser.php";
$raw_xml_data = file_get_contents("pkg1_client.xml");
$synchdr = parse_xml($raw_xml_data, new xml_offset_mapper(array("SYNCML", "SYNCHDR")));
printf("Message %d from %s\n", $synchdr["MSGID"][0][SYNCML_XML_DATA], $synchdr["SOURCE"][0]["LOCURI"][0][SYNCML_XML_DATA]);
unset($synchdr);
$syncbody = parse_xml($raw_xml_data, new xml_offset_mapper(array("SYNCML", "SYNCBODY")));
foreach ($syncbody[SYNCML_XML_ORIGINAL_ORDER] as $command) {
    if ($command[SYNCML_XML_TAG_NAME] != "FINAL") {
        printf("Command ID %d (%s)\n", $command["CMDID"][0][SYNCML_XML_DATA], $command[SYNCML_XML_TAG_NAME]);
    }
}