コード例 #1
0
 protected function _post_args($key, $type = ARGS_TYPE_STRING, $default = '', $params = array())
 {
     $value = '';
     $post_default = '';
     $key_exist = array_key_exists($key, $_POST);
     $override = array_key_exists('override', $params) ? $params['override'] : FALSE;
     $entities_to_ascii = array_key_exists('entities_to_ascii', $params) ? $params['entities_to_ascii'] : FALSE;
     $gtzero = array_key_exists('gtzero', $params) ? $params['gtzero'] : TRUE;
     switch ($type) {
         case ARGS_TYPE_STRING:
             $post_default = $override ? $default : '';
             $value = $key_exist ? $this->input->post($key, TRUE) ? $this->input->post($key, TRUE) : $post_default : $default;
             if ($entities_to_ascii) {
                 $value = entities_to_ascii($value);
             }
             break;
         case ARGS_TYPE_INT:
             $default = validate_integer($default) ? to_int($default) : 0;
             $post_default = $override ? $default : 0;
             $value = $key_exist ? ($value = $this->input->post($key)) && gtzero_integer($value) ? to_int($value) : $post_default : $default;
             break;
         case ARGS_TYPE_TRUE_FALSE:
             $default = validate_integer($default) ? gtzero_integer($default) ? TRUE : FALSE : FALSE;
             $post_default = $override ? $default : FALSE;
             $value = $key_exist ? ($value = $this->input->post($key)) && ($gtzero && gtzero_integer($value) || !$gtzero && validate_integer($value)) ? TRUE : $post_default : $default;
             break;
         case ARGS_TYPE_ARRAY:
             $value = $key_exist ? ($value = $this->input->post($key)) && is_array($value) ? $value : array() : (is_array($default) ? $default : array());
             break;
         case ARGS_TYPE_DECIMAL:
             $default = gtzero_decimal($default) ? to_float($default) : 0;
             $post_default = $override ? $default : 0;
             $value = $key_exist ? ($value = $this->input->post($key)) && gtzero_decimal($value) ? to_float($value) : $post_default : $default;
             break;
         case ARGS_TYPE_DATE:
             $default = validate_date($default) ? $default : '';
             $post_default = $override ? $default : '';
             $value = $key_exist ? ($value = $this->input->post($key)) && validate_date($value) ? $value : $post_default : $default;
             break;
         case ARGS_TYPE_DATETIME:
             $default = validate_datetime($default) ? $default : '';
             $post_default = $override ? $default : '';
             $value = $key_exist ? ($value = $this->input->post($key)) && validate_date($value) ? $value : $post_default : $default;
             break;
         default:
             $post_default = $override ? $default : '';
             $value = $key_exist ? $this->input->post($key, TRUE) ? $this->input->post($key, TRUE) : $post_default : $default;
             break;
     }
     unset($post_default);
     return $value;
 }
