Thursday, 5 February 2015

Tracking Xml file request from php



I have htaccess file



SetEnvIf X-Real-IP "1.1.1.1|2.2.2.2" allowclient
order deny,allow
deny from all
Allow from env=allowclient


So i grant access to thoose IP


In directory i have Xml files.


Now I need to track how often and which IP request each Xml file.


I know that i can do this with php but have to do this with Xml files?


I trying to write code in Htaccess



RewriteEngine on
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]


in 1.php



<?php
file_put_contents("1.txt", "\n"."REAL_IP=" .@$_SERVER['HTTP_X_REAL_IP']."\n\t" ."Time:".date('Y-m-d H:i:s',@$_SERVER['REQUEST_TIME'])."\n---------------------------------------------------------------------------------------", FILE_APPEND);
include '1.xml';
?>


But i get error



Parse error: syntax error, unexpected 'version' (T_STRING) in



So i need to track data and return the same xml file to end users without changing link to file.


No comments:

Post a Comment