Example #1
0
 private function config_jsdz()
 {
     $this->db = System::load_sys_class('model');
     $param = array("version" => "1.0", "token" => "", "merchantNum" => ConfigUtil::get_val_by_key('merchantNum'), "merchantRemark" => $this->config['shouname'], "tradeNum" => $this->config['code'], "tradeName" => $this->config['title'], "tradeDescription" => $this->config['title'], "tradeTime" => date('Y-m-d H:i:s', time()), "tradeAmount" => $this->config['money'] * 100, "currency" => "CNY", "notifyUrl" => $this->config['NotifyUrl'], "successCallbackUrl" => $this->config['ReturnUrl'], "failCallbackUrl" => $this->config['ReturnUrl']);
     $sign = SignUtil::sign($param);
     $param["merchantSign"] = $sign;
     if ($param["version"] == "1.0") {
         //敏感信息未加密
     } else {
         if ($param["version"] == "2.0") {
             //敏感信息加密
             //获取商户 DESkey
             //对敏感信息进行 DES加密
             $desUtils = new DesUtils();
             $key = ConfigUtil::get_val_by_key("desKey");
             $param["merchantRemark"] = $desUtils->encrypt($param["merchantRemark"], $key);
             $param["tradeNum"] = $desUtils->encrypt($param["tradeNum"], $key);
             $param["tradeName"] = $desUtils->encrypt($param["tradeName"], $key);
             $param["tradeDescription"] = $desUtils->encrypt($param["tradeDescription"], $key);
             $param["tradeTime"] = $desUtils->encrypt($param["tradeTime"], $key);
             $param["tradeAmount"] = $desUtils->encrypt($param["tradeAmount"], $key);
             $param["currency"] = $desUtils->encrypt($param["currency"], $key);
             $param["notifyUrl"] = $desUtils->encrypt($param["notifyUrl"], $key);
             $param["successCallbackUrl"] = $desUtils->encrypt($param["successCallbackUrl"], $key);
             $param["failCallbackUrl"] = $desUtils->encrypt($param["failCallbackUrl"], $key);
         }
     }
     $cbjpaySubmit = new CbjpaySubmit($param);
     $this->url = $cbjpaySubmit->buildRequestForm($param, 'POST', 'submit');
 }
Example #2
0
 public function __construct($collection)
 {
     $this->_mongo = new MongoConnection();
     $this->_mongo->getCredentialsFromConfig(ConfigUtil::getConfig());
     $this->_mongo->open();
     $this->_mongo->setCollection($collection);
 }
 /**
  * Validate search criteria.
  */
 function validateCriteria()
 {
     $type_of_data = $this->criteria['global']['type_of_data'];
     if (!isset($this->criteria['global']['records_from'])) {
         $this->criteria['global']['records_from'] = 1;
     }
     $records_from = $this->criteria['global']['records_from'];
     if (!isset($this->criteria['global']['max_records'])) {
         $this->criteria['global']['max_records'] = $this->getMaxAllowedTransactionResults();
     }
     $max_records = $this->criteria['global']['max_records'];
     $response_format = $this->criteria['global']['response_format'];
     if (!isset($type_of_data)) {
         $this->addError(1000, array('@paramName' => 'type_of_data'));
     } else {
         if (!in_array($type_of_data, ValidatorConfig::$domains)) {
             $this->addError(1001, array('@value' => $type_of_data, '@paramName' => 'type_of_data', '@validValues' => implode(',', ValidatorConfig::$domains)));
         }
     }
     if (!in_array($response_format, ValidatorConfig::$response_formats)) {
         $this->addError(1001, array('@value' => $response_format, '@paramName' => 'response_format', '@validValues' => implode(',', ValidatorConfig::$response_formats)));
     }
     $this->validateResultRecordRange($records_from, $max_records);
     if (!$this->hasErrors()) {
         $domain_config = ConfigUtil::getDomainConfiguration(strtolower($type_of_data));
         $this->validateDomainCriteria($type_of_data, $domain_config);
     }
 }