コード例 #2
0
ファイル: order.action.php プロジェクト: ohjack/newErp
 private function act_getOrderCondition()
 {
     #########################################################################
     #########					 查询条件 start			 			#########
     #########################################################################
     $nowtime = time();
     $starttime = $endtime = 0;
     $searcherrs = $ordercd = $userinfo = array();
     if (isset($_GET['KeywordsType']) && $_GET['KeywordsType'] != '*' && !empty($_GET['KeywordsType'])) {
         $field = trim($_GET['KeywordsType']);
         if (isset($_GET['Keywords']) && !empty($_GET['Keywords'])) {
             $Keywords = trim($_GET['Keywords']);
             if (in_array($field, array('platformId'))) {
                 $Keywords = getPlatformIdFromName($Keywords);
             } elseif (in_array($field, array('accountId'))) {
                 $Keywords = getAccountIdFromName($Keywords);
             }
             $keycond = strpos($Keywords, ',') !== false ? array('$in' => array2strarray(explode(',', $Keywords))) : array('$e' => $Keywords);
             if (in_array($field, array('id', 'recordNumber', 'platformId', 'accountId'))) {
                 $ordercd[$field] = $keycond;
             } else {
                 if (in_array($field, array('email', 'platformUsername'))) {
                     $userinfo[$field] = $keycond;
                 } else {
                     if (in_array($field, array('tracknumber'))) {
                         $trackcd[$field] = $keycond;
                     } else {
                         if (in_array($field, array('PayPalPaymentId'))) {
                             $orderextcd[$field] = $keycond;
                         }
                     }
                 }
             }
         }
     }
     if (isset($_GET['status']) && $_GET['status'] != '*' && !empty($_GET['status'])) {
         $ordercd['status'] = array('$e' => intval($_GET['status']));
         $ordercd['menu'] = array('$e' => intval($_GET['menu']));
     }
     if (isset($_GET['platformId']) && $_GET['platformId'] != '*' && !empty($_GET['platformId'])) {
         $ordercd['platformId'] = array('$e' => intval($_GET['platformId']));
     }
     if (isset($_GET['accountId']) && $_GET['accountId'] != '*' && !empty($_GET['accountId'])) {
         $ordercd['accountId'] = array('$e' => intval($_GET['accountId']));
     }
     if (isset($_GET['transportationType']) && $_GET['transportationType'] != '*' && !empty($_GET['transportationType'])) {
         $ordercd['transportationType'] = array('$e' => intval($_GET['transportationType']));
     }
     if (isset($_GET['transportation']) && $_GET['transportation'] != '*' && !empty($_GET['transportation'])) {
         $ordercd['transportId'] = array('$e' => intval($_GET['transportation']));
     }
     if (isset($_GET['isNote']) && $_GET['isNote'] != '*' && !empty($_GET['isNote'])) {
         $ordercd['isNote'] = array('$e' => intval($_GET['isNote']));
     }
     if (isset($_GET['ostatus']) && !empty($_GET['ostatus']) && $_GET['ostatus'] != '*') {
         $ordercd['orderStatus'] = array('$e' => intval($_GET['ostatus']));
     }
     if (isset($_GET['isexpressdelivery']) && !empty($_GET['isexpressdelivery']) && $_GET['isexpressdelivery'] != '*') {
         $ordercd['isExpressDelivery'] = array('$e' => intval($_GET['isexpressdelivery']));
     }
     if (isset($_GET['otype']) && !empty($_GET['otype']) && $_GET['otype'] != '*') {
         $ordercd['orderType'] = array('$e' => intval($_GET['otype']));
     }
     if (isset($_GET['countrySn']) && !empty($_GET['countrySn'])) {
         $countrySn = trim($_GET['countrySn']);
         if ($this->act_checkCountryCode($countrySn) !== false) {
             $userinfo['countrySn'] = array('$e' => $countrySn);
         } else {
             $searcherrs[$this->errCode] = get_promptmsg($this->errCode, $countrySn);
         }
     }
     $sTimeType = isset($_GET['searchTimeType']) && !empty($_GET['searchTimeType']) ? trim($_GET['searchTimeType']) : 'paymentTime';
     if (isset($_GET['OrderTime1']) && !empty($_GET['OrderTime1'])) {
         $OrderTime1 = trim($_GET['OrderTime1']);
         if (validate_datetime($OrderTime1)) {
             $starttime = strtotime($OrderTime1);
         } else {
             $searcherrs[10005] = get_promptmsg(10005, $OrderTime1);
         }
     }
     if (isset($_GET['OrderTime2']) && !empty($_GET['OrderTime2'])) {
         $OrderTime2 = trim($_GET['OrderTime2']);
         if (validate_datetime($OrderTime2)) {
             $endtime = strtotime($OrderTime2);
         } else {
             $searcherrs[10006] = get_promptmsg(10006, $OrderTime2);
         }
     }
     if ($starttime > 0 && $endtime === 0 && $nowtime) {
         $ordercd[$sTimeType] = array('$gt' => $starttime);
     } else {
         if ($starttime === 0 && $endtime > 0) {
             $ordercd[$sTimeType] = array('$lt' => $endtime);
         } else {
             if ($starttime < $endtime) {
                 $ordercd[$sTimeType] = array('$b' => "{$starttime}-{$endtime}");
             } else {
                 if ($starttime > $endtime) {
                     $searcherrs[10007] = get_promptmsg(10007, $OrderTime1, $OrderTime2);
                 } else {
                     if ($starttime > 0 && ($starttime = $endtime)) {
                         $searcherrs[10008] = get_promptmsg(10008, $OrderTime1, $OrderTime2);
                     }
                 }
             }
         }
     }
     if (isset($this->orderpower) && !empty($this->orderpower)) {
         foreach ($this->orderpower as $name => $plist) {
             $ordercds[] = "{$name} IN (" . implode(',', $plist) . ")";
         }
     }
     //分表相关
     $ordercd['is_delete'] = array('$e' => 0);
     //查询条件合并
     $conditions = array();
     $conditions['order'] = $ordercd;
     //主表必须在前面
     if (!empty($userinfo)) {
         $conditions['userinfo'] = $userinfo;
     }
     if (!empty($trackcd)) {
         $conditions['trackcd'] = $trackcd;
     }
     if (!empty($orderextcd)) {
         $conditions['orderextcd'] = $orderextcd;
     }
     #########################################################################
     #########					 查询条件 end			 				#########
     #########################################################################
     return $conditions;
 }
