How to fix Composer not working on your cPanel/WHM server?

Composer not installing or working properly? Getting loads of error messages simply to run?

It looks something like this:

Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/Mbstring.php:661
Stack trace:
#0 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/bootstrap.php(48): Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth(' [Composer\\Dow...', 'ASCII')
#1 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Helper/Helper.php(54): mb_strwidth(' [Composer\\Dow...', 'ASCII')
#2 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php(654): Symfony\Component\Console\Helper\Helper::strlen(' [Composer\\Dow...')
#3 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(Composer\Downloader\TransportException), Object(Symfony\Component\Console\Output\StreamOutput))
#4 phar:///opt/cpanel/composer/bin/composer/src/Composer/Console/Application.php(103): Symfony\Component\Console\Applicatio in phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/Mbstring.php on line 661
[aspapp@client-192-129-227-26 www]$ composer require maltyxx/restclient

 

1. Google the error message for more info: https://stackoverflow.com/questions/40800616/call-to-undefined-function-symfony-polyfill-mbstring-iconv-strlen
2. Install missing extensions: https://cyberpersons.com/2016/10/21/install-missing-php-extensions-cpanelwhm/
3. Then try again!

How to solve SMTP emails not sending on your cPanel web server?

If you run a cPanel dedicated server, and your outgoing SMTP emails are sent from your PHP application code, but not delivering successfully, this could be due to configuration issue with your WHM / CSF firewall.

Even after you have added the outgoing ports 465, 567, and usual SMTP / TLS ports, you are still having this issue?

Then make sure you have checked your WHM > Tweak Settings > Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) . Turn that off.

When restarting your CSF firewall, you may also see the following message:

WARNING The option “WHM > Tweak Settings > Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)” is incompatible with this firewall. The option must be disabled in WHM and the SMTP_BLOCK alternative in csf used instead

How and what can I use with DOACE 220v to 110v voltage converter?

Ok so you have one of these and you want to be sure what products work on which ports before destroying your expensive electronics? Here’s a list of electronics that have been tested and the locations.

Apple Macbook Pro:

  • Target Country: Cambodia
  • Target voltage: 230V
  • Product (Apple Macbook Pro) voltage: 100V to 240V
  • Product (Apple Macbook Pro) connected port on DOACE voltage converter: 1x Dual Adapter Sockets

The Apple Macbook Pro power adapter is a multi-voltage device, meaning it can work in countries with voltage from 100V to 240V. Cambodia’s voltage of 230V is within that range, therefore your Apple Macbook Pro can connect directly to the power socket in Cambodia.

If you still want to connect it to the DOACE voltage converter device, DO NOT connect it to the “Auto Switch Voltage Converter Socket”! Use one of the “Dual Adapter Socket” instead.

How to use an Apple Superdrive on a non-Mac PC on Windows?

You need:

  1. Latest Bootcamp 6 Drivers for Windows 10
  2. If you are an advanced user, you can also sift through this file using Wordpad to find an even updated driver, but the above file in Step 1 will work as of 20181203.
  3. Use 7-Zip or Winrar to open the AppleBcUpdate.exe file.
  4. Head to BootCamp\Drivers\Apple in the file
  5. Run AppleODDInstaller64.exe and install the drivers.
  6. That’s it! Your DVD drive should now appear.

 

References:

http://osxdaily.com/2018/02/25/use-apple-superdrive-windows/

https://digiex.net/threads/apple-windows-10-bootcamp-6-drivers-download-applebcupdate-exe-april-1st-2016.14828/

 

How to deal with time mismatch in MySQL records when date(‘Y-m-d H:i:s’) in PHP does not match MySQL’s server time?

Try setting the locale in PHP for the current application in code.

  1. run in MYSQL : SELECT @@system_time_zone;
  2. Add this to the first line in PHP code, date_default_timezone_set(‘US/Eastern’);
  3. Replace ‘US/Eastern’ in Step 2, with the timezone value you got from Step 1.
  4. In codeigniter, you can place Step 2 line in config.php
  5. If there are errors, use the right timezones here:
    1. https://www.php.net/manual/en/timezones.america.php
    2. date_default_timezone_set(‘America/New_York’); used for aspa and webhooks.

 

 


function getCurrentDatabaseTime() {
    $ci =& get_instance(); 
    $ci->load->database();
	
	$query = $ci->db->query('SELECT NOW() as `current_time`;');
    // if exist
    $results = array();
    if ($query->num_rows() > 0) {
        foreach ($query->result_array() as $row)
            {
                return $row;
            }            
    }
        
    return FALSE; 	
}