Example #4
0
 public function getBeauticianWorkTime()
 {
     $workTime = ConfigUtil::loadConfig($this->beauticianWorkTimeConfigFile);
     if (is_array($workTime)) {
         $this->beauticianWorkTime = $workTime;
     }
     return $workTime;
 }
Example #5
0
 public function __construct($config = 'weixin')
 {
     $weixinConfig = ConfigUtil::loadConfig($config);
     $this->appId = $weixinConfig['appId'];
     $this->appSecret = $weixinConfig['appSecret'];
     $this->mchId = $weixinConfig['mchId'];
     $this->apiKey = $weixinConfig['apiKey'];
     $this->noticeUrl = $weixinConfig['noticeUrl'];
 }
Example #6
0
 public function __construct($totalSize = 0, $config = 'pagination')
 {
     $config = ConfigUtil::loadConfig($config);
     $instance = get_instance();
     $config['total_rows'] = $totalSize;
     $config['base_url'] = RequestUtil::CM();
     $instance->load->library('pagination', $config);
     $this->pagination = $instance->pagination;
 }
Example #7
0
 public function __construct($config = 'weixin')
 {
     $weixinConfig = ConfigUtil::loadConfig($config);
     $this->appId = $weixinConfig['appId'];
     $this->appSecret = $weixinConfig['appSecret'];
     $this->mchId = $weixinConfig['mchId'];
     $this->apiKey = $weixinConfig['apiKey'];
     $this->noticeUrl = $weixinConfig['noticeUrl'];
     include 'WxPayPubHelper/WxPayPubHelper.php';
 }
Example #8
0
 /**
  * 获得当前用户领取的优惠券
  * @param $openId
  * @param int $offset
  */
 public function getCustomerCouponList($openId, $offset = 0)
 {
     $coupon = new CouponModel();
     $where = array('open_id' => $openId);
     $this->db->order_by('customer_coupon_id desc');
     $pagination = ConfigUtil::loadConfig('pagination');
     $limit = $pagination['per_page'];
     $this->db->join($coupon->table, "{$this->table}.coupon_id={$coupon->table}.coupon_id");
     $query = $this->db->get_where($this->table, $where, $limit, $offset);
     return $query->result_array();
 }
 public function getCustomerExchangeGoodsList($openId, $offset = 0)
 {
     $exchangeGoods = new ExchangeGoodsModel();
     $where = array('open_id' => $openId);
     $this->db->order_by('customer_exchange_goods_id desc');
     $pagination = ConfigUtil::loadConfig('pagination');
     $limit = $pagination['per_page'];
     $this->db->join($exchangeGoods->table, "{$this->table}.exchange_goods_id={$exchangeGoods->table}.exchange_goods_id");
     $query = $this->db->get_where($this->table, $where, $limit, $offset);
     return $query->result_array();
 }
Example #10
0
 /**
  * 我的订单
  * @param $openId
  * @param int $orderStatus
  * @param int $offset
  * @return mixed
  */
 public function getUserOrders($openId, $orderStatus = 0, $offset = 0)
 {
     $paginationConfig = ConfigUtil::loadConfig('user-center');
     $rows = $paginationConfig['per_page'];
     $sql = "select a.*, b.*, c.name as beautician_name, a.order_status+0 as order_sign from `order` as a" . " left join order_project as b on a.order_id=b.order_id" . " left join beautician as c on a.beautician_id=c.beautician_id ";
     $orderStatusWhere = '';
     if ($orderStatus) {
         $orderStatusWhere = " and a.order_status={$orderStatus}";
     }
     $sql .= " where a.disabled=0 and a.open_id='{$openId}'{$orderStatusWhere}" . " order by a.order_id desc limit {$offset}, {$rows}";
     return (new CurdUtil($this))->query($sql);
 }
