If you are using Unix or Linux, you can write a php script that
runs over inetd. Please note that you need to compile PHP as
statical binary.
The script could look something like this:
Create a new file /usr/local/il/il.phx:
#!/usr/local/bin/php -q
<?
$pass = "your_password";
function sread(&$string)
{
global $STDIN;
$string = '';
$x = $string;
while ($x!="\n")
{
$x = fread($STDIN, 1);
$string.=$x;
}
$string = trim($string);
return("$string");
}
$STDIN = fopen('php://stdin', 'r');
print("+OK\n");
sread($password);
if($password != $pass) {
print("-ER\n");
} else {
print("+OK\n");
$loop = true;
while($loop) {
sread($input);
// $input[0] is the function that you want to execute
// $input[x] are the arguments
$input = explode(" ",$input);
switch($input[0]) {
case 'quit':
print("bye\n");
$loop = false;
break;
case 'addaccount':
// Do what ever you want as user root
print("Your input was: $input\n");
print("+OK\n");
break;
default:
print("unknown command\n");
break;
}
}
}
?>
Then edit /etc/inetd.conf and add following line:
il stream tcp nowait root /usr/sbin/tcpd /usr/local/il/il.phx
After that, edit /etc/services and add following:
il 2000/tcp # Comment
Now restart the inet service and everything is done.
/etc/rc.d/init.d/inet restart
OK, now you should be able to telnet to the port 2000.
telnet localhost 2000
your_password
+OK
addaccount test@test.com <next arg> <next arg>
+OK
quit
bye
--
You are now able to connect to port 2000 over a web frontend using the php socket functions.
$fp = fsockopen ("yourhost", 2000, $errno, $errstr, 30);
fputs ($fp, "addaccount test@test.com <next arg> <next arg>\n");
while (!feof($fp)) {
echo fgets ($fp,128);
}
fclose ($fp);
You should use mcrypt to encrypt the data that is transfered
between the web frontend and the il.phx script.
In case you're unable to understand what i'm trying to tell you,
feel free to contact me. Maybe there are some mistakes since it's
pretty early in the morning here and i just had my second beer.
Please aswell note, that i have been writting this script with PHP
4.0.x and not with the newest version. So maybe you'll have to
do some little adjustments.
Please aswell ensure, that you create rules in hosts.allow and hosts.deny, so that the script can only be executed by you:
hosts.deny:
ANY: ANY
hosts.allow:
il.phx: <ip address from the host with the web frontend>
I'm shure that this will help you to create your email accounts in plain text files, ldap or elsewhere.
Cheers
Chris