Category Archives: Uncategorized

Download OpenVPN 2.4.7 and TAP-Windows

From here you can download latest OpenVPN version: https://openvpn.net/community-downloads/ And from here you can download all latest stable versions: https://build.openvpn.net/downloads/releases/latest/ It includes also TAP-Windows versions.

How to Configure OVH Email POP3 with Thunderbird

When adding a new email address (OVH hosted) on Thunderbird: The red-removed part should be your website. Reference (Italian): https://docs.ovh.com/it/emails/email_condivisa_guida_alla_configurazione_di_thundebird/

What is the Correct JSON Content-Type for HTTP Headers?

Many web services uses different content-type for JSON data, i.e: application/json application/x-javascript text/javascript text/x-javascript text/x-jsonapplication/json application/x-javascript text/javascript text/x-javascript text/x-json But what is the correct content type to use for JSON data? For JSON text you should use application/json (read more on RFC 4627). For JSONP (runnable javascript) with callback, use application/javascript. You should read also […]

PHP Notice: Undefined offset: 1 (Array)

How to fix PHP Notice: Undefined offset: 1? This PHP snippet will generate a “Undefined Offset” notice: $parts = explode(".", "aaaa");   $data = $parts[1];   print_r($data);$parts = explode(".", "aaaa"); $data = $parts[1]; print_r($data); This happens because $parts[1] is undefined. To fix this “Undefined Offset” notice just check if isset($parts[1]): $parts = explode(".", "aaaa");   […]

How to Find PHP.ini Location

Need to know where is located your PHP.ini file? Locate PHP.ini with Find The best way (in my opinion) is to use “find” to locate the php.ini: find / -name php.inifind / -name php.ini You should get something like this: /etc/php/7.3/fpm/php.ini /etc/php/7.3/cli/php.ini/etc/php/7.3/fpm/php.ini /etc/php/7.3/cli/php.ini So this way you will locate PHP.ini for both PHP7 FPM and […]

How to Enable Display of Errors in PHP

First edit your PHP.ini file to make sure display_errors is enabled: display_errors = ondisplay_errors = on Then if you changed this value, you’ll need to restart PHP7-FPM process: /etc/init.d/php7.3-fpm restart/etc/init.d/php7.3-fpm restart Additionally you may prepend these lines on your PHP script: error_reporting(E_ALL); ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1);error_reporting(E_ALL); ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1);

Go One Directory Level Up/Back with Dirname() in PHP

For PHP < 5.3 use this: echo realpath(dirname(__FILE__) . '/..');echo realpath(dirname(__FILE__) . '/..'); For PHP 5.3 to 5.6 use this: echo realpath(__DIR__ . '/..');echo realpath(__DIR__ . '/..'); For PHP >= 7.0 use this: echo dirname(__DIR__, 1);echo dirname(__DIR__, 1); References: https://www.php.net/manual/en/function.dirname.php

Get Current Script Path in PHP

Snippet to get current script path in PHP: echo realpath(dirname(__FILE__));echo realpath(dirname(__FILE__)); It will output the current PHP script path, i.e: /var/www/domain.com/htdocs/libs/var/www/domain.com/htdocs/libs

How to Extract a GZ file with PHP

A simple function to extract a .gz compressed file with PHP: function php_extract_gz_file($gzfile, $savefileas, $removegz = false) { if(!file_exists($gzfile)) return false;   $gzopen_handle = gzopen($gzfile, ‘rb’);   if(!$gzopen_handle) return false;   $outfile_handle = fopen($savefileas, ‘wb’);   if(!$outfile_handle) return false;   while(!gzeof($gzopen_handle)) { fwrite($outfile_handle, gzread($gzopen_handle, 4096)); }   fclose($outfile_handle);   gzclose($gzopen_handle);   if(!file_exists($savefileas)) return false;   […]

How to Install VirtualBox Guest Additions on Windows Guest

From your Windows VM open Internet Explorer and open: http://download.virtualbox.org/virtualbox/6.0.10/http://download.virtualbox.org/virtualbox/6.0.10/ *** http://download.virtualbox.org/virtualbox/ -> View all VirtualBox versions *** Then download the file: VBoxGuestAdditions_6.0.10.isoVBoxGuestAdditions_6.0.10.iso Then download and install 7-zip: https://www.7-zip.org/download.htmlhttps://www.7-zip.org/download.html Now right-click on VBoxGuestAdditions_6.0.10.iso and select: 7-Zip -> Extract Here7-Zip -> Extract Here This will extract the files from the ISO file. Now click on VBoxWindowsAdditions-amd64.exe […]