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(); |
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]; |
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]; |
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
/* ------------------------------------------------------------------------------------------- */ | |
/* [get HTTP Response Code] Get HTTP Header Response Code from Server #php #function #httpcode */ | |
/* ------------------------------------------------------------------------------------------- */ | |
function getHttpResponseCode($url) { | |
if (!function_exists('curl_init')) die('ERROR - Please install cURL on your PHP!'); | |
$ch = @curl_init($url); | |
@curl_setopt($ch, CURLOPT_HEADER, TRUE); | |
@curl_setopt($ch, CURLOPT_NOBODY, TRUE); | |
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); |
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
/* ----------------------------------------------------------------------------------------------- */ | |
/* [Google Suggest] Get all the related keywords from Google Suggest #php #function #GoogleSuggest */ | |
/* ----------------------------------------------------------------------------------------------- */ | |
function googleSuggestKeywords($keyword, $only_one_keyword_allowed=false) { | |
if (!function_exists('curl_init')) die('ERROR - Please install cURL on your PHP!'); | |
if ($only_one_keyword_allowed==true) { // IF JUST ONE WORD ALLOWED | |
$keyword = explode(' ', $keyword); | |
$keyword = $keyword[0]; | |
} |
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
/* ---------------------------------------------------------------------------- */ | |
/* [URL2PDF] pdflayer.com API to generate a PDF from an URL #php #function #pdf */ | |
/* ---------------------------------------------------------------------------- */ | |
function url2pdf($url, $licensekey='a2ce7bfc1f9be9d8ca741365fc532ab2') { | |
// GET YOUR API ACCESS KEY - https://pdflayer.com/dashboard | |
ini_set('user_agent', 'Mozilla/5.0'); | |
$api = 'http://api.pdflayer.com/api/convert?access_key=' . $licensekey . '&document_url=' . $url; | |
$filename = str_replace('www.', '', pathinfo($url, PATHINFO_FILENAME) . '.pdf'); | |
if (!headers_sent()) { | |
header('Content-type: application/pdf'); |
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
// https://www.geoplugin.com/examples | |
function ipInfo($ip = NULL, $purpose = "location", $deep_detect = TRUE) { | |
if ( isBot() ) return false; | |
$output = NULL; | |
if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) { | |
$ip = $_SERVER["REMOTE_ADDR"]; | |
if ($deep_detect) { | |
if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) |
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
/* ------------------------------------------------------------------------------------------- */ | |
/* [FileSize URL] Get FileSize of an URL without downloading the file #php #function #filesize */ | |
/* ------------------------------------------------------------------------------------------- */ | |
function getRemoteFileSize($url) { | |
ini_set('user_agent', 'Mozilla/5.0'); | |
if (substr($url,0,4)=='http') { | |
$header = array_change_key_case(get_headers($url, 1), CASE_LOWER); | |
#echo'<pre>';var_dump($$header); | |
if ( strcasecmp($header[0], 'HTTP/1.1 200 OK') != 0 ) { |
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
/* ----------------------------------------------------------------------------------------- */ | |
/* [URL Shortener] Shorten URL and preview shortend URL in long #php #function #urlshortener */ | |
/* ----------------------------------------------------------------------------------------- */ | |
function doShortURL($url) { | |
// thanks to tinyurl.com | |
return file_get_contents('http://tinyurl.com/api-create.php?url=' . $url); | |
} | |
function doLongURL($url) { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder