Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Set the id of your piwik site here
- $idSite = 1;
- $token_auth = 'your user token here';
- $img = 'stat.png';
- //Load Piwik Tracker
- require_once 'PiwikTracker.php';
- //Set the URL path to your Piwik Installation
- $t = new PiwikTracker($idSite, 'http://strainplumbing.com/piwik');
- //Auth to allow for more API functions
- $t->setTokenAuth($token_auth);
- //Set correct IP (Should be users, not the web server issuing the request)
- $t->setIp($_SERVER['REMOTE_ADDR']);
- //Set referrer (if applicable)
- if(isset($_SERVER['HTTP_REFERER']))
- {
- $t->setUrl($_SERVER['HTTP_REFERER']);
- }
- $t->doTrackPageView('Strain Plumbing');
- if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($img))
- {
- header('Last-modified: '.date(DATERFC_1123, filemtime($img)), true, 304);
- exit;
- }
- //Set header
- header('Content-Type: image/png');
- header('Expires: '.date(DATE_RFC1123, time()+2592000));
- header('Last-modified: '.date(DATE_RFC1123, filemtime($img)));
- //Output image
- echo file_get_contents($img);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement