James Bachini

php

  • REGEX | A Complete Guide With Examples

    REGEX | A Complete Guide With Examples

    Regexes are a powerful way to do search queries on a text string. They can be used to replace text, sanitize user inputs and much more. Contents Introduction to REGEX REGEX Cheatsheet REGEX Examples REGEX Javascript Code An Introduction to REGEX A REGEX or regular expression is used to match text strings in many programming […]

  • A simple iOS / Android traffic splitter in PHP

    A simple iOS / Android traffic splitter in PHP

    The following basic PHP code will split traffic by device with iOS traffic going to the first out link, Android to the second and leftovers to the third. TIP: This uses a 301 redirect however you can do any type of programmatic variation based on the user agent. You can copy and paste this into […]

  • RAM & CPU Usage PHP Script | Server Health Check

    RAM & CPU Usage PHP Script | Server Health Check

    This single file server health check script works on Windows, Linux and possibly others. It is written in PHP to show CPU usage, RAM usage, Incoming Connections and Hard disk usage. Update September 2020 Server Check PHP was getting a lot of downloads so I’ve updated the code and open sourced it on Github. If […]

  • Setting up Maxmind GEOIP2 Legacy Database with PHP or Javascript

    This is the php code I use to access geoip data from Maxmind’s geoip database: <?php $gpath = getcwd() . “/GeoIPCity.dat”; if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $myip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } if (isset($_SERVER[‘REMOTE_ADDR’])) { $myip = $_SERVER[‘REMOTE_ADDR’]; } include(“./geoipcity.inc”); $gi = geoip_open($gpath,GEOIP_STANDARD); $record = geoip_record_by_addr($gi,$myip); $city = $record->city; $countrycode = $record->country_code; geoip_close($gi); echo ‘countrycode = “‘.$countrycode.’”; city = […]

  • Passing Through Landing Page Variables

    This was inspired by another post which is well worth a read at: http://affplaybook.com/blog/affiliate-marketing/the-ultimate-guide-to-landing-page-tricks/ So many traffic sources provide you with tags such as {keyword} {countrycode} {device} etc. You can add these variables to your url so it would look something like: http://www.myserver.com/landingpage.htm?kw={keyword}&device={device} Then in the code to your landing page you can access these […]

  • Email Bounce Handling

    Here’s some PHP code developed to handle bounced email responses. This will give each response a code to $resno and a category to $rescat. There are 4 categories: Unknown – Hard bounce user or email address isn’t valid Spam – Soft bounce, blocked by spam filters Full – Soft bounce, user is out of resources […]

  • Coding PHP for Affiliates | A Getting Started Guide

    Coding PHP for Affiliates | A Getting Started Guide

    Coding for me is one of the most important skills you can have as an affiliate marketer. I’ve met plenty of affiliates that are running huge volume, making millions and can’t write a single line of code. “I just outsource it all” but for me I couldn’t imagine coming up with a tweak to a […]

  • Direct Linking and Retargeting

    Here is how to do it, you’ll still need a server and a domain. Point all your traffic towards a php file i.e. http://www.mydomain.com/trackandforward.php Then place all your retargeting pixels in to the trackandforward.php file and put a meta refresh at the the end. The page will load the retargeting cookies will be placed and […]

  • Automatic backup of MySQL database

    Would you like to have a backup of your critical MySQL database emailed to you automatically? The following script was moified from backup2mail and needs setting up as a cron job, instructions are in the code. Download it for free here This is what the code looks like: <?php /// Setup /// // Test it […]

  • First Steps in Automation

    First Steps in Automation

    One of the great things about this industry is the lifestyle flexibility it offers you. The dream is to setup a campaign or website, let it run itself and live off the money tree you’ve made. In reality it rarely works like this but automation can release hours off your daily routines and go some […]