HostFact - Hosting class
Hostingaccounts
Op deze pagina staan alle functies om hostingaccounts te beheren. Hiervoor dienen de pakketten-functies reeds geimplementeerd te zijn. Om naderhand extra domeinnamen te ondersteunen bij hostingaccounts, dienen de domeinnamen-functies ook geimplementeerd te worden.
createAccount()
Maak een webhosting account aan op de server.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->Password | Wachtwoord |
$this->Domain | Domeinnaam |
$this->TemplateName | Naam pakket |
$this->ServerIP | (Shared) IP-adres server |
$this->EmailAddress | E-mailadres van de klant |
Voorbeeld implementatie
function createAccount() { // Create account on server $result = true; if($result) { return true; } else { // Give reason of error $this->Error[] = 'Your error message'; // Log the message if cronjob runs this action createMessageLog('error','Your error message for logging'); return false; } }
createResellerAccount()
Maak een resellerhosting account aan op de server. Beschikbare variabelen en voorbeeld implementatie is te vinden onder createAccount().
deleteAccount()
Verwijder een account definitief van de server.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->Domain | Domeinnaam |
$this->Reseller | true = resellerhosting account, false = webhosting account |
Voorbeeld implementatie
function deleteAccount() { // Delete account on server $result = true; if($result) { return true; } else { // Give reason of error $this->Error[] = 'Your error message'; // Log the message if cronjob runs this action createMessageLog('error','Your error message for logging'); return false; } }
checkIfAccountExists()
Controleert of het hostingaccount bestaat op de server.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->Password | Wachtwoord |
$this->Domain | Domeinnaam |
Voorbeeld implementatie
function checkIfAccountExists() { // Check if account exists on the server $result = true; if($result) { return true; } else { // Give reason of error $this->Error[] = 'Your error message'; return false; } }
getAccountUsage($accountname)
Haalt het verbruik (webruimte en dataverkeer) van het hostingaccount op.
Beschikbare variabelen | Beschrijving |
---|---|
$accountname | Accountnaam |
$this->Domain | Domeinnaam |
Voorbeeld implementatie
function getAccountUsage($accountname) { // Get account usage and limits for bandwidth and webspace $usage = array(); // Only fill array if we retrieved data if(true) { // Real usage in MBs $usage['UsedBandWidth'] = 1253; $usage['UsedDiscSpace'] = 25.5; // Limits in MBs $usage['BandWidth'] = 2000; $usage['DiscSpace'] = 30; } return $usage; }
listAccounts()
Haal alle actieve accounts op van de server, zodat deze kunnen worden geïmporteerd in HostFact. De functie moet een array teruggeven met accounts en per account dienen de volgende gegevens meegegeven te worden.
Key | Beschrijving |
---|---|
Username | Accountnaam (verplicht) |
Password | Wachtwoord (indien bekend) |
Type | 'normal' of 'reseller' |
Domain | Domeinnaam |
Package | Naam van het pakket. Leeg indien pakketnaam onbekend |
Suspended | 'yes' of 'no', afhankelijk van de status van het account |
Voorbeeld implementatie
function listAccounts() { $account_list = array(); // Loop through retrieved accounts foreach($retrieved_accounts as $acc_info) { $account = array(); $account['Username'] = $acc_info['Username']; $account['Password'] = ''; // unknown $account['Type'] = 'normal'; $account['Domain'] = $acc_info['Domain']; $account['Package'] = $acc_info['Package']; $account['Suspended'] = ($acc_info['Status'] != 'active') ? 'yes' : 'no'; $account_list[] = $account; } return $account_list; }
suspendAccount()
Hostingaccounts blokkeren of deblokkeren.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->Domain | Domeinnaam |
$this->Suspend | true = suspenden, false = unsuspenden |
Voorbeeld implementatie
function suspendAccount() { // Suspend user $suspended = true; if($suspended) { return true; } else { $this->Error[] = '(un)suspending failed'; return false; } }
changeAccountPassword()
Wijzigen van het wachtwoord van het hosting account.
Let op: het wachtwoord van het FTP, MySQL en e-mail root account wijzigt ook.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->Password | Wachtwoord |
$this->Domain | Domeinnaam |
Voorbeeld implementatie
function changeAccountPassword() { // Change the password of the account on the server $result = true; if($result) { return true; } else { // Give reason of error $this->Error[] = 'Your error message'; createMessageLog('error','Your error message for logging'); return false; } }
changePackage()
Up-/downgrade van het hosting account.
Beschikbare variabelen | Beschrijving |
---|---|
$Username | Accountnaam |
$TemplateName | Naam nieuw pakket |
$this->Domain | Domeinnaam |
Voorbeeld implementatie
function changePackage($Username, $TemplateName) { // Change the package of the hosting account on the server $result = true; if($result) { return true; } else { // Give reason of error $this->Error[] = 'Your error message'; createMessageLog('error','Your error message for logging'); return false; } }
singleSignOn()
Ophalen van informatie om de klant of medewerker in te kunnen laten loggen in het hostingaccount middels Single sign-on.
Beschikbare variabelen | Beschrijving |
---|---|
$this->Username | Accountnaam |
$this->IPAddresses | Array met 1 of meerdere IP-adressen voor de tijdelijke toegang |
$this->Reseller | true = resellerhosting account, false = webhosting account |
Voorbeeld implementatie
function singleSignOn() { // Get a redirect URL OR return some data for posting a form. $result = true; $method = 'url'; // 'url' or 'post'. Option must be set in version.php. Here it is done for this example. // Use a URL redirect if($result && $method == 'url') { return array('url' => 'https://url/?session_token=XYZ'); } // Use form post elseif($result && $method == 'post') { // Build result array with form_action and post data $result = array(); $result['form_action'] = 'https://url/'; $result['data']['username'] = $this->Username; $result['data']['password'] = 'temp-password'; return $result; } else { // Give reason of error $this->Error[] = 'Your error message'; createMessageLog('error','Your error message for logging'); return false; } }