diff --git a/VERSION b/VERSION index b0bb878..85b7c69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.5 +0.9.6 diff --git a/add_attr.php b/add_attr.php index dadd99b..23e819b 100644 --- a/add_attr.php +++ b/add_attr.php @@ -1,9 +1,7 @@ isReadOnly() ) + pla_error( $lang['no_updates_in_read_only_mode'] ); +if( ! $ldapserver->haveAuthInfo()) + pla_error( $lang['not_enough_login_info'] ); + $attr = $_POST['attr']; $val = isset( $_POST['val'] ) ? $_POST['val'] : false;; $dn = $_POST['dn'] ; +$is_binary_val = isset( $_POST['binary'] ) ? true : false; + $encoded_dn = rawurlencode( $dn ); $encoded_attr = rawurlencode( $attr ); -$is_binary_val = isset( $_POST['binary'] ) ? true : false; if( ! $is_binary_val && $val == "" ) { pla_error( $lang['left_attr_blank'] ); } -if( is_server_read_only( $server_id ) ) - pla_error( $lang['no_updates_in_read_only_mode'] ); - -check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] ); -have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] ); - -// special case for binary attributes (like jpegPhoto and userCertificate): +// special case for binary attributes (like jpegPhoto and userCertificate): // we must go read the data from the file and override $val with the binary data // Secondly, we must check if the ";binary" option has to be appended to the name // of the attribute. // Check to see if this is a unique Attribute -if( $badattr = checkUniqueAttr( $server_id, $dn, $attr, array($val) ) ) { - $search_href='search.php?search=true&form=advanced&server_id=' . $server_id . '&filter=' . $attr . '=' . $badattr; - pla_error(sprintf( $lang['unique_attr_failed'] , $attr,$badattr,$dn,$search_href ) ); +if( $badattr = checkUniqueAttr( $ldapserver, $dn, $attr, array($val) ) ) { + $search_href = sprintf('search.php?search=true&form=advanced&server_id=%s&filter=%s=%s',$server_id,$attr,$badattr); + pla_error(sprintf( $lang['unique_attr_failed'],$attr,$badattr,$dn,$search_href ) ); } if( $is_binary_val ) { - if( 0 == $_FILES['val']['size'] ) - pla_error( $lang['file_empty'] ); - if( ! is_uploaded_file( $_FILES['val']['tmp_name'] ) ) { - if( isset( $_FILES['val']['error'] ) ) - switch($_FILES['val']['error']){ - case 0: //no error; possible file attack! - pla_error( $lang['invalid_file'] ); - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - pla_error( $lang['uploaded_file_too_big'] ); - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - pla_error( $lang['uploaded_file_too_big'] ); - case 3: //uploaded file was only partially uploaded - pla_error( $lang['uploaded_file_partial'] ); - case 4: //no file was uploaded - pla_error( $lang['left_attr_blank'] ); - default: //a default error, just in case! :) - pla_error( $lang['invalid_file'] ); - break; - } - else - pla_error( $lang['invalid_file'] ); - } + if( 0 == $_FILES['val']['size'] ) + pla_error( $lang['file_empty'] ); + + if( ! is_uploaded_file( $_FILES['val']['tmp_name'] ) ) { + + if( isset( $_FILES['val']['error'] ) ) + + switch($_FILES['val']['error']) { + case 0: //no error; possible file attack! + pla_error( $lang['invalid_file'] ); + break; + + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + pla_error( $lang['uploaded_file_too_big'] ); + break; + + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive specified in the html form + pla_error( $lang['uploaded_file_too_big'] ); + break; + + case 3: //uploaded file was only partially uploaded + pla_error( $lang['uploaded_file_partial'] ); + break; + + case 4: //no file was uploaded + pla_error( $lang['left_attr_blank'] ); + break; + + default: //a default error, just in case! :) + pla_error( $lang['invalid_file'] ); + break; + } + + else + pla_error( $lang['invalid_file'] ); + } + $file = $_FILES['val']['tmp_name']; - $f = fopen( $file, 'r' ); - $binary_data = fread( $f, filesize( $file ) ); - fclose( $f ); - $val = $binary_data; + $f = fopen( $file, 'r' ); + $binary_data = fread( $f, filesize( $file ) ); + fclose( $f ); + + $val = $binary_data; if( is_binary_option_required( $server_id, $attr ) ) - $attr .=";binary"; + $attr .= ";binary"; } -// Automagically hash new userPassword attributes according to the -// chosen in config.php. -if( 0 == strcasecmp( $attr, 'userpassword' ) ) -{ +// Automagically hash new userPassword attributes according to the +// chosen in config.php. +if( 0 == strcasecmp( $attr, 'userpassword' ) ) { + if( isset( $servers[$server_id]['default_hash'] ) && - $servers[$server_id]['default_hash'] != '' ) - { + $servers[$server_id]['default_hash'] != '' ) { + $enc_type = $servers[$server_id]['default_hash']; $val = password_hash( $val, $enc_type ); } } -elseif( ( 0 == strcasecmp( $attr , 'sambantpassword' ) || 0 == strcasecmp( $attr , 'sambalmpassword') ) ){ - $mkntPassword = new MkntPasswdUtil(); - $mkntPassword->createSambaPasswords( $val ); - $val = $mkntPassword->valueOf($attr); + +elseif( in_array( $attr,array('sambantpassword','sambalmpassword') ) ){ + $mkntPassword = new MkntPasswdUtil(); + $mkntPassword->createSambaPasswords( $val ); + $val = $mkntPassword->valueOf($attr); } -$ds = pla_ldap_connect( $server_id ) or pla_error( $lang['could_not_connect'] ); $new_entry = array( $attr => $val ); -$result = @ldap_mod_add( $ds, $dn, $new_entry ); +$result = @ldap_mod_add( $ldapserver->connect(), $dn, $new_entry ); if( $result ) - header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&modified_attrs[]=$encoded_attr" ); + header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&modified_attrs[]=$encoded_attr" ); + else - pla_error( $lang['failed_to_add_attr'], ldap_error( $ds ) , ldap_errno( $ds ) ); + pla_error( $lang['failed_to_add_attr'],ldap_error($ldapserver->connect()),ldap_errno($ldapserver->connect()) ); -// check if we need to append the ;binary option to the name -// of some binary attribute +/** + * Check if we need to append the ;binary option to the name + * of some binary attribute + * + * @param int $server_id Server ID that the attribute is in. + * @param attr $attr Attribute to test to see if it requires ;binary added to it. + * @return bool + */ -function is_binary_option_required( $server_id, $attr ){ +function is_binary_option_required( $server_id, $attr ) { - // list of the binary attributes which need the ";binary" option - $binary_attributes_with_options = array( - // Superior: Ldapv3 Syntaxes (1.3.6.1.4.1.1466.115.121.1) - '1.3.6.1.4.1.1466.115.121.1.8' => "userCertificate", - '1.3.6.1.4.1.1466.115.121.1.8' => "caCertificate", - '1.3.6.1.4.1.1466.115.121.1.10' => "crossCertificatePair", - '1.3.6.1.4.1.1466.115.121.1.9' => "certificateRevocationList", - '1.3.6.1.4.1.1466.115.121.1.9' => "authorityRevocationList", - // Superior: Netscape Ldap attributes types (2.16.840.1.113730.3.1) - '2.16.840.1.113730.3.1.40' => "userSMIMECertificate" - ); - - // quick check by attr name (short circuits the schema check if possible) - //foreach( $binary_attributes_with_options as $oid => $name ) - //if( 0 == strcasecmp( $attr, $name ) ) + // list of the binary attributes which need the ";binary" option + $binary_attributes_with_options = array( + // Superior: Ldapv3 Syntaxes (1.3.6.1.4.1.1466.115.121.1) + '1.3.6.1.4.1.1466.115.121.1.8' => "userCertificate", + '1.3.6.1.4.1.1466.115.121.1.8' => "caCertificate", + '1.3.6.1.4.1.1466.115.121.1.10' => "crossCertificatePair", + '1.3.6.1.4.1.1466.115.121.1.9' => "certificateRevocationList", + '1.3.6.1.4.1.1466.115.121.1.9' => "authorityRevocationList", + // Superior: Netscape Ldap attributes types (2.16.840.1.113730.3.1) + '2.16.840.1.113730.3.1.40' => "userSMIMECertificate" + ); + + // quick check by attr name (short circuits the schema check if possible) + //foreach( $binary_attributes_with_options as $oid => $name ) + //if( 0 == strcasecmp( $attr, $name ) ) //return true; - $schema_attr = get_schema_attribute( $server_id, $attr ); - if( ! $schema_attr ) - return false; + $schema_attr = get_schema_attribute( $ldapserver, $attr ); + if( ! $schema_attr ) + return false; - $syntax = $schema_attr->getSyntaxOID(); - if( isset( $binary_attributes_with_options[ $syntax ] ) ) - return true; + $syntax = $schema_attr->getSyntaxOID(); + if( isset( $binary_attributes_with_options[ $syntax ] ) ) + return true; - return false; + return false; } - ?> diff --git a/add_attr_form.php b/add_attr_form.php index ed0eef8..fa1737c 100644 --- a/add_attr_form.php +++ b/add_attr_form.php @@ -1,29 +1,32 @@ isReadOnly() ) + pla_error( $lang['no_updates_in_read_only_mode'] ); +if( ! $ldapserver->haveAuthInfo()) + pla_error( $lang['not_enough_login_info'] ); + $dn = $_GET['dn']; $encoded_dn = rawurlencode( $dn ); -$server_id = $_GET['server_id']; $rdn = get_rdn( $dn ); -$server_name = $servers[$server_id]['name']; -if( is_server_read_only( $server_id ) ) - pla_error( $lang['no_updates_in_read_only_mode'] ); - -check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] ); -have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] ); $friendly_attrs = process_friendly_attr_table(); include './header.php'; ?> @@ -31,22 +34,24 @@ include './header.php'; ?>
-"; +//echo "diff --git a/blowfish.php b/blowfish.php index 4848c57..de6dfb6 100644 --- a/blowfish.php +++ b/blowfish.php @@ -1,4 +1,5 @@ - * @version $Revision: 1.1 $ + * @version $Revision: 1.3 $ * @since Horde 2.2 * @package horde.cipher */ +/** + * @package horde.cipher + */ // Change for phpMyAdmin by lem9: //class Horde_Cipher_blowfish extends Horde_Cipher { @@ -386,7 +390,7 @@ class Horde_Cipher_blowfish { $parts = $this->_encryptBlock($L, $R); return pack("NN", $parts['L'], $parts['R']); } - + /** * Encrypt a block on data. * diff --git a/check_lang_files.php b/check_lang_files.php index 9422a40..bc97df0 100644 --- a/check_lang_files.php +++ b/check_lang_files.php @@ -1,10 +1,15 @@ -"; //print_r( $new_entry ); //exit; -$ds = pla_ldap_connect( $server_id ); -pla_ldap_connection_is_error( $ds ); -$add_res = @ldap_mod_add( $ds, $dn, $new_entry ); +$add_res = @ldap_mod_add( $ldapserver->connect(), $dn, $new_entry ); -if( ! $add_res ) -{ - pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) ); -} -else -{ +if( ! $add_res ) { + pla_error( $lang['could_not_perform_ldap_mod_add'],ldap_error($ldapserver->connect()),ldap_errno($ldapserver->connect()) ); + +} else { header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&modified_attrs[]=objectclass" ); } - ?> diff --git a/add_oclass_form.php b/add_oclass_form.php index cbe624f..766aa33 100644 --- a/add_oclass_form.php +++ b/add_oclass_form.php @@ -1,9 +1,7 @@ isReadOnly() ) pla_error( $lang['no_updates_in_read_only_mode'] ); +if( ! $ldapserver->haveAuthInfo()) + pla_error( $lang['not_enough_login_info'] ); -check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] ); -have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] ); +$new_oclass = $_REQUEST['new_oclass']; +$dn = rawurldecode( $_REQUEST['dn'] ); +$encoded_dn = rawurlencode( $dn ); /* Ensure that the object has defined all MUST attrs for this objectClass. * If it hasn't, present a form to have the user enter values for all the * newly required attrs. */ -$entry = get_object_attrs( $server_id, $dn, true ); +$entry = get_object_attrs( $ldapserver, $dn, true ); + $current_attrs = array(); foreach( $entry as $attr => $junk ) $current_attrs[] = strtolower($attr); // grab the required attributes for the new objectClass -$oclass = get_schema_objectclass( $server_id, $new_oclass ); +$oclass = get_schema_objectclass( $ldapserver, $new_oclass ); if( $oclass ) $must_attrs = $oclass->getMustAttrs(); + else $must_attrs = array(); @@ -54,52 +58,57 @@ else // but that the object does not currently contain $needed_attrs = array(); foreach( $must_attrs as $attr ) { - $attr = get_schema_attribute( $server_id, $attr->getName() ); - //echo ""; var_dump( $attr ); echo ""; - // First, check if one of this attr's aliases is already an attribute of this entry - foreach( $attr->getAliases() as $alias_attr_name ) - if( in_array( strtolower( $alias_attr_name ), $current_attrs ) ) - // Skip this attribute since it's already in the entry - continue; - if( in_array( strtolower($attr->getName()), $current_attrs ) ) - continue; + $attr = get_schema_attribute( $ldapserver, $attr->getName() ); - // We made it this far, so the attribute needs to be added to this entry in order - // to add this objectClass - $needed_attrs[] = $attr; + //echo ""; var_dump( $attr ); echo ""; + + // First, check if one of this attr's aliases is already an attribute of this entry + foreach( $attr->getAliases() as $alias_attr_name ) + if( in_array( strtolower( $alias_attr_name ), $current_attrs ) ) + + // Skip this attribute since it's already in the entry + continue; + + if( in_array( strtolower($attr->getName()), $current_attrs ) ) + continue; + + // We made it this far, so the attribute needs to be added to this entry in order + // to add this objectClass + $needed_attrs[] = $attr; } -if( count( $needed_attrs ) > 0 ) -{ +if( count( $needed_attrs ) > 0 ) { include './header.php'; ?> - + - + - +
- +
+ + | |||
+ : name; ?> :+ |
+
+ : name; ?> :+ |
+ ||
+ + | +(" . $lang['no_attributes'] . ") | \n"; + echo "