added support for profile, config and help in modules
This commit is contained in:
		
							parent
							
								
									bcb60e5dea
								
							
						
					
					
						commit
						2dcbda5ecb
					
				|  | @ -412,7 +412,9 @@ class accountContainer { | |||
| 		echo "<form action=\"".$this->type."edit.php\" method=\"post\">\n"; | ||||
| 		// Display errir-messages
 | ||||
| 		if (is_array($result)) | ||||
| 			for ($i=0; $i<sizeof($result); $i++) StatusMessage($result[$i][0], $result[$i][1], $result[$i][2]); | ||||
| 			foreach ($result as $result2) | ||||
| 				if (is_array($result2)) | ||||
| 					for ($i=0; $i<sizeof($result2); $i++) StatusMessage($result2[$i][0], $result2[$i][1], $result2[$i][2]); | ||||
| 		// Create left module-menu
 | ||||
| 		echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >"; | ||||
| 		echo "<table><tr>"; | ||||
|  | @ -443,9 +445,7 @@ class accountContainer { | |||
| 		// display html-code from mdule
 | ||||
| 		$function = '$result = $this->module[$this->order[$this->module[\'main\']->current_page]]->display_html_'.$this->module['main']->subpage.'($post);'; | ||||
| 		eval ($function); | ||||
| 		echo "<table>\n"; | ||||
| 		$this->parse_html($this->order[$this->module['main']->current_page], $result); | ||||
| 		echo "</table>\n"; | ||||
| 		// Display rest of html-page
 | ||||
| 		echo "</fieldset>\n"; | ||||
| 		echo "</td></tr></table>\n"; | ||||
|  | @ -457,6 +457,7 @@ class accountContainer { | |||
| 
 | ||||
| 	function parse_html($module, $input) { | ||||
| 		if (is_array($input)) { | ||||
| 			echo "<table>\n"; | ||||
| 			for ($i=0; $i<count($input); $i++) { | ||||
| 				// Draw column
 | ||||
| 				echo "<tr>\n"; | ||||
|  | @ -479,8 +480,8 @@ class accountContainer { | |||
| 								if ($input[$i][$j]['size']!='') $output .= ' size="' . $input[$i][$j]['size'] . '"'; | ||||
| 								if ($input[$i][$j]['maxlength']!='') $output .= ' maxlength="' . $input[$i][$j]['maxlength'] . '"'; | ||||
| 								if ($input[$i][$j]['value']!='') $output .= ' value="' . $input[$i][$j]['value'] . '"'; | ||||
| 								if (isset($input[$i][$j]['disabled'])) $output .= ' disabled'; | ||||
| 								if (isset($input[$i][$j]['checked'])) $output .= ' checked'; | ||||
| 								if ($input[$i][$j]['disabled']) $output .= ' disabled'; | ||||
| 								if ($input[$i][$j]['checked']) $output .= ' checked'; | ||||
| 								$output .= "></td>\n"; | ||||
| 								echo $output; | ||||
| 								break; | ||||
|  | @ -490,12 +491,12 @@ class accountContainer { | |||
| 								echo ">\n"; | ||||
| 								echo "<fieldset>\n"; | ||||
| 								if ($input[$i][$j]['legend']!='') echo "<legend>" . $input[$i][$j]['legend'] . "</legend>\n"; | ||||
| 								echo "<table>\n"; | ||||
| 								$this->parse_html($module, $input[$i][$j]['value']); | ||||
| 								echo "</table>\n"; | ||||
| 								echo "</fieldset>\n"; | ||||
| 								break; | ||||
| 							case 'select': | ||||
| 								if (!is_array($input[$i][$j]['options'])) $input[$i][$j]['options'] = array ( $input[$i][$j]['options'] ); | ||||
| 								if (!is_array($input[$i][$j]['options_selected'])) $input[$i][$j]['options_selected'] = array ( $input[$i][$j]['options_selected'] ); | ||||
| 								echo "<td"; | ||||
| 								if ($input[$i][$j]['td']['valign']!='') echo ' valign="' . $input[$i][$j]['td']['valign'] .'"'; | ||||
| 								echo ">\n"; | ||||
|  | @ -506,10 +507,12 @@ class accountContainer { | |||
| 								// merge both option arrays and sort them.
 | ||||
| 								$options = array_merge ($input[$i][$j]['options'], $input[$i][$j]['options_selected'] ); | ||||
| 								$options = array_unique($options); | ||||
| 								sort($options, SORT_STRING); | ||||
| 								sort($options, SORT_NUMERIC); | ||||
| 								foreach ($options as $option) { | ||||
| 									if (in_array($option, $input[$i][$j]['options_selected'])) echo "<option selected>" . $option . "</option>\n"; | ||||
| 										else echo "<option>" . $option . "</option>\n"; | ||||
| 									if ($option!='') { | ||||
| 										if (in_array($option, $input[$i][$j]['options_selected'])) echo "<option selected>" . $option . "</option>\n"; | ||||
| 											else echo "<option>" . $option . "</option>\n"; | ||||
| 										} | ||||
| 									} | ||||
| 								echo "</select></td>\n"; | ||||
| 								break; | ||||
|  | @ -517,16 +520,14 @@ class accountContainer { | |||
| 								echo "<td"; | ||||
| 								if ($input[$i][$j]['td']['valign']!='') echo ' valign="' . $input[$i][$j]['td']['valign'] .'"'; | ||||
| 								echo ">\n"; | ||||
| 								echo "<table>\n"; | ||||
| 								$this->parse_html($module, $input[$i][$j]['value']); | ||||
| 								echo "</table>\n"; | ||||
| 								echo "</td>\n"; | ||||
| 								break; | ||||
| 							case 'help': | ||||
| 								echo "<td"; | ||||
| 								if ($input[$i][$j]['td']['valign']!='') echo ' valign="' . $input[$i][$j]['td']['valign'] .'"'; | ||||
| 								echo ">\n"; | ||||
| 								echo "<a href=../help.php?module=$module&item=$input[$i][$j]['value']>" . _('Help') . "</a></td>\n"; | ||||
| 								echo "<a href=../help.php?module=$module&item=". $input[$i][$j]['value'] . ">" . _('Help') . "</a></td>\n"; | ||||
| 								break; | ||||
| 							default: | ||||
| 								echo "<td>Unrecognized type: " . $input[$i][$j]['kind'] . "</td>\n"; | ||||
|  | @ -536,6 +537,7 @@ class accountContainer { | |||
| 				echo "</tr>\n"; | ||||
| 				} | ||||
| 			} | ||||
| 		echo "</table>\n"; | ||||
| 		} | ||||
| 
 | ||||
| 	/* Add attributes to variable. Syntax is array( attribute = array ( objectClass1 => MUST|MAX, objectClass2 => MUST|MAY ), ... ) | ||||
|  | @ -795,6 +797,8 @@ class accountContainer { | |||
| 		else { | ||||
| 			// Add module if it exists
 | ||||
| 			if (class_exists($objectClass)) { | ||||
| 				print $objectClass; | ||||
| 				print "<br>X"; | ||||
| 				$this->module[$objectClass] = new $objectClass($this->base); | ||||
| 				} | ||||
| 			else trigger_error (_("objectClass $objectClass required but no module found."), E_USER_WARNING); | ||||
|  | @ -853,7 +857,7 @@ class accountContainer { | |||
| 	* for a new account | ||||
| 	*/ | ||||
| 	function new_account() { | ||||
| 		$modulelist = array('posixAccount', 'shadowAccount', 'sambaAccount'); | ||||
| 		$modulelist = array('posixAccount', 'sambaAccount'); | ||||
| 		// *** fixme add modules from config which should be used but not yet in loaded account
 | ||||
| 		foreach ($modulelist as $objectClass) $this->add_objectClass($objectClass); | ||||
| 
 | ||||
|  | @ -1031,6 +1035,7 @@ class accountContainer { | |||
| 						$temparray[0] = $singleresult[0]; | ||||
| 						$temparray[1] = _($singleresult[1]); | ||||
| 						$temparray[2] = _($singleresult[2]); | ||||
| 						$errors[] = $temparray; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
|  |  | |||
|  | @ -183,7 +183,7 @@ class inetOrgPerson { | |||
| 		if (isset($this->attributes['host'])) { | ||||
| 			$host = $post['host']; | ||||
| 			if ((!$host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $host)) | ||||
| 				$errors[] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'), 'host'); | ||||
| 				$errors['host'][] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.')); | ||||
| 			$hosts = explode(" ", $host); | ||||
| 			$this->attributes['host'] = array(); | ||||
| 			foreach ($hosts as $host) | ||||
|  | @ -192,18 +192,18 @@ class inetOrgPerson { | |||
| 
 | ||||
| 		// Do some regex-checks and return error if attributes are set to wrong values
 | ||||
| 		if (!$profile) { | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'][0])) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'), 'givenName'); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'][0])) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'), 'sn'); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'][0]))  $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'), 'telephoneNumber'); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'][0]))  $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'), 'mobileTelephoneNumber'); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'][0]))  $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'), 'facsimileTelephoneNumber'); | ||||
| 			if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $this->attributes['mail'][0]))  $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'), 'mail'); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'][0]))  $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'), 'street'); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'][0]))  $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'), 'postalAdress'); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'][0]))  $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'), 'personal_postalCode'); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'][0])) $errors['givenName'][] = array('ERROR', _('Given name'), _('Given name contains invalid characters')); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'][0])) $errors['sn'][] = array('ERROR', _('Surname'), _('Surname contains invalid characters')); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'][0]))  $errors['telephoneNumber'][] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!')); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'][0]))  $errors['mobileTelephoneNumber'][] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!')); | ||||
| 			if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'][0]))  $errors['facsimileTelephoneNumber'][] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!')); | ||||
| 			if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $this->attributes['mail'][0]))  $errors['mail'] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!')); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'][0]))  $errors['street'][] = array('ERROR', _('Street'), _('Please enter a valid street name!')); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'][0]))  $errors['postalAdress'][] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!')); | ||||
| 			if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'][0]))  $errors['personal_postalCode'][] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!')); | ||||
| 			} | ||||
| 		if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'][0]))  $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!'), 'title'); | ||||
| 		if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'][0]))  $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'), 'employeeType'); | ||||
| 		if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'][0]))  $errors['title'][] = array('ERROR', _('Title'), _('Please enter a valid title!')); | ||||
| 		if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'][0]))  $errors['employeeType'][] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!')); | ||||
| 		// Return error-messages
 | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		return 0; | ||||
|  |  | |||
|  | @ -141,12 +141,12 @@ class main { | |||
| 			} | ||||
| 		// save profile
 | ||||
| 		if ($post['saveProfile']) { | ||||
| 			if ($post['selectSaveProfile']=='') $errors[] = array('ERROR', _('Save profile'), _('No profilename given.')); | ||||
| 			if ($post['selectSaveProfile']=='') $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('No profilename given.')); | ||||
| 			else { | ||||
| 				$function = 'save'.ucfirst($scope).'Profile();'; | ||||
| 				eval($function); | ||||
| 				if ($function) $errors[] = array('INFO', _('Save profile'), _('New profile created.')); | ||||
| 					else $errors[] = array('ERROR', _('Save profile'), _('Wrong profilename given.')); | ||||
| 				if ($function) $errors['saveProfile'][] = array('INFO', _('Save profile'), _('New profile created.')); | ||||
| 					else $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('Wrong profilename given.')); | ||||
| 				} | ||||
| 			if (is_array($errors) && !$profile) return $errors; | ||||
| 				else return 0; | ||||
|  |  | |||
|  | @ -155,9 +155,16 @@ class posixAccount { | |||
| 		return array('attributes', 'groups'); | ||||
| 		} | ||||
| 
 | ||||
| 	function profile_attributes() { | ||||
| 		// array of attribtues wich are unique and not allowed to store in profile
 | ||||
| 		//array unique_attributes ( 'user' => array ('cn', 'rid', 'uid', 'uidNumber', 'userPassword')  );
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
|  | @ -253,7 +260,7 @@ class posixAccount { | |||
| 
 | ||||
| 		// Remove primary group from additional groups
 | ||||
| 		for ($i=0; $i<count($this->groups); $i++) { | ||||
| 			if ($this->groups[$i]==$_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'])) unset($this->groups[$i]); | ||||
| 			if ($this->groups[$i]==$_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0])) unset($this->groups[$i]); | ||||
| 			} | ||||
| 
 | ||||
| 		// Set additional group memberships
 | ||||
|  | @ -331,15 +338,15 @@ class posixAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0]) | ||||
| 			$errors[] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?'), 'uid'); | ||||
| 			$errors['uid'][] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?')); | ||||
| 		if ($this->orig['gidNumber'][0]!='' && $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0]) | ||||
| 			$errors[] = array('INFO', _('GID number'), sprintf(_('GID number has changed. To keep file ownership you have to run the following command as root: \'find / -gid %s -uid %s -exec chgrp %s {} \;\''), $this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber'])), 'gidNumber'); | ||||
| 			$errors['gidNumber'][] = array('INFO', _('GID number'), sprintf(_('GID number has changed. To keep file ownership you have to run the following command as root: \'find / -gid %s -uid %s -exec chgrp %s {} \;\''), $this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber']))); | ||||
| 		if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0]) | ||||
| 			$errors[] = array('INFO', _('UID number'), sprintf(_('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\''), $this->orig['uidNumber'][0], $this->attributes['uidNumber'][0]), 'uidNumber'); | ||||
| 			$errors['uidNumber'][] = array('INFO', _('UID number'), sprintf(_('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\''), $this->orig['uidNumber'][0], $this->attributes['uidNumber'][0])); | ||||
| 		if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0]) | ||||
| 			$errors[] = array('INFO', _('Home directory'), sprintf(_('Home directory changed. To keep home directory you have to run the following command as root: \'mv %s %s\''), $this->orig['homeDirectory'][0], $this->attributes['homeDirectory'][0]), 'homeDirectory'); | ||||
| 			$errors['homeDirectory'][] = array('INFO', _('Home directory'), sprintf(_('Home directory changed. To keep home directory you have to run the following command as root: \'mv %s %s\''), $this->orig['homeDirectory'][0], $this->attributes['homeDirectory'][0])); | ||||
| 
 | ||||
| 		// Load attributes
 | ||||
| 		$this->attributes['uid'][0] = $post['uid']; | ||||
|  | @ -355,150 +362,153 @@ class posixAccount { | |||
| 			else $this->userPassword_no=false; | ||||
| 		if ($post['userPassword_lock']) $this->userPassword_lock=true; | ||||
| 			else $this->userPassword_lock=false; | ||||
| 		if (isset($post['userPassword'])) { | ||||
| 			if ($post['userPassword'] != $post['userPassword2']) { | ||||
| 				$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'userPassword'); | ||||
| 				unset ($post['userPassword2']); | ||||
| 				} | ||||
| 				else $this->userPassword($post['userPassword']); | ||||
| 			} | ||||
| 		if ($post['genpass']) $this->userPassword(genpasswd()); | ||||
| 		// Check if UID is valid. If none value was entered, the next useable value will be inserted
 | ||||
