[pLog-svn] r6093 - in plog/branches/lifetype-1.2: . class/security config
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Thu Nov 29 11:32:11 EST 2007
Author: jondaley
Date: 2007-11-29 11:32:11 -0500 (Thu, 29 Nov 2007)
New Revision: 6093
Modified:
plog/branches/lifetype-1.2/.htaccess
plog/branches/lifetype-1.2/class/security/bayesianfilter.class.php
plog/branches/lifetype-1.2/class/security/commentfilter.class.php
plog/branches/lifetype-1.2/class/security/nullpipelinefilter.class.php
plog/branches/lifetype-1.2/class/security/pipeline.class.php
plog/branches/lifetype-1.2/class/security/pipelinefilter.class.php
plog/branches/lifetype-1.2/config/config.properties.php
Log:
my attempt at making both Mark and I happy. I am not sure if I succeeded. Plugins can now decide what they want to do based on the 'previouslyRejected' and 'secondRun' flags.
Modified: plog/branches/lifetype-1.2/.htaccess
===================================================================
--- plog/branches/lifetype-1.2/.htaccess 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/.htaccess 2007-11-29 16:32:11 UTC (rev 6093)
@@ -6,127 +6,96 @@
deny from all
</Files>
-Options -Indexes
-Options +FollowSymLinks
-
-<IfModule mod_rewrite.c>
-
RewriteEngine On
-RewriteBase /
+RewriteBase /plog
- # Point to the sitemap file that is local to the blog
-RewriteRule ^sitemap([0-9]+)\.gz$ tmp/sitemap/$1/sitemap.gz [L,NC]
+#RewriteCond %{REMOTE_HOST} !orange.limedaley.com
+#RewriteRule .* /temporary_failure.html [L]
-# Permalink to the blog entry (i.e. /1_userfoo/archive/3_title-foo-bar.html)
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]+)_[^.]+\.html$ index.php?op=ViewArticle&blogId=$1&articleId=$2 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]+)_[^.]+\.html\.page\.([1-9]+)$ index.php?op=ViewArticle&blogId=$1&articleId=$2&page=$3 [L,NC]
+# old category name
+RewriteRule ^category/internet(-|_)stuff(.*) /plog/category/internet$2 [R=permanent,L]
-# Monthly archive (i.e. /1_userfoo/archive/200401.html)
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ index.php?blogId=$1&Date=$2 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html\.page\.([1-9]+)$ index.php?blogId=$1&Date=$2&page=$3 [L,NC]
+# old links
+RewriteRule ^content(.*) /plog/static$1 [R=permanent,L]
-# Daily archive (i.e. /1_blogfoo/archive/20040101.html)
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{8})\.html$ index.php?blogId=$1&Date=$2 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{8})\.html\.page\.([1-9]+)$ index.php?blogId=$1&Date=$2&page=$3 [L,NC]
+RewriteCond %{REQUEST_URI} ^/plog/(category|archives)/[^_]+_
+RewriteRule ^([^_]+)_(.*)$ $1-$2 [R=permanent,L]
-# Album (i.e. /88_userfoo/albums/34_title-foo-bar.html)
-RewriteRule ^([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html$ index.php?op=ViewAlbum&blogId=$1&albumId=$2 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html\.page\.([1-9]+)$ index.php?op=ViewAlbum&blogId=$1&albumId=$2&page=$3 [L,NC]
+RewriteRule ^jonathan/?$ /plog/category/jonathan [R,L]
+RewriteRule ^isaac/?$ /plog/category/isaac [R,L]
+RewriteRule ^(1|jondaley)/?$ /plog/ [R,L]
-# Albums (i.e. /88_userfoo/albums/)
-RewriteRule ^([0-9]+)_[^/]+/albums/$ index.php?op=ViewAlbum&blogId=$1&albumId=0 [L,NC]
+#############################################################################
+## My query string gets
+# Static Pages (i.e /page/userfoo[.template])
+#RewriteRule ^page/(.+)$ index.php?op=Template&show=$1&%{QUERY_STRING} [L]
-# Category view (i.e. /88_userfoo/categories/4_cat-foobar.html)
-RewriteRule ^([0-9]+)_[^/]+/categories/([0-9]+)_[^.]+\.html$ index.php?blogId=$1&postCategoryId=$2 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^/]+/categories/([0-9]+)_[^.]+\.html\.page\.([1-9]+)$ index.php?blogId=$1&postCategoryId=$2&page=$3 [L,NC]
+###############################
+## catch all to avoid errors in the error.log
+#RewriteCond %{REQUEST_URI} !^/plog/error.php
+#RewriteCond %{REQUEST_URI} !^/plog/admin.php
+#RewriteCond %{REQUEST_URI} !^/plog/index.php
+#RewriteCond %{REQUEST_URI} !^/plog/templates
+#RewriteCond %{REQUEST_URI} !^/plog/files
+#RewriteRule (.*) /plog/error.php [L]
+###############################
-# Category-Feeds (i.e. /3_userfoo/feeds/categories/2_category/atom)
-RewriteRule ^([0-9]+)_[^/]+/feeds/categories/([0-9]+)_[^.]+/(.*)$ rss.php?blogId=$1&categoryId=$2&profile=$3 [L,NC]
+<Files *.php>
+ ForceType application/x-httpd-php5
+</Files>
-# Feeds (i.e. /3_userfoo/feeds/atom)
-RewriteRule ^([0-9]+)_[^/]+/feeds/(.*)$ rss.php?blogId=$1&profile=$2 [L,NC]
-
-# Trackbacks (i.e. /3_userfoo/trackbacks/34_title-foo-bar.html)
-RewriteRule ^([0-9]+)_[^/]+/trackbacks/([0-9]+)_[^.]+\.html$ index.php?op=Trackbacks&blogId=$1&articleId=$2 [L,NC]
-
-# Comment form (i.e. /88_userfoo/comment/34_title-foo-bar.html)
-RewriteRule ^([0-9]+)_[^/]+/comment/([0-9]+)_[^.]+\.html$ index.php?op=Comment&blogId=$1&articleId=$2 [L,NC]
-
-# Resources (i.e. /88_userfoo/resources/this-is-a-resource-name.pdf.html)
-RewriteRule ^([0-9]+)_[^/]+/resources/([^.]+)\.([^.]+)\.html$ index.php?op=ViewResource&blogId=$1&resource=$2.$3 [L,NC]
-
-# Download a resource (i.e. /88_userfoo/get/this-is-a-resource-name.pdf)
-RewriteRule ^([0-9]+)_[^/]+/get/(.+)$ resserver.php?blogId=$1&resource=$2 [L,NC]
-
-# A non-default blog (i.e. /88_userfoo)
-RewriteRule ^([0-9]+)_[^.]+$ index.php?blogId=$1 [L,NC]
-# -- same as above but with paging included
-RewriteRule ^([0-9]+)_[^.]+\.page\.([1-9]+)$ index.php?blogId=$1&page=$2 [L,NC]
-
-# Static Pages (i.e /3_userfoo/demosites)
-RewriteRule ^([0-9]+)_[^/]+/(.+)$ index.php?op=Template&blogId=$1&show=$2 [NC]
-
-</IfModule>
-
-
-
<Files post>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files archives>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files static>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files rss>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files category>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files trackbacks>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files comment>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files resource>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files get>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files album>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files blog>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files user>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
<Files page>
- ForceType application/x-httpd-php
+ ForceType application/x-httpd-php5
</Files>
-ErrorDocument 401 /error.php
-ErrorDocument 403 /error.php
-ErrorDocument 404 /error.php
+ErrorDocument 401 /plog/error.php
+ErrorDocument 403 /plog/error.php
+ErrorDocument 404 /plog/error.php
Modified: plog/branches/lifetype-1.2/class/security/bayesianfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/bayesianfilter.class.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/class/security/bayesianfilter.class.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -41,7 +41,7 @@
* @return A positive PipelineResult object is the comment is not spam or a negative
* one if it is.
*/
- function filter()
+ function filter($secondRun = false)
{
$config =& Config::getConfig();
@@ -134,41 +134,65 @@
if( $parentId == "" )
$parentId = 0;
- $spamicity = $this->getSpamProbability($blogInfo->getId(), $commentTopic, $commentText, $userName, $userEmail, $userUrl);
-
- if ($spamicity >= $config->getValue("bayesian_filter_spam_probability_treshold"))
+ $spamicity = $this->getSpamProbability($blogInfo->getId(),
+ $commentTopic, $commentText,
+ $userName, $userEmail, $userUrl);
+ if($spamicity >=
+ $config->getValue("bayesian_filter_spam_probability_treshold"))
{
- // need this to get the locale
+ // need this to get the locale
$plr = $this->getPipelineRequest();
$bi = $plr->getBlogInfo();
$locale = $bi->getLocale();
-
- // now we need to check what we have to do with this comment... either throw it away
- // or keep it in the database
-
- // this piece of code shouldn't really go here, but it's easier than letting
- // the AddComment action that there was actually a comment and that it should
- // still be added but marked as spam and so on... sometimes breaking a few
- // rules makes things easier :)
+
+ // now we need to check what we have to do with this comment... either throw it away
+ // or keep it in the database
+
+ // this piece of code shouldn't really go here, but it's easier than letting
+ // the AddComment action that there was actually a comment and that it should
+ // still be added but marked as spam and so on... sometimes breaking a few
+ // rules makes things easier :)
if( $config->getValue( "bayesian_filter_spam_comments_action" ) == BAYESIAN_FILTER_KEEP_COMMENT_ACTION ) {
$result = new PipelineResult(false, HIGH_SPAM_PROBABILITY, $locale->tr("error_comment_spam_keep" ));
$comments = new ArticleComments();
$clientIp = Client::getIp();
$comment = new UserComment( $articleId, $blogInfo->getId(), $parentId, $commentTopic, $commentText,
- null, $userName, $userEmail, $userUrl, $clientIp,
- 0, COMMENT_STATUS_SPAM );
- // mark it as a trackback instead of a user comment...
-
+ null, $userName, $userEmail, $userUrl, $clientIp,
+ 0, COMMENT_STATUS_SPAM );
+ // mark it as a trackback instead of a user comment...
+
if( $isTrackback ) {
$comment->setType( COMMENT_TYPE_TRACKBACK );
}
-
- // add the comment to the db
- $comments->addComment( $comment );
+ if(!$secondRun){
+ // add the comment to the db
+ $comments->addComment( $comment );
+ }
+ else{
+ // This is the second time through this filter, so
+ // the comment has already been saved to the
+ // database. However, if we previously trained this
+ // as non-spam, and another filter said it was
+ // spam, we should train it as spam now.
+ //
+ // Assuming previouslyRejected gets set correctly
+ // for the second pass, I think the below code will
+ // take care of this for us.
+ //
+ // Mark pointed out a situation where if the
+ // bayesian filter catches a comments as spam, and
+ // the auth-image (or other plugin) also catches it
+ // as spam, we probably don't want the comment in
+ // the database at all. I am not sure who should
+ // remove it, either here, since we added it
+ // incorrectly, or the other plugin, since it is
+ // overriding the bayesian filter.
+ }
}
else {
- // nothing to do here, simply throw the comment away
- $result = new PipelineResult(false, HIGH_SPAM_PROBABILITY, $locale->tr("error_comment_spam_throw_away" ));
+ // nothing to do here, simply throw the comment away
+ $result = new PipelineResult(false, HIGH_SPAM_PROBABILITY,
+ $locale->tr("error_comment_spam_throw_away" ));
}
$spam = true;
}
@@ -178,6 +202,8 @@
$spam = false;
}
+ // if(!$secondRun){ // if this is commented, the bayesian filter can
+ // train on the text of comments that other filters marked as spam.
if ( !$previouslyRejected )
{
// train the filter with the message, be it spam or not...
@@ -194,14 +220,15 @@
{
// Un-train this non-spam
BayesianFilterCore::untrain( $blogInfo->getId(), $commentTopic, $commentText, $userName, $userEmail,
- $userUrl, $spam );
+ $userUrl, false );
// train this as spam
BayesianFilterCore::train( $blogInfo->getId(), $commentTopic, $commentText, $userName, $userEmail,
$userUrl, true );
}
}
-
+ // } // end of don't let bayesian filter train on other filters
+
//print "<h1>" . number_format($spamicity * 100, 0) . "% of spamicity</h1>";
return $result;
}
Modified: plog/branches/lifetype-1.2/class/security/commentfilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/commentfilter.class.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/class/security/commentfilter.class.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -33,7 +33,7 @@
*
* @return A PipelineResult object
*/
- function filter()
+ function filter($secondRun = false)
{
// check if we're posting a comment
$request = $this->_pipelineRequest->getHttpRequest();
Modified: plog/branches/lifetype-1.2/class/security/nullpipelinefilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/nullpipelinefilter.class.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/class/security/nullpipelinefilter.class.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -21,7 +21,7 @@
/**
* Always returns a positive result
*/
- function filter()
+ function filter($secondRun = false)
{
lt_include( PLOG_CLASS_PATH . 'class/security/pipelineresult.class.php' );
Modified: plog/branches/lifetype-1.2/class/security/pipeline.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/pipeline.class.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/class/security/pipeline.class.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -135,7 +135,7 @@
$pipelineRequest = new PipelineRequest( $this->_httpRequest, $this->_blogInfo );
$filter = new $filterClass( $pipelineRequest );
// and execute it...
- $result = $filter->filter();
+ $result = $filter->filter(false);
// if there was an error, we better say so now
// and quite, making sure that we're keeping the
// error code
@@ -163,7 +163,7 @@
true );
$filter = new $filterClass( $pipelineRequest );
// and execute it...
- $result = $filter->filter();
+ $result = $filter->filter(true);
// if there was an error, we want to keep going
}
}
Modified: plog/branches/lifetype-1.2/class/security/pipelinefilter.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/pipelinefilter.class.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/class/security/pipelinefilter.class.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -53,7 +53,7 @@
* @return a PipelineResult object
* @see Pipelineresult
*/
- function filter()
+ function filter($secondRun=false)
{
throw( new Exception( "This method must be implemented by child classes!" ));
}
Modified: plog/branches/lifetype-1.2/config/config.properties.php
===================================================================
--- plog/branches/lifetype-1.2/config/config.properties.php 2007-11-29 15:31:04 UTC (rev 6092)
+++ plog/branches/lifetype-1.2/config/config.properties.php 2007-11-29 16:32:11 UTC (rev 6093)
@@ -26,13 +26,14 @@
# (note, if upgrading between minor releases:
# 1.0 to 1.0.1, etc. you shouldn't run the wizard)
-$config['db_host'] = '';
-$config['db_username'] = '';
-$config['db_password'] = '';
-$config['db_database'] = '';
+$config['db_host'] = 'localhost';
+$config['db_username'] = 'jondaley';
+$config['db_password'] = '4hUJeraG5TEche2U';
+$config['db_database'] = 'jondaley';
$config["db_persistent"] = true;
$config['db_character_set'] = '';
+#$config['db_options'] = Array( "enable_mysql_fulltext_search" => true );
#
# the database prefix will be appended to the name of each database tables in case you want
# to have more than one version of plog running at the same time, such as the stable and
@@ -40,5 +41,5 @@
# coexist in the same unique database. If you change this after the initial configuration done
# with the installation wizard, please make sure that you also rename the tables.
#
-$config['db_prefix'] = '';
+$config['db_prefix'] = 'plog_';
?>
More information about the pLog-svn
mailing list