Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/personal/userset.phps
<?
// If data is set (i.e the submit button has been hit)
if (isset($data)) {
	if (is_array($data)) {
		// remove spaces and slashes.
		while (list($key, $val) = each($data))
			$data[$key] = trim(stripslashes($val));
		
		// HARDCODED $data['uid'], 'id'
		$data['uid'] = $personaldata['username'];
		$data['id'] = $personaldata['id'];

		$error = user("update",$data);
		if ($error)
			echo "<br>&nbsp;&nbsp;&bull; ".implode("<br>\n&nbsp;&nbsp;&bull; ",$error)."<br>\n";
		else {
			// if username / skin / lang changed, display a message & reload.
			if ($data['username'] != $personaldata['username']
				OR $data['skin'] != $personaldata['skin']
				OR $data['lang'] != $personaldata['lang']) {
				echo "<br><div align='center'><b>".$T['user updated reload']."</b></div><br>
<script language='JavaScript1.3'>
<!-- 
load_url('./?cp=$cp&url=$url&number=$number&user=".$data['username']."&confirm=".time()."')
// -->
</script>";
			}
			else
				echo "<br><div align='center'><b>".$T['user updated']."</b></div><br>\n";
			
			// update $personaldata
			$personaldata = fetchdata("*","user",$data['username']);
		}
	}
}
// If we're back from a reload (i.e confirm is set), display message.
if ($confirm)
	echo "<br><div align='center'><b>".$T['user updated']."</b></div><br>\n";
?>