| 		// load min and may uidNumber
 | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minUID()); | ||||
| 			$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxUID()); | ||||
| 			} | ||||
| 		if ($_SESSION[$this->base]->type=='host') { | ||||
| 			$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minMachine()); | ||||
| 			$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxMachine()); | ||||
| 			} | ||||
| 		$dn_uids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uidNumber', 'posixAccount', '*'); | ||||
| 		// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | ||||
| 		foreach ($dn_uids as $uid) $uids[] = $uid[0]; | ||||
| 		if(is_array($uids)) sort ($uids, SORT_NUMERIC); | ||||
| 		if ($this->attributes['uidNumber'][0]=='') { | ||||
| 			// No id-number given
 | ||||
| 			if ($this->orig['uidNumber'][0]=='') { | ||||
| 				// new account -> we have to find a free id-number
 | ||||
| 				if (count($uids)!=0) { | ||||
| 					// There are some uids
 | ||||
| 					// Store highest id-number
 | ||||
| 					$id = $uids[count($uids)-1]; | ||||
| 					// Return minimum allowed id-number if all found id-numbers are too low
 | ||||
| 					if ($id < $minID) $this->attributes['uidNumber'][0] = $minID; | ||||
| 					// Return higesht used id-number + 1 if it's still in valid range
 | ||||
| 					if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1; | ||||
| 					/* If this function is still running we have to fid a free id-number between | ||||
| 					* the used id-numbers | ||||
| 					*/ | ||||
| 					$i = intval($minID); | ||||
| 					while (in_array($i, $uids)) $i++; | ||||
| 					if ($i>$maxID) | ||||
| 						$errors[] = array('ERROR', _('ID-Number'), _('No free ID-Number!'), 'uidNumber'); | ||||
| 						else { | ||||
| 							$this->attributes['uidNumber'][0] = $i; | ||||
| 							$errors[] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'), 'uidNumber'); | ||||
| 							} | ||||
| 		if (!$profile) { | ||||
| 			if (isset($post['userPassword'])) { | ||||
| 				if ($post['userPassword'] != $post['userPassword2']) { | ||||
| 					$errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.')); | ||||
| 					unset ($post['userPassword2']); | ||||
| 					} | ||||
| 				else $this->attributes['uidNumber'][0] = $minID; | ||||
| 				// return minimum allowed id-number if no id-numbers are found
 | ||||
| 					else $this->userPassword($post['userPassword']); | ||||
| 				} | ||||
| 			else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0]; | ||||
| 			// old account -> return id-number which has been used
 | ||||
| 			} | ||||
| 		else { | ||||
| 			// Check manual ID
 | ||||
| 			// id-number is out of valid range
 | ||||
| 			if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors[] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID), 'uidNumber'); | ||||
| 			// $uids is allways an array but not if no entries were found
 | ||||
| 			if (is_array($uids)) { | ||||
| 				// id-number is in use and account is a new account
 | ||||
| 				if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'uidNumber'); | ||||
| 				// id-number is in use, account is existing account and id-number is not used by itself
 | ||||
| 				if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) { | ||||
| 					$errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'uidNumber'); | ||||
| 					$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0]; | ||||
| 			if ($post['genpass']) $this->userPassword(genpasswd()); | ||||
| 			// Check if UID is valid. If none value was entered, the next useable value will be inserted
 | ||||
| 			// load min and may uidNumber
 | ||||
| 			if ($_SESSION[$this->base]->type=='user') { | ||||
| 				$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minUID()); | ||||
| 				$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxUID()); | ||||
| 				} | ||||
| 			if ($_SESSION[$this->base]->type=='host') { | ||||
| 				$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minMachine()); | ||||
| 				$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxMachine()); | ||||
| 				} | ||||
| 			$dn_uids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uidNumber', 'posixAccount', '*'); | ||||
| 			// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | ||||
| 			foreach ($dn_uids as $uid) $uids[] = $uid[0]; | ||||
| 			if(is_array($uids)) sort ($uids, SORT_NUMERIC); | ||||
| 			if ($this->attributes['uidNumber'][0]=='') { | ||||
| 				// No id-number given
 | ||||
| 				if ($this->orig['uidNumber'][0]=='') { | ||||
| 					// new account -> we have to find a free id-number
 | ||||
| 					if (count($uids)!=0) { | ||||
| 						// There are some uids
 | ||||
| 						// Store highest id-number
 | ||||
| 						$id = $uids[count($uids)-1]; | ||||
| 						// Return minimum allowed id-number if all found id-numbers are too low
 | ||||
| 						if ($id < $minID) $this->attributes['uidNumber'][0] = $minID; | ||||
| 						// Return higesht used id-number + 1 if it's still in valid range
 | ||||
| 						if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1; | ||||
| 						/* If this function is still running we have to fid a free id-number between | ||||
| 						* the used id-numbers | ||||
| 						*/ | ||||
| 						$i = intval($minID); | ||||
| 						while (in_array($i, $uids)) $i++; | ||||
| 						if ($i>$maxID) | ||||
| 							$errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('No free ID-Number!')); | ||||
| 							else { | ||||
| 								$this->attributes['uidNumber'][0] = $i; | ||||
| 								$errors['uidNumber'][] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.')); | ||||
| 								} | ||||
| 						} | ||||
| 					else $this->attributes['uidNumber'][0] = $minID; | ||||
| 					// return minimum allowed id-number if no id-numbers are found
 | ||||
| 					} | ||||
| 				else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0]; | ||||
| 				// old account -> return id-number which has been used
 | ||||
| 				} | ||||
| 			else { | ||||
| 				// Check manual ID
 | ||||
| 				// id-number is out of valid range
 | ||||
| 				if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID)); | ||||
| 				// $uids is allways an array but not if no entries were found
 | ||||
| 				if (is_array($uids)) { | ||||
| 					// id-number is in use and account is a new account
 | ||||
| 					if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); | ||||
| 					// id-number is in use, account is existing account and id-number is not used by itself
 | ||||
| 					if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) { | ||||
| 						$errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); | ||||
| 						$this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0]; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			if (($this->attributes['uid'][0] != $post['uid']) &&  ereg('[A-Z]$', $post['uid'])) | ||||
| 				$errors[] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'uid'); | ||||
| 			if (($this->attributes['uid'][0] != $post['uid']) &&  ereg('[A-Z]$', $post['uid']) && !$profile) | ||||
| 				$errors['uid'][] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.')); | ||||
| 			// Check if Homedir is valid
 | ||||
| 			$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]); | ||||
| 			if ($this->attributes['uid'][0] != '') | ||||
| 				$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]); | ||||
| 			if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors[] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.')); | ||||
| 			if (!$profile) { | ||||
| 					$this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]); | ||||
| 				if ($this->attributes['uid'][0] != '') | ||||
| 					$this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]); | ||||
| 				if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.')); | ||||
| 				} | ||||
| 			if ( !ereg('^[/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*([/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*)*$', $this->attributes['homeDirectory'][0] )) | ||||
| 				$errors[] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'), 'homeDirectory'); | ||||
| 				$errors['homeDirecotry'][] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'), 'homeDirectory'); | ||||
| 			// Check if Username contains only valid characters
 | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['uid'][0])) | ||||
| 				$errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'), 'uid'); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['uid'][0]) && !$profile) | ||||
| 				$errors['uid'][] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); | ||||
| 			} | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='host') { | ||||
| 		if ($_SESSION[$this->base]->type=='host' && !$profile) { | ||||
| 			if (($this->attributes['uid'][0] != $post['form_account_uid']) &&  ereg('[A-Z]$', $post['form_account_uid'])) | ||||
| 				$errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'uid'); | ||||
| 				$errors['uid'][] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.')); | ||||
| 			// Check if Username contains only valid characters
 | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+[$]$', $this->attributes['uid'][0])) | ||||
| 				$errors[] = array('ERROR', _('Hostname'), _('Hostname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ ! Hostname must end with $ !'), 'uid'); | ||||
| 				$errors['uid'][] = array('ERROR', _('Hostname'), _('Hostname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ ! Hostname must end with $ !')); | ||||
| 			} | ||||
| 
 | ||||
| 		// Create automatic useraccount with number if original user already exists
 | ||||
| 		// Reset name to original name if new name is in use
 | ||||
| 		// Set username back to original name if new username is in use
 | ||||
| 		if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0],'uid', '*')!=false && ($this->orig['uid'][0]!='')) { | ||||
| 			$this->attributes['uid'][0] = $this->orig['uid'][0]; | ||||
| 			} | ||||
| 		// Change uid to a new uid until a free uid is found
 | ||||
| 		else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0], 'uid', '*')) { | ||||
| 			if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1); | ||||
| 				// get last character of username
 | ||||
| 			$lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1); | ||||
| 			// Last character is no number
 | ||||
| 			if ( !ereg('^([0-9])+$', $lastchar)) | ||||
| 				/* Last character is no number. Therefore we only have to | ||||
| 				* add "2" to it. | ||||
| 				*/ | ||||
| 				if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$'; | ||||
| 					else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2'; | ||||
| 			 else { | ||||
| 				/* Last character is a number -> we have to increase the number until we've | ||||
| 				* found a groupname with trailing number which is not in use. | ||||
| 				* | ||||
| 				* $i will show us were we have to split groupname so we get a part | ||||
| 				* with the groupname and a part with the trailing number | ||||
| 				*/ | ||||
| 				$i=strlen($this->attributes['uid'][0])-1; | ||||
| 				$mark = false; | ||||
| 				// Set $i to the last character which is a number in $account_new->general_username
 | ||||
| 				while (!$mark) { | ||||
| 					if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--; | ||||
| 						else $mark=true; | ||||
| 					} | ||||
| 				// increase last number with one
 | ||||
| 				$firstchars = substr($this->attributes['uid'][0], 0, $i+1); | ||||
| 				$lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i); | ||||
| 				// Put username together
 | ||||
| 				if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$"; | ||||
| 					else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1); | ||||
| 		if (!$profile) { | ||||
| 			if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0],'uid', '*')!=false && ($this->orig['uid'][0]!='')) { | ||||
| 				$this->attributes['uid'][0] = $this->orig['uid'][0]; | ||||
| 				} | ||||
| 			// Change uid to a new uid until a free uid is found
 | ||||
| 			else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0], 'uid', '*')) { | ||||
| 				if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1); | ||||
| 					// get last character of username
 | ||||
| 				$lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1); | ||||
| 				// Last character is no number
 | ||||
| 				if ( !ereg('^([0-9])+$', $lastchar)) | ||||
| 					/* Last character is no number. Therefore we only have to | ||||
| 					* add "2" to it. | ||||
| 					*/ | ||||
| 					if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$'; | ||||
| 						else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2'; | ||||
| 				else { | ||||
| 					/* Last character is a number -> we have to increase the number until we've | ||||
| 					* found a groupname with trailing number which is not in use. | ||||
| 					* | ||||
| 					* $i will show us were we have to split groupname so we get a part | ||||
| 					* with the groupname and a part with the trailing number | ||||
| 					*/ | ||||
| 					$i=strlen($this->attributes['uid'][0])-1; | ||||
| 					$mark = false; | ||||
| 					// Set $i to the last character which is a number in $account_new->general_username
 | ||||
| 					while (!$mark) { | ||||
| 						if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--; | ||||
| 							else $mark=true; | ||||
| 						} | ||||
| 					// increase last number with one
 | ||||
| 					$firstchars = substr($this->attributes['uid'][0], 0, $i+1); | ||||
| 					$lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i); | ||||
| 					// Put username together
 | ||||
| 					if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$"; | ||||
| 						else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 		// Show warning if lam has changed username
 | ||||
| 		if ($_SESSION[$this->base]->type=='user') | ||||
| 			if ($this->attributes['uid'][0] != $post['uid']) { | ||||
| 				$errors[] = array('WARN', _('Username'), _('Username in use. Selected next free username.'), 'uid'); | ||||
| 				$errors['uid'][] = array('WARN', _('Username'), _('Username in use. Selected next free username.')); | ||||
| 				} | ||||
| 		if ($_SESSION[$this->base]->type=='host') | ||||
| 			if ($this->attributes['uid'][0] != $post['uid']) { | ||||
| 				$errors[] = array('WARN', _('Hostname'), _('Hostname in use. Selected next free hostname.'), 'uid'); | ||||
| 				$errors['uid'][] = array('WARN', _('Hostname'), _('Hostname in use. Selected next free hostname.')); | ||||
| 				} | ||||
| 
 | ||||
| 		if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword())) | ||||
| 			$errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'userPassword'); | ||||
| 			if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword())) | ||||
| 				$errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); | ||||
| 			} | ||||
| 		// Return error-messages
 | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		// Go to additional group page when no error did ocour and button was pressed
 | ||||
