A list of amazingly awesome PHP libraries, resources and shiny things.
- Composer/Packagist - A package and dependency manager.
- Composer Installers - A multi framework Composer library installer.
<?php | |
$ip='94.219.40.96'; | |
print_r(geoCheckIP($ip)); | |
//Array ( [domain] => dslb-094-219-040-096.pools.arcor-ip.net [country] => DE - Germany [state] => Hessen [town] => Erzhausen ) | |
//Get an array with geoip-infodata | |
function geoCheckIP($ip) | |
{ | |
//check, if the provided ip is valid | |
if(!filter_var($ip, FILTER_VALIDATE_IP)) |
<?php | |
function getSlug($text) | |
{ | |
$text = preg_replace('~[^\\pL\d]+~u', '-', $text); | |
$text = trim($text, '-'); | |
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); | |
$text = strtolower($text); | |
$text = preg_replace('~[^-\w]+~', '', $text); | |
if (empty($text)) | |
{ |
<?php | |
// | |
// this gist takes most of the code from https://gist.github.com/3176917 but adds in form uploading which is just an @ symbol | |
// this also explores different options for the form data | |
// | |
// curl_post_upload.php | |
// You can modify this script to make PHP use a webpage like a person sitting | |
// at a computer would use a webpage. | |
// | |
// tags: #php #curl #form #upload |
A list of amazingly awesome PHP libraries, resources and shiny things.
<?php | |
$path = $_SERVER['DOCUMENT_ROOT']; //gets the path to your root directory of your site | |
//now all links instead of being: | |
// (images/index.php) and have it be different across all pages, use this: | |
include_once ($path . '/layout/footer.php'); //and it is now universal across all pages | |
//found at: http://css-tricks.com/php-include-from-root/ | |
?> |
// if (!window.L) { window.L = function () { console.log(arguments);} } // optional EZ quick logging for debugging | |
/** | |
* A modified (improved?) version of the jQuery plugin design pattern | |
* See http://docs.jquery.com/Plugins/Authoring (near the bottom) for details. | |
* | |
* ADVANTAGES OF EITHER FRAMEWORK: | |
* - Encapsulates additional plugin action methods without polluting the jQuery.fn namespace | |
* - Ensures ability to use '$' even in compat modes | |
* |
/* | |
* 'Highly configurable' mutable plugin boilerplate | |
* Author: @markdalgleish | |
* Further changes, comments: @addyosmani | |
* Licensed under the MIT license | |
*/ | |
// Note that with this pattern, as per Alex Sexton's, the plugin logic | |
// hasn't been nested in a jQuery plugin. Instead, we just use | |
// jQuery for its instantiation. |
/* | |
A (very) WIP collection of optimized/recommended jQuery plugin patterns | |
from @addyosmani, @cowboy, @ajpiano and others. | |
Disclaimer: | |
----------------------- | |
Whilst the end-goal of this gist is to provide a list of recommended patterns, this | |
is still very much a work-in-progress. I am not advocating the use of anything here | |
until we've had sufficient time to tweak and weed out what the most useful patterns |
<?php | |
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { | |
$theta = $longitude1 - $longitude2; | |
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); | |
$miles = acos($miles); | |
$miles = rad2deg($miles); | |
$miles = $miles * 60 * 1.1515; | |
$feet = $miles * 5280; | |
$yards = $feet / 3; | |
$kilometers = $miles * 1.609344; |
<!--# | |
A complete HTML page for a Facebook "app" that does login entirely on the client. | |
1 - Create a Facebook application (see Facebook developer docs.). | |
2 - Because of a Facebook "bug" the app should have Sandbox Mode | |
disabled (App Settings - Advanced - Authentication). | |
3 - Uncomment the appropriate redirectUrl var. 4 - Update the appId and | |
redirectUrl vars with your Facebook app values. 5 - Make the page available from a server. | |
Thanks to http://www.guineacode.com/2011/facebook-app-authorization/ | |
for the FB.getLoginStatus example that allows all the Facebook |