[Comoblog-commit] comoblog/include config.inc.php, 1.2, 1.3 libraries.inc.php, 1.9, 1.10
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-08-15 16:56:35
|
Update of /cvsroot/comoblog/comoblog/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20529/include Modified Files: config.inc.php libraries.inc.php Log Message: Initial commit of the comment verificatin code - see also mod_comment_notify still needs update script doing - but this works (for me at least) as a new install. will document fully when i get home tonight, but briefly.. - new collumn in comments table for live state (y or n) - new preferences for default live state and a quick password - new table for preauthenticated users / pre bared users - new code in libraries.inc.php to manipulate the above Index: libraries.inc.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/include/libraries.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- libraries.inc.php 17 Feb 2006 15:16:37 -0000 1.9 +++ libraries.inc.php 15 Aug 2006 16:56:31 -0000 1.10 @@ -411,6 +411,62 @@ return (true); } +function get_commenter_approval_state($commenter_author_email){ + + // gets the default for people who have been recorded before, + // returns "unknown_user" for people who it cant find + // and Y or N if it can. + $query = " + select c.commenter_default + from ".CFG_MYSQL_TABPREFIX."commenters c + where c.commenter_author_email= '".addslashes($commenter_author_email)."'"; + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)){ + return ("unknown_user"); + } + + return mysql_query($res,0,0); + +} + +function set_commenter_approval_state($commenter_author_email,$state){ + + // empty place holder + $query =""; + // find out if we know about the user already. + if (get_commenter_approval_state($commenter_author_email) !="unknown_user"){ + // if we do - update the record. + $query ="update ".CFG_MYSQL_TABPREFIX."commenters " . + "set commenter_default=''".addslashes($state)."'" . + "' where commenter_author_email= '".addslashes($commenter_author_email)."'"; + } + + else { + // if not - add a record + $query = " + insert into ".CFG_MYSQL_TABPREFIX."commenters + (comment_author_email,commenter_default) + values ( + '".addslashes($commenter_author_email)."', + '".addslashes($state)."' + ) + "; + } + + + // run the query + $res = mysql_query($query); + + if (!$res) + return (false); + + $insert_id = mysql_insert_id(); + + return ($insert_id); + +} + function comment_add ($comment) { $comment['comment_author'] = clean_up_txt($comment['comment_author']); @@ -422,27 +478,41 @@ $comment['comment_text'] = clean_up_txt($comment['comment_text']); } + + + // first we get the default state for new comments + if (CFG_COMMENTS_DEFAULT_STATE == 'yes'){ + $comment['comment_live'] = "Y"; + } + else { + $comment['comment_live'] = "N"; + } + // then we check if we have seen them before + if (get_commenter_approval_state($comment['comment_author_email']) !="unknown_user"){ + $comment['comment_live'] =get_commenter_approval_state($comment['comment_author_email']); + } // apply comment filters - global $COMMENT_FILTERS; - if (count($COMMENT_FILTERS) > 0) { - for ($comment_cnt = 0; $comment_cnt < count($COMMENT_FILTERS); $comment_cnt++) { - include_once (CFG_BASE_PATH.'/modules/'.$COMMENT_FILTERS[$comment_cnt].'/'.$COMMENT_FILTERS[$comment_cnt].'_comment_filter.php'); + global $COMMENT_PRE_FILTERS; + if (count($COMMENT_PRE_FILTERS) > 0) { + for ($comment_cnt = 0; $comment_cnt < count($COMMENT_PRE_FILTERS); $comment_cnt++) { + include_once (CFG_BASE_PATH.'/modules/'.$COMMENT_PRE_FILTERS[$comment_cnt].'/'.$COMMENT_PRE_FILTERS[$comment_cnt].'_comment_filter.php'); } } $query = " insert into ".CFG_MYSQL_TABPREFIX."comments - (comment_author,comment_author_email,comment_author_url,comment_text,comment_added,post_id) + (comment_author,comment_author_email,comment_author_url,comment_text,comment_added,post_id,comment_live) values ( '".addslashes($comment['comment_author'])."', '".addslashes($comment['comment_author_email'])."', - '".addslashes($comment['comment_author_url'])."', + '".addslashes($comment['comment_author_url'])."', '".addslashes($comment['comment_text'])."', '".time()."', - '".$comment['post_id']."' + '".$comment['post_id']."', + '".$comment['comment_live']."' ) "; $res = mysql_query($query); @@ -452,6 +522,15 @@ $comment['comment_id'] = mysql_insert_id(); + // apply comment filters + global $COMMENT_POST_FILTERS; + if (count($COMMENT_POST_FILTERS) > 0) { + for ($comment_cnt = 0; $comment_cnt < count($COMMENT_POST_FILTERS); $comment_cnt++) { + include_once (CFG_BASE_PATH.'/modules/'.$COMMENT_POST_FILTERS[$comment_cnt].'/'.$COMMENT_POST_FILTERS[$comment_cnt].'_comment_filter.php'); + } + } + + return ($comment); } Index: config.inc.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/include/config.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- config.inc.php 5 Oct 2005 00:45:34 -0000 1.2 +++ config.inc.php 15 Aug 2006 16:56:31 -0000 1.3 @@ -50,6 +50,8 @@ $POST_PRE_FILTERS = array(); $POST_POST_FILTERS = array(); $COMMENT_FILTERS = array(); +$COMMENT_PRE_FILTERS = array(); +$COMMENT_POST_FILTERS = array(); $query = " select mod_name, mod_pos, mod_display_order, mod_filter_posts, mod_filter_comments from ".CFG_MYSQL_TABPREFIX."modules @@ -67,12 +69,20 @@ $TOP_MODULES[] = $row['mod_name']; } - if ($row['mod_filter_posts'] == 'Y') + if ($row['mod_filter_posts'] == 'Y'){ $POST_PRE_FILTERS[] = $row['mod_name']; - else if ($row['mod_filter_posts'] == 'O') + } + else if ($row['mod_filter_posts'] == 'O'){ $POST_POST_FILTERS[] = $row['mod_name']; - if ($row['mod_filter_comments'] == 'Y') - $COMMENT_FILTERS[] = $row['mod_name']; + } + if ($row['mod_filter_comments'] == 'Y'){ + $COMMENT_PRE_FILTERS[] = $row['mod_name']; + } + else if ($row['mod_filter_comments'] == 'O'){ + $COMMENT_POST_FILTERS[] = $row['mod_name']; + } + + } } ?> |