|  | @ -508,7 +518,7 @@ class posixAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_group($post) { | ||||
| 	function proccess_group($post, $profile=false) { | ||||
| 		do { // X-Or, only one if() can be true
 | ||||
| 			if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
 | ||||
| 				// Add new group
 | ||||
|  | @ -534,10 +544,10 @@ class posixAccount { | |||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 		$groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames
 | ||||
| 		$shelllist = getshells(); // list of all valid shells
 | ||||
| 		if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword(); | ||||
| 			else $password=''; | ||||
| 
 | ||||
| 		if (!$profile) { | ||||
| 			if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword(); | ||||
| 				else $password=''; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Username").'*' ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['uid'][0]), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'uid')); | ||||
|  | @ -554,9 +564,11 @@ class posixAccount { | |||
| 			2 => array ('kind' => 'help', 'value' => 'gidNumber')); | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'addgroup')); | ||||
| 			if (!$profile) { | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')), | ||||
| 					2 => array ('kind' => 'help', 'value' => 'addgroup')); | ||||
| 				} | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home directory').'*' ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'homeDirectory')); | ||||
|  |  | |||
|  | @ -143,6 +143,18 @@ class posixGroup { | |||
| 		return array('attributes', 'user'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of posixGroup and returns | ||||
| 	* also their values. | ||||
|  | @ -295,9 +307,9 @@ class posixGroup { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		if ($this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0]) | ||||
| 			$errors[] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'), 'gidNumber'); | ||||
| 			$errors['gidNumber'][] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.')); | ||||
| 
 | ||||
| 		// Load attributes
 | ||||
| 		$this->attributes['cn'][0] = $post['cn']; | ||||
|  | @ -307,123 +319,126 @@ class posixGroup { | |||
| 			else $this->userPassword_no=false; | ||||
| 		if ($post['userPassword_lock']) $this->userPassword_lock=true; | ||||
| 			else $this->userPassword_lock=false; | ||||
| 		if ($post['changegids']) $this->changegids=true; | ||||
| 			else $this->changegids=false; | ||||
| 		If (!$profile) { | ||||
| 			if ($post['changegids']) $this->changegids=true; | ||||
| 				else $this->changegids=false; | ||||
| 
 | ||||
| 		if (isset($post['userPassword'])) { | ||||
| 			if ($post['userPassword'] != $post['userPassword2']) { | ||||
| 				$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'userPassword'); | ||||
| 				unset ($post['userPassword2']); | ||||
| 			if (isset($post['userPassword'])) { | ||||
| 				if ($post['userPassword'] != $post['userPassword2']) { | ||||
| 					$errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.')); | ||||
| 					unset ($post['userPassword2']); | ||||
| 					} | ||||
| 					else $this->userPassword($post['userPassword']); | ||||
| 				} | ||||
| 				else $this->userPassword($post['userPassword']); | ||||
| 			} | ||||
| 		if ($post['genpass']) $this->userPassword(genpasswd()); | ||||
| 			if ($post['genpass']) $this->userPassword(genpasswd()); | ||||
| 
 | ||||
| 		// Check if UID is valid. If none value was entered, the next useable value will be inserted
 | ||||
| 		// load min and may uidNumber
 | ||||
| 		$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minGID()); | ||||
| 		$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxGID()); | ||||
| 		$dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*'); | ||||
| 		// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | ||||
| 		foreach ($dn_gids as $gid) $gids[] = $gid[0]; | ||||
| 		if(is_array($gids)) sort ($gids, SORT_NUMERIC); | ||||
| 		if ($this->attributes['gidNumber'][0]=='') { | ||||
| 			// No id-number given
 | ||||
| 			if ($this->orig['gidNumber'][0]=='') { | ||||
| 				// new account -> we have to find a free id-number
 | ||||
| 				if (count($gids)!=0) { | ||||
| 					// There are some uids
 | ||||
| 					// Store highest id-number
 | ||||
| 					$id = $gids[count($gids)-1]; | ||||
| 					// Return minimum allowed id-number if all found id-numbers are too low
 | ||||
| 					if ($id < $minID) $this->attributes['gidNumber'][0] = $minID; | ||||
| 					// Return higesht used id-number + 1 if it's still in valid range
 | ||||
| 					if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1; | ||||
| 					/* If this function is still running we have to fid a free id-number between | ||||
| 					* the used id-numbers | ||||
| 			// Check if UID is valid. If none value was entered, the next useable value will be inserted
 | ||||
| 			// load min and may uidNumber
 | ||||
| 			$minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minGID()); | ||||
| 			$maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxGID()); | ||||
| 			$dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*'); | ||||
| 			// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | ||||
| 			foreach ($dn_gids as $gid) $gids[] = $gid[0]; | ||||
| 			if(is_array($gids)) sort ($gids, SORT_NUMERIC); | ||||
| 			if ($this->attributes['gidNumber'][0]=='') { | ||||
| 				// No id-number given
 | ||||
| 				if ($this->orig['gidNumber'][0]=='') { | ||||
| 					// new account -> we have to find a free id-number
 | ||||
| 					if (count($gids)!=0) { | ||||
| 						// There are some uids
 | ||||
| 						// Store highest id-number
 | ||||
| 						$id = $gids[count($gids)-1]; | ||||
| 						// Return minimum allowed id-number if all found id-numbers are too low
 | ||||
| 						if ($id < $minID) $this->attributes['gidNumber'][0] = $minID; | ||||
| 						// Return higesht used id-number + 1 if it's still in valid range
 | ||||
| 						if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1; | ||||
| 						/* If this function is still running we have to fid a free id-number between | ||||
| 						* the used id-numbers | ||||
| 						*/ | ||||
| 						$i = intval($minID); | ||||
| 						while (in_array($i, $gids)) $i++; | ||||
| 						if ($i>$maxID) | ||||
| 							$errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('No free ID-Number!')); | ||||
| 							else { | ||||
| 								$this->attributes['gidNumber'][0] = $i; | ||||
| 								$errors['gidNumber'][] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.')); | ||||
| 								} | ||||
| 						} | ||||
| 					else $this->attributes['gidNumber'][0] = $minID; | ||||
| 					// return minimum allowed id-number if no id-numbers are found
 | ||||
| 					} | ||||
| 				else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; | ||||
| 				// old account -> return id-number which has been used
 | ||||
| 				} | ||||
| 			else { | ||||
| 				// Check manual ID
 | ||||
| 				// id-number is out of valid range
 | ||||
| 				if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID)); | ||||
| 				// $uids is allways an array but not if no entries were found
 | ||||
| 				if (is_array($gids)) { | ||||
| 					// id-number is in use and account is a new account
 | ||||
| 					if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); | ||||
| 					// id-number is in use, account is existing account and id-number is not used by itself
 | ||||
| 					if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) { | ||||
| 						$errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use')); | ||||
| 						$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 
 | ||||
| 			if (($this->attributes['cn'][0] != $post['cn']) &&  ereg('[A-Z]$', $post['cn'])) | ||||
| 				$errors['cn'][] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.')); | ||||
| 			// Check if Username contains only valid characters
 | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0])) | ||||
| 				$errors['cn'][] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); | ||||
| 
 | ||||
| 			// Create automatic useraccount with number if original user already exists
 | ||||
| 			// Reset name to original name if new name is in use
 | ||||
| 			// Set username back to original name if new username is in use
 | ||||
| 			if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) { | ||||
| 				$this->attributes['cn'][0] = $this->orig['cn'][0]; | ||||
| 				} | ||||
| 			// Change uid to a new uid until a free uid is found
 | ||||
| 			else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0], 'cn', '*')) { | ||||
| 				// get last character of username
 | ||||
| 				$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1); | ||||
| 				// Last character is no number
 | ||||
| 				if ( !ereg('^([0-9])+$', $lastchar)) | ||||
| 					/* Last character is no number. Therefore we only have to | ||||
| 					* add "2" to it. | ||||
| 					*/ | ||||
| 					$i = intval($minID); | ||||
| 					while (in_array($i, $gids)) $i++; | ||||
| 					if ($i>$maxID) | ||||
| 						$errors[] = array('ERROR', _('ID-Number'), _('No free ID-Number!'), 'gidNumber'); | ||||
| 						else { | ||||
| 							$this->attributes['gidNumber'][0] = $i; | ||||
| 							$errors[] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'), 'gidNumber'); | ||||
| 							} | ||||
| 					} | ||||
| 				else $this->attributes['gidNumber'][0] = $minID; | ||||
| 				// return minimum allowed id-number if no id-numbers are found
 | ||||
| 				} | ||||
| 			else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; | ||||
| 			// old account -> return id-number which has been used
 | ||||
| 			} | ||||
| 		else { | ||||
| 			// Check manual ID
 | ||||
| 			// id-number is out of valid range
 | ||||
| 			if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors[] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID), 'gidNumber'); | ||||
| 			// $uids is allways an array but not if no entries were found
 | ||||
| 			if (is_array($gids)) { | ||||
| 				// id-number is in use and account is a new account
 | ||||
| 				if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'gidNumber'); | ||||
| 				// id-number is in use, account is existing account and id-number is not used by itself
 | ||||
| 				if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) { | ||||
| 					$errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'gidNumber'); | ||||
| 					$this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; | ||||
| 					$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2'; | ||||
| 				else { | ||||
| 					/* Last character is a number -> we have to increase the number until we've | ||||
| 					* found a groupname with trailing number which is not in use. | ||||
| 					* | ||||
| 					* $i will show us were we have to split groupname so we get a part | ||||
| 					* with the groupname and a part with the trailing number | ||||
| 					*/ | ||||
| 					$i=strlen($this->attributes['cn'][0])-1; | ||||
| 					$mark = false; | ||||
| 					// Set $i to the last character which is a number in $account_new->general_username
 | ||||
| 					while (!$mark) { | ||||
| 						if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--; | ||||
| 							else $mark=true; | ||||
| 						} | ||||
| 					// increase last number with one
 | ||||
| 					$firstchars = substr($this->attributes['cn'][0], 0, $i+1); | ||||
| 					$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i); | ||||
| 					// Put username together
 | ||||
| 					$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 		if (($this->attributes['cn'][0] != $post['cn']) &&  ereg('[A-Z]$', $post['cn'])) | ||||
| 			$errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'cn'); | ||||
| 		// Check if Username contains only valid characters
 | ||||
| 		if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0])) | ||||
| 			$errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'), 'cn'); | ||||
| 
 | ||||
| 		// Create automatic useraccount with number if original user already exists
 | ||||
| 		// Reset name to original name if new name is in use
 | ||||
| 		// Set username back to original name if new username is in use
 | ||||
| 		if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) { | ||||
| 			$this->attributes['cn'][0] = $this->orig['cn'][0]; | ||||
| 			} | ||||
| 		// Change uid to a new uid until a free uid is found
 | ||||
| 		else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0], 'cn', '*')) { | ||||
| 			// get last character of username
 | ||||
| 			$lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1); | ||||
| 			// Last character is no number
 | ||||
| 			if ( !ereg('^([0-9])+$', $lastchar)) | ||||
| 				/* Last character is no number. Therefore we only have to | ||||
| 				* add "2" to it. | ||||
| 				*/ | ||||
| 				$this->attributes['cn'][0] = $this->attributes['cn'][0] . '2'; | ||||
| 			 else { | ||||
| 				/* Last character is a number -> we have to increase the number until we've | ||||
| 				* found a groupname with trailing number which is not in use. | ||||
| 				* | ||||
| 				* $i will show us were we have to split groupname so we get a part | ||||
| 				* with the groupname and a part with the trailing number | ||||
| 				*/ | ||||
| 				$i=strlen($this->attributes['cn'][0])-1; | ||||
| 				$mark = false; | ||||
| 				// Set $i to the last character which is a number in $account_new->general_username
 | ||||
| 				while (!$mark) { | ||||
| 					if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--; | ||||
| 						else $mark=true; | ||||
| 					} | ||||
| 				// increase last number with one
 | ||||
| 				$firstchars = substr($this->attributes['cn'][0], 0, $i+1); | ||||
| 				$lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i); | ||||
| 				// Put username together
 | ||||
| 				$this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1); | ||||
| 			// Show warning if lam has changed username
 | ||||
| 			if ($this->attributes['cn'][0] != $post['cn']) { | ||||
| 				$errors['cn'][] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.')); | ||||
| 				} | ||||
| 
 | ||||
| 			if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword())) | ||||
| 				$errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); | ||||
| 			} | ||||
| 
 | ||||
| 		// Show warning if lam has changed username
 | ||||
| 		if ($this->attributes['cn'][0] != $post['cn']) { | ||||
| 			$errors[] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'), 'cn'); | ||||
| 			} | ||||
| 
 | ||||
| 		if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword())) | ||||
| 			$errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'userPassword'); | ||||
| 		// Return error-messages
 | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		// Go to additional group page when no error did ocour and button was pressed
 | ||||
|  | @ -433,7 +448,7 @@ class posixGroup { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_user($post) { | ||||
| 	function proccess_user($post, $profile=false) { | ||||
| 		do { // X-Or, only one if() can be true
 | ||||
| 			if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add groups to list
 | ||||
| 				// Add new user
 | ||||
|  | @ -463,65 +478,41 @@ class posixGroup { | |||
| 	function display_html_attributes($post) { | ||||
| 		if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword(); | ||||
| 			else $password=''; | ||||
| 		echo "<table border=0 width=\"100%\">\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo '<td>' . _('Groupname') . "*</td>\n"; | ||||
| 		echo "<td><input name=\"cn\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"".$this->attributes['cn'][0]."\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=400\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('GID number') ."</td>\n"; | ||||
| 		echo "<td><input name=\"gidNumber\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"".$this->attributes['gidNumber'][0]."\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=401\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Description') . "</td>\n"; | ||||
| 		echo "<td><input name=\"description\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"".$this->attributes['description'][0]."\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=404\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Group members') . "</td>\n"; | ||||
| 		echo "<td><input name=\"adduser\" type=\"submit\" value=\"" . _('Edit groups') . "\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=402\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Password') . "</td>\n"; | ||||
| 		echo "<td><input name=\"userPassword\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"$password\"></td>\n";
 | ||||
| 		echo "<td><input name=\"genpass\" type=\"submit\" value=\"" . _('Generate password') . "\"></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Repeat password') . "</td>\n"; | ||||
| 		echo "<td><input name=\"userPassword2\" type=\"password\" size=\"20\" maxlength=\"20\" value=\""; | ||||
| 			if ($post['userPassword2']!='') echo $post['userPassword2']; | ||||
| 			else echo $password; | ||||
| 		echo "\"></td>\n"; | ||||
| 		echo "<td></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Use no password') . "</td>\n"; | ||||
| 		echo "<td><input name=\"userPassword_no\" type=\"checkbox\""; | ||||
| 			if ($this->userPassword_no) echo " checked "; | ||||
| 			echo "></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Lock password') . "</td>\n"; | ||||
| 		echo "<td><input name=\"userPassword_lock\" type=\"checkbox\""; | ||||
| 			if ($this->userPassword_lock) echo " checked "; | ||||
| 			echo "></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='') { | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Change GID number of users and hosts') . "</td>\n"; | ||||
| 			echo "<td><input name=\"changegids\" type=\"checkbox\""; | ||||
| 				if ($this->changegids) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=XXX\" target=\"lamhelp\">" . _('Help-XX') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 		if (!$profile) { | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Groupname").'*' ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['cn'][0]), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'cn')); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('GID number').'*' ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['gidNumber'][0]), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'gidNumber')); | ||||
| 			} | ||||
| 		echo "</table>\n"; | ||||
| 		return 0; | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]), | ||||
| 			2 => array ('kind' => 'help', 'value' => 'description')); | ||||
| 		if (!$profile) { | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Group members").'*' ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'adduser', 'type' => 'submit', 'value' => _('Edit groups')), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'adduser')); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password), | ||||
| 				2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password'))); | ||||
| 			if ($post['userPassword2']!='') $password2 = $post['userPassword2']; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'userPassword')); | ||||
| 			} | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use no password') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'userPassword_no', 'type' => 'checkbox', 'checked' => $this->userPassword_no), | ||||
| 			2 => array ('kind' => 'help', 'value' => 'userPassword_no')); | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock), | ||||
| 			2 => array ('kind' => 'help', 'value' => 'userPassword_lock')); | ||||
| 		if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='' && !$profile) { | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'changegids')); | ||||
| 			} | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  | @ -529,7 +520,7 @@ class posixGroup { | |||
| 		return 0; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_user($post) { | ||||
| 	function display_html_user($post, $profile=false) { | ||||
| 		// load list with all groups
 | ||||
| 		$dn_users = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'posixAccount', 'user'); | ||||
| 		foreach ($dn_users as $user) $users[] = $user[0]; | ||||
|  | @ -553,42 +544,20 @@ class posixGroup { | |||
| 		// sort users
 | ||||
| 		sort($users); | ||||
| 
 | ||||
| 		echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 		echo "<td><fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 			echo "<legend class=\"".$_SESSION[$this->base]->type."edit-bright\"><b>" . _("Group members") . "</b></legend>\n"; | ||||
| 			echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 				echo "<td valign=\"top\">"; | ||||
| 				echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo "<legend class=\"".$_SESSION[$this->base]->type."edit-bright\">" . _("Selected users") . "</legend>\n"; | ||||
| 					// Show all groups the user is additional member of
 | ||||
| 					if (count($this->attributes['memberUid'])!=0) { | ||||
| 						echo "<select name=\"removeusers[]\" class=\"".$_SESSION[$this->base]->type."edit-bright\" size=15 multiple>\n"; | ||||
| 						foreach ($this->attributes['memberUid'] as $member) | ||||
| 							if ($member!='') echo "<option>$member</option>\n"; | ||||
| 						echo "</select>\n"; | ||||
| 						} | ||||
| 					echo "</fieldset></td>\n"; | ||||
| 				echo "<td align=\"center\" width=\"10%\"><input type=\"submit\" name=\"addusers_button\" value=\"<=\">"; | ||||
| 				echo " "; | ||||
| 				echo "<input type=\"submit\" name=\"removeusers_button\" value=\"=>\"><br><br>"; | ||||
| 				echo "<a href=\""."../help.php?HelpNumber=402\" target=\"lamhelp\">"._('Help')."</a></td>\n"; | ||||
| 				echo "<td valign=\"top\">\n"; | ||||
| 				echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo "<legend class=\"".$_SESSION[$this->base]->type."edit-bright\">" . _('Available users') . "</legend>\n"; | ||||
| 					// show all groups expect these the user is member of
 | ||||
| 					if (count($users)!=0) { | ||||
| 						echo "<select name=\"addusers[]\" size=15 multiple class=\"".$_SESSION[$this->base]->type."edit-bright\">\n"; | ||||
| 						for ($i=0; $i<count($users); $i++) | ||||
| 							if ($users[$i]!='') echo "<option> $users[$i] </option>\n"; | ||||
| 						echo "</select>\n"; | ||||
| 						} | ||||
| 					echo "</fieldset></td>\n"; | ||||
| 				echo "</tr>\n"; | ||||
| 				echo "</table>\n"; | ||||
| 			echo "<input name=\"toattributes\" type=\"submit\" value=\""; echo _('Back'); echo "\">\n"; | ||||
| 			echo "</fieldset>\n"; | ||||
| 		echo "</td></tr></table>\n"; | ||||
| 		return 0; | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' => | ||||
| 			array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected userss"), 'value' => | ||||
| 				array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))), | ||||
| 			1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', | ||||
| 				'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>' )), | ||||
| 				2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'adduser' )))), | ||||
| 			2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available users"), 'value' => | ||||
| 				array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'addusers[]', 'size' => '15', 'multiple', 'options' => $users)))) | ||||
| 				)))); | ||||
| 
 | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ), | ||||
