Location: PHPKode > projects > proManager > proman/www/new_user.php
<?php

require "inc/init.php";
require "inc/small_functions.php";

$post_vars = array(
  'name','username','password','password2','email','cancel','can_add_user'
);
include "import_vars_post.inc";

#$get_vars = array('task_id','note_id');
#include "import_vars_get.inc";



  if ($cancel) {
    header ("Location: home.php");
    exit;
  }


  // validate data

  $name = AddSlashes(StripSlashes($name));
  $username = AddSlashes(StripSlashes($username));
  $password = AddSlashes(StripSlashes($password));
  $password2 = AddSlashes(StripSlashes($password2));
  $email = AddSlashes(StripSlashes($email));



  // can this guy have resources?
  if (GetUserInfo($user_id,$d,$can_add_user,$d,$d,$d,$d)) {
    if ($can_add_user != 1) {
      // user cannot add users
      // send him home
      Header ("Location: home.php");
    }
  } else {
    // user doesn't exist
    // give him login screen
    Header ("Location: index.php");
  }




  // verify if passwords match

  if ("$password" != "$password2") $error = $strThepasswordsdontmatch;





  // verify if username doesnt exist

  if(GetUserId($username,$d)) $error = $strThatusernameisalreadybeingused;


  // validate form
  $can_add_user += 0;


  // if we get parameters (without any error messages)
  // save them and head to home.php (homepage)
  // otherwise ask for a new slave


  if ($name && $username && !$error) {
 
    if (GetNodeLeafFromTree($user_id,$node,$leaf)) {

      if ($node != "root") {
        if ($node == "") $node = $leaf;
        else $node = "$node-$leaf";
      } else $node = "";

      if (!GetNextLeaf($node,$leaf)) $leaf = 1;
      if (!$leaf) $leaf = 1;

    } else {

      // non-existent master, get outta here
      Header ("Location: index.php");
    }


    CreateUser($node,$leaf,$username,$password,$name,$email,$can_add_user);
    Header ("Location: home.php");

  } else {

?>
<html>
<head>
<title><? echo $strAddnewslave; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<? if ($charset) print $charset; else print "ISO-8859-1"; ?>">
<link href="css/pman.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor=<? print $bgcolorNewSlave; ?>>
<table width=100% height=100%>
  <tr>
      <td width=30% valign=middle align=center>
          <form method=post>
<?

    if ($error) $error = "\n<p align=center><font color=#FF0000>$error</font></p>\n";

    $content = "
        <br><div align=center>$error
        $strRealname: <input type=text name=name><br>
        $strUsername: <input type=text name=username><br>
        $strPassword: <input type=password name=password><br>
        $strConfirmpassword: <input type=password name=password2><br><br>
        $strUsercanhaveslaves: <input type=checkbox name=can_add_user value=1><br><br>
        $strEmail: <input type=text name=email value=\"$email\" size=30><br><br>
        <input type=submit value=\"$strCreate\">&nbsp;
        <input type=submit name=cancel value=\"$strCancel\"><br>
        </div>\n";

    $title = $strAddnewslave;
    $titlecolor = $boxtitlecolorNewSlave;
    $color = $boxcolorNewSlave;
    $plus = "width=45%";

    include "templates/box.php";


?>
      <form>
    </td>
  </tr>
</table>
</body>
</html>
<?
  }
?>
Return current item: proManager