Open source survey application

Due to business requirements, I have forked and re-skinned a legacy PHP survey application with material design.

To give back to the community, here’s the updated source:

It contains the following improvements

  • Add material design for user-facing pages
  • Add appropriate ignore to avoid leaking credentials on source control
  • Add default user ID you can set via GET parameter when sending out mass email
  • Stricter .htaccess
  • More readable fonts

How to install zip extension for PHP7

Specifically for LAMP stack / webmin

First, install the module

sudo apt-get install php7.0-zip

Then restart the web server

sudo service apache2 restart
sudo service nginx restart

That’s it!

WARNING: Module mcrypt ini file doesn’t exist under /etc/php/7.2/mods-available

Reason: This module is not available for PHP 7.2 yet, you need to install the 7.1 version and link it to 7.2

Pointing to php7.1-mcrypt with php7.2 will solve the issue here. Below are the steps to configure 7.1 version mcrypt with php7.2

Install php7.1-mcrypt

sudo apt install php7.1-mcrypt

Create symbolic link to php7.1-mcrypt

sudo ln -s /etc/php/7.1/mods-available/mcrypt.ini /etc/php/7.2/mods-available/

Enable mcrypt extension

sudo phpenmod mcrypt

Thanks StackOverflow!

Alternative way

Installing mcrypt on PHP 7.2 or 7.3

To install this extension on PHP 7.2 or 7.3, run the following commands as your server’s root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev php-pear
sudo pecl install mcrypt

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo > /etc/php7.2-sp/conf.d/mcrypt.ini"
sudo service php7.2-fpm-sp restart

Verifying mcrypt Is Installed

You can check that the extension was installed with this command:

php7.2-sp -i | grep mcrypt

The output will look like this:

$ php7.2-sp -i | grep mcrypt
Registered Stream Filters => zlib.*, convert.iconv.*, bzip2.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

Uninstalling the Mcrypt Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/mcrypt.ini
sudo peclX.Y-sp uninstall mcrypt

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

Bug in PHP My admin on Ubuntu 18.04

I got this error every time I tried to query a table in PHPMyAdmin

Warning in ./libraries/sql.lib.php#601
count(): Parameter must be an array or an object that implements Countable


./libraries/sql.lib.php#2038: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#1984: PMA_executeQueryAndGetQueryResponse(
boolean true,
string 'alternativegirls',
string 'tgp_photo',

Turns out there’s a but in the PHP My Admin version that comes with Ubuntu 18.04 running on PHP 7.2

You need to edit /usr/share/phpmyadmin/libraries/sql.lib.php

Replace: (count($analyzed_sql_results['select_expr'] == 1) With:(count($analyzed_sql_results['select_expr']) == 1


Screen Shot 2018-06-26 at 4.13.04 PM.png

Thanks StackOverflow!

PHP result in blank page and 404 in nginx

If I go to a .php file, I got a blank page, if I add a query string ?something=something I got a 404.

I tried to search this error with the script I was trying to use on Google to no avail… and then I added this line

error_log /var/log/nginx/ error;

Who would have thought? Missing the error log result in a blank page!