* @license PHP License * @package WB * @subpackage service */ WBClass::load('WBService'); /** * Deliver Tracking Pixel * * @version 0.1.1 * @package WB * @subpackage service */ class WBService_Pixel extends WBService { /** * Display * * @param int $status * @param mixed $data to be send * @param string $checksum * @return bool true */ public function run(&$status, &$data, &$checksum = null) { // browser must revalidate $this->res->setCacheControl(WBResponse::CACHECONTROL_MUSTREVALIDATE); $this->res->setMaxAge(null); $lt = WBClass::create('WBStatistic_LinkTracker'); $lt->add(); $stat = WBClass::create('WBStatistic_View'); $stat->addPath(implode('/', $this->path), WBStatistic_View::NS_PIXEL); // make session read only to avoid blocking further requests $this->sess->close(); $this->res->addHeader('Content-Disposition', 'inline; filename="px.gif"'); $this->res->addHeader('Content-Type', 'image/gif'); // Keep image in code //$file = WBParam::get('wb/dir/base') . '/htdoc/s/px.gif'; //$px = base64_encode(file_get_contents($file)); $px = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; $data = base64_decode($px); /* * caching time in seconds * 60 * 60 * = 3600 * = 1 hour */ $this->res->setMaxAge(3600); $this->res->addHeader('Content-Length', strlen($data)); $this->res->addHeader('Accept-Ranges', 'bytes'); $checksum = md5($data); $status = 200; return true; } }