Exemple #1
0
/**
 * 对用户的密码进行加密
 * @param string $password
 * @param string $encrypt //传入加密串,在修改密码时做认证
 * @return array/password
 */
function password($password, $encrypt = '')
{
    $pwd = array();
    $pwd['encrypt'] = $encrypt ? $encrypt : Org\Util\String::randString(6);
    $pwd['password'] = md5(md5(trim($password)) . $pwd['encrypt']);
    return $encrypt ? $pwd['password'] : $pwd;
}
Exemple #2
0
/**
 * 创建随机字符串。
 * @return string 随机字符串
 */
function create_rand_str()
{
    if (APP_DEBUG) {
        trace("创建随机字符串...");
    }
    return Org\Util\String::randString();
}
 /**
  *代购订单
  */
 public function buyAccept()
 {
     $info = I('post.');
     $phone = $info['phone'];
     $save = $info;
     if ($phone != session('phone')) {
         $return = ['status' => '-10', 'info' => '账户不存在'];
         $this->ajaxReturn($return);
     } else {
         $save['userId'] = session('userId');
     }
     if ($info['sendAddr'] == null || $info['goodsDesc'] == null || $info['priceLimit'] == null || $info['runnerFee'] == null) {
         $return = ['status' => '-100', 'info' => '请完整填写上述内容'];
         $this->ajaxReturn($return);
     }
     $save['recipientTel'] = $phone;
     if (!is_null(session("userName"))) {
         $save['recipientName'] = session("userName");
     } else {
         $save['recipientName'] = session("userNick");
     }
     $save['sendAddr'] = $info['sendAddr'] . $info['sendDet'];
     $location = $this->locationToLal($info['sendAddr']);
     $save['longitude'] = $location['lng'];
     $save['latitude'] = $location['lat'];
     M('purchase')->add($save);
     $sendId = M('purchase')->getLastInsID();
     $string = new \Org\Util\String();
     $randNum = $string->randString(8, 1);
     $orderNo = "B" . time() . $randNum;
     $order = ['orderNo' => $orderNo, 'type' => 1, 'orderTime' => date('Y-m-d H-i-s', time()), 'userId' => session('userId'), 'payStatus' => 0, 'status' => 0, 'binCode' => '111', 'sendId' => $sendId, 'money' => $info['runnerFee'], 'revenue' => $this->revenue($info['runnerFee'])];
     M('orders')->add($order);
     $return = ['status' => '0', 'info' => 'success', 'orderNo' => $orderNo, 'money' => $info['runnerFee']];
     $this->ajaxReturn($return);
 }
 public function submitOrder()
 {
     if (!$this->isLogin()) {
         $this->redirect('Home/register');
     }
     $this->commonProcess();
     $orderLogic = D('Order', 'Logic');
     $userId = $this->getCurrentUserId();
     $backlogOrder = $orderLogic->getOrderByUserId($userId, 'N');
     if (count($backlogOrder) > 0) {
         $order = $backlogOrder[0];
         //如果没有地址,用默认地址
         if ($order['shippingAddress'] == 0) {
             $defaultAddress = D("ShippingAddress", "Logic")->getDefaultAddress($userId);
             $data['shippingAddress'] = $defaultAddress['addressId'];
         }
         //检查库存
         $inadequateInventoryItems = $this->checkOrderItemsInventory($order['orderId']);
         if (count($inadequateInventoryItems) > 0) {
             $this->redirect('Cart/index', array('itemId' => $inadequateInventoryItems['itemId'], 'itemSize' => $inadequateInventoryItems['itemSize']));
         }
         if ($order['orderNumber'] == '') {
             //生成订单号,规则: 数字8(1位) + 年份最后1位,如2016最后一位6(1位) + 月份,如04(2位) + 日期,如12(2位) + 当前秒数,如59(2位) + 用户ID后2位,如87(2位) + 随机数(2位)
             $strUtil = new \Org\Util\String();
             $orderNumber = '8' . substr(date("Ymds"), 3) . substr($userId, -2) . $strUtil->randString(2, 1);
             $data['orderNumber'] = $orderNumber;
         } else {
             $orderNumber = $order['orderNumber'];
         }
         $data['orderDate'] = date("Y-m-d H:i:s", time());
         $orderLogic->updateOrder($data, $order['orderId']);
         $this->redirect('Payment/index', array('orderNumber' => $orderNumber));
     }
 }
