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

if (($_SESSION['loginstatus'] >= $login_level['LoginUser']) && ($_SESSION['edit_domain'] != "*") && ($_SESSION['edit_user'] != "*"))
{
  echo "<h1><a href=\"javascript:help('xpai_help.html#usermproc','".$helpwidth."','".$helpheight."')\"><img src='gfx/ico_help.png' alt='Help' border='0'></a>&nbsp;&nbsp;";
  echo "Mail processing for user <br>&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"blue\">".$_SESSION['edit_user']."@".$_SESSION['edit_domain']."</span></h1>";

  if (!isset($_REQUEST['Go']))
  {
    $vars = $mail_server->usergetmproc($_SESSION['edit_domain'], $_SESSION['edit_user']);
    $editallowed = true;
		if ($_SESSION['loginstatus'] < $login_level['LoginSuperuser'])
		{
      if (is_array($vars))
      {
        foreach ($vars as $var)
        {
          if (is_array($var))
          {
            if ($var[0] != "" && strcasecmp($var[0], "mailbox") && strcasecmp($var[0], "lredirect")  && strcasecmp($var[0], "redirect") && strcasecmp($var[0], "smtprelay"))
            {
              $editallowed = false;
              break;
            }
          } else {
            if ($var != "" && strcasecmp($var, "mailbox") && strcasecmp($var[0], "lredirect")  && strcasecmp($var, "redirect") && strcasecmp($var[0], "smtprelay"))
            {
              $editallowed = false;
              break;
            }
          }
        }
      }
		}
    if ($editallowed == true)
    {
?>
      <form name='frmusermproc' action='main.php' method='post'>
      	<input type='hidden' name='action' value='usermproc'>
        <input type='hidden' name='enabled' value=''>
        <input type='hidden' name='Go' value='true'>
        <table border='0' class='tbl'>
         	<tr>
         		<th width="10"></th>
        		<th width="150"></th>
         		<th width="*"></th>
        	</tr>
<?php
      $counter = 0;
      if (is_array($vars))
      {
        foreach ($vars as $var)
        {
          $action = "";
          if (is_array($var))
          {
            $action = $var[0];
            $data = $var[1];
          } else {
            $action = $var;
            $data = "";
          }
          if ($action != "")
          {
?>
            <tr>
            <td>&nbsp;</td>
            <td>
        		   <select name='umpc_action_<?php echo $counter; ?>' size='1' style='width: 100px;'>
                 <option value='mailbox' <?php if (!strcasecmp($action, "mailbox")) echo "selected";?>>Mailbox</option>
                 <option value='redirect'<?php if (!strcasecmp($action, "redirect")) echo "selected";?>>Redirect</option>
                 <option value='smtprelay'<?php if (!strcasecmp($action, "smtprelay")) echo "selected";?>>Smtprelay</option>
                 <option value='redirect'<?php if (!strcasecmp($action, "lredirect")) echo "selected";?>>LRedirect</option>
<?php 
						 if ($_SESSION['loginstatus'] == $login_level['LoginSuperuser'])
						 {
?>						 
                 <option value='external'<?php if (!strcasecmp($action, "external")) echo "selected";?>>External</option>
<?php
		 				 }								 
?>								 
                 <option value=''>Remove this line</option>
               </select>
             </td>
       		   <td>
         		   <input type='text' name='umpc_data_<?php echo $counter; ?>' size='30' style='width: 400px;' value='<?php if ($data != "") echo $data; else echo ""; ?>'>
       		   </td>
             </tr>
<?php
             $counter++;
           }
         }
       } else {
         echo "User specific mail processing yet not defined<br><br>";
       }
?>
       <tr>
         <td>&nbsp;</td>
       	 <td>
           <select name='xtr_action' size='1' style='width: 100px;'>
             <option value='' checked></option>
             <option value='mailbox'>Mailbox</option>
             <option value='redirect'>Redirect</option>
             <option value='smtprelay'>Smtprelay</option>
             <option value='lredirect'>LRedirect</option>
<?php 
						 if ($_SESSION['loginstatus'] == $login_level['LoginSuperuser'])
						 {
?>						 
             <option value='external'>External</option>
<?php
		 				 }								 
?>								 
            </select>
          </td>
       	  <td>
          	<input type='text' name='xtr_data' size='30' style='width: 400px;'>
         	</td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
        	<td>&nbsp;</td>
        	<td><input type='submit' name='save' value=' Save values '></td>
        </tr>
      </table>
    </form>
<?php
    } else {
?>
      <table border='0' class='tbl'>
     	<tr>
     		<th width="10"></th>
     		<th width="150"></th>
     		<th width="*"></th>
     	</tr>
<?php
      echo "</table>";
      echo "Modification of user mail processing is <b>NOT</b> allowed on this user.<br><br>";
    }
  } else {
		$vars = array();
		foreach($_REQUEST as $key=>$mprocval)
    {
			if (ereg("umpc_action_", $key))
      {
        $data_field = str_replace("_action_", "_data_", $key);
        if ($_REQUEST[$key] != '')
        {
          if (isset($_REQUEST[$data_field]) && (strcasecmp($mprocval, "mailbox")))
          {
            if ($_REQUEST[$data_field] != "")
          		array_push($vars, array($mprocval, $_REQUEST[$data_field]));
            else
              echo "Error: Redirect/Smtprelay without address ignored!<br>";
          } else
  				  array_push($vars, array($mprocval));
        }
			}
		}
		if ($_REQUEST['xtr_action'] != '')
    {
      if (strcasecmp($_REQUEST['xtr_action'], "mailbox"))
      {
        if ($_REQUEST['xtr_data'] != "")
    			array_push($vars, array($_REQUEST['xtr_action'], $_REQUEST['xtr_data']));
        else
          echo "Error: Redirect without address ignored!<br>";
      } else
			  array_push($vars, array($_REQUEST['xtr_action']));;
		}

		if ($mail_server->usersetmproc($_SESSION['edit_domain'], $_SESSION['edit_user'], $vars))
    {
			echo "User mail processing was saved successfully.<br>";
      echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
  	} else {
			echo "Error when saving user mail processing.<br>";
      echo "Server result: ".$_SESSION['LastXMAILResult']."<br><br>";
    }
?>
    <form action='main.php' method='post'>
       <input type='hidden' name='action' value='usermproc'>
       <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)