Exemple #1
0
 /**
  * _getClientFloodCount
  * Check cache to see if IP requires rate limiting
  * If exceeds max attempts, inject delay
  *
  */
 protected function _getClientFloodCount()
 {
     $ip = Foresmo::getIP();
     $count = 0;
     if ($ip != '0.0.0.0') {
         $key = 'foresmo_flood_control_' . $ip;
         $life = $this->_cache->_config['life'];
         $this->_cache->_config['life'] = self::FLOODCONTROL_CACHE_CLIENT;
         $count = $this->_cache->fetch($key);
         $this->_cache->_config['life'] = $life;
         if ($count !== false && is_numeric($count)) {
             $count = (int) $count;
         } else {
             $count = 0;
         }
     }
     return $count;
 }
Exemple #2
0
 /**
  * insertComment
  * Insert a comment from post data
  *
  * @param $comment_data
  * @param $spam default false
  *
  * @return mixed last insert id
  */
 public function insertComment($comment_data, $spam = false)
 {
     $comment_data['post_id'] = (int) $comment_data['post_id'];
     $comment_data['url'] = $this->_cleanURL($comment_data['url']);
     if ($spam) {
         $status = 2;
     } else {
         $status = 1;
     }
     if (isset($_SESSION['Foresmo_App']['Foresmo_user_id'])) {
         $type = 1;
     } else {
         $type = 0;
     }
     $data = array('post_id' => $comment_data['post_id'], 'name' => $comment_data['name'], 'email' => $comment_data['email'], 'url' => $comment_data['url'], 'ip' => sprintf("%u", ip2long(Foresmo::getIP())), 'content' => $comment_data['comment'], 'status' => $status, 'date' => time(), 'type' => $type);
     return $this->insert($data);
 }