public function execute($request) { if ($request->format == 'json') { $user = Sp_Account_User::current(); $userid = $user->id; $row = Sp_Account_User::getUser($userid); $old = $request->old; $password = $request->password; $confirming = $request->confirming; $patternPasswd = Sp_Dictionary::getOtherOption('patternPasswd'); if (false == preg_match($patternPasswd, $old)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } if (false == preg_match($patternPasswd, $confirming)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } if (false == preg_match($patternPasswd, $password)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } // 旧密码 if (!$this->checkOldPassword($old, $row)) { return array('status' => '-1', 'msg' => '旧密码不正确'); } if ($password != $confirming) { return array('status' => '-2', 'msg' => '两次密码不一致'); } $newpwd = Sp_Account_User::encrypt($password, $row['kid']); Sp_Account_Info::updatePassword($userid, $newpwd); return array('status' => '0', 'msg' => '密码修改成功'); } }
public function execute($request) { if ($request->format == 'json') { $data = array(); $email = $request->email; $mobile = $request->mobile; $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); if (false == preg_match($patternEmail, $email)) { return array('status' => '-120', 'msg' => '邮件格式不正确'); } else { if (false == preg_match($patternMobile, $mobile)) { return array('status' => '-121', 'msg' => '电话格式不正确'); } } $user = Sp_Account_User::current(); $data['name'] = $request->name; $data['gender'] = $request->gender; $data['mobile'] = $mobile; $data['email'] = $email; $data['province'] = $request->province; $data['city'] = $request->city; $data['area'] = $request->area; $data['face'] = $request->face; $ret = Sp_Account_Info::updateUser($user->id, $data); return array('status' => '0', 'msg' => '成功'); } }
/** * 发送短信 * * @param string $phone 手机号 */ function sendSms($phone) { $content = '您的验证码为: [code], 任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效'; $code = mt_rand(100000, 999999); Sp_Sendmsg::send(array('type' => Sp_Dictionary::getSmsType(0), 'username' => $phone, 'code' => $code, 'content' => str_replace('[code]', $code, $content))); return true; }
public function check($account = '', $type = '') { $rules['phone'] = Sp_Dictionary::getOtherOption("patternMobile"); $rules['email'] = Sp_Dictionary::getOtherOption("patternEmail"); $msg['phone'] = "电话格式不正确"; $msg['email'] = "邮箱格式不正确"; $return = 1; $filter = array('phone', 'email'); if (false == in_array($type, $filter)) { $return = array("status" => -100, "msg" => "参数错误"); } else { if (FALSE == preg_match($rules[$type], $account)) { $return = array("status" => -101, "msg" => $msg[$type]); } else { $currentTime = time(); $time = $currentTime - 60; $hours = $currentTime - 60 * 60; $where = array($type => $account); $flag = Da_Wrapper::select()->table('sp.huitong.ht_sms_report')->columns('id')->where($where)->where("crttime >= {$time}")->getOne(); if (false != $flag) { $return = array("status" => -102, "msg" => "请一分钟后在试"); } $sendCount = Da_Wrapper::select()->table('sp.huitong.ht_sms_report')->columns('id')->where($where)->where("crttime >= {$hours}")->getTotal(); if (5 <= $sendCount) { $return = array("status" => -103, "msg" => "你已多次获取,为保证账号的安全,防止恶意验证,请1小时后再试"); } } } return $return; }
function getExcelData($uploadfile = '') { global $log; $log->log('处理file开始'); if (is_readable($uploadfile) == false) { $log->log('文件不可读'); return FALSE; } $data = array(); Loader::import(PHPEXCEL_ROOT); try { $objReader = PHPExcel_IOFactory::createReader('Excel5'); $objReader->setReadDataOnly(TRUE); $objPHPExcel = $objReader->load($uploadfile); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $fieldAndTitle = getFieldAndTitle(); $log->log('处理file结束'); $fields = array(); for ($j = 1; $j <= $highestRow; $j++) { for ($k = 'A'; $k <= $highestColumn; $k++) { $value = $objPHPExcel->getActiveSheet()->getCell("{$k}{$j}")->getValue(); if ($j == 1) { $field = array_search($value, $fieldAndTitle); if (false !== $field) { $fields[$k] = $field; } else { // ("模板有误,请从新生存模板"); } } else { $key = $fields[$k]; $data[$j][$key] = $value == NUll ? '' : $value; if ($key == 'name') { $data[$j]['firstChater'] = Sp_Dictionary::getFirstCharter($value); } } } } $log->log('返回数据成功'); } catch (Exception $e) { $log->log('处理错误: ' . $e->__toString()); } return $data; }
public function addAttendee() { $data = $_POST; unset($data['action']); $flag = true; if (false == $data['name']) { $flag = false; } else { if (false == preg_match(Sp_Dictionary::getOtherOption('patternMobile'), $data['phone'])) { $flag = false; } else { if ($data['email']) { if (false == preg_match(Sp_Dictionary::getOtherOption('patternEmail'), $data['email'])) { $flag = false; } } } } if (false == $flag) { return array('status' => 0, 'msg' => '数据有误请从新填写'); } else { $data['firstChater'] = Sp_Dictionary::getFirstCharter($data['name']); $data['fromId'] = -1; $data['applyTime'] = time(); $return = Sp_Account_Attendee::add($data); if ($return == -2) { return array('status' => -2, 'msg' => '此人已经存在'); } else { if (-3 == $return) { return array('status' => -3, 'msg' => '此人已经签到'); } else { if (-4 == $return) { return array('status' => -4, 'msg' => '添加失败'); } else { if ($return) { return array('status' => 1, 'msg' => '添加成功'); } } } } return array('status' => 0, 'msg' => '数据有误请从新填写'); } }
public function check($username = '', $passwd = '') { $username = trim($username); $passwd = trim($passwd); $confirm_passwd = trim($confirm_passwd); $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); $patternPasswd = Sp_Dictionary::getOtherOption('patternPasswd'); $patternUserId = Sp_Dictionary::getOtherOption('patternUserId'); if ((preg_match($patternEmail, $username) || preg_match($patternMobile, $username) || preg_match($patternUserId, $username)) && strlen($passwd) >= 6) { return TRUE; } else { if (false == preg_match($patternEmail, $username)) { return array('status' => '-120', 'msg' => '账户名格式不匹配'); } else { if (strlen($passwd) < 6) { return array('status' => '-105', 'msg' => '密码长度在6-16位字符之间'); } } } }
public function check($email = '', $mobile = '', $passwd = '', $confirm_passwd = '', $code = '') { $email = trim($email); $mobile = trim($mobile); $passwd = trim($passwd); $confirm_passwd = trim($confirm_passwd); $code = trim($code); $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); $patternPasswd = Sp_Dictionary::getOtherOption('patternPasswd'); if (false == preg_match($patternEmail, $email)) { return array('status' => '-120', 'msg' => '邮件格式不正确'); } else { if (false == preg_match($patternMobile, $mobile)) { return array('status' => '-121', 'msg' => '电话格式不正确'); } else { if (false == preg_match($patternPasswd, $passwd)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } else { if ($passwd !== $confirm_passwd) { return array('status' => '-123', 'msg' => '密码和确认密码不一致'); } else { if (false == Util_Captcha::verify_captcha($code)) { return array('status' => '-124', 'msg' => '验证码错误'); } else { if (false == Sp_Account_Regist::isAvailableEmail($email)) { return array('status' => '-125', 'msg' => '该邮件已经注册'); } else { if (false == Sp_Account_Regist::isAvailableMobile($mobile)) { return array('status' => '-126', 'msg' => '该手机号已经注册'); } } } } } } } return true; }
public function checkCodeAndUser($username = '', $code = '', $type = '') { $username = trim($username); $code = trim($code); $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); if (strlen($code) != 6) { return array('status' => '-126', 'msg' => '验证码长度有误'); } if (preg_match($patternEmail, $username) || preg_match($patternMobile, $username)) { if (preg_match($patternMobile, $username)) { if (TRUE == Sp_Account_Regist::isAvailableMobile($username)) { return array('status' => '-125', 'msg' => '该手机号不存在'); } $row = Sp_Sendmsg::getSmsByPhone($username, $type); $nowTime = time() - $row['crttime']; if (!is_array($row) || $nowTime > 15 * 60 || $row['code'] != $code) { return array('status' => '-126', 'msg' => '验证码错误'); } } if (preg_match($patternEmail, $username)) { if (TRUE == Sp_Account_Regist::isAvailableEmail($username)) { return array('status' => '-126', 'msg' => '该邮箱不存在'); } $row = Sp_Sendmsg::getSmsByEmail($username, $type); $nowTime = time() - $row['crttime']; if (!is_array($row) || $nowTime > 15 * 60 || $row['code'] != $code) { return array('status' => '-126', 'msg' => '验证码错误'); } } return TRUE; } else { return array('status' => '-121', 'msg' => '格式不正确'); } }
/** * 根据登录名和密码,验证用户 * * @param string $username * @param string $password * @param array $option = null * @return mixed 成功返回对象,失败返回 负数或FALSE */ public static function authenticate($username, $password, $option = null) { $src_id = isset($option['src_id']) ? $option['src_id'] : 0; $username = trim($username); if (!$username) { return parent::ERR_USERNAME_NOT_FOUND; } $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); if (preg_match($patternMobile, $username)) { $field_name = 'mobile'; } elseif (preg_match($patternEmail, $username)) { $field_name = 'email'; } else { $field_name = 'userid'; } $user = self::load($username, $field_name, $src_id); if ($user->valid()) { $crypted_password = self::encrypt($password, $user->kid); if ($crypted_password == trim($user->pwd)) { if ($user->status == 1) { return parent::ERR_ACCOUNT_DISABLED; } return $user; } else { Sp_Log::notice('password incorrect: ' . $crypted_password . ' - ' . $user['pwd']); return parent::ERR_PASSWORD_INCORRECT; } } return parent::ERR_USERNAME_NOT_FOUND; }
public function insert($data) { $data['applyTime'] = time(); $data['firstChater'] = Sp_Dictionary::getFirstCharter($data['name']); try { $id = Sp_Account_Attendee::add($data); } catch (PDOException $e) { $id = false; } return $id < 1 ? false : $id; }
<?php /* * editor by carten */ define('ROOT_PATH', __DIR__ . '/../../../'); include_once ROOT_PATH . 'config/init.php'; $request = Request::current(); $signNo = $request->signNo; $activeId = $request->active_Id; file_put_contents("/sproot/logs/1111_sign_line.txt", "signNo:" . $signNo . ",activeId:" . $activeId); $patternMobile = Sp_Dictionary::getOtherOption("patternMobile"); if (preg_match($patternMobile, $signNo)) { $where = array("phone" => $signNo, "activeId" => $activeId); } else { $where = array("signId" => $signNo); } $signId = Da_Wrapper::select()->table("sp.huitong.ht_apply_data")->columns('Id,status')->where($where)->getRow(); if (!$signId['Id']) { $jsonParam = array("code" => "204", "msg" => "签到码不存在"); } else { if (1 == $signId['status']) { $jsonParam = array("code" => "205", "msg" => "签到码已使用"); } else { if (-1 == $signId['status']) { $jsonParam = array("code" => "206", "msg" => "签到码无效"); } else { if (0 == $signId['status']) { $model = new Sp_Account_Attendee(); if ($model->signAndDelete(array($signId["Id"]), 1)) { $jsonParam = array("code" => "200", "msg" => "恭喜您,签到成功");
public static function checkCode($account, $code = '', $type = '') { $rules['phone'] = Sp_Dictionary::getOtherOption("patternMobile"); $rules['email'] = Sp_Dictionary::getOtherOption("patternEmail"); $msg['phone'] = "电话格式不正确"; $msg['email'] = "邮箱格式不正确"; $return = 1; $filter = array('phone', 'email'); if (false == in_array($type, $filter)) { $return = array("status" => -100, "msg" => "参数错误"); } else { if (FALSE == preg_match($rules[$type], $account)) { $return = array("status" => -101, "msg" => $msg[$type]); } else { if (6 !== strlen($code)) { $return = array("status" => -102, "msg" => "验证码格式错误"); } } } return $return; }