Example #11
0
 /**
  * 缩略图
  * @param $resizeType
  * @param $upload
  */
 public function resizeImage($resizeType, $upload)
 {
     if (!is_array($resizeType)) {
         $resizeType = array($resizeType);
     }
     $this->instance->load->library('image_lib');
     foreach ($resizeType as $type) {
         $config = ConfigUtil::loadConfig($type);
         $config['source_image'] = $upload['full_path'];
         $this->instance->image_lib->initialize($config);
         $this->instance->image_lib->resize();
         $this->instance->image_lib->clear();
     }
 }
Example #12
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (Yii::app()->getUrlManager()->showScriptName) {
         $scriptUrl = basename($_SERVER['SCRIPT_NAME']);
         if (strpos($_SERVER['REQUEST_URI'], $scriptUrl) === false) {
             header("location: index.php");
         }
     }
     $entries = array();
     if (ConfigUtil::getUrlFopen()) {
         $xml = @simplexml_load_file('http://feeds.launchpad.net/chive/announcements.atom');
         if ($xml != null) {
             $entries = $xml->entry;
         }
     }
     $this->render('index', array('entries' => $entries, 'formatter' => Yii::app()->getDateFormatter()));
 }
Example #13
0
 public function readLimit($where, $limit = '', $order = '', $config = 'pagination')
 {
     if (!$limit) {
         $limit = 0;
     }
     if (empty($where)) {
         $where = '1=1';
     }
     if ($order) {
         $this->db->order_by($order);
     }
     $pagination = ConfigUtil::loadConfig($config);
     $offset = $pagination['per_page'];
     $this->model->beforeRead();
     $query = $this->db->get_where($this->table, $where, $offset, $limit);
     $this->model->afterRead();
     return $this->result($query);
 }
Example #14
0
 /**
  * Returns the maximum filesize to upload
  *
  * @param	bool		return as formatted string
  * @return	mixed
  */
 public static function getMaxUploadSize($_asString = false, $_value = null)
 {
     $maxUpload = ConfigUtil::ini2bytes(ini_get("upload_max_filesize"));
     $maxPost = ConfigUtil::ini2bytes(ini_get("post_max_size"));
     if ($_value != null) {
         if ($_value < $maxUpload) {
             $maxUpload = $_value;
         }
         if ($_value < $maxPost) {
             $maxPost = $_value;
         }
     }
     if ($maxPost < $maxUpload) {
         $maxUpload = $maxPost;
     }
     if ($_asString) {
         return Formatter::fileSize($maxUpload);
     } else {
         return $maxUpload;
     }
 }
Example #15
0
 /**
  * @param array  $config
  * @param string $propertyPath
  * @param array  $fieldConfig
  *
  * @return array
  */
 protected function applyPropertyPathConfig(array $config, $propertyPath, array &$fieldConfig)
 {
     $properties = ConfigUtil::explodePropertyPath($propertyPath);
     $currentConfig =& $config;
     $currentProperty = $properties[0];
     $this->applyPropertyConfig($currentConfig, $currentProperty);
     $count = count($properties);
     if ($count > 1) {
         $i = 1;
         while ($i < $count) {
             $currentConfig =& $currentConfig[ConfigUtil::FIELDS][$properties[$i - 1]];
             if (null === $currentConfig) {
                 $currentConfig = [];
             }
             $currentProperty = $properties[$i];
             $this->applyPropertyConfig($currentConfig, $currentProperty);
             $i++;
         }
     }
     if (array_key_exists(ConfigUtil::DATA_TRANSFORMER, $fieldConfig)) {
         $currentConfig[ConfigUtil::FIELDS][$currentProperty][ConfigUtil::DATA_TRANSFORMER] = $fieldConfig[ConfigUtil::DATA_TRANSFORMER];
         unset($fieldConfig[ConfigUtil::DATA_TRANSFORMER]);
     }
     return $config;
 }