コード例 #3
0
ファイル: index.php プロジェクト: akaplya/xhprof.io
// $_GET['xhprof']['query'] is used throughout the code to filter data. NULL value will be ignored.
// This is a convenience method to prevent repetitious variable presence checking.
if (empty($_GET['xhprof']['query'])) {
    $_GET['xhprof']['query'] = NULL;
} else {
    foreach ($_GET['xhprof']['query'] as $e) {
        if (is_array($e)) {
            throw new \Exception('Defining a filter with a multidimensional array is not supported.');
        }
    }
    // ay_input() will look for the default input value in this globally accessible variable.
    $input = array('query' => $_GET['xhprof']['query']);
    if (!empty($_GET['xhprof']['query']['datetime_from']) && !validate_datetime($_GET['xhprof']['query']['datetime_from'])) {
        \ay\message('Invalid <mark>from</mark> date-time format.');
    }
    if (!empty($_GET['xhprof']['query']['datetime_to']) && !validate_datetime($_GET['xhprof']['query']['datetime_to'])) {
        \ay\message('Invalid <mark>to</mark> date-time format.');
    }
    if (isset($_GET['xhprof']['query']['host'], $_GET['xhprof']['query']['host_id'])) {
        \ay\message('<mark>host_id</mark> will overwrite <mark>host</mark>. Unset either to prevent unexpected results.');
    }
    if (isset($_GET['xhprof']['query']['uri'], $_GET['xhprof']['query']['uri_id'])) {
        \ay\message('<mark>uri_id</mark> will overwrite <mark>uri</mark>. Unset either to prevent unexpected results.');
    }
}
$xhprof_data_obj = new Data($config['pdo']);
ob_start();
require BASE_PATH . '/templates/' . $template['file'] . '.tpl.php';
$template['body'] = ob_get_clean();
require BASE_PATH . '/templates/frontend.layout.tpl.php';
unset($_SESSION['ay']['flash']);
コード例 #4
0
    /**
     * 插入订单的验证和转化
     * @author yxd
     * @return boolean
     */
    public function act_transformInsertOrder()
    {
        #################order表信息验证及格式化##############################
        $distributorsData = json_decode('[
    {
        "order": {
            "recordNumber": "12680437",
            "account": "hello",
            "ordersTime": "2014-08-02 09:44:38",
            "paymentMethod": "PayPal",
            "paymentTime": "2014-08-02 09:44:38",
            "onlineTotal": "7.26",
            "currency": "AUD",
            "actualShipping": "22.000",
            "ORtransport": "chinapost"
        },
        "orderExtension": {
			"companyId": "yks",
            "payPalPaymentId": "7HE13018KL3271431",
            "orderId": "380882639665-508802711025",
            "feedback": "none"
        },
        "orderUserInfo": {
            "username": "******",
            "platformUsername": "******",
            "email": "*****@*****.**",
            "countryName": "Australia",
            "countrySn": "AU",
            "currency": "AUD",
            "state": "New South Wales",
            "city": "Peakhurst",
            "address1": "760a forest road",
            "address2": "760a forest road",
			"address3": "760a forest road",
            "phone": "02 91536215",
            "zipCode": "2210"
        },
	    "orderDeclarationContent" :[{
			"spu": "SV003829",
			"amount": 10,
			"price": 100,
			"enTitle": "T-Shirt",
			"cnTitle": "T恤",
			"hamcodes": "8531100000",
			"material":"棉",
			"unit": "pics"
	    }],
        "orderDetails": [
            {
                "orderDetail": {
                    "recordNumber": "630634",
                    "itemPrice": "7.26",
				    "itemId": "7733333",
                    "sku": "SV001920_BE_M",
                    "onlinesku": "SV001920_BE_M:N98B",
                    "amount": "1",
                    "shippingFee": "3.00",
                    "createdTime": "2014-08-02 09:44:38"
                },
                "orderDetailExtension": {
                    "itemTitle": "Womens Tummy Control Underbust Slimming Shapewear Shaper Suit Body Control N98B[Beige,Asian M (US S(4-6)  UK 6-8  EU ...",
                    "itemURL": "11"
                }
            }
        ]
    }
]', true);
        $order = $distributorsData[0]['order'];
        $recordNumber = $order['recordNumber'];
        //平台对应的订单号
        if (!isset($recordNumber)) {
            self::$errMsg[123] = '平台对应的订单号不能为空';
            return false;
        }
        if (!preg_match("/^\\w*\$/", $recordNumber)) {
            self::$errMsg[123] = 'recordnumber格式不规范';
        }
        $account = $order['account'];
        //账号
        if (!isset($account)) {
            self::$errMsg[123] = '账号不能为空';
            return false;
        }
        //验证账号是否存在
        if (!M('Account')->checkIsExists(array('account' => $account))) {
            self::$errMsg[1234] = '非法账号--不存在';
            return false;
        }
        //根据账号查找账号Id
        $accountId = M('Account')->getAccountIdByName($account);
        //账号id
        if (empty($accountId)) {
            self::$errMsg[1235] = '非法账号--不存在';
            return false;
        }
        //根据账号查平台Id
        $platformId = M('Account')->getPlatformid($accountId);
        //平台id
        $platformId = $platformId[0]['platformId'];
        if (empty($platformId)) {
            self::$errMsg[1236] = '非法账号';
            return false;
        }
        //这里还要验证该$account_id下这个$recordNumber是否存在查重
        if (M('OrderAdd')->checkIsExists(array('recordNumber' => $recordNumber, 'accountId' => $accountId))) {
            self::$errMsg[10043] = get_promptmsg(10043, $recordNumber);
            //"该recordNumber已经存在<br/>";
            return false;
        }
        //验证时间格式
        $ordersTime = $order['ordersTime'];
        //订单在平台的生成时间
        if (!validate_datetime($ordersTime)) {
            self::$errMsg[124] = '非法时间格式ordersTime标准格式为[2014-08-03 18:58:23]';
            return false;
        }
        $ordersTime = strtotime($ordersTime);
        //系统以时间戳格式存放
        $paymentTime = $order['paymentTime'];
        //订单付款时间
        if (!validate_datetime($paymentTime)) {
            self::$errMsg[124] = "非法时间格式paymentTime标准格式为[2014-08-03 18:58:23]";
            return false;
        }
        $paymentTime = strtotime(paymentTime);
        //系统以时间戳格式存放
        $orderAddTime = time();
        //订单进入系统时间时间
        $onlineTotal = $order['onlineTotal'];
        //线上总价 可以为空
        if (!validate_float2($onlineTotal)) {
            self::$errMsg[125] = "非法线上总价标准格式为[12.00]";
            return false;
        }
        $currency = $order['currency'];
        //币种3个大写字母,必填
        if (!preg_match("/^([A-Z]{3})\$/", $currency)) {
            self::$errMsg[124] = "非法币种标准格式为[3个大写字母组成]";
            return false;
        }
        $paymentMethod = $order['paymentMethod'];
        //付款方式
        if (empty($paymentMethod)) {
            self::$errMsg[111] = "付款方式不能为空";
            return false;
        }
        $ORtransport = $order['ORtransport'];
        // 订单进系统时分配给它的原始运输方式,只用作备份
        $actualShipping = $order['actualShipping'];
        //线上时间付款运费 可以为空
        if (!validate_float3($actualShipping)) {
            self::$errMsg[125] = "运费格式非法标准格式为[12.000]";
            return false;
        }
        $orderArr = array('recordNumber' => $recordNumber, 'platformId' => $platformId, 'accountId' => $accountId, 'ordersTime' => $ordersTime, 'paymentMethod' => $paymentMethod, 'paymentTime' => $paymentTime, 'onlineTotal' => $onlineTotal, 'currency' => $currency, 'ORtransport' => $ORtransport, 'actualShipping' => $actualShipping, 'orderAddTime' => $orderAddTime);
        ################orderdetail 及exteendtion数据验证#######################
        $orderDetails = $distributorsData[0]['orderDetails'];
        $orderDetailArr = array();
        foreach ($orderDetails as $value) {
            $orderDetail = $value['orderDetail'];
            //订单详情表
            $itemPrice = isset($orderDetail['itemPrice']) ? $orderDetail['itemPrice'] : 0.0;
            //平台对应的销售单价
            if (!validate_float2($itemPrice)) {
                self::$errMsg[123] = "平台对应的销售单价不规范标准格式为[12.00]";
                return false;
            }
            $itemId = isset($orderDetail['itemId']) ? $orderDetail['itemId'] : null;
            //商品在平台上的ID
            if (!preg_match("/^\\d*\$/", $itemId)) {
                self::$errMsg[123] = "商品在平台上的ID不规范标准格式为[5454143004]";
                return false;
            }
            $sku = $orderDetail['sku'];
            $isSkuExsit = M("InterfacePc")->getSkuinfo($sku);
            if (empty($isSkuExsit)) {
                self::$errMsg[123] = "sku在系统中不存在";
                return false;
            }
            $onlinesku = isset($orderDetail['onlinesku']) ? $orderDetail['onlinesku'] : null;
            //线上sku
            $amount = isset($orderDetail['amount']) ? $orderDetail['amount'] : 0;
            if (!preg_match("/^\\d*\$/", $amount)) {
                self::$errMsg = "订单中的商品数量不规范,必须为有效数字";
                return false;
            }
            $amount = intval($orderDetail['amount']);
            $shippingFee = $orderDetail['shippingFee'];
            //平台对应料号的运费
            if (!validate_float2($shippingFee)) {
                self::$errMsg[123] = "平台对应料号的运费不规范标准格式为[12.00]";
                return false;
            }
            $orderDetailExtension = $value['orderDetailExtension'];
            //订单详情扩展表
            $itemTitle = isset($orderDetailExtension['itemTitle']) ? $orderDetailExtension['itemTitle'] : null;
            $itemTitle = htmlentities($itemTitle);
            $itemURL = isset($orderDetailExtension['itemURL']) ? $orderDetailExtension['itemURL'] : null;
            $orderDetailArr[] = array("orderDetail" => array("recordNumber" => $recordNumber, 'itemId' => $itemId, "itemPrice" => $itemPrice, "sku" => $sku, "onlinesku" => $onlinesku, "amount" => $amount, "shippingFee" => $shippingFee), "orderDetailExtension" => array("itemTitle" => $itemTitle, "itemURL" => $itemURL));
        }
        ################# orderUserInfo###################################
        $orderUserInfo = $distributorsData[0]['orderUserInfo'];
        //获取分销商订单用户数据
        $username = $orderUserInfo['username'];
        //收件人
        $platformUsername = isset($orderUserInfo['platformUsername']) ? $orderUserInfo['platformUsername'] : null;
        //对应平台的用户登陆名称
        $platformUsername = htmlspecialchars($platformUsername);
        $email = $orderUserInfo['email'];
        //客户邮箱
        if (!validate_email($email)) {
            self::$errMsg['146'] = "非法邮箱格式";
            return false;
        }
        $countryname = $orderUserInfo['countryName'];
        //收件人国家名
        if (M('CountryList')->checkIsExists($countryname)) {
            self::$errMsg[145] = "非法国家";
            return false;
        }
        $countrySn = M('CountryList')->geZhByEn($countryname);
        //国家简码
        if (empty($countrySn)) {
            self::$errMsg[145] = "非法国家";
            return false;
        }
        $currency = isset($orderUserInfo['currency']) ? $orderUserInfo['currency'] : null;
        //币种
        $city = $orderUserInfo['city'];
        //买家所在城市
        $city = htmlspecialchars($city);
        $state = $orderUserInfo['state'];
        //买家所在州
        $state = htmlspecialchars($state);
        $address1 = isset($orderUserInfo['address1']) ? $orderUserInfo['address1'] : 0;
        $address1 = htmlspecialchars($address1);
        $address2 = isset($orderUserInfo['address2']) ? $orderUserInfo['address2'] : 0;
        $address2 = htmlspecialchars($address2);
        $address3 = isset($orderUserInfo['address3']) ? $orderUserInfo['address3'] : 0;
        $address3 = htmlspecialchars($address3);
        $landline = isset($orderUserInfo['landline']) ? $orderUserInfo['landline'] : 0;
        //座机
        $phone = isset($orderUserInfo['phone']) ? $orderUserInfo['phone'] : 0;
        //手机
        if (!validate_phone($phone)) {
            self::$errMsg[124] = "phone格式不规范";
            return false;
        }
        $zipCode = $orderUserInfo['zipCode'];
        //邮编
        if (!validate_zipCode($zipCode)) {
            self::$errMsg[124] = "zipCode不规范";
            return false;
        }
        $orderUserInfoArr = array('username' => $username, 'platformUsername' => $platformUsername, 'email' => $email, 'countryName' => $countryname, 'countrySn' => $countrySn, 'currency' => $currency, 'state' => $state, 'city' => $city, 'county' => "sss", 'address1' => $address1, 'address2' => $address2, 'address3' => $address3, 'phone' => $phone, 'zipCode' => $zipCode);
        ################# orderextension#######################################
        $orderExtensions = $distributorsData[0]['orderExtension'];
        $companyId = $orderExtensions['companyId'];
        $orderId = $orderExtensions['orderId'];
        //ebay系统线上抓取组合ID,格式为itemid-transid
        $feedback = $orderExtensions['feedback'];
        //客户留言
        $orderExtensionArr = array('companyId' => $companyId, 'orderId' => $orderId, 'feedback' => $feedback);
        #####################orderDeclarationContent##########################
        $orderDeclarationContent = $distributorsData[0]['orderDeclarationContent'];
        $orderDeclarationContentArr = array();
        foreach ($orderDeclarationContent as $value) {
            $spu = $value['spu'];
            //申报料号
            $amount = $value['amount'];
            //申报数量
            if (!preg_match("/^\\d*\$/", $amount)) {
                self::$errMsg[124] = "申报数量必须为有效数字";
                return false;
            }
            $price = $value['price'];
            //申报价值(美金)
            if (validate_float2($price)) {
                self::$errMsg[125] = "申报价值格式不规范标准格式为[12.00]";
                return false;
            }
            $enTitle = $value['enTitle'];
            //申报名称(英文)
            $enTitle = htmlspecialchars($enTitle);
            $cnTitle = $value['cnTitle'];
            //申报名称(文)
            $cnTitle = htmlspecialchars($cnTitle);
            $hamcodes = $value['hamcodes'];
            //海关编码
            $material = $value['material'];
            //申报材质
            $unit = $value['unit'];
            //计量单位
            /* 	$description    = $value['description'];//申报描述
               	$description    = htmlspecialchars($description); */
            $orderDeclarationContentArr[] = array("spu" => $spu, "amount" => $amount, "price" => $price, "enTitle" => $enTitle, "cnTitle" => $cnTitle, "hamcodes" => $hamcodes, "material" => $material, "unit" => $unit, "datetime" => time());
        }
        //格式化数据
        $data[] = array('order' => $orderArr, 'orderDetail' => $orderDetailArr, 'orderExtension' => $orderExtensionArr, 'orderUserInfo' => $orderUserInfoArr, 'orderDeclarationContent' => $orderDeclarationContentArr);
        ################  end 格式化POST信息到统一数组   ##################
        return array($data);
    }