Hello Everyone,
I've been learning some SimpleXML last night and decided to share some of
my work with the Abyss Web Server community. I've written a function that will
read your "abyss.conf" and output all User Accounts per Host.
This is very helpful if you wish to read abyss.conf and use those accounts with
your own PHP scripts. My function creates an Associated Array with every single
User Account you add per Host. Enjoy!
Note: PHP5 is required in order to use this function.
<pre>
<?php
/**
* The abyss_user_accounts() Function
* Created by: Josh (TRUSTAbyss)
*/
function abyss_user_accounts($file, $host_id) {
$xml = simplexml_load_file($file);
$output = array();
if (count($xml->server->host[$host_id]->users->user) > 0) {
foreach ($xml->server->host[$host_id]->users->user as $account) {
$user = trim((string) $account->name);
$pass = trim((string) $account->password);
$output["user"][] = $user;
$output["pass"][] = $pass;
}
return $output;
}
else {
return FALSE;
}
}
// Add the path to your abyss.conf file.
$file = "C:\\Program Files\\Abyss Web Server\\abyss.conf";
// Let's lookup the current Host so we know which Users to Pull.
$host_id = $_SERVER['INSTANCE_ID'] - 1;
// This just assigns $output variable, the array of the accounts
$output = @abyss_user_accounts($file, $host_id);
// Last but not least, output it!
print_r($output);
// Let's retrieve the first User Account. This is easy! lol
echo "<br>";
echo "Username: " . $output['user'][0] . "\n";
echo "Password: " . $output['pass'][0];
?>
</pre>
Edit: To create an Abyss Web Server user account. Use this code.
<?php
function create_abyss_password($user, $pass) {
return md5(base64_encode("$user:$pass"));
}
// Let's create an Abyss Web Server password
// Syntax: abyss_create_password("Username", "Password")
$user = "Josh"; // Username to use
$pass = "password here"; // User's Password in plain Text
echo "Username ".$user." has the password ".abyss_create_password($user, $pass);
?>
Sincerely, Josh (TRUSTAbyss)