[pLog-svn] r6092 - plog/branches/lifetype-1.2/class/security
mark at devel.lifetype.net
mark at devel.lifetype.net
Thu Nov 29 10:31:05 EST 2007
Author: mark
Date: 2007-11-29 10:31:04 -0500 (Thu, 29 Nov 2007)
New Revision: 6092
Modified:
plog/branches/lifetype-1.2/class/security/pipeline.class.php
Log:
Revet the code to 6087.
Modified: plog/branches/lifetype-1.2/class/security/pipeline.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/security/pipeline.class.php 2007-11-29 08:21:57 UTC (rev 6091)
+++ plog/branches/lifetype-1.2/class/security/pipeline.class.php 2007-11-29 15:31:04 UTC (rev 6092)
@@ -3,19 +3,19 @@
/**
* \defgroup Security
*
- * The Security module provides a basic implementation of a generic Pipeline to which we can
+ * The Security module provides a basic implementation of a generic Pipeline to which we can
* register "filters", which wil carry out specific actions. Any of the filters can interrupt the
* processing, depending on the logic of the filter. Please see the Pipeline class for more information.
*/
-
+
lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
-
+
/**
* global array used to hold the list of filters that we're going to use in the pipeline.
* Now again, more than ever, wish that PHP4 had support for static attributes at the class
- * level...
+ * level...
*/
$_pLogPipelineRegisteredFilters = array();
@@ -35,7 +35,7 @@
* The out of the box implementation of the Pipeline comes with a null filter (a filter that does nothing -- go figure :))
* and a filter that implements a Bayesian filter for advanced spam protection. See the BayesianFilter class for more information.
*/
- class Pipeline
+ class Pipeline
{
/**
@@ -49,7 +49,7 @@
* that is currently processing the incoming request
*/
var $_blogInfo;
-
+
/**
* variable to hold the final result of executing the pipeline
*/
@@ -64,14 +64,14 @@
*/
function Pipeline( $httpRequest, $blogInfo = null )
{
+
-
$this->_httpRequest = $httpRequest;
$this->_blogInfo = $blogInfo;
-
+
$this->_registerDefaultFilters();;
}
-
+
/**
* Method that takes care of registering the default filters used in the pipeline.
*
@@ -88,10 +88,10 @@
$this->registerFilter( "NullPipelineFilter" );
$this->registerFilter( "CommentFilter" );
$this->registerFilter( "BayesianFilter" );
-
+
return true;
}
-
+
/**
* Static method that registers a filter externally
*
@@ -102,10 +102,10 @@
function registerFilter( $filterClass )
{
global $_pLogPipelineRegisteredFilters;
-
+
if( !is_array($_pLogPipelineRegisteredFilters)) // make sure that we have an array...
$_pLogPipelineRegisteredFilters = Array();
-
+
$_pLogPipelineRegisteredFilters["$filterClass"] = $filterClass;
}
@@ -117,8 +117,8 @@
{
lt_include( PLOG_CLASS_PATH . 'class/security/pipelinerequest.class.php' );
lt_include( PLOG_CLASS_PATH . 'class/security/pipelineresult.class.php' );
- global $_pLogPipelineRegisteredFilters;
-
+ global $_pLogPipelineRegisteredFilters;
+
// check if the pipeline is enabled
$config =& Config::getConfig();
if( $config->getValue( "security_pipeline_enabled" ) == false ) {
@@ -129,30 +129,46 @@
// Assume that this will be successful
$this->_result = new PipelineResult( true );
- // flag to represent the pipeline filters validate status
- $filterValidStatus = true;
-
// if enabled, then check all the filters
foreach( $_pLogPipelineRegisteredFilters as $filterClass ) {
// create an instance of the filter
$pipelineRequest = new PipelineRequest( $this->_httpRequest, $this->_blogInfo );
$filter = new $filterClass( $pipelineRequest );
- // and execute it...
+ // and execute it...
$result = $filter->filter();
-
- // We just keep the first invalid pipeline filter result
- if( $filterValidStatus && !$result->isValid()) {
- $this->_result = $result;
- $filterValidStatus = false;
+ // if there was an error, we better say so now
+ // and quite, making sure that we're keeping the
+ // error code
+
+ // Save off the result
+ $this->_result = $result;
+
+ if( !$result->isValid()) {
+ // break out of this loop
+ break;
}
-
- // If pipeline filter result vlidate, we just the $this->_result
- // to the last result every time.
- if( $filterValidStatus )
- $this->_result = $result;
}
+
+ // If one of the filters returns that this was not a valid result
+ if ( !$this->_result->isValid() ) {
+ // Now rerun through all of the filters so they can clean up
+ // if they have saved anything persistantly
+ // This also gives filters a chance to do anything else they
+ // want to do (i.e. report ip address to dns blacklist)
+
+ foreach( $_pLogPipelineRegisteredFilters as $filterClass ) {
+ // create an instance of the filter
+ $pipelineRequest = new PipelineRequest( $this->_httpRequest,
+ $this->_blogInfo,
+ true );
+ $filter = new $filterClass( $pipelineRequest );
+ // and execute it...
+ $result = $filter->filter();
+ // if there was an error, we want to keep going
+ }
+ }
return $this->_result ;
}
}
-?>
\ No newline at end of file
+?>
More information about the pLog-svn
mailing list