You are herestatistics to log my php variables in url path
statistics to log my php variables in url path
I use drupal 4.6 with clean URLs enabled. I do lots of php inside a node of type 'page' as this is one of my favourite drupal features. So i call from external applications with userdefined variables like:
/display_invoice/?id=123456
Then i have seen that the statistics.module was not logging the wholue URL with my user defined variables.
That was important for this application as i wanted to know who watched which invoice.
I tried to find my way through nodes.module and regular expressions to be able to use my variables inside clean URLs like
/display_invoice/id/123456 instead of
/display_invoice/?id=123456
but i failed after hours of search and the complexity of the core drupal design.
So i hacked the statistics.module like this
//////////////////////////////////////////////////////////
// quick hack to enable logging for ?x=y variables
// replaced in modules/statistics.module around line 79
// db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, timestamp) values('%s', '%s', '%s', '%s', %d, %d)", drupal_get_title(), $_GET['q'], $referrer, $hostname, $user->uid, time());
//
$full_url = $_GET['q']; // default as from the original statistics module
if ( isset($_GET['id']) ) {$full_url = $_GET['q'].'?id='.$_GET['id']; }
if ( isset($_GET['invoice_number']) ) {$full_url = $_GET['q'].'?invoice_number='.$_GET['invoice_number']; }
// and so, on. continue with the varibales you need for external URL calls to drupal
db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, timestamp) values('%s', '%s', '%s', '%s', %d, %d)", drupal_get_title(), $full_url, $referrer, $hostname, $user->uid, time());
// ^--------- replaced here to the new variable
//////////////////////////////////////////////////////////whats the easy and clean solution for this ?
thanks in advance, Robert
