Jump to content

Executing PHP on another server/website


blu78

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by AbraCadaver
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"; ?>
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.