Blog Madness

e-Marketing tips

Tuesday, February 26, 2013

Executing large PHP scripts.

  • A PHP script executed from the command-line or from a shell script, cron job, etc. does not have a timeout by default.
  • You can also set a PHP script's timeout dynamically with the set_time_limit() function. Beware: set_time_limit() has no effect when PHP is running in safe mode.

Wednesday, February 6, 2013

Creating Dynamic Virtual Hosts Using .htaccess

Good post on how to dynamically allocate the virtual host directory based on the host name.

Saturday, February 2, 2013

Only show ads if a visitor comes from a specific site

Scenario:

  • You are running Wordpress.
  • You only want to show specific ads to visitors coming from the domain foobar.com and google.com.

Code:

In your functions.php add:

function fromspecificsite(){ $ref = $_SERVER['HTTP_REFERER']; $SITES = array('foobar.com', 'google.com'); foreach ($SITE as $source) { if (strpos($ref,$source)!==false) return true; } return false; }

In your template add:

if (function_exists('fromspecificsite')) { if (fromspecificsite()) { echo "your ad code"; } }

Only show ads if a visitor comes from a specific site

Scenario:

  • You are running Wordpress.
  • You only want to show specific ads to visitors coming from the domain foobar.com and google.com.

Code:

In your functions.php add:

function fromspecificsite(){ $ref = $_SERVER['HTTP_REFERER']; $SITES = array('foobar.com', 'google.com'); foreach ($SITE as $source) { if (strpos($ref,$source)!==false) return true; } return false; }

In your template add:

if (function_exists('fromspecificsite')) { if (fromspecificsite()) { INSERT YOUR CODE HERE } }

Wordpress API: "wp remote get"

From the Wordpress Codex: $response = wp_remote_get( 'http://somedomain.com/filetoget.txt' ); if( is_wp_error( $response ) ) { echo 'Something went wrong!'; } else { echo 'Response:
';     print_r( $response );     echo '
'; }