Example #16
0
 public function getMaxFileSize()
 {
     return ConfigUtil::getMaxUploadSize(true);
 }
		</tr>
		<tr>
			<td><?php 
echo Yii::t('core', 'chiveVersion');
?>
</td>
			<td><?php 
echo Yii::app()->params->version;
?>
</td>
		</tr>
	</tbody>
</table>

<?php 
if (ConfigUtil::getUrlFopen() && count($entries) > 0) {
    ?>
	<table class="list" style="float: left; width: 50%; margin-left: 10px;">
		<colgroup>
			<col style="width: 200px;"></col>
			<col></col>
			<col style="width: 20px;"></col>
		</colgroup>
		<thead>
			<tr>
				<th colspan="3">
					<span class="icon">
						<?php 
    echo CHtml::link(Html::icon('rss'), 'http://feeds.launchpad.net/chive/announcements.atom');
    ?>
						<span><?php 
Example #18
0
        }
        // 验签成功,业务处理
        // 对Data数据进行解密
        $des = new DesUtils();
        // (秘钥向量,混淆向量)
        $decryptArr = $des->decrypt($params['DATA'][0], $desKey);
        // 加密字符串
        $log_->log_result("对<DATA>进行解密得到的数据:" . $decryptArr);
        $params['data'] = $decryptArr;
        $log_->log_result("最终数据:" . json_encode($params));
        $log_->log_result("**********接收异步通知结束。**********\n\n");
        return 200;
    }
}
$MD5_KEY = ConfigUtil::get_val_by_key("md5Key");
$DES_KEY = ConfigUtil::get_val_by_key("desKey");
/**
 * 测试列子 
 */
//start
$testString = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxDSElOQUJBTks+DQogICAg\n\n            PFZFUlNJT04+MS4yLjA8L1ZFUlNJT04+DQogICAgPE1FUkNIQU5UPjIyMzEyNzgxPC9NRVJDSEFO\n\n            VD4NCiAgICA8VEVSTUlOQUw+MDAwMDAwMDE8L1RFUk1JTkFMPg0KICAgIDxEQVRBPkJiQ2NzeVUx\n\n            L3kyMjlIeXZ4RFQ1Rm1SVnVjSFRXUFJqaGhyWmViRW1wTVAvL2xjdW04cjBRdVhGcjZPeDY5NXdN\n\n            dEYwblMwWHhjYVYKOVNoMWdrYU16dVJHQXorcytjOWhYREVnMUFXNVNUY3lRM0c3UTZKdzlBajJM\n\n            V0ZpelQ5cUNRYXVqT1FQT3RPWjIyRWF2RzZzNVJYLwo4c3AzYlJKa3hKNnpDYlQ3ckw0anNJZm9G\n\n            T05BdDBIV1VYUUpiazRBa3NlK1d3emNybU5QUDVzMVcyckRPUnA5Z3cwcVVhVW9DZmdNCk5LSGNY\n\n            Ymx2ZVZlVmNZeHlBMHJrRk9xNnFIV0tybEhqRGdqVWl0dFJZQU9CYlA0TDJDSTVvK3dMQzNpV1Z5\n\n            NmVpTHd2QnNJeWM3amwKU2NhanNaTkgxeDlPbUhUVitXWFA1ejBlejdYb0U1SGJUaDBmckdaeERZ\n\n            U2wwZlQvMnkvUDFpbnlrVUpwQktiVnA3c2w4NVVyZjVTcgpZZGM0VzA0QXdJajI0NnBpOW1KUHU2\n\n            d0w2bG5VV24zdXpjT2xDRUxpWkJ6OTJueXI3anlYeXIzR05Ha0VwdFdudXlYenhXV3AzMW8zCmNm\n\n            MFkwWTMrMGJjbm5BPT08L0RBVEE+DQogICAgPFNJR04+YzhhYTc1NGVmZjQ5MzIyNmYzNzU4NTJk\n\n            MGFmNTlmMmU8L1NJR04+DQo8L0NISU5BQkFOSz4NCg0K";
if (isset($_POST["resp"])) {
    $w = new WebAsynNotificationCtrl();
    $w->execute($MD5_KEY, $DES_KEY, $_POST["resp"]);
} else {
    $webAsynNotificationCtrl = new WebAsynNotificationCtrl();
    $webAsynNotificationCtrl->execute($MD5_KEY, $DES_KEY, $testString);
    //end
}
?>
Example #19
0
 public static function log($message, $code = -1)
 {
     $logsLocation = ConfigUtil::getLogsPath();
     $logger = new Logger($logsLocation);
     $logger->message($code, print_r($message, true));
 }
