// put cellphone number into session, in case user use an different number to register. $sessionController->addCellphone($phone); } $last_time = $sessionController->getVerifyTime(); if (!empty($last_time)) { $this_time = time(); $interval = $this_time - $last_time; if ($interval < 120) { echo "时间间隔太短!"; return; } } $user = $userDao->getByPhone($phone); if ($user) { echo "手机号已被注册"; return; } // Generate a 6-digits random number $random = rand(100000, 999999); // Send to user's cellphone $sms = new SmsSender(); if ($sms->sendVerifyCode($phone, $random)) { echo "{\"msg\":\"success\"}"; // put it in the session $sessionController->addCode($random); $sessionController->addVerifyTime(time()); } else { echo "\n短信服务失败!"; } // temporary return to page // echo $random;
if ($today_time == WechatLotteryService::OVER_LIMIT) { // Draw action over daily limit header("Location:result.php?price=-1&casa=" . $r . "&gua=" . $gua); } else { if ($reward_row) { // Already won, 中过奖了 header("Location:result.php?price=0&casa=" . $r . "&gua=" . $gua); } else { $win = $wls->draw(); // 中奖了 if ($win) { // 中了几等奖 $price_level = $wls->draw_price(); // save in session $sc = new SessionController(); $sc->addCode($openid); // save in database $wls->save_winner($openid, $price_level); // redirect header("Location:result.php?price=" . $price_level . "&casa=" . $r . "&gua=" . $gua); } else { header("Location:result.php?price=0&casa=" . $r . "&gua=" . $gua); } } } } else { echo "微信信息获取失败!"; } /*//根据openid和access_token查询用户信息 $get_user_info_url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$access_token .'&openid='.$openid.'&lang=zh_CN';