| 			1 => array ( 'kind' => 'text'), | ||||
| 			2 => array ('kind' => 'text')); | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	} | ||||
|  |  | |||
|  | @ -95,6 +95,18 @@ class quota { | |||
| 		return array('attributes'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of quota and returns | ||||
| 	* also their values. | ||||
|  | @ -185,7 +197,7 @@ class quota { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		// Write all general values into $account_new
 | ||||
| 		$i=0; | ||||
| 		// loop for every mointpoint with quotas
 | ||||
|  | @ -196,17 +208,17 @@ class quota { | |||
| 			$this->quota[$i][7] = $post[$i . '_7']; | ||||
| 			// Check if values are OK and set automatic values. if not error-variable will be set
 | ||||
| 			if (!ereg('^([0-9])*$', $this->quota[$i][2])) | ||||
| 				$errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 				$errors[$this->quota[$i][2]][] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 			if (!ereg('^([0-9])*$', $this->quota[$i][3])) | ||||
| 				$errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 				$errors[$this->quota[$i][3]][] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 			if (!ereg('^([0-9])*$', $this->quota[$i][6])) | ||||
| 				$errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 				$errors[$this->quota[$i][6]][] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 			if (!ereg('^([0-9])*$', $this->quota[$i][7])) | ||||
| 				$errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 				$errors[$this->quota[$i][7]][] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed')); | ||||
| 			if (intval($this->quota[$i][2]) > intval($this->quota[$i][3])) | ||||
| 				$errors[] = array('ERROR', _('Block quota'), _('Block soft quota must be smaller than block hard quota')); | ||||
| 				$errors[$this->quota[$i][2]][] = array('ERROR', _('Block quota'), _('Block soft quota must be smaller than block hard quota')); | ||||
| 			if (intval($this->quota[$i][6]) > intval($this->quota[$i][7])) | ||||
| 				$errors[] = array('ERROR', _('Inode quota'), _('Inode soft quota must be smaller than inode hard quota')); | ||||
| 				$errors[$this->quota[$i][6]][] = array('ERROR', _('Inode quota'), _('Inode soft quota must be smaller than inode hard quota')); | ||||
| 			$i++; | ||||
| 			} | ||||
| 
 | ||||
|  | @ -220,49 +232,43 @@ class quota { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_attributes($post) { | ||||
| 		echo "<table border=0 width=\"100%\">\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Mountpoint') . "</td>\n"; | ||||
| 		echo "<td>" . _('Used blocks') . "</td>\n"; | ||||
| 		echo "<td>" . _('Soft block limit') . "</td>\n"; | ||||
| 		echo "<td>" . _('Hard block limit') . "</td>\n"; | ||||
| 		echo "<td>" . _('Grace block period') . "</td>\n"; | ||||
| 		echo "<td>" . _('Used inodes') . "</td>\n"; | ||||
| 		echo "<td>" . _('Soft inode limit') . "</td>\n"; | ||||
| 		echo "<td>" . _('Hard inode limit') . "</td>\n"; | ||||
| 		echo "<td>" . _('Grace inode period') . "</td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=439\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=440\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=441\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=442\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=443\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=444\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=445\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=446\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=447\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 
 | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mountpoint') ), | ||||
| 				1 => array ( 'kind' => 'text', 'text' => _('Used blocks') ), | ||||
| 				2 => array ( 'kind' => 'text', 'text' => _('Soft block limit') ), | ||||
| 				3 => array ( 'kind' => 'text', 'text' => _('Hard block limit') ), | ||||
| 				4 => array ( 'kind' => 'text', 'text' => _('Grace block period') ), | ||||
| 				5 => array ( 'kind' => 'text', 'text' => _('Used inodes') ), | ||||
| 				6 => array ( 'kind' => 'text', 'text' => _('Soft inode limit') ), | ||||
| 				7 => array ( 'kind' => 'text', 'text' => _('Hard inode limit') ), | ||||
| 				8 => array ( 'kind' => 'text', 'text' => _('Grace inode period') )); | ||||
| 
 | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'help', 'value' => 'Mountpoint' ), | ||||
| 				1 => array ( 'kind' => 'help', 'value' => 'UsedBlocks' ), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'SoftBlockLimit' ), | ||||
| 				3 => array ( 'kind' => 'help', 'value' => 'HardBlockLimit' ), | ||||
| 				4 => array ( 'kind' => 'help', 'value' => 'GraceBlockPeriod' ), | ||||
| 				5 => array ( 'kind' => 'help', 'value' => 'UsedInodes' ), | ||||
| 				6 => array ( 'kind' => 'help', 'value' => 'SoftInodeLimit' ), | ||||
| 				7 => array ( 'kind' => 'help', 'value' => 'HardInodeLimit' ), | ||||
| 				8 => array ( 'kind' => 'help', 'value' => 'GraceInodePeriod' )); | ||||
| 
 | ||||
| 		$i=0; | ||||
| 		// loop for every mointpoint with enabled quotas
 | ||||
| 		while ($this->quota[$i][0]) { | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . $this->quota[$i][0] . "</td>\n"; | ||||
| 			echo "<td>" . $this->quota[$i][1] . "</td>\n"; // used blocks
 | ||||
| 			echo "<td><input name=\"" . $i . "_2\" type=\"text\" size=\"12\" maxlength=\"20\" value=\"" . $this->quota[$i][2] . "\"></td>\n"; // blocks soft limit
 | ||||
| 			echo "<td><input name=\"" . $i . "_3\" type=\"text\" size=\"12\" maxlength=\"20\" value=\"" . $this->quota[$i][3] . "\"></td>\n"; // blocks hard limit
 | ||||
| 			echo "<td>" . $this->quota[$i][4] . "</td>\n"; // block grace period
 | ||||
| 			echo "<td>" . $this->quota[$i][5] . "</td>\n"; // used inodes
 | ||||
| 			echo "<td><input name=\"" . $i . "_6\" type=\"text\" size=\"12\" maxlength=\"20\" value=\"" . $this->quota[$i][6] . "\"></td>\n"; // inodes soft limit
 | ||||
| 			echo "<td><input name=\"" . $i . "_7\" type=\"text\" size=\"12\" maxlength=\"20\" value=\"" . $this->quota[$i][7] . "\"></td>\n"; // inodes hard limit
 | ||||
| 			echo "<td>" . $this->quota[$i][8] . "</td>\n"; | ||||
| 			echo "</tr>\n"; // inodes grace period
 | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $this->quota[$i][0] ), | ||||
| 				1 => array ( 'kind' => 'text', 'text' => $this->quota[$i][1] ), | ||||
| 				2 => array ( 'kind' => 'input', 'name' => $i . '_2', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][2]), | ||||
| 				3 => array ( 'kind' => 'input', 'name' => $i . '_3', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][3]), | ||||
| 				4 => array ( 'kind' => 'text', 'text' => $this->quota[$i][4] ), | ||||
| 				5 => array ( 'kind' => 'text', 'text' => $this->quota[$i][5] ), | ||||
| 				6 => array ( 'kind' => 'input', 'name' => $i . '_6', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][6]), | ||||
| 				7 => array ( 'kind' => 'input', 'name' => $i . '_7', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][7]), | ||||
| 				8 => array ( 'kind' => 'text', 'text' => $this->quota[$i][8] )); | ||||
| 			$i++; | ||||
| 			} | ||||
| 		echo "</table>\n"; | ||||
| 		return 0; | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  |  | |||
|  | @ -150,6 +150,18 @@ class sambaAccount { | |||
| 		return array('attributes', 'userWorkstations'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of sambaAccount and returns | ||||
| 	* also their values. | ||||
|  | @ -237,7 +249,7 @@ class sambaAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		$this->attributes['domain'][0] = $post['domain']; | ||||
| 		// Start character
 | ||||
| 		$flag = "["; | ||||
|  | @ -254,7 +266,7 @@ class sambaAccount { | |||
| 		$flag = $flag. "]"; | ||||
| 		$this->attributes['acctFlags'][0] = $flag; | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='host') { | ||||
| 		if ($_SESSION[$this->base]->type=='host' && !$profile) { | ||||
| 			$this->attributes['primaryGroupID'][0] = $this->rids[_('Domain Computers')]; | ||||
| 			if ($post['ResetSambaPassword']) { | ||||
| 				// *** fixme. What is the default password?
 | ||||
|  | @ -273,61 +285,79 @@ class sambaAccount { | |||
| 			$this->attributes['homeDrive'][0] = $post['homeDrive']; | ||||
| 			$this->attributes['scriptPath'][0] = stripslashes($post['scriptPath']); | ||||
| 			$this->attributes['profilePath'][0] = stripslashes($post['profilePath']); | ||||
| 			$rids = array_keys($this->rids); | ||||
| 			$wrid = false; | ||||
| 			for ($i=0; $i<count($rids); $i++) { | ||||
| 				if ($post['primaryGroupID'] == $rids[$i]) { | ||||
| 					$wrid = true; | ||||
| 					$this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]]; | ||||
| 			if (!$profile) { | ||||
| 				$rids = array_keys($this->rids); | ||||
| 				$wrid = false; | ||||
| 				for ($i=0; $i<count($rids); $i++) { | ||||
| 					if ($post['primaryGroupID'] == $rids[$i]) { | ||||
| 						$wrid = true; | ||||
| 						$this->attributes['primaryGroupID'][0] = $this->rids[$rids[$i]]; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001; | ||||
| 				if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001; | ||||
| 
 | ||||
| 			if (isset($post['lmPassword'])) { | ||||
| 				if ($post['lmPassword'] != $post['lmPassword2']) { | ||||
| 					$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'lmPassword'); | ||||
| 					unset ($post['lmPassword2']); | ||||
| 				if (isset($post['lmPassword'])) { | ||||
| 					if ($post['lmPassword'] != $post['lmPassword2']) { | ||||
| 						$errors['lmPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.')); | ||||
| 						unset ($post['lmPassword2']); | ||||
| 						} | ||||
| 						else $this->lmPassword($post['lmPassword']); | ||||
| 					} | ||||
| 					else $this->lmPassword($post['lmPassword']); | ||||
| 				if ($post['rid']== _('Administrator')) { | ||||
| 					$this->attributes['rid'][0] = "500"; | ||||
| 					// Do a check if an administrator already exists
 | ||||
| 					if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 						$errors['rid'][] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.')); | ||||
| 					} | ||||
| 				if ($post['rid']== _('Guest')) { | ||||
| 					$this->attributes['rid'][0] = "501"; | ||||
| 					// Do a check if an administrator already exists
 | ||||
| 					if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 						$errors['rid'][] = array('ERROR', _('Special user'), _('There can be only one guest per domain.')); | ||||
| 					} | ||||
| 				$this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]); | ||||
| 				$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]); | ||||
| 				if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors['smbHome'][] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.')); | ||||
| 				$this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]); | ||||
| 				$this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]); | ||||
| 				if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors['scriptPath'][] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.')); | ||||
| 				$this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]); | ||||
| 				$this->attributes['profilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['profilePath'][0]); | ||||
| 				if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $errors['profilePath'][] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.')); | ||||
| 				if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', | ||||
| 					$this->lmPassword())) $errors['lmPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); | ||||
| 				if ( (!$this->attributes['smbHome'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $this->attributes['smbHome'][0]))) | ||||
| 						$errors['smbHome'][] = array('ERROR', _('Home path'), _('Home path is invalid.')); | ||||
| 				if ( (!$this->attributes['scriptPath'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'. | ||||
| 					'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['scriptPath'][0]))) | ||||
| 					$errors['scriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!')); | ||||
| 				if ( (!$this->attributes['profilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['profilePath'][0])) | ||||
| 					&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['profilePath'][0]))) | ||||
| 						$errors['profilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!')); | ||||
| 				} | ||||
| 			else { | ||||
| 				$smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]); | ||||
| 				$smbHome = str_replace('$group', 'group', $smbHome); | ||||
| 				$scriptPath = str_replace('$user', 'user', $this->attributes['scriptPath'][0]); | ||||
| 				$scriptPath = str_replace('$group', 'group', $scriptPath); | ||||
| 				$profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]); | ||||
| 				$profilePath = str_replace('$group', 'group', $profilePath); | ||||
| 				if ( (!$smbHome=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $smbHome))) | ||||
| 						$errors['smbHome'][] = array('ERROR', _('Home path'), _('Home path is invalid.')); | ||||
| 				if ( (!$scriptPath=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'. | ||||
| 					'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $scriptPath))) | ||||
| 					$errors['scriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!')); | ||||
| 				if ( (!$profilePath=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $profilePath)) | ||||
| 					&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $profilePath))) | ||||
| 						$errors['profilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!')); | ||||
| 				} | ||||
| 
 | ||||
