Link to home
Start Free TrialLog in
Avatar of jasdak
jasdak

asked on

Javascript Alter Server Side File

i have a blogspot.com blog and want to be able to play a sound locally on my computer whenever the blog is visited.  i use google analytics to record web traffic and google analytics had me place the following code right before the </body> tag:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3173439-1";
urchinTracker();
</script>

can i do something similar with a javascript file on my local web server?  i want whenever someone visits my blog for the text file (on my local web server) contents to be incremented by one.  i have a local VB6 program running on my local webserver that monitors that text file and whenever it detects a change it plays a wave file.

thanks!
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jasdak
jasdak

ASKER

i can do php serverside.  i found a way to do it by monitoring apache's access.log file and look for specific GET requests for certain jpeg photos.  but that requires parsing a 9mb file quite often.  if you have suggestions of how to do this by simply creating/updating a txt file with a single value that'd be great.  thanks!
I can help with the PHP script.  I have one question though.  The script needs to be in the page that shows the blog.  It wouldn't work if the file isn't called as part of the process to visit the blog.

Before working on script I just wanted to make sure this method would work for what you have.  Let me know if you have a question.  If it will work then any details you can provide will help me make the script more accurate (e.g. filename, location, etc).

bol
Avatar of jasdak

ASKER

my blog is at blogspot.com and as far as i know they do not allow php on their pages.  i can add whatever html i want though.  my personal webserver does php fine with apache.  so if this scenario works, that'd be great if you could show me how.  either way though i'll give you the points since you are so helpful and quick.  thanks!

if you can show me code to do it, that'd be great.
With the blog on a different server you wouldn't be able to use PHP to directly change something on your server so it doesn't matter that PHP isn't supported.

Since you can modify the html on blogspot then you might be able to run Javascript on that page or add a hidden iframe.  This assumes blogspot won't try to prevent certain tags or scripts like many sites do.

For you to use a Javascript method you would add a tag like the one below to the head of your blogspot page, one the visitor would view.

<script type="text/javascript" src="http://yourPHPserver/folder/file.js"></script>

That js file would have script to call the PHP script on your site or notify your server in some way.

For the iframe method you would use the src tag to call the PHP script file on your server.  The tag would look like the one below and be somewhere in the body.

<iframe name="frame1" src="http://yourPHPserver/folder/file.php" style="display: none;"></iframe>

An example and good explanation of the PHP to use for working (i.e. creating, reading, modifying) a file can be found at http://www.tizag.com/phpT/filecreate.php and the pages before and after it (see the links to the left).  This would use PHP to do it but you may also have other options with some server object, etc.

I'm glad I was able to help and I hope this adds a bit more.  If you want more and post a new question then feel free to let me know by posting the new question's URL here.  Thanks for the grade, the points and the fun question.

bol