You can use hooks in SolusVM 2 to automatically run custom scripts before or after specific events take place. Hooks should be set under this directory: /usr/local/solus/hooks/, they can be written using Bash, PHP, Python or else.

 
Basically what it does is whenever there is an event it sends in stdin a json snap with the event and the action (e.g.: new installation, os reinstall, restart, etc) to all files under the hooks’ folder.
 
Example of JSON code:
{
  "action": "server-restart",
  "stage": "pre",
  "data": {
    "uuid": "915b5ca2-ff02-45ab-ba73-2e90793e6819",
    "virtualization_type": "vz"
  }
}

Continue reading

Following is a basic code to get the last received e-mail using IMAP protocol:

ini_set('display_errors', 1);
error_reporting(E_ALL);

// Debug flag
$mail = imap_open('{mail.example.com:143/debug}', 'test@example.com', 'password');
// or using SSL/TLS $mail = imap_open('{mail.example.com:993/ssl/debug}', 'text@example.com', 'password');

$last_mail = imap_num_msg($mail);

var_dump(imap_headerinfo($mail, $last_mail));
echo imap_body($mail, $last_mail);

imap_close($mail);

One of the funniest and useful things some users tend to do when having a max connection limitation on MySQL is to create several users cyclically or even randomly.

$db_users = array("db_user1","db_user2","db_user3","db_user4","db_user5","db_user7"...);

$db_user = $users [rand(0,5)];

$db_connection = new mysqli($db_host, $db_user, $db_password, $db_name);