Ejemplo n.º 1
0
 /**
  * 登陆失败调用此方法
  * 1分钟之内只允许错3次 三次后不允许登陆
  * @param $ip
  */
 public function faildlogin($ip)
 {
     $key = cachekey('allow_login', $ip);
     $result = $this->redis->getRedis()->exists($key);
     if ($result) {
         $this->redis->incr($key);
     } else {
         $this->redis->set($key, 1, 600);
     }
 }
Ejemplo n.º 2
0
 public function saycount()
 {
     $key = cachekey(__FUNCTION__);
     $data = $this->redis->hget(__CLASS__, $key);
     if (is_bool($data)) {
         $sql = "select count(*) as c from say";
         $data = $this->db->get_one($sql, 'c');
         $this->redis->hset(__CLASS__, $key, $data);
     }
     return $data;
 }
Ejemplo n.º 3
0
 /**
  * 获取所有通过申请的友情链接
  */
 public function linklist($admin = false)
 {
     $key = cachekey(__FUNCTION__, $admin);
     $data = $this->redis->hget(__CLASS__, $key);
     if (is_bool($data)) {
         if (!$admin) {
             $where = 'where status = 1';
         } else {
             $where = '';
         }
         $sql = "select * from link " . $where;
         $data = $this->db->get_all($sql);
         $this->redis->hset(__CLASS__, $key, $data);
     }
     return $data;
 }
Ejemplo n.º 4
0
 /**
  * 获取博客的所有类型
  * 父可以没子 子不可没父
  */
 public function alltypes()
 {
     $key = cachekey(__FUNCTION__);
     $data = $this->redis->hget(__CLASS__, $key);
     if (is_bool($data)) {
         $sql = "select * from blogtype";
         $arr = $this->db->get_all($sql);
         $data = [];
         foreach ($arr as $value) {
             if ($value['topid'] == 0) {
                 $data[$value['id']] = ['name' => $value['name']];
             } else {
                 $data[$value['topid']]['child'][$value['id']] = $value['name'];
             }
         }
         $this->redis->hset(__CLASS__, $key, $data);
     }
     return $data;
 }
Ejemplo n.º 5
0
 /**
  * 获取所有标签和id
  * @return mixed
  */
 public function alltags()
 {
     $key = cachekey(__FUNCTION__);
     $data = $this->redis->hget(__CLASS__, $key);
     if (is_bool($data)) {
         $data = [];
         $sql = "select * from tag";
         $arr = $this->db->get_all($sql);
         foreach ($arr as $value) {
             $data[$value['id']] = $value;
         }
         $this->redis->hset(__CLASS__, $key, $data);
     }
     return $data;
 }
Ejemplo n.º 6
0
 /**
  * 除了数据库中的阅读量,又有多少阅读量
  * @param $blogid
  * @return int
  */
 public function getlook($blogid)
 {
     $key = cachekey($blogid);
     $data = $this->redis->hget('bloglook', $key);
     if (is_bool($data)) {
         $data = 0;
         $this->redis->hset('bloglook', $key, $data);
     }
     return $data;
 }
Ejemplo n.º 7
0
 public function allowcomment($ip)
 {
     $key = cachekey('allow_comment', $ip);
     $data = $this->redis->get($key);
     if ($data >= 2) {
         return false;
     } else {
         if ($data > 0) {
             $this->redis->incr($key);
         } else {
             $this->redis->set($key, 1, 60);
         }
         return true;
     }
 }