function getdata($style, $parameter) { $array = array(); foreach ($parameter as $key => $value) { if (is_array($value)) { $parameter[$key] = implode(',', $value); } } $parameter['clientid'] = $this->blockdata['clientid']; $parameter['op'] = 'getdata'; $parameter['charset'] = CHARSET; $parameter['version'] = $this->blockdata['version']; $xmlurl = $this->blockdata['url']; $parse = parse_url($xmlurl); if (!empty($parse['host'])) { define('IN_ADMINCP', true); require_once libfile('function/importdata'); $importtxt = @dfsockopen($xmlurl, 0, create_sign_url($parameter, $this->blockdata['key'], $this->blockdata['signtype'])); } else { $importtxt = @file_get_contents($xmlurl); } if ($importtxt) { require libfile('class/xml'); $array = xml2array($importtxt); } $idtype = 'xml_' . $this->blockdata['id']; foreach ($array['data'] as $key => $value) { $value['idtype'] = $idtype; $array['data'][$key] = $value; } if (empty($array['data'])) { $array['data'] = null; } return $array; }
public function check_patch($ignore = 0) { global $_G; if (!$ignore && $_G['cookie']['checkpatch']) { return false; } require_once DISCUZ_ROOT . 'source/discuz_version.php'; require_once libfile('class/xml'); $versionpath = ''; foreach (explode(' ', substr(DISCUZ_VERSION, 1)) as $unit) { $versionpath = $unit; break; } $patchdir = 'http://upgrade.discuz.com/DiscuzX/' . $versionpath . '/'; $checkurl = $patchdir . 'md5sums'; $patchlist = dfsockopen($checkurl); if (defined('DISCUZ_FIXBUG')) { C::t('common_patch')->update_status_by_serial(1, DISCUZ_FIXBUG, '<='); } if ($patchlist) { $serial_md5s = explode("\r\n", $patchlist); $bound = intval(substr($serial_md5s[count($serial_md5s) - 2], 0, 8)); $maxpatch = intval(C::t('common_patch')->fetch_max_serial()); if (defined('DISCUZ_FIXBUG')) { $maxpatch = $maxpatch < DISCUZ_FIXBUG ? DISCUZ_FIXBUG : $maxpatch; } if ($bound > $maxpatch) { $insertarrlist = array(); foreach ($serial_md5s as $serial_md5) { $downloadpatch = $patch = ''; list($serial, $md5, $release) = explode(' ', $serial_md5); if ($serial > $maxpatch && (!$release || in_array(DISCUZ_RELEASE, explode(',', $release)))) { $downloadpatch = $patchdir . $serial . '.xml'; $patch = dfsockopen($downloadpatch); if (md5($patch) != $md5) { continue; } $patch = xml2array($patch); if (is_array($patch) && !empty($patch)) { $insertarr = array('serial' => intval($patch['serial']), 'rule' => serialize($patch['rule']), 'note' => $patch['note'], 'status' => 0, 'dateline' => $patch['dateline']); C::t('common_patch')->insert($insertarr); $insertarrlist[$insertarr['serial']] = $insertarr; } } } if ($insertarrlist && $_G['setting']['patch']['autoopened']) { foreach ($insertarrlist as $key => $patch) { $this->fix_patch($patch); } } if ($insertarrlist) { C::t('common_setting')->update('showpatchnotice', 1); include_once libfile('function/cache'); updatecache('setting'); } } } dsetcookie('checkpatch', 1, 60); return true; }
function xml2array($xml) { foreach ($xml->children() as $parent => $child) { $return["{$parent}"] = xml2array($child) ? xml2array($child) : "{$child}"; } return $return; }
function getLotteriesInfoFromAPI() { global $cfg; $xml = @file_get_contents($cfg['lottery_api_url']); $arrLotteries = xml2array($xml); $arrRet = array(); foreach ($arrLotteries['array'] as $lottery) { $arrUnit = array(); $arrUnit['currency'] = $lottery['array'][0]['currency']; $arrUnit['draw-time'] = $lottery['array'][0]['draw-time']; $arrUnit['id'] = $lottery['array'][0]['id']; $arrUnit['name'] = $lottery['array'][0]['name']; $arrUnit['time-zone'] = $lottery['array'][0]['time-zone']; $arrUnit['date'] = $lottery['array'][1]['array']['date']; $arrUnit['jackpot'] = $lottery['array'][1]['array']['jackpot']; $offsetTimezone = getTimezoneOffset($arrUnit['time-zone']); $lottery_timestamp = strtotime($arrUnit['date'] . ' ' . $arrUnit['draw-time']); $arrUnit['lottery-base-timestamp'] = $lottery_timestamp; $arrUnit['lottery-timestamp'] = $lottery_timestamp; $arrUnit['system-time'] = time() + $offsetTimezone * 3600; if ($arrUnit['discount-amount'] > 0) { $arrRet[] = $arrUnit; } } usort($arrRet, 'sortByOrder'); return $arrRet; }
function xml2array($xmlObject, $out = array()) { foreach ((array) $xmlObject as $index => $node) { $out[$index] = is_object($node) ? xml2array($node) : $node; } return $out; }
public function import($s) { require_once litepublisher::$paths->lib . 'domrss.class.php'; $a = xml2array($s); $urlmap = turlmap::i(); $urlmap->lock(); $cats = tcategories::i(); $cats->lock(); $tags = ttags::i(); $tags->lock(); $posts = tposts::i(); $posts->lock(); foreach ($a['rss']['channel'][0]['item'] as $item) { if ($post = $this->add($item)) { $posts->add($post); if (isset($item['wp:comment']) && is_array($item['wp:comment'])) { $this->importcomments($item['wp:comment'], $post->id); } if (!tfilestorage::$disabled) { $post->free(); } } } $posts->unlock(); $tags->unlock(); $cats->unlock(); $urlmap->unlock(); }
function process_result_stacking($xml_data) { $result = array(); $xml_array = xml2array($xml_data); //debug($xml_array); if (isset($xml_array['validstack']['unluck'])) { fianet_insert_log("fianet_sender.php - process_result_stacking() <br />\nError : <br />\n" . $xml_array['validstack']['unluck']['value']); return $result; } elseif (isset($xml_array['validstack']['result'])) { $xml_array = $xml_array['validstack']['result']; //debug($xml_array); if (isset($xml_array[0])) { foreach ($xml_array as $transaction_result) { $index = count($result); $result[$index]['refid'] = $transaction_result['attr']['refid']; $result[$index]['etat'] = $transaction_result['attr']['avancement']; $result[$index]['details'] = $transaction_result['detail']['value']; } } else { $index = count($result); $result[$index]['refid'] = $xml_array['attr']['refid']; $result[$index]['etat'] = $xml_array['attr']['avancement']; $result[$index]['details'] = $xml_array['detail']['value']; } } return $result; }
function xml2array($simplexml) { if (!is_object($simplexml)) { return array(); } $arr = array(); $lastk = ''; foreach ($simplexml as $k => $v) { $test = array(); $test = xml2array($v); $ck = (string) $k; if ($ck == $lastk) { $cur = count($arr); if ($cur <= 1) { $t = $arr[$lastk]; $arr = array($t); } $ck = count($arr); } if (empty($test)) { $arr[$ck] = urldecode((string) $v); } else { $arr[$ck] = $test; } $lastk = (string) $k; } return $arr; }
function xml2array($xml) { $xmlary = array(); $reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s'; $reattrs = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/'; preg_match_all($reels, $xml, $elements); foreach ($elements[1] as $ie => $xx) { $xmlary[$ie]["name"] = $elements[1][$ie]; if ($attributes = trim($elements[2][$ie])) { preg_match_all($reattrs, $attributes, $att); foreach ($att[1] as $ia => $xx) $xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia]; } $cdend = strpos($elements[3][$ie], "<"); if ($cdend > 0) { $xmlary[$ie]["text"] = substr($elements[3][$ie], 0, $cdend - 1); } if (preg_match($reels, $elements[3][$ie])) $xmlary[$ie]["elements"] = xml2array($elements[3][$ie]); else if ($elements[3][$ie]) { $xmlary[$ie]["text"] = $elements[3][$ie]; } } return $xmlary; }
function get_data_query_array($snmp_query_id) { global $config, $data_query_xml_arrays; include_once($config["library_path"] . "/xml.php"); /* load the array into memory if it hasn't been done yet */ if (!isset($data_query_xml_arrays[$snmp_query_id])) { $xml_file_path = db_fetch_cell("select xml_path from snmp_query where id=$snmp_query_id"); $xml_file_path = str_replace("<path_cacti>", $config["base_path"], $xml_file_path); if (!file_exists($xml_file_path)) { debug_log_insert("data_query", "Could not find data query XML file at '$xml_file_path'"); return false; } debug_log_insert("data_query", "Found data query XML file at '$xml_file_path'"); $data = implode("",file($xml_file_path)); $xml_data = xml2array($data); /* store the array value to the global array for future reference */ $data_query_xml_arrays[$snmp_query_id] = $xml_data; } return $data_query_xml_arrays[$snmp_query_id]; }
private function run($action, $xml = '') { $this->last_action = $action; $request = $this->build($action); $xml = str_replace('[CallerReference]', $request['callref'], $xml); $this->last_xml = $xml; // was having problems with wp http, so using staright curl $ch = curl_init($request['url']); curl_setopt($ch, CURLOPT_USERAGENT, 'YourMembers CloudFront Lib'); curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'get_etag')); if ($this->method == 'POST') { curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); } else { if ($this->method != 'GET') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method); if ($xml) { curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); } } } curl_setopt($ch, CURLOPT_HTTPHEADER, $request['headers']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); $this->result = $result; $data = xml2array($result, 1, 'nottag'); $this->info = $info; $r = $this->error_handle($data); if ($r) { return $r; } return $data; }
function xml2array($xmlContent, $out = array()) { $xmlObject = is_object($xmlContent) ? $xmlContent : simplexml_load_string($xmlContent); foreach ((array) $xmlObject as $index => $node) { $out[$index] = is_object($node) || is_array($node) ? xml2array($node) : $node; } return $out; }
/** * XML to object * * @version 1 * @author Rick de Man <*****@*****.**> * * @param object $xmlObject * @return object */ function xml2array($xmlObject) { // Create variable $result; // Loop throught object foreach ((array) $xmlObject as $index => $node) { // add data $result[$index] = is_object($node) ? xml2array($node) : $node; } // Return results return $result; }
function xml2array($xml) { $arr = array(); foreach ($xml->children() as $r) { $t = array(); if (count($r->children()) == 0) { $arr[$r->getName()] = strval($r); } else { $arr[$r->getName()][] = xml2array($r); } } return $arr; }
public static function XML2Array($xml) { $arr = array(); foreach ($xml as $element) { $tag = $element->getName(); $e = get_object_vars($element); if (!empty($e)) { $arr[$tag] = $element instanceof SimpleXMLElement ? xml2array($element) : $e; } else { $arr[$tag] = trim($element); } } return $arr; }
function xml2array($xml) { $return_array = array(); foreach ($xml->childNodes as $node) { $length = $node->childNodes->length; $key = $node->getAttribute('key'); if ($length == 1 and $node->firstChild->nodeType == XML_TEXT_NODE) { $return_array[$key] = $node->nodeValue; } else { $return_array[$key] = xml2array($node); } } return $return_array; }
protected function xml2array($xml) { $arr = []; foreach ($xml as $element) { $tag = $element->getName(); $e = get_object_vars($element); if (!empty($e)) { $arr[$tag] = $element instanceof SimpleXMLElement ? xml2array($element) : $e; continue; } $arr[$tag] = trim($element); } return $arr; }
function get_data_query_array($snmp_query_id) { global $config; include_once $config["library_path"] . "/xml.php"; $xml_file_path = db_fetch_cell("select xml_path from snmp_query where id={$snmp_query_id}"); $xml_file_path = str_replace("<path_cacti>", $config["base_path"], $xml_file_path); if (!file_exists($xml_file_path)) { debug_log_insert("data_query", "Could not find data query XML file at '{$xml_file_path}'"); return false; } debug_log_insert("data_query", "Found data query XML file at '{$xml_file_path}'"); $data = implode("", file($xml_file_path)); return xml2array($data); }
function dopost($postXml) { $postArray = xml2array($postXml); $postData = $postArray['xml']; error_log('token验证:' . print_R($postData, true), 3, dirname(__FILE__) . '/pay.log'); switch ($postData['MsgType']) { case 'event': $paramsData['Content'] = '欢迎访问WEB人生百科'; $paramsData['MsgType'] = 'text'; send_msg($postData, $paramsData); break; default: commonMsg($postData); } }
public function readAllFromSocket() { $message = ''; $read_more = true; $count = 1; do { $new_message = $this->readFromSocket(false); $message .= $new_message; if (trim($new_message) == '') { $read_more = false; } $count++; } while ($read_more); return xml2array($message); }
function pullLocation($ip) { if (preg_match('/^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:[.](?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$/', $ip)) { $xml = @file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key=55b9067222216786ca4c6cc0bc40abd1b978420333204fafeb48ec3d47ba8a9c&ip=' . $ip . '&format=xml'); //Break down the XML string $results = xml2array($xml); if (sizeof($results) > 0) { return "<span style='text-transform:capitalize;'>" . strtolower($results['Response']['cityName'] . " " . $results['Response']['regionName'] . " " . $results['Response']['countryName']) . "</span>"; exit; } else { return "<em>Unknown</em>"; exit; } } return "<em>Unknown</em>"; }
/** * fetch weather from cwb opendata http://opendata.cwb.gov.tw * @param url: opendata xml url * @return array cities weather data * */ function fetchWeather($url) { if (!strlen($url)) { return []; } $xmlstring = file_get_contents($url); $forecasting = xml2array($xmlstring); $cities = []; foreach ($forecasting['dataset']['location'] as $city) { $cityName = $city['locationName']; $cityName = str_replace('臺', '台', $cityName); $element = $city['weatherElement']; $cities[$cityName] = parseCityForecastData($element); } return $cities; }
function new_products_lightspeed($atts) { /** * Featured Products shortcode * * @param array $atts * @return string */ global $woocommerce_loop, $products, $product; // include our handy API wrapper that makes it easy to call the API, it also depends on MOScURL to make the cURL call require_once "MOSAPICall.class.php"; extract(shortcode_atts(array('per_page' => '12', 'columns' => '4', 'orderby' => 'date', 'order' => 'desc'), $atts)); $woocommerce_loop['columns'] = $columns; ob_start(); $mosapi = new MOSAPICall("992e498dfa5ab5245f5bd5afee4ee1ce6ac6e0a1ee7d11e36480694a9b5282e7", "83442"); $emitter = 'https://api.merchantos.com/API/Account/83442/ItemMatrix'; $xml_query_string = 'limit=100&orderby=timeStamp&orderby_desc=1&load_relations=["ItemECommerce","Tags","Images"]'; $products = $mosapi->makeAPICall("Account.ItemMatrix", "Read", null, null, $emitter, $xml_query_string); $wp_session = WP_Session::get_instance(); $products = xml2array($products); $wp_session['products'] = $products; //var_dump($wp_session['products']); $i = 0; //if ( $products->children() ) : ?> <?php woocommerce_product_loop_start(); ?> <?php foreach ($products as $prod) { foreach ($prod as $product) { wc_get_template_part('content', 'lightspeedproduct'); } } // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php //endif; return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>'; }
/** * Loads a INI file according the Language * * @version 1 * @author Rick de Man <*****@*****.**> * * @param string $File * location of the INI file * @param string $Lang * Requested Language * @param string $DefaultLang * Default Language * * @return array | false Array when found, false when failed */ function getxmlarray($File, $Lang = "", $DefaultLang = "") { $INI = str_replace('%1', $Lang, $File); if (file_exists($INI)) { // Load XML $XML = simplexml_load_file($INI); // XML to Array $XML = xml2array($XML); // Return XML array return $XML; } else { if ($DefaultLang !== "") { // Using Default Language return GetXmlArray(str_replace('%1', $DefaultLang, $File)); } } return false; }
function dealRequest($postXml) { $postArray = xml2array($postXml); $postData = $postArray['xml']; //LogUtil::logs("dealRequest ====>".print_R($postData,true), getLogFile("/business.log")); if ($postData['MsgType'] == "event") { $te = new TypeEvent(); $te->dealByAychReturn($postData); } elseif ($postData['MsgType'] == "text") { $tt = new TypeText(); $tt->deal($postData); } elseif ($postData['MsgType'] == "image") { $tt = new TypeImage(); $tt->deal($postData); } elseif ($postData['MsgType'] == "voice") { $tt = new TypeVoice(); $tt->deal($postData); } }
function getpagelink($city, $page, $updatetype = false) { global $_G; require_once libfile('class/xml'); $goodsxmlfile = MOKUAI_DIR . '/shop/1.0/Data/lashou_' . $city . '.xml'; $goodss = xml2array(file_get_contents($goodsxmlfile)); $goodslist_text = file_get_contents('http://' . $city . '.lashou.com/page' . $page); $ga0 = explode('<div class="content-list">', $goodslist_text); $ga1 = explode('<!-- main end -->', $ga0[1]); $ga2 = explode('<div class="com-img">', $ga1[0]); foreach ($ga2 as $k => $v) { $ga3 = explode('.lashou.com/deal/', $v); $ga4 = explode('.html', $ga3[1]); if ($ga4[0]) { $goodss[$ga4[0]]['oldid'] = $ga4[0]; } } file_put_contents($goodsxmlfile, diconv(array2xml($goodss, 1), "UTF-8", $_G['charset'] . "//IGNORE")); return $goodss; }
function get_country_name($country_code) { if ($country_code != "ALL" && strlen($country_code) != 2) { return ""; } $country_names_xml = "/usr/local/share/mobile-broadband-provider-info/iso_3166-1_list_en.xml"; $country_names_contents = file_get_contents($country_names_xml); $country_names = xml2array($country_names_contents); if ($country_code == "ALL") { $country_list = array(); foreach ($country_names['ISO_3166-1_List_en']['ISO_3166-1_Entry'] as $country) { $country_list[] = array("code" => $country['ISO_3166-1_Alpha-2_Code_element'], "name" => ucwords(strtolower($country['ISO_3166-1_Country_name']))); } return $country_list; } foreach ($country_names['ISO_3166-1_List_en']['ISO_3166-1_Entry'] as $country) { if ($country['ISO_3166-1_Alpha-2_Code_element'] == strtoupper($country_code)) { return ucwords(strtolower($country['ISO_3166-1_Country_name'])); } } return ""; }
function renderById($id, $base = "./") { $arrayMapping = xml2array($this->mapedPortlets); if (!$arrayMapping) { echo $this->ERRO_AT_LOADING_MAPPING; return; } $mappingCollection = null; $foundItens = false; foreach ($arrayMapping['mapping'] as $mapping) { if (is_array($mapping)) { $mapId = $mapping['id']; $mappingCollection = $mapping; } else { $mapId = $mapping; $mappingCollection = $arrayMapping['mapping']; } if ($id == $mapId) { $foundItens = true; foreach ($mappingCollection['item'] as $x => $item) { if (is_array($item)) { $fileNameOfItem = $item['file']; } else { $fileNameOfItem = $item; } if (!file_exists($fileNameOfItem)) { return false; } //$this->renderJavascript($id); include $fileNameOfItem; } } } if (!$foundItens) { echo $this->NOT_FOUND_ITENS; } }
/** * Obtiene la informacion del author del codigo, asi como * los puntos. * * @param string $codeName * @return array */ function codeInfo($codeName) { $fileName = 'code/' . $codeName . '/code.php'; $fileNameInfo = 'code/' . $codeName . '/info.txt'; if (@file_exists($fileName)) { include_once $fileName; $className = 'Battle_Code_' . $codeName; $info = array(); $infoInfo = array(); if (class_exists($className)) { $instance = new $className(); $info = $instance->info; unset($instance); } if (@file_exists($fileNameInfo)) { $infoInfo = xml2array($fileNameInfo); foreach ($infoInfo['info']['children'] as $name => $value) { $info[$name] = $value['data']; } } return $info; } return array(); }
function scan_kml($filepath) { $obj = xml2array(file_get_contents($filepath)); if (!empty($obj["kml"]["Document"]["Folder"])) { foreach ($obj["kml"]["Document"]["Folder"] as $n) { foreach ($n as $n_) { if (!try_fetch_href($n_, $filename)) { foreach ($n_ as $n__) { if (!try_fetch_href($n__, $filename)) { foreach ($n__ as $n___) { if (!try_fetch_href($n___, $filename)) { foreach ($n___ as $n____) { if (!try_fetch_href($n____, $filename)) { foreach ($n____ as $n_____) { if (!try_fetch_href($n_____, $filename)) { foreach ($n_____ as $n______) { if (!try_fetch_href($n______, $filename)) { } } } } } } } } } } } } } } }