View Full Version : Stats From External Website
netroact
02-20-2005, 12:33 AM
I have a small perl stats program I made that uses ssi to store page visitor stats. It works just fine on my server, but I need to read the environment variables from an external site hosted on another server. I used a snippet of javascript on the other site to call my perl script, but of course, it displayed the environment variable from my site. The script url became the current page, and the page on the other site with the snippet became the referrer.
I read somewhere that they use a javascript on the external server to call a perl script, which in turn, executes another javascript on the external server, and that submits the stats to the perl script. Huh?
I currently store the stats in a text file for my website, and display them with a perl generated graphical interface.
Any comments or suggestions would be appreciated.
mlseim
02-20-2005, 04:18 PM
Is the external site saving it's stats in a file on it's server?
And you would like to read those stats from another server?
If that's the case, you really don't need to use Javascript. You
could have a Perl script on your server execute a Perl script
on the external server. That script would then send back
the file contents back to your Perl script where you would
save them locally.
It all depends on when and how often you need to have the
stats from the external site. If your webhost allows CRON,
you could have it done (scheduled) automatically every night.
I would be careful on how often you do this, as BOTH sites
will be hit with the same bandwidth usage at the same time.
If you have your local site set up with an FTP account that
someone else can access, your external site could be that
"someone else" .... it could then send it's file all by itself
without any permissions or interventions at pre-defined
intervals. You're basically giving the external site permission
to transfer one of it's files into one of your directories. I think this
method would use a lot less bandwidth.
netroact
02-20-2005, 07:19 PM
Thanks for your suggestion. Unfortunately, the external site doesn't have cgi-bin access, and it will be moved in a few months.
I see these stats programs on the web where all you do is place the snippet of code on your site, and they can access the stats for that site. They are using javascript, and it's calling a cgi script on their remote server. You can see the path in the javascript snippet.
I could probably use a javascript snippet, and store environment variables in the snippet, but I just wanted to know how these remote stat services were doing it. That would probably be much better.
Thanks again for your suggestion.
mlseim
02-20-2005, 07:57 PM
They are doing it just like this example, except it would call
a Perl script instead of a PHP script ... same thing though.
http://www.catpin.com/ping.html
View HTML source to see the Javascript.
netroact
02-20-2005, 08:19 PM
Thanks, but I can call the script. That's not the problem. The problem is getting the environment variables from the external site. I can put the environment variables in the javascript like you did with the referrer, but I wanted to figure out what they are doing. Their javascript doesn't contain the environment variables, and I think that way would be better.
Thanks for your suggestions.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.