diff --git a/VERSION b/VERSION index 9a74a7c..63161b2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -$Name: RELEASE-0_9_8 $ +$Name: RELEASE-0_9_8_1 $ diff --git a/htdocs/create.php b/htdocs/create.php index 7d1f015..10d3efa 100644 --- a/htdocs/create.php +++ b/htdocs/create.php @@ -1,5 +1,5 @@ ',$new_dn); } else { - echo '
'; + echo ''; } - if (isset($_REQUEST['form'])) + if (isset($_REQUEST['form'])) { foreach ($_REQUEST['form'] as $attr => $value) { # Check for any with post actions. @@ -167,6 +167,26 @@ if (isset($template['empty_attrs'])) { printf('',$attr,$value); } + # Have we got a Binary Attribute? + if (isset($_FILES['form']['name']) && is_array($_FILES['form']['name'])) { + foreach ($_FILES['form']['name'] as $attr => $details) { + if (is_uploaded_file($_FILES['form']['tmp_name'][$attr])) { + $file = $_FILES['form']['tmp_name'][$attr]; + $f = fopen($file,'r'); + $binary_data = fread($f,filesize($file)); + fclose($f); + + // @todo: This may need to be implemented. + //if (is_binary_option_required($ldapserver,$attr)) + // $attr .= ';binary'; + + $_SESSION['submitform'][$attr] = $binary_data; + printf('',$attr); + } + } + } + } + printf('',$ldapserver->server_id); printf('',$_REQUEST['template']); printf('',rawurlencode(serialize(array_values($template['objectclass'])))); @@ -195,14 +215,14 @@ if (isset($template['empty_attrs'])) { } else { echo ' '; echo 'Container DN:'; - printf('', + printf('', htmlspecialchars($_REQUEST['container'])); - printf('',$_REQUEST['container']); + printf('',$_REQUEST['container']); echo ''; } } else { - printf('',$_REQUEST['container']); + printf('',$_REQUEST['container']); } $count = 0; @@ -323,7 +343,19 @@ if (isset($template['empty_attrs'])) { # Display the input box. echo ''; - if (in_array($type,array('text','password'))) { + # Is this a binary attribute + if ($ldapserver->isAttrBinary($attr)) { + printf('',$attr); + + if (! ini_get('file_uploads')) + printf('
%s
', + _('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.')); + + else + printf('
%s: %s
', + _('Maximum file size'),ini_get('upload_max_filesize')); + + } elseif (in_array($type,array('text','password'))) { printf('', $type,$size,$attr,(isset($detail['array']) && ($detail['array'] > 1) ? '[]' : ''),$attr, (isset($detail['value']) ? $detail['value'] : ''), @@ -464,14 +496,16 @@ if (isset($template['empty_attrs'])) { } $attrs[] = $attr; + printf('',($counter++%2==0?'even':'odd')); printf('',$attr); + if (is_array($value)) foreach ($value as $item) { if ($item && ! isset($unique[$item])) { $unique[$item] = 1; - printf('%s%s', - ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars($item)); - printf('',array_search($attr,$attrs),$item); + printf('', + array_search($attr,$attrs),$item); + printf('%s%s',$attr,htmlspecialchars($item)); } } @@ -481,13 +515,19 @@ if (isset($template['empty_attrs'])) { if (obfuscate_password_display($_REQUEST['enc'])) $display = '********'; - printf('%s%s', - ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars($display)); printf('',$value); + printf('%s%s',$attr,htmlspecialchars($display)); } } + echo ''; + foreach (array_keys($_SESSION['submitform']) as $attr) { + + printf('%s%s', + ($counter++%2==0?'even':'odd'),$attr,_('Binary value not displayed')); + printf('',$attr); + } } echo ''; @@ -577,7 +617,7 @@ if (isset($template['empty_attrs'])) { $jstext .= "\t\t\telse if (id == '$attr') {\n"; if (isset($detail['must'])) $jstext .= "\t\t\t\treduceMust('$attr');\n"; - $hash =& $templates->getJsHash(); + $hash = $templates->getJsHash(); if (isset($hash['autoFill'.$attr])) { $jstext .= $hash['autoFill'.$attr]; } diff --git a/lib/functions.php b/lib/functions.php index 77cc5dc..92a4a61 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,5 +1,5 @@ 300) { $scale_factor = 300 / $width; $img_width = 300; - $img_height = $height * $scale_factor; + $img_height = intval($height * $scale_factor); } else { $img_width = $width; diff --git a/lib/hooks.php b/lib/hooks.php index b48f9b5..30520e1 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -1,5 +1,5 @@ read() ) ) { if ( is_file ("hooks/$entry") and eregi ('php[0-9]?$', $entry) ) { diff --git a/lib/server_functions.php b/lib/server_functions.php index 1ff6ed8..40e7dc2 100644 --- a/lib/server_functions.php +++ b/lib/server_functions.php @@ -1,5 +1,5 @@ connect()) { $r = array_pop($this->search(null,'','objectClass=*',array('namingContexts'),'base')); - $r = array_change_key_case($r); + if (is_array($r)) + $r = array_change_key_case($r); if (isset($r['namingcontexts'])) { if (! is_array($r['namingcontexts'])) @@ -414,12 +415,12 @@ class LDAPserver { global $config; if ($this->connect(false) && $this->haveAuthInfo() && ! $this->isReadOnly() && - ! $config->GetValue('appearance','tree_plm')) { + ! $config->GetValue('appearance','tree_plm') && + $config->GetValue('appearance','mass_delete') === true) - $config->GetValue('appearance','mass_delete') === true; return true; - } else + else return false; } @@ -1135,7 +1136,7 @@ class LDAPserver { with its name set to the alias name, and all other data copied.*/ foreach ($aliases as $alias_attr_name) { # clone is a PHP5 function and must be used. - if (function_exists('clone')) + if (version_compare(PHP_VERSION,'5.0') > 0 ) $new_attr = clone($attr); else $new_attr = $attr; @@ -1435,8 +1436,12 @@ class LDAPserver { # Delete entry from parent's children as well. $parent = get_container($dn); - $index = array_search($dn,$tree['browser'][$parent]['children']); - unset($tree['browser'][$parent]['children'][$index]); + + # If the parent hasnt been opened in the tree, then there wont be any children. + if (isset($tree['browser'][$parent]['children'])) { + $index = array_search($dn,$tree['browser'][$parent]['children']); + unset($tree['browser'][$parent]['children'][$index]); + } # Might be worthwhile adding it to our miss list, while we are here. $tree['misses'][$dn] = true; @@ -2433,11 +2438,14 @@ class LDAPserver { get_class($this),$dn,$lower_case_attr_names,$deref); $attrs = array_pop($this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref)); - if ($lower_case_attr_names) - $attrs = array_change_key_case($attrs); - if (is_array($attrs)) + if (is_array($attrs)) { + if ($lower_case_attr_names) + $attrs = array_change_key_case($attrs); + ksort($attrs); + } + return $attrs; } diff --git a/lib/template_functions.php b/lib/template_functions.php index ef6d1c7..9e1f6e5 100644 --- a/lib/template_functions.php +++ b/lib/template_functions.php @@ -1,5 +1,5 @@ ";print_r($matchall); //0 = highlevel match, 1 = attr, 2 = subst, 3 = mod if (! isset($_js_hash['autoFill'.$origin])) @@ -476,44 +496,50 @@ class Templates { $_js_hash['autoFill'.$origin] .= sprintf(" var %s;\n",$match_attr); - if (trim($match_subst)) { - preg_match_all('/([0-9]*)-([0-9]*)/',$match_subst,$substrarray); - } - - if ($match_mod == '/T') { + if (strstr($match_mod,'T')) { $_js_hash['autoFill'.$origin] .= sprintf( " %s = document.getElementById('%s').options[document.getElementById('%s').selectedIndex].text;\n", $match_attr,$match_attr,$match_attr); - } else { + $_js_hash['autoFill'.$origin] .= sprintf(" %s = document.getElementById('%s').value;\n", + $match_attr,$match_attr); + } + + if (strstr($match_mod,'k')) { + preg_match_all('/([0-9]+)/',trim($match_subst),$substrarray); + if (isset($substrarray[1][0])) { + $tok_idx = $substrarray[1][0]; + } else { + $tok_idx = '0'; + } + $_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.split(':')[%s];\n",$match_attr,$match_attr,$tok_idx); + } else { + preg_match_all('/([0-9]*)-([0-9]*)/',trim($match_subst),$substrarray); if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) { - $_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById("%s").value.substr(%s,%s)', + $_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.substr(%s,%s);\n", $match_attr,$match_attr, $substrarray[1][0] ? $substrarray[1][0] : '0', - $substrarray[2][0] ? $substrarray[2][0] : sprintf('document.getElementById("%s").value.length',$match_attr)); - } else { - $_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById(\'%s\').value', - $match_attr,$match_attr); + $substrarray[2][0] ? $substrarray[2][0] : sprintf('%s.length',$match_attr)); } + } - switch ($match_mod) { - case '/l': - $_js_hash['autoFill'.$origin] .= '.toLowerCase()'; - break; - } - $_js_hash['autoFill'.$origin] .= ";\n"; + if (strstr($match_mod,'l')) { + $_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.toLowerCase();\n",$match_attr,$match_attr); + } + if (strstr($match_mod,'U')) { + $_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.toUpperCase();\n",$match_attr,$match_attr); } # Matchfor only entry without modifiers. $formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',$formula); # Matchfor only entry with modifiers. - $formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','$1 + \'\'',$formula); + $formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','$1 + \'\'',$formula); # Matchfor begining entry. - $formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','$1 + \'',$formula); + $formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%/U','$1 + \'',$formula); # Matchfor ending entry. - $formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','\' + $1 ',$formula); + $formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','\' + $1 ',$formula); # Match for entries not at begin/end. - $formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','\' + $1 + \'',$formula); + $formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[:lTU]+)?%/U','\' + $1 + \'',$formula); } $_js_hash['autoFill'.$origin] .= sprintf(" fillRec('%s', %s);\n",$attr,$formula); @@ -562,6 +588,7 @@ class Templates { $picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs); $detail['value'] = sprintf('