Location: PHPKode > projects > FtpREadmin > ftpreadmin-0.2/secure.php
<?php
/* ftpREadmin (ProFTPd MySQL Admin with Quota), Copyright (C) 2008 Vaidotas Gaidelis
 * ftpREadmin comes with ABSOLUTELY NO WARRANTY.
 * This is free software, and you are welcome to redistribute it
 * under the terms of the GNU General Public License.
 * Read 'COPYING' for further information.
 */
 
try {
	/* Include config and main class */
	require_once('config/config.inc.php');
	require_once('class/ftpREadmin.class.php');
	$ftpadmin = new ftpREadmin($confArr);
	
	/* Verify the user has login, otherwise redirect to login page */
	if ($ftpadmin->verifyAccess()) {
		switch ($_GET['pg']) {
			case "users":
				$title = "users";
				$header = "users";
				$section = "User List";
				
				switch($_GET['action']) {
						/* Edit user, call editFtpUser() method */
						case "edit":
						$title = "edit user";
						$header = "edit user";
						$section = "Edit user";
						$content = $ftpadmin->editFtpUser($_GET['ftpUserId']);
					break;
					/* Delete user, call deleteFtpUser() method */
					case "delete":
						$content = $ftpadmin->deleteFtpUser($_GET['ftpUserId']);
						$content .= $ftpadmin->getFtpUsers();
					break;
					/* Update user, call updateFtpUser() method */
					case "update":
						$content = $ftpadmin->updateFtpUser($_POST['ftpUserId'],
							$_POST['username'], $_POST['passwd'], $_POST['comment'],
							$_POST['quota_type'], $_POST['per_session'],
							$_POST['limit_type'], $_POST['bytes_in_avail'],
							$_POST['quota_in_units'], $_POST['bytes_out_avail'],
							$_POST['quota_out_units'], $_POST['bytes_xfer_avail'],
							$_POST['xfer_units']);
						$content .= $ftpadmin->getFtpUsers();
					break;
					default:
						$content = $ftpadmin->getFtpUsers();
					break;
				}
			break;
			case "add_user":
				$title = "add user";
				$header = "add user";
				$section = "Add new FTP user";
				
				/* if form has been submitted add new user */
				if (isset($_POST['submit'])) {
					$content = $ftpadmin->addFtpUser(
							$_POST['userid'], $_POST['passwd'],
							$_POST['homedir'], $_POST['comment'],
							$_POST['quota_type'], $_POST['per_session'],
							$_POST['limit_type'], $_POST['bytes_in_avail'],
							$_POST['quota_in_units'], $_POST['bytes_out_avail'],
							$_POST['quota_out_units'], $_POST['bytes_xfer_avail'],
							$_POST['xfer_units']);
					$content .= $ftpadmin->showAddFtpUserForm();
				} else {
					$content = $ftpadmin->showAddFtpUserForm();
				}
			break;
			/* Show user stats from ftpquotatallies table */
			case "stats":
				$title = "user stats";
				$header = "user stats";
				$section = "User activity stats";
			    $content = $ftpadmin->getFtpUsersStats();
			break;
			case "settings":
				$title = "settings";
				$header = "settings";
				$section = "ftpREadmin settings";
				
				/* if action is unban, unban IP */
				if($_GET['action'] == 'unban') {
					$content = $ftpadmin->removeBan($_GET['bannedIP']);
				}
				/* if form has been submitted, change admin's settings */
				if(isset($_POST['submit'])) {
					$content = $ftpadmin->updateFtpAdmin(
								$_POST['user_id'],
								$_POST['username'],
								$_POST['password']
							   );
				}
				
				$content .= $ftpadmin->ftpREadminSettings();
			break;
			/* Log out of ftpREadmin */
			case "log_out":
				$content = $ftpadmin->logOut();
				break;
			default:
				$title = "users";
				$header = "users";
				$section = "User List";
				$content = $ftpadmin->getFtpUsers();
			break;
		}
		/* Include template */
		require_once('template/template.tpl.php');
	}
}
catch(Exception $error) {
	print $error->getMessage();
}
?>
Return current item: FtpREadmin