| 			if ($post['useunixpwd']) $this->useunixpwd = true; | ||||
| 				else $this->useunixpwd = false; | ||||
| 
 | ||||
| 			if ($post['rid']== _('Administrator')) { | ||||
| 				$this->attributes['rid'][0] = "500"; | ||||
| 				// Do a check if an administrator already exists
 | ||||
| 				if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 					$errors[] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'), 'rid'); | ||||
| 				} | ||||
| 			if ($post['rid']== _('Guest')) { | ||||
| 				$this->attributes['rid'][0] = "501"; | ||||
| 				// Do a check if an administrator already exists
 | ||||
| 				if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 					$errors[] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'), 'rid'); | ||||
| 				} | ||||
| 			$this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]); | ||||
| 			$this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]); | ||||
| 			if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'), 'smbHome'); | ||||
| 			$this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]); | ||||
| 			$this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]); | ||||
| 			if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors[] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.'), 'scriptPath'); | ||||
| 			$this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]); | ||||
| 			$this->attributes['profilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['profilePath'][0]); | ||||
| 			if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'), 'profilePath'); | ||||
| 			if ( (!$this->attributes['smbHome'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $this->attributes['smbHome'][0]))) | ||||
| 					$errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'smbHome'); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', | ||||
| 				$this->lmPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'lmPassword'); | ||||
| 			if ( (!$this->attributes['scriptPath'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'. | ||||
| 				'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['scriptPath'][0]))) | ||||
| 				$errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'scriptPath'); | ||||
| 			if ( (!$this->attributes['profilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['profilePath'][0])) | ||||
| 				&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['profilePath'][0]))) | ||||
| 					$errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'profilePath'); | ||||
| 			} | ||||
| 
 | ||||
| 		if ((!$this->attributes['domain'][0]=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $this->attributes['domain'][0])) | ||||
| 			$errors[] = array('ERROR', _('Domain name'), _('Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'), 'domain'); | ||||
| 			$errors['domain'][] = array('ERROR', _('Domain name'), _('Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.')); | ||||
| 
 | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		if ($post['userWorkstations'])  return 'userWorkstations'; | ||||
|  | @ -336,48 +366,50 @@ class sambaAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_userWorkstations($post) { | ||||
| 	function proccess_userWorkstations($post, $profile=false) { | ||||
| 		// Load attributes
 | ||||
| 		do { // X-Or, only one if() can be true
 | ||||
| 			if (isset($post['availableUserWorkstations']) && isset($post['userWorkstations_add'])) { // Add workstations to list
 | ||||
| 				$temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 				$workstations = explode (',', $temp); | ||||
| 				for ($i=0; $i<count($workstations); $i++) | ||||
| 					if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 				$workstations = array_values($workstations); | ||||
| 				// Add new // Add workstations
 | ||||
| 				$workstations = array_merge($workstations, $post['availableUserWorkstations']); | ||||
| 				// remove doubles
 | ||||
| 				$workstations = array_flip($workstations); | ||||
| 				array_unique($workstations); | ||||
| 				$workstations = array_flip($workstations); | ||||
| 				// sort workstations
 | ||||
| 				sort($workstations); | ||||
| 				// Recreate workstation string
 | ||||
| 				$this->attributes['userWorkstations'][0] = $workstations[0]; | ||||
| 				for ($i=1; $i<count($workstations); $i++) { | ||||
| 					$this->attributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i]; | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			do { // X-Or, only one if() can be true
 | ||||
| 				if (isset($post['availableUserWorkstations']) && isset($post['userWorkstations_add'])) { // Add workstations to list
 | ||||
| 					$temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 					$workstations = explode (',', $temp); | ||||
| 					for ($i=0; $i<count($workstations); $i++) | ||||
| 						if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 					$workstations = array_values($workstations); | ||||
| 					// Add new // Add workstations
 | ||||
| 					$workstations = array_merge($workstations, $post['availableUserWorkstations']); | ||||
| 					// remove doubles
 | ||||
| 					$workstations = array_flip($workstations); | ||||
| 					array_unique($workstations); | ||||
| 					$workstations = array_flip($workstations); | ||||
| 					// sort workstations
 | ||||
| 					sort($workstations); | ||||
| 					// Recreate workstation string
 | ||||
| 					$this->attributes['userWorkstations'][0] = $workstations[0]; | ||||
| 					for ($i=1; $i<count($workstations); $i++) { | ||||
| 						$this->attributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i]; | ||||
| 						} | ||||
| 					break; | ||||
| 					} | ||||
| 				break; | ||||
| 				} | ||||
| 			if (isset($post['userWorkstations']) && isset($post['userWorkstations_remove'])) { // remove // Add workstations from list
 | ||||
| 				// Put all workstations in array
 | ||||
| 				$temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 				$workstations = explode (',', $temp); | ||||
| 				for ($i=0; $i<count($workstations); $i++) | ||||
| 					if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 				$workstations = array_values($workstations); | ||||
| 				// Remove unwanted workstations from array
 | ||||
| 				$workstations = array_delete($post['userWorkstations'], $workstations); | ||||
| 				// Recreate workstation string
 | ||||
| 				$this->attributes['userWorkstations'][0] = $workstations[0]; | ||||
| 				for ($i=1; $i<count($workstations); $i++) { | ||||
| 					$this->attributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i]; | ||||
| 				if (isset($post['userWorkstations']) && isset($post['userWorkstations_remove'])) { // remove // Add workstations from list
 | ||||
| 					// Put all workstations in array
 | ||||
| 					$temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 					$workstations = explode (',', $temp); | ||||
| 					for ($i=0; $i<count($workstations); $i++) | ||||
| 						if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 					$workstations = array_values($workstations); | ||||
| 					// Remove unwanted workstations from array
 | ||||
| 					$workstations = array_delete($post['userWorkstations'], $workstations); | ||||
| 					// Recreate workstation string
 | ||||
| 					$this->attributes['userWorkstations'][0] = $workstations[0]; | ||||
| 					for ($i=1; $i<count($workstations); $i++) { | ||||
| 						$this->attributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i]; | ||||
| 						} | ||||
| 					break; | ||||
| 					} | ||||
| 				break; | ||||
| 				} | ||||
| 			} while(0); | ||||
| 		if ($post['attributes']) return 'attributes'; | ||||
| 				} while(0); | ||||
| 			if ($post['attributes']) return 'attributes'; | ||||
| 			} | ||||
| 		return 0; | ||||
| 		} | ||||
| 
 | ||||
|  | @ -385,189 +417,136 @@ class sambaAccount { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_attributes($post) { | ||||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			$canchangedate = getdate($this->attributes['pwdCanChange'][0]); | ||||
| 			$mustchangedate = getdate($this->attributes['pwdMustChange'][0]); | ||||
| 			echo	'<input name="pwdCanChange_h" type="hidden" value="'.$canchangedate['hours'].'">'. | ||||
| 				'<input name="pwdCanChange_m" type="hidden" value="'.$canchangedate['minutes'].'">'. | ||||
| 				'<input name="pwdCanChange_s" type="hidden" value="'.$canchangedate['seconds'].'">'. | ||||
| 				'<input name="pwdMustChange_h" type="hidden" value="'.$mustchangedate['hours'].'">'. | ||||
| 				'<input name="pwdMustChange_m" type="hidden" value="'.$mustchangedate['minutes'].'">'. | ||||
| 				'<input name="pwdMustChange_s" type="hidden" value="'.$mustchangedate['seconds'].'">'. | ||||
| 				'<input name="acctFlagsU" type="hidden" value="true">'; | ||||
| 			echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Samba password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"lmPassword\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"" . $this->lmPassword() . "\"></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Repeat password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"lmPassword2\" type=\"password\" size=\"20\" maxlength=\"20\" value=\""; | ||||
| 				if ($post['lmPassword2']!='') echo $post['lmPassword2']; | ||||
| 				else echo $this->lmPassword(); | ||||
| 				echo "\"></td>\n"; | ||||
| 			echo "<td></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) { | ||||
| 				echo "<tr>\n"; | ||||
| 				echo "<td>" . _('Use unix password') . "</td>\n"; | ||||
| 				echo "<td><input name=\"useunixpwd\" type=\"checkbox\""; | ||||
| 					if ($this->useunixpwd) echo " checked "; | ||||
| 					echo "></td>\n"; | ||||
| 				echo "<td><a href=\"../help.php?HelpNumber=428\" target=\"lamhelp\">" . _('Help') . "</a></td>"; | ||||
| 				echo "</tr>\n"; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_h', 'type' => 'hidden', 'value' => $canchangedate['hours']), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_m', 'type' => 'hidden', 'value' => $canchangedate['minutes']), | ||||
| 					2 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_s', 'type' => 'hidden', 'value' => $canchangedate['seconds']), | ||||
| 					3 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_h', 'type' => 'hidden', 'value' => $mustchangedate['hours']), | ||||
| 					4 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']), | ||||
| 					5 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']), | ||||
| 					6 => array ( 'kind' => 'input', 'name' => 'acctFlagsU', 'type' => 'hidden', 'value' => 'true')); | ||||
| 
 | ||||
| 			if (!$profile) { | ||||
| 				if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->lmPassword(); | ||||
| 					else $password=''; | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password)); | ||||
| 				if ($post['lmPassword2']!='') $password2 = $post['lmPassword2']; | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2), | ||||
| 					2 => array ('kind' => 'help', 'value' => 'lmPassword')); | ||||
| 				} | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Use no password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"acctFlagsN\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['acctFlags'][0], "N")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help' ) ."</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Password does not expire') . "</td>\n"; | ||||
| 			echo "<td><input name=\"acctFlagsX\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['acctFlags'][0], "X")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=429\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('User can change password') . "</td>\n"; | ||||
| 			echo "<td><select name=\"pwdCanChange_day\">"; | ||||
| 					for ( $i=1; $i<=31; $i++ ) { | ||||
| 						if ($canchangedate['mday']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"pwdCanChange_mon\">"; | ||||
| 					for ( $i=1; $i<=12; $i++ ) { | ||||
| 						if ($canchangedate['mon'] == $i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"pwdCanChange_yea\">"; | ||||
| 					for ( $i=2003; $i<=2030; $i++ ) { | ||||
| 						if ($canchangedate['year']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=430\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('User must change password') . "</td>\n"; | ||||
| 			echo "<td><select name=\"pwdMustChange_day\">"; | ||||
| 					for ( $i=1; $i<=31; $i++ ) { | ||||
| 						if ($mustchangedate['mday']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"pwdMustChange_mon\">"; | ||||
| 					for ( $i=1; $i<=12; $i++ ) { | ||||
| 						if ($mustchangedate['mon'] == $i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"pwdMustChange_yea\">"; | ||||
| 					for ( $i=2030; $i>=2003; $i-- ) { | ||||
| 						if ($mustchangedate['year']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=431\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" .  _('Account is deactivated') . "</td>\n"; | ||||
| 			echo "<td><input name=\"acctFlagsD\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['acctFlags'][0], "D")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=432\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Home drive') . "</td>\n"; | ||||
| 			echo "<td><select name=\"homeDrive\">"; | ||||
| 				for ($i=90; $i>67; $i--) | ||||
| 					if ($this->attributes['homeDrive'][0]== chr($i).':') echo "<option selected>".chr($i).":</option>"; | ||||
| 						else echo "<option>".chr($i).":</option>"; | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=433\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Home path') . "</td>\n"; | ||||
| 			echo "<td><input name=\"smbHome\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['smbHome'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=437\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Profile path') . "</td>\n"; | ||||
| 			echo "<td><input name=\"profilePath\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['profilePath'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=435\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Script path') . "</td>\n"; | ||||
| 			echo "<td><input name=\"scriptPath\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['scriptPath'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=434\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Samba workstations') . "</td>\n"; | ||||
| 			echo "<td><input name=\"userWorkstations\" type=\"submit\" value=\"" . _('Edit workstations') . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=436\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Windows group') . "</td>\n"; | ||||
| 			echo "<td><select name=\"primaryGroupID\">"; | ||||
| 				// Display if group SID should be mapped to a well kown SID
 | ||||
| 
 | ||||
| 			if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) { | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd), | ||||
| 					2 => array ('kind' => 'help', 'value' => 'useunixpwd')); | ||||
| 				} | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['acctFlags'][0], "N")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use no password') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'acctFlagsN', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'acctFlagsN')); | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['acctFlags'][0], "X")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password does not expire') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'acctFlagsX', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'acctFlagsX')); | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['acctFlags'][0], "D")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Account is deactivated') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'acctFlagsD', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'acctFlagsD')); | ||||
| 			for ( $i=1; $i<=31; $i++ ) $mday[] = $i; | ||||
| 			for ( $i=1; $i<=12; $i++ ) $mon[] = $i; | ||||
| 			for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('User can change password') ), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'pwdCanChange_day', | ||||
| 						'options' => $mday, 'options_selectd' => $canchangedate['mday']), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'pwdCanChange_mon', | ||||
| 						'options' => $mon, 'options_selectd' => $canchangedate['mon']), | ||||
| 					2 => array ( 'kind' => 'select', 'name' => 'pwdCanChange_yes', | ||||
| 						'options' => $year, 'options_selectd' => $canchangedate['year'])))), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'pwdCanChange' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('User must change password') ), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'pwdMustChange_day', | ||||
| 						'options' => $mday, 'options_selectd' => $mustchangedate['mday']), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'pwdMustChange_mon', | ||||
| 						'options' => $mon, 'options_selectd' => $mustchangedate['mon']), | ||||
| 					2 => array ( 'kind' => 'select', 'name' => 'pwdMustChange_yes', | ||||
| 						'options' => $year, 'options_selectd' => $mustchangedate['year'])))), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'pwdMustChange' )); | ||||
| 			for ($i=90; $i>67; $i--) $drives[] = chr($i).':'; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home drive') ), | ||||
| 				1 => array ( 'kind' => 'select', 'name' => 'homeDrive', 'options' => $drives, 'options_selected' => array ($this->attributes['homeDrive'][0])), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'homeDrive' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home path') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'smbHome', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['smbHome'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'smbHome' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Profile path') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'profilePath', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['profilePath'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'profilePath' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Script path') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'scriptPath', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['scriptPath'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'scriptPath' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba workstations') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations', 'value' => _('Edit workstations')), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'userWorkstations' )); | ||||
| 
 | ||||
