haveAuthInfo()) pla_error( $lang['not_enough_login_info'] ); dn_exists( $ldapserver, $dn ) or pla_error( sprintf( $lang['no_such_entry'], pretty_print_dn( $dn ) ) ); $rdn = get_rdn($dn); $attrs = get_object_attrs( $ldapserver, $dn, false, $config->GetValue('deref','view')); $modified_attrs = isset( $_REQUEST['modified_attrs'] ) ? $_REQUEST['modified_attrs'] : false; $show_internal_attrs = isset( $_REQUEST['show_internal_attrs'] ) ? true : false; # If an entry has more children than this, stop searching and display this amount with a '+' $max_children = 100; } else { $dn = ''; $rdn = ''; $encoded_dn = ''; isset($_REQUEST['template']) or die(); // pla_error( $lang['must_choose_template'] ); if ($_REQUEST['template'] == 'custom') { include TMPLDIR.'template_header.php'; require TMPLDIR.'creation/custom.php'; die(); } else { $templates = new Templates($ldapserver->server_id); $template = $templates->GetTemplate($_REQUEST['template']); } } include TMPLDIR.'template_header.php'; /* * When we get here, (either a new entry, or modifying an existing entry), if the * empty_attrs array has content, then we need to ask the user for this information. */ if (isset($template['empty_attrs'])) { masort($template['empty_attrs'],'page,order',1); # What page are we working on. $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; ?>