<div align="center">
<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
<table border="0" cellspacing="0" cellpadding="0"><tr><td>
<table border="0" cellspacing="0" cellpadding="0" class="tblbg">
	<tr>
		<td>
		<table border="0" cellspacing="1">
			<tr>
				<td colspan="2" class="tbltop">&nbsp;<?=$T[$cp][$url];?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Full Name'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<input type="text" name="data[name]" size="30" maxlength="255" value="<?=$personaldata['name'];?>">&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Username'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<? if ($userdata['level'] < 4) { ?><input type="text" name="data[username]" size="30" maxlength="255" value="<?=$personaldata['username'];?>"><? } else echo $personaldata['username']; ?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Password'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<input type="text" name="data[password]" size="15" maxlength="25" value="<? if ($userdata['level'] <= 1 AND $userdata['type'] != 'demo' AND $cfg['ssl']) echo $personaldata['password'];?>">&nbsp;&nbsp;<?=$T['confirm'];?> <input type="checkbox" name="data[pass_confirm]" value="1">&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['User Root Directory'];?>&nbsp;</b></td>
			<? // get dir listing to get possible user roots
				$i = 0;
				unset($dir_info);
				// get default values
				$tmp = str_replace($cfg['webdir']."/".$personaldata['id'],"",$personaldata['root']);
				$tmp = ereg_replace("/+","/",$tmp);
				if (!$tmp) $tmp = "/";
				$dir_info[$i++] = $tmp;
				$dir_info[$i++] = "";
				
				// get dir data
				$tmp_array = dirlist($cfg['webdir']."/".$personaldata['id']."/","dir");
				
				//make it all look nice
				do {
					$tmp = str_replace($cfg['webdir']."/".$personaldata['id'],"",current($tmp_array));
					$tmp = ereg_replace("/+","/",$tmp);
					if ($tmp) $dir_info[$i++] = $tmp;
				} while (next($tmp_array));
					
			?>
			
				<td class="row2">
				&nbsp;<? 
				if ($userdata['level'] < 4) {
					echo '<select name="data[root]">';
					$i = 0;
					while (isset($dir_info[$i])) {
						echo '<option value="'.$dir_info[$i].'"> ';
						$tmp = $dir_info[$i];
						if (strlen($tmp) > 25)
							$tmp = substr($tmp, 0, 5)."[..]".substr($tmp, strlen($tmp)-16, 16);
						else
							$tmp =  $dir_info[$i];
						echo "$tmp</option>\n";
						++$i;
					}
					echo '</select>';
				}
				else echo $dir_info[0];
			?>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Access Level'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<select name="data[level]">
				<? for ($i=4; $i>=$userdata['level'];$i--) {
					echo '<option value="'.$i.'"';
					if ($personaldata['level'] == $i) echo " selected";
					echo "> ".$T['userlvl'][$i]."</option>\n";
				} ?>
                           </select>
                           &nbsp;</td>
			</tr>
			<?
			// display possible IP Restrictions
			$tmp = explode('.',$REMOTE_ADDR);
			$row[0] = "";
			$row[1] = $tmp[0].'.';
			$row[2] = $tmp[0].'.'.$tmp[1].'.';
			$row[3] = $tmp[0].'.'.$tmp[1].'.'.$tmp[2].'.';
			$row[4] = $tmp[0].'.'.$tmp[1].'.'.$tmp[2].'.'.$tmp[3];
			if ($personaldata['ip_restrict'])
				$ipr[$personaldata['ip_restrict']] = ' checked';
			?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['IP Restriction'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<select name="data[ip_restrict]">
				<? for ($i=0; $i <=4; $i++) {
					echo "<option value='".$row[$i]."'";
					if ($personaldata['ip_restrict'] == $row[$i]) echo ' selected';
					if ($row[$i])
						echo "> ".$row[$i]."</option>\n";
					else
						echo "> ".$T['none']."</option>\n";
				} ?></select>&nbsp;</td>
			</tr>
			<? // Get domain data
			$domaindata = fetchdata("shell","domain",$personaldata['id']);
			
				if ($domaindata['shell'] == "on") {
					$check[$personaldata['shell']] = ' checked';
					?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Shell Access'];?>&nbsp;</b></td>
				<td class="row2">
				<? if ($userdata['level'] < 4) {?>
				&nbsp;<input type="radio" name="data[shell]" value="on"<?=$check['on'];?>><?=$T['on'];?>
				<input type="radio" name="data[shell]" value="off"<?=$check['off'];?>><?=$T['off'];?>&nbsp;
				<? } else { 
					echo $personaldata['shell'];
				}
				?>
				</td>
			</tr>
			<? } ?>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Hard Disk Space'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<?=$personaldata['hd_used'];?> / <? if ($userdata['level'] < 4) { ?><input type="text" name="data[hd]" size="4" maxlength="10" value="<?=$personaldata['hd'];?>"><? } else echo $personaldata['hd'];?> (<?=(round($personaldata['hd_used'] / $personaldata['hd'] * 100,2));?>%)&nbsp;</td>
			</tr>
			<tr>
			<? // get available languages
				if (strstr($cfg['lang'],",")) {
					$language = explode(",",$cfg['lang']);
				}
				else $language[1] = $cfg['lang'];
				?>
				<td class="row1"><b>&nbsp;<?=$T['Language'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<select name="data[lang]">
				<? do {
					echo '<option value="'.trim(current($language)).'"';
					if (current($language) == $personaldata['lang']) echo " SELECTED";
					echo '> '.$T[current($language)].'</option>';
					echo "\n";
				} while(next($language)); ?>
                           </select>&nbsp;</td>
			</tr>
			<tr>
				<td class="row1"><b>&nbsp;<?=$T['Default Page'];?>&nbsp;</b>
				<div align="right">&nbsp;<?=$T['Reset'];?><input type="checkbox" name="bookmark" value="reset">&nbsp;</div></td>
				<td class="row2">
				<? // check & parse user's default page
					if ($personaldata['favorites']) {
						$tmp = explode(":",$personaldata['favorites']);
						$fav_cp = $T['menu'][$tmp[0]];
						$fav_url = $T[$tmp[0]][$tmp[1]];
				   	}
				   	else {
				  		$fav_cp = $T['none'];
				  		$fav_url = $T['none'];
				   	}
				?>
				<table border="0" cellpadding="0" summary="">
					<tr>
						<td class="row2">&nbsp;<?=$T['Panel'];?>&nbsp;</td>
						<td class="row2">&nbsp;<?=$fav_cp;?>&nbsp;</td>
					</tr>
					<tr>
						<td class="row2">&nbsp;<?=$T['Page'];?>&nbsp;</td>
						<td class="row2">&nbsp;<?=$fav_url;?>&nbsp;</td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<? 				
					// fetch reseller data to check any limitation on skin usage
					$rdata = fetchdata("skin","reseller",$personaldata['id']);

					// Check if a skin list exists, if so parse it.  Else use default skin.
					if (file_exists("skin/list")) {
						unset($skin_info);
						$i = 0;
						$j = 0;
						$tmp = file("skin/list");
						while ($tmp[$i]) {
							
							$tmp_info = split("[[:space:]]+",$tmp[$i]);
							if (count($tmp_info) >= 2) {
								if ($rdata['skin'] == "any" OR $rdata['skin'] == $tmp_info[0]) {
									
									$skin_info[$j]['dir'] = array_shift($tmp_info);
									if (count($tmp_info) > 1)
										$skin_info[$j]['name'] = implode(" ",$tmp_info);
									else
										$skin_info[$j]['name'] = $tmp_info[0];
									++$j;
								}
							}
							++$i;
						}
	
						// Check if we actually got anything.
						if (count($skin_info) < 1) {
							unset($skin_info);
							$skin_info[0]['dir'] = $cfg['defaultskin'];
							$skin_info[0]['name'] = $cfg['defaultskin'];
						}
					}
					else {
						$skin_info[0]['dir'] = $cfg['defaultskin'];
						$skin_info[0]['name'] = $cfg['defaultskin'];
					}
				?>
				<td class="row1"><b>&nbsp;<?=$T['Interface Look'];?>&nbsp;</b></td>
				<td class="row2">&nbsp;<select name="data[skin]">
				<? // print skin choice(s)
					$i = 0;
					while ($skin_info[$i]) {
						echo '<option value="'.$skin_info[$i]['dir'].'"';
						if ($personaldata['skin'] == $skin_info[$i]['dir']) echo " SELECTED";
						echo '> '.$skin_info[$i]['name'].'</option>';
						echo "\n";
						++$i;
					}
				?>
                           </select>&nbsp;</td>
			</tr>
		</table>
		
		</td>
	</tr>
</table>
<br><div align="right"><input type="submit" value="<?=$T['Update User'];?>"></div>
</td></tr></table>
</form></div>

Return current item: web-cp - Web Hosting Control Panel