[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/summary/data/validator/ -> customsummarypagevalidator.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/data/validator/validator.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );    
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/rules/filteredwordsrule.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
   8  
   9      /**
  10       * custom summary page validator that does:
  11       *
  12       * 1) check whether the page is a valid string
  13       * 2) whether it has the correct characters
  14       * 3) whether the page exists under templates/summary/ and it is readable
  15       *
  16       * If all the checks above are successful, it will return true
  17       */
  18      class CustomSummaryPageValidator extends Validator
  19      {
  20      
  21  		function CustomSummaryPageValidator()
  22          {
  23              // check that the page has the right characters
  24              $this->addRule( new RegExpRule( "[A-Za-z0-9\-_]" ));
  25              // and that it is a string at all
  26              $this->addValidator( new StringValidator());
  27              // and that it is not any of the default templates...
  28              $this->addRule( new FilteredWordsRule( Array( "summaryerror",
  29                                                            "agreement",
  30                                                            "email_confirm",
  31                                                            "registerfinished",
  32                                                            "blogprofile",
  33                                                            "formvalidate",
  34                                                            "pager",
  35                                                            "userlist",
  36                                                            "userprofile",
  37                                                            "validate",
  38                                                            "changepassword",
  39                                                            "message",
  40                                                            "resetpassword",
  41                                                            "resetpasswordemail",
  42                                                            "searchresults",
  43                                                            "bloglist",
  44                                                            "index",
  45                                                            "recent",
  46                                                            "registererror",
  47                                                            "footer",
  48                                                            "header",
  49                                                            "summary" )));                                                        
  50          }
  51          
  52  		function validate( $data )
  53          {
  54              // check the rules created in the constructor
  55              if( !parent::validate( $data ))
  56                  return false;
  57                  
  58              // and if they succeeded, check if the file exists. If not, return false
  59              // and go to the main page...
  60              $filePath = "templates/summary/$data.template";
  61              return( File::isReadable( $filePath ));
  62          }        
  63      }
  64  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics