Exemplo n.º 1
0
 /**
  * 发送手机验证码
  * @method POST_phoneAction
  * @author NewFuture
  */
 public function POST_phoneAction()
 {
     $response['status'] = 0;
     if (!Input::post('phone', $phone, Config::get('regex.phone'))) {
         $response['info'] = '手机号格式有误或者不支持!';
     } elseif (!Input::post('account', $account, Config::get('regex.account'))) {
         $response['info'] = '账号有误,如果账号忘记请联系云印工作人员';
     } elseif (!($Printer = PrinterModel::where('account', $account)->field('id,phone')->find())) {
         $response['info'] = '尚未注册';
     } elseif (!Safe::checkTry('pwd_phone_' . $account)) {
         $response['info'] = '尝试次数过多,临时封禁!';
     } elseif (!$Printer['phone'] || $Printer['phone'] != $phone) {
         $response['info'] = '绑定手机不一致,或者手机号错误';
     } elseif (!Sms::findPwd($phone, $code = Random::number(6))) {
         $response['info'] = '短信发送出错,请联系我们!';
     } else {
         /*发送成功*/
         $find = ['id' => $Printer['id'], 'account' => $account, 'code' => strtoupper($code)];
         Session::set('find_info_p', $find);
         Safe::del('pwd_phone_' . $account);
         $response['status'] = 1;
         $response['info'] = '验证短信已发送';
     }
     $this->response = $response;
 }
Exemplo n.º 2
0
 /**
  * Simulates a trading period
  *
  * @param int $steps
  * @param int $drift
  * @param float $volatility
  * @param bool $start
  * @return $this
  */
 public function simulate($steps = 8, $drift = 0, $volatility = 0.1, $start = false)
 {
     $price = $this->price;
     if ($start) {
         $price = $start;
     }
     $this->addRun($price);
     //TODO CONSIDER GAPS
     for ($i = 0; $i < $steps; $i++) {
         $growth = exp($drift + $volatility * Random::number());
         $price = round($price * pow($growth, 1 / $steps), 2);
         $this->addRun($price);
     }
     $this->price = $price;
     return $this;
 }
Exemplo n.º 3
0
 /**
  * 绑定用户手机,发送验证码
  * PUT /user/1/phone {phone:"13888888888"}
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function POST_phoneAction($id = 0)
 {
     $id = $this->auth($id);
     $response['status'] = 0;
     if (!Input::post('phone', $phone, 'phone')) {
         $response['info'] = '手机号码无效';
     } elseif (UserModel::getByPhone($phone)) {
         $response['info'] = '已经绑定过用户';
     } elseif (!Safe::checkTry('bind_phone_' . $id)) {
         $response['info'] = '发送次数过多,稍后重试';
     } else {
         /*手机有效,发送验证码*/
         $code = Random::number(6);
         Session::set('code_phone', [$code => $phone]);
         if (Sms::bind($phone, $code)) {
             $response['status'] = 1;
             $response['info'] = '发送成功[最多可重发5次]';
         } else {
             $response['info'] = '短信发送出错[最多可重发5次]';
         }
     }
     $this->response = $response;
 }
Exemplo n.º 4
0
 /**
  * 数字编码并按指定长度补位
  * @param $num
  * @param int $len
  * @return string
  */
 public static function numberDec($num, $len = 0)
 {
     $numStr = strval($num);
     $slen = strlen($numStr);
     $tagNo = '5';
     //没有补位
     $tagYes = '4';
     // 已经补位 ,补位后第二个字符为补位长度
     if ($len == 0) {
         return $tagNo . self::to62($num);
     }
     if ($len <= $slen) {
         return $tagNo . self::to62($numStr);
     }
     // 补位,补位长度不能操过62
     $bl = $len - $slen;
     $numStr = Random::number($bl) . $numStr;
     return $tagYes . self::to62($bl) . self::to62($numStr);
 }