Category Archives: Uncategorized

How to Validate JSON in PHP

Simple PHP function to validate JSON in PHP: function is_valid_json($string) { return !empty($string) && is_string($string) && is_array(json_decode($string, true)) && json_last_error() === 0; }function is_valid_json($string) { return !empty($string) && is_string($string) && is_array(json_decode($string, true)) && json_last_error() === 0; } Alternatively you can do like this (doing only one json_decode() call): $output = json_decode($string, true);   if (!is_array($output) […]

PHP CURL Download Remote URL to File

Simple PHP snippet to download a remote URL to a file: function curl_download_to_file( $url, $file ) { $fp = fopen($file, ‘w+’); $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_TIMEOUT, 10); curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1"); curl_setopt ($curl, CURLOPT_HEADER, 0); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); […]

PHP Check if a file was modified more than 1 hour ago

Simple PHP snippet to check if a file was last modified more than 1 hour ago: if(time() – filemtime("/path/to/file") >= 1 * 3600) { echo "File was modified more than 1 hour ago"; }if(time() – filemtime("/path/to/file") >= 1 * 3600) { echo "File was modified more than 1 hour ago"; } Check if a file […]

Improve TP-Link TL-MR6400 WiFi Download Speed

I recently got a TP-Link TL-MR6400 to use it with a 4G SIM card. However once I configured all I noticed that the WiFi download speed was 50% slower than with wired (cable). So I made a quick test by disabling the WiFi password (check “Disable Security”): And I immediately noticed the WiFi download speed […]

Merge Two Redis Databases via PHP

Simple PHP script I used to merge two Redis databases. In short, the PHP script adds all redis-1 database (0) data to redis-2 database (0). The PHP script first retrieves all keys->values from redis-1 database (0) and then it adds via set() all keys->values to redis-2 database (0). // Connect to Redis Database 1   […]

How to Connect to Redis Database via PHP

First make sure to install PHP extension for Redis: https://github.com/phpredis/phpredis On Debian-like OS you can install it this way: apt-get install php7.0-redisapt-get install php7.0-redis Then you can connect to Redis via PHP this way: $redis = new Redis();   try { $connected = $redis->connect(‘127.0.0.1’, 6379, 1); } catch(Exception $e) { echo "Failed to connect to […]

PHP Shell_Exec() Get Complete Output as String

With PHP you can use shell_exec() to execute a command via shell and return the complete output as a string, here si a quick example to do so: $output = shell_exec(‘ls -lart’);$output = shell_exec(‘ls -lart’); However some commands like “gunzip -t” may show empty results. To fix that, just add 2>&1 to the end of […]

SMS messages from 1-410-200-500 are a scam

There is a new wave of fraudulent SMS sent from 1-410-200-500 to users located mainly in India, USA and EU. The fraudulent SMS messages contain a malicious URL that redirects users to a fraudulent website used to steal your personal information and credit card, make sure you never click on the link and do not […]

“Google FREE Apple iPhone X Visitor Browser Opinion Survey” Scam

If you got an email with a subject like “Google FREE Apple iPhone X Visitor Browser Opinion” beware that it is a scam! Do not participate in the survey, it is a fraudulent website that push you to purchase other products so the online scammers are paid for each purchase you make. This is the […]

Email addresses associated with suspicious online shops

Here is a list of email addresses associated with suspicious and potentially fraudulent online shopping websites that sell counterfeit products or that just get your money without sending you anything. Most of these shopping sites are operated by people located in China. wholesalenewhat@gmail.com support1@webmicroshop.com anweiler@discontseason.com surpport@cctmalls.com livechat.kc@gmail.com service@ezvmall.com system@ezvmall.com bag@list-customs-service.com service.negozio.italian@gmail.com service@mx2.commerce-line.info alex@promt-reply.com nina@promotion-town.com alex@promt-reply.com […]