Example #20
0
 public static function get_trade_num()
 {
     return ConfigUtil::get_val_by_key('merchantNum') . ConfigUtil::getMillisecond();
 }
Example #21
0
    echo CHtml::hiddenField("Import", "true");
    ?>
		<fieldset>
			<legend><?php 
    echo Yii::t('core', 'importFile');
    ?>
</legend>
			<?php 
    echo CHtml::fileField('file', '', array());
    ?>
&nbsp;
			(<?php 
    echo Yii::t('core', 'maximum');
    ?>
: <?php 
    echo ConfigUtil::getMaxUploadSize(true);
    ?>
)
			<br />
			<br />
			<?php 
    //echo Yii::t('core', 'characterSet', array(1));
    ?>
<br />
			<?php 
    //echo CHtml::activeDropDownList($model, 'fromCharacterSet', CHtml::listData($model->characterSets, 'name', 'name'));
    ?>
			<b><?php 
    echo Yii::t('core', 'notice');
    ?>
</b><br />
Example #22
0
 public function houtai()
 {
     $resp = $_REQUEST['resp'];
     if (null == $resp) {
         return;
     }
     $desKey = ConfigUtil::get_val_by_key("desKey");
     $md5Key = ConfigUtil::get_val_by_key("md5Key");
     $params = $this->xml_to_array(base64_decode($resp));
     $ownSign = $this->generateSign($params, $md5Key);
     $params_json = json_encode($params);
     if ($params['SIGN'][0] == $ownSign) {
         // 验签正确
         //echo "签名验证正确!" . "\n";
         $des = new DesUtils();
         // (秘钥向量,混淆向量)
         $decryptArr = $des->decrypt($params['DATA'][0], $desKey);
         // 加密字符串
         $params['data'] = $decryptArr;
         $respone = $this->xml_to_array($decryptArr);
         if ($respone['RETURN']['code'] == '0000' || $respone['RETURN']['DESC'] == '成功') {
             //数据库操作
             $v_oid = $respone['TRADE']['ID'];
             $this->db->Autocommit_start();
             $dingdaninfo = $this->db->GetOne("select * from `@#_member_addmoney_record` where `code` = '{$v_oid}' and `status` = '未付款' for update");
             if (!$dingdaninfo) {
                 return;
             }
             //没有该订单,失败
             $c_money = intval($dingdaninfo['money']);
             $j_num = intval($c_money / 100);
             $uid = $dingdaninfo['uid'];
             $time = time();
             $up_q1 = $this->db->Query("UPDATE `@#_member_addmoney_record` SET `pay_type` = '京东支付手机', `status` = '已付款' where `id` = '{$dingdaninfo['id']}' and `code` = '{$dingdaninfo['code']}'");
             $up_q2 = $this->db->Query("UPDATE `@#_member` SET `money` = `money` + {$c_money},`jiangnum`=`jiangnum`+{$j_num} where (`uid` = '{$uid}')");
             $up_q3 = $this->db->Query("INSERT INTO `@#_member_account` (`uid`, `type`, `pay`, `content`, `money`, `time`) VALUES ('{$uid}', '1', '账户', '京东支付手机', '{$c_money}', '{$time}')");
             if ($up_q1 && $up_q2 && $up_q3) {
                 $this->db->Autocommit_commit();
             } else {
                 $this->db->Autocommit_rollback();
                 return;
             }
             if (empty($dingdaninfo['scookies'])) {
                 //充值完成
                 return;
             }
             $scookies = unserialize($dingdaninfo['scookies']);
             $pay = System::load_app_class('pay', 'pay');
             $pay->scookie = $scookies;
             $ok = $pay->init($uid, $pay_type['pay_id'], 'go_record');
             //闪购商品
             if ($ok != 'ok') {
                 _setcookie('Cartlist', NULL);
                 //商品购买失败
                 return;
             }
             $check = $pay->go_pay(1);
             if ($check) {
                 $this->db->Query("UPDATE `@#_member_addmoney_record` SET `scookies` = '1' where `code` = '{$v_oid}' and `status` = '已付款'");
                 _setcookie('Cartlist', NULL);
                 return;
             } else {
                 return;
             }
         } else {
             return;
         }
     } else {
         //echo "签名验证错误!" . "\n";
         return;
     }
 }
