Example #1
0
function amend($rrr)
{
    require_once 'ip.php';
    //$ip1 = $_SERVER['REMOTE_ADDR'];
    $ip1 = "122.200.86.153";
    $iplocation = new iplocate();
    $address = $iplocation->getaddress($ip1);
    $iparea = $address['area1'] . $address['area2'];
    echo $iparea;
    //$exe = mysql_query( "insert into ssc_memberamend set uid = '".$_SESSION["uid"]."',username = '******',level = '".$_SESSION["level"]."', cont='".$rrr."', ip='".$ip1."', area='".$iparea."', adddate='".date("Y-m-d H:i:s")."'");
    //return $rrr;
}
Example #2
0
 public function index()
 {
     $root = array();
     $client_ip = strim($GLOBALS['request']['client_ip']);
     if (empty($client_ip)) {
         $client_ip = get_client_ip();
     }
     $root['ip'] = $client_ip;
     $root['ip_city_name'] = '';
     $root['ip_city_id'] = 0;
     //设置如存在的IP订位
     if (file_exists(APP_ROOT_PATH . "system/extend/ip.php")) {
         require_once APP_ROOT_PATH . "system/extend/ip.php";
         $iplocation = new iplocate();
         $address = $iplocation->getaddress($client_ip);
         $root['address'] = $address;
         //$root['ip_city_name'] = str_replace('市', '', $address['area1']);
         $root['ip_city_id'] = 0;
         if (mb_strpos($address['area1'], '省', 0, 'utf-8') === false) {
             $root['ip_city_name'] = $address['area1'];
         } else {
             $ipos = intval(mb_strpos($address['area1'], '省', 0, 'utf-8'));
             $root['ip_city_name'] = mb_substr($address['area1'], $ipos + 1, 10, 'utf-8');
         }
         $root['ip_city_name'] = str_replace('市', '', $root['ip_city_name']);
         $sql = "select * from " . DB_PREFIX . "deal_city where is_delete = 0 and is_effect = 1 ";
         $city_list = $GLOBALS['db']->getAll($sql);
         //不知谁把$city_list 查询去掉了; 去掉后就不能通过ip定位了; chenfq 现在又添加上去了 2014-09-18
         foreach ($city_list as $city) {
             if (strpos($address['area1'], $city['name'])) {
                 $deal_city = $city;
                 $root['ip_city_id'] = $city['id'];
                 break;
             }
         }
     }
     if (!$deal_city) {
         $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_default = 1 and is_effect = 1 and is_delete = 0");
     }
     $root['city_name'] = $deal_city['name'];
     $root['city_id'] = $deal_city['id'];
     output($root);
 }
