Browse files

Added a fix for base64_decode to allow the strict argument to work on…

… PHP 5.1
  • Loading branch information...
1 parent 91bfcd0 commit 3aadf5c2ce97778fada56f91f4f96277b372eba0 @adamfranco adamfranco committed Sep 4, 2009
View
4 actions/add_member.php
@@ -12,14 +12,14 @@
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
-$groupId = base64_decode($_POST['group_id'], true);
+$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
if (!isset($_POST['user_id']) || !$_POST['user_id'])
throw new InvalidArgumentException("No user_id passed");
-$userId = base64_decode($_POST['user_id'], true);
+$userId = base64_decode_fix($_POST['user_id'], true);
if (!$userId)
throw new InvalidArgumentException("Invalid user_id passed");
View
4 actions/change_manager.php
@@ -12,11 +12,11 @@
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
-$groupId = base64_decode($_POST['group_id'], true);
+$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
-$userId = base64_decode($_POST['new_manager'], true);
+$userId = base64_decode_fix($_POST['new_manager'], true);
if (!$userId)
throw new InvalidArgumentException("Invalid user_id passed");
View
2 actions/create_group.php
@@ -12,7 +12,7 @@
if (!isset($_POST['container_dn']) || !$_POST['container_dn'])
throw new InvalidArgumentException("No container_dn passed");
-$containerDn = base64_decode($_POST['container_dn'], true);
+$containerDn = base64_decode_fix($_POST['container_dn'], true);
if (!$containerDn)
throw new InvalidArgumentException("Invalid container_dn passed");
View
2 actions/delete_group.php
@@ -12,7 +12,7 @@
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
-$groupId = base64_decode($_POST['group_id'], true);
+$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
View
2 actions/list_all.php
@@ -2,7 +2,7 @@
<?php
if (isset($_GET['current']) && $_GET['current'])
- $current = base64_decode($_GET['current'], true);
+ $current = base64_decode_fix($_GET['current'], true);
if (!isset($current) || ! $current)
$current = $ldapConfig['BaseDN'];
View
4 actions/remove_member.php
@@ -12,14 +12,14 @@
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
-$groupId = base64_decode($_POST['group_id'], true);
+$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
if (!isset($_POST['user_id']) || !$_POST['user_id'])
throw new InvalidArgumentException("No user_id passed");
-$userId = base64_decode($_POST['user_id'], true);
+$userId = base64_decode_fix($_POST['user_id'], true);
if (!$userId)
throw new InvalidArgumentException("Invalid user_id passed");
View
2 config.inc.php-sample
@@ -21,6 +21,8 @@ $ldapConfig['WritableGroupContainers'] = array(
'OU=MIDD,OU=web data,DC=middlebury,DC=edu',
'OU=MIIS,OU=web data,DC=middlebury,DC=edu',
);
+// This is that attribute in LDAP that maps to the the CAS user id.
+$ldapConfig['UserIdAttribute'] = 'middleburyCollegeUID';
global $notifyConfig;
$notifyConfig = array(
View
21 lib/functions.php
@@ -229,4 +229,23 @@ function notify ($groupDN) {
trigger_error("Group change notification failed for '".$config['URL']."' with message: ".$result, E_USER_WARNING);
curl_close($ch);
}
-}
+}
+
+/**
+ * workaround for bug in php 4.3.11 through 4.4.7, 5.1.2 through 5.2.4
+ *
+ * Function by zmorris at zsculpt dot com
+ * http://us.php.net/manual/en/function.base64-decode.php#79098
+ *
+ * @param string $data
+ * @param boolean $strict
+ * @return string
+ */
+function base64_decode_fix($data, $strict = false) {
+ if ($strict) {
+ if (preg_match( '![^a-zA-Z0-9/+=]!', $data))
+ return false;
+ }
+ return base64_decode($data);
+}
+

0 comments on commit 3aadf5c

Please sign in to comment.