How do I use the ternary operator ( ? : ) in PHP as a shortcut for “if / else”?

PHP 5+

(condition) ? /* value to return if condition is true */ 
            : /* value to return if condition is false */ ;

syntax is not a “shorthand if” operator (the ? is called the conditional operator) because you cannot execute code in the same manner as if you did:

if (condition) {
    /* condition is true, do something like echo */
else {
    /* condition is false, do something else */

PHP 7+

As of PHP 7, this task can be performed simply by using the Null coalescing operator like this :

// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';

// Coalescing can be chained: this will return the first
// defined value out of $_GET['user'], $_POST['user'], and
// 'nobody'.
$username = $_GET['user'] ?? $_POST['user'] ?? 'nobody';

ftp connection via Midnight Commander

Midnight Commander has ability to connect to ftp in a pane, so it’s possible to use it to connect to a remote FTP server.

Go to Shell, execute mc and press F9 to call the menu. Select Left/Right window, select FTP Link

Enter FTP server details in one of the following formats:

username:password@host           #for non-anonymous login;
host                             #for anonymous login;
!username:password@host          #for servers behind the firewall, through proxy servers;
username:password@host:port      #for servers using non std port;
username:password@host/directory #to go to specific directory. 

Once you’ve connected to your remote FTP server, you can copy any files or folders between the panes in your Midnight Commander and any directory on your remote FTP server.


How to delete emails from qmail queue on H-Sphere

First check the status of your queue:

# /var/qmail/bin/qmail-qstat
messages in queue: 6751
messages in queue but not yet preprocessed: 56

After you find and stop the spammer, you now have a bunch of email on your QMail queue. Here’s how to remove it

take a “” that happens in emails from the spammer (usually the sender) and run this command:

grep -R /var/qmail/queue/mess/* | awk -F”:” ‘{print “rm -f ” $1}’ | sh

make sure the quotes and single quotes are straight, not round upon copy/paste

That will delete the emails that contain that

but it would leave behind various indexes and later on your users would start receiving bouncebacks for emails they’ve never sent!


this removes not only messages, but all the mentioning of those messages from everywhere. (sasa4uk)


Hsphere file paths

Socket file: /var/lib/mysql/mysql.sock
Database file: /var/lib/mysql
mysql password file: /var/lib/mysql/.my.cnf
Error log: /var/log/mysql/error.log


Proftpd is default with hsphere.

Configuration file: /hsphere/shared/config/ftpd/proftpd.conf
Log file: /hsphere/local/var/proftpd/xferlog


networking Uncategorized

Cannot Map NAS in Windows 10 Pro x64

I have purchased a D-link DNS 321, and after several hours of trying I could not map the NAS as a drive nor access it using NFS

Objective: use NAS as network file server.

Go to Programs and Features in Windows 10 Control Panel. Click Turn Windows features on or off link.
Scroll down to SMB 1.0/CIFS File Sharing Support and check all of the features. Click OK.
Once all of the installation is done, click Restart now.
In Windows Explorer go to Network => Storage (or whatever your NAS’ name is) and you will be presented with all the Volumes available.

CURL ERROR: SSL certificate problem: self signed certificate in certificate chain (

Recently there was a spike in customers that reported their sites credit card processing errors which, according to log files resulted in the following error produced:

CURL ERROR: SSL certificate problem: self signed certificate in certificate chain


Testing (oneliner):

echo | openssl s_client -connect -showcerts -verify 10 -CAfile /home/path/to/cert.pem

Make sure to replace “/home/path/to/cert.pem” with the real path. If all is good you’ll get something like this at the end:

Verify return code: 0 (ok)

Otherwise you’ll see:

Verify return code: 19 (self signed certificate in certificate chain)