[pLog-svn] r6277 - in plog/branches/lifetype-1.2/class: data/validator misc template test/tests/misc

mark at devel.lifetype.net mark at devel.lifetype.net
Sat Mar 29 13:56:25 EDT 2008


Author: mark
Date: 2008-03-29 13:56:24 -0400 (Sat, 29 Mar 2008)
New Revision: 6277

Modified:
   plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php
   plog/branches/lifetype-1.2/class/misc/glob.class.php
   plog/branches/lifetype-1.2/class/misc/integritychecker.class.php
   plog/branches/lifetype-1.2/class/template/templatesandbox.class.php
   plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php
Log:
Revert to 6273. We can use strtolower() to implement an easier solution and better compatibility.

Modified: plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php	2008-03-29 16:57:04 UTC (rev 6276)
+++ plog/branches/lifetype-1.2/class/data/validator/uploadvalidator.class.php	2008-03-29 17:56:24 UTC (rev 6277)
@@ -81,7 +81,7 @@
             // check if the filename extension is forbidden or not
             $fileName = basename($upload->getFileName());
             foreach( explode( " ", $forbiddenFilesStr ) as $file ) {
-            	if( Glob::myFnmatch( $file, $fileName, FNM_CASEFOLD )) {
+            	if( Glob::myFnmatch( $file, $fileName )) {
                 	return UPLOAD_VALIDATOR_ERROR_FORBIDDEN_EXTENSION;
                 }
             }
@@ -99,7 +99,7 @@
             // check if the filename extension is one of the allowed ones or not
             $fileName = basename($upload->getFileName());
             foreach( explode( " ", $allowedFilesStr ) as $file ) {
-            	if( Glob::myFnmatch( $file, $fileName, FNM_CASEFOLD )) {
+            	if( Glob::myFnmatch( $file, $fileName )) {
 //					print("it's a valid file!");
                 	return true;
                 }

Modified: plog/branches/lifetype-1.2/class/misc/glob.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/misc/glob.class.php	2008-03-29 16:57:04 UTC (rev 6276)
+++ plog/branches/lifetype-1.2/class/misc/glob.class.php	2008-03-29 17:56:24 UTC (rev 6277)
@@ -68,15 +68,15 @@
          * @return True if the file matches the pattern or false if not.
          * @static
          */
-        function fnmatch( $pattern, $file, $flags = 0 )
+        function fnmatch( $pattern, $file )
         {
         	if( function_exists("fnmatch")) {
             	// use the native fnmatch version
-                return fnmatch( $pattern, $file, $flags );
+                return fnmatch( $pattern, $file );
             }
             else {
                 // otherwise, use our own
-                return Glob::myFnmatch( $pattern, $file, $flags );
+                return Glob::myFnmatch( $pattern, $file );
             }
         }
 
@@ -91,7 +91,7 @@
          * files will match and which will not.
          * @return An array with the matching files and false if error.
          */
-        function myGlob( $folder = ".", $pattern = "*", $flags = 0 )
+        function myGlob( $folder = ".", $pattern = "*" )
         {
         	// Note that !== did not exist until 4.0.0-RC2
             // what if the temp folder is deleted?  or $folder is not exist? then will raise
@@ -103,7 +103,7 @@
 
                 while (false !== ($file = readdir($handle))) {
                     if( $file !="." && $file != ".." )	// ignore '.' and '..'
-                        if( Glob::fnmatch($pattern,$file,$flags)) {
+                        if( Glob::fnmatch($pattern,$file)) {
                         	if( $folder[strlen($folder)-1] != "/")
                         		$filePath = $folder."/".$file;
                             else
@@ -129,12 +129,12 @@
  	 	 *
 		 * @static
          */
-        function myFnmatch( $pattern, $file, $flags = 0 )
+        function myFnmatch( $pattern, $file )
         {
         	for($i=0,$len = strlen($pattern); $i<$len; $i++) {
             	if($pattern[$i] == "*") {
                 	for($c=$i; $c<max(strlen($pattern), strlen($file)); $c++) {
-                    	if(Glob::myFnmatch(substr($pattern, $i+1), substr($file, $c), $flags)) {
+                    	if(Glob::myFnmatch(substr($pattern, $i+1), substr($file, $c))) {
                         	return true;
                         }
                     }
@@ -150,27 +150,20 @@
                         	break;
                     }
                     foreach ($letter_set as $letter) {
-                    	if(Glob::myFnmatch($letter.substr($pattern, $c+1), substr($file, $i), $flags)) {
+                    	if(Glob::myFnmatch($letter.substr($pattern, $c+1), substr($file, $i))) {
                         	return true;
                         }
                     }
                     return false;
-                }
-                if($pattern[$i] == "?") {
+               }
+               if($pattern[$i] == "?") {
               		continue;
-                }
-                if($flags == FNM_CASEFOLD){
-                    if(strtolower($pattern[$i]) != strtolower($file[$i])) {
-                        return false;
-                    }
-                }
-                else{
-                    if($pattern[$i] != $file[$i]) {
-                        return false;
-                    }
-                }
-            }
-            return true;
-        }
+              }
+              if($pattern[$i] != $file[$i]) {
+              	return false;
+              }
+         }
+         return true;
+       }
     }
 ?>

Modified: plog/branches/lifetype-1.2/class/misc/integritychecker.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/misc/integritychecker.class.php	2008-03-29 16:57:04 UTC (rev 6276)
+++ plog/branches/lifetype-1.2/class/misc/integritychecker.class.php	2008-03-29 17:56:24 UTC (rev 6277)
@@ -84,7 +84,7 @@
 			
 			$result = false;
 			foreach( $ignore as $pattern ) {
-				if( Glob::myFnMatch( $pattern, $file, FNM_CASEFOLD )) {
+				if( Glob::myFnMatch( $pattern, $file )) {
 					$result = true;
 					break;					
 				}

Modified: plog/branches/lifetype-1.2/class/template/templatesandbox.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/template/templatesandbox.class.php	2008-03-29 16:57:04 UTC (rev 6276)
+++ plog/branches/lifetype-1.2/class/template/templatesandbox.class.php	2008-03-29 17:56:24 UTC (rev 6277)
@@ -48,7 +48,7 @@
             // otherwise, turn the thing into an array and go through all of them
 			lt_include( PLOG_CLASS_PATH.'class/misc/glob.class.php' );			
             foreach( explode( " ", $forbiddenFilesStr ) as $file ) {
-                $files = Glob::myGlob( $folder, $file, FNM_CASEFOLD );
+                $files = Glob::myGlob( $folder, $file );
                 if( count($files) > 0 )
                 	return false;
             }

Modified: plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php	2008-03-29 16:57:04 UTC (rev 6276)
+++ plog/branches/lifetype-1.2/class/test/tests/misc/glob_test.class.php	2008-03-29 17:56:24 UTC (rev 6277)
@@ -17,10 +17,6 @@
 			
 			// valid match
 			$this->assertTrue( Glob::myFnMatch( "*index.template.*", "index.template.php" ));			
-
-                // case sensitive checking
-			$this->assertTrue( Glob::myFnMatch( "*index.template.PHP", "index.template.php", FNM_CASEFOLD ));
-			$this->assertFalse( Glob::myFnMatch( "*index.template.PHP", "index.template.php"));
 		}		
 	}
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list