[sork] Re: [imp] Fatal error ctype_lower() passwd/main.php

Eric Rostetter eric.rostetter at physics.utexas.edu
Thu Feb 6 16:37:02 PST 2003


Quoting "Oliver Schulze L." <oliver at samera.com.py>:

> Hi Eric,
> Same problem here.
> RedHat 7.3 php-4.1.2-7.3.6 package does not have ctype support.
> 
> Oliver

Try what I just commited to CVS RELENG_2.  If you don't have CVS, the
patch is:

Index: main.php
===================================================================
RCS file: /usr/repository/passwd/main.php,v
retrieving revision 1.1.1.1.2.7
retrieving revision 1.1.1.1.2.8
diff -u -r1.1.1.1.2.7 -r1.1.1.1.2.8
--- main.php    29 Jan 2003 20:25:04 -0000      1.1.1.1.2.7
+++ main.php    6 Feb 2003 22:33:53 -0000       1.1.1.1.2.8
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: passwd/main.php,v 1.1.1.1.2.7 2003/01/29 20:25:04 ericr Exp $
+ * $Horde: passwd/main.php,v 1.1.1.1.2.8 2003/02/06 22:33:53 ericr Exp $
  *
  * Copyright 1999-2003 Charles J. Hagenbuch <chuck at horde.org>
  * Copyright 1999-2003 Jon Parise <jon at horde.org>
@@ -84,18 +84,31 @@
         break;
     }

-    // disect the password in a localised way.
+    // disect the password in a localised way if the ctype extensions
+    // are available, otherwise in a non-localized way
     $alpha = 0; $alnum = 0; $num = 0; $upper = 0; $lower = 0; $space = 0;
     for ($i = 0; $i < strlen($newpassword0); $i++) {
         $char = substr($newpassword0, $i, 1);
-        if (ctype_lower($char)) {
-            $lower++; $alpha++; $alnum++;
-        } elseif (ctype_upper($char)) {
-            $upper++; $alpha++; $alnum++;
-        } elseif (ctype_digit($char)) {
-            $num++; $alnum++;
-        } elseif (ctype_space($char)) {
-            $space++;
+       if (extension_loaded("ctype")) {
+            if (ctype_lower($char)) {
+                $lower++; $alpha++; $alnum++;
+            } elseif (ctype_upper($char)) {
+                $upper++; $alpha++; $alnum++;
+            } elseif (ctype_digit($char)) {
+                $num++; $alnum++;
+            } elseif (ctype_space($char)) {
+                $space++;
+            }
+        } else {
+            if (preg_match('/[[:lower:]]/', $char)) {
+                $lower++; $alpha++; $alnum++;
+            } elseif (preg_match('/[[:upper:]/', $char)) {
+                $upper++; $alpha++; $alnum++;
+            } elseif (preg_match('/[[:digit:]]/', $char)) {
+                $num++; $alnum++;
+            } elseif ($char === ' ') {
+                $space++;
+            }
         }
     }

-- 
Eric Rostetter
The Department of Physics
The University of Texas at Austin

Why get even? Get odd!


More information about the sork mailing list