Location: PHPKode > projects > XMail PHP Admin Interface (XPAI) > xpai/includes/useradd.php
<?php
if (!$in_xpai)
  die;

if (($_SESSION['loginstatus'] >= $login_level['LoginPostmaster']) && ($_SESSION['edit_domain'] != "*"))
{
  echo "<h1><a href=\"javascript:help('xpai_help.html#useradd','".$helpwidth."','".$helpheight."')\"><img src='gfx/ico_help.png' alt='Help' border='0'></a>&nbsp;&nbsp;";
  echo "Create new user in domain<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"blue\">".$_SESSION['edit_domain']."</span></h1>";

  if (!isset($_REQUEST['Go']))
  {
?>
  <form name='frmNewUser' action='main.php' method='post'>
    <input type='hidden' name='action' value='useradd'>
    <input type='hidden' name='Go' value='true'>
    <table border='0' class='tbl'>
      <tr>
        <td>&nbsp;</td>
        <td><b>User name:<b></td>
<?php
        if (isset($_REQUEST['redo_useradd']) && $_REQUEST['redo_useradd'] == true)
          echo "<td><input type='text' name='edit_user' size='30' style='width: 400px;' value='".$_REQUEST['user_addname']."'></td>";
        else
          echo "<td><input type='text' name='edit_user' size='30' style='width: 400px;'></td>";
?>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><b>User password:</b></td>
        <td><input type='password' name='edit_pwd1' size='30' style='width: 400px;'></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><b>User password (repeat):</b></td>
        <td><input type='password' name='edit_pwd2' size='30' style='width: 400px;'></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><b>User type:<b></td>
        <td>
        <input type='radio' name='edit_user_type' value="U"' checked>User&nbsp;
<?php
  if (isset($allow_mailing_list) && ($allow_mailing_list == true))
  {
?>
        <input type='radio' name='edit_user_type' value="M"'>Mailing list
        <input type='radio' name='edit_user_type' value="MC"'>Mailing list (closed)
<?php
  }
?>
         </td>
      </tr>
<?php
  if (isset($enable_filters) && $enable_filters && count($filter_files))
  {
    $first = true;
    foreach ($filter_files as $filter_key => $filter_value)
    {
?>
      <tr>
        <td>&nbsp;</td>
<?php
      if ($first)
      { 
        echo "<td><strong>Filter settings</strong></td>";
        $first = false;
      } else {
        echo "<td></td>";
      }
?>
        <td>&nbsp;<input type='checkbox' name='filter_<?php echo $filter_value; ?>'>
        <b><?php echo $filter_key; ?><b></td>
      </tr>
<?php
    }
  }
?>        
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td><input type='submit' value=' submit '></td>
      </tr>
    </table>
  </form>
  <script language="JavaScript" type="text/javascript">
  <!--
    document.frmNewUser.edit_user.focus();
  //-->
  </script>
  
<?php
  } else {
    $set_closed_ml = false;
    $edit_pwd1 = $_REQUEST['edit_pwd1'];
    $edit_pwd2 = $_REQUEST['edit_pwd2'];
    if (!strcmp(htmlentities($_REQUEST['edit_user']), $_REQUEST['edit_user']))
    {
      if (!strcmp($edit_pwd1, $edit_pwd2) && $edit_pwd1 != "")
      {
        $_SESSION['edit_user'] = $_REQUEST['edit_user'];
        if (!strcmp($_REQUEST['edit_user_type'],'MC'))
        {
          $_REQUEST['edit_user_type'] = "M";
          $set_closed_ml = true;
        }
        if ($mail_server->useradd($_SESSION['edit_domain'], $_REQUEST['edit_user'], $edit_pwd1, $_REQUEST['edit_user_type']))
        {
          echo "New user <b>".$_REQUEST['edit_user']."@".$_SESSION['edit_domain']."</b> was created successfully.<br>";
          echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
          if ($set_closed_ml)
          {
            if ($mail_server->uservarsset($_SESSION['edit_domain'], $_REQUEST['edit_user'], "ClosedML\t1"))
            {
              echo "Created closed mailing list.<br>";
              echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
            } else {
              echo "Failed to set mailing list to closed status.<br>";
              echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
            }
          } else 
            if ($_REQUEST['edit_user_type'] == "M")
              echo "<br>Created mailing list.<br>";

          if (isset($enable_filters) && $enable_filters && count($filter_files))
          {
            foreach ($filter_files as $filter_value)
            {
              $filter_name = ereg_replace("\.", "_", $filter_value);
              $mail_server->upd_filtersin($_SESSION['edit_user']."@".$_SESSION['edit_domain'], $filter_value, (isset($_REQUEST["filter_".$filter_name]) ? 1 : 0)); 
            }
            echo "<br>Filter settings for <b>".$_SESSION['edit_user']."@".$_SESSION['edit_domain']."</b> were set successfully.<br>";
            echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
          }

          if (isset($enable_IMAP) && $enable_IMAP && $IMAP_default_status && ($_REQUEST['edit_user_type'] != "M"))
          {
             $mail_server->uservarsset($_SESSION['edit_domain'], $_SESSION['edit_user'], $IMAP_configword."\t1\n");
            $mail_server->update_IMAP($_SESSION['edit_user']."@".$_SESSION['edit_domain'], $_SESSION['edit_user'], $_SESSION['edit_domain'], $edit_pwd1, "CREATE", true, true, true);
             echo "<br>IMAP settings for <b>".$_SESSION['edit_user']."@".$_SESSION['edit_domain']."</b> were set successfully.<br>";
            echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
          } 

      } else {
          echo "Adding new user <b>".$_REQUEST['edit_user']."@".$_SESSION['edit_domain']."</b> failed<br>";
          echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
          $_SESSION['edit_user'] = "*";
        }
        $do_menu_update = true;
?>
        <form action='main.php' method='get'>
          <input type='hidden' name='action' value='userlist'>
          <input type='submit' name='click' style='width: 50px;' value=' OK '>
        </form>
<?php
      } else {
        echo "Passwords are not identical or empty - creation failed.<br>";
        $_SESSION['edit_user'] = '*';
?>
        <form action='main.php' method='post'>
          <input type='hidden' name='action' value='useradd'>
          <input type='hidden' name='user_addname' value='<?php echo $_REQUEST['edit_user']; ?>'>
           <input type='hidden' name='redo_useradd' value='true'>
           <input type='submit' name='click' style='width: 50px;' value=' OK '>
         </form>
<?php
      }
    } else {
      echo "The username contains illegal characters!<br>";
      $_SESSION['edit_user'] = '*';
?>
      <form action='main.php' method='post'>
        <input type='hidden' name='action' value='useradd'>
        <input type='hidden' name='user_addname' value='<?php echo $_REQUEST['edit_user']; ?>'>
         <input type='hidden' name='redo_useradd' value='true'>
         <input type='submit' name='click' style='width: 50px;' value=' OK '>
       </form>
<?php      
    }
  }
} else {
  echo "<br><br><h2>Authorization failed to access this function!</h2><br><br>";
}
?>

Return current item: XMail PHP Admin Interface (XPAI)