Posts


https://www.vultr.com

The Everywhere Cloud

Deploy an instance.
Accelerate your application.


Replacing split() with preg_split() in PHP

Image
After upgrading PHP, some scripts such as those used in old Drupal systems may report the fatal error "undefined function split()" due to the function's deprecation and removal. Simply replace it with preg_split() to solve the problem. ========== 1. Find the split() function. split($pattern, $subject); 2. Convert it to the preg_match() function as shown. preg_split( "/".$pattern."/" , $subject); ==========

Avoiding the preg_replace() /e Modifier in PHP

Image
After upgrading PHP, some scripts such as those used in old Drupal systems may report an error on preg_replace() that "the /e modifier is no longer supported" due to the modifier's deprecation and removal for being a security risk. Replace it with preg_replace_callback() to solve the problem. ========== 1. Find the preg_replace() function. preg_replace ("/".$pattern."/e", $replacement, $subject); 2. Convert it to the preg_replace_callback() function as shown. preg_replace_callback( "/".$pattern."/" ,         function ($args) { return nameOfCallback($args); } ,         $subject ); ==========

Replacing ereg() with preg_match() in PHP

Image
After upgrading PHP, some scripts such as those used in old Drupal systems may report the fatal error "undefined function ereg()" due to the function's deprecation and removal. Simply replace it with preg_match() to solve the problem. ========== 1. Find the ereg() function. ereg($pattern, $subject, $matches); 2. Convert it to the preg_match() function as shown. preg_match( "/".$pattern."/" , $subject, $matches); ==========

Debugging Drupal WSOD Errors

Image
Whenever errors are encountered, content management systems (CMS) like Drupal just stop working without displaying anything, commonly referred to as the "White Screen of Death" (WSOD). Applications that use CMS are usually accessible to the general public, so it is a security risk to allow such systems to always spit out error reports that may give attackers an idea of how a site is configured. An administrator with command-line access can simply look into the server logs to figure out what went wrong, but this may not always be the case in some shared-hosting services. Alternatively, the administrator can just enable the debugging feature of PHP to determine the error and copy the report, then disable it a few seconds later. The probability that attackers can gain any useful insight in that small time frame is very low. The following procedure shows how the PHP debugging feature can be enabled in Drupal temporarily. ========== 1. In the Drupal folder, open the file ...

Self-Signed Certs for Apache in Debian-based Linux

Image
The following procedure shows how to apply self-signed certificates to the Apache web server in Debian-based Linux distributions. After creating and installing  the TLS/SSL certificate/key pair, they can be utilized to  secure Debian-based Linux web services  with encryption during the development and testing process. It is important to keep in mind that self-signing may be deemed UNTRUSTWORTHY in a production environment. ========== 1. Go to the directory containing the Apache site configuration files. user@host: $ cd /etc/apache2/sites-available 2.  BACK UP the default HTTPS configuration file for the secure site. user@host: $ sudo cp default-ssl.conf default-ssl-conf.back 3. Open the default HTTPS configuration file. user@host: $ sudo nano default-ssl.conf 4. Find and modify the following Apache directives. # BEGIN CODE # ... SSLCertificateFile /etc/ssl/certs/myserver.crt # The self-signed certificate. SSLCertificateKeyFile /...