function store() { require_once mnminclude . 'log.php'; global $db, $current_user, $globals; if (!$this->date) { $this->date = time(); } $comment_author = $this->author; $comment_link = $this->link; $comment_karma = $this->karma; $comment_date = $this->date; $comment_randkey = $this->randkey; $comment_content = $db->escape(clean_lines($this->content)); if ($this->id === 0) { $this->ip = $db->escape($globals['user_ip']); $db->query("INSERT INTO comments (comment_user_id, comment_link_id, comment_karma, comment_ip, comment_date, comment_randkey, comment_content) VALUES ({$comment_author}, {$comment_link}, {$comment_karma}, '{$this->ip}', FROM_UNIXTIME({$comment_date}), {$comment_randkey}, '{$comment_content}')"); $this->id = $db->insert_id; // Insert comment_new event into logs log_insert('comment_new', $this->id, $current_user->user_id); } else { $db->query("UPDATE comments set comment_user_id={$comment_author}, comment_link_id={$comment_link}, comment_karma={$comment_karma}, comment_ip = '{$this->ip}', comment_date=FROM_UNIXTIME({$comment_date}), comment_randkey={$comment_randkey}, comment_content='{$comment_content}' WHERE comment_id={$this->id}"); // Insert comment_new event into logs log_conditional_insert('comment_edit', $this->id, $current_user->user_id, 30); } $this->update_order(); }
function normalize_content() { $this->content = clean_lines(clear_whitespace(normalize_smileys($this->content))); return $this->content; }
function same_text_count($min = 30) { global $db; // WARNING: $db->escape(clean_lines($comment->content)) should be the sama as in libs/comment.php (unify both!) return (int) $db->get_var("select count(*) from posts where post_user_id = {$this->author} and post_date > date_sub(now(), interval {$min} minute) and post_content = '" . $db->escape(clean_lines($this->content)) . "'"); }