Example #3
0
File: city.php Project: macall/jsd
 public static function locate_city($city_py = "")
 {
     if (!$city_py) {
         $city_py = strim($_GET['city']);
     }
     if ($city_py) {
         $current_city = es_session::get("current_city");
         //强行定位
         if ($current_city['uname'] != $city_py && $current_city['id'] != $city_py) {
             $current_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where (uname = '" . $city_py . "' or id = '" . $city_py . "') and is_effect = 1");
         }
     }
     if (empty($current_city)) {
         //无城市,由session中获取
         $current_city = es_session::get("current_city");
     }
     if (empty($current_city)) {
         $city_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_city where is_effect = 1");
         //自动定位
         require_once APP_ROOT_PATH . "system/extend/ip.php";
         $ip = CLIENT_IP;
         $iplocation = new iplocate();
         $address = $iplocation->getaddress($ip);
         foreach ($city_list as $city) {
             if (strpos($address['area1'], $city['name'])) {
                 $current_city = $city;
                 break;
             }
         }
     }
     if (empty($current_city)) {
         $current_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_default = 1 and is_effect = 1");
     }
     es_session::set("current_city", $current_city);
     return $current_city;
 }
 public function get_payment_code($payment_notice_id)
 {
     include APP_ROOT_PATH . "system/payment/yeepay/yeepayMPay.php";
     $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
     $order_sn = $payment_notice['notice_sn'];
     $money = round($payment_notice['money'], 2);
     $payment_info = $GLOBALS['db']->getRow("select id,config,logo from " . DB_PREFIX . "payment where id=" . intval($payment_notice['payment_id']));
     $payment_info['config'] = unserialize($payment_info['config']);
     $sql = "select name " . "from " . DB_PREFIX . "deal " . "where id =" . intval($payment_notice['deal_id']);
     $title_name = $GLOBALS['db']->getOne($sql);
     $subject = $order_sn;
     $yeepay = new yeepayMPay($payment_info['config']['merchantaccount'], $payment_info['config']['merchantPublicKey'], $payment_info['config']['merchantPrivateKey'], $payment_info['config']['yeepayPublicKey']);
     //$notify_url = get_domain().APP_ROOT."/yeepay_web/alipayapi.php?order_id=".intval($payment_notice['order_id'])."&out_trade_no=".$order_sn;//."&out_trade_no={$data.walipay.out_trade_no}";
     $data_return_url = get_domain() . APP_ROOT . '/yeepay_web/yjwap_response.php';
     $data_notify_url = get_domain() . APP_ROOT . '/yeepay_web/yjwap_notify.php';
     $data_notify_url = str_replace("/sjmapi", "", $data_notify_url);
     $data_notify_url = str_replace("/mapi", "", $data_notify_url);
     $data_notify_url = str_replace("/wap", "", $data_notify_url);
     $data_return_url = str_replace("/sjmapi", "", $data_return_url);
     $data_return_url = str_replace("/mapi", "", $data_return_url);
     $data_return_url = str_replace("/wap", "", $data_return_url);
     $order_id = $order_sn;
     //网页支付的订单在订单有效期内可以进行多次支付请求,但是需要注意的是每次请求的业务参数都要一致,交易时间也要保持一致。否则会报错“订单与已存在的订单信息不符”
     $transtime = NOW_TIME;
     // time();//交易时间,是每次支付请求的时间,注意此参数在进行多次支付的时候要保持一致。
     $product_catalog = $payment_info['config']['productcatalog'];
     //商品类编码是我们业管根据商户业务本身的特性进行配置的业务参数。
     $identity_id = $payment_notice['user_id'];
     //用户身份标识,是生成绑卡关系的因素之一,在正式环境此值不能固定为一个,要一个用户有唯一对应一个用户标识,以防出现盗刷的风险且一个支付身份标识只能绑定5张银行卡
     $identity_type = 2;
     //支付身份标识类型码
     require_once APP_ROOT_PATH . 'system/extend/ip.php';
     $iplocation = new iplocate();
     $user_ip = $iplocation->getIP();
     //此参数不是固定的商户服务器IP,而是用户每次支付时使用的网络终端IP,否则的话会有不友好提示:“检测到您的IP地址发生变化,请注意支付安全”。
     $user_ua = $_SERVER['HTTP_USER_AGENT'];
     //'NokiaN70/3.0544.5.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1';//用户ua
     $callbackurl = $data_notify_url;
     //商户后台系统回调地址,前后台的回调结果一样
     $fcallbackurl = $data_return_url;
     //商户前台系统回调地址,前后台的回调结果一样
     $product_name = '订单号-' . $title_name;
     //出于风控考虑,请按下面的格式传递值:应用-商品名称,如“诛仙-3 阶成品天琊”
     $product_desc = '';
     //商品描述
     $terminaltype = 3;
     $terminalid = '';
     //其他支付身份信息
     $amount = $money * 100;
     //订单金额单位为分,支付时最低金额为2分,因为测试和生产环境的商户都有手续费(如2%),易宝支付收取手续费如果不满1分钱将按照1分钱收取。
     $url = $yeepay->webPay($order_id, $transtime, $amount, $product_catalog, $identity_id, $identity_type, $user_ip, $user_ua, $callbackurl, $fcallbackurl, $currency = 156, $product_name, $product_desc, $terminaltype, $terminalid, $orderexp_date = 60);
     $pay = array();
     $pay['subject'] = $subject;
     $pay['body'] = $title_name;
     $pay['total_fee'] = $money;
     $pay['total_fee_format'] = format_price($money);
     $pay['out_trade_no'] = $payment_notice['notice_sn'];
     $pay['notify_url'] = $url;
     $pay['is_wap'] = 1;
     $pay['pay_code'] = 'wyeepay';
     //,支付宝;mtenpay,财付通;mcod,货到付款
     return $pay;
 }
 public function get_payment_code($payment_notice_id)
 {
     $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
     $order_sn = $payment_notice['notice_sn'];
     $money = round($payment_notice['money'], 2);
     $payment_info = $GLOBALS['db']->getRow("select id,config,logo from " . DB_PREFIX . "payment where id=" . intval($payment_notice['payment_id']));
     $payment_info['config'] = unserialize($payment_info['config']);
     $wx_config = $payment_info['config'];
     $sql = "select name " . "from " . DB_PREFIX . "deal " . "where id =" . intval($payment_notice['deal_id']);
     $title_name = $GLOBALS['db']->getOne($sql);
     if (!$payment_notice['order_id']) {
         $title_name = '充值';
     }
     $subject = $order_sn;
     include APP_ROOT_PATH . "system/payment/Wxjspay/WxPayPubHelper.php";
     // 		$data_notify_url = get_domain().APP_ROOT.'/wx_web/yjwap_response.php';
     //		$data_return_url = get_domain().APP_ROOT.'/wx_web/yjwap_notify.php';
     //
     //		$data_notify_url = str_replace("/sjmapi", "", $data_notify_url);
     //		$data_notify_url = str_replace("/mapi", "", $data_notify_url);
     //		$data_notify_url = str_replace("/wap", "", $data_notify_url);
     $data_return_url = str_replace("/sjmapi", "", $data_return_url);
     $data_return_url = str_replace("/mapi", "", $data_return_url);
     $data_return_url = str_replace("/wap", "", $data_return_url);
     $notify_url = get_domain() . REAL_APP_ROOT . "/wxpay_web/notify_url.php?order_id=" . intval($payment_notice['order_id']) . "&out_trade_no=" . $order_sn;
     //."&out_trade_no={$data.walipay.out_trade_no}";
     $order_id = $order_sn;
     //网页支付的订单在订单有效期内可以进行多次支付请求,但是需要注意的是每次请求的业务参数都要一致,交易时间也要保持一致。否则会报错“订单与已存在的订单信息不符”
     $return['notify_url'] = url_wap("cart#wx_jspay", array("id" => $payment_notice_id));
     $money_fen = intval($money * 100);
     if ($wx_config['type'] == 'V2') {
         require_once APP_ROOT_PATH . 'system/extend/ip.php';
         $iplocation = new iplocate();
         $user_ip = $iplocation->getIP();
         $unifiedOrder = new UnifiedOrder_pub();
         $unifiedOrder->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         $unifiedOrder->setParameter("input_charset", "GBK");
         $unifiedOrder->setParameter("bank_type", "WX");
         $unifiedOrder->setParameter("body", $title_name);
         $unifiedOrder->setParameter("partner", $wx_config['partnerid']);
         //$unifiedOrder->setParameter("out_trade_no", $unifiedOrder->create_noncestr());
         $unifiedOrder->setParameter("out_trade_no", $order_sn);
         $unifiedOrder->setParameter("total_fee", "{$money_fen}");
         $unifiedOrder->setParameter("fee_type", "0");
         $unifiedOrder->setParameter("notify_url", $notify_url);
         $unifiedOrder->setParameter("spbill_create_ip", $user_ip);
         $unifiedOrder->setParameter("input_charset", "GBK");
         $jsApiParameters = $unifiedOrder->create_biz_package();
     } elseif ($wx_config['type'] == 'V3' || $wx_config['type'] == 'V4') {
         $jsApi = new JsApi_pub();
         $jsApi->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         if (!isset($_GET['code'])) {
             //触发微信返回code码
             $url = $jsApi->createOauthUrlForCode(urlencode(get_domain() . $return['notify_url']));
             Header("Location: {$url}");
             $return['notify_url'] = $url;
             return $return;
         } else {
             //获取code码,以获取openid
             $code = $_GET['code'];
             $jsApi->setCode($code);
             $openid = $jsApi->getOpenId();
         }
         $unifiedOrder = new UnifiedOrder_pub();
         $unifiedOrder->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         $unifiedOrder->setParameter("openid", "{$openid}");
         //商品描述
         $unifiedOrder->setParameter("body", iconv_substr($title_name, 0, 50, 'UTF-8'));
         //商品描述
         $timeStamp = NOW_TIME;
         $unifiedOrder->setParameter("out_trade_no", "{$order_sn}");
         //商户订单号
         $unifiedOrder->setParameter("total_fee", $money_fen);
         //总金额
         $unifiedOrder->setParameter("notify_url", $notify_url);
         //通知地址
         $unifiedOrder->setParameter("trade_type", "JSAPI");
         //交易类型
         $prepay_id = $unifiedOrder->getPrepayId();
         //=========步骤3:使用jsapi调起支付============
         $jsApi->setPrepayId($prepay_id);
         $jsApiParameters = $jsApi->getParameters($wx_config['type']);
         if ($wx_config['type'] == 'V4') {
             $jsApiParameters = str_replace('deal_url', url_wap("deal#index", array('id' => $payment_notice['deal_id'])), $jsApiParameters);
         }
     }
     $return['parameters'] = $jsApiParameters;
     //echo $jsApiParameters;
     return $return;
 }