function getCurrentDatabaseTimezone() {
	//SELECT @@system_time_zone
    $ci =& get_instance(); 
    $ci->load->database();
	
	$query = $ci->db->query('SELECT @@system_time_zone as `current_time_zone`;');
    // if exist
    $results = array();
    if ($query->num_rows() > 0) {
        foreach ($query->result_array() as $row)
            {
                return $row;
            }            
    }
        
    return FALSE;	
}

function getPacificTime($timeString) {
// Right now it's about four minutes before 1 PM, PST.
$pst = new DateTimeZone('America/Los_Angeles');
//$three_hours_ago = new DateTime('-3 hours', $pst); // first argument uses strtotime parsing
$now = new DateTime($timeString, $pst); // first argument uses strtotime parsing
//echo $three_hours_ago->format('Y-m-d H:i:s'); // "2010-06-15 09:56:36"
return $now->format('Y-m-d H:i:s');	
}


// inside a controller , index()

public function index() {
		$this->load->helper('common');
		$current_timezone_array = getCurrentDatabaseTimezone();
		$current_time_array = getCurrentDatabaseTime();
		echo 'Current Database Timezone: '.$current_timezone_array['current_time_zone'];
		echo '<hr>';
		echo 'Current Database Time: '.$current_time_array['current_time'];
		echo '<hr>';
		echo 'Current PHP Server Time: '.date('Y-m-d H:i:s');
		echo '<hr>';
		echo 'Current Pacific Time: '.getPacificTime('now');
		if ($current_time_array['current_time'] != date('Y-m-d H:i:s')) echo '<hr><font color=red>Possible time issues! Database time and server time mismatch!</font><hr>';
		else echo '<hr><font color=green>Good! Database time and server time matches!</font><hr>';
		
		// application should have mysql time and server time matching for things to work properly.
		// see: https://apps.badjoerichards.com/apps/developerhack/deal-time-mismtach-mysql-records-datey-m-d-php-not-match-mysqls-server-time/

}

How to install kext on your Mac OS easily?

You’ve tried to manually install kext extensions for you Mac OS.

You’ve meddled with permissions and copied the files, but things aren’t working.

The solution is to simply use the Kext utility.

Of course there are several prerequisites, but simply spend some time fixing them, and you’re going to thank me for the amount of time you have saved.

The problem with all the guides around is that they are mostly written by hard-core or self-taught developers – so only they would understand what they teach. And most of these guides are hard to follow and get right. That’s what this site is for, building advanced guides that are simple to follow – for the pros and newbies alike.

 

How to increase the maximum upload file size (1MB) on a WordPress Multisite?

In case you’ve spent the last 15 minutes of your life googling for answers, here’s the answer you need:

There’s a special setting for this on a Wordpress Multisite Network.

  1. Head to My sites > Network Admin > Settings (http://www.example.com/wp-admin/network/settings.php)Wordpress Network Admin Settings
  2. Scroll down and look for Upload Settings
  3. Increase the ‘Max upload file size’ field.Max upload file size

How to protect your iPhone 7 (3 best ways) or 7s and save $960?

So you’ve just gotten the latest new iPhone 7 or 7s, and you’re figuring out how to best protect it? Well, before you start bringing it out with you when you go to work, school or gym tomorrow, make sure you’ve at least done the following 3 things. Alright, or at least just one of them, please?

Here are the 3 top and best ways to protect your iPhone 7.

  1. Get a screen protector. ($7.99) Believe me it’s well worth the $8 dollars. Have you dropped your phone before? Have you dropped it more than once in the past year? If you answered yes to any of the above, you’ll know it costs anywhere for $80 to $120 just to have your iPhone screen fixed. ($7.99 to save $80.00 in repairs)iPhone 7 screen protector
  2. Get a case. ($10.98) And as a savvy user, I’m talking about a slim, transparent one that protects your phone from scratches and also falling from your pockets – no nonsense. ($10.98 to save $80.00 in repairs)iPhone 7 case protect
  3. Turn on Find my iPhone. (Free) You just spent $800 getting a brand new iPhone 7 or 7s, now you don’t want to lose it. Turn it on with the following steps:
    1. From the Home screen, navigate: Settings > Privacy > Location Services.
    2. Ensure that the Location Services switch is on.
    3. Tap System Services.
    4. Tap the Find My iPhone switch to turn on.

Now anytime you need to find your phone. Head to iCloud.com , log in, and click on ‘Find my iPhone’. ($0.00 to save $800.00 potentially)

There you have it. While we’ll continually figure out the top best ways to protect your new iPhone 7, feel free to let us know if you have new or better ideas which we can update this list with. This is the 3 best ways to protect your new iPhone 7.