Exemple #5
0
function get_phone_code($phone, $where)
{
    $ip = $_SERVER['REMOTE_ADDR'];
    //$where = I ( 'where' ); //在哪里要求发送手机验证码,(找回密码|注册)
    $result = preg_match("/" . get_phone_preg() . "/", $phone, $m);
    if (!$result) {
        return array('status' => 0, 'msg' => '请填写正确手机号');
    }
    if ('forget' == $where) {
        $res = get_info('member', array('phone' => $phone));
        if (!$res) {
            return array('status' => 0, 'msg' => '此手机号没有注册');
        }
    } else {
        if ('register' == $where) {
            if ('18687456146' == $phone) {
            } else {
                $res = get_info('member', array('phone' => $phone));
                if ($res) {
                    return array('status' => 0, 'msg' => '此手机号已经注册过了');
                }
            }
        } else {
            if ('modify_phone' == $where) {
                if (GetLoginMember()->phone == $phone) {
                    return array('status' => 1, 'msg' => '您要修改的手机号和您现在的手机号相同');
                }
            }
        }
    }
    $model = M('log_sms');
    $count = $model->where("phone='%s' AND day='%s'", $phone, strtotime(date('Y-m-d')))->count();
    if (3 <= $count) {
        if ('18687456146' == $phone) {
        } else {
            return array('status' => 0, 'msg' => '这个手机号今天已经发送三次了,请明天再来');
        }
    }
    $sms = $model->where("phone='%s'", $phone)->order('time DESC')->find();
    $second = time() - $sms['time'];
    if ($second < 120) {
        if ('18687456146' == $phone) {
        } else {
            return array('status' => 0, 'msg' => '还 要等待 ' . (120 - $second) . '秒才能重发信息', 'second' => 120 - $second);
        }
    }
    //删除随机验证码
    $str_obj = new \Org\Util\String();
    $code = $str_obj->randNumber(111111, 999999);
    $content = "验证码【" . $code . "】";
    $_SESSION[$phone] = $code;
    $_SESSION[$phone . 'time'] = time();
    if (IsDebug()) {
        if ('18687456146' == $phone) {
            return array('status' => 1, 'msg' => '信息已发送(测试中,实际没有发: ' . $code . ')');
        } else {
        }
    }
    include_once "../AhLib/AhSmsSend.class.php";
    $send = new AhSmsSend();
    $smsArr[$phone] = array('%action%' => $types[$type], '%Code%' => $code);
    $response = $send->sendBy388($smsArr);
    return array('status' => 1, 'msg' => '信息已发送');
}
 /**
  * 创建token
  *
  * @param array $user
  *        	会员数据
  * @return boolean 创建结果
  */
 private function create_token($user)
 {
     $token_m = M(self::$token_table);
     $str_obj = new \Org\Util\String();
     $token = $str_obj->keyGen();
     // 生成唯一GUID
     while ($token_m->where(array('token' => $token))->count()) {
         $token = $str_obj->keyGen();
         // 如果GUID已存在,重新生成
     }
     $create_time = time();
     // 创建时间
     $expires = strtotime("2 hours", $create_time);
     // 2小时有效期
     $result = $token_m->add(array('token' => $token, 'mid' => $user['id'], 'create_time' => $create_time, 'role' => intval($user["wap_role"]), 'expires' => $expires, 'req_ip' => get_client_ip()));
     if ($result) {
         $mapp = M("member_app");
         $app_data = $mapp->getByUid($user['id']);
         if (!$app_data) {
             $mapp->add(array("uid" => $user['id'], "login_num" => 0));
             $login_num = 0;
         } else {
             $login_num = intval($mapp->getFieldByUid($user['id'], "login_num"));
         }
         if (!$login_num) {
             $score = M("app_setting")->getFieldByItem("first_login_coin", "value");
             M("score_log")->add(array("type" => "score", "uid" => $user['id'], "uname" => $user['nickname'], "score" => $score, "table_name" => "member", "table_id" => $user['id'], "action" => "/v1/tokens", "msg" => "首次登陆APP客户端", "create_time" => time(), "status" => 1));
             M("member")->where(array("id" => $user['id']))->setInc("coin", $score);
         }
         $mapp->where(array("uid" => $user['id']))->setInc("login_num");
         return $token;
     }
     return false;
 }