public function doCreateAction() { $email = $this->input('email'); $rname = $this->input('rname'); if (empty($email) || !Zyon_Util::isEmail($email)) { $this->flash(0, '邮件地址错误'); } if ($rname == '') { $this->flash(0, '真实姓名必须填写'); } if ($this->model('user')->getUserByEmail($email)) { $this->flash(0, '邮件地址已存在'); } $idtype = $this->input('idtype'); if (!array_key_exists($idtype, $this->model('user')->getIdTypes())) { $this->flash(0, '证件类型错误'); } $user = $this->model('user')->getNewUser($email, $rname, STAFFS_PASSWORD); $user['u_hid'] = $this->_master['u_hid']; $user['u_idtype'] = $idtype; $user['u_idno'] = $this->input('idno'); $user['u_rolename'] = $this->input('rolename'); $mobile = $this->input('mobile'); if (!empty($mobile)) { $user['u_phone'] = $mobile; } $permit = $this->input('permit', 'array'); if (!empty($permit)) { $user['u_permit'] = 0; foreach ($permit as $key => $val) { if (!isset($key[1]) || $key[0] !== 'b' || !Zyon_Util::isBin($bin = substr($key, 1)) || ($dec = bindec($bin)) > PERMIT_MASTER || $dec < 1) { $this->flash(0, '权限分配错误'); } if ($val > 0) { $user['u_permit'] = $user['u_permit'] | $dec; } } } $user['u_status'] = 1; $user['u_active'] = USER_ACTIVE_DL | USER_ACTIVE_JH; if ($uid = $this->model('user')->addUser($user)) { $user = $this->model('user')->getUser($uid); $this->model('log.user')->addLog($this->model('log.user')->getNewSignupLog($this->_master, $user)); $this->flash(1, array('message' => '添加帐号成功!', 'forward' => '/master/account/')); } $this->flash(0); }
/** * fetchOrderGuest * * @param array $array * @param mixed $gtype * @return array */ public function fetchOrderGuest($array, $gtype) { if (empty($array) || !is_array($array) || !isset($array['name']) || !is_string($array['name']) || ($array['name'] = trim($array['name'])) == '' || !isset($array['call'])) { $this->flash(0, '客人信息缺失'); } $gtype = $gtype === HOTEL_GUEST_TYPE_LIVE ? 'lver' : 'bker'; $guest = array("o_g{$gtype}_name" => $array['name'], "o_g{$gtype}_phone" => $array['call']); if (isset($array['mail'])) { if (!is_string($array['mail']) || ($array['mail'] = trim($array['mail'])) !== '' && !Zyon_Util::isEmail($array['mail'])) { $this->flash(0, '客人邮箱错误'); } $guest["o_g{$gtype}_email"] = $array['mail']; } if (isset($array['idtype'])) { if (!$this->model('user')->isIdType($array['idtype'])) { $this->flash(0, '证件类型错误'); } $guest["o_g{$gtype}_idtype"] = $array['idtype']; } isset($array['idno']) and $guest["o_g{$gtype}_idno"] = $array['idno']; isset($array['gender']) and $guest["o_g{$gtype}_gender"] = $array['gender']; if (!$this->model('order')->verify($guest)) { $this->flash(0, '客人信息错误'); } return $guest; }
/** * checkTimesLimit * * @param string $to_email * @param string $title * @param string $from_name * @return bool */ public function checkTimesLimit($to_email, $title, $from_name) { if (!isset($from_name[0]) || !is_string($from_name) || !isset($title[0]) || !is_string($title)) { return false; } if (!Zyon_Util::isEmail($to_email)) { return false; } $now = time(); $rules = array($now - 86400 => 5, $now - 3600 => 3, $now - 600 => 1); // ksort($rules, SORT_NUMERIC); try { $sql = $this->dbase()->select()->from($this->tname('mail_job'), 'mj_ctime as ctime')->where('mj_to_email = :to_email')->where('mj_title = :title')->where('mj_from_name = :from_name')->where('mj_ctime >= ?', min(array_keys($rules)))->order('mj_ctime ASC')->limit(max($rules)); if ($ret = $this->dbase()->fetchCol($sql, array('to_email' => $to_email, 'title' => $title, 'from_name' => $from_name))) { if (isset($ret[max($rules) - 1])) { return false; } if (!isset($ret[min($rules) - 1])) { return true; } foreach ($rules as $ctime => $limit) { foreach ($ret as $idx => $val) { if ($val < $ctime) { unset($ret[$idx]); } else { break; } } if (empty($ret)) { return true; } if (count($ret) >= $limit) { return false; } } } } catch (Exception $e) { $this->log($e); return false; } return true; }
/** * getMberByEmail * * @param string $email * @param int $hid * @return array */ public function getMberByEmail($email, $hid) { if (empty($email) || !Zyon_Util::isEmail($email) || !Zyon_Util::isUnsignedInt($hid)) { return false; } try { $sql = $this->dbase()->select()->from($this->tname('mber'))->where('m_email = :email')->where('m_hid = :hid')->limit(1); return $this->dbase()->fetchRow($sql, array('email' => $email, 'hid' => $hid)); } catch (Exception $e) { $this->log($e); return false; } }
/** * 执行登录动作 */ public function doSigninAction() { if ($this->_master) { $this->flash(1, '您已经登录过了'); } if (!Zyon_Util::isEmail($usign = $this->input('username'))) { $this->flash(0, '请填写正确的邮箱地址'); } $chash = md5(__CLASS__ . ':signin#' . $usign); if ($this->input('captcha') !== '' || $this->cache()->load($chash)) { $captcha = new Geek_Captcha_Image('/master/index/do-signin'); if (!$captcha->isValid($this->input('captcha'))) { $this->flash($this->input('captcha') !== '' ? 0 : -1, '请填写正确的验证码'); } } $outcome = $this->model('user')->getAuth()->verify($this); if (($session = $outcome->getSession()) && ($uid = $this->model('user')->parseAuthUqid($session->getIdentity()))) { $this->_master = $this->model('user')->getUser($uid); $this->checkUserStat(); $this->model('log.user')->addLog($this->model('log.user')->getNewSigninLog($this->_master)); $this->cache()->remove($chash); $this->flash(1, array('timeout' => 0, 'forward' => '/master')); } $this->cache()->save(1, $chash); $this->flash($this->input('captcha') !== '' ? 0 : -1, $outcome->getMessage()); }
/** * verify * * @param array $record * @return bool */ public function verify($record) { if (empty($record) || !is_array($record)) { return false; } if (isset($record['o_hid'])) { if (!Zyon_Util::isUnsignedInt($record['o_hid']) || empty($record['o_hid']) || strlen($record['o_hid']) > 10) { return false; } } if (isset($record['o_sid'])) { if (!Zyon_Util::isUnsignedInt($record['o_sid']) || empty($record['o_sid']) || strlen($record['o_sid']) > 10) { return false; } } if (isset($record['o_bid'])) { if (!Zyon_Util::isUnsignedInt($record['o_bid']) || empty($record['o_bid']) || strlen($record['o_bid']) > 10) { return false; } } if (isset($record['o_rid'])) { if (!Zyon_Util::isUnsignedInt($record['o_rid']) || empty($record['o_rid']) || strlen($record['o_rid']) > 10) { return false; } } if (isset($record['o_mid'])) { if (!Zyon_Util::isUnsignedInt($record['o_mid']) || strlen($record['o_mid']) > 10) { return false; } } if (isset($record['o_mno'])) { if (!is_string($record['o_mno']) || mb_strlen($record['o_mno']) > 30) { return false; } } if (isset($record['o_room'])) { if (!is_string($record['o_room']) || trim($record['o_room']) == '' || mb_strlen($record['o_room']) > 30) { return false; } } if (isset($record['o_price'])) { if (!Zyon_Util::isUnsignedInt($record['o_price']) || strlen($record['o_price']) > 9) { return false; } } if (isset($record['o_brice'])) { if (!Zyon_Util::isUnsignedInt($record['o_brice']) || strlen($record['o_brice']) > 9) { return false; } } if (isset($record['o_attr']) && !$record['o_attr'] instanceof Zend_Db_Expr) { if (!Zyon_Util::isUnsignedInt($record['o_attr']) || strlen($record['o_attr']) > 10) { return false; } } if (isset($record['o_memo'])) { if (!is_string($record['o_memo']) || mb_strlen($record['o_memo']) > 500) { return false; } } if (isset($record['o_btime'])) { if (!Zyon_Util::isUnsignedInt($record['o_btime']) || strlen($record['o_btime']) > 10) { return false; } } if (isset($record['o_etime'])) { if (!Zyon_Util::isUnsignedInt($record['o_etime']) || strlen($record['o_etime']) > 10 || isset($record['o_btime']) && date('Y-m-d', $record['o_etime']) === date('Y-m-d', $record['o_btime'])) { return false; } } if (isset($record['o_bdatm'])) { if (!Zyon_Util::isUnsignedInt($record['o_bdatm']) || strlen($record['o_bdatm']) > 10 || isset($record['o_btime']) && date('Y-m-d', $record['o_btime']) !== date('Y-m-d', $record['o_bdatm'])) { return false; } } if (isset($record['o_edatm'])) { if (!Zyon_Util::isUnsignedInt($record['o_edatm']) || strlen($record['o_edatm']) > 10 || isset($record['o_bdatm']) && $record['o_bdatm'] === $record['o_edatm'] || isset($record['o_etime']) && date('Y-m-d', $record['o_etime']) !== date('Y-m-d', $record['o_edatm'])) { return false; } } if (isset($record['o_cid'])) { if (!Zyon_Util::isUnsignedInt($record['o_cid']) || strlen($record['o_cid']) > 10) { return false; } } if (isset($record['o_tid'])) { if (!Zyon_Util::isUnsignedInt($record['o_tid']) || strlen($record['o_tid']) > 10) { return false; } } if (isset($record['o_prices'])) { if (!is_string($record['o_prices']) || trim($record['o_prices']) == '') { return false; } } if (isset($record['o_brices'])) { if (!is_string($record['o_brices']) || trim($record['o_brices']) == '') { return false; } } if (isset($record['o_status'])) { if (!$this->getStateNameByCode($record['o_status']) || strlen($record['o_status']) > 3) { return false; } } if (isset($record['o_gbker_name'])) { if (!is_string($record['o_gbker_name']) || trim($record['o_gbker_name']) == '' || mb_strlen($record['o_gbker_name']) > 14) { return false; } } if (isset($record['o_gbker_idno']) && $record['o_gbker_idno'] !== '') { if (!is_string($record['o_gbker_idno']) || mb_strlen($record['o_gbker_idno']) > 30) { return false; } } if (isset($record['o_gbker_email']) && $record['o_gbker_email'] !== '') { if (!Zyon_Util::isEmail($record['o_gbker_email']) || mb_strlen($record['o_gbker_email']) > 100) { return false; } } if (isset($record['o_gbker_phone'])) { if (!is_string($record['o_gbker_phone']) || mb_strlen($record['o_gbker_phone']) > 20) { return false; } } if (isset($record['o_gbker_idtype'])) { if (!Zyon_Util::isUnsignedInt($record['o_gbker_idtype']) || strlen($record['o_gbker_idtype']) > 3) { return false; } } if (isset($record['o_glver_name'])) { if (!is_string($record['o_glver_name']) || trim($record['o_glver_name']) == '' || mb_strlen($record['o_glver_name']) > 14) { return false; } } if (isset($record['o_glver_idno']) && $record['o_glver_idno'] !== '') { if (!is_string($record['o_glver_idno']) || mb_strlen($record['o_glver_idno']) > 30) { return false; } } if (isset($record['o_glver_email']) && $record['o_glver_email'] !== '') { if (!Zyon_Util::isEmail($record['o_glver_email']) || mb_strlen($record['o_glver_email']) > 100) { return false; } } if (isset($record['o_glver_phone'])) { if (!is_string($record['o_glver_phone']) || mb_strlen($record['o_glver_phone']) > 20) { return false; } } if (isset($record['o_glver_idtype'])) { if (!Zyon_Util::isUnsignedInt($record['o_glver_idtype']) || strlen($record['o_glver_idtype']) > 3) { return false; } } return true; }
/** * getUserByEmail * * @param string $email * @return array */ public function getUserByEmail($email) { if (empty($email) || !Zyon_Util::isEmail($email)) { return false; } try { if ($id = $this->cache()->load($key = $this->hash($email))) { if (($ret = $this->getUser($id)) && $ret['u_email'] === $email) { return $ret; } $this->cache()->remove($key); } $sql = $this->dbase()->select()->from($this->tname('user'))->where('u_email = :email')->limit(1); if ($ret = $this->dbase()->fetchRow($sql, array('email' => $email))) { $this->cache()->save($ret['u_id'], $key); } return $ret; } catch (Exception $e) { $this->log($e); return false; } }
/** * verify * * @param array $record * @return bool */ public function verify($record) { if (empty($record) || !is_array($record)) { return false; } if (isset($record['h_attr']) && !$record['h_attr'] instanceof Zend_Db_Expr) { if (!Zyon_Util::isUnsignedInt($record['h_attr']) || strlen($record['h_attr']) > 10) { return false; } } if (isset($record['h_name'])) { if (!is_string($record['h_name']) || trim($record['h_name']) == '' || mb_strlen($record['h_name']) > 15) { return false; } } if (isset($record['h_note'])) { if (!is_string($record['h_note']) || mb_strlen($record['h_note']) > 500) { return false; } } if (isset($record['h_title'])) { if (!is_string($record['h_title']) || mb_strlen($record['h_title']) > 50) { return false; } } if (isset($record['h_iname'])) { if (!$this->isIname($record['h_iname'])) { return false; } } if (isset($record['h_email'])) { if (!Zyon_Util::isEmail($record['h_email']) || mb_strlen($record['h_email']) > 50) { return false; } } if (isset($record['h_phone'])) { if (!is_string($record['h_phone']) || !isset($record['h_phone'][5]) || mb_strlen($record['h_phone']) > 20) { return false; } } if (isset($record['h_domain'])) { if (!is_string($record['h_domain']) || mb_strlen($record['h_domain']) > 50) { return false; } } if (isset($record['h_website'])) { if (!is_string($record['h_website']) || mb_strlen($record['h_website']) > 50) { return false; } } if (isset($record['h_address'])) { if (!is_string($record['h_address']) || mb_strlen($record['h_address']) > 250) { return false; } } if (isset($record['h_country'])) { if (!is_string($record['h_country']) || mb_strlen($record['h_country']) > 50) { return false; } } if (isset($record['h_province'])) { if (!is_string($record['h_province']) || mb_strlen($record['h_province']) > 50) { return false; } } if (isset($record['h_city'])) { if (!is_string($record['h_city']) || mb_strlen($record['h_city']) > 50) { return false; } } if (isset($record['h_obill_default_settlem'])) { if (!Zyon_Util::isUnsignedInt($record['h_obill_default_settlem']) || strlen($record['h_obill_default_settlem']) > 10) { return false; } } if (isset($record['h_order_default_typedef'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_default_typedef']) || strlen($record['h_order_default_typedef']) > 10) { return false; } } if (isset($record['h_order_default_channel'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_default_channel']) || strlen($record['h_order_default_channel']) > 10) { return false; } } if (isset($record['h_order_default_payment'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_default_payment']) || strlen($record['h_order_default_payment']) > 10) { return false; } } if (isset($record['h_order_default_stacode'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_default_stacode']) || strlen($record['h_order_default_stacode']) > 3) { return false; } } if (isset($record['h_order_enddays'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_enddays']) || strlen($record['h_order_enddays']) > 3 || $record['h_order_enddays'] > 450) { return false; } } if (isset($record['h_order_minlens'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_minlens']) || $record['h_order_minlens'] < 1 || strlen($record['h_order_minlens']) > 4) { return false; } } if (isset($record['h_order_maxlens'])) { if (!Zyon_Util::isUnsignedInt($record['h_order_maxlens']) || $record['h_order_maxlens'] > 31) { return false; } } if (isset($record['h_obill_keptime'])) { if (!Zyon_Util::isUnsignedInt($record['h_obill_keptime']) || strlen($record['h_obill_keptime']) > 10) { return false; } } if (isset($record['h_order_enabled']) && !$record['h_order_enabled'] instanceof Zend_Db_Expr) { if (!Zyon_Util::isUnsignedInt($record['h_order_enabled']) || $record['h_order_enabled'] > 3) { return false; } } if (isset($record['h_rosta_visible']) && !$record['h_rosta_visible'] instanceof Zend_Db_Expr) { if (!Zyon_Util::isUnsignedInt($record['h_rosta_visible']) || $record['h_rosta_visible'] > 3) { return false; } } if (isset($record['h_checkin_time'])) { if (!Zyon_Util::isUnsignedInt($record['h_checkin_time']) || $record['h_checkin_time'] > 86399) { return false; } } if (isset($record['h_checkout_time'])) { if (!Zyon_Util::isUnsignedInt($record['h_checkout_time']) || $record['h_checkout_time'] > 86399) { return false; } } if (isset($record['h_prompt_checkin'])) { if (!Zyon_Util::isUnsignedInt($record['h_prompt_checkin']) || strlen($record['h_prompt_checkin']) > 10) { return false; } } if (isset($record['h_prompt_checkout'])) { if (!Zyon_Util::isUnsignedInt($record['h_prompt_checkout']) || strlen($record['h_prompt_checkout']) > 10) { return false; } } if (isset($record['h_status'])) { if (!Zyon_Util::isUnsignedInt($record['h_status']) || strlen($record['h_status']) > 3) { return false; } } return true; }