Example #23
0
 public static function get_node($node = NULL)
 {
     if (!$node or !is_string($node)) {
         throw new Exception("{$node} format error.");
     }
     $ret = ConfigUtil::get_instance()->load($node);
     return isset($ret[$node]) ? $ret[$node] : FALSE;
 }
Example #24
0
 /**
  *网银在线网关地址
  */
 function __construct($cbpay_config)
 {
     $this->cbpay_config = $cbpay_config;
     $this->cbjpay_gateway_new = ConfigUtil::get_val_by_key('serverPayUrl');
 }
Example #25
0
 /**
  * @return mixed
  */
 private function loadConfiguration()
 {
     // TODO - Avoid loading twice. Already loaded in search criteria.
     $criteria = $this->requestSearchCriteria->getCriteria();
     $configuration = ConfigUtil::getConfiguration($criteria['global']['type_of_data'], $this->requestSearchCriteria->getConfigKey());
     return $configuration;
 }
Example #26
0
 /**
  * @param array  $row
  * @param string $propertyPath
  *
  * @return mixed
  */
 protected function extractValueByPropertyPath(array &$row, $propertyPath)
 {
     $result = null;
     $properties = ConfigUtil::explodePropertyPath($propertyPath);
     $lastIndex = count($properties) - 1;
     $i = 0;
     $path = [];
     $currentRow =& $row;
     while ($i <= $lastIndex) {
         $property = $properties[$i];
         if (null === $currentRow || !array_key_exists($property, $currentRow)) {
             break;
         }
         if ($i === $lastIndex) {
             // get property value
             $result = $currentRow[$property];
             // remove extracted property
             unset($currentRow[$property]);
             // remove empty containers
             $p = count($path) - 1;
             while ($p >= 0) {
                 $currentRow =& $path[$p][0];
                 if (!empty($currentRow[$path[$p][1]])) {
                     break;
                 }
                 unset($currentRow[$path[$p][1]]);
                 $p--;
             }
             break;
         }
         $path[] = [&$currentRow, $property];
         $currentRow =& $currentRow[$property];
         $i++;
     }
     return $result;
 }