Example #6
0
/**
 * 定位城市
 * @param int $deal_city_id 城市id
 * @return unknown
 */
function get_cur_deal_city($deal_city_id = 0)
{
    if ($deal_city_id > 0) {
        $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_effect = 1 and is_delete = 0 and id = " . intval($deal_city_id));
    }
    if (!$deal_city) {
        //设置如存在的IP订位
        if (file_exists(APP_ROOT_PATH . "system/extend/ip.php")) {
            require_once APP_ROOT_PATH . "system/extend/ip.php";
            $ip = get_client_ip();
            $iplocation = new iplocate();
            $address = $iplocation->getaddress($ip);
            $sql = "select * from " . DB_PREFIX . "deal_city where is_delete = 0 and is_effect = 1 ";
            $city_list = $GLOBALS['db']->getAll($sql);
            //不知谁把$city_list 查询去掉了; 去掉后就不能通过ip定位了; chenfq 现在又添加上去了 2014-09-18
            foreach ($city_list as $city) {
                if (strpos($address['area1'], $city['name'])) {
                    $deal_city = $city;
                    break;
                }
            }
        }
        if (!$deal_city) {
            $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_default = 1 and is_effect = 1 and is_delete = 0");
        }
    }
    return $deal_city;
}
Example #7
0
/**
 * 获取当前团购城市
 */
