Source for file track.php
Documentation is available at track.php
* This is the goal tracker + redirect handler.
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}.
* @license http://quamplures.net/license.html GNU General Public License (GPL)
* @author fplanque: Francois PLANQUE.
* Do the MAIN initializations:
require_once dirname(__FILE__ ). '/../qp_config/_config.php';
require_once $inc_path. '_main.inc.php';
param( 'key', 'string', '' );
WHERE goal_key = '. $DB->quote($key);
$Goal = $DB->get_row( $sql );
require $templates_path. '_404_not_found.main.php'; // error & exit
if( !empty($Goal->goal_redir_url) )
{ // TODO adapt and use header_redirect()
$redir_url = $Goal->goal_redir_url;
if( preg_match( '/\$([a-z_]+)\$/i', $redir_url, $matches ) )
{ // We want to replace a special code like $hit_ID$ in the redir URL:
// Tblue> What about using preg_replace_callback() to do this?
// We need to log the HIT now because we need the hit ID!
$Hit->log(); // log the hit on this page
$redir_url = str_replace( '$hit_ID$', $Hit->ID, $redir_url );
header( 'HTTP/1.1 302 Found' );
header( 'Location: '. $redir_url, true, 302 ); // explictly setting the status is required for (fast)cgi
// TODO: dh> str_repeat won't be enough (when gzipped), see http://core.trac.wordpress.org/ticket/8942
// should be probably a more general function and get used in e.g. bad_request_die(), too (if necessary)
// At this point Firefox 2 will redirect without waiting for the end of the page, but IE7 will not :/
{ // No redirection specified, we send a blank pixel instead:
// TODO: dh> Looks like caching should get prevented here?! (so additional requests arrive here, too)?!
$blank_gif = $rsc_path. 'img/blank.gif';
header('Content-type: image/gif' );
// We need to log the HIT now because we need the hit ID!
$Hit->log(); // log the hit on this page
if( isset ( $_SERVER['QUERY_STRING'] ) )
$extra_params = '&'. $_SERVER['QUERY_STRING']. '&';
$extra_params = str_replace( '&key='. $key. '&', '&', $extra_params );
$extra_params = trim( $extra_params, '&' );
$sql = 'INSERT INTO T_track__goalhit( ghit_goal_ID, ghit_hit_ID, ghit_params )
VALUES( '. $Goal->goal_ID. ', '. $Hit->ID. ', '. $DB->quote($extra_params). ' )';
|