/** * function get_conversation() * This function gets the conversation format * @param array $convoArr - the conversation array * @return array $convoArr **/ function get_conversation($convoArr) { $conversation = get_conversation_to_display($convoArr); runDebug(__FILE__, __FUNCTION__, __LINE__, "Processing conversation as " . $convoArr['conversation']['format'], 4); switch ($convoArr['conversation']['format']) { case "html": $convoArr = get_html($convoArr, $conversation); break; case "json": $convoArr = get_json($convoArr, $conversation); break; case "xml": $convoArr = get_xml($convoArr, $conversation); break; } return $convoArr; }
function merge_xml($xml1, $xml2) { $xml1 = get_xml($xml1); $xml2 = get_xml($xml2); foreach ($xml2 as $tag => $elem2) { if (!$xml1->{$tag}) { $xml1->{$tag} = trim((string) $elem2); } if (count($elem2->attributes())) { foreach ($elem2->attributes() as $attr => $value) { $xml1->{$tag}->addAttribute($attr, $value); } } if ($elem2->count()) { merge_xml($xml1->{$tag}, $elem2); } } return $xml1; }
curl_close($ch); $news = xml2array($data); return $news; } $html = scraperwiki::scrape("http://www.cicregulator.gov.uk/coSearch/companyList.shtml"); $dom = new simple_html_dom(); $dom->load($html); $rows = $dom->find('tr'); // Dump the first element of the array as it contains headers array_shift($rows); foreach ($rows as $row) { $name = $row->children[0]->plaintext; $number = $row->children[1]->plaintext; $location = $row->children[2]->plaintext; $url = "http://opencorporates.com/companies/uk/" . $number . ".xml"; $xml = get_xml($url); ///sometimes the xml source file isn't found or is a 404 page or an error response if (empty($xml) || isset($xml['html']) || isset($xml['head']) && isset($xml['head']['title']) && isset($xml['head']['title']['value']) && $xml['head']['title']['value'] == 'Error response') { continue; } if (!isset($xml['company'])) { print_r(array('xml' => $xml, 'url' => $url, 'isset' => isset($xml), 'is_array' => is_array($xml), 'empty' => empty($xml))); die; } if (isset($xml['company']['incorporation-date']) && isset($xml['company']['incorporation-date']['value'])) { $incorporationdate = $xml['company']['incorporation-date']['value']; } else { $incorporationdate = ''; } if (isset($xml['company']['registered-address-in-full']) && isset($xml['company']['registered-address-in-full']['value'])) { $address = $xml['company']['registered-address-in-full']['value'];
if ($_GET) { // Replace this with your API Key - you can sign up at http://policeapi.rkh.co.uk/signup/ $key = "ENTER-API-KEY"; $postcode = str_replace(" ", "", $_GET['postcode']); // This gets the details of the policing team and police force $getteam = get_xml("http://policeapi.rkh.co.uk/api/geocode-team?key=" . $key . "&q=" . $postcode); $teamid = $getteam['police-api']['response']['team']['team-id']['value']; $forceid = $getteam['police-api']['response']['team']['force-id']['value']; $team = get_xml("http://policeapi.rkh.co.uk/api/team?key=" . $key . "&force=" . $forceid . "&team=" . $teamid); $members = get_xml("http://policeapi.rkh.co.uk/api/team-people?key=" . $key . "&force=" . $forceid . "&team=" . $teamid); //This gets the crime area ID and crime data from the last 15 months $getcrimearea = get_xml("http://policeapi.rkh.co.uk/api/geocode-crime-area?key=" . $key . "&q=" . $postcode); $crimearea = $getcrimearea['police-api']['response']['areas']['area'][3]['area-id']['value']; $crime = get_xml("http://policeapi.rkh.co.uk/api/crime-area?key=" . $key . "&force=" . $forceid . "&area=" . $crimearea . "&compare=local"); // This gets the nearest police station $station = get_xml("http://policeapi.rkh.co.uk/api/nearest-police-station?key=3bca9c7a2e301f130c4e18093dec3ca5&q=ws149sq"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Police Information</title> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/grid.css" /> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/typography.css" /> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/forms.css" /> <link type="text/css" rel="stylesheet" href="style.css" /> </head> <body> <div style="width: 90%; margin: 10px auto;"> <h1>My Police Information</h1>
{ $headers[] = "Accept-Encoding: gzip"; //see: http://trog.qgl.org/20110729/differences-in-requesting-gziped-content-using-curl-in-php/ $ch = curl_init(); if (!$ch) { $MainMSG = "Kindly let Webmaster know, thru email: <a href=\"mailto:someone@someplace.com\"><b>Webmaster</b></a>"; #---- email the error ----> emailUs($url); die("Couldn't initialize a cURL handle to access file: >>> " . $url . "<<<.<br>\n" . $MainMSG . "<br>"); exit(1); // A response code other than 0 is a failure } curl_setopt($ch, CURLOPT_URL, $url); #curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // The number of seconds to wait while trying to connect. curl_setopt($ch, CURLOPT_TIMEOUT, 5); // Timeout in seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, '*****@*****.**'); ob_start(); //--- Start buffering $data = curl_exec($ch); ob_end_clean(); //--- End buffering and clean output curl_close($ch); return $data; } /////////////////////////////////////////////////////////////////////// $url = "http://www.someplace_unique.com/data/nwsweatherstory.kml"; $contents_of_XML_file = get_xml($url); echo $contents_of_XML_file;
} if (isset($type)) { if ($type) { $type = ucfirst(strtolower($type)); $filename = './Models/' . $type . 'Model.php'; if (file_exists($filename)) { include_once $filename; } else { include_once './Models/UrlModel.php'; } } else { include_once './Models/UrlModel.php'; } } else { include_once './Models/UrlModel.php'; } if (isset($id)) { if ($id) { !$pid && ($pid = 2); //isset($_COOKIE["pidcookie"])&&$pid=$_COOKIE["pidcookie"]; $t = getvideo($id, $pid); echo get_xml($t); die; } else { echo '错误的调用参数'; die; } } else { echo '错误的调用参数'; die; }
<?php function get_xml($order_id, $item_id) { $orderxml = "<root>\n <user_id>1</user_id>\n <api_key>123</api_key>\n <api_pass>123</api_pass> \n <order_id>{$order_id}</order_id> <!-- which order which item for this user -->\n <item_id>{$item_id}</item_id> <!-- which item to remove --> \n</root>"; return $orderxml; } include "../config.php"; $apiurl = hostname . "api/xml/hotels/remove_order_items"; $order_id = isset($_GET['order_id']) ? (int) $_GET['order_id'] : 0; $item_id = isset($_GET['item_id']) ? (int) $_GET['item_id'] : 0; if ($order_id <= 0 || $item_id <= 0) { die("Order ID : {$order_id}, Item ID : {$item_id}"); } $payload = get_xml($order_id, $item_id); $request = Requests::post($apiurl, array(), array('__payload__' => $payload)); $result = simplexml_load_string($request->body); if ($result->success == 0) { //die($result->msg); } ?> <html> <head> <meta charset="UTF-8"> <title></title> <style> label {display: block; margin-bottom: 10px}; </style> </head> <body>
/** * Draws a form to add a new service to a virtual site * @return null */ function draw_form() { require_once '../xml_output/get_xml.php'; require_once '../web_portal/components/Get_User_Principle.php'; require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php'; if (!is_numeric($_REQUEST['s_group_id'])) { throw new Exception("Invalid service group ID"); } if (!is_numeric($_REQUEST['grid_id'])) { throw new Exception("Invalid grid ID"); } $vSiteId = $_REQUEST['s_group_id']; $gridId = $_REQUEST['grid_id']; authorize($vSiteId); // Get the vsite's data to show the name in the form $vSite = \Factory::getVSiteService()->getVSite($vSiteId, $gridId); $type_xml_string = get_xml('Draw_SE_Service_Types', null); $type_xml = simplexml_load_string($type_xml_string['XML_String']); foreach ($type_xml->group as $type) { $service_types[] = (string) $type->NAME; } $params = array('Service_Types' => $service_types, 'vSite' => $vSite[0], 'gridId' => $gridId); show_view("vsite/add_new_se_to_service_group.php", $params); }
if (isset($argv[1])) { $domain = $argv[1]; } else { die('Please specify a domain name.'); } // Get the XML $values = get_xml($domain); // Check if we have a sitemap or an index of sitemaps // If it's a sitemap index, get the individual sitemaps // and add their URLs to the array if ($values[0]['tag'] == 'SITEMAPINDEX') { foreach ($values as $value) { if ($value['tag'] == 'LOC') { if (strpos($value['value'], '.xml') !== FALSE) { $sitemap = str_replace($domain . '/', '', $value['value']); $new_values = get_xml($domain, $sitemap); $values = array_merge($values, $new_values); } } } } // Create an array of URLs $urls = array(); // Add URLs from the sitemap to the array foreach ($values as $value) { if ($value['tag'] == 'LOC') { if (strpos($value['value'], '.xml') === FALSE) { array_push($urls, $value['value']); } } }
$results = $db->fetch_assoc($sql); $url = $results['url']; $pointserver = $results['pointserver']; $rule = $results['rule']; $siteuser = $results['siteuser']; $sitepwd = $results['sitepwd']; $cookie = $results['cookie']; $hash = $results['hash']; if ($db->db_num_rows($sql) > 0) { if ($pointserver == $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_ADDR'] == '127.0.0.1' or $_SERVER['REMOTE_ADDR'] == '::1') { $up_arr['status'] = 'ing'; //echo "$url|$pointserver|$rule|$siteuser|$sitepwd|$cookie|$hash"; $scan_arr['target_url'] = $url; $scan_arr['scan_rule'] = $rule; $scan_arr['siteuser'] = $siteuser; $scan_arr['sitepwd'] = $sitepwd; $scan_arr['sitecookie'] = $cookie; $scan_arr['hash'] = $hash; echo base64_encode(json_encode($scan_arr)); $update = $db->update('scan_list', $up_arr, "status='new' and hash='{$hash}'"); } } else { $sql = "select * from `scan_list` where status='ing'"; $sf = $db->fetch_assoc($sql); $get_hash = $sf['hash']; if (!empty($get_hash)) { $url = "http://10.0.13.58/file.php?p={$get_hash}"; //echo $url; get_xml($url); } }
function parse_chapter_list(&$volume) { $list_xml = get_xml($volume['list_file']); $volume['chapters'] = array(); foreach ($list_xml->chapter as $chapter_xml) { $chapter = array(); $chapter['title'] = (string) $chapter_xml['title']; $chapter['line_start'] = (int) $chapter_xml['start']; $chapter['line_end'] = (int) $chapter_xml['end']; $chapter['is_valid'] = $chapter['line_start'] > -1 && $chapter['line_start'] <= $chapter['line_end']; $volume['chapters'][] = $chapter; } $imgs = $list_xml->imgs; $volume['has_pics'] = $imgs && $imgs->img && count($imgs->img) > 0; if ($volume['has_pics']) { $volume['pic_dir'] = $imgs['dir'] ? (string) $imgs['dir'] : $novel['id']; $volume['pic_prefix'] = (string) $imgs['prefix']; $volume['pic_suffix'] = (string) $imgs['suffix']; $volume['pictures'] = array(); foreach ($imgs->img as $picture_xml) { $picture = array(); $picture['file'] = $volume['pic_prefix'] . (string) $picture_xml['filename'] . (strlen((string) $picture_xml['suffix']) ? (string) $picture_xml['suffix'] : $volume['pic_suffix']); if ($picture_xml['insert']) { $picture['line_insert'] = (int) $picture_xml['insert']; $picture['name'] = '彩图' . (string) $picture_xml['filename']; } else { $picture['name'] = (string) $picture_xml['alt']; } if ($picture_xml['notfloat']) { $picture['not_float'] = preg_match('/^\\s*true\\s*$/', (string) $picture_xml['notfloat']) > 0; } if ($picture_xml['joinnext']) { $picture['join_next'] = preg_match('/^\\s*true\\s*$/', (string) $picture_xml['joinnext']) > 0; } if ($picture_xml['clearnext']) { $picture['clear_next'] = preg_match('/^\\s*true\\s*$/', (string) $picture_xml['clearnext']) > 0; } if ($picture_xml['clear']) { $picture['clear_style'] = preg_replace('/^\\s*(both|left|right)\\s*$/', '$1', (string) $picture_xml['clear']); } $volume['pictures'][] = $picture; } } return $volume; }
<li>We've recently updated this application so that it tests IATI files up to and including version 2.01.</li> <li>Use Auto Detect in the version selector and the application will try to test your data to the version it finds.</li> </ul> </div> </div> </div> <?php } else { ?> <?php if (isset($_SESSION['uploadedfilepath'])) { $file_path = $_SESSION['uploadedfilepath']; //Sanitise/Check this? } require_once 'functions/get_xml.php'; $dom = get_xml($file_path); if ($dom === FALSE) { return FALSE; } if (isset($dom)) { $sxe = @simplexml_import_dom($dom); } //$sxe = simplexml_load_file($file_path); if (!$sxe) { $_SESSION['wellformed'] = FALSE; $test_result = '<div class="alert alert-error"><strong>Sorry.</strong> This is not a well-formed xml file</div>'; $error_detail = "Failed loading XML<br/><ul>"; foreach (libxml_get_errors() as $error) { $error_detail .= "<li>" . $error->message . "</li>"; } $error_detail . "</ul>";
<?php include "xmlparse.php"; if ($_GET) { $postcode = str_replace(" ", "", $_GET['postcode']); $area = get_xml("http://neighbourhood.statistics.gov.uk/NDE2/Disco/SearchSByAByPostcode?LevelTypeId=14&Postcode=" . $postcode); $wardid = $area['ans1:SearchSByAByPostcodeResponseElement']['ns0:AreaFallsWithins']['ns0:AreaFallsWithin']['ns0:Area']['ns0:AreaId']['value']; $wardname = $area['ans1:SearchSByAByPostcodeResponseElement']['ns0:AreaFallsWithins']['ns0:AreaFallsWithin']['ns0:Area']['ns0:Name']['value']; $councilid = $area['ans1:SearchSByAByPostcodeResponseElement']['ns0:AreaFallsWithins']['ns0:AreaFallsWithin']['ns0:FallsWithin']['ns0:Area']['ns0:AreaId']['value']; $getwardsnac = get_xml("http://neighbourhood.statistics.gov.uk/NDE2/Disco/GetAreaDetail?AreaId=" . $wardid); $getcouncilsnac = get_xml("http://neighbourhood.statistics.gov.uk/NDE2/Disco/GetAreaDetail?AreaId=" . $councilid); $wardsnac = $getwardsnac['ans1:GetAreaDetailResponseElement']['ns0:AreaDetail']['ns0:ExtCode']['value']; $councilsnac = $getcouncilsnac['ans1:GetAreaDetailResponseElement']['ns0:AreaDetail']['ns0:ExtCode']['value']; $warddetail = get_xml("http://openlylocal.com/wards/snac_id/" . $wardsnac . ".xml"); $councildetail = get_xml("http://openlylocal.com/councils/snac_id/" . $councilsnac . ".xml"); $members = $warddetail['ward']['members']['member']; } $location = $xml['rss']['channel']['item'][0]['title']['value']; $details = explode(",", $location); $postcode = trim(str_replace(strstr($details[2], "heading"), "", $details[2])); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Who is my councillor?</title> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/grid.css" /> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/typography.css" /> <link type="text/css" rel="stylesheet" href="http://www.blueprintcss.org/blueprint/src/forms.css" /> <link type="text/css" rel="stylesheet" href="style.css" /> </head>
$os2w = $ll2w->toOSRef(); $eastingnorthing = $os2w->toSplitString(); $easting = $eastingnorthing['easting']; $northing = $eastingnorthing['northing']; $geohash = file_get_contents("http://geohash.org?q=" . $lat . "," . $lng . "&format=url"); if ($row['county'] != "00") { $county = get_xml("http://statistics.data.gov.uk/doc/local-authority/" . $row['county'] . ".rdf"); $countytitle = $county['rdf:RDF']['rdf:Description'][0]['skos:prefLabel']['value']; $countycode = $county['rdf:RDF']['rdf:Description'][0]['skos:notation']['value']; $district = electoralDistrict($easting, $northing); } print_r($district); $district = get_xml("http://statistics.data.gov.uk/doc/local-authority/" . $row['county'] . $row['district'] . ".rdf"); $districttitle = $district['rdf:RDF']['rdf:Description'][0]['skos:prefLabel']['value']; $districtcode = $district['rdf:RDF']['rdf:Description'][0]['skos:notation']['value']; $ward = get_xml("http://statistics.data.gov.uk/doc/electoral-ward/" . $row['county'] . $row['district'] . $row['ward'] . ".rdf"); $wardtitle = $ward['rdf:RDF']['rdf:Description'][0]['rdfs:label'][1]['value']; if ($_GET['format'] == "xml" || $_SERVER['HTTP_ACCEPT'] == "application/xml") { header("content-type: application/xml"); include "xml.php"; } elseif ($_GET['format'] == "json" || $_SERVER['HTTP_ACCEPT'] == "application/json") { header('Content-type: application/json'); include "json.php"; } elseif ($_GET['format'] == "rdf" || $_SERVER['HTTP_ACCEPT'] == "application/rdf+xml") { header("Content-type: application/rdf+xml"); include "rdf.php"; } elseif ($_GET['format'] == "csv" || $_SERVER['HTTP_ACCEPT'] == "text/csv") { header("Content-type: application/octet-stream"); include "csv.php"; } elseif (strlen($_GET['format']) == 0) { header("content-type: text/html");
* If the file upload is problematic, we issue and alert and present the upload form again * If successful we present a tabbed interface with info about the file. */ require_once 'pages/validate-xsd_functions.php'; require_once 'functions/detect_iati_version.php'; if (!isset($_SESSION['uploadedfilepath'])) { ?> <?php header('Location: index.php'); } else { ?> <?php $file_path = $_SESSION['uploadedfilepath']; //Sanitise/Check this? require_once 'functions/get_xml.php'; $xml = get_xml($file_path); if ($xml === FALSE) { return FALSE; } // Need this to prevent entity security problem $detected_version = detect_iati_version($xml); //Get the right schema to validate against //Has the version been set by the user to a valid IATI version? //echo $_SESSION["version"]; if (!isset($version) || $version == "auto") { //We put this in place so tests work! tests.php specifies the version already by this point. if (isset($_SESSION["version"]) && in_array($_SESSION["version"], $iati_versions)) { //$detected_version = check_iati_version($xml); $version = $_SESSION["version"]; //echo $version; } else {
if (in_array('setup', array($data['core_path'], $data['base_url'], $data['mgr_url']))) { print '"setup" is not allowed as a path or URL option because it is reserved for the installation process.'; $error_flag = true; } if (!filter_var($data['cmsadminemail'], FILTER_VALIDATE_EMAIL)) { print 'Invalid email address'; $error_flag = true; } // $data['database_type'] // $data['database_server'] // $data['database_user'] // No duplicates? e.g manager != connectors if ($error_flag) { goto ENTERNEWDATA; } $xml = get_xml($data); } else { // Get XML from config file $xml = file_get_contents($args['config']); // Fill $data array from XML (we need this data in order to do the unzipping correctly) $xmldata = simplexml_load_file($args['config']); $data['database_type'] = $xmldata->database_type; $data['database_server'] = $xmldata->database_server; $data['database'] = $xmldata->database; $data['database_user'] = $xmldata->database_user; $data['database_password'] = $xmldata->database_password; $data['database_charset'] = $xmldata->database_connection_charset; $data['database_collation'] = $xmldata->database_collation; $data['table_prefix'] = $xmldata->table_prefix; $data['cmsadmin'] = $xmldata->cmsadmin; $data['cmsadminemail'] = $xmldata->cmsadminemail;
<?php error_reporting(0); include_once './class/base.php'; include_once './class/vid.php'; if (!isset($_GET['u'])) { die('no url!'); } $url = base64_decode($_GET['u']); if (preg_match("/^[a-zA-Z0-9-_]{4,41}\\.[a-z0-9]{2,12}\$/", $url)) { $arr = explode('.', $url); $data['id'] = $arr[0]; $data['type'] = $arr[1]; } else { $data = getvideoid($url); if ($data['status'] < 0) { echo json_encode($data); die; } } if ($data['type']) { $filename = './class/' . $data['type'] . '.php'; if (file_exists($filename)) { include_once $filename; } else { include_once './class/url.php'; } } $t = getvideo($data['id']); echo get_xml($t, $data['type']);