| 			if (!$profile) { | ||||
| 				$names = array_keys($this->rids); | ||||
| 				$wrid=false; | ||||
| 				for ($i=0; $i<count($names); $i++) { | ||||
| 					if ($this->attributes['primaryGroupID'][0]==$this->rids[$names[$i]]) { | ||||
| 						echo "<option selected>" . $names[$i] . "</option>"; | ||||
| 						$selected[] = $names[$i]; | ||||
| 						$wrid=true; | ||||
| 						} | ||||
| 					else echo "<option>" . $names[$i] . "</option>"; | ||||
| 					else $options[] = $names[$i]; | ||||
| 					} | ||||
| 				if ($wrid) echo "<option>" . $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]) . "</option>"; | ||||
| 					else echo "<option selected>" . $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]) . "</option>"; | ||||
| 				echo	"</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=464\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Special user') . "</td>\n"; | ||||
| 			echo "<td><select name=\"rid\">"; | ||||
| 				if ($wrid) $options[] = $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]); | ||||
| 					else $selected[] = $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]); | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'primaryGroupID', 'options' => $options, 'options_selected' => $selected), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'primaryGroupID' )); | ||||
| 				// Display if group SID should be mapped to a well kown SID
 | ||||
| 				$wrid=false; | ||||
| 				if ($this->attributes['rid'][0]=="500") { | ||||
| 					echo "<option selected>" . _('Administrator') . "</option>"; | ||||
| 					$selected[] = _('Administrator'); | ||||
| 					$wrid=true; | ||||
| 					} | ||||
| 				else echo "<option>" . _('Administrator') . "</option>"; | ||||
| 				else $options[] = _('Administrator'); | ||||
| 				if ($this->attributes['rid'][0]=="501") { | ||||
| 					echo "<option selected>" . _('Guest') . "</option>"; | ||||
| 					$selected[] = _('Guest'); | ||||
| 					$wrid=true; | ||||
| 					} | ||||
| 				else echo "<option>" . _('Guest') . "</option>"; | ||||
| 				if ($wrid) echo "<option>" . _('Ordinary user') . "</option>"; | ||||
| 					else echo "<option selected>" . _('Ordinary user') . "</option>"; | ||||
| 				echo	"</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=XXX\" target=\"lamhelp\">" . _('Help-XX') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Domain') . "</td>\n"; | ||||
| 			echo "<td><input name=\"domain\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['domain'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=438\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "</table>\n"; | ||||
| 				else $options[] = _('Guest'); | ||||
| 				if ($wrid) $options[] = _('Ordinary user'); | ||||
| 					else $selected[] = _('Ordinary user'); | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'rid', 'options' => $options, 'options_selected' => $selected), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'rid' )); | ||||
| 				} | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'domain' )); | ||||
| 			} | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='host') { | ||||
| 			echo '<input name="acctFlagsW" type="hidden" value="true">'; | ||||
| 			echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Reset password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"ResetSambaPassword\" type=\"submit\" value=\"" . _('Reset password') . "\"></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Domain') . "</td>\n"; | ||||
| 			echo "<td><input name=\"domain\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['domain'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=438\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "</table>\n"; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'acctFlagsW', 'type' => 'hidden', 'value' => 'true' )); | ||||
| 			if (!$profile) { | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' )); | ||||
| 				} | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'domain' )); | ||||
| 			} | ||||
| 		return 0; | ||||
| 
 | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  | @ -579,51 +558,33 @@ class sambaAccount { | |||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_userWorkstations($post) { | ||||
| 		// Get list of all hosts.
 | ||||
| 		$result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaAccount', 'host'); | ||||
| 		if (is_array($result)) { | ||||
| 			foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]); | ||||
| 			sort($availableUserWorkstations, SORT_STRING); | ||||
| 			$result = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 			$userWorkstations = explode (',', $result); | ||||
| 			$availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations); | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			// Get list of all hosts.
 | ||||
| 			$result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaAccount', 'host'); | ||||
| 			if (is_array($result)) { | ||||
| 				foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]); | ||||
| 				sort($availableUserWorkstations, SORT_STRING); | ||||
| 				$result = str_replace(' ', '', $this->attributes['userWorkstations'][0]); | ||||
| 				$userWorkstations = explode (',', $result); | ||||
| 				$availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations); | ||||
| 				} | ||||
| 
 | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Allowed workstations"), 'value' => | ||||
| 				array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Allowed workstations"), 'value' => | ||||
| 					array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'userWorkstations[]', 'size' => '15', 'multiple', 'options' => $userWorkstations)))), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations_add', | ||||
| 					'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations_remove', 'value' => '=>' )), | ||||
| 					2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'userWorkstations' )))), | ||||
| 				2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available workstations"), 'value' => | ||||
| 					array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'availableUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $availableUserWorkstations)))) | ||||
| 					)))); | ||||
| 
 | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ), | ||||
| 				1 => array ( 'kind' => 'text'), | ||||
| 				2 => array ('kind' => 'text')); | ||||
| 			} | ||||
| 		echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td valign=\"top\">"; | ||||
| 			echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\"><legend class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo _("Allowed workstations"); | ||||
| 				echo "</legend>\n"; | ||||
| 			// display all workstations the user is allowed to login
 | ||||
| 			if (count($userWorkstations)!=0) { | ||||
| 				echo "<select name=\"userWorkstations[]\" class=\"".$_SESSION[$this->base]->type."edit-bright\" size=15 multiple>\n"; | ||||
| 				for ($i=0; $i<count($userWorkstations); $i++) | ||||
| 					if ($userWorkstations[$i]!='') echo "<option>".$userWorkstations[$i]."</option>\n"; | ||||
| 				echo "</select>\n"; | ||||
| 				} | ||||
| 			echo "</fieldset></td>\n"; | ||||
| 		echo "<td align=\"center\" width=\"10%\"><input type=\"submit\" name=\"userWorkstations_add\" value=\"<=\">"; | ||||
| 			echo " "; | ||||
| 			echo "<input type=\"submit\" name=\"userWorkstations_remove\" value=\"=>\"><br><br>"; | ||||
| 			echo "<a href=\""."../help.php?HelpNumber=436\" target=\"lamhelp\">"._('Help')."</a></td>\n"; | ||||
| 		echo "<td valign=\"top\">"; | ||||
| 			echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\"><legend class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo _('Available workstations'); | ||||
| 				echo "</legend>\n"; | ||||
| 			// Display all workstations without these the user is allowed to login
 | ||||
| 			if (count($availableUserWorkstations)!=0) { | ||||
| 				echo "<select name=\"availableUserWorkstations[]\" size=15 multiple class=\"".$_SESSION[$this->base]->type."edit-bright\">\n"; | ||||
| 				foreach ($availableUserWorkstations as $temp) echo "<option>$temp</option>\n"; | ||||
| 				echo "</select>\n"; | ||||
| 				} | ||||
| 			echo "</fieldset></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td><input name=\"attributes\" type=\"submit\" value=\"" . _('Back') . "\"></td>\n"; | ||||
| 		echo "<td></td>\n"; | ||||
| 		echo "<td></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "</table>\n"; | ||||
| 
 | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	} | ||||
|  |  | |||
|  | @ -118,6 +118,18 @@ class sambaGroupMapping { | |||
| 		return array('attributes'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of sambaGroupMapping and returns | ||||
| 	* also their values. | ||||
|  | @ -187,32 +199,39 @@ class sambaGroupMapping { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 		// Get Domain SID from name
 | ||||
| 		$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); | ||||
| 		for ($i=0; $i<count($sambaDomains); $i++ ) | ||||
| 			if ($post['sambaDomainName'] == $sambaDomains[$i]->name) { | ||||
| 				$SID = $sambaDomains[$i]->SID; | ||||
| 				$RIDbase = $sambaDomain[$i]->RIDbase; | ||||
| 				} | ||||
| 
 | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		// Load attributes
 | ||||
| 		$this->attributes['displayName'][0] = $post['displayName']; | ||||
| 		$this->attributes['sambaGroupType'][0] = 2; | ||||
| 
 | ||||
| 		$rids = array_keys($this->rids); | ||||
| 		$wrid = false; | ||||
| 		for ($i=0; $i<count($rids); $i++) { | ||||
| 			if ($post['sambaSID'] == $rids[$i]) { | ||||
| 				$wrid = true; | ||||
| 				// Get Domain SID
 | ||||
| 				$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]]; | ||||
| 				// Do a check if special grou pis unique
 | ||||
| 				if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group')) | ||||
| 					$errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID'); | ||||
| 		if (!$profile) { | ||||
| 			// Get Domain SID from name
 | ||||
| 			$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); | ||||
| 			for ($i=0; $i<count($sambaDomains); $i++ ) | ||||
| 				if ($post['sambaDomainName'] == $sambaDomains[$i]->name) { | ||||
| 					$SID = $sambaDomains[$i]->SID; | ||||
| 					$RIDbase = $sambaDomain[$i]->RIDbase; | ||||
| 					} | ||||
| 
 | ||||
| 			// Load attributes
 | ||||
| 			$this->attributes['displayName'][0] = $post['displayName']; | ||||
| 			$this->attributes['sambaGroupType'][0] = 2; | ||||
| 
 | ||||
| 			$rids = array_keys($this->rids); | ||||
| 			$wrid = false; | ||||
| 			for ($i=0; $i<count($rids); $i++) { | ||||
| 				if ($post['sambaSID'] == $rids[$i]) { | ||||
| 					$wrid = true; | ||||
| 					// Get Domain SID
 | ||||
| 					$this->attributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]]; | ||||
| 					// Do a check if special grou pis unique
 | ||||
| 					if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group')) | ||||
| 						$errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID'); | ||||
| 					} | ||||
| 				} | ||||
| 			if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1; | ||||
| 			} | ||||
| 		if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1; | ||||
| 
 | ||||
| 		// Return error-messages
 | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		return 0; | ||||
|  | @ -222,7 +241,7 @@ class sambaGroupMapping { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_attributes($post) { | ||||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 		// Get Domain SID from name
 | ||||
| 		$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); | ||||
| 		// Get Domain-SID from group SID
 | ||||
|  | @ -235,42 +254,32 @@ class sambaGroupMapping { | |||
| 				$sel_domain = $sambaDomains[$i]->name; | ||||
| 				} | ||||
| 			} | ||||
| 		echo "<table border=0 width=\"100%\">\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _("Display name") . "</td>\n"; | ||||
| 		echo "<td><input name=\"displayName\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$this->attributes['displayName'][0]."\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=420\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Special group') . "</td>\n"; | ||||
| 		echo "<td><select name=\"sambaSID\">"; | ||||
| 			// Display if group SID should be mapped to a well kown SID
 | ||||
| 			$names = array_keys($this->rids); | ||||
| 			$wrid=false; | ||||
| 			for ($i=0; $i<count($names); $i++) { | ||||
| 				if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) { | ||||
| 					echo "<option selected>" . $names[$i] . "</option>"; | ||||
| 					$wrid=true; | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'displayName' )); | ||||
| 
 | ||||
| 		if (!$profile) { | ||||
| 				$names = array_keys($this->rids); | ||||
| 				$wrid=false; | ||||
| 				for ($i=0; $i<count($names); $i++) { | ||||
| 					if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) { | ||||
| 						$selected[] = $names[$i]; | ||||
| 						$wrid=true; | ||||
| 						} | ||||
| 					else $options[] = $names[$i]; | ||||
| 					} | ||||
| 				else echo "<option>" . $names[$i] . "</option>"; | ||||
| 				} | ||||
| 			if ($wrid) echo "<option>" . $this->attributes['cn'][0] . "</option>"; | ||||
| 				else echo "<option selected>" . $this->attributes['cn'][0] . "</option>"; | ||||
| 			echo	"</select></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=464\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Domain') . "</td>\n"; | ||||
| 		echo "<td><select name=\"sambaDomainName\">"; | ||||
| 			foreach ($sambaDomainNames as $domain) { | ||||
| 				if ($sel_domain==$domain) echo "<option selected>$domain</option>"; | ||||
| 					else echo "<option>$domain</option>"; | ||||
| 				} | ||||
| 			echo "</select></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=467\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "</table>\n"; | ||||
| 		return 0; | ||||
| 				if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0]; | ||||
| 					else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0]; | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); | ||||
| 			} | ||||
| 
 | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), | ||||
| 			1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); | ||||
| 
 | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  |  | |||
|  | @ -150,6 +150,18 @@ class sambaSamAccount { | |||
| 		return array('attributes', 'sambaUserWorkstations'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of posixAccount and returns | ||||
| 	* also their values. | ||||
|  | @ -243,7 +255,7 @@ class sambaSamAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		// Load attributes
 | ||||
| 		$this->attributes['sambaDomainName'][0] = $post['sambaDomainName']; | ||||
| 		// Get Domain SID from name
 | ||||
|  | @ -296,7 +308,7 @@ class sambaSamAccount { | |||
| 				} | ||||
| 			if (!$wrid) $this->attributes['sambaPrimaryGroupSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+$RIDbase+1; | ||||
| 
 | ||||
| 			if (isset($post['sambaLMPassword'])) { | ||||
| 			if (isset($post['sambaLMPassword']) && !$profile) { | ||||
| 				if ($post['sambaLMPassword'] != $post['sambaLMPassword2']) { | ||||
| 					$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'sambaLMPassword'); | ||||
| 					unset ($post['sambaLMPassword2']); | ||||
|  | @ -306,38 +318,58 @@ class sambaSamAccount { | |||
| 			if ($post['useunixpwd']) $this->useunixpwd = true; | ||||
| 				else $this->useunixpwd = false; | ||||
| 
 | ||||
| 			if ($post['sambaSID']== _('Administrator')) { | ||||
| 				$this->attributes['sambaSID'][0] = $SID."-500"; | ||||
| 				// Do a check if an administrator already exists
 | ||||
| 				if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 					$errors[] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'), 'sambaSID'); | ||||
| 			if (!$profile) { | ||||
| 				if ($post['sambaSID']== _('Administrator')) { | ||||
| 					$this->attributes['sambaSID'][0] = $SID."-500"; | ||||
| 					// Do a check if an administrator already exists
 | ||||
| 					if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 						$errors['sambaSID'][] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.')); | ||||
| 					} | ||||
| 				if ($post['sambaSID']== _('Guest')) { | ||||
| 					$this->attributes['sambaSID'][0] = $SID."-501"; | ||||
| 					// Do a check if an administrator already exists
 | ||||
| 					if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 						$errors['sambaSID'][] = array('ERROR', _('Special user'), _('There can be only one guest per domain.')); | ||||
| 					} | ||||
| 				// Check values
 | ||||
| 				$this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]); | ||||
| 				$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]); | ||||
| 				if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors['sambaHomePath'][] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.')); | ||||
| 				$this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]); | ||||
| 				$this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]); | ||||
| 				if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors['sambaLogonScript'][] = array('INFO', _('Logon script'), _('Inserted user- or groupname in logon script.')); | ||||
| 				$this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]); | ||||
| 				$this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]); | ||||
| 				if ($this->attributes['sambaProfiletPath'][0] != stripslashes($post['sambaProfilePath'])) $errors['sambaProfilePath'][] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.')); | ||||
| 				if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0]))) | ||||
| 						$errors['sambaHomePath'][] = array('ERROR', _('Home path'), _('Home path is invalid.')); | ||||
| 				if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', | ||||
| 					$this->sambaLMPassword())) $errors['sambaLMPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); | ||||
| 				if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'. | ||||
| 					'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0]))) | ||||
| 					$errors['sambaScriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!')); | ||||
| 				if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0])) | ||||
| 					&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0]))) | ||||
| 						$errors['sambaProfilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!')); | ||||
| 				} | ||||
| 			if ($post['sambaSID']== _('Guest')) { | ||||
| 				$this->attributes['sambaSID'][0] = $SID."-501"; | ||||
| 				// Do a check if an administrator already exists
 | ||||
| 				if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig) | ||||
| 					$errors[] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'), 'sambaSID'); | ||||
| 			else { | ||||
| 				$sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]); | ||||
| 				$sambaHomePath = str_replace('$group', 'group', $sambaHomePath); | ||||
| 				$sambaLogonScript = str_replace('$user', 'user', $this->attributes['sambaLogonScript'][0]); | ||||
| 				$sambaLogonScript = str_replace('$group', 'group', $sambaLogonScript); | ||||
| 				$sambaProfilePath = str_replace('$user', 'user', $this->attributes['sambaProfilePath'][0]); | ||||
| 				$sambaProfilePath = str_replace('$group', 'group', $sambaProfilePath); | ||||
| 				if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0]))) | ||||
| 						$errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'sambaHomePath'); | ||||
| 				if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', | ||||
| 					$this->sambaLMPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'sambaLMPassword'); | ||||
| 				if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'. | ||||
| 					'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0]))) | ||||
| 					$errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'sambaScriptPath'); | ||||
| 				if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0])) | ||||
| 					&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0]))) | ||||
| 						$errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'sambaProfilePath'); | ||||
| 				} | ||||
| 			// Check values
 | ||||
