Skip to content
Extraits de code Groupes Projets
piwik.php 992 octets
Newer Older
  • Learn to ignore specific revisions
  • <?php
    /**
     *  Proxy to normal piwik.php, but in testing mode
    
     *  - Use the tests database to record Tracking data
    
     *  - Allows to overwrite the Visitor IP, and Server datetime
     *
    
    mattpiwik's avatar
    mattpiwik a validé
    
    
    use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
    
    use Piwik\Site;
    
    use Piwik\Tracker\Cache;
    
    mattab's avatar
    mattab a validé
    require realpath(dirname(__FILE__)) . "/includes.php";
    
    // Wrapping the request inside ob_start() calls to ensure that the Test
    // calling us waits for the full request to process before unblocking
    
    mattab's avatar
    mattab a validé
    ob_start();
    
    try {
        Piwik_TestingEnvironment::addHooks();
    
        GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
    
        Tracker::setTestEnvironment();
        Manager::getInstance()->deleteAll();
        Option::clearCache();
        Site::clearCache();
    
        include PIWIK_INCLUDE_PATH . '/piwik.php';
    } catch (Exception $ex) {
    
        echo "Unexpected error during tracking: " . $ex->getMessage() . "\n" . $ex->getTraceAsString() . "\n";
    
    ob_end_flush();