Location: PHPKode > scripts > HostBuilder > hostbuilder/signup.php
<?php
/*
	HostBuilder
	Free Edition
	(C) 2007-2008 Data Components Software Development

	Sign-up module
*/

include "functions.php";
include "admin.functions.php";
include "templates.php";

$t['message'] = "";
if ($_POST['funcbtn'] == "Sign Up") {
	if (gettotalindex() >= intval(getconfig(2)) && intval(getconfig(2)) != 0) {
	  $globalmsg .= "<center><b><font face=Tahoma>There are a maximum of only ".getconfig(2)." sign-ups allowed!</font></b></center><hr>";
	}
  if (!isset($_POST['agree'])) {
   	$globalmsg .= "<center><b><font face=Tahoma>You must agree to the Terms and Conditions!</font></b></center><hr>";
  }
 	if (trim($_POST['username']) == NULL) {
 	  $globalmsg .= "<center><b><font face=Tahoma>You must enter a username!</font></b></center><hr>";
 	}
	if ($_POST['email'] == NULL) {
	  $globalmsg .= "<center><b><font face=Tahoma>You must enter an e-mail address!</font></b></center><hr>";
	}
	if ($_POST['group'] == NULL) {
	  $globalmsg .= "<center><b><font face=Tahoma>You must select a group!</font></b></center><hr>";
	}
	if ($_POST['name'] == NULL) {
    $globalmsg .= "<center><b><font face=Tahoma>You must enter a name!</font></b></center><hr>";
	}
	if (trim($_POST['username']) != "") {
    $f = file(getcwd()."/accounts.db");
  	foreach ($f as $l) {
	    $v = split("::", $l);
	    if ($v[0] == strtolower(trim($_POST['username']))) {
	      $globalmsg .= "<center><b><font face=Tahoma>Username <b>".strtolower(trim($_POST['username']))." already exists!</font></b></center><hr>";
	    }
    }
  }
	if ($globalmsg == NULL) {
	  $ap = getconfig(5);
	  if (substr($ap, -1) == "/") {
	    $ap = substr($ap, 0, -1);
	  }
	  $udir = $ap.strtolower(trim($_POST['username']));
	  mkdir($udir, 0777);
	  chmod($udir, 0777);
		$a['name'] = stripslashes($_POST['name']);
		$outhtml = parse_tpl("autohtml", $a);
		$h = fopen($udir."/index.html", "w");
		fwrite($h, $outhtml);
		fclose($h);
		insertads($udir."/index.html");
    $au = getconfig(6);
		if (substr($au, -1) != "/") {
		  $au .= "/";
		}
	  $mgr = getconfig(10);
		if (substr($mgr, -1) != "/") {
		  $mgr .= "/";
		}
		$salt = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvXxYyZz0123456789";
		srand((double)microtime()*1000000);
		$i = 0;
		while ($i <= 8) {
		  $num = rand() % strlen($salt);
		  $tmp = substr($salt, $num, 1);
		  $pass = $pass . $tmp;
		  $i++;
		}
		$password = $pass;
		$h = fopen(getcwd()."/accounts.db", "a");
		fwrite($h, trim(strtolower($_POST['username']))."::".md5($password)."::".getconfig(1)."::".getconfig(3)."::".getconfig(4)."::".$udir."::".time()."::".stripslashes($_POST['name'])."::".stripslashes($_POST['group'])."::".$au."::".$_POST['email']."::"."1\n");
		fclose($h);
		$headers = "From: ".getconfig(9)."\n".
							"Reply-To: ".getconfig(9)."\n\n";
	  $b['commname'] = getconfig(0);
	  $b['username'] = strtolower(trim($_POST['username']));
	  $b['password'] = $password;
	  $b['url'] = $au;
	  $b['manager'] = $mgr."manager.php";
		$message = parse_tpl("mail.signup", $b);
		mail($_POST['email'], "Your new account on ".getconfig(0), $message, $headers);
		$t['commname'] = getconfig(0);
		echo parse_tpl("signup.complete", $t);
	} else {
	  $t['message'] = $globalmsg;
	}
} else {
  $t['commname'] = getconfig(0);
  $f = file(getcwd()."/terms.inc");
  foreach ($f as $l) {
    $t['terms'] .= $l;
  }
  $t['username'] = "";
  $t['email'] = "";
  $t['name'] = "";
  foreach ($HTTP_POST_VARS as $pn => $pv) {
    $t[$pn] = $pv;
  }
  $f = file(getcwd()."/groups.db");
  foreach ($f as $l) {
    $g .= $l;
  }
  $g = str_replace("\n", "", $g);
  $grps = split(",", $g);
  foreach ($grps as $v) {
    $t['groups'] .= "<option value=\"".$v."\">".$v."</option>\n";
  }
  echo parse_tpl("signup", $t);
}

?>
Return current item: HostBuilder