function sendSMSAli($mobile, $mobile_code, $time = '', $mid = '') { include "TopSdk.php"; $c = new TopClient(); $c->appkey = "23294546"; //这里填写您申请的appkey $c->secretKey = "7f5f7a5d562089d01792ac5372f81d08"; //这里填写您申请的secretKey $req = new AlibabaAliqinFcSmsNumSendRequest(); $req->setExtend("123456"); //填写什么都可以 $req->setSmsType("normal"); //短信类型,不用修改 $req->setSmsFreeSignName("注册验证"); //这里填写短信签名 $req->setSmsParam("{\"code\":\"{$mobile_code}\",\"product\":\"技师达\"}"); //按要求引入变量 $req->setRecNum($mobile); //接收短信的手机变量 $req->setSmsTemplateCode("SMS_3991033"); //这里填写短信模板编号 $resp = $c->execute($req); $reArray = xmlToArray($resp); //返回结果 if (isset($reArray["code"]) && $reArray["code"] > 0) { return false; } else { return true; } }
function sendSMSAli($mobile, $mobile_code, $time = '', $mid = '') { include "TopSdk.php"; $c = new TopClient(); $c->appkey = "23278568"; //这里填写您申请的appkey $c->secretKey = "87410133aa8ab0cdfd2ba521209a3793"; //这里填写您申请的secretKey $req = new AlibabaAliqinFcSmsNumSendRequest(); $req->setExtend("123456"); //填写什么都可以 $req->setSmsType("normal"); //短信类型,不用修改 $req->setSmsFreeSignName("注册验证"); //这里填写短信签名 $req->setSmsParam("{\"code\":\"{$mobile_code}\",\"product\":\"钰盈堂净颜梅\"}"); //按要求引入变量 $req->setRecNum($mobile); //接收短信的手机变量 $req->setSmsTemplateCode("SMS_2950020"); //这里填写短信模板编号 $resp = $c->execute($req); $reArray = xmlToArray($resp); //返回结果 if (isset($reArray["code"]) && $reArray["code"] > 0) { return false; } else { return true; } }
/** * Create plain PHP associative array from XML. * * Example usage: * $xmlNode = simplexml_load_file('example.xml'); * $arrayData = xmlToArray($xmlNode); * echo json_encode($arrayData); * * @param SimpleXMLElement $xml The root node * @param array $options Associative array of options * @return array * @link http://outlandishideas.co.uk/blog/2012/08/xml-to-json/ More info * @author Tamlyn Rhodes <http://tamlyn.org> * @license http://creativecommons.org/publicdomain/mark/1.0/ Public Domain */ function xmlToArray($xml, $options = array()) { $defaults = array('namespaceSeparator' => ':', 'attributePrefix' => '', 'alwaysArray' => array(), 'autoArray' => true, 'textContent' => '$', 'autoText' => true, 'keySearch' => '@', 'keyReplace' => ''); $options = array_merge($defaults, $options); $namespaces = $xml->getDocNamespaces(); $namespaces[''] = null; //add base (empty) namespace //get attributes from all namespaces $attributesArray = array(); foreach ($namespaces as $prefix => $namespace) { foreach ($xml->attributes($namespace) as $attributeName => $attribute) { //replace characters in attribute name if ($options['keySearch']) { $attributeName = str_replace($options['keySearch'], $options['keyReplace'], $attributeName); } $attributeKey = $options['attributePrefix'] . ($prefix ? $prefix . $options['namespaceSeparator'] : '') . $attributeName; $attributesArray[$attributeKey] = (string) $attribute; } } //get child nodes from all namespaces $tagsArray = array(); foreach ($namespaces as $prefix => $namespace) { foreach ($xml->children($namespace) as $childXml) { //recurse into child nodes $childArray = xmlToArray($childXml, $options); list($childTagName, $childProperties) = each($childArray); //replace characters in tag name if ($options['keySearch']) { $childTagName = str_replace($options['keySearch'], $options['keyReplace'], $childTagName); } //add namespace prefix, if any if ($prefix) { $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName; } if (!isset($tagsArray[$childTagName])) { //only entry with this key //test if tags of this type should always be arrays, no matter the element count $tagsArray[$childTagName] = in_array($childTagName, $options['alwaysArray']) || !$options['autoArray'] ? array($childProperties) : $childProperties; } elseif (is_array($tagsArray[$childTagName]) && array_keys($tagsArray[$childTagName]) === range(0, count($tagsArray[$childTagName]) - 1)) { //key already exists and is integer indexed array $tagsArray[$childTagName][] = $childProperties; } else { //key exists so convert to integer indexed array with previous value in position 0 $tagsArray[$childTagName] = array($tagsArray[$childTagName], $childProperties); } } } //get text content of node $textContentArray = array(); $plainText = trim((string) $xml); if ($plainText !== '') { $textContentArray[$options['textContent']] = $plainText; } //stick it all together $propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || $plainText === '' ? array_merge($attributesArray, $tagsArray, $textContentArray) : $plainText; //return node as array return array($xml->getName() => $propertiesArray); }
public function notify() { //使用通用通知接口 $notify = new \Notify_pub(); //存储微信的回调 $xml = $GLOBALS['HTTP_RAW_POST_DATA']; $notify->saveData($xml); //验证签名,并回应微信。 //对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败, //微信会通过一定的策略(如30分钟共8次)定期重新发起通知, //尽可能提高通知的成功率,但微信不保证通知最终能成功。 if ($notify->checkSign() == FALSE) { $notify->setReturnParameter("return_code", "FAIL"); //返回状态码 $notify->setReturnParameter("return_msg", "签名失败"); //返回信息 } else { $notify->setReturnParameter("return_code", "SUCCESS"); //设置返回码 } $returnXml = $notify->returnXml(); echo $returnXml; //==商户根据实际情况设置相应的处理流程,此处仅作举例======= //以log文件形式记录回调信息 $log_ = new \Log_(); $time = date('Ymd', time()); $log_name = './logs/pay/jsAPI/' . $time . "notify_url.log"; $log_->log_result($log_name, "【接收到的notify通知】:\n" . $xml . "\n"); if ($notify->checkSign() == TRUE) { if ($notify->data["return_code"] == "FAIL") { //此处应该更新一下订单状态,商户自行增删操作 $log_->log_result($log_name, "【通信出错】:\n" . $xml . "\n"); //推送信息给用户 } elseif ($notify->data["result_code"] == "FAIL") { //此处应该更新一下订单状态,商户自行增删操作 $log_->log_result($log_name, "【业务出错】:\n" . $xml . "\n"); } else { $log_->log_result($log_name, "【业务成功】:\n\r\n"); //以上是业务代码 $jsAPInotify = D('JPN'); $object = xmlToArray($xml); $res = $jsAPInotify->jsAPINotifyUpO($object); $xml = "\n <xml>\n <return_code><![CDATA[" . $res . "]]></return_code>\n <return_msg><![CDATA[ITS OVER]]></return_msg>\n </xml>\n "; exit($xml); } } }
public static function convertXMLtoArr($xml, $root = true) { if (!$xml->children()) { return (string) $xml; } $array = array(); foreach ($xml->children() as $element => $node) { $totalElement = count($xml->{$element}); if (!isset($array[$element])) { $array[$element] = ""; } // Has attributes if ($attributes = $node->attributes()) { $data = array('attributes' => array(), 'value' => count($node) > 0 ? xmlToArray($node, false) : (string) $node); foreach ($attributes as $attr => $value) { $data['attributes'][$attr] = (string) $value; } if ($totalElement > 1) { $array[$element][] = $data; } else { $array[$element] = $data; } // Just a value } else { if ($totalElement > 1) { $array[$element][] = self::convertXMLtoArr($node, false); } else { $array[$element] = self::convertXMLtoArr($node, false); } } } if ($root) { return array($xml->getName() => $array); } else { return $array; } }
$xml_parser = array(); $orders_created_collection = array(); foreach ($files as $file) { $xmlfilename = $file_path . $file['filename']; if (in_array($jng_sp_id, $xmlwithgpg)) { $xmlfilename = str_replace('.gpg', '', $xmlfilename); } $xmlfile = file_get_contents($xmlfilename); if (file_exists($xmlfilename)) { $import_status = true; $import_date = date('Y-m-d H:i:s'); if ($jng_sp_id == '2') { /////////////// // Otto DE // /////////////// $arr_xml = xmlToArray($xmlfile); $OrderTags = isset($arr_xml["ottopartner"]["Orders"]['Order']['order-no']) ? $arr_xml["ottopartner"]["Orders"] : $arr_xml["ottopartner"]["Orders"]['Order']; $n_orders = count($OrderTags); if ($n_orders > 0) { foreach ($OrderTags as $sets_of_order) { $order = array(); $order['jng_sp_id'] = $jng_sp_id; $order['xml_file'] = basename($xmlfilename); $order['xml_date'] = 'null'; $order['iln_jng'] = 'null'; $order['iln_sp'] = 'null'; $order['sp_jng_id'] = $arr_xml["ottopartner"]["LKZ"]["value"]; $order['order_date'] = str_replace("T", " ", $sets_of_order["creation-date"]["value"]); $dateonly = date('Y-m-d', strtotime($order['order_date'])); if (!isset($daily_counter[$dateonly])) { $daily_counter[$dateonly] = $class_jo->nextDailyCounter($jng_sp_id, $dateonly);
<?php require_once 'funciones.php'; $url = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"; $result = 1; while ($result == 1) { $xmlNode = simplexml_load_file($url); $arrayData = xmlToArray($xmlNode); $result = saveCurrency($arrayData['Envelope']['Cube']['Cube']['Cube']); usleep(1200000000); }
/** * 退款 * @param $refund 退款申请记录 * @param $order 订单 */ function refund($refund, $order) { $http = http::getInstance(); $account = new \stdClass(); $account->transOut = $this->_system->get('splitpartner', 'alipay'); $account->amount = $this->_system->get('splitrate', 'alipay') * $refund['money']; $account->currency = 'CNY'; $split_fund_info = array($account); $data = array('service' => 'forex_refund', 'partner' => $this->_system->get('partner', 'alipay'), '_input_charset' => $this->_config['input_charset'], 'sign_type' => $this->_config['sign_type'], 'notify_url' => ($http->isHttps() ? 'https://' : 'http://') . $http->host() . '/gateway/alipay/notify.php', 'out_return_no' => $refund['refundno'], 'out_trade_no' => $order['orderno'], 'return_rmb_amount' => $refund['money'], 'currency' => 'EUR', 'gmt_return' => date("YmdHis", $refund['time']), 'reason' => $refund['reason'], 'product_code' => 'NEW_WAP_OVERSEAS_SELLER', 'split_fund_info' => json_encode($split_fund_info)); if ($order['client'] == 'web') { $data['product_code'] = 'NEW_OVERSEAS_SELLER'; } $data = $this->trade($data); $response = file_get_contents($this->_config['gateway_url'] . '?' . http_build_query($data)); $response = xmlToArray($response); return $response; }
if (($mode_xml || $mode_cxml) && !$mode_server && !$mode_output) { $trigger_wait_message = true; } } // END IF } // END IF if ($APP['ms']->kind != "no-messaging" && !$messaging_complete) { // WAIT FOR MESSAGE QUEUE RESPONSE $message = $new_job_id->receive("replyfrom_" . $selected_job_server_name); $all_messages .= $message . "<br/>\n"; if (($message . "" == "NULL" || strlen($message . "") == 0) && $cnt < 15) { sleep(1); continue; } $message_xml = xmlToArray(simplexml_load_string($message)); $collected_job_id = new job_id_user(); $collected_job_id->fromobjectxml($message_xml); if ($collected_job_id->id == $id_submitted_job) { $new_job_id->fromobjectxml($message_xml); $messaging_complete = True; } else { $all_messages .= "received a wrong message: " . htmlspecialchars($message); // we collected a message from anoth/er job - re-post the message to the queue so we don't end up stealing other jobs' responses $collected_job_id->send("replyfrom_" . $selected_job_server_name, $message); } } else { $new_job_id->get_from_hashrange($u->id_user, $new_job_id->id); } if ($new_job_id->id_status != 'running' && $new_job_id->id_status != 'new' && $new_job_id->id_status != 'paused') { // JOB IS DONE
<?php /* Returns the JSON-encoded data to the caller. */ // Load function that converts a simple XML object into an array. require_once 'xml-to-array.php'; // Convert the string into a simple XML document. $response_xml = simplexml_load_string($response_raw); // Convert the simple XML document to a PHP array. $response_array = xmlToArray($response_xml); // JSON encode the array. $response_json = json_encode($response_array); // Set HTTP status code to 200 ("OK"). header('Status: 200', TRUE, 200); // Return the result. echo $response_json;
} $this_http = "http"; if (isset($_SERVER['HTTPS'])) { if ($_SERVER['HTTPS'] == "on") { $this_http = "https"; } } if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"])) { if ($_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") { $this_http = "https"; } } $sample_config = str_replace("<uri value=\"{uri}\"/>", "<uri value=\"{$this_server_url}\"/>", $sample_config); // $sample_config is now an xml representation of the settings page // convert to php code $sample_config_xml_array = xmlToArray(simplexml_load_string($sample_config)); $sample_config = "<?php\n"; $sample_config .= "\$" . "settings="; $sample_config .= var_export($sample_config_xml_array, true) . ";"; $sample_config .= "\n"; $sample_config .= "\$GLOBALS['settings']=\$" . "settings;\n"; $sample_config .= "?" . ">"; $sample_config = trim($sample_config); if (file_put_contents($BIN_DIR . $PATH_SEPERATOR . "his-config.php", $sample_config) === FALSE) { $FILE_WRITE = false; } else { $FILE_WRITE = true; } } else { $FILE_WRITE = true; }
echo '支付失败,错误代码' . $dataArray['err_code'] . ':' . $dataArray['err_code'] . $dataArray['err_code_des']; } } else { echo $dataArray['return_msg']; exit; } echo $dataJson; exit; } else { echo getOrderStu($inf['stu']); } } if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) { $tmpmsg = array('touser' => $to, 'template_id' => 'oMhzLlRCMJ_vXQKQL9Yx12DsG8fXlIUzcz0qz4kb9SI', 'url' => 'http://www.qq.com', 'data' => array('first' => array('value' => '交易成功'), 'product' => array('value' => '测试商品1'), 'price' => array('value' => '1988.00'), 'time' => array('value' => '1月9日16:00'), 'remark' => array('value' => '欢迎再次选购'))); $error = array('return_code' => 'SUCCESS', 'return_msg' => 'OK'); $responseData = xmlToArray($GLOBALS["HTTP_RAW_POST_DATA"]); // mylog(getArrayInf($responseData)); if ('SUCCESS' == $responseData['return_code']) { if ('SUCCESS' == $responseData['result_code']) { if (signVerify($responseData)) { include_once '../wechat/serveManager.php'; $orderId = $responseData['out_trade_no']; pdoUpdate('order_tbl', array('stu' => "1"), array('id' => $orderId)); $payChkArray = array('first' => array('value' => '您在阿诗顿商城的网购订单已支付成功:'), 'orderno' => array('value' => $orderId, 'color' => '#0000ff'), 'amount' => array('value' => '¥' . $responseData['total_fee'] / 100, 'color' => '#0000ff'), 'remark' => array('value' => '商城即将安排发货,请留意物流通知')); $re = sendTemplateMsg($responseData['openid'], $template_key_order, '', $payChkArray); } else { } } else { } } else { }
function compareResults($resultNew, $resultOld) { $resultNew = normalizeResultBuffer($resultNew); $resultOld = normalizeResultBuffer($resultOld); if ($resultNew == $resultOld) { return array(); } $resultNew = xmlToArray($resultNew); $resultOld = xmlToArray($resultOld); if (!$resultNew && !$resultOld) { return array('failed to parse both XMLs'); } if (!$resultNew) { return array('failed to parse new XML'); } if (!$resultOld) { return array('failed to parse old XML'); } return compareArrays($resultNew, $resultOld, ""); }
include_once "model.storage.php"; $fs = new Settings_Storage_Adapter($settings); $fs = $fs->storage; $APP['fs'] = $fs; if (!$fs->connect()) { include "templates/existsmessage.php"; exit; } include_once "model.message.php"; $ms = new Settings_Message_Adapter($settings); $ms = $ms->messenger; $APP['ms'] = $ms; } /// SERVICES $services_file = $BIN_DIR . $PATH_SEPERATOR . "services.xml"; $service_doc = xmlToArray(simplexml_load_file($services_file)); $services = array(); foreach ($service_doc as $services_list) { foreach ($services_list as $service) { $new_service = new Service($service); $services[] = $new_service; } } //$GLOBALS['settings']=$settings; $APP['services'] = $services; $GLOBALS['APP'] = $APP; global $APP; class his { public $obj_key_type = 'hash'; public $obj_version;
public function notify() { $rsv_data = $GLOBALS['HTTP_RAW_POST_DATA']; $result = xmlToArray($rsv_data); $map["appid"] = $result["appid"]; $map["mchid"] = $result["mch_id"]; $info = M('member_public')->where($map)->find(); //获取公众号信息,jsApiPay初始化参数 $this->options['appid'] = $info['appid']; $this->options['mchid'] = $info['mchid']; $this->options['mchkey'] = $info['mchkey']; $this->options['secret'] = $info['secret']; $this->options['notify_url'] = $info['notify_url']; $this->wxpaycfg = new WxPayConfig($this->options); //发送模板消息 $TMArray = array("touser" => $result["openid"], "template_id" => "diW6jm5hBwemeoDF0FZdU2agSZ9kydje22YJIC0gVMo", "url" => "http://test.uctoo.com/index.php?s=/home/addons/execute/Ucuser/Ucuser/index/mp_id/107.html", "topcolor" => "#FF0000", "data" => array("name" => array("value" => "优创智投", "color" => "#173177"), "remark" => array("value" => "今天", "color" => "#173177"))); $options['appid'] = $info['appid']; //初始化options信息 $options['appsecret'] = $info['secret']; $options['encodingaeskey'] = $info['encodingaeskey']; $weObj = new TPWechat($options); $res = $weObj->sendTemplateMessage($TMArray); //回复公众平台支付结果 $notify = new PayNotifyCallBackController($this->wxpaycfg); // $notify->Handle(false); //处理业务逻辑 }
function xmlToArray($xml, $root = true) { if (!$xml->children()) { return (string) $xml; } $array = array(); foreach ($xml->children() as $element => $node) { $totalElement = count($xml->{$element}); if (!isset($array[$element])) { $array[$element] = ""; } // Has attributes if ($attributes = $node->attributes()) { $data = array('attributes' => array()); if (!count($node->children())) { $data['value'] = (string) $node; } else { $data = array_merge($data, xmlToArray($node, false)); } foreach ($attributes as $attr => $value) { $data['attributes'][$attr] = (string) $value; } if ($totalElement > 1) { $array[$element][] = $data; } else { $array[$element] = $data; } // Just a value } else { if ($totalElement > 1) { $array[$element][] = xmlToArray($node, false); } else { $array[$element] = xmlToArray($node, false); } } } if ($root) { return array($xml->getName() => $array); } else { return $array; } }
function xmlToArray($xml) { $array = json_decode(json_encode($xml), TRUE); if ($array) { if (count(array_slice($array, 0)) > 0) { foreach (array_slice($array, 0) as $key => $value) { if ($value === false || $value === "" || $value === NULL) { $array[$key] = NULL; // NULL } elseif (is_array($value)) { $array[$key] = xmlToArray($value); } } } } return $array; }
function importOttoB2BOrderFromXML($xml_uploaded_file) { $import_time = date('Y-m-d H:i:s'); $xmlfile = file_get_contents($xml_uploaded_file['tmp_name']); $xmlcontent = mb_convert_encoding($xmlfile, 'UTF-8', 'ISO-8859-1'); $arr_xml = xmlToArray($xmlcontent); return importOttoB2BOrderFromArray($arr_xml['OttoB2B:Order'], $xml_uploaded_file['name'], $import_time); }
public function alarmnotify() { $post_data = $GLOBALS['HTTP_RAW_POST_DATA']; \Think\Log::record("alarmnotify" . $post_data); $result = xmlToArray($post_data); $resp = true; $respdata["return_code"] = "SUCCESS"; $respdata["return_msg"] = ""; $map["appid"] = $result["appid"]; $map["mch_id"] = $result["mch_id"]; $map["openid"] = $result["openid"]; $map["out_trade_no"] = $result["out_trade_no"]; // while (true) { //alarmnotify和orderpaid调用时序无保证,未将历史订单的支付流水写入订单表就一直循环 $orderdata = M("mall_order_his")->where($map)->order('id DESC')->find(); if ($orderdata["id"] != "") { //已经记录过的订单数据 $map1["openid"] = $orderdata["openid"]; $map1["dcnum"] = $orderdata["out_trade_no"]; //TODO:进行安全校验,修订订单支付状态 $dddata = M("ml_mall_order")->where($map1)->order('id asc')->find(); if ($dddata["statekz"] == "0" || $dddata["statekz"] == "1") { //未支付,设置为已支付,没有记录交易流水的将交易流水写入订单表 M("mall_order")->where($map1)->save(array("statekz" => 1, "transaction_id" => $orderdata["transaction_id"])); } if ($resp == true) { //根据不同的错误设置返回数据 return arrayToXml($respdata); } else { return arrayToXml($respdata); } } else { $order = M("mall_order_his"); /* 保存附件 */ if ($order->create($result) && $order->add()) { $resp = true; } else { $resp = false; $respdata["return_msg"] = "保存订单数据错误"; } } }
function xmlToArray(SimpleXMLElement $xml, $skipattributes = false) { $return = array(); $_value = trim((string) $xml); if (!strlen($_value)) { $_value = null; } if ($_value !== null) { $return = $_value; } if (!$skipattributes) { $attributes = array(); foreach ($xml->attributes() as $name => $value) { $attributes[$name] = trim($value); } if ($attributes) { $return = array_merge($return, $attributes); } } $children = array(); $first = true; $skipattributes = false; foreach ($xml->children() as $elementName => $child) { if ($elementName == 'rowset') { $elementName = (string) $child->attributes()->name; $skipattributes = true; } if ($elementName == 'row') { $value = xmlToArray($child, $skipattributes); $children[] = $value; continue; } $value = xmlToArray($child, $skipattributes); if (isset($children[$elementName])) { if (is_array($children[$elementName])) { if ($first) { $temp = $children[$elementName]; unset($children[$elementName]); $children[$elementName][] = $temp; $first = false; } $children[$elementName][] = $value; } else { $children[$elementName] = array($children[$elementName], $value); } } else { $children[$elementName] = $value; } } if ($children) { $return = array_merge($return, $children); } return $return; }
unset($_SESSION['prev_page']); header("Location: index.php"); } else { $_SESSION['page'] = 'start'; header("Location: index.php"); } if (isset($_POST["patronid"])) { $cardNum = $_POST["patronid"]; //Get the Patron's Internal ID $patronLookup = xmlToArray(file_get_contents("{$opacURL}/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id={$cardNum}&id_type=cardnumber")); //Does the patron even exist... if (isset($patronLookup["id"])) { # var_dump($patronLookup); $patronID = $patronLookup["id"]; //Lets get the lowdown on the user $patronInfo = xmlToArray(file_get_contents("{$opacURL}/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id={$patronID}&show_fines=1&show_loans=1&show_contact=0")); #var_dump($patronInfo); if (isset($patronInfo["debarred"])) { $msg->add('d', "There is a restriction on your account preventing you from checking out books, please see the Circulation Desk to remove the restriction"); $_SESSION["patronDebarred"] = true; } if ($patronInfo["charges"] > 0) { $owes = $patronInfo["charges"]; if ($patronInfo["charges"] >= $maxFine) { $msg->add('d', "You owe \${$owes} and cannot checkout books, please see the Circulation Desk for more infomation and to pay your fine"); } else { $msg->add('w', "You owe \${$owes}, please see a the Circulation Desk for more infomation and to pay your fine"); } } //if ($patronInfo["charges"] > 0) $_SESSION['patronName'] = $patronInfo["firstname"] . ' ' . $patronInfo["surname"];
function expression_results_and_interface($OBJ_EXPR, $idx, $entire_match, $idt, $bool_buffer_output_merge) { global $db; global $mode_xml, $mode_edit, $mode_cxml, $mode_short, $mode_output; global $this_server_url, $q, $qn; global $standalone_code; global $STATIC; global $adjacent_dictionary; global $APP; global $mode_jidonly; global $settings; global $u; global $demo_domain; global $system_adjacent_dictionary_keys; $retval = array(); $retval['buffer'] = ""; // idx = tree # in the forest of trees // xml mode if ($mode_xml) { for ($in = 1; $in < $idt + 1; $in++) { echo "\t"; } echo "<result>\n"; for ($in = 1; $in < $idt + 2; $in++) { echo "\t"; } echo "<hfs>\n"; } // edit mode if ($mode_edit) { echo "<ul style='margin-left:0px;background-color:" . rcolor() . "'>"; //echo "<font size=-1>"; } // CUSTOM HEADER FIELDS/PRINTOUT $chead = ""; $chead_after_replace = ""; if (isset($OBJ_EXPR->obj_match_customs['0.header'])) { $chead = $OBJ_EXPR->obj_match_customs['0.header']->obj_txt->body; $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters); } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $chead_after_replace; } } $retval['buffer'] = $retval['buffer'] . $chead_after_replace; //if ($mode_cxml && !$mode_jidonly) echo $chead_after_replace; if ($mode_edit) { echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>"; echo getTranslation("Custom Header", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . "0"; echo "): "; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_key' value='0.header'/>"; echo "<textarea name='str_txt' rows='1' cols='50' style='width:500px;'>"; echo str_replace("<", "<", $chead); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; } if ($chead != $chead_after_replace && $mode_edit) { echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n"; } if ($mode_edit) { echo "<ul style='margin-left:5px;'>"; } $mi = 0; //print_r($entire_match); if (is_array($entire_match)) { foreach ($entire_match as $match_field) { // for each (each "(.*?)" field in the regex) $mi = $mi + 1; $this_value = $match_field; $filtering_expression = ""; $rid = 0; // CUSTOM HEADER FIELDS/PRINTOUT $custom_head = $OBJ_EXPR->obj_match_customs; $chead = ""; $chead_after_replace = ""; if ($custom_head) { if (isset($custom_head[$mi . '.header'])) { $chead = $custom_head[$mi . '.header']->obj_txt->body; $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters); } } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $chead_after_replace; } } $retval['buffer'] = $retval['buffer'] . $chead_after_replace; // CUSTOM HEADER GUI EDIT FIELD $this_box_color = ""; if ($mode_edit) { echo "<br/>"; echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Header", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . $mi . "): "; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_key' value='" . $mi . ".header'/>"; echo "<textarea rows='1' name='str_txt' style='width:500px;'/>"; echo str_replace("<", "<", $chead); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; if ($chead != $chead_after_replace) { echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n"; } echo "<br/>"; echo "<b><span style='margin-left:15px;'>" . getTranslation("FILTER RESULT VALUE", $settings) . " (" . getTranslation("Length", $settings) . ": " . strlen($this_value) . "):</span></b>\n"; echo "<ul style='margin-left:15px;'>"; $rows_textarea = 1; if (strlen($this_value) > 30) { //$rows_textarea=2; } echo "<textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='{$rows_textarea}' cols='60'>"; echo str_replace("<", "<", $this_value); //echo print_r($this_value); //echo trim(htmlspecialchars($this_value)); echo "</textarea>"; $this_box_color = rcolor(); echo "<div style='vertical-align:top;background-color:" . rcolor() . ";margin-left:0px;'>"; } $match_entries = $OBJ_EXPR->obj_match_entries; $bool_has_filter = false; $bool_has_operation = false; $bool_has_buffer = false; $bool_has_action = false; $bool_has_output = false; $bool_has_output_type_print = false; $bool_buffer_children = false; if (is_array($match_entries)) { //print_r($match_entries); if ($mode_edit) { echo "<ul style='margin-left:5px;'>"; } foreach ($match_entries as $match_entry) { if ($match_entry->id_entry_type == 'processing') { $bool_has_filter = true; } if ($match_entry->id_entry_type == 'operation') { $bool_has_operation = true; } // OUTPUT if ($match_entry->id_entry_type == 'output') { if (strpos($match_entry->idx_id, "-1") === False) { $bool_has_output = true; if ($match_entry->id_entry_subtype == 'print-value') { $bool_has_output_type_print = true; } } } // END IF OUTPUT // ACTION if ($match_entry->id_entry_type == 'action') { $bool_has_action = true; if ($match_entry->id_entry_subtype == 'buffer') { $bool_has_buffer = true; } } // END IF ACTION } // FOREACH if ($bool_has_buffer || $bool_buffer_output_merge) { $bool_buffer_children = true; } usort($match_entries, "meordersort"); if ($mode_edit) { } // END IF (NOTEFILTER) foreach ($match_entries as $match_entry) { foreach ($match_entry->obj_me_settings as $MESK => $MESV) { //if ( !isset($match_entry->obj_me_settings[$MESK]->value) ) //{ // $match_entry->obj_me_settings[$MESK]->value = ""; //} $match_entry->obj_me_settings[$MESK]->value = replace_dictionary($match_entry->obj_me_settings[$MESK]->value, $adjacent_dictionary); } $match_entry_apply_to_subgroup_array = explode("#", $match_entry->idx_id); $match_entry_apply_to_subgroup = $match_entry_apply_to_subgroup_array[0]; if ($match_entry_apply_to_subgroup != $mi) { continue; } // PROCESSING if ($match_entry->id_entry_type == 'processing') { if ($mode_edit) { $this_box_color = rcolor(); echo getTranslation("PROCESSING", $settings); echo ": "; echo "<ul style='background-color:{$this_box_color};'>"; if (isset($match_entry->obj_expression)) { echo "<a name='" . $match_entry->obj_expression->id . "_-1.notesection'>"; echo "<div style='background-color:" . rcolor() . ";padding-left:35px;'>"; echo getTranslation("Describe everything in the outer area covered by", $settings); echo "<span style='background-color:{$this_box_color};width:100px;display:inline;'>"; echo getTranslation("this color", $settings); echo "</span>"; echo getTranslation("- what does it take as input, and what does it give as output?", $settings); echo "<br/>"; echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>"; echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_expression->id . "'/>"; echo "<input type='hidden' name='idx_key' value='-1.notesection'/>"; echo "<textarea rows='1' name='str_txt' style='background-color:" . rcolor() . ";width:75%;'/>"; $custom_entry = $match_entry->obj_expression->obj_match_customs; if (isset($custom_entry["-1.notesection"])) { echo htmlspecialchars($custom_entry["-1.notesection"]->obj_txt->body); } echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "<a style='font-size:10px;padding-left:40px;' href='#filtering_toc'>"; echo "Go to table of contents"; echo "</a>"; echo "</form>\n"; echo "</div>"; echo "</a>"; } // END IF (NOTESECTION) echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>"; echo "<input type='hidden' name='id_entry_type' value='output'/>"; echo "PROCESSING TYPE: <select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['processing_types'] as $processing_key => $processing_value) { $seltxt = ""; if ($processing_key == $match_entry->id_entry_subtype) { $seltxt = " selected"; } echo "<option value='" . $processing_key . "'{$seltxt}>" . getTranslation($processing_value, $settings) . "</option>"; } echo "</select>"; echo "<br/>"; echo " "; echo getTranslation("use", $settings); echo " "; echo "<textarea rows='1' name='str_expression' style='width:600px;background-color:" . rcolor() . ";display:inline;'>"; if (isset($match_entry->obj_me_settings['str_expression'])) { echo $match_entry->obj_me_settings['str_expression']->obj_value->body; } echo "</textarea>"; echo "<ul style='padding-left:80px;'>"; echo "<div style='background-color:" . rcolor() . ";'>"; $fail_match_checked = false; if (isset($match_entry->obj_me_settings['str_bool_fail_n_matches'])) { if ($match_entry->obj_me_settings['str_bool_fail_n_matches']->value == "true") { $fail_match_checked = true; } } $checked_html = ""; if ($fail_match_checked) { $checked_html = " checked='checked'"; } echo "<input type='checkbox' name='str_bool_fail_n_matches' value='true'{$checked_html}/>"; echo " "; echo getTranslation("If # of Matches/Occurrences", $settings); echo " "; $selected = ""; echo "<select name='str_fail_match_operator' style='background-color:" . rcolor() . ";display:inline;'>"; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "eq") { $selected = " selected='selected'"; } } echo "<option value='eq'{$selected}>"; echo "="; echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "not") { $selected = " selected='selected'"; } } echo "<option value='not'{$selected}>"; echo getTranslation("Not", $settings); echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gt") { $selected = " selected='selected'"; } } echo "<option value='gt'{$selected}>"; echo ">"; echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lt") { $selected = " selected='selected'"; } } echo "<option value='lt'{$selected}>"; echo "<"; echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lte") { $selected = " selected='selected'"; } } echo "<option value='lte'{$selected}>"; echo "<="; echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gte") { $selected = " selected='selected'"; } } echo "<option value='gte'{$selected}>"; echo ">="; echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "mod") { $selected = " selected='selected'"; } } echo "<option value='mod'{$selected}>"; echo getTranslation("Mod by N = 0", $settings); echo "</option>"; $selected = ""; if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "modnot0") { $selected = " selected='selected'"; } } echo "<option value='modnot0'{$selected}>"; echo getTranslation("Mod by N not 0", $settings); echo "</option>"; echo "</select>"; echo " "; echo "<input type='text' name='str_fail_n_matches' value='"; if (isset($match_entry->obj_me_settings['str_fail_n_matches'])) { echo $match_entry->obj_me_settings['str_fail_n_matches']->obj_value->body; } else { echo "0"; } echo "' style='background-color:" . rcolor() . ";display:inline;width:50px;'/>"; echo " "; echo getTranslation("cause function to fail with status", $settings); echo " "; echo "<input type='text' name='str_fail_status' value='"; if (isset($match_entry->obj_me_settings['str_fail_status'])) { echo $match_entry->obj_me_settings['str_fail_status']->obj_value->body; } else { echo "failed"; } echo "' style='background-color:" . rcolor() . ";display:inline;'/>"; echo "</div>"; echo "<div style='background-color:" . rcolor() . ";'>"; $max_matches_checked = false; if (isset($match_entry->obj_me_settings['str_bool_max_matches'])) { if ($match_entry->obj_me_settings['str_bool_max_matches']->value == "true") { $max_matches_checked = true; } } $checked_html = ""; if ($max_matches_checked) { $checked_html = " checked='checked'"; } echo "<input type='checkbox' name='str_bool_max_matches' value='true'{$checked_html}/>"; echo "Max # of Matches: "; echo "<input type='text' name='str_max_match_count' value='"; if (isset($match_entry->obj_me_settings['str_max_match_count'])) { echo $match_entry->obj_me_settings['str_max_match_count']->obj_value->body; } else { echo "0"; } echo "' style='background-color:" . rcolor() . ";display:inline;'/>"; echo "</div>"; echo "</ul>"; echo "<br/>"; echo "<ul>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>"; echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>"; echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>"; echo "</ul>"; echo "</form>"; echo "\n<ul>"; echo getTranslation("using", $settings); echo " "; if ($match_entry->id_entry_subtype == 'filter-regex') { echo getTranslation("pattern", $settings); } if ($match_entry->id_entry_subtype == 'filter-split-string') { echo getTranslation("split delimiter", $settings); } if ($match_entry->id_entry_subtype == 'filter-xpath') { echo getTranslation("XPath", $settings); } if ($match_entry->id_entry_subtype == 'filter-split-regex') { echo getTranslation("split regex", $settings); } echo ": <b>"; if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') { echo "#"; } if (isset($match_entry->obj_me_settings['str_expression'])) { echo htmlspecialchars($match_entry->obj_me_settings['str_expression']->obj_value->body); } if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') { echo "#ism"; echo "<br/>"; echo "<ul >"; echo getTranslation("filter-regex tip", $settings); echo "</ul>"; } echo "</b></ul>\n"; } // end if (edit interface) $filtering_expression = ""; if (isset($match_entry->obj_me_settings['str_expression'])) { $filtering_expression = $match_entry->obj_me_settings['str_expression']->obj_value->body; } $orig_filtering_expression = $filtering_expression; $filtering_expression = replace_hf_parameters($filtering_expression, $q->obj_hf_parameters); if ($mode_edit) { if ($filtering_expression != $orig_filtering_expression) { if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') { echo "#"; } echo htmlspecialchars($filtering_expression); if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') { echo "#ism"; } } if ($match_entry->id_entry_subtype == 'filter-regex') { echo "<br/>"; } } // XML MODE OUTPUT if ($mode_xml) { for ($in = 1; $in < $idt + 3; $in++) { echo "\t"; } echo "<hf>\n"; for ($in = 1; $in < $idt + 4; $in++) { echo "\t"; } echo "<expression>" . htmlspecialchars($filtering_expression) . "</expression>\n"; } // end if // PROCESSING SUBTYPE: FILTER REGEX if ($match_entry->id_entry_subtype == 'filter-regex') { // if regex if (strlen($filtering_expression) > 0) { preg_match_all("#" . $filtering_expression . "#ism", $this_value, $submatches, PREG_SET_ORDER); } else { } if (strlen($filtering_expression) == 0) { $submatches = array(); } else { if ($filtering_expression == "(.*)") { $submatches = array(array($this_value)); } else { for ($i = 0; $i < count($submatches); $i++) { unset($submatches[$i][0]); } } } } // end if (is regex filtering) // PROCESSING SUBTYPE: SPLIT STRING if ($match_entry->id_entry_subtype == 'filter-split-string') { $submatch_retval = array(); if (strlen($filtering_expression) > 0) { // if split $submatches = explode($filtering_expression, $this_value); foreach ($submatches as $sm) { $submatch_retval[] = array($sm); } $submatches = $submatch_retval; } } // PROCESSING SUBTYPE: STRING FORMATTER if ($match_entry->id_entry_subtype == 'filter-string-formatter') { // if split //echo "SUBMATCHES:"; $submatches = sscanf($this_value, $filtering_expression); $submatch_retval = array(); foreach ($submatches as $sm) { $submatch_retval[] = array($sm); } $submatches = $submatch_retval; //print_r($submatches); } // PROCESSING SUBTYPE: REGEX SPLIT if ($match_entry->id_entry_subtype == 'filter-split-regex') { // if split if (strlen($filtering_expression) > 0) { $submatches = preg_split("#" . $filtering_expression . "#ism", $this_value); $submatch_retval = array(); foreach ($submatches as $sm) { $submatch_retval[] = array($sm); } $submatches = $submatch_retval; } else { $submatches = array(); } // echo "<pre>"; // print_r($submatches); } // PROCESSING SUBTYPE: XPATH if ($match_entry->id_entry_subtype == 'filter-xpath') { try { // if xpath if (strlen($filtering_expression) > 0) { $xp_xml = new SimpleXMLElement($this_value); $submatches = $xp_xml->xpath($filtering_expression); for ($iii = 0; $iii < count($submatches); $iii++) { $submatches[$iii] = array(if_attribute_xpath_parse(innerxml($submatches[$iii]), $filtering_expression)); } } } catch (Exception $e) { } } // XML MODE OUTPUT if ($mode_xml) { for ($in = 1; $in < $idt + 4; $in++) { echo "\t"; } echo "<results>\n"; } // end if if ($mode_edit) { echo "<ul style='margin-left:5px;'>"; echo "<ul style='margin-left:5px;'>"; } $match_counter = 0; // IF A NON-BLANK FILTERING EXPRESSION... if (strlen($filtering_expression) > 0) { $chead = ""; $chead_after_replace = ""; //echo "<pre>"; //print_r($match_entry->obj_expression); if (isset($match_entry->obj_expression->obj_match_customs)) { $custom_head = $match_entry->obj_expression->obj_match_customs; if (isset($custom_head['-1.header'])) { $chead = $custom_head['-1.header']->obj_txt->body; $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters); } } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $chead_after_replace; } } $retval['buffer'] = $retval['buffer'] . $chead_after_replace; // CUSTOM FOOTER GUI EDIT FIELD if ($mode_edit) { echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Header", $settings) . "(" . substr($match_entry->obj_expression->id, 0, min(strlen($match_entry->obj_expression->id), 5)) . ",-1): "; echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_me_settings['str_expression']->obj_value->id . "'/>"; echo "<input type='hidden' name='idx_key' value='-1.header'/>"; echo "<textarea rows='1' name='str_txt' style='width:500px;'/>"; echo str_replace("<", "<", $chead); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; } if ($chead != $chead_after_replace) { echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n"; } if (isset($match_entry->obj_me_settings['str_bool_max_matches']) && isset($match_entry->obj_me_settings['str_max_match_count'])) { if ($match_entry->obj_me_settings['str_bool_max_matches']->value != "false") { if (strlen($match_entry->obj_me_settings['str_max_match_count']->value) > 0) { if (count($submatches) > intval($match_entry->obj_me_settings['str_max_match_count']->value) && intval($match_entry->obj_me_settings['str_max_match_count']->value) > 0) { $submatches = array_slice($submatches, 0, intval($match_entry->obj_me_settings['str_max_match_count']->value)); } } } } $function_fail = false; // FAIL CONDITION CHECK if (true) { if (isset($match_entry->obj_me_settings['str_bool_fail_n_matches']) && isset($match_entry->obj_me_settings['str_fail_match_operator']) && isset($match_entry->obj_me_settings['str_fail_n_matches']) && isset($match_entry->obj_me_settings['str_fail_status'])) { if ($match_entry->obj_me_settings['str_bool_fail_n_matches']->value != "false") { if (strlen($match_entry->obj_me_settings['str_fail_match_operator']->value) > 0 && strlen($match_entry->obj_me_settings['str_fail_n_matches']->value) > 0 && strlen($match_entry->obj_me_settings['str_fail_status']->value) > 0) { if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "eq") { if (count($submatches) == intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "not") { if (count($submatches) != intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lt") { if (count($submatches) < intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gt") { if (count($submatches) > intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gte") { if (count($submatches) >= intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lte") { if (count($submatches) <= intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "mod") { if (count($submatches) % intval($match_entry->obj_me_settings['str_fail_n_matches']->value) == 0) { $function_fail = true; } } if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "modnot0") { if (count($submatches) % intval($match_entry->obj_me_settings['str_fail_n_matches']->value) != 0) { $function_fail = true; } } } // end if (fail fields not blank) } } } if ($function_fail) { if (($mode_xml || $mode_cxml) && $mode_output) { $new_job_flag = new job_flag(); $props = array(); $props['id_job'] = $_GET['JID']; $props['flag'] = "failed"; $props['status'] = $match_entry->obj_me_settings['str_fail_status']->value; //."-count:".count($submatches); $new_job_flag->create($props); sleep(2); return; } if ($mode_edit) { echo "<ul>"; echo getTranslation("If this function were run, it would fail because there are", $settings) . " " . count($submatches) . " " . getTranslation("matches.", $settings); echo "</ul>"; } } if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-xpath') { foreach ($submatches as $sm) { $match_counter = $match_counter + 1; $bo = expression_results_and_interface($match_entry->obj_expression, $match_counter, $sm, $idt + 4, $bool_buffer_children); if ($bool_buffer_children) { $retval['buffer'] = $retval['buffer'] . $bo['buffer']; } if ($match_counter == 20 && $mode_short) { if ($mode_edit) { echo "<span style='background-color:red;color:white'>Only a few values have been printed out on this edit page (limit 100)</span><br/>\n"; } break; } } // foreach (submatch) } else { if ($match_entry->id_entry_subtype == 'filter-split-string' || $match_entry->id_entry_subtype == 'filter-split-regex' || $match_entry->id_entry_subtype == 'filter-string-formatter') { foreach ($submatches as $sm) { $bo = expression_results_and_interface($match_entry->obj_expression, 1, $sm, $idt + 4, $bool_buffer_children); if ($bool_buffer_children) { $retval['buffer'] = $retval['buffer'] . $bo['buffer']; } } // end for } } // end if (split) // CUSTOM FOOTER GUI EDIT FIELD $cfoot = ""; $cfoot_after_replace = ""; if (isset($match_entry->obj_expression->obj_match_customs)) { $custom_foot = $match_entry->obj_expression->obj_match_customs; if (isset($custom_foot['-1.footer'])) { $cfoot = $custom_foot['-1.footer']->obj_txt->body; $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters); } } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $cfoot_after_replace; } } $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace; if ($mode_edit) { echo "<br/>"; echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . "(" . substr($match_entry->obj_expression->id, 0, min(strlen($match_entry->obj_expression->id), 5)) . ",-1): "; echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_me_settings['str_expression']->obj_value->id . "'/>"; echo "<input type='hidden' name='idx_key' value='-1.footer'/>"; echo "<textarea rows='1' name='str_txt' style='width:500px;'/>"; echo str_replace("<", "<", $cfoot); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; } if ($cfoot != $cfoot_after_replace) { echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n"; } } // end if (not blank processing expression) if ($mode_edit) { echo "</ul>"; echo "</ul>"; } // A EXPRESSION WHICH HAS FAILED (NO MATCHES) // PRINT OUT VAL if ($mode_cxml) { if ($match_counter == 0) { //echo htmlspecialchars($this_value); } } // XML MODE OUTPUT if ($mode_xml) { // A EXPRESSION WHICH HAS FAILED (NO MATCHES) // PRINT OUT VAL /*if ($match_counter==0) // there were no more submatches! print out val { for($in=1;$in<$idt+2+3;$in++) echo "\t"; echo "<value>"; echo "<offset>".$this_idx."</offset><string>".mb_convert_encoding(htmlspecialchars($this_value),"UTF-8")."</string>"; echo "</value>\n"; }*/ for ($in = 1; $in < $idt + 4; $in++) { echo "\t"; } echo "</results>\n"; for ($in = 1; $in < $idt + 3; $in++) { echo "\t"; } echo "</hf>\n"; } // end if (xml) if ($mode_edit) { //echo "</ul>"; } if ($mode_edit) { echo "</ul>"; } } else { if ($match_entry->id_entry_type == 'operation') { $pp = ''; $ap = ''; if ($match_entry->id_entry_subtype == 'prepend-and-append' || $match_entry->id_entry_subtype == 'prepend-and-append-file') { if (isset($match_entry->obj_me_settings['prepend'])) { $pp = $match_entry->obj_me_settings['prepend']->obj_value->body; } if (isset($match_entry->obj_me_settings['prepend'])) { $ap = $match_entry->obj_me_settings['append']->obj_value->body; } } // end if (prepend & append) $find = ""; $replace_with = ""; if ($match_entry->id_entry_subtype == 'replace' || $match_entry->id_entry_subtype == 'replace-using-regex') { if (isset($match_entry->obj_me_settings['find'])) { $find = $match_entry->obj_me_settings['find']->obj_value->body; } if (isset($match_entry->obj_me_settings['replace_with'])) { $replace_with = $match_entry->obj_me_settings['replace_with']->obj_value->body; } } // end if (replace) if ($mode_edit) { echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post'>"; echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>"; echo "<input type='hidden' name='id_entry_type' value='" . $match_entry->id_entry_type . "'/>"; echo getTranslation("OPERATION", $settings); echo ": <select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['operation_types'] as $operation_type_key => $operation_type_value) { $seltxt = ""; if ($operation_type_key == $match_entry->id_entry_subtype) { $seltxt = " selected"; } echo "<option value='" . $operation_type_key . "'" . $seltxt . ">" . getTranslation($operation_type_value, $settings) . "</option>"; } echo "</select>"; echo ":<br/>"; echo "<ul>"; if ($match_entry->id_entry_subtype == 'prepend-and-append' || $match_entry->id_entry_subtype == 'prepend-and-append-file') { echo getTranslation("Prepend", $settings); echo ": <textarea rows='1' name='prepend' style='background-color:" . rcolor() . ";width:200px;display:inline;'>" . htmlspecialchars($pp) . "</textarea>;"; echo getTranslation("Append", $settings); echo ": <textarea rows='1' name='append' style='background-color:" . rcolor() . ";width:200px;display:inline;'>" . htmlspecialchars($ap) . "</textarea>;"; } // end if (prepend) if ($match_entry->id_entry_subtype == 'replace' || $match_entry->id_entry_subtype == 'replace-using-regex') { echo getTranslation("Replace", $settings); echo ": <textarea style='background-color:" . rcolor() . ";display:inline;' rows='1' name='find'>" . htmlspecialchars($find) . "</textarea>; "; echo getTranslation("With", $settings); echo ": <textarea style='background-color:" . rcolor() . ";display:inline;' rows='1' name='replace_with'>" . htmlspecialchars($replace_with) . "</textarea>;"; } // end if (replace) echo "<br/>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>"; echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>"; echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>"; echo "</form>"; echo "</ul>"; echo ""; } // end if (edit mode); if ($match_entry->id_entry_subtype == 'read-non-html') { $inside_counter = 0; $finalval = ""; for ($i = 0; $i < strlen($this_value); $i++) { $this_letter = substr($this_value, $i, 1); if ($this_letter == "<") { $inside_counter = $inside_counter + 1; continue; } if ($this_letter == ">") { $inside_counter = $inside_counter - 1; continue; } if ($inside_counter == 0) { $finalval = $finalval . $this_letter; } } // end for $this_value = $finalval; // non-html } else { if ($match_entry->id_entry_subtype == 'urlencode') { $this_value = urlencode($this_value); } else { if ($match_entry->id_entry_subtype == 'double-urlencode') { $this_value = urlencode($this_value); $this_value = urlencode($this_value); } else { if ($match_entry->id_entry_subtype == 'treat-as-integer') { $this_value = intval($this_value); } else { if ($match_entry->id_entry_subtype == 'treat-as-float') { $this_value = floatval($this_value); } else { if ($match_entry->id_entry_subtype == 'urldecode') { $this_value = urldecode($this_value); $this_value = str_replace("&", "&", $this_value); } else { if ($match_entry->id_entry_subtype == 'double-urldecode') { $this_value = urldecode($this_value); $this_value = str_replace("&", "&", $this_value); $this_value = urldecode($this_value); $this_value = str_replace("&", "&", $this_value); } else { if ($match_entry->id_entry_subtype == 'prepend-and-append') { $pp_new = replace_hf_parameters($pp, $q->obj_hf_parameters); $pp_new = replace_dictionary($pp, $adjacent_dictionary); $ap_new = replace_hf_parameters($ap, $q->obj_hf_parameters); $ap_new = replace_dictionary($ap, $adjacent_dictionary); if ($pp != $pp_new) { if ($mode_edit) { echo "<br/><ul style='vertical-align:top;'>VALUE BEFORE SUBSTITUTION: <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($pp)) . "</textarea></ul>"; } } if ($ap != $ap_new) { if ($mode_edit) { echo "<br/><ul style='vertical-align:top;'>VALUE BEFORE SUBSTITUTION: <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($ap)) . "</textarea></ul>"; } } $ap = $ap_new; $pp = $pp_new; $this_value = $pp . $this_value . $ap; // prepend & append } else { if ($match_entry->id_entry_subtype == 'replace') { // replace $this_value = str_replace($find, $replace_with, $this_value); } else { if ($match_entry->id_entry_subtype == 'erase') { $this_value = ""; // erase } else { if ($match_entry->id_entry_subtype == 'prepend-and-append-file') { // prepend & append file contents $ppf = file_get_contents($pp); $apf = file_get_contents($ap); $this_value = $ppf . $this_value . $apf; // prepend & append } else { if ($match_entry->id_entry_subtype == 'replace-using-regex') { // replace using regular expression $this_value = preg_replace('#' . $find . '#', $replace_with, $this_value); } else { if ($match_entry->id_entry_subtype == 'html-entities') { // htmlentities $this_value = htmlentities($this_value, ENT_QUOTES); } else { if ($match_entry->id_entry_subtype == 'trim') { // trim $this_value = trim($this_value); } else { if ($match_entry->id_entry_subtype == 'keywdreppass') { //keyword prelacement pass $value_after_replacement = replace_hf_parameters($this_value, $q->obj_hf_parameters); $value_after_replacement2 = replace_dictionary($value_after_replacement, $adjacent_dictionary); $this_value = $value_after_replacement2; } else { if ($match_entry->id_entry_subtype == 'base64-decode') { //base64_decode $this_value = base64_decode($this_value); } else { if ($match_entry->id_entry_subtype == 'base64-encode') { //base64_encode $this_value = base64_encode($this_value); } else { if ($match_entry->id_entry_subtype == 'html-entity-decode') { $this_value = html_entity_decode($this_value, ENT_QUOTES); } else { if ($match_entry->id_entry_subtype == 'htmlspecialchars') { // htmlspecialchars $this_value = htmlspecialchars($this_value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_XML1, 'UTF-8'); } else { if ($match_entry->id_entry_subtype == 'htmlspecialchars-decode') { // htmlspecialchars_decode $this_value = htmlspecialchars_decode($this_value, ENT_QUOTES | ENT_XML1, 'UTF-8'); } else { if ($match_entry->id_entry_subtype == 'strtoupper') { // strtoupper $this_value = strtoupper($this_value); } else { if ($match_entry->id_entry_subtype == 'strtolower') { // strtolower $this_value = strtolower($this_value); } } } } } } } } } } } } } } } } } } } } } } if ($mode_edit) { echo "<br/><ul style='vertical-align:top;'>"; echo getTranslation("VALUE AFTER OPERATION", $settings); echo ": <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($this_value)) . "</textarea></ul><br/><br/>"; } } else { if ($match_entry->id_entry_type == 'action') { // todo need to add xml/cxml mode codes if ($mode_edit) { echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>"; echo "<input type='hidden' name='id_entry_type' value='output'/>"; echo getTranslation("ACTION", $settings); echo ": <select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['action_types'] as $action_key => $action_value) { $seltxt = ""; if ($action_key == $match_entry->id_entry_subtype) { $seltxt = " selected"; } if ($action_key != "php-code" || $_SERVER['HTTP_HOST'] != $demo_domain) { echo "<option value='" . $action_key . "'{$seltxt}>" . getTranslation($action_value, $settings) . "</option>"; } } echo "</select>"; } if ($match_entry->id_entry_subtype == 'his-hf') { $his_url = ""; if (isset($match_entry->obj_me_settings['str_his'])) { $his_url = $match_entry->obj_me_settings['str_his']->obj_value->body; } $his_url_after_hfp_replacement = replace_hf_parameters($his_url, $q->obj_hf_parameters); $his_url_after_dict_replace = replace_dictionary($his_url_after_hfp_replacement, $adjacent_dictionary); if ($mode_edit) { echo ": "; echo "<br/>"; echo "<ul>"; echo "HIS "; echo getTranslation("URL", $settings); echo ":<br/><textarea rows='1' name='str_his' style='width:500px;'>"; echo htmlspecialchars($his_url); echo "</textarea>"; echo "<br/>"; if ($his_url != $his_url_after_dict_replace) { echo "<b>"; echo getTranslation("After Function Parameter/Adjacent Dictionary Value Replacement", $settings); echo ":</b>"; echo "<ul>"; echo "<textarea style='background-color:#ddd;width:500px;' readonly='readonly'>"; echo htmlspecialchars($his_url_after_dict_replace); echo "</textarea>"; echo "</ul>"; } echo getTranslation("Shortcut to Settings page", $settings); echo ": "; echo "<ul>"; echo "<a href='?q={$qn}&v=settings' target='_new'>"; echo getTranslation("Click Here", $settings); echo " "; echo "<img src='images/settings.png' border='0' width='20'/></a>"; echo "</ul>"; echo getTranslation("Example", $settings); echo "<ul>"; echo "{$this_server_url}/<font color='red'>?</font>s=weather<font color='red'>&</font>uid=YOUR-UID<font color='red'>&</font>secret=YOUR-SECRET<font color='red'>&</font>cxml<font color='red'>&</font>remote<font color='red'>&</font>location=Atlanta%2C+GA"; echo "</ul>"; echo getTranslation("Example", $settings); echo "<ul>"; echo "{$this_server_url}/<font color='red'>?</font>q=4f6cc17061477b0348630219f32985420855235a<font color='red'>&</font>uid=YOUR-UID<font color='red'>&</font>secret=YOUR-SECRET<font color='red'>&</font>cxml<font color='red'>&</font>remote<font color='red'>&</font>location=Atlanta%2C+GA"; echo "</ul>"; echo "<br/>"; echo "<br/>"; echo getTranslation("Suggested Local HIS Functions based on current parameters and dictionary values", $settings); echo ":"; echo "<ul>"; $suggested_hfs = array(); foreach ($adjacent_dictionary as $adk => $adv) { if (is_standard_ad($adk)) { continue; } $hfp_hf = new hfp_hf(); $hfp_hfs = $hfp_hf->get_from_hashrange($u->id_user . "@" . $adk); foreach ($hfp_hfs as $each_hfp_hf) { if ($each_hfp_hf['id_hf'] != "undefined") { $suggested_id_hf_ary = explode("@", $each_hfp_hf['id_hf']); $suggested_id_hf = $suggested_id_hf_ary[0]; if ($suggested_id_hf == $qn) { continue; } $suggested_hf = new hf_id_user(); $suggested_hf->get_from_hashrange($u->id_user, $suggested_id_hf); if ($suggested_hf->id != "undefined") { $suggested_hfs[] = array('hf' => $suggested_hf, 'param' => $each_hfp_hf); //echo $suggested_hf->name; //echo "<br/>"; } } } } foreach ($q->obj_hf_parameters as $hf_param) { if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) { continue; } if (isset($hf_param->obj_inherited) && $hf_param->obj_inherited) { //continue; } $hfp_hf = new hfp_hf(); $hfp_hfs = $hfp_hf->get_from_hashrange($u->id_user . "@" . $hf_param->keyword); foreach ($hfp_hfs as $each_hfp_hf) { if ($each_hfp_hf['id_hf'] != "undefined") { $suggested_id_hf_ary = explode("@", $each_hfp_hf['id_hf']); $suggested_id_hf = $suggested_id_hf_ary[0]; if ($suggested_id_hf == $qn) { continue; } $suggested_hf = new hf_id_user(); $suggested_hf->get_from_hashrange($u->id_user, $suggested_id_hf); if ($suggested_hf->id != "undefined") { $suggested_hfs[] = array('hf' => $suggested_hf, 'param' => $each_hfp_hf); //$suggested_hfs[]=$suggested_hf; //echo $suggested_hf->name; //echo "<br/>"; } } } } $printed_suggestions = array(); foreach ($suggested_hfs as $suggested_hf) { $suggested_hf_function = $suggested_hf['hf']; $suggested_hf_param = $suggested_hf['param']; //if (in_array($suggested_hf->id,$printed_suggestions)) continue; echo "<a href='?q=" . $suggested_hf_function->id . "&v=overview' target='_new'>"; echo $suggested_hf_function->name; echo "</a>"; echo " "; echo getTranslation("uses", $settings); echo " "; echo "<font color='red'>"; $full_hfp_split = explode("@", $suggested_hf_param['parameter_name']); $full_hfp = $full_hfp_split[1]; echo htmlspecialchars($full_hfp); echo "</font>"; echo " "; echo getTranslation("as an input", $settings); echo " "; echo "<input onClick='this.form.str_his.value=\"[THIS_HIS_WEB_INTERFACE_HOME]/?q=" . urlencode($suggested_hf_function->id) . "&cxml&remote&uid=ENTER-YOUR-UID&secret=ENTER-YOUR-SECRET\";' type='button' value='"; echo getTranslation("Use", $settings); echo "'/>"; echo " "; echo "<input onClick='this.form.str_his.value=\"[THIS_HIS_WEB_INTERFACE_HOME]/?s=" . urlencode($suggested_hf_function->name) . "&cxml&remote&uid=ENTER-YOUR-UID&secret=ENTER-YOUR-SECRET\";' type='button' value='"; echo getTranslation("Use by Name", $settings); echo "'/>"; echo "<br/>"; $printed_suggestions[] = $suggested_hf_function->id; } echo "</ul>"; echo "<br/>"; echo "<br/>"; echo "</ul>"; } // end if (mode edit) if ($his_url != $his_url_after_dict_replace) { $his_url = $his_url_after_dict_replace; } if ($mode_xml || $mode_cxml || $mode_jidonly) { if (strlen($his_url) > 0) { // set his action flag (not nec., the server can detect when placeholders exist for its job id) // choose placeholder hash to insert into output file for now // generate special postback url that will fulfill placeholder in the future, and replace the hash value // in this file's temporary output // submit job to gather output // set this job's status equal to "paused" when done, instead of "completed" // doable without changing code here // jobs getting executed & updating the placeholder hashes with real his hf output // database table mah_placeholders // id // id_job (this job) // str_placeholder (generated hash) // id_child_job (job submitted to gather results to replace this job's temporary hash value printed // postback url's activities will include something to fulfill the placeholder (not necessary) // and also run a check to see if all placeholders for this job have been completed, and, if so, // run all value replacements and overwrite an updated copy of this job's temporary output // file to the file storage location $placeholder_hash = sha1($this_value . microtime() . rand(1, 20)); if (!$mode_jidonly) { echo $placeholder_hash; } $GLOBALS['HIS_URLS_TO_VISIT' . $GLOBALS['VISITOR']][$placeholder_hash] = $his_url . "&jidonly&uid=" . urlencode($_GET['uid']) . "&secret=" . urlencode($_GET['secret']); // $should add &remote also? $this_value = ""; } // end if (hisurl not blank) } // end if (xml or cxml) } // end if (his + postback) if ($match_entry->id_entry_subtype == 'cur-as-key' || $match_entry->id_entry_subtype == 'cur-as-val' || $match_entry->id_entry_subtype == 'key-and-val' || $match_entry->id_entry_subtype == 'clear-adj') { // use current value as adjacent dictionary key2/value3 $readonly_key = ""; $readonly_value = ""; if ($match_entry->id_entry_subtype == 'cur-as-key') { $readonly_key = " readonly='readonly' style='background-color:#ddd;'"; } else { if ($match_entry->id_entry_subtype == 'cur-as-val') { $readonly_value = " readonly='readonly' style='background-color:#ddd;'"; } } $dict_key = ""; $dict_value = ""; if ($match_entry->id_entry_subtype == 'cur-as-key' || $match_entry->id_entry_subtype == 'key-and-val') { if (isset($match_entry->obj_me_settings['str_value'])) { if ($match_entry->obj_me_settings['str_value']) { $dict_value = $match_entry->obj_me_settings['str_value']->obj_value->body; } } } if ($match_entry->id_entry_subtype == 'cur-as-val' || $match_entry->id_entry_subtype == 'key-and-val') { if (isset($match_entry->obj_me_settings['str_key'])) { if ($match_entry->obj_me_settings['str_key']) { $dict_key = $match_entry->obj_me_settings['str_key']->obj_value->body; } } } if ($match_entry->id_entry_subtype == 'cur-as-key') { // use current value as adjacent dictionary key $dict_key = $this_value; } else { if ($match_entry->id_entry_subtype == 'cur-as-val') { // use current value as adjacent dictionary value $dict_value = $this_value; } } if ($match_entry->id_entry_subtype != 'clear-adj') { if (strlen($dict_key) == 0 && $match_entry->id_entry_subtype != 'clear-adj') { $dict_key = "[test_key]"; } if ($mode_edit && $match_entry->id_entry_subtype != 'clear-adj') { echo ":<br/>"; echo "<ul>"; $field_name = "name='str_key'"; if ($match_entry->id_entry_subtype == 'cur-as-key') { $field_name = ""; } echo "<textarea {$field_name}{$readonly_key}>"; } $dict_key_after_hfp_replacement = replace_hf_parameters($dict_key, $q->obj_hf_parameters); if ($mode_edit) { echo htmlspecialchars($dict_key); echo "</textarea>"; $field_name = "name='str_value'"; if ($match_entry->id_entry_subtype == 'cur-as-val') { $field_name = ""; } echo " <font style='font-size:70px;'>=</font> <textarea {$field_name}{$readonly_value}>"; } $dict_value_after_hfp_replacement = replace_hf_parameters($dict_value, $q->obj_hf_parameters); if ($mode_edit) { echo htmlspecialchars($dict_value); echo "</textarea><br/>"; } if ($mode_edit && $match_entry->id_entry_subtype != 'clear-adj') { echo "</ul>"; } // show a post-hfparameter'd version if (count($q->obj_hf_parameters) > 0 && ($dict_value != $dict_value_after_hfp_replacement || $dict_key != $dict_key_after_hfp_replacement)) { if ($mode_edit) { echo "<b>After Function Parameter Value Replacement:</b>"; echo "<ul>"; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo $dict_key_after_hfp_replacement; } $dict_key = $dict_key_after_hfp_replacement; if ($mode_edit) { echo "</textarea>"; echo " <font style='font-size:70px;'>=</font> "; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo $dict_value_after_hfp_replacement; } $dict_value = $dict_value_after_hfp_replacement; if ($mode_edit) { echo "</textarea><br/>"; echo "</ul>"; } } // do a AVK replace ALSO & show $adjacent_dictionary_without_this_entry = $adjacent_dictionary; if (isset($adjacent_dictionary_without_this_entry[$dict_key])) { unset($adjacent_dictionary_without_this_entry[$dict_key]); } $dict_key_after_dict_replace = replace_dictionary($dict_key, $adjacent_dictionary_without_this_entry); $dict_value_after_dict_replace = replace_dictionary($dict_value, $adjacent_dictionary_without_this_entry); if (count($adjacent_dictionary) > 0 && ($dict_key != $dict_key_after_dict_replace || $dict_value != $dict_value_after_dict_replace)) { if ($mode_edit) { echo "<b>After Adjacent Dictionary Value Replacement:</b>"; echo "<ul>"; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo $dict_key_after_dict_replace; } $dict_key = $dict_key_after_dict_replace; if ($mode_edit) { echo "</textarea>"; echo " <font style='font-size:70px;'>=</font> "; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo $dict_value_after_dict_replace; } $dict_value = $dict_value_after_dict_replace; if ($mode_edit) { echo "</textarea><br/>"; echo "</ul>"; } } if (strlen($dict_key) > 0) { if (isset($adjacent_dictionary[$dict_key])) { unset($adjacent_dictionary[$dict_key]); } $adjacent_dictionary[$dict_key] = $dict_value; } } // END IF (NOT CLEAR ADJACENT DICTIONARY MATCHENTRY SUBTYPE) if ($match_entry->id_entry_subtype == 'clear-adj') { foreach ($adjacent_dictionary as $ak => $av) { if (!in_array($ak, $system_adjacent_dictionary_keys)) { unset($adjacent_dictionary[$ak]); } } if ($mode_edit) { echo "<br/>"; echo "<br/>"; echo "<ul>"; echo getTranslation("Adjacent dictionary has been cleared.", $settings); echo "<br/>"; echo "<br/>"; } } // END IF (CLEAR ADJACENT DICTIONARY) // show dictionary summary if (count($adjacent_dictionary) > 0 || $match_entry->id_entry_subtype == 'clear-adj') { if ($mode_edit) { echo "<ul>"; echo "<b>"; echo getTranslation("Current Parameter Values", $settings); echo ": "; echo "</b>"; echo "<ul>"; echo "<table border='1'>"; foreach ($q->obj_hf_parameters as $hf_param) { if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) { continue; } echo "<tr>"; echo "<td>"; echo htmlspecialchars($hf_param->keyword); echo "</td>"; echo "<td style='font-size:10px'>"; echo htmlspecialchars($hf_param->printable_value); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<br/>"; echo "</ul>"; echo getTranslation("Current Adjacent Dictionary Contents", $settings); echo ": "; echo "<ul>"; echo "<table border='1'>"; foreach ($adjacent_dictionary as $adk => $adv) { if (is_standard_ad($adk)) { continue; } echo "<tr>"; echo "<td>"; echo htmlspecialchars($adk); echo "</td>"; echo "<td style='font-size:10px'>"; echo htmlspecialchars($adv); echo "</td>"; echo "</tr>"; } if (count($adjacent_dictionary) == 0) { echo "<tr>"; echo "<td>"; echo getTranslation("Adjacent dictionary is empty.", $settings); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</ul>"; echo "<br/>"; echo "</ul>"; } } // END IF (SHOW ADJ DICT SUMMARY TABLE) if ($match_entry->id_entry_subtype == 'clear-adj') { if ($mode_edit) { echo "</ul>"; echo "<br/>"; } } if ($mode_edit) { //echo "</ul>"; } } // end if (use current value as adjacent dictionary key) if ($match_entry->id_entry_subtype == 'buffer') { // buffer action - collect previous childrens' value/filtering results and set filtered value to this //$this_value=$retval['buffer']; if ($bool_has_buffer) { $bool_has_buffer = false; $bool_buffer_children = true; } if ($bool_buffer_output_merge) { } else { $bool_has_filter = false; } if ($mode_edit) { echo "<ul><br/>"; echo getTranslation("This Buffering action will prevent printing of preceeding sub-processings' data outputs unless a \"Print Value\" OUTPUT entry is made below.", $settings); echo "<br/>"; echo "<br/>"; echo getTranslation("Buffered Content added to Adjacent Dictionary Key [BUFFER]", $settings); echo ":<br/><textarea cols='100'>"; if (isset($retval['buffer'])) { echo str_replace("<", "<", $retval['buffer']); //echo htmlspecialchars($this_value); } echo "</textarea>"; echo "<br/>"; } if ($mode_cxml && !$mode_jidonly) { //echo $retval['buffer']; } // do a AVK replace ALSO & show $adjacent_dictionary["[BUFFER]"] = $retval['buffer']; // show dictionary summary if (count($adjacent_dictionary) > 0) { if ($mode_edit) { echo "<b>"; echo getTranslation("Current Parameter Values", $settings); echo ": "; echo "</b>"; echo "<ul>"; echo "<table border='1'>"; foreach ($q->obj_hf_parameters as $hf_param) { if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) { continue; } echo "<tr>"; echo "<td>"; echo htmlspecialchars($hf_param->keyword); echo "</td>"; echo "<td style='font-size:10px'>"; echo htmlspecialchars($hf_param->printable_value); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<br/>"; echo "</ul>"; echo getTranslation("Current Adjacent Dictionary Contents", $settings); echo ": "; echo "<ul>"; echo "<table border='1'>"; foreach ($adjacent_dictionary as $adk => $adv) { if (is_standard_ad($adk)) { continue; } echo "<tr>"; echo "<td>"; echo htmlspecialchars($adk); echo "</td>"; echo "<td style='font-size:10px'>"; echo htmlspecialchars($adv); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</ul>"; echo "<br/>"; echo "</ul>"; } } } // end if (buffer action) if ($match_entry->id_entry_subtype == 'php-code' && strpos($settings['uri']['@attributes']['value'], $demo_domain) === FALSE) { // EXECUTE PHP CODE HERE - $STR contains current value $the_code = ""; if (isset($match_entry->obj_me_settings['php_code'])) { $the_code = $match_entry->obj_me_settings['php_code']->obj_value->body; } $the_code_replace = replace_hf_parameters($the_code, $q->obj_hf_parameters); $the_code_replace = replace_dictionary($the_code_replace, $adjacent_dictionary); $the_code_original = $the_code; $the_code = $the_code_replace; $this_value_before_code = $this_value; $STR = $this_value; if ($mode_edit) { echo "<ul>"; // use current value as adjacent dictionary key echo "<br/>"; echo getTranslation("Run PHP Code (Variable \$STR gets or sets current value)", $settings); echo ":<br/><textarea cols='50' name='php_code'>"; echo str_replace("<", "<", $the_code_original); echo "</textarea>"; if ($the_code_original != $the_code_replace) { echo "<br/>"; echo "<b>After Function Parameter/Adjacent Dictionary Value Replacement:</b>"; echo "<ul>"; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo htmlspecialchars($the_code); echo "</textarea>"; echo "</ul>"; } echo "<br/>"; echo "<br/>"; echo "</ul>"; } // end if (edit mode) if (strlen($the_code) > 0) { eval($the_code); } $this_value = $STR; if ($mode_edit) { if ($this_value_before_code != $this_value) { echo "<br/>"; echo "<b>Value of \$STR After PHP Code:</b>"; echo "<ul>"; echo "<textarea style='background-color:#ddd;' readonly='readonly'>"; echo htmlspecialchars($this_value); echo "</textarea>"; echo "</ul>"; } } } // end if (use current value as adjacent dictionary key) // MOVE MATCH ENTRY UP OR DOWN, UPDATE OR DELETE if ($mode_edit) { echo "<ul>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>"; echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>"; echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>"; echo "</form>"; //echo "<input type='submit' value='Update'/><input type='submit' name='btnUp' value='Move Up'/><input type='submit' name='btnDown' value='Move Down'/></form>"; //echo "<form style='display:inline;' action='?q=$qn&action=delete-match-action' method='post'>"; //echo "<input type='hidden' name='id_match_entry' value='".$match_entry['id']."'/>"; //echo "<input type='submit' value='Delete'/>"; //echo "</form>"; echo "</ul>"; } // end if (edit mode) } else { if ($match_entry->id_entry_type == 'output') { // todo need to add xml/cxml mode codes if (strpos($match_entry->idx_id, "-1") === False) { $bool_has_output = true; } $raw_response = ""; /// SERVICES DEFINITION $services_file = dirname(__FILE__) . "/services.xml"; $service_doc = xmlToArray(simplexml_load_file($services_file)); $SERVICES = array(); foreach ($service_doc as $services) { foreach ($services as $service) { $SERVICES[] = new Service($service); } } // GENERALLY USED MATCH ENTRY SETTING - ITS OKAY IF IT IS NOT USED $do_this_output_in_edit_mode = false; if (isset($match_entry->obj_me_settings['run_in_edit_mode'])) { if ($match_entry->obj_me_settings['run_in_edit_mode']->value == "true") { $do_this_output_in_edit_mode = true; } } $plugin_base_filename = "plugins/matchentry." . $match_entry->id_entry_type . "." . $match_entry->id_entry_subtype . ""; $plugin_init_filename = $plugin_base_filename . "." . "init" . ".php"; $plugin_exec_filename = $plugin_base_filename . "." . "exec" . ".php"; $plugin_dispose_filename = $plugin_base_filename . "." . "dispose" . ".php"; $plugin_edit_filename = $plugin_base_filename . "." . "edit" . ".php"; if (file_exists($plugin_init_filename)) { try { include $plugin_init_filename; } catch (Exception $e) { if ($mode_edit) { echo "<br/>"; } echo getTranslation("PLUGIN ERROR DURING INITIALIZATION", $settings); echo ": "; if ($mode_edit) { echo "<br/>"; echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>"; } echo str_replace("<", "<", $e); if ($mode_edit) { echo "</textarea>"; echo "<br/>"; } } } // IF NOT EDIT MODE, OR IS EDIT MODE & RUN-IN-EDIT-MODE SETTING IS TURNED ON if (!$mode_edit || $mode_edit && $do_this_output_in_edit_mode) { if (file_exists($plugin_exec_filename)) { try { include $plugin_exec_filename; } catch (Exception $e) { if ($mode_edit) { echo "<br/>"; } echo getTranslation("PLUGIN ERROR DURING EXECUTION", $settings); echo ": "; if ($mode_edit) { echo "<br/>"; echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>"; } echo str_replace("<", "<", $e); if ($mode_edit) { echo "</textarea>"; echo "<br/>"; } } } } // IF NOT MODE EDIT OR EDIT MODE + RUN IN EDIT MODE if (file_exists($plugin_dispose_filename)) { try { include $plugin_dispose_filename; } catch (Exception $e) { if ($mode_edit) { echo "<br/>"; } echo getTranslation("PLUGIN ERROR DURING DISPOSAL", $settings); echo ": "; if ($mode_edit) { echo "<br/>"; echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>"; } echo str_replace("<", "<", $e); if ($mode_edit) { echo "</textarea>"; echo "<br/>"; } } } // SHOW EDIT GUI if ($mode_edit) { echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>"; echo "<input type='hidden' name='id_entry_type' value='output'/>"; echo getTranslation("OUTPUT", $settings); echo ": <select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['output_types'] as $output_key => $output_value) { $seltxt = ""; $extratxt = ""; if ($output_key == $match_entry->id_entry_subtype) { $seltxt = " selected"; } if ($output_key != "print-value") { $extratxt = getTranslation("Post data externally, do not print", $settings); $extratxt = $extratxt . ": "; } echo "<option value='" . $output_key . "'{$seltxt}>" . $extratxt . getTranslation($output_value, $settings) . "</option>"; } echo "</select>"; echo ": "; echo "<br/>"; echo "<ul>"; if ($match_entry->id_entry_subtype == 'print-value') { // PRINT VALUE echo "<br/>"; echo "Value will be printed out to the web page/console/output file."; echo "<br/>"; } // END IF (PRINT VALUE) if (file_exists($plugin_edit_filename)) { include $plugin_edit_filename; } // Database hf if ($match_entry->id_entry_subtype == 'database-hf') { // Database Function echo "Database Type "; echo "<select name='str_dbtype'>"; echo "<option value=''></option>"; foreach ($APP['services'] as $service) { if ($service->enabled && $service->type == "database") { $seltxt = ""; if (isset($match_entry->obj_me_settings['str_dbtype'])) { if ($match_entry->obj_me_settings['str_dbtype']->obj_value->body == $service->name) { $seltxt = " selected='selected'"; } } echo "<option value='" . $service->name . "'{$seltxt}>" . $service->name . "</option>"; } } echo "</select>"; echo "<br/>"; echo ""; echo "Database Server: "; echo "<textarea rows='1' name='str_server'>"; if (isset($match_entry->obj_me_settings['str_server'])) { echo $match_entry->obj_me_settings['str_server']->obj_value->body; } echo "</textarea>"; echo "<br/>"; echo "<ul>"; echo "username: <textarea rows='1' name='str_user'>"; if (isset($match_entry->obj_me_settings['str_user'])) { echo $match_entry->obj_me_settings['str_user']->obj_value->body; } echo "</textarea>"; echo "<br/>"; echo "password: <textarea rows='1' name='str_pass'>"; if (isset($match_entry->obj_me_settings['str_pass'])) { echo $match_entry->obj_me_settings['str_pass']->obj_value->body; } echo "</textarea>"; echo "<br/>"; echo "database name: <textarea rows='1' name='str_dbname'>"; if (isset($match_entry->obj_me_settings['str_dbname'])) { echo $match_entry->obj_me_settings['str_dbname']->obj_value->body; } echo "</textarea>"; echo "<br/>"; echo "</ul>"; echo "Database Statement:<ul><textarea readonly='readonly' style='background-color:#ddd;width:600px;'>"; echo htmlspecialchars($this_value); echo "</textarea></ul>"; } // end if (database hf) // Send E-Mail // TODO echo "<br/>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>"; echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>"; echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>"; echo "</form>"; echo "</ul>"; echo "<br/>"; } // end if (edit mode); } } } } // end if (match entry type == output) } // END FOREACH (MATCH ENTRY) if ($mode_edit) { echo "</ul>"; } } // END IF (ANY MATCH ENTRIES ON THIS MATCH) // NO MATCH PROCESSING FILTERS ON THIS AT ALL; PRINT OUT THE VALUE YOU HAVE if (!$bool_has_filter && !$bool_has_output) { if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { if (!isUTF8($this_value)) { // TODO: WHAT IF THIS WAS BINARY RESULT CONTENT? echo mb_convert_encoding($this_value, "UTF-8"); } else { echo $this_value; } } } // mode cxml $retval['buffer'] = $retval['buffer'] . $this_value; if ($mode_xml && !$mode_jidonly) { for ($in = 1; $in < $idt + 2; $in++) { echo "\t"; } echo "<value>"; //echo "<offset>".$this_idx."</offset>"; echo "<string>"; if (!isUTF8($this_value)) { echo mb_convert_encoding(htmlspecialchars($this_value), "UTF-8"); } else { echo htmlspecialchars($this_value); } echo "</string>"; echo "</value>\n"; } // mode xml } // end if ( no filters found - behavior ) // ADD OUTPUT, ADD PROCESSING, ADD OPERATION, ADD ACTION GUI ELEMENTS if ($mode_edit) { //echo "</div>"; //echo "<ul>"; echo "\n"; echo "</div>"; echo getTranslation("ADD", $settings) . " " . getTranslation("OUTPUT", $settings) . ": " . getTranslation("Output this value", $settings) . ": "; echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>"; echo "<input type='hidden' name='id_entry_type' value='output'/>"; echo "<select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['output_types'] as $output_key => $output_value) { echo "<option value='" . $output_key . "'>" . getTranslation($output_value, $settings) . "</option>"; } echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>"; echo "</form>"; echo "<br/>"; echo getTranslation("ADD", $settings) . " " . getTranslation("PROCESSING", $settings) . ": " . getTranslation("The text above", $settings) . ":<!--({$mi}," . $OBJ_EXPR->id . ",{$qn})-->"; echo " "; echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>"; echo "<input type='hidden' name='id_entry_type' value='processing'/>"; echo "<select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['processing_types'] as $processing_key => $processing_value) { echo "<option value='" . $processing_key . "'>" . getTranslation($processing_value, $settings) . "</option>"; } echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>"; echo "</form>"; echo "<br/>"; echo getTranslation("ADD", $settings) . " " . getTranslation("OPERATION", $settings) . ": " . getTranslation("In-place modify", $settings) . ": "; echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>"; echo "<input type='hidden' name='id_entry_type' value='operation'/>"; echo "<select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['operation_types'] as $operation_key => $operation_value) { echo "<option value='" . $operation_key . "'>" . getTranslation($operation_value, $settings) . "</option>"; } echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>"; echo "</form>"; echo "<br/>"; echo getTranslation("ADD", $settings) . " " . getTranslation("ACTION", $settings) . ":"; echo " "; echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>"; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>"; echo "<input type='hidden' name='id_entry_type' value='action'/>"; echo "<select name='id_entry_subtype'>"; echo "<option value=''></option>"; foreach ($STATIC['action_types'] as $action_key => $action_value) { if ($action_key != "php-code" || $_SERVER['HTTP_HOST'] != $demo_domain) { echo "<option value='" . $action_key . "'>" . getTranslation($action_value, $settings) . "</option>"; } } echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>"; echo "</form>"; echo "</b></font>\n"; echo "</ul><br/>"; //echo "<div style='margin-left:0px;background-color:".rcolor()."'>"; } // end if (edit mode) $custom_foot = $OBJ_EXPR->obj_match_customs; $cfoot = ""; $cfoot_after_replace = ""; if ($custom_foot) { if (isset($custom_foot[$mi . '.footer'])) { $cfoot = $custom_foot[$mi . '.footer']->obj_txt->body; $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters); } } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $cfoot_after_replace; } } $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace; if ($mode_edit) { echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . $mi . "): "; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_key' value='" . $mi . ".footer'/>"; echo "<textarea rows='1' name='str_txt' style='width:500px;'/>"; echo str_replace("<", "<", $cfoot); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; } if ($cfoot != $cfoot_after_replace) { echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n"; } } // end foreach (each match field (i.e. "(.*?)" ) in the regex) } else { // NO MATCH PROCESSING FILTERS ON THIS AT ALL; PRINT OUT THE VALUE YOU HAVE if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { if (!isUTF8($this_value)) { // TODO: WHAT IF THIS WAS BINARY RESULT CONTENT? echo mb_convert_encoding($this_value, "UTF-8"); } else { echo $this_value; } } } // mode cxml $retval['buffer'] = $retval['buffer'] . $this_value; if ($mode_xml && !$mode_jidonly) { for ($in = 1; $in < $idt + 2; $in++) { echo "\t"; } echo "<value>"; //echo "<offset>".$this_idx."</offset>"; echo "<string>"; if (!isUTF8($this_value)) { echo mb_convert_encoding(htmlspecialchars($this_value), "UTF-8"); } else { echo htmlspecialchars($this_value); } echo "</string>"; echo "</value>\n"; } // mode xml } if ($mode_edit) { echo "</ul>"; } // CUSTOM FOOTER FIELDS/PRINTOUT $cfoot = ""; $cfoot_after_replace = ""; if (isset($OBJ_EXPR->obj_match_customs['0.footer'])) { if (isset($OBJ_EXPR->obj_match_customs['0.footer'])) { $cfoot = $custom_foot['0.footer']->obj_txt->body; $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters); } } if ($mode_cxml && !$mode_jidonly) { if (!$bool_buffer_output_merge) { echo $cfoot_after_replace; } } $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace; //if ($mode_cxml && !$mode_jidonly) echo $cfoot_after_replace; if ($mode_edit) { echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . "0" . "): "; echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>"; echo "<input type='hidden' name='idx_key' value='0.footer'/>"; echo "<textarea rows='1' name='str_txt' style='width:500px;'/>"; echo str_replace("<", "<", $cfoot); echo "</textarea>"; echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>"; echo "</form>\n"; } if ($cfoot != $cfoot_after_replace && $mode_edit) { echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n"; } if ($mode_xml) { for ($in = 1; $in < $idt + 2; $in++) { echo "\t"; } echo "</hfs>\n"; } if ($mode_edit) { echo "\n\n"; echo "</font></ul>"; } if ($mode_xml) { for ($in = 1; $in < $idt + 1; $in++) { echo "\t"; } echo "</result>\n"; } //echo "<hr/>"; return $retval; }
function xmlToArray($xmlObj) { $output = []; foreach ((array) $xmlObj as $index => $node) { $output[$index] = is_object($node) ? xmlToArray($node) : $node; } return $output; }
/** @method:xml to array * * @param : simplexml $xml * @author:taylor * */ function xmlToArray($xml, &$tmparr = array()) { $object = simplexml_load_file($xml); if (is_object($object)) { $tmparr = get_object_vars($object); } foreach ($tmparr as $k => $v) { if (is_array($v)) { $tmparr[$k] = xmlToArray($v, $tmparr[$k]); } elseif (is_object($v)) { $tmparr[$k] = xmlToArray($v, $tmparr[$k]); } else { $tmparr[$k] = $v; } } return $tmparr; }
function xmlToArray($xmlObj) { if (is_string($xmlObj)) { return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); } else { $output = array(); foreach ((array) $xmlObj as $index => $node) { $output[$index] = is_object($node) ? xmlToArray($node) : $node; } return $output; } }
$rss = ''; $rss .= '<rss version="2.0">'; $rss .= '<channel>'; $rss .= '<title>Amazon.com Gold Box Deals</title>'; $rss .= '<link>http://www.amazon.com/gp/goldbox</link>'; $rss .= '<description>Amazon.com Gold Box Deals</description>'; $rss .= '<lastBuildDate>' . date(DATE_RSS) . '</lastBuildDate>'; foreach ($items as $item) { $rss .= makeRssItem($item); } $rss .= '</channel>'; $rss .= '</rss>'; $dom->loadXML($rss); return $dom->saveXml(); } $feedData = xmlToArray(requestData(getGoldBoxUrl()), $blackList); if ($feedSorted = sortFeedArray($feedData, 'pubDate', $feedLimitToday)) { if ($feedPersonalized = personalizeAffiliateLinks(array_slice($feedSorted, 0, $feedLimit), $affiliateTagId)) { try { file_put_contents($outputLocation . '/' . $outputFilename, makeRssDoc($feedPersonalized)); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } } if ($feedToday = getTodaysItems($feedData, $currentDate)) { if ($feedTodayPersonalized = personalizeAffiliateLinks(array_slice($feedToday, 0, $feedLimit), $affiliateTagId)) { try { file_put_contents($outputTodayLocation . '/' . $outputTodayFilename, makeRssDoc($feedTodayPersonalized)); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n";