Example #27
0
 /**
  * Given the filename, returns an array of commands to execute for xml file creation,
  * This function modifies the sql to handle derived columns dynamically.
  *
  * @param $filename
  * @return array
  */
 private function getXMLJobCommands($filename)
 {
     global $conf;
     $query = $this->jobDetails['data_command'];
     $request_criteria = $this->jobDetails['request_criteria'];
     $search_criteria = new SearchCriteria($request_criteria, $this->responseFormat);
     $config = ConfigUtil::getConfiguration($request_criteria['global']['type_of_data'], $search_criteria->getConfigKey());
     //map tags and build sql
     $rootElement = $config->dataset->displayConfiguration->xml->rootElement;
     $rowParentElement = $config->dataset->displayConfiguration->xml->rowParentElement;
     $elementsColumn = $config->dataset->displayConfiguration->xml->elementsColumn;
     $elementsColumn = (array) $elementsColumn;
     $columnMappings = array_flip($elementsColumn);
     $end = strpos($query, 'FROM');
     $select_part = substr($query, 0, $end);
     $select_part = str_replace("SELECT", "", $select_part);
     $sql_parts = explode(",", $select_part);
     $new_select_part = "'<" . $rowParentElement . ">'";
     foreach ($sql_parts as $sql_part) {
         $sql_part = trim($sql_part);
         $is_derived_column = strpos(strtoupper($sql_part), "CASE WHEN") !== FALSE;
         //get column and alias
         $alias = "";
         if ($is_derived_column) {
             $pos = strpos($sql_part, " AS");
             $column = trim(str_replace("AS", "", substr($sql_part, $pos)));
         } else {
             $pos = strpos($sql_part, " AS");
             $pos = $pos !== FALSE ? $pos : strlen($sql_part);
             $column = substr($sql_part, 0, $pos);
         }
         if (strpos($sql_part, ".") !== false) {
             $alias_pos = strpos($sql_part, ".");
             $alias = substr($sql_part, $alias_pos - 2, 3);
             $column = str_replace($alias, "", $column);
         }
         //Handle derived columns
         $tag = $columnMappings[$column] == "" ? $column : $columnMappings[$column];
         //column open tag
         $new_select_part .= "\n||'<" . $tag . ">' || ";
         if ($is_derived_column) {
             $sql_part = substr_replace($sql_part, "", $pos);
             $new_select_part .= str_replace($alias . $column, "REPLACE(REPLACE(REPLACE(COALESCE(CAST(" . $alias . $column . " AS VARCHAR),''),'&','&amp;'),'>','&gt;'),'<','&lt;')", $sql_part);
         } else {
             $new_select_part .= "REPLACE(REPLACE(REPLACE(COALESCE(CAST(" . $alias . $column . " AS VARCHAR),''),'&','&amp;'),'>','&gt;'),'<','&lt;')";
         }
         //column close tag
         $new_select_part .= " || '</" . $tag . ">'";
     }
     $new_select_part .= "||'</" . $rowParentElement . ">'";
     $new_select_part = "SELECT " . ltrim($new_select_part, "\n||") . "\n";
     $query = substr_replace($query, $new_select_part, 0, $end);
     //open/close tags
     $open_tags = "<?xml version=\"1.0\"?><response><status><result>success</result></status>";
     $open_tags .= "<result_records><record_count>" . $this->getRecordCount() . "</record_count><" . $rootElement . ">";
     $close_tags = "</" . $rootElement . "></result_records></response>";
     $file = $this->getFullPathToFile($filename, $this->tmpFileOutputDir);
     $commands = array();
     //sql command
     $command = $conf['check_book']['data_feeds']['command'] . " -c \"\\\\COPY (" . $query . ") TO '" . $file . "' \" ";
     $commands[$filename][] = $command;
     //prepend open tags command
     $command = "sed -i '1i " . $open_tags . "' " . $file;
     $commands[$filename][] = $command;
     //append close tags command
     $command = "sed -i '\$" . "a" . $close_tags . "' " . $file;
     $commands[$filename][] = $command;
     //xmllint command to format the xml
     $formatted_filename = $this->tmpFileOutputDir . '/formatted_' . $filename . '.xml';
     $command = "xmllint --format {$file} --output {$formatted_filename}";
     $commands[$filename][] = $command;
     //move the formatted file back
     $command = "mv {$formatted_filename} {$file}";
     $commands[$filename][] = $command;
     return $commands;
 }