blu78 Posted November 6, 2013 Share Posted November 6, 2013 I have a PHP script installed on mysite, which allows me to track visitors by adding the php require function to each page I want to track. What I want/need is to track one page on othersite using that tracking code, and have the data transmitted back to mysite. However, I'm not sure how to do that. I'm sure I've done it before several years ago, I just can't remember how I did it and I've lost all the files. I've spent hours trying to figure this out and it's driving me crazy. I'm starting to think that I may need to use javascript to execute the php code on othersite, but I'm not sure if that's possible either.Does anyone know how I can accomplish what I want to do? Quote Link to comment Share on other sites More sharing options...
blu78 Posted November 6, 2013 Author Share Posted November 6, 2013 I should have clarified that using the php require function code on othersite doesn't work and returns several errors. I've made some small progress in that if I use file_get_contents in the tracking code on othersite, it will record an IP address on mysite. However, it's recording the server IP address of othersite and not the visitor's IP address. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 6, 2013 Share Posted November 6, 2013 (edited) If you can't require the file on the remote site, then most likely allow_url_fopen is off. You can try this on the remote site pages: <script type="txt/javascript"> xmlhttp.open("GET","http://yoursite.com/tracker.php", true); xmlhttp.send(); </script> Or your tracking script could output a 1px transparent image and your remote site pages would just use: <img src="http://yoursite.com/tracker.php"> Edited November 6, 2013 by AbraCadaver Quote Link to comment Share on other sites More sharing options...
blu78 Posted November 7, 2013 Author Share Posted November 7, 2013 I checked and allow_url_fopen is on. Is there any reason why I wouldn't be able to get the require function to work? I managed to get javascript and the image to work, but it doesn't always work depending on the browser, etc. I'd really like to try to use php. Ugh! This is driving me crazy, I've spent hours upon hours trying to figure this out and it doesn't help that I'm not very experienced with php. Quote Link to comment Share on other sites More sharing options...
blu78 Posted November 7, 2013 Author Share Posted November 7, 2013 I still can't get php require to work, but I solved part of the problem, I think. Apparently I had my back slashes and forward slashes mixed up. I had http://mysite.com and I guess it's supposed to be http:\\mysite.com. Because once I changed it, one of the three error messages went away. But maybe I shouldn't be using http:\\mysite.com as the address for the require function. It keeps looking for a local (?) address in that it says there's no such file at /home/username/public_html/ Am I doing something wrong? Here's what I've got now <?php require "http:\\mysite.com\tracker\tracker.php"; ?> Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 7, 2013 Share Posted November 7, 2013 Sorry, I was wrong. allow_url_fopen affects file_get_contents() etc. allow_url_include determines whether you can include/require. When using any of those you us // not \\ in http:// Quote Link to comment Share on other sites More sharing options...
blu78 Posted November 8, 2013 Author Share Posted November 8, 2013 Thanks for the help. I checked and the allow_url_include is turned off for security purposes. Do you know if there's any other way to accomplish what I want to do? Is there something I could do in my htaccess file? I've also read that I should be able to do something in cURL, but I know nothing about that. I don't mind trying to figure this out by myself, but it would be helpful if someone could point me in the right direction. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.