Added sources
This commit is contained in:
45
php/add_database.php
Normal file
45
php/add_database.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
// Server credentials
|
||||
$hst_hostname = 'server.hestiacp.com';
|
||||
$hst_port = '8083';
|
||||
$hst_username = 'admin';
|
||||
$hst_password = 'p4ssw0rd';
|
||||
$hst_returncode = 'yes';
|
||||
$hst_command = 'v-add-database';
|
||||
|
||||
// New Database
|
||||
$username = 'demo';
|
||||
$db_name = 'wordpress';
|
||||
$db_user = 'wordpress';
|
||||
$db_pass = 'wpbl0gp4s';
|
||||
|
||||
// Prepare POST query
|
||||
$postvars = array(
|
||||
'user' => $hst_username,
|
||||
'password' => $hst_password,
|
||||
'returncode' => $hst_returncode,
|
||||
'cmd' => $hst_command,
|
||||
'arg1' => $username,
|
||||
'arg2' => $db_name,
|
||||
'arg3' => $db_user,
|
||||
'arg4' => $db_pass
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
// Check result
|
||||
if($answer === 0) {
|
||||
echo "Database has been successfuly created\n";
|
||||
} else {
|
||||
echo "Query returned error code: " .$answer. "\n";
|
||||
}
|
||||
41
php/add_domain.php
Normal file
41
php/add_domain.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
// Server credentials
|
||||
$hst_hostname = 'server.hestiacp.com';
|
||||
$hst_port = '8083';
|
||||
$hst_username = 'admin';
|
||||
$hst_password = 'p4ssw0rd';
|
||||
$hst_returncode = 'yes';
|
||||
$hst_command = 'v-add-domain';
|
||||
|
||||
// Domain details
|
||||
$username = 'demo';
|
||||
$domain = 'demo.hestiacp.com';
|
||||
|
||||
// Prepare POST query
|
||||
$postvars = array(
|
||||
'user' => $hst_username,
|
||||
'password' => $hst_password,
|
||||
'returncode' => $hst_returncode,
|
||||
'cmd' => $hst_command,
|
||||
'arg1' => $username,
|
||||
'arg2' => $domain
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
// Check result
|
||||
if($answer === 0) {
|
||||
echo "Domain has been successfuly created\n";
|
||||
} else {
|
||||
echo "Query returned error code: " .$answer. "\n";
|
||||
}
|
||||
38
php/check_user_account.php
Normal file
38
php/check_user_account.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$hostname = 'server.yourdomain.tld';
|
||||
$port = '8083';
|
||||
$hstadmin = 'admin';
|
||||
$hstadminpw = 'AdMin_pWd';
|
||||
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
$postvars = array(
|
||||
'user' => $hstadmin,
|
||||
'password' => $hstadminpw,
|
||||
'returncode' => 'no',
|
||||
'cmd' => 'v-check-user-password',
|
||||
'arg1' => $username,
|
||||
'arg2' => $password,
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hostname . ':' . $port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
//var_dump($answer);
|
||||
// Check result
|
||||
|
||||
if($answer == 'OK') {
|
||||
echo "OK: User can login\n";
|
||||
} else {
|
||||
echo "Error: Username or password is incorrect\n";
|
||||
}
|
||||
49
php/create_user.php
Normal file
49
php/create_user.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
// Server credentials
|
||||
$hst_hostname = 'server.hestiacp.com';
|
||||
$hst_port = '8083';
|
||||
$hst_username = 'admin';
|
||||
$hst_password = 'p4ssw0rd';
|
||||
$hst_returncode = 'yes';
|
||||
$hst_command = 'v-add-user';
|
||||
|
||||
// New Account
|
||||
$username = 'demo';
|
||||
$password = 'd3m0p4ssw0rd';
|
||||
$email = 'demo@gmail.com';
|
||||
$package = 'default';
|
||||
$first_name = 'Rust';
|
||||
$last_name = 'Cohle';
|
||||
|
||||
// Prepare POST query
|
||||
$postvars = array(
|
||||
'user' => $hst_username,
|
||||
'password' => $hst_password,
|
||||
'returncode' => $hst_returncode,
|
||||
'cmd' => $hst_command,
|
||||
'arg1' => $username,
|
||||
'arg2' => $password,
|
||||
'arg3' => $email,
|
||||
'arg4' => $package,
|
||||
'arg5' => $first_name,
|
||||
'arg6' => $last_name
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
// Check result
|
||||
if($answer === 0) {
|
||||
echo "User account has been successfuly created\n";
|
||||
} else {
|
||||
echo "Query returned error code: " .$answer. "\n";
|
||||
}
|
||||
42
php/delete_user.php
Normal file
42
php/delete_user.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// Server credentials
|
||||
$hst_hostname = 'server.hestiacp.com';
|
||||
$hst_port = '8083';
|
||||
$hst_username = 'admin';
|
||||
$hst_password = 'p4ssw0rd';
|
||||
$hst_returncode = 'yes';
|
||||
$hst_command = 'v-delete-user';
|
||||
|
||||
// Account
|
||||
$username = 'demo';
|
||||
|
||||
// Prepare POST query
|
||||
$postvars = array(
|
||||
'user' => $hst_username,
|
||||
'password' => $hst_password,
|
||||
'returncode' => $hst_returncode,
|
||||
'cmd' => $hst_command,
|
||||
'arg1' => $username
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
// Parse JSON output
|
||||
$data = json_decode($answer, true);
|
||||
|
||||
// Check result
|
||||
if(is_numeric($answer) && $answer === '0') {
|
||||
echo "User account has been successfuly deleted\n";
|
||||
} else {
|
||||
echo "Query returned error code: " .$answer. "\n";
|
||||
}
|
||||
42
php/list_web_domains.php
Normal file
42
php/list_web_domains.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// Server credentials
|
||||
$hst_hostname = 'server.hestiacp.com';
|
||||
$hst_port = '8083';
|
||||
$hst_returncode = 'no';
|
||||
$hst_username = 'admin';
|
||||
$hst_password = 'p4ssw0rd';
|
||||
$hst_command = 'v-list-web-domain';
|
||||
|
||||
// Account
|
||||
$username = 'demo';
|
||||
$domain = 'demo.hestiacp.com';
|
||||
$format = 'json';
|
||||
|
||||
// Prepare POST query
|
||||
$postvars = array(
|
||||
'user' => $hst_username,
|
||||
'password' => $hst_password,
|
||||
'returncode' => $hst_returncode,
|
||||
'cmd' => $hst_command,
|
||||
'arg1' => $username,
|
||||
'arg2' => $domain,
|
||||
'arg3' => $format
|
||||
);
|
||||
|
||||
// Send POST query via cURL
|
||||
$postdata = http_build_query($postvars);
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
||||
$answer = curl_exec($curl);
|
||||
|
||||
// Parse JSON output
|
||||
$data = json_decode($answer, true);
|
||||
|
||||
// Print result
|
||||
print_r($data);
|
||||
Reference in New Issue
Block a user