Location: PHPKode > projects > Content*Builder > modules/community/register.inc.php
<?php
/**
 * Modul dient zum registrieren von neuen Benutzern
 * 
 * @author Jörg Stöber <hide@address.com> 
 * @version $Id: register.inc.php,v 1.5 2004/09/29 17:27:45 cb_fog Exp $
 * @copyright 2003 Jörg Stöber
 **/
 
$communityOption = new CBOption();
$communityOption->setModule("community");
$communityOption->getOptionList();

$showForm = 1;
$activationType = 0;

if($communityOption->getSingleOption("requireUserActivation")) {
	if($communityOption->getSingleOption("requireUserActivationPerMail")) {
		$activationType = 2;
	} else {
		$activationType = 3;
	}
} else {
	$activationType = 1;
}

if(!empty($community_register)) {
	$registerError = array();
	/* 
	* check ob user bereits existiert 
	*/
	$isRegisteredCheck = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_community_user WHERE name = '$community_r_name'"));
	if(!empty($isRegisteredCheck->name)) {
		$registerError['unameExists'] = 1;
	}
	
	/* 
	* check ob Passwörter übereinstimmen
	*/
	if($community_r_pass1 != $community_r_pass2) {
		$registerError['passwordsUnequal'] = 1;
	}
	
	/* 
	* check ob Email korrekt ist
	*/
	if(!preg_match("/^([\w\.\-\_]+)*@([\w\.\-\_]+)+([a-zA-Z]{2,3})$/", $community_r_email)) { 
		$community_r_email = ""; 
		$registerError['invalidEmail'] = 1;
	}
	
	if(count($registerError) == 0) {
		$password = md5($community_r_pass1);
		$showForm = 0;
		
		/*
		* Ist User gleich am Anfang aktiviert?
		*/
		if($communityOption->getSingleOption("requireUserActivation")) {
			$reg_options = 0;
		} else {
			$reg_options = 1;
		}
		
		/*
		* User Eingaben für MySQL absichern
		*/
		$community_r_name     = mysql_escape_string($community_r_name);
		$community_r_fullname = mysql_escape_string($community_r_fullname);
		if($community_r_fullname == "") {
			$community_r_fullname = $community_r_name;
		}
		
		$registerSuccess = mysql_query("INSERT INTO ".TABLE."_community_user (name, fullname, password, email, registerDate, options) VALUES ('$community_r_name', '$community_r_fullname', '$password', '$community_r_email', NOW(), '$reg_options')");
		$_userID = mysql_insert_id();
		
		/*
		* Aktivierung per Mail, speichern des Codes in der DB, senden der Mail
		*/
		if($activationType == 2) {
			$activationCode = md5(uniqid(date("Y-m-d H:i:s")));
			$registerActivationQuery = mysql_query("INSERT INTO ".TABLE."_community_activation (userID, activationCode, datetime) VALUES ('$_userID', '$activationCode', NOW())");
			
			/* Mail einbinden */
			if(!class_exists("Mail")) {
				require_once 'Mail.php';
			}
			
			/*
			* Mail Parameter setzen
			*/
			if(substr(PHP_OS, 0, 3) == 'WIN') {
				$crlf="\r\n";
			} else {
				$crlf="\n";
			}
			
			$hdrs = "From: info@{$_SERVER['SERVER_NAME']}\r\n" .
     				"Reply-To: info@{$_SERVER['SERVER_NAME']}\r\n" .
    				"X-Mailer: PHP/" . phpversion();
				
			
			$activationBody  = "Registrierung erfolgreich. \r\n \r\n Bitte aktivieren Sie Ihren Account indem sie folgenden Freischaltcode auf der Webseite eingeben: \r\n";
			$activationBody .= $activationCode;
			
			#$nlMailObject =& Mail::factory("mail");
			#$mailResult = $nlMailObject->send($community_r_email, $hdrs, $activationBody);
			
			$mailResult = mail($community_r_email, "Community Registration", $activationBody, $hdrs);
			$mailResult ? $mailResult = 1 : $mailResult = 0;
		}
	}
}

if($showForm) {
	$tpl->assign("registerForm", "1");
	$tpl->assign("registerActivated", $activationType);
	if(count($registerError) > 0) {
		$tpl->assign(
			array ( "reg_name"  => $community_r_name,
					"reg_full"  => $community_r_fullname,
					"reg_email" => $community_r_email,
					"reg_error" => $registerError
			)
		);
	}
} else {
	$tpl->assign("registerActivated", $activationType);
	$tpl->assign("registerForm", "0");
	$tpl->assign("registerMailResult", $mailResult);
}
$tpl->display("register.template");
?>
Return current item: Content*Builder