Location: PHPKode > projects > Murmuradmin > forgot.php
<?php
/*  Murmur WebAdministrator - Administration of Murmur Server on web for end users.
    Copyright (C) 2009  Kevin Traub

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

include 'config.php';
include 'functions.php';

echo basecss();
echo basemenu($logged, $meta, $serverid);

switch ($_POST['Reset Password']) {
	case 'Register' :
		$username = "0";
		$email = "0";
		$serverid = ($_REQUEST['server']);
		$server = $meta->getServer($serverid + 0);
		if (isset($_REQUEST['username'])) {
			$username = $_REQUEST['username'];
			}

		// Get server info
		$servername = $server->getConf("registername");
		$serverport = $server->getConf("port");
		$serverhost = $server->getConf("host");
		if (empty($serverhost)) {
			$default = $meta->getDefaultConf();
			$serverhost = $default['host'];
		}
		// Test to see if this name is used:
		$exists = $server->getRegisteredPlayers($username);
		if (empty($exists)) {
			//player name exists.. cancel!
			//print_r($exists);
			echo "<span class='alt_text'>Username not found!</span>";
			exit();
		} else {
			$password = generate_password();
			$uid = $server->registerPlayer($username);
			$user = $server->getRegistration($uid + 0);
			$email = $user->email;
			$user->pw = $password;
			$server->updateRegistration($user);

			$subject = "Mumble Password reset!";

			$body = "Your mumble password has been reset!\r\n";
			$body = $body."You can connect to '".$servername."' at:\r\n";
			$body = $body."IP:".$serverhost.", Port:".$serverport."\r\n\r\n";
			$body = $body."Your Username is: ".$username."\r\n";
			$body = $body."Your Password is: ".$password."\r\n";
			$body = $body."\r\n";
			$body = $body."You can access your account information and change your password at:\r\n";
			$body = $body.$url."\r\n";
			$body = $body."\r\n";

			SendEmail($email, $subject, $body);
			echo "<span class='alt_text'>Confirmation Email Sent!</span>";
			exit();
		}
	break;


// Register User
	default:
		$arr = GetServerList($meta);
		echo "<div class='header'>Reset Password</div>\n";
		echo "<table  id='hor-minimalist-b'>\n";
		echo "<form method='POST' name='forgot' action='".$_SERVER['PHP_SELF']."'>\n";
		echo "<tr><td>Username:</td><td><input type='text' name='username' size='20'></td></tr>\n";
		echo "<tr><td>Select server:</td><td>";
		//.ServerSelectBox($arr,$serverid)."</td></tr>\n";
		echo "<select  name='server' tabindex='-1'>\n";
		foreach($arr as $s) {
			echo "<option ";
			if ($s[0] == $serverid) {
				echo "selected='selected' ";
			}
			echo "value='$s[0]'>$s[1]</option>\n";
		}
		echo "</select>\n";
		echo "</td></tr>\n";
		echo "<tr><td></td><td><input type='submit' value='Reset Password' name='Submit'></td></tr>\n";
		echo "</form>\n";
		echo "</table>\n";
	break;
}
include 'footer.php';
?>
Return current item: Murmuradmin