| 			$this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]); | ||||
| 			$this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]); | ||||
| 			if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'), 'sambaHomePath'); | ||||
| 			$this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]); | ||||
| 			$this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]); | ||||
| 			if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors[] = array('INFO', _('Logon script'), _('Inserted user- or groupname in logon script.'), 'sambaLogonScript'); | ||||
| 			$this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]); | ||||
| 			$this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]); | ||||
| 			if ($this->attributes['sambaProfiletPath'][0] != stripslashes($post['sambaProfilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'), 'sambaProfilePath'); | ||||
| 			if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0]))) | ||||
| 					$errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'sambaHomePath'); | ||||
| 			if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', | ||||
| 				$this->sambaLMPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'sambaLMPassword'); | ||||
| 			if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'. | ||||
| 				'([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0]))) | ||||
| 				$errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'sambaScriptPath'); | ||||
| 			if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0])) | ||||
| 				&& (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0]))) | ||||
| 					$errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'sambaProfilePath'); | ||||
| 			} | ||||
| 		if (is_array($errors)) return $errors; | ||||
| 		if ($post['sambaUserWorkstations'])  return 'sambaUserWorkstations'; | ||||
|  | @ -346,48 +378,50 @@ class sambaSamAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_sambaUserWorkstations($post) { | ||||
| 	function proccess_sambaUserWorkstations($post, $profile=false) { | ||||
| 		// Load attributes
 | ||||
| 		do { // X-Or, only one if() can be true
 | ||||
| 			if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list
 | ||||
| 				$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 				$workstations = explode (',', $temp); | ||||
| 				for ($i=0; $i<count($workstations); $i++) | ||||
| 					if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 				$workstations = array_values($workstations); | ||||
| 				// Add new // Add workstations
 | ||||
| 				$workstations = array_merge($workstations, $post['availableSambaUserWorkstations']); | ||||
| 				// remove doubles
 | ||||
| 				$workstations = array_flip($workstations); | ||||
| 				array_unique($workstations); | ||||
| 				$workstations = array_flip($workstations); | ||||
| 				// sort workstations
 | ||||
| 				sort($workstations); | ||||
| 				// Recreate workstation string
 | ||||
| 				$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; | ||||
| 				for ($i=1; $i<count($workstations); $i++) { | ||||
| 					$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			do { // X-Or, only one if() can be true
 | ||||
| 				if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list
 | ||||
| 					$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 					$workstations = explode (',', $temp); | ||||
| 					for ($i=0; $i<count($workstations); $i++) | ||||
| 						if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 					$workstations = array_values($workstations); | ||||
| 					// Add new // Add workstations
 | ||||
| 					$workstations = array_merge($workstations, $post['availableSambaUserWorkstations']); | ||||
| 					// remove doubles
 | ||||
| 					$workstations = array_flip($workstations); | ||||
| 					array_unique($workstations); | ||||
| 					$workstations = array_flip($workstations); | ||||
| 					// sort workstations
 | ||||
| 					sort($workstations); | ||||
| 					// Recreate workstation string
 | ||||
| 					$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; | ||||
| 					for ($i=1; $i<count($workstations); $i++) { | ||||
| 						$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; | ||||
| 						} | ||||
| 					break; | ||||
| 					} | ||||
| 				break; | ||||
| 				} | ||||
| 			if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
 | ||||
| 				// Put all workstations in array
 | ||||
| 				$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 				$workstations = explode (',', $temp); | ||||
| 				for ($i=0; $i<count($workstations); $i++) | ||||
| 					if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 				$workstations = array_values($workstations); | ||||
| 				// Remove unwanted workstations from array
 | ||||
| 				$workstations = array_delete($post['sambaUserWorkstations'], $workstations); | ||||
| 				// Recreate workstation string
 | ||||
| 				$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; | ||||
| 				for ($i=1; $i<count($workstations); $i++) { | ||||
| 					$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; | ||||
| 				if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
 | ||||
| 					// Put all workstations in array
 | ||||
| 					$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 					$workstations = explode (',', $temp); | ||||
| 					for ($i=0; $i<count($workstations); $i++) | ||||
| 						if ($workstations[$i]=='') unset($workstations[$i]); | ||||
| 					$workstations = array_values($workstations); | ||||
| 					// Remove unwanted workstations from array
 | ||||
| 					$workstations = array_delete($post['sambaUserWorkstations'], $workstations); | ||||
| 					// Recreate workstation string
 | ||||
| 					$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; | ||||
| 					for ($i=1; $i<count($workstations); $i++) { | ||||
| 						$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; | ||||
| 						} | ||||
| 					break; | ||||
| 					} | ||||
| 				break; | ||||
| 				} | ||||
| 			} while(0); | ||||
| 		if ($post['attributes']) return 'attributes'; | ||||
| 				} while(0); | ||||
| 			if ($post['attributes']) return 'attributes'; | ||||
| 			} | ||||
| 		return 0; | ||||
| 		} | ||||
| 
 | ||||
|  | @ -395,7 +429,7 @@ class sambaSamAccount { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_attributes($post) { | ||||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 		// Get Domain SID from name
 | ||||
| 		$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); | ||||
| 		for ($i=0; $i<count($sambaDomains); $i++ ) { | ||||
|  | @ -403,198 +437,132 @@ class sambaSamAccount { | |||
| 			if ($this->attributes['sambaDomainName'][0] == $sambaDomains[$i]->name) | ||||
| 				$SID = $sambaDomains[$i]->SID; | ||||
| 			} | ||||
| 		$canchangedate = getdate($this->attributes['sambaPwdCanChange'][0]); | ||||
| 		$mustchangedate = getdate($this->attributes['sambaPwdMustChange'][0]); | ||||
| 
 | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			$canchangedate = getdate($this->attributes['sambaPwdCanChange'][0]); | ||||
| 			$mustchangedate = getdate($this->attributes['sambaPwdMustChange'][0]); | ||||
| 			echo	'<input name="sambaPwdCanChange_h" type="hidden" value="'.$canchangedate['hours'].'">'. | ||||
| 				'<input name="sambaPwdCanChange_m" type="hidden" value="'.$canchangedate['minutes'].'">'. | ||||
| 				'<input name="sambaPwdCanChange_s" type="hidden" value="'.$canchangedate['seconds'].'">'. | ||||
| 				'<input name="sambaPwdMustChange_h" type="hidden" value="'.$mustchangedate['hours'].'">'. | ||||
| 				'<input name="sambaPwdMustChange_m" type="hidden" value="'.$mustchangedate['minutes'].'">'. | ||||
| 				'<input name="sambaPwdMustChange_s" type="hidden" value="'.$mustchangedate['seconds'].'">'. | ||||
| 				'<input name="sambaAcctFlagsU" type="hidden" value="true">'; | ||||
| 			echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Samba password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaLMPassword\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"" . $this->sambaLMPassword() . "\"></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Repeat password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaLMPassword2\" type=\"password\" size=\"20\" maxlength=\"20\" value=\""; | ||||
| 				if ($post['sambaLMPassword2']!='') echo $post['sambaLMPassword2']; | ||||
| 				else echo $this->sambaLMPassword(); | ||||
| 				echo "\"></td>\n"; | ||||
| 			echo "<td></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) { | ||||
| 				echo "<tr>\n"; | ||||
| 				echo "<td>" . _('Use unix password') . "</td>\n"; | ||||
| 				echo "<td><input name=\"form_sambaAccount_useunixpwd\" type=\"checkbox\""; | ||||
| 					if ($this->useunixpwd) echo " checked "; | ||||
| 					echo "></td>\n"; | ||||
| 				echo "<td><a href=\"../help.php?HelpNumber=428\" target=\"lamhelp\">" . _('Help') . "</a></td>"; | ||||
| 				echo "</tr>\n"; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_h', 'type' => 'hidden', 'value' => $canchangedate['hours']), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_m', 'type' => 'hidden', 'value' => $canchangedate['minutes']), | ||||
| 					2 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_s', 'type' => 'hidden', 'value' => $canchangedate['seconds']), | ||||
| 					3 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_h', 'type' => 'hidden', 'value' => $mustchangedate['hours']), | ||||
| 					4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']), | ||||
| 					5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']), | ||||
| 					6 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true')); | ||||
| 			if (!$profile) { | ||||
| 				if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->sambaLMPassword(); | ||||
| 					else $password=''; | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password)); | ||||
| 				if ($post['sambaLMPassword2']!='') $password2 = $post['sambaLMPassword2']; | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2), | ||||
| 					2 => array ('kind' => 'help', 'value' => 'sambaLMPassword')); | ||||
| 				} | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Use no password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaAcctFlagsN\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['sambaAcctFlags'][0], "N")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help' ) ."</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Password does not expire') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaAcctFlagsX\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['sambaAcctFlags'][0], "X")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=429\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('User can change password') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaPwdCanChange_day\">"; | ||||
| 					for ( $i=1; $i<=31; $i++ ) { | ||||
| 						if ($canchangedate['mday']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"sambaPwdCanChange_mon\">"; | ||||
| 					for ( $i=1; $i<=12; $i++ ) { | ||||
| 						if ($canchangedate['mon'] == $i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"sambaPwdCanChange_yea\">"; | ||||
| 					for ( $i=2003; $i<=2030; $i++ ) { | ||||
| 						if ($canchangedate['year']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=430\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('User must change password') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaPwdMustChange_day\">"; | ||||
| 					for ( $i=1; $i<=31; $i++ ) { | ||||
| 						if ($mustchangedate['mday']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"sambaPwdMustChange_mon\">"; | ||||
| 					for ( $i=1; $i<=12; $i++ ) { | ||||
| 						if ($mustchangedate['mon'] == $i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select><select name=\"sambaPwdMustChange_yea\">"; | ||||
| 					for ( $i=2030; $i>=2003; $i-- ) { | ||||
| 						if ($mustchangedate['year']==$i) echo "<option selected>$i</option>"; | ||||
| 							else echo "<option>$i</option>"; | ||||
| 						} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=431\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" .  _('Account is deactivated') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaAcctFlagsD\" type=\"checkbox\""; | ||||
| 				if (strpos($this->attributes['sambaAcctFlags'][0], "D")) echo " checked "; | ||||
| 				echo "></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=432\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Home drive') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaHomeDrive\">"; | ||||
| 				for ($i=90; $i>67; $i--) | ||||
| 					if ($this->attributes['sambaHomeDrive'][0]== chr($i).':') echo "<option selected>".chr($i).":</option>"; | ||||
| 						else echo "<option>".chr($i).":</option>"; | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=433\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Home path') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaHomePath\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['sambaHomePath'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=437\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Profile path') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaProfilePath\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['sambaProfilePath'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=435\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Logon script') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaLogonScript\" type=\"text\" size=\"20\" maxlength=\"80\" value=\"" . $this->attributes['sambaLogonScript'][0] . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=434\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Samba workstations') . "</td>\n"; | ||||
| 			echo "<td><input name=\"sambaUserWorkstations\" type=\"submit\" value=\"" . _('Edit workstations') . "\"></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=436\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Windows group') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaPrimaryGroupSID\">"; | ||||
| 				// Display if group SID should be mapped to a well kown SID
 | ||||
| 			if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) { | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use unix password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd), | ||||
| 					2 => array ('kind' => 'help', 'value' => 'useunixpwd')); | ||||
| 				} | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['sambaAcctFlags'][0], "N")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use no password') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsN', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'sambaAcctFlagsN')); | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['sambaAcctFlags'][0], "X")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password does not expire') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsX', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'sambaAcctFlagsX')); | ||||
| 			$checked = false; | ||||
| 			if (strpos($this->attributes['sambaScctFlags'][0], "D")) $checked = true; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Account is deactivated') ), | ||||
| 				1 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsD', 'type' => 'checkbox', 'checked' => $checked), | ||||
| 				2 => array ('kind' => 'help', 'value' => 'sambaAcctFlagsD')); | ||||
| 			for ( $i=1; $i<=31; $i++ ) $mday[] = $i; | ||||
| 			for ( $i=1; $i<=12; $i++ ) $mon[] = $i; | ||||
| 			for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('User can change password') ), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'sambaPwdCanChange_day', | ||||
| 						'options' => $mday, 'options_selectd' => $canchangedate['mday']), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'sambaPwdCanChange_mon', | ||||
| 						'options' => $mon, 'options_selectd' => $canchangedate['mon']), | ||||
| 					2 => array ( 'kind' => 'select', 'name' => 'sambaPwdCanChange_yes', | ||||
| 						'options' => $year, 'options_selectd' => $canchangedate['year'])))), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaPwdCanChange' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('User must change password') ), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'sambaPwdMustChange_day', | ||||
| 						'options' => $mday, 'options_selectd' => $mustchangedate['mday']), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'sambaPwdMustChange_mon', | ||||
| 						'options' => $mon, 'options_selectd' => $mustchangedate['mon']), | ||||
| 					2 => array ( 'kind' => 'select', 'name' => 'sambaPwdMustChange_yes', | ||||
| 						'options' => $year, 'options_selectd' => $mustchangedate['year'])))), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaPwdMustChange' )); | ||||
| 			for ($i=90; $i>67; $i--) $drives[] = chr($i).':'; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home drive') ), | ||||
| 				1 => array ( 'kind' => 'select', 'name' => 'sambaHomeDrive', 'options' => $drives, 'options_selected' => array ($this->attributes['sambaHomeDrive'][0])), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaHomeDrive' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home path') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'sambaHomePath', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['sambaHomePath'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaHomePath' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Profile path') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'sambaProfilePath', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['sambaProfilePath'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaProfilePath' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Logon script') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'sambaLogonScript', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['sambaLogonScript'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaLogonScript' )); | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba workstations') ), | ||||
| 				1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations', 'value' => _('Edit workstations')), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' )); | ||||
| 
 | ||||
