function processXML($rawXML) { global $messageStack; //echo '<pre>' . $rawXML . '</pre>'; $rawXML = utf8_decode($rawXML); $rawXML = iconv("UTF-8", "UTF-8//IGNORE", $rawXML); //echo '<pre>' . $rawXML . '</pre>'; if (!($objXML = xml_to_object($rawXML))) { return false; } // parse the submitted string, check for errors //echo 'parsed string = '; print_r($objXML); echo '<br />'; if (DEBUG) { $messageStack->debug("\n\nobjXML array = " . serialize($objXML)); } $this->username = $objXML->Request->UserID; $this->password = $objXML->Request->Password; $this->version = $objXML->Request->Version; $this->function = $objXML->Request->Function; $this->action = $objXML->Request->Action; $this->validateUser($this->username, $this->password); $this->processOrder($objXML); $extra_response = NULL; if (sizeof($this->successful) > 0) { $result_code = '0'; $result_flag = 'success'; $extra_response .= xmlEntry('SuccessfulOrders', implode(', ', $this->successful)); } if (sizeof($this->failed) > 0) { $result_code = '90'; $result_flag = 'error'; $extra_response .= xmlEntry('FailedOrders', implode(', ', $this->failed)); } $this->responseXML($result_code, implode("<br />", $this->response), $result_flag, $extra_response); }
/** * Import an ODD document. * * @param string $xml The XML ODD. * * @return ODDDocument */ function ODD_Import($xml) { // Parse XML to an array $elements = xml_to_object($xml); // Sanity check 1, was this actually XML? if (!$elements || !$elements->children) { return false; } // Create ODDDocument $document = new ODDDocument(); // Itterate through array of elements and construct ODD document $cnt = 0; foreach ($elements->children as $child) { $odd = ODD_factory($child); if ($odd) { $document->addElement($odd); $cnt++; } } // Check that we actually found something if ($cnt == 0) { return false; } return $document; }
/** * Parse the xml into its components according to spec. * This first version is a little primitive. * * @param string $xml XML * * @return void */ private function _parse($xml) { $xml = xml_to_object($xml); // sanity check if (isset($xml->name) && strcasecmp($xml->name, "methodCall") != 0) { throw new CallException(elgg_echo('CallException:NotRPCCall')); } // method name $this->methodname = $xml->children[0]->content; // parameters $this->params = $xml->children[1]->children; }
function submitXML($id, $action = '', $hide_success = false, $inc_image = true) { global $messageStack; switch ($action) { case 'product_ul': if (!$this->buildProductUploadXML($id, $inc_image)) { return false; } $url = 'products.php'; break; case 'product_sync': if (!$this->buildProductSyncXML()) { return false; } $url = 'sync.php'; break; case 'confirm': if (!$this->buildConfirmXML()) { return false; } $url = 'confirm.php'; break; default: $messageStack->add(ZENCART_INVALID_ACTION, 'error'); return false; } //echo 'Submit to ' . ZENCART_URL . '/soap/' . $url . ' and XML string = <pre>' . htmlspecialchars($this->strXML) . '</pre><br />'; $this->response = doCURLRequest('POST', ZENCART_URL . '/soap/' . $url, $this->strXML); //echo 'XML response (at the PhreeBooks side from Zencart) => <pre>' . htmlspecialchars($this->response) . '</pre><br />' . chr(10); if (!$this->response) { return false; } if (!($results = xml_to_object($this->response))) { return false; } //echo 'Parsed string = '; print_r($results); echo '<br />'; $this->result = $results->Response->Result; $this->code = $results->Response->Code; $this->text = $results->Response->Text; if ($this->code == 0) { if (!$hide_success) { $messageStack->add($this->text, strtolower($this->result)); } return true; } else { $messageStack->add(ZENCART_TEXT_ERROR . $this->code . ' - ' . $this->text, strtolower($this->result)); return false; } }
require_once DIR_FS_MODULES . 'phreedom/classes/backup.php'; /************** page specific initialization *************************/ $working = new xml_builder(); $mod_xml = new backup(); /*************** Act on the action request *************************/ switch ($_REQUEST['action']) { case 'save': validate_security($security_level, 2); // read the input variables $mod = $_POST['mod']; $mod_admin = $mod . '_admin'; require_once DIR_FS_MODULES . $mod . '/classes/install.php'; $mod_info = new $mod_admin(); // read the existing xml file to set as base, if it exists if (file_exists(DIR_FS_MODULES . $mod . '/' . $mod . '.xml')) { $working->output = xml_to_object(file_get_contents(DIR_FS_MODULES . $mod . '/' . $mod . '.xml')); // fix some lists if (!is_array($working->output->Module->Table)) { $working->output->Module->Table = array($working->output->Module->Table); } $temp = array(); foreach ($working->output->Module->Table as $tkey => $table) { $tname = $table->Name; $temp[$tname] = $working->output->Module->Table[$tkey]; // copy most of the info // index keys if (isset($table->Key)) { if (!is_array($table->Key)) { $table->Key = array($table->Key); } foreach ($table->Key as $kkey => $index) {
//function to write text to a file pointer. The function is called //params: file_pointer, text variable, value function loop_write($file, $txt, $num) { for ($x = 1; $x <= $num; $x++) { fwrite($file, $txt); } } $x = 1; $y = 0; $z = 0; $val = 1; //Getting all the file_pointers, read and write pointers list($read_file, $write_file) = file_open(); //$output is the array which consists of the text fields which is obtained from the xml schema file list($data, $apparatus, $tabs) = xml_to_object($read_file[0], $val); //$number is the number of pages which will be present in the easyauthor framework wizard $aim = $data[$z++]; //****************************************************Generating process starts*****************************************************// //echo $read_file[$x]; fwrite($write_file, $read_file[$x++] . $data[$z++] . $read_file[$x++] . $aim . "</h4>\n </div>\n <div id='rootwizard'>\n <ul>"); for ($y = 1; $y <= $tabs[0]; $y++) { fwrite($write_file, "<li><a href='#tab" . $y . "' data-toggle='tab'>" . $tabs[$y] . "</a></li>"); } fwrite($write_file, $read_file[$x++]); loop_write($write_file, $read_file[$x++], 1); fwrite($write_file, $read_file[$x++]); for ($y = 1; $y <= $apparatus[0]; $y++) { fwrite($write_file, "<button type='button'>" . $apparatus[$y] . "</button> Click to get a " . $apparatus[$y] . "<br><br>"); } fwrite($write_file, $read_file[$x++] . "<img src=" . $data[$z++] . " alt='Finding g' style='width:600px;height:350px;'>" . $read_file[$x++]);
function deleteLabel($method = '', $shipment_id = '') { global $db, $messageStack; if (!$shipment_id) { $messageStack->add('Cannot delete shipment, shipment ID was not provided!', 'error'); return false; } $shipments = $db->Execute("select ship_date, tracking_id from " . TABLE_SHIPPING_LOG . " where shipment_id = " . $shipment_id); $tracking_number = $shipments->fields['tracking_id']; $strXML = $this->FormatUPSDeleteRequest($tracking_number); $url = MODULE_SHIPPING_UPS_TEST_MODE == 'Test' ? MODULE_SHIPPING_UPS_VOID_SHIPMENT_TEST : MODULE_SHIPPING_UPS_VOID_SHIPMENT; $SubmitXML = GetXMLString($strXML, $url, "POST"); // Check for XML request errors if ($SubmitXML['result'] == 'error') { $messageStack->add(SHIPPING_UPS_CURL_ERROR . $SubmitXML['message'], 'error'); return false; } $ResponseXML = xml_to_object($SubmitXML['xmlString']); $XMLFail = $ResponseXML->VoidShipmentResponse->Response->Error->ErrorCode; $XMLWarn = $ResponseXML->VoidShipmentResponse->Response->Error->ErrorSeverity; if ($XMLFail && $XMLWarn == 'Warning') { // soft error, report it and continue $messageStack->add('Label Delete Warning # ' . $XMLFail . ' - ' . $ResponseXML->VoidShipmentResponse->Response->Error->ErrorDescription, 'caution'); } elseif ($XMLFail && $XMLWarn != 'Warning') { // hard error - return with bad news $messageStack->add('Label Delete Error # ' . $XMLFail . ' - ' . $ResponseXML->VoidShipmentResponse->Response->Error->ErrorDescription, 'error'); return false; } // delete the label file $date = explode('-', $shipments->fields['ship_date']); $file_path = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $this->code . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/'; if (file_exists($file_path . $shipments->fields['tracking_id'] . '.lpt')) { $file_name = $shipments->fields['tracking_id'] . '.lpt'; } elseif (file_exists($file_path . $shipments->fields['tracking_id'] . '.gif')) { $file_name = $shipments->fields['tracking_id'] . '.gif'; } else { $file_name = false; // file does not exist, skip } if ($file_name) { if (!unlink($file_path . $file_name)) { $messageStack->add_session('Trouble deleting label file (' . $file_path . $file_name . ')', 'caution'); } } // if we are here the delete was successful, the lack of an error indicates success $messageStack->add_session('Successfully deleted the shipping label. Tracking # ' . $tracking_number, 'success'); return true; }
function table_import_xml($structure, $db_table, $filename) { //echo 'structure = '; print_r($structure); echo '<br>'; global $db; $data = file_get_contents($_FILES[$filename]['tmp_name'], "r"); $temp = $structure->Module->Table; foreach ($structure->Module->Table as $table) { if ($table->Name == $db_table) { $tbl_active = $table; $tbl_tagname = $table->TagName; break; } } if (!($result = xml_to_object($data))) { return false; } // fix some special cases, multi elements with single entries convert to arrays if (is_object($result->{$tbl_tagname})) { $result = array($result); } foreach ($result->{$tbl_tagname} as $entry) { $sql_array = array(); foreach ($tbl_active->Field as $field) { $tag = $field->TagName; if (isset($entry->{$tag})) { $sql_array[$field->Name] = $entry->{$tag}; } } //echo 'sql_array to write to table ' . DB_PREFIX . $db_table . ': '; print_r($sql_array); echo '<br>'; db_perform(DB_PREFIX . $db_table, $sql_array, 'insert'); // fetch the id for use with dependent tables $id = db_insert_id(); // now look into dependent tables if (is_object($tbl_active->LinkTable)) { $tbl_active->LinkTable = array($tbl_active->LinkTable); } if (isset($tbl_active->LinkTable)) { foreach ($tbl_active->LinkTable as $subtable) { $sub_sql_array = array(); $sub_sql_array[$subtable->DependentField] = $id; $sub_table_name = $subtable->Name; foreach ($temp as $working) { if ($subtable->Name == $working->Name) { $subtag = $working->TagName; foreach ($working->Field as $field) { $fieldtag = $field->TagName; if (isset($entry->{$subtag}->{$fieldtag})) { $sub_sql_array[$field->Name] = $entry->{$subtag}->{$fieldtag}; } } } } //echo 'sql_array to write to subtable ' . DB_PREFIX . $sub_table_name . ': '; print_r($sub_sql_array); echo '<br><br>'; db_perform(DB_PREFIX . $sub_table_name, $sub_sql_array, 'insert'); } } } }
$start_period = $start_period + 12; $runaway++; if ($runaway > 10) { break; } } if (DEBUG) { $messageStack->debug("\n loading chart of accounts"); } // load the retail chart as default if the chart of accounts table is empty $result = $db->Execute("select id from " . TABLE_JOURNAL_MAIN . " limit 1"); $entries_exist = $result->RecordCount() > 0 ? true : false; $result = $db->Execute("select id from " . TABLE_CHART_OF_ACCOUNTS . " limit 1"); $chart_exists = $result->RecordCount() > 0 ? true : false; if (!$entries_exist && !$chart_exists) { $accounts = xml_to_object(file_get_contents($default_chart)); if (is_object($accounts->ChartofAccounts)) { $accounts = $accounts->ChartofAccounts; } // just pull the first one if (is_object($accounts->account)) { $accounts->account = array($accounts->account); } // in case of only one chart entry if (is_array($accounts->account)) { foreach ($accounts->account as $account) { $sql_data_array = array('id' => $account->id, 'description' => $account->description, 'heading_only' => $account->heading, 'primary_acct_id' => $account->primary, 'account_type' => $account->type); db_perform(TABLE_CHART_OF_ACCOUNTS, $sql_data_array, 'insert'); } } }
function validateAddress($address) { // this can be called with ajax or directly global $messageStack; $output = array(); $xml = '?input=<VERIFYADDRESS>'; $xml .= '<COMMAND>ZIP1</COMMAND>'; $xml .= '<SERIALNO>830413</SERIALNO>'; // Phreesoft, LLC common Dial-A-Zip validation login info for use only with this module $xml .= '<USER>830413</USER>'; $xml .= '<PASSWORD>Phreedom_2012_LLC</PASSWORD>'; $xml .= '<ADDRESS0>' . urlencode(remove_special_chars($address->ship_primary_name)) . '</ADDRESS0>'; $xml .= '<ADDRESS1>' . urlencode(remove_special_chars($address->ship_contact)) . '</ADDRESS1>'; $xml .= '<ADDRESS2>' . urlencode(remove_special_chars($address->ship_address1) . ' ' . remove_special_chars($address->ship_address2)) . '</ADDRESS2>'; $xml .= '<ADDRESS3>' . urlencode(strtoupper($address->ship_city_town) . ', ' . strtoupper($address->ship_state_province) . ' ' . strip_alphanumeric($address->ship_postal_code)) . '</ADDRESS3>'; $xml .= '</VERIFYADDRESS>'; $result = file_get_contents(MODULE_SHIPPING_ENDICIA_DIAL_A_ZIP_URL . $xml); $result = substr($result, strpos($result, '>') + 1); $result = str_replace('<Dial-A-ZIP_Response>', '', trim($result)); $result = str_replace('</Dial-A-ZIP_Response>', '', trim($result)); $parts = xml_to_object($result); if ($parts->ReturnCode == '31') { $address->ship_contact = ''; $address->ship_address1 = $parts->AddrLine1; $address->ship_address2 = $parts->AddrLine2; $address->ship_city_town = $parts->City; $address->ship_state_province = $parts->State; $address->ship_postal_code = $parts->ZIP5 . '-' . $parts->Plus4; $response = array('result' => 'success', 'xmlString' => '<address>' . object_to_xml($address) . '</address>', 'message' => 'The address will be corrected per results from Dial-A-Zip.'); } else { $response = array('result' => 'error', 'message' => sprintf(SHIPPING_ENDICIA_ADD_VAL_ERROR, $parts->ReturnCode, $this->dialAZipCodes[$parts->ReturnCode])); } return $response; // xml string response }
$install_mod = new $classname(); $install_mod->load_reports($entry); } } } // load the files, parse, insert into db $rpt_cnt = 0; $orph_cnt = 0; $name_map = array(); $reports = scandir(PF_DIR_MY_REPORTS); foreach ($reports as $report) { if (substr($report, 0, 3) != 'pf_') { continue; } $rpt_id = substr($report, 3); $rpt = xml_to_object(file_get_contents(PF_DIR_MY_REPORTS . $report)); if ($rpt->PhreeformReport) { $rpt = $rpt->PhreeformReport; } // lose the container if ($rpt->security == 'u:-1;g:-1') { $rpt->security = 'u:' . $_SESSION['admin_id'] . 'g:-1'; } // orphaned, set so current user can access $result = $db->Execute("select id from " . TABLE_PHREEFORM . " where doc_group = '" . $rpt->groupname . "' and doc_type = '0'"); if ($result->RecordCount() == 0) { // orphaned put into misc category $orph_cnt++; $search_type = $rpt->reporttype == 'frm' ? 'misc:misc' : 'misc'; // put in misc $result = $db->Execute("select id from " . TABLE_PHREEFORM . " where doc_group = '" . $search_type . "' and doc_type = '0'");
function xml_to_object($xml = '') { global $messageStack; $xml = trim($xml); if ($xml == '') { return ''; } $output = new objectInfo(); $runaway = 0; while (strlen($xml) > 0) { if (strpos($xml, '<?xml') === 0) { // header xml, ignore $xml = trim(substr($xml, strpos($xml, '>') + 1)); } elseif (strpos($xml, '</') === 0) { // ending tag, should not happen $xml = trim(substr($xml, strpos($xml, '>') + 1)); } elseif (substr($xml, 0, 3) == '<![') { // it's data, clean up and return return substr($xml, strpos($xml, '[CDATA[') + 7, strrpos($xml, ']]') - strpos($xml, '[CDATA[') - 7); } elseif (substr($xml, 0, 1) == '<') { // beginning tag, process $tag = substr($xml, 1, strpos($xml, '>') - 1); $attr = array(); if (substr($tag, -1) == '/') { // the tag is self closing $selfclose = true; $tag = substr($xml, 1, strpos($xml, '>') - 2); $end_tag = '<' . $tag . '/>'; $taglen = strlen($tag) + 3; } else { $selfclose = false; $end_tag = '</' . $tag . '>'; $taglen = strlen($tag) + 2; } if (strpos($tag, ' ') !== false) { // there are tag properites $new_tag = substr($tag, 0, strpos($tag, ' ')); $end_tag = $selfclose ? '<' . $tag . '/>' : '</' . $new_tag . '>'; $temp = explode(' ', $tag); $tag = array_shift($temp); if (sizeof($temp) > 0) { foreach ($temp as $prop) { if ($prop) { $oneval = explode('=', $prop); $attr[$oneval[0]] = $onveal[1]; } } } } // TBD, the attr array is set but how to add to output? if (!$selfclose && strpos($xml, $end_tag) === false) { $messageStack->add('PhreeBooks XML parse error looking for end tag: ' . $tag . ' but could not find it!', 'error'); return false; } while (true) { $runaway++; if ($runaway > 10000) { return $messageStack->add('Runaway counter 1 reached. There is an error in the xml entry!', 'error'); } $data = $selfclose ? '' : trim(substr($xml, $taglen, strpos($xml, $end_tag) - $taglen)); if (isset($output->{$tag})) { if (!is_array($output->{$tag})) { $output->{$tag} = array($output->{$tag}); } array_push($output->{$tag}, xml_to_object($data)); } else { $output->{$tag} = xml_to_object($data); } $xml = trim(substr($xml, strpos($xml, $end_tag) + strlen($end_tag))); $next_tag = substr($xml, 1, strpos($xml, '>') - 1); if ($next_tag != $tag) { break; } } } else { // it's probably just plain data, return with it return $xml; } $runaway++; if ($runaway > 10000) { $messageStack->add('Runaway counter 2 reached. There is an error in the xml entry!', 'error'); } } return $output; }
} else { if ($tag['tag'] == 'num' && $tag['level'] == 2) { $count[0] = $tag['value']; } } $elements[$index]->name = $tag['tag']; $elements[$index]->attributes = $tag['attributes']; $elements[$index]->content = $tag['value']; if ($tag['type'] == "open") { // push $elements[$index]->children = array(); $stack[count($stack)] =& $elements; $elements =& $elements[$index]->children; } } if ($tag['type'] == "close") { // pop $elements =& $stack[count($stack) - 1]; unset($stack[count($stack) - 1]); } } //return array($tabs, $data); return array($type, $data, $count); } //Give the name of the xml file to be parsed $rfile1 = fopen("/var/www/html/config/telugu.xml", "r") or die("Unable to open file!"); $xml = fread($rfile1, filesize("/var/www/html/config/telugu.xml")); //Give the name of the attribute to be compared $val = 'name'; list($output1, $output2, $count) = xml_to_object($xml, $val);
function ImportReport($RptName = '', $RptFileName = '', $import_path = PF_DIR_DEF_REPORTS, $save_path = PF_DIR_MY_REPORTS) { global $db, $messageStack; $rID = ''; if ($RptFileName != '') { // then a locally stored report was chosen $path = $import_path . $RptFileName; } else { if (validate_upload('reportfile')) { $path = $_FILES['reportfile']['tmp_name']; } else { $messageStack->add(PHREEFORM_IMPORT_ERROR, 'error'); return false; } } $handle = fopen($path, "r"); $contents = fread($handle, filesize($path)); fclose($handle); if (strpos($contents, 'Report Builder Export Tool')) { // it's an old style report require_once DIR_FS_MODULES . 'phreeform/functions/reportwriter.php'; if (!($report = import_text_params(file($path)))) { return false; } } else { // assume it's a new xml type if (!($report = xml_to_object($contents))) { return false; } if (is_object($report->PhreeformReport)) { $report = $report->PhreeformReport; } // remove container tag } if ($RptName != '') { $report->title = $RptName; } // replace the title if provided // error check $result = $db->Execute("select id from " . TABLE_PHREEFORM . "\n\t where doc_title = '" . addslashes($report->title) . "' and doc_type <> '0'"); if ($result->RecordCount() > 0) { // the report name already exists, if file exists error, else write $rID = $result->fields['id']; if (file_exists($save_path . 'pf_' . $rID)) { // file exists - error and return $messageStack->add(sprintf(PHREEFORM_REPDUP, $report->title), 'error'); return false; } } if (!($result = save_report($report, $rID, $save_path))) { return false; } return true; }
} //file pointers initialized and pointed $wfile = fopen("/var/www/html/easyauthor/test.php", "w") or die("Unable to open file!"); $rfile = fopen("/var/www/html/config/telugu.xml", "r") or die("Unable to open file!"); $rfile1 = fopen("/var/www/html/src/stitch-1.txt", "r") or die("Unable to open file!"); $rfile3 = fopen("/var/www/html/src/stitch-3.txt", "r") or die("Unable to open file!"); $rfile5 = fopen("/var/www/html/src/stitch-5.txt", "r") or die("Unable to open file!"); //file pointers reading or writing $xml = fread($rfile, filesize("/var/www/html/config/telugu.xml")); $txt1 = fread($rfile1, filesize("/var/www/html/src/stitch-1.txt")); $txt3 = fread($rfile3, filesize("/var/www/html/src/stitch-3.txt")); $txt5 = fread($rfile5, filesize("/var/www/html/src/stitch-5.txt")); //$val is the variable which consists of the attribute in the xml file. You get the data which is enclosed in the attribute $val = 'name'; //$output is the array which consists of the text fields which is obtained from the xml schema file list($type, $data, $count, $tabs) = xml_to_object($xml, $val); //$number is the number of pages which will be present in the easyauthor framework wizard $number = $count[0]; //*********************************Generating process starts*******************************// //Initializing HTML and scripts fwrite($wfile, $txt1); //Specifing the language $txt = "\$" + "lang = {$lang}"; fwrite($wfile, $txt); //Tab generating,initializing and naming for ($x = 1; $x <= $number; $x++) { $word = $tabs[$x]; $txt2 = "<li><a href='#tab{$x}' data-toggle='tab'>{$word}</a></li>"; fwrite($wfile, $txt2); } fwrite($wfile, $txt3);
function queryUSPS($pkg, $user_choices, $num_packages) { // Fetch the book rates from USPS global $messageStack; $arrRates = array(); if (MODULE_SHIPPING_USPS_SERVER == 'production') { $strXML = 'API=RateV2&XML=' . $this->production_FormatUSPSRateRequest($pkg, $num_packages); $RateURL = 'http://Production.ShippingAPIs.com/ShippingAPI.dll'; } else { $strXML = 'API=RateV2&XML=' . $this->FormatUSPSRateRequest($pkg, $num_packages); $RateURL = 'http://testing.shippingapis.com/ShippingAPITest.dll'; } $SubmitXML = GetXMLString($strXML, $RateURL, "GET"); // Check for XML request errors if ($SubmitXML['result'] == 'error') { $messageStack->add(SHIPPING_USPS_CURL_ERROR . $SubmitXML['message'], 'error'); return false; } $ResponseXML = xml_to_object($SubmitXML['xmlString']); // Check for errors $XMLFail = $ResponseXML->Error->Number; if ($XMLFail) { // fetch the error code $XMLErrorDesc = $ResponseXML->Error->Description; $messageStack->add($this->code . ' - ' . $XMLFail . ' - ' . $XMLErrorDesc, 'error'); return false; } // Fetch the USPS Rates return $this->GetUSPSRateArray($ResponseXML); }
public function testElggPluginManifestFromXMLEntity() { $xml = xml_to_object($manifest_file = file_get_contents(get_config('path') . 'engine/tests/test_files/plugin_17/manifest.xml')); $manifest = new ElggPluginManifest($xml); $this->assertIsA($manifest, 'ElggPluginManifest'); }
$x->close(); ######## CREATE GEOJSON ######## CREATE GEOJSON ######## CREATE GEOJSON ###### $eventsCount = sizeof($events); $x2GeoStruct = array(); $x2ImpactStruct = array(); $toBeEncoded1 = array("type" => "FeatureCollection", "features" => []); for ($i = 0; $i < $eventsCount; $i++) { $toBeEncoded1[features][$i] = array("type" => "Feature", "geometry" => ["type" => "null", "coordinates" => []], "properties" => array("id" => $events[$i][id], "location" => "null", "description" => $events[$i][description], "planned" => "null", "alternativeRoute" => "N/A", "eventType" => $events[$i][eventType], "expectedResolution" => "null", "impact" => "null", "locationAreas" => "null", "status" => "null", "eventCreated" => $events[$i][startDate], "eventModified" => $events[$i][lastModified])); //function call to XMLStructReader.php script for conversion to struct $x2ImpactStruct[] = xml_to_object($events[$i][trafficImpactsXML]); $impactCount = sizeof($x2ImpactStruct[$i]->children); $tmpImpactString = ""; for ($p = 0; $p < $impactCount; $p++) { $tmpImpactString .= $x2ImpactStruct[$i]->children[$p]->content . ". "; } $x2GeoStruct[] = xml_to_object($events[$i][geoXML]); $geoCount = sizeof($x2GeoStruct[$i]->children); for ($j = 0; $j < $geoCount; $j++) { $tmpGeoType = $x2GeoStruct[$i]->children[0]->children[1]->content; $tmpCoords = $x2GeoStruct[$i]->children[0]->children[2]->content; //function call to helperFunctions.php $coordsFinal = convertCoords($tmpCoords); $closePolygon = array((double) $coordsFinal[0][0], (double) $coordsFinal[0][1]); $tmpFinalCoordLen = sizeof($coordsFinal); $coordsFinal[$tmpFinalCoordLen] = $closePolygon; } $toBeEncoded1[features][$i][properties][impact] = $tmpImpactString; $toBeEncoded1[features][$i][geometry][type] = "Polygon"; $toBeEncoded1[features][$i][geometry][coordinates] = [$coordsFinal]; } //
/** * Load and parse a plugin manifest from a plugin XML file. * * Example file: * * <plugin_manifest> * <field key="author" value="Curverider Ltd" /> * <field key="version" value="1.0" /> * <field key="description" value="My plugin description, keep it short" /> * <field key="website" value="http://www.elgg.org/" /> * <field key="copyright" value="(C) Curverider 2008-2010" /> * <field key="licence" value="GNU Public License version 2" /> * </plugin_manifest> * * @param string $plugin Plugin name. * @return array of values */ function load_plugin_manifest($plugin) { global $CONFIG; $xml = xml_to_object(file_get_contents($CONFIG->pluginspath . $plugin . "/manifest.xml")); if ($xml) { $elements = array(); foreach ($xml->children as $element) { $key = $element->attributes['key']; $value = $element->attributes['value']; $elements[$key] = $value; } return $elements; } return false; }
/** * Load a manifest file, XmlElement or path to manifest.xml file * * @param mixed $manifest A string, XmlElement, or path of a manifest file. * @param string $plugin_id Optional ID of the owning plugin. Used to * fill in some values automatically. */ public function __construct($manifest, $plugin_id = null) { if ($plugin_id) { $this->pluginID = $plugin_id; } // see if we need to construct the xml object. if ($manifest instanceof XmlElement) { $manifest_obj = $manifest; } else { if (substr(trim($manifest), 0, 1) == '<') { // this is a string $raw_xml = $manifest; } elseif (is_file($manifest)) { // this is a file $raw_xml = file_get_contents($manifest); } $manifest_obj = xml_to_object($raw_xml); } if (!$manifest_obj) { throw new PluginException(elgg_echo('PluginException:InvalidManifest', array($this->getPluginID()))); } // set manifest api version if (isset($manifest_obj->attributes['xmlns'])) { $namespace = $manifest_obj->attributes['xmlns']; $version = str_replace($this->namespace_root, '', $namespace); } else { $version = 1.7; } $this->apiVersion = $version; $parser_class_name = 'ElggPluginManifestParser' . str_replace('.', '', $this->apiVersion); // @todo currently the autoloader freaks out if a class doesn't exist. try { $class_exists = class_exists($parser_class_name); } catch (Exception $e) { $class_exists = false; } if ($class_exists) { $this->parser = new $parser_class_name($manifest_obj, $this); } else { throw new PluginException(elgg_echo('PluginException:NoAvailableParser', array($this->apiVersion, $this->getPluginID()))); } if (!$this->parser->parse()) { throw new PluginException(elgg_echo('PluginException:ParserError', array($this->apiVersion, $this->getPluginID()))); } return true; }
function initialize($loaded_modules) { global $db, $messageStack, $currencies; // load the latest currency exchange rates if (web_connected(false) && AUTO_UPDATE_CURRENCY && ENABLE_MULTI_CURRENCY) { gen_pull_language('phreedom', 'admin'); require_once DIR_FS_MODULES . 'phreedom/classes/currency.php'; $currency = new currency(); $currency->btn_update(); } // Fix for change to audit log for upgrade to R3.6 causes perpertual crashing when writing audit log if (!db_field_exists(TABLE_AUDIT_LOG, 'stats')) { $db->Execute("ALTER TABLE " . TABLE_AUDIT_LOG . " ADD stats VARCHAR(32) NOT NULL AFTER ip_address"); } // load installed modules and initialize them if (is_array($loaded_modules)) { foreach ($loaded_modules as $module) { if ($module == 'phreedom') { continue; } // skip this module require_once DIR_FS_MODULES . $module . '/classes/install.php'; $install_class = $module . '_admin'; $mod_init = new $install_class(); if (constant('MODULE_' . strtoupper($module) . '_STATUS') != constant('MODULE_' . strtoupper($module) . '_VERSION')) { // add any new constants if (sizeof($mod_init->keys) > 0) { foreach ($mod_init->keys as $key => $value) { if (!defined($key)) { write_configure($key, $value); } } } admin_install_dirs($mod_init->dirlist, DIR_FS_MY_FILES . $_SESSION['company'] . '/'); if (method_exists($mod_init, 'update')) { $mod_init->update($module); } } if (method_exists($mod_init, 'initialize')) { $mod_init->initialize($module); } } } if (web_connected(false) && CFG_AUTO_UPDATE_CHECK && SECURITY_ID_CONFIGURATION > 3) { // check for software updates $revisions = @file_get_contents(VERSION_CHECK_URL); if ($revisions) { $versions = xml_to_object($revisions); $latest = $versions->Revisions->Phreedom->Current; $current = MODULE_PHREEDOM_VERSION; if ($latest > $current) { $messageStack->add_session(sprintf(TEXT_VERSION_CHECK_NEW_VER, $current, $latest), 'caution'); } foreach ($loaded_modules as $mod) { // check rest of modules if ($mod == 'phreedom') { continue; } // skip this module $latest = $versions->Revisions->Modules->{$mod}->Current; $current = constant('MODULE_' . strtoupper($mod) . '_VERSION'); if ($latest > $current) { $messageStack->add_session(sprintf(TEXT_VERSION_CHECK_NEW_MOD_VER, $mod, $current, $latest), 'caution'); } } } } // Make sure the install directory has been moved/removed if (is_dir(DIR_FS_ADMIN . 'install')) { $messageStack->add_session(TEXT_INSTALL_DIR_PRESENT, 'caution'); } }
<?php include 'parse.php'; $rfile = fopen("/var/www/html/src/files/exp-1.xml", "r") or die("Unable to open file!"); $xml = fread($rfile, filesize("/var/www/html/src/files/exp-1.xml")); $val = 2; list($data, $apparatus, $tabs) = xml_to_object($xml, $val);
/***************** prepare to display templates *************************/ // build some general pull down arrays $sel_yes_no = array(array('id' => '0', 'text' => TEXT_NO), array('id' => '1', 'text' => TEXT_YES)); $sel_gl_desc = array(array('id' => '0', 'text' => TEXT_NUMBER), array('id' => '1', 'text' => TEXT_DESCRIPTION), array('id' => '2', 'text' => TEXT_BOTH)); $sel_order_lines = array(array('id' => '0', 'text' => TEXT_DOUBLE_MODE), array('id' => '1', 'text' => TEXT_SINGLE_MODE)); $sel_inv_due = array(array('id' => '0', 'text' => BNK_INVOICE_DATE), array('id' => '1', 'text' => BNK_DUE_DATE)); // load available charts based on language if (is_dir($dir = DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/charts')) { $charts = scandir($dir); } else { $charts = scandir(DIR_FS_WORKING . 'language/en_us/charts'); } $sel_chart = array(array('id' => '0', 'text' => TEXT_SELECT)); foreach ($charts as $chart) { if (strpos($chart, 'xml')) { $temp = xml_to_object(file_get_contents(DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/charts/' . $chart)); if ($temp->ChartofAccounts) { $temp = $temp->ChartofAccounts; } $sel_chart[] = array('id' => $chart, 'text' => $temp->description); } } // some pre-defined gl accounts $cash_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(0)); // cash types only $ar_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(2)); // ar types only $ap_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(20)); // ap types only $ocl_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(22)); // other current liability types only