View wallpaper.php
This file contains 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
/* -------------------------------------------------------------------- */ | |
/* [Download 100 Wallpapers] from taskade.com #php #function #wallpaper */ | |
/* -------------------------------------------------------------------- */ | |
if ( !is_dir( 'wallpaper' ) ) { | |
mkdir( 'wallpaper' ); | |
} |
View Brightness.php
This file contains 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
/* -------------------------------------------------------------------------------------------------------------------------------- */ | |
/* [Brightness] Change the brightness of a color by a percentage (0.3 = 30% lighter / -0.4 = 40% darker) #php #function #brightness */ | |
/* -------------------------------------------------------------------------------------------------------------------------------- */ | |
function adjustBrightness($hexCode, $adjustPercent) { | |
$hexCode = ltrim($hexCode, '#'); | |
if (strlen($hexCode) == 3) $hexCode = $hexCode[0].$hexCode[0].$hexCode[1].$hexCode[1].$hexCode[2].$hexCode[2]; | |
$hexCode = array_map('hexdec', str_split($hexCode, 2)); | |
foreach ($hexCode as & $color) { | |
$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
View isBot.php
This file contains 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
/* ---------------------------------------------------------------- */ | |
/* [is it a Bot] Check if a user_agent is a Bot #php #function #bot */ | |
/* ---------------------------------------------------------------- */ | |
function isBot($user_agent='') { | |
if (empty($user_agent)) $user_agent = $_SERVER['HTTP_USER_AGENT']; | |
$bot_regex_pattern = "(googlebot\/|Googlebot\-Mobile|Googlebot\-Image|Google favicon|Mediapartners\-Google|bingbot|slurp|java|wget|curl|Commons\-HttpClient|Python\-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST\-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub\.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum\.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips\-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sit |
View contrast.php
This file contains 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
/* ---------------------------------------------------------------------------------------------------------------------- */ | |
/* [Contrast Color] Decide contrast colour in white or black depending on the background colour #php #function #contrastcolor */ | |
/* ---------------------------------------------------------------------------------------------------------------------- */ | |
function contrast($color, $lightColor='#FFFFFF', $darkColor='#000000') { | |
/** | |
* This is useful for ensuring that a color is readable against a background, | |
* which is also useful for accessibility compliance. | |
*/ | |
// REMOVE # IF THERE IS ONE |
View slugify.php
This file contains 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 | |
/* --------------------------------------------------------------- */ | |
/* [slugify] make slug from e.g. title string #php #function #slug */ | |
/* --------------------------------------------------------------- */ | |
function slugify($string=null) { | |
$LIST = [ | |
' ' => '-', |
View print_var_name.php
This file contains 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 | |
/* -------------------------------------------------------------------------- */ | |
/* [Print var name] Function that print the varname #function #debug #varname */ | |
/* -------------------------------------------------------------------------- */ | |
/** | |
* USE: print_var_name($var) | |
* PRINT: var | |
* @see https://stackoverflow.com/a/36921487 |
View truncate.php
This file contains 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 | |
/* ----------------------------------------------------------------------------------------- */ | |
/* [Truncate] Function that truncate a string and don't break words #php #function #truncate */ | |
/* ----------------------------------------------------------------------------------------- */ | |
function truncate($string, $max_length, $breakWords=false, $append='…') { | |
$strLength = mb_strlen($string); | |
// IF IT'S NOT TO LONG RETURN IT AS IT IS | |
if ($strLength <= $max_length) return $string; |
View checkMime.php
This file contains 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
/* ----------------------------------------------------------------------- */ | |
/* [Check Mime Type] Check if URl is a given MimeType #php #function #mime */ | |
/* ----------------------------------------------------------------------- */ | |
function checkMime($url, $mime='application/pdf') { | |
// MP3 = 'audio/mpeg' - PDF = 'application/pdf' | |
if (!function_exists('curl_init')) die('ERROR - Please install CURL on your PHP!'); | |
$a = parse_url($url); | |
if (checkdnsrr(str_replace('www.','',$a['host']),'A') or checkdnsrr(str_replace('www.','',$a['host']))) { | |
$ch = @curl_init(); |
View doSMTPValidation.php
This file contains 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
/* ------------------------------------------------------------------------------ */ | |
/* [Mail Validation] Use SMTP to validate eMail Address #php #function #mailcheck */ | |
/* ------------------------------------------------------------------------------ */ | |
function doSMTPValidation($email, $probe_address='', $debug=false) { | |
$output = ''; | |
if (!$probe_address) $probe_address = $_SERVER['SERVER_ADMIN']; | |
if (preg_match('/^([a-zA-Z0-9\._\+-]+)\@((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,7}|[0-9]{1,3})(\]?))$/', $email, $matches)) { | |
$user = $matches[1]; |
View getLatLong.php
This file contains 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
/* ---------------------------------------------------------------------------------------- */ | |
/* [getLatLong] Get lat and long coordinatesby address from Google Maps #php #function #geo */ | |
/* ---------------------------------------------------------------------------------------- */ | |
function getLatLong($address){ | |
if (!is_string($address)) die('ERROR - Address must be a string!'); | |
$url = sprintf('https://www.google.com/maps/place/%s', rawurlencode($address)); | |
$result = file_get_contents($url); | |
preg_match('!center=(-?\d+\.\d+)%2C(-?\d+\.\d+)&zoom=!U', $result, $match); | |
$_coords['lat'] = $match[1]; |
NewerOlder