This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Below is a php time range function you can add in your php library and call it where you want to add time range dropdown. | |
function createTimeRange($startTime, $endTime, $interval = '15 mins', $format = '12') { | |
try { | |
if(!isset($startTime) || !isset($endTime)) { | |
throw new exception("Start or End time is missing"); | |
} | |
$startTime = strtotime($startTime); | |
$endTime = strtotime($endTime); | |
$currentTime = time(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getAge($dob) { | |
$today = date("Y-m-d"); | |
$diff = date_diff(date_create($dob), date_create($today)); | |
return $diff->format('%yYears, %mMonths, %dDays'); | |
} | |
// You can add the above function in your php library and use any where to calculate the age of the user by their date of birth. | |
echo getAge('19-10-1988'); | |
// Output: 27Years, 10Months, 19Days | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Here I have created a quick function in php to extract zip file. | |
Unzipping file is now very easy using php. | |
In php there is a function called ZipArchive::extractTo, using this predefined function you can easily extract zip archive. | |
*/ | |
function unzip($file, $location) { | |
$zip = new ZipArchive; | |
if ($zip->open($file) === TRUE) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Suppose you have three sub domain like http://au.example.com, http://ng.example.com, http://in.example.com Australia, Nigeria, India. | |
And If some one type http://example.com then he/she redirected county specific url as per geo ip location. Here is the solution. | |
// By PHP | |
First of all download geoplugin library and call it on your page. | |
http://www.geoplugin.com/_media/webservices/geoplugin.class.phps | |
<?php | |
require_once('geoplugin.class.php'); | |
$geoplugin = new geoPlugin(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is quick tutorial about How to detect mobile device and transfer visitor to mobile version of your website. | |
If you don't have a mobile responsive website and you created separate mobile version of website. | |
If user open your website in mobile then he/she should automatically redirect mobile version of your website. | |
Then the following function will help you to achieve this goal. | |
Like you have seen in many popular website like facebook.com. | |
If you open facebook on mobile's browser you will be automatically redirected on their mobile version m.facebook.com. | |
// Here is the function in PHP | |
<?php | |
$useragent=$_SERVER['HTTP_USER_AGENT']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
In this tutorial I am going to show you some PHP Methods By which you can easily download remote server image on your local server. | |
Suppose you don't have FTP access of images but you are able to access images via http port and you want to perform bulk image download. | |
Then these methods are very useful and you can try any of them to download and save a remote images on your server folder. | |
*/ | |
// Method-1: By using simple copy() function in PHP | |
copy("REMOTE SERVER IMAGE URL", 'LOCAL SERVER PATH'); | |
// ie: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
You can easily use PHP array in javascript you only need to convert PHP array into JSON format Using json_encode() function. | |
PHP array can be converted to JavScript array and accessible in JavaScript. | |
Whatever the array type is, a single or multidimensional or indexed or associative array. | |
*/ | |
//In PHP | |
var $booksArray = array("Book-1", "Book-2", "Book-3"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_GET['signature'])){ | |
ini_set('max_execution_time', 0); | |
$useragent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36"; | |
$v = base64_decode($_GET['signature']); | |
parse_str($v); | |
if(!isset($mime)){ | |
$mime = "video/mp4"; | |
} | |
$extension = explode("/", $mime)[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function AdblockDetector(){ | |
} | |
AdblockDetector.prototype.run = function() { | |
var ad = document.querySelector("ins.adsbygoogle"); | |
if(ad && ad.innerHTML.replace(/\s/g, "").length == 0) { | |
//Adblock detected | |
if(typeof ga !== 'undefined') { | |
ga('send', 'event', 'AdBlock', 'True', {'nonInteraction': 1}); //event hit will not be used in bounce-rate calculation. | |
}else if(typeof _gaq !== 'undefined') { | |
_gaq.push(['_trackEvent', 'Adblock', 'True', undefined, undefined, true]); //event hit will not be used in bounce-rate calculation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var linkList = [ | |
"https://google.com", | |
"https://yahoo.com", | |
"https://facebook.com", | |
"https://twitter.com", | |
"https://ebay.com", | |
"https://youtube.com" | |
]; | |
var randomLink = linkList[Math.floor(Math.random()*linkList.length)]; |