m u r
2nd June 2007, 18:17
I tested this php form, and it worked on 2 out of three computers. The three computers were on different networks. The one that didn't work stalled after you hit submit . . . so you wouldn't get any of the error messages or anything. This happened whether it was on a PC or Mac, in Firefox, or IE. Any ideas what could be causing it? Thanks.
<?php
$domainname = "mydomain.com"; /** Change this to your own domain **/
$adminmail = "info@mydomain.com"; /** Change this to your own email address **/
$webmail = "https://mydomain.com/mail/"; /** Change this to your own webmail url **/
$scriptlocation = "/home/ecreate"; /** Change this to point to your script **/
$name = escapeshellcmd($_REQUEST['name']);
$username = escapeshellarg(escapeshellcmd($_REQUEST['username']));
$password = escapeshellarg(escapeshellcmd($_REQUEST['password']));
if (!isset($_REQUEST['name'])) {
?>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="index2.php">
Full Name:
<input type="text" name="name" />
<br>
Username:
<input type="text" name="username" />
<br>
Password:
<input type="password" name="password" />
<input type="submit" />
</form>
</body>
</html>
<?php
}
elseif (empty($name) || empty($username) || empty($password)) {
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have left one of the information fields blank. Please press "back" on your
browser and try again.
</body>
</html>
<?php
}
$reply = exec ("sudo $scriptlocation $name $username $password");
switch ($reply) {
case "success":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Success:<br>
</div>
Congratulations, <?php echo $name ?>, you have successfully created an email
account at <?php echo $domainname ?> with username <?php echo $username ?>. You
may access your webmail account from anywhere by going to <a href=<?php echo $webmail ?>><?php echo $webmail ?></a> and
signing in.
</body>
</html>
<?php;
$date = date('l dS \of F Y h:i A');
$subject = "Email User $name added to $domainname";
$body = "Email User was added on $date with a username of $username";
$headers = "From: root" . "\r\n" . "Reply-To: root@$domainname";
mail($adminmail,$subject,$body,$headers);
break;
case "error2":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your first name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error3":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your last name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error4":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your username. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error5":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your password. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error7":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
The username you have selected is already in use. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case ereg("^-bash: syntax error", $reply)
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
Your input has caused an error. There might be a problem with your permissions.
Please check your setup and try again.
</body>
</html>
<?php;
break;
}
?>
<?php
$domainname = "mydomain.com"; /** Change this to your own domain **/
$adminmail = "info@mydomain.com"; /** Change this to your own email address **/
$webmail = "https://mydomain.com/mail/"; /** Change this to your own webmail url **/
$scriptlocation = "/home/ecreate"; /** Change this to point to your script **/
$name = escapeshellcmd($_REQUEST['name']);
$username = escapeshellarg(escapeshellcmd($_REQUEST['username']));
$password = escapeshellarg(escapeshellcmd($_REQUEST['password']));
if (!isset($_REQUEST['name'])) {
?>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="index2.php">
Full Name:
<input type="text" name="name" />
<br>
Username:
<input type="text" name="username" />
<br>
Password:
<input type="password" name="password" />
<input type="submit" />
</form>
</body>
</html>
<?php
}
elseif (empty($name) || empty($username) || empty($password)) {
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have left one of the information fields blank. Please press "back" on your
browser and try again.
</body>
</html>
<?php
}
$reply = exec ("sudo $scriptlocation $name $username $password");
switch ($reply) {
case "success":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Success:<br>
</div>
Congratulations, <?php echo $name ?>, you have successfully created an email
account at <?php echo $domainname ?> with username <?php echo $username ?>. You
may access your webmail account from anywhere by going to <a href=<?php echo $webmail ?>><?php echo $webmail ?></a> and
signing in.
</body>
</html>
<?php;
$date = date('l dS \of F Y h:i A');
$subject = "Email User $name added to $domainname";
$body = "Email User was added on $date with a username of $username";
$headers = "From: root" . "\r\n" . "Reply-To: root@$domainname";
mail($adminmail,$subject,$body,$headers);
break;
case "error2":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your first name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error3":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your last name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error4":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your username. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error5":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your password. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error7":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
The username you have selected is already in use. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case ereg("^-bash: syntax error", $reply)
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
Your input has caused an error. There might be a problem with your permissions.
Please check your setup and try again.
</body>
</html>
<?php;
break;
}
?>