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 | |
setlocale(LC_ALL, 'en_US.UTF8'); | |
function slugit($str, $replace=array(), $delimiter='-') { | |
if ( !empty($replace) ) { | |
$str = str_replace((array)$replace, ' ', $str); | |
} | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); | |
$clean = strtolower(trim($clean, '-')); | |
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); |
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 | |
// This is PHP function to convert a user-supplied URL to just the domain name, | |
// which I use as the link text. | |
// Remember you still need to use htmlspecialchars() or similar to escape the | |
// result. | |
function url_to_domain($url) | |
{ |
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
I took my chance to provide full .htaccess code to pass on Google PageSpeed Insight: | |
1. Enable compression | |
2. Leverage browser caching | |
# Enable Compression | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/rss+xml |
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
@media (min-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */ } | |
@media (min-width:481px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ } | |
@media (min-width:641px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ } | |
@media (min-width:961px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } | |
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ } | |
@media (min-width:1281px) { /* hi-res laptops and desktops */ } |
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
.htaccess flag list | |
C (chained with next rule) | |
CO=cookie (set specified cookie) | |
E=var:value (set environment variable var to value) | |
F (forbidden - sends a 403 header to the user) | |
G (gone - no longer exists) | |
H=handler (set handler) | |
L (last - stop processing rules) | |
Last rule: instructs the server to stop rewriting after the preceding directive is processed. |
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)]; |
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
<?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
<?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 | |
/* | |
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: |
OlderNewer