| 			if (!$profile) { | ||||
| 				$names = array_keys($this->rids); | ||||
| 				$wrid=false; | ||||
| 				for ($i=0; $i<count($names); $i++) { | ||||
| 					if ($this->attributes['sambaPrimaryGroupSID'][0]==$SID."-".$this->rids[$names[$i]]) { | ||||
| 						echo "<option selected>" . $names[$i] . "</option>"; | ||||
| 						$selected[] = $names[$i]; | ||||
| 						$wrid=true; | ||||
| 						} | ||||
| 					else echo "<option>" . $names[$i] . "</option>"; | ||||
| 					else $options[] = $names[$i]; | ||||
| 					} | ||||
| 				if ($wrid) echo "<option>" . $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]) . "</option>"; | ||||
| 					else echo "<option selected>" . $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]) . "</option>"; | ||||
| 				echo	"</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=464\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Special user') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaSID\">"; | ||||
| 				if ($wrid) $options[] = $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]); | ||||
| 					else $selected[] = $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]); | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'sambaPrimaryGroupSID', 'options' => $options, 'options_selected' => $selected), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'sambaPrimaryGroupSID' )); | ||||
| 				// Display if group SID should be mapped to a well kown SID
 | ||||
| 				$wrid=false; | ||||
| 				if ($this->attributes['sambaSID'][0]==$SID."-500") { | ||||
| 					echo "<option selected>" . _('Administrator') . "</option>"; | ||||
| 					$selected[] = _('Administrator'); | ||||
| 					$wrid=true; | ||||
| 					} | ||||
| 				else echo "<option>" . _('Administrator') . "</option>"; | ||||
| 				if ($this->attributes['sambaSID'][0]==$SID."-501") { | ||||
| 					echo "<option selected>" . _('Guest') . "</option>"; | ||||
| 				else $options[] = _('Administrator'); | ||||
| 				if ($this->attributes['sambaSID'][0]==$SIM."-501") { | ||||
| 					$selected[] = _('Guest'); | ||||
| 					$wrid=true; | ||||
| 					} | ||||
| 				else echo "<option>" . _('Guest') . "</option>"; | ||||
| 				if ($wrid) echo "<option>" . _('Ordinary user') . "</option>"; | ||||
| 					else echo "<option selected>" . _('Ordinary user') . "</option>"; | ||||
| 				echo	"</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=XXX\" target=\"lamhelp\">" . _('Help-XX') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Domain') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaDomainName\">"; | ||||
| 				foreach ($sambaDomainNames as $domain) { | ||||
| 					if ($this->attributes['sambaDomainName'][0]==$domain) echo "<option selected>$domain</option>"; | ||||
| 						else "<option>$domain</option>"; | ||||
| 					} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=438\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "</table>\n"; | ||||
| 				else $options[] = _('Guest'); | ||||
| 				if ($wrid) $options[] = _('Ordinary user'); | ||||
| 					else $selected[] = _('Ordinary user'); | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ), | ||||
| 					1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); | ||||
| 				} | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), | ||||
| 				1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array($this->attributes['sambaDomainName'][0])), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); | ||||
| 			} | ||||
| 		if ($_SESSION[$this->base]->type=='host') { | ||||
| 			echo '<input name="sambaAcctFlagsW" type="hidden" value="true">'; | ||||
| 			echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Reset password') . "</td>\n"; | ||||
| 			echo "<td><input name=\"ResetSambaPassword\" type=\"submit\" value=\"" . _('Reset password') . "\"></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "<tr>\n"; | ||||
| 			echo "<td>" . _('Domain') . "</td>\n"; | ||||
| 			echo "<td><select name=\"sambaDomainName\">"; | ||||
| 				foreach ($sambaDomainNames as $domain) { | ||||
| 					if ($this->attributes['sambaDomainName'][0]==$domain) echo "<option selected>$domain</option>"; | ||||
| 						else "<option>$domain</option>"; | ||||
| 					} | ||||
| 				echo "</select></td>\n"; | ||||
| 			echo "<td><a href=\"../help.php?HelpNumber=438\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 			echo "</tr>\n"; | ||||
| 			echo "</table>\n"; | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsW', 'type' => 'hidden', 'value' => 'true' )); | ||||
| 			if (!$profile) { | ||||
| 				$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ), | ||||
| 					1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'), | ||||
| 					2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' )); | ||||
| 				} | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), | ||||
| 				1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $this->attributes['sambaDomainName'][0]), | ||||
| 				2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); | ||||
| 			} | ||||
| 		return 0; | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  | @ -605,52 +573,33 @@ class sambaSamAccount { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_sambaUserWorkstations($post) { | ||||
| 		// Get list of all hosts.
 | ||||
| 		$result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaSamAccount', 'host'); | ||||
| 		if (is_array($result)) { | ||||
| 			foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]); | ||||
| 			sort($availableUserWorkstations, SORT_STRING); | ||||
| 			$result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 			$userWorkstations = explode (',', $result); | ||||
| 			$availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations); | ||||
| 	function display_html_sambaUserWorkstations($post, $profile=false) { | ||||
| 		if ($_SESSION[$this->base]->type=='user') { | ||||
| 			// Get list of all hosts.
 | ||||
| 			$result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaSamAccount', 'host'); | ||||
| 			if (is_array($result)) { | ||||
| 				foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]); | ||||
| 				sort($availableUserWorkstations, SORT_STRING); | ||||
| 				$result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); | ||||
| 				$userWorkstations = explode (',', $result); | ||||
| 				$availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations); | ||||
| 				} | ||||
| 
 | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Allowed workstations"), 'value' => | ||||
| 				array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Allowed workstations"), 'value' => | ||||
| 					array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'sambaUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $userWorkstations)))), | ||||
| 				1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_add', | ||||
| 					'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_remove', 'value' => '=>' )), | ||||
| 					2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' )))), | ||||
| 				2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available workstations"), 'value' => | ||||
| 					array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'availableSambaUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $availableUserWorkstations)))) | ||||
| 					)))); | ||||
| 
 | ||||
| 			$return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ), | ||||
| 				1 => array ( 'kind' => 'text'), | ||||
| 				2 => array ('kind' => 'text')); | ||||
| 			} | ||||
| 		echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td valign=\"top\">"; | ||||
| 			echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\"><legend class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo _("Allowed workstations"); | ||||
| 				echo "</legend>\n"; | ||||
| 			// display all workstations the user is allowed to login
 | ||||
| 			if (count($userWorkstations)!=0) { | ||||
| 				echo "<select name=\"sambaUserWorkstations[]\" class=\"".$_SESSION[$this->base]->type."edit-bright\" size=15 multiple>\n"; | ||||
| 				for ($i=0; $i<count($userWorkstations); $i++) | ||||
| 					if ($userWorkstations[$i]!='') echo "<option>".$userWorkstations[$i]."</option>\n"; | ||||
| 				echo "</select>\n"; | ||||
| 				} | ||||
| 			echo "</fieldset></td>\n"; | ||||
| 		echo "<td align=\"center\" width=\"10%\"><input type=\"submit\" name=\"sambaUserWorkstations_add\" value=\"<=\">"; | ||||
| 			echo " "; | ||||
| 			echo "<input type=\"submit\" name=\"sambaUserWorkstations_remove\" value=\"=>\"><br><br>"; | ||||
| 			echo "<a href=\""."../help.php?HelpNumber=436\" target=\"lamhelp\">"._('Help')."</a></td>\n"; | ||||
| 		echo "<td valign=\"top\">"; | ||||
| 			echo "<fieldset class=\"".$_SESSION[$this->base]->type."edit-bright\"><legend class=\"".$_SESSION[$this->base]->type."edit-bright\">"; | ||||
| 				echo _('Available workstations'); | ||||
| 				echo "</legend>\n"; | ||||
| 			// Display all workstations without these the user is allowed to login
 | ||||
| 			if (count($availableUserWorkstations)!=0) { | ||||
| 				echo "<select name=\"availableSambaUserWorkstations[]\" size=15 multiple class=\"".$_SESSION[$this->base]->type."edit-bright\">\n"; | ||||
| 				foreach ($availableUserWorkstations as $temp) echo "<option>$temp</option>\n"; | ||||
| 				echo "</select>\n"; | ||||
| 				} | ||||
| 			echo "</fieldset></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td><input name=\"attributes\" type=\"submit\" value=\"" . _('Back') . "\"></td>\n"; | ||||
| 		echo "<td></td>\n"; | ||||
| 		echo "<td></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "</table>\n"; | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	} | ||||
|  |  | |||
|  | @ -111,6 +111,18 @@ class shadowAccount { | |||
| 		return array('attributes'); | ||||
| 		} | ||||
| 
 | ||||
| 	/* | ||||
| 	*/ | ||||
| 	function get_help($id) { | ||||
| 		switch ($id) { | ||||
| 			case "description": | ||||
| 				return array ("ext" => "FALSE", "Headline" => _("Description"), | ||||
| 					"Text" => _("Host Description.")); | ||||
| 				break; | ||||
| 			} | ||||
| 		return false; | ||||
| 		} | ||||
| 
 | ||||
| 	/* This function returns all ldap attributes | ||||
| 	* which are part of shadowAccount and returns | ||||
| 	* also their values. | ||||
|  | @ -168,7 +180,7 @@ class shadowAccount { | |||
| 
 | ||||
| 	/* Write variables into object and do some regexp checks | ||||
| 	*/ | ||||
| 	function proccess_attributes($post) { | ||||
| 	function proccess_attributes($post, $profile=false) { | ||||
| 		// Load attributes
 | ||||
| 		$this->attributes['shadowMin'][0] = $post['shadowMin']; | ||||
| 		$this->attributes['shadowMax'][0] = $post['shadowMax']; | ||||
|  | @ -191,51 +203,36 @@ class shadowAccount { | |||
| 	* to show a page with all attributes. | ||||
| 	* It will output a complete html-table | ||||
| 	*/ | ||||
| 	function display_html_attributes($post) { | ||||
| 	function display_html_attributes($post, $profile=false) { | ||||
| 		// Use dd-mm-yyyy format of date because it's easier to read for humans
 | ||||
| 		$date = getdate ($this->attributes['shadowExpire'][0]*3600*24); | ||||
| 		echo "<table border=0 width=\"100%\">\n<tr>\n"; | ||||
| 		echo "<td>" . _('Password warn') . "</td>\n"; | ||||
| 		echo "<td><input name=\"shadowWarning\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"" . $this->attributes['shadowWarning'][0] . "\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=414\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Password Expire') . "</td>\n"; | ||||
| 		echo "<td><input name=\"shadowInactive\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"" . $this->attributes['shadowInactive'][0] . "\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=415\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Maximum password age') . "</td>\n"; | ||||
| 		echo "<td><input name=\"shadowMax\" type=\"text\" size=\"5\" maxlength=\"5\" value=\"" . $this->attributes['shadowMax'][0] . "\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=416\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Minimum password age') . "</td>\n"; | ||||
| 		echo "<td><input name=\"shadowMin\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"" . $this->attributes['shadowMin'][0] . "\"></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=417\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "<tr>\n"; | ||||
| 		echo "<td>" . _('Expire date') . "</td>\n"; | ||||
| 		echo "<td><select name=\"shadowExpire_day\">"; | ||||
| 			for ( $i=1; $i<=31; $i++ ) { | ||||
| 				if ($date['mday']==$i) echo "<option selected>$i</option>"; | ||||
| 				else echo "<option>$i</option>"; | ||||
| 				} | ||||
| 			echo "</select>\n<select name=\"shadowExpire_mon\">"; | ||||
| 			for ( $i=1; $i<=12; $i++ ) { | ||||
| 				if ($date['mon'] == $i) echo "<option selected>$i</option>"; | ||||
| 				else echo "<option>$i</option>"; | ||||
| 				} | ||||
| 			echo "</select>\n<select name=\"shadowExpire_yea\">"; | ||||
| 			for ( $i=2030; $i>=2003; $i-- ) { | ||||
| 				if ($date['year']==$i) echo "<option selected>$i</option>"; | ||||
| 				else echo "<option>$i</option>"; | ||||
| 				} | ||||
| 			echo "</select></td>\n"; | ||||
| 		echo "<td><a href=\"../help.php?HelpNumber=418\" target=\"lamhelp\">" . _('Help') . "</a></td>\n"; | ||||
| 		echo "</tr>\n"; | ||||
| 		echo "</table>\n"; | ||||
| 		return 0; | ||||
| 
 | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password warn') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowWarning'][0] ), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'shadowWarning' )); | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password expire') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowInactive'][0] ), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'shadowInactive' )); | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Maximum password age') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMax'][0] ), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'shadowMax' )); | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Minimum password age') ), | ||||
| 			1 => array ( 'kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMin'][0] ), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'shadowMin' )); | ||||
| 
 | ||||
| 		for ( $i=1; $i<=31; $i++ ) $mday[] = $i; | ||||
| 		for ( $i=1; $i<=12; $i++ ) $mon[] = $i; | ||||
| 		for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; | ||||
| 		$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Expire day') ), | ||||
| 			1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'shadowExpire_day', | ||||
| 					'options' => $mday, 'options_selectd' => $date['mday']), | ||||
| 				1 => array ( 'kind' => 'select', 'name' => 'shadowExpire_mon', | ||||
| 					'options' => $mon, 'options_selectd' => $date['mon']), | ||||
| 				2 => array ( 'kind' => 'select', 'name' => 'shadowExpire_yea', | ||||
| 					'options' => $year, 'options_selectd' => $date['year'])))), | ||||
| 			2 => array ( 'kind' => 'help', 'value' => 'shadowExpire' )); | ||||
| 
 | ||||
| 		return $return; | ||||
| 		} | ||||
| 
 | ||||
| 	function display_html_delete($post) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue