[Mapbender-commits] r3089 - in branches/beck_dev/http: . x_beck

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Oct 1 07:04:12 EDT 2008


Author: beck
Date: 2008-10-01 07:04:12 -0400 (Wed, 01 Oct 2008)
New Revision: 3089

Added:
   branches/beck_dev/http/x_beck/
   branches/beck_dev/http/x_beck/forgotten_password.php
Log:


Added: branches/beck_dev/http/x_beck/forgotten_password.php
===================================================================
--- branches/beck_dev/http/x_beck/forgotten_password.php	                        (rev 0)
+++ branches/beck_dev/http/x_beck/forgotten_password.php	2008-10-01 11:04:12 UTC (rev 3089)
@@ -0,0 +1,50 @@
+<?php
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+import_request_variables("PG");
+
+function forgotten_password() {
+	if(
+		!isset($_REQUEST["Benutzername"]) || !isset($_REQUEST["EMail"]) || 
+		empty($_REQUEST["Benutzername"]) || empty($_REQUEST["EMail"]) || 
+		!(bool)trim($_REQUEST["Benutzername"]) || !(bool)trim($_REQUEST["EMail"])
+	) {
+		return -1;
+	}
+
+	if(!USE_PHP_MAILING) {
+		return FALSE;
+	}
+
+	$administration = new administration();
+	define("USER_NAME", trim($_REQUEST["Benutzername"]));
+	define("USER_EMAIL",trim($_REQUEST["EMail"]));
+
+	if(
+		!$administration->getUserIdByUserName(USER_NAME) || 
+		USER_EMAIL != $administration->getEmailByUserId($administration->getUserIdByUserName(USER_NAME))) {
+		return -2;
+	}
+
+	$new_password  = $administration->getRandomPassword();
+
+	$sql_update = "UPDATE mb_user SET mb_user_password = $1 WHERE mb_user_id = $2";
+	$v          = array(md5($new_password),$administration->getUserIdByUserName(USER_NAME));
+	$t          = array("s","i");		      
+
+	if(!db_prep_query($sql_update,$v,$t)) {
+		return -3;
+	}
+
+	$email_subject = "New MapBender Password";
+	$email_body    = sprintf("Your new MapBender password is: %s",$new_password);
+
+	if(!$administration->sendEmail(NULL,NULL,USER_EMAIL,USER_NAME,$email_subject,$email_body,$error_msg)) {
+		return FALSE;
+	}
+
+	return 1;
+}
+
+forgotten_password();
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list