$value) { # Check for any with post actions. if (isset($template['attribute'][$attr]['post']) && $_REQUEST['page'] == $template['attribute'][$attr]['page']+1) { if (preg_match('/^=php\.(\w+)\((.*)\)$/',$template['attribute'][$attr]['post'],$matches)) { switch ($matches[1]) { case 'Password' : preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall); $value = password_hash( $_REQUEST['form'][$matchall[1][1]], $_REQUEST[$matchall[1][0]] ); $_REQUEST['form'][$attr] = $value; break; case 'SambaPassword' : $matchall = explode(',',$matches[2]); $attr = preg_replace('/%/','',$matchall[1]); $sambapassword = new smbHash; switch ($matchall[0]) { case 'LM' : $value = $sambapassword->lmhash($_REQUEST['form'][$attr]); break; case 'NT' : $value = $sambapassword->nthash($_REQUEST['form'][$attr]); break; default : $value = null; } $_REQUEST['form'][$attr] = $value; break; case 'Join' : preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall); $matchattrs = explode(',',$matches[2]); $char = $matchattrs[0]; $values = array(); foreach ($matchall[1] as $joinattr) { if (isset($_REQUEST['form'][$joinattr])) $values[] = $_REQUEST['form'][$joinattr]; else if (isset($_REQUEST[$joinattr])) $values[] = $_REQUEST[$joinattr]; else pla_error($lang['template_post_join']); } $value = implode($char,$values); $_REQUEST['form'][$attr] = $value; break; default: #@todo: Error, unknown post funciton. } } } if (is_array($value)) foreach ($value as $item) printf('',$attr,$item); else printf('',$attr,$value); } ?> $detail) { $mustitem = false; $verifyitem = false; $onChange = ''; $onBlur = ''; $type = isset($detail['type']) ? $detail['type'] : 'text'; if (! isset($detail['page'])) $detail['page'] = 1; $size = isset($detail['size']) ? $detail['size'] : 20; $maxlength = isset($detail['maxlength']) ? $detail['maxlength'] : null; # Check that the page number is correct. if ($detail['page'] < $page && ! isset($attr[$attr])) { # ERROR: This attribute should be set by now. print "We should have set [$attr] by now.
"; } elseif ($detail['page'] == $page) { $count++; print ''; # Some conditional checking. # $detail['must'] & $detail['disable'] cannot be set at the same time. if (isset($detail['must']) && $detail['must'] && isset($detail['disable']) && $detail['disable']) { pla_error(printf($lang['template_mustattr'],$attr)); } # If this attribute is disabled, go to the next one. if (isset($detail['disable']) && $detail['disable']) continue; # Evaluate our Default Value, if its a function call result. if (isset($detail['value'])) { if (is_array($detail['value'])) { # If value is an array, then it must a select list. $type = 'select'; $defaultresult = sprintf(''; $detail['value'] = $defaultresult; } else { $detail['value'] = $templates->EvaluateDefault($ldapserver,$detail['value'],$_REQUEST['container'],null,(isset($detail['default']) ? $detail['default'] : null)); } #if the default has a select list, then change the type to select if (preg_match('/','hidden',$attr,$attr,$detail['value']); continue; } # This is a displayed attribute. # Flag it as a must attribute so that we do get a value. if (isset($detail['must']) && $detail['must'] && ! isset($detail['presubmit'])) { $mustitems++; $mustitem = true; $onBlur .= sprintf("reduceMust(this.form,%s,'%s');",$attr,$attr); } # Display the icon if one is required. if (isset($detail['icon']) && trim($detail['icon'])) printf('',$detail['icon']); else printf(''); print ''; # Calculate the events. # @todo: Need to change js so that if a must attr is auto populated, it decrements the total and enables the submit. if (isset($detail['onchange'])) { if (is_array($detail['onchange'])) { foreach ($detail['onchange'] as $value) { $onChange .= sprintf('%s;',$templates->OnChangeAdd($value)); } } else { $onChange .= sprintf('%s;',$templates->OnChangeAdd($detail['onchange'])); } } # Display the input box. print '',$detail['hint']); else print ''; print ''; # Do we have a verify attribute? if (isset($detail['verify']) && ($detail['verify'])) { $verifyitems = true; print ''; } # Is this a multiarray input? if (isset($detail['array']) && ($detail['array'])) { for ($i=2; $i <= $detail['array']; $i++) { print ''; printf(''; } } # Do we have a helper. # Side helpers are handled above. # @todo: Helpers must have an onchange or onsubmit. # @todo: Helpers must have an id field. # @todo: Helpers must have an post field. if (isset($detail['helper']) && (! isset($detail['helper']['location']) || $detail['helper']['location'] != 'side')) { print ''; print ''; printf('',$templates->HelperValue($detail['helper']['value'],$detail['helper']['id'])); } if (isset($detail['spacer']) && $detail['spacer']) print ''; # See if there are any future ones - if there are and we dont ask any this round, then thats an error. } elseif ($detail['page'] > $page) { $nextpage++; } } # @todo: Proper error message required. if ($nextpage && ! $count) pla_error(sprintf($lang['template_nextpage'],$nextpage)); # If there is no count, display the summary if (! $count) { printf('', $template['icon'],$lang['createf_create_object'],htmlspecialchars($new_dn)); print ''; $counter = 0; foreach ($_REQUEST['form'] as $attr => $value) { # Remove blank attributes. if (! $_REQUEST['form'][$attr]) { unset($_REQUEST['form'][$attr]); continue; } $attrs[] = $attr; printf('',$attr); if (is_array($value)) foreach ($value as $item) { if ($item && ! isset($unique[$item])) { $unique[$item] = 1; printf('', ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars($item)); printf('',array_search($attr,$attrs),$item); } } else { $display = $value; if (isset($template['attribute'][$attr]['type']) && $template['attribute'][$attr]['type'] == 'password') if (obfuscate_password_display($_REQUEST['enc'])) $display = '********'; printf('', ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars($display)); printf('',$value); } } } ?> $detail) { if (isset($template['attribute'][$attr]['presubmit']) && ! isset($_REQUEST['form'][$attr])) { printf('', ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars($lang['t_auto_submit'])); printf('',$attr); } } ?>
Container DN:
Container DN:
'; # Display the label. if (isset($detail['description']) && (trim($detail['description']))) printf('%s:',$detail['description'],$detail['display']); else printf('%s:',$detail['display']); print ''; if (in_array($type,array('text','password'))) { printf('', $type,$size,$attr,(isset($detail['array']) && ($detail['array'] > 1) ? '[]' : ''),$attr, (isset($detail['value']) ? $detail['value'] : ''), ($onChange ? sprintf('onChange="%s"',$onChange) : '').($onBlur ? sprintf(' onBlur="%s"',$onBlur) : ''), (isset($detail['disable']) ? 'disabled' : ''), (isset($detail['maxlength']) ? sprintf(' maxlength="%s" ',$maxlength) : '')); } else if ($type == 'select') { printf($detail['value'],$attr, ($onChange ? sprintf('onChange="%s"',$onChange) : '').($onBlur ? sprintf(' onBlur="%s"',$onBlur) : ''), (isset($detail['disable']) ? 'disabled' : '')); } # Disabled items dont get submitted. # @todo need to add some js to enable them on submit, or add them as hidden items. if ($mustitem) { print ' *'; } # Do we have a helper, and is it configured for the side. if (isset($detail['helper']) && isset($detail['helper']['location']) && $detail['helper']['location'] == 'side' && isset($detail['helper']['value'])) { printf(' %s',$templates->HelperValue($detail['helper']['value'], (isset($detail['helper']['id']) ? $detail['helper']['id'] : ''), $_REQUEST['container'],$ldapserver,null, isset($detail['helper']['default']) ? $detail['helper']['default'] : '')); } if (isset($detail['hint']) && (trim($detail['hint']))) printf(' (hint: %s)
 '; # Display the label. if (isset($detail['description']) && (trim($detail['description']))) printf('%s %s:',$lang['t_verify'],$detail['description'],$detail['display']); else printf('%s %s:',$lang['t_verify'],$detail['display']); print ''; if (in_array($type,array('text','password'))) { printf('', $type,$attr."V",$attr."V",(isset($detail['value']) ? $detail['value'] : ''), sprintf('onBlur="check(form.%s,form.%sV)"',$attr,$attr)); } print '
  ', $type,$attr,$attr.$i, (isset($detail['value']) ? $detail['value'] : ''), ($onChange ? sprintf('onChange="%s"',$onChange) : '').($onBlur ? sprintf(' onBlur="%s"',$onBlur) : ''), isset($detail['disable']) ? 'disabled' : ''); if (isset($detail['helper']) && isset($detail['helper']['location']) && $detail['helper']['location'] == 'side' && isset($detail['helper']['value'])) { printf(' %s',$templates->HelperValue($detail['helper']['value'], (isset($detail['helper']['id']) ? $detail['helper']['id'] : ''),$_REQUEST['container'],$ldapserver,$i)); } print '
 '; # Display the label. if (isset($detail['helper']['description']) && (trim($detail['helper']['description']))) printf('%s:',$detail['helper']['description'],$detail['helper']['display']); else printf('%s:',$detail['helper']['display']); print '%s
%s :%s
%s%s
%s%s
%s%s

/>

/>

/>
This is the template engine.
. '; print ' var reduced = new Array();'; print 'function reduceMust(form,attr,attrname){'; print ' if (attr.value.length > 0) {'; print ' if (! reduced[attrname]) {'; print ' reduced[attrname] = 1;'; print ' form.mustitems.value--;'; print ' }'; print ''; print ' if (form.mustitems.value < 0) {'; print ' form.mustitems.value = 0;'; print ' }'; print ''; print ' if (form.mustitems.value == 0) {'; print ' form.submit.disabled = false;'; print ' }'; print ' } else {'; print ' if (reduced[attrname]) {'; print ' reduced[attrname] = 0;'; print ' form.mustitems.value++;'; print ' }'; print ' if (form.mustitems.value > 0) {'; print ' form.submit.disabled = true;'; print ' }'; print ' }'; print '}'; print ''; } if (isset($verifyitems) && $verifyitems) { //@todo: Return focus to the first item. print ''; } if ($templates->OnChangeDisplay()) { print ''; } # User needs to submit form to continue. die(); } if (! isset($template)) $template['attrs'] = $attrs; # If we get here - we are displaying/editing the entry. # Sort these entries. uksort( $template['attrs'], 'sortAttrs' ); $js_date_attrs = $config->GetValue('appearance','date_attrs'); printf('',$config->GetValue('appearance','date')); foreach( $template['attrs'] as $attr => $vals ) { flush(); $schema_attr = $ldapserver->getSchemaAttribute($attr,$dn); if( $schema_attr ) $attr_syntax = $schema_attr->getSyntaxOID(); else $attr_syntax = null; if( ! strcasecmp( $attr, 'dn' ) ) continue; // has the config.php specified that this attribute is to be hidden or shown? if( is_attr_hidden( $ldapserver, $attr)) continue; // Setup the $attr_note, which will be displayed to the right of the attr name (if any) $attr_note = ''; // is there a user-friendly translation available for this attribute? if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) { $attr_display = $friendly_attrs[ strtolower( $attr ) ]; $attr_note = "alias"; } else { $attr_display = $attr; } // is this attribute required by an objectClass? $required_by = ''; if( $schema_attr ) foreach( $schema_attr->getRequiredByObjectClasses() as $required ) if( isset($attrs['objectClass']) && in_array( strtolower( $required ), arrayLower( $attrs['objectClass'] ) ) ) $required_by .= $required . ' '; // It seems that some LDAP servers (Domino) returns attributes in lower case? elseif( isset($attrs['objectclass']) && in_array( strtolower( $required ), arrayLower( $attrs['objectclass'] ) ) ) $required_by .= $required . ' '; if( $required_by ) { if( trim( $attr_note ) ) $attr_note .= ', '; $attr_note .= "" . $lang['required'] . " "; } // is this attribute required because its the RDN if (preg_match("/^${attr}=/",$rdn)) { if( trim( $attr_note ) ) $attr_note .= ', '; $attr_note .= " " . 'rdn' . " "; } if( is_array( $modified_attrs ) && in_array( strtolower($attr), $modified_attrs ) ) $is_modified_attr = true; else $is_modified_attr = false; if( $is_modified_attr ) { ?> server_id,real_attr_name($attr)); ?> () isReadOnly() || is_attr_read_only( $ldapserver, $attr ) ) draw_jpeg_photos( $ldapserver, $dn, $attr, false ); else draw_jpeg_photos( $ldapserver, $dn, $attr, true ); // proceed to the next attribute echo "\n"; if( $is_modified_attr ) echo ''; continue; } /* * Is this attribute binary? */ if( is_attr_binary( $ldapserver, $attr ) ) { $href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,$attr); ?>
1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?> "> ()

isReadOnly() && ! is_attr_read_only( $ldapserver, $attr ) ) { ?>
'; continue; } /* * Note: at this point, the attribute must be text-based (not binary or jpeg) */ // If this is the userPassword attribute, add the javascript so we can call check password later. if (! strcasecmp( $attr, 'userPassword' ) ) { $user_password = $vals[0]; ?> isReadOnly() || is_attr_read_only( $ldapserver, $attr ) || (preg_match("/^${attr}=/",$rdn)) ) { if( is_array( $vals ) ) { foreach( $vals as $i => $val ) { if( trim( $val ) == "" ) echo "[" . $lang['empty'] . "]
\n"; elseif( ! strcasecmp( $attr, 'userPassword' ) && $config->GetValue('appearance','obfuscate_password_display')) echo preg_replace( '/./', '*', $val ) . "
"; elseif( in_array(strtolower($attr), $shadow_format_attrs) ) { $shadow_date = shadow_date( $attrs, $attr); echo htmlspecialchars($val)." "; echo ""; if( ($today < $shadow_date) && in_array(strtolower($attr), $shadow_before_today_attrs) ) echo ''.htmlspecialchars("(".strftime($config->GetValue('appearance','date'),$shadow_date).")").''; elseif( $today > $shadow_date && in_array(strtolower($attr), $shadow_after_today_attrs) ) echo ''.htmlspecialchars("(".strftime($config->GetValue('appearance','date'),$shadow_date).")").''; else echo htmlspecialchars("(".strftime($config->GetValue('appearance','date'),shadow_date( $attrs, $attr)).")"); echo ""; } else echo htmlspecialchars( $val ) . "
"; } } else { if( ! strcasecmp( $attr, 'userPassword' ) && obfuscate_password_display()) echo preg_replace( '/./', '*', $vals ) . "
"; else echo $vals . "
"; } if (! strcasecmp( $attr, 'userPassword' ) ) {?> () '; continue; } /* * Is this a userPassword attribute? */ if( 0 == strcasecmp( $attr, 'userpassword' ) ) { $user_password = $vals[0]; $enc_type = get_enc_type( $user_password ); // Set the default hashing type if the password is blank (must be newly created) if( $user_password == '' ) $enc_type = get_default_hash( $ldapserver->server_id ); ?>
" name="new_values[userpassword]" value="" />
'; continue; } /* * Is this a boolean attribute? */ if( is_attr_boolean( $ldapserver, $attr) ) { $val = $vals[0]; ?> '; continue; } /* * Is this a date type attribute? */ if (in_array_ignore_case($attr, array_keys($js_date_attrs))) { $val = $vals[0]; ?> '; continue; } /* * End of special case attributes (non plain text). */ /* * This is a plain text attribute, to be displayed and edited in plain text. */ foreach( $vals as $i => $val ) { $input_name = "new_values[" . htmlspecialchars( $attr ) . "][$i]"; // We smack an id="..." tag in here that doesn't have [][] in it to allow the // draw_chooser_link() to identify it after the user clicks. $input_id = "new_values_" . htmlspecialchars($attr) . "_" . $i; ?> getSchemaObjectClass($val); if ($schema_object->getType() == 'structural') { echo "$val (" . $lang['structural'] . ")
"; ?> server_id)) { ?> '; // If this is a gidNumber on a non-PosixGroup entry, lookup its name and description for convenience if( ! strcasecmp( $attr, 'gidNumber' ) && ! in_array_ignore_case( 'posixGroup', get_object_attr( $ldapserver, $dn, 'objectClass' ) ) ) { $gid_number = $val; $search_group_filter = "(&(objectClass=posixGroup)(gidNumber=$val))"; $group = pla_ldap_search( $ldapserver, $search_group_filter, null, array( 'dn', 'description' ) ); if( count( $group ) > 0 ) { echo "
"; $group = array_pop( $group ); $group_dn = $group['dn']; $group_name = explode( '=', get_rdn( $group_dn ) ); $group_name = $group_name[1]; $href = sprintf('edit.php?server_id=%s&dn=%s',$ldapserver->server_id,urlencode($group_dn)); echo ""; echo "" . htmlspecialchars($group_name) . ""; $description = isset( $group['description'] ) ? $group['description'] : null; if( $description ) echo " (" . htmlspecialchars( $description ) . ")"; echo ""; } } // Show the dates for all the shadow attributes. if( in_array(strtolower($attr), $shadow_format_attrs) ) { if( ( $shadow_date = shadow_date( $attrs, $attr) ) !== false ) { echo "
"; echo ""; if( ($today < $shadow_date) && in_array(strtolower($attr), $shadow_before_today_attrs) ) echo ''.htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)).''; elseif( $today > $shadow_date && in_array(strtolower($attr), $shadow_after_today_attrs) ) echo ''.htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)).''; else echo htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)); echo ""; } } } /* end foreach value */ /* Draw the "add value" link under the list of values for this attributes */ if( ! $ldapserver->isReadOnly() && ( $schema_attr = $ldapserver->getSchemaAttribute($attr,$dn)) && ! $schema_attr->getIsSingleValue() ) { $add_href = sprintf('add_value_form.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,rawurlencode($attr)); printf('
(%s)
', $add_href,sprintf( $lang['add_value_tooltip'], $attr ),$lang['add_value']); } ?> $vals ) */ if (! $ldapserver->isReadOnly()) { ?>
\n"; ?>