Friday, 19 December 2014

Replacing the <? with <?php using Regular expression

If you have older version of php where you probably using the <? tag like instead of <?php, then you may need to exclusively use <?php for newer version of PHP
In such case, please use the below regular expression to replace the tags on your project files;

Text to find:  [\<][\?][\p{Space}|\n]
Replace with:  <?php

Thursday, 18 December 2014

Modifying the System Email Notification email setting for New Registration on Joomla 3+

By default, the joomla send system email notifications to administrator when someone register from frontend. However,  if you are active joomla user and your account's "Receive System emails" is set to "Yes" under "Account Detail tab, then you would be getting email notification when someone register into the website. I am not sure whether it's a Joomla glitch or it has been setup like that.

However, if you need to only send email acknowledgement notification about new user registration to only those members who are active, have administrative privilege ('Administrator'), and who's "Receive System emails" status is set to "Yes, please follow the below step;

1. Go to the /root/components/com_users/models/registration.php,
2. Find the line number 519 on under the public function register($temp) function at line 339.
3. Please replace as below and it would work as mention above;

function register($temp)
 // Get all admin users
  ->select($db->quoteName(array('name', 'email', 'sendEmail')))
  ->where($db->quoteName('sendEmail') . ' = ' . 1);

 // Uncomment the above bit and add the below bit

 // Pulling all the Administrative privilege Users whos sendEmail/System emails is enabled.
  ->select($db->quoteName(array('gm.user_id', 'gm.group_id', 'g.title', '', '', '', 'u.sendEmail', 'u.block')))
  ->from($db->quoteName('#__user_usergroup_map').' AS gm')
  ->join('left', '#__usergroups AS g ON')
  ->join('left', '#__users AS u ON')
  ->where($db->quoteName('g.title') . ' = "Administrator" AND '. $db->quoteName('u.block') . ' = "0" AND ' . $db->quoteName('u.sendEmail') . ' = ' . 1);
 //echo nl2br(str_replace('#__','j3x_',$query));




Tuesday, 16 December 2014

Get a sentence,string initials or abbreviation via Regular Expression

Please use the below function to get the sentence/string initial (abbreviation).

function initials($str) {
        $matches = preg_split("/[,]/", $str);

        $initials = array();
        foreach ($matches as $list) {
            $words = preg_split("/[^\w-]/", ($list));

            $initial = '';
            foreach ($words as $word) {
                $initial .= strtoupper($word[0]);
            $initials[] = $initial;

        return ( implode('/', $initials) );

Also, please use the link to understand more about regular expression using this Regular Expression Tutorials

Friday, 12 December 2014

Installing ionCube PHP Loader in Windows and Linux

If you are stuck with the below errors, this may be good tutorial for you.

.....requires the ionCube PHP Loader ioncube_loader_win_5.4.dll to be installed by the website operator. If you are the website operator please use the ionCube Loader Wizard to assist with installation.

In Windows
Please go to download the IonCube loader from the IonCube website and you unzip the file and click the loader-installer.exe and the window pop-up.
To install in your local computer, please use the below format;
Installation Type: Local machine
Base URL: http://localhost/
Base directory: your_htdocs_folder_full_path (e.g. C:\Bitnami\wampstack\apache2\htdocs, C:\xampp\htdocs)

Then, click the start and once installation process completes, please restart the apache. Also, if you goto php.ini file, the zend_extension="your_ioncube_dll_path" is added to the beginning of the file, which you can move to the right place within the file.

FYI: I would be adding to do same on Linux soon..


To Enable the ionCube PHP Loader for WHMCS installation.
1. Please download the Linux package (64 bits or 32 bits) form the IonCube Loader page.
2. Unzip the files and create a ioncube/ in your public_html/ folder and move all those extracted files in it.
3. Create the php.ini file with below content in it.
zend_extension = "/home/your_site_username/public_html/ioncube/"

4. Then copy the above php.ini file across in your WHMCS main folder (where you are going to install), its install/, admin/ folders.

Then, try refreshing the page. It should be working.