Wednesday, August 16, 2017
Home Code

Code

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

Setting up twitter feed to post to Twitter and Facebook accounts

If you don't already have a facebook and twitter account for your company they are really easy to setup. On facebook remember to click the "Create a Page for a celebrity,...

Setting up custom facebook and twitter buttons using php

The canonical tag has been a god send for us helping to get pages indexed and clean up site structures. In many sites we use the same php variable for our...

Mixing php with javascrip – Heredoc

My main issue with javascript is the fact it is full of ' and " which can be a real pain when coding. I've started using a method called heredoc to...

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; }

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...

Three ways to debug php

Method 1 - error.log For this to work you need to be coding in a linux environment with php, apache etc setup. This is the best way I have found and what...

list to php array list2phparray

Code below for a script to take a list and turn it into an array. Comes in pretty useful. <?php if ($_POST) { $splist = explode("n", $_POST); $out = '$x = array('; foreach ($splist as $line)...

Prosper202 Hacks and Modifications

JiM's Prosper202 mods 1) increase session life (stops it locking you out every few minutes) add the following line just before session_start(); in 202-config/connect.php ini_set('session.gc_maxlifetime',99999); 2) Cchange the first page you see. edit 202-login.php line 80: header('location:...

Dynamically modifying the landing page with TrafficVance using php

I ran into a silly issue today when dynamically modifying a landing page using TrafficVance. The script I was using was a pretty straight forward: <?php if ($_GET) { $kw = strip_tags($_GET); } if(strpos($kw,'jetinternetmarketing.co.uk') !== false) { $page...