Saturday, October 21, 2017
Home Code

Code

A place for code php, ruby, javascript, jquery, html, css etc.

Poor mans GeoIP – Quick and Easy Geolocation

//poor mans geoip $country=trim(file_get_contents("http://api.hostip.info/country.php?ip=".$_SERVER)); //You can then redirect customers to different offers depending on country. I wouldn't recommend this for critical or high volume use. if ($country == 'MyCountry') { yadda yadda yadda; }

Combining Maxmind GeoIP with Google Maps iFrame

This is a quick script which uses Maxminds geoip location db downloadable for free from here with Google Maps iFrame. I haven't tested this enough to find out if Google restrict...

Prosper 202 Mods 2012

Prosper202 mods 1) increase session life - stops it logging you out every five minutes when you are trying to work add the following line just before session_start(); in 202-config/connect.php ini_set('session.gc_maxlifetime',99999); 2) bypass adverts on...

Two php functions for scraping content and extracting links

////// Grab webpage ////// function webFetcher($url) { $crawl = curl_init(); curl_setopt ($crawl, CURLOPT_URL, $url); curl_setopt($crawl, CURLOPT_RETURNTRANSFER, 1); $resulting = $resulting.curl_exec($crawl); curl_close($crawl); return $result = $resulting; } //////////////////////////////// //// extract links //// function extract_links($text) { preg_match_all('/<s*a*?href=?(*)?*>(.*?)</a>/si', $text, $match_array, PREG_SET_ORDER); $return = array() ; foreach ($match_array as $serp) { $full_anchor = $serp; $href...

Captcha Cracker For PHPBB written in Ruby

It's been a while since I've done much in SEO so I am going to start publishing some of my old scripts. This is a captcha cracker which uses gocr and...

Regex’s | Regular Expressions in Programming

Today I saw a nice script which redirects mobile traffic by searching the useragent string for a list of search terms related to mobile devices. This is PHP but I'll show...

Google Friendly Mobile Pages Test

Google have provided a tool which checks to see if a site renders clearly in a mobile browser. The tool looks like it is setup at 320px and if your site...

Wasabi Opensource A/B Testing Platform

Intuit have opensourced a enterprise grade A/B testing platform called Wasabi. This runs as an API on a separate server from your site/landers. It isn't the easiest thing to setup and will...

Calculate distance between two geocooridnates

Here is a javascript function to calculate the distance between two latitude and longitude coordinates. function deg2rad(deg) { return deg * (Math.PI/180) } function calcDistance(lat1,lon1,lat2,lon2) {   var R = 6371; // Radius of...

A simple floating feedback/support button

It can be very useful for online businesses to collect feedback from their customers. This gives us priceless insight in to their wants, needs and problems. One quick way to start...