Author: Bad Joe
How to fix WordPress dashboard or login infinite redirect loop?
As of 20191003, you should be using PHP 7.1 and above for your WordPress websites.
However, some older plugins can cause your WordPress Dashboard or wp-login.php page to fail with an infinite redirect loop.
To diagnose, set ‘WP_DEBUG’ to true in your wp-config.php file, then attempt to login or visit your WordPress dashboard.
If it fails, head to your cPanel/WHM to change your PHP version for your website to 5.5, 5.6, 7.0, 7.2 and the likes.
While switching, you should be able to see error messages to help you diagnose the plugins that is causing the problem.
How to beautify a print_r in PHP?
function console_print($obj) { $js = json_encode($obj); print_r('<script>console.log('.$js.')</script>'); } function prettyPrint($a, $t='pre') {echo "<$t>".print_r($a,1)."</$t>";} // https://github.com/kint-php/kint consider using this
How to write or draw text in a Circle or around a Circle in Photoshop?
Create a path and write on it.
Here’s an informative video:
How to solve and fix “Invalid default value” MySQL error for dates and timestamp?
Last updated: 20211220
To avoid this issue, you need to remove NO_ZERO_DATE from the mysql mode configuration.
- Go to ‘phpmyadmin’. (in WHM not cPanel)
- Once phpmyadmin is loaded up, click on the ‘variables’ tab.
- Scroll down and search for ‘sql mode’.
- Click on the Edit option and remove NO_ZERO_DATE (and its trailing comma) from the configuration line.
- Save (hit ‘save’ on the left side) and that’s it!
- You will have to repeat this on every server upgrade/reboot of your MYSQL.
This is a very common issue in the local environment with wamp or xamp.
This will allow you to use default ” 0000-00-00 00:00:00″ as a timestamp value.
Reference:
https://stackoverflow.com/questions/9192027/invalid-default-value-for-create-date-timestamp-field
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:
- Latest Bootcamp 6 Drivers for Windows 10
- 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.
- Use 7-Zip or Winrar to open the AppleBcUpdate.exe file.
- Head to BootCamp\Drivers\Apple in the file
- Run AppleODDInstaller64.exe and install the drivers.
- 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.
- run in MYSQL : SELECT @@system_time_zone;
- Add this to the first line in PHP code, date_default_timezone_set(‘US/Eastern’);
- Replace ‘US/Eastern’ in Step 2, with the timezone value you got from Step 1.
- In codeigniter, you can place Step 2 line in config.php
- If there are errors, use the right timezones here:
- https://www.php.net/manual/en/timezones.america.php
- 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/ }