function get_current_deal_city()
{
    if (es_cookie::is_set("deal_city")) {
        $deal_city_id = es_cookie::get("deal_city");
        $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_effect = 1 and is_delete = 0 and id = " . intval($deal_city_id));
    }
    if (!$deal_city) {
        //设置如存在的IP订位
        if (file_exists(APP_ROOT_PATH . "system/extend/ip.php")) {
            require_once APP_ROOT_PATH . "system/extend/ip.php";
            $ip = get_client_ip();
            $iplocation = new iplocate();
            $address = $iplocation->getaddress($ip);
            foreach ($city_list as $city) {
                if (strpos($address['area1'], $city['name'])) {
                    $deal_city = $city;
                    break;
                }
            }
        }
        if (!$deal_city) {
            $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where is_default = 1 and is_effect = 1 and is_delete = 0");
        }
    }
    return $deal_city;
}
Example #8
0
 public function get_payment_code($payment_notice_id)
 {
     $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
     $order_info = $GLOBALS['db']->getRow("select deal_ids from " . DB_PREFIX . "deal_order where id = " . $payment_notice['order_id']);
     $order_sn = $payment_notice['notice_sn'];
     $money = round($payment_notice['money'], 2);
     $payment_info = $GLOBALS['db']->getRow("select id,config,logo from " . DB_PREFIX . "payment where id=" . intval($payment_notice['payment_id']));
     $payment_info['config'] = unserialize($payment_info['config']);
     $wx_config = $payment_info['config'];
     $sql = "select name from " . DB_PREFIX . "deal where id =" . intval($order_info['deal_ids']);
     $title_name = $GLOBALS['db']->getOne($sql);
     $subject = $order_sn;
     include APP_ROOT_PATH . "system/payment/Wxjspay/WxPayPubHelper.php";
     $notify_url = get_domain() . APP_ROOT . "/wxpay_web/notify_url.php?order_id=" . intval($payment_notice['order_id']) . "&out_trade_no=" . $order_sn;
     //."&out_trade_no={$data.walipay.out_trade_no}";
     $notify_url = str_replace("/sjmapi", "", $notify_url);
     $notify_url = str_replace("/mapi", "", $notify_url);
     $order_id = $order_sn;
     //网页支付的订单在订单有效期内可以进行多次支付请求,但是需要注意的是每次请求的业务参数都要一致,交易时间也要保持一致。否则会报错“订单与已存在的订单信息不符”
     $data_return_url = get_domain() . APP_ROOT . "/wap/index.php?ctl=pay_order&order_id=" . intval($payment_notice['order_id']);
     //$return['notify_url']=$notify_url;
     $data_return_url = str_replace("/sjmapi", "", $data_return_url);
     $data_return_url = str_replace("/mapi", "", $data_return_url);
     $return['notify_url'] = $data_return_url;
     $return['is_wap'] = 1;
     $return['is_wap_url'] = 0;
     $return['show_pay_wxbtn'] = 1;
     $return['pay_code'] = 'Wwxjspay';
     $return['body'] = $title_name;
     $return['total_fee'] = $money;
     $return['total_fee_format'] = format_price($money);
     $return['out_trade_no'] = $payment_notice['notice_sn'];
     $money_fen = intval($money * 100);
     if ($wx_config['type'] == 'V2') {
         require_once APP_ROOT_PATH . 'system/extend/ip.php';
         $iplocation = new iplocate();
         $user_ip = $iplocation->getIP();
         $unifiedOrder = new UnifiedOrder_pub();
         $unifiedOrder->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         $unifiedOrder->setParameter("input_charset", "GBK");
         $unifiedOrder->setParameter("bank_type", "WX");
         $unifiedOrder->setParameter("body", $title_name);
         $unifiedOrder->setParameter("partner", $wx_config['partnerid']);
         //$unifiedOrder->setParameter("out_trade_no", $unifiedOrder->create_noncestr());
         $unifiedOrder->setParameter("out_trade_no", $order_sn);
         $unifiedOrder->setParameter("total_fee", "{$money_fen}");
         $unifiedOrder->setParameter("fee_type", "0");
         $unifiedOrder->setParameter("notify_url", $notify_url);
         $unifiedOrder->setParameter("spbill_create_ip", $user_ip);
         $unifiedOrder->setParameter("input_charset", "GBK");
         $jsApiParameters = $unifiedOrder->create_biz_package();
     } elseif ($wx_config['type'] == 'V3') {
         $jsApi = new JsApi_pub();
         $jsApi->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         if (!isset($_REQUEST['code'])) {
             //触发微信返回code码
             $url = $jsApi->createOauthUrlForCode(urlencode($return['notify_url']));
             //header("Location:".$url);
             $return['is_wap_url'] = 1;
             $return['wap_notify_url'] = $url;
             return $return;
         } else {
             //获取code码,以获取openid
             $code = $_REQUEST['code'];
             $jsApi->setCode($code);
             $openid = $jsApi->getOpenId();
         }
         $unifiedOrder = new UnifiedOrder_pub();
         $unifiedOrder->update_config($wx_config['appid'], $wx_config['appsecret'], $wx_config['mchid'], $wx_config['partnerid'], $wx_config['partnerkey'], $wx_config['key'], $wx_config['sslcert'], $wx_config['sslkey']);
         $unifiedOrder->setParameter("openid", "{$openid}");
         //商品描述
         $unifiedOrder->setParameter("body", substr($title_name, 0, 50));
         //商品描述
         $timeStamp = NOW_TIME;
         $unifiedOrder->setParameter("out_trade_no", "{$order_sn}");
         //商户订单号
         $unifiedOrder->setParameter("total_fee", $money_fen);
         //总金额
         $unifiedOrder->setParameter("notify_url", $notify_url);
         //通知地址
         $unifiedOrder->setParameter("trade_type", "JSAPI");
         //交易类型
         $prepay_id = $unifiedOrder->getPrepayId();
         //=========步骤3:使用jsapi调起支付============
         $jsApi->setPrepayId($prepay_id);
         //file_put_contents(APP_ROOT_PATH."/sjmapi/log/log_xml_1.txt",print_r($prepay_id,1));
         $jsApiParameters = $jsApi->getParameters();
         //$deal_url=get_domain().APP_ROOT."/wap/index.php";
         //$deal_url = str_replace("/sjmapi", "", $deal_url);
         //$deal_url = str_replace("/mapi", "", $deal_url);
         //$jsApiParameters=str_replace('deal_url',$deal_url,$jsApiParameters);
     }
     $return['parameters'] = $jsApiParameters;
     //echo $jsApiParameters;
     return $return;
 }
Example #9
0
/**
 * 获取当前团购城市
 */
function getCurrentDealCity()
{
    $model = M("City");
    if ($city = $_GET['city']) {
        $deal_city = $model->where("city_py='{$city}'")->find();
    } else {
        if ($city_id = cookie('deal_city')) {
            $deal_city = $model->where("id={$city_id}")->find();
        } else {
            //导入Ip类
            Vendor('IP.ip');
            $ip = get_client_ip();
            $iplocation = new iplocate();
            $address = $iplocation->getaddress($ip);
            $city_list = $model->select();
            foreach ($city_list as $city) {
                if (strpos($address['area1'], $city['city'])) {
                    $deal_city = $city;
                    break;
                }
            }
            if (!$deal_city) {
                $default = C("DEFAULT_CITY");
                $deal_city = $model->where("id={$default}")->find();
            }
        }
    }
    cookie("deal_city", $deal_city['id']);
    return $deal_city;
}