473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Combining a Perl download counter script with an audio player pop-up window

I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related.

I found a script called BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the operating system and audio file type, then opens a window with the audio file (passed as a parameter) in an object with a
Expand|Select|Wrap|Line Numbers
  1. param name=src
and an
Expand|Select|Wrap|Line Numbers
  1. embed
statement each referencing the audio file. The calling HTML code is
Expand|Select|Wrap|Line Numbers
  1. <a href="audiofile.mp3" target="_blank" onclick="javascript:BatmoAudioPop('description',this.href,'1'); return false"> 
(The third parameter (1) is the window number.) It works fine.

I found another server-side script called load.cgi that opens a text file, finds the passed url name of the file to be downloaded in it, updates the count associated with it (or, if not there, creates a new entry with the count set to 1) then redirects the page with
Expand|Select|Wrap|Line Numbers
  1. print: "Location: $link\n\n";
It is called with
Expand|Select|Wrap|Line Numbers
  1. <a href="cgi-bin/load.cgi?downloadfile.whatever">
An associated script, showload.cgi, gets the current count for the passed url name so that it can be displayed in the page. The load.cgi / showload.cgi combination works fine.

What I'm trying to do is to combine the two scripts (BatmoAudiopop.js and load.cgi) so that when someone clicks on 'PLAY', the count gets updated at the server and the pop-up player opens. (Note - I don't care about the 'calling' page getting its count updated at this point - just the next time it is viewed.)

If I just alter the javascript call to
Expand|Select|Wrap|Line Numbers
  1. <a href="cgi-bin/load.cgi?audiofile.mp3" target="_blank" onclick=javascript etc....
then, to my surprise, the count gets updated by 3 instead of 1 (I'm sure I also saw it get updated by 4 once, but I might have been hallucinating).

I've examined load.cgi and can't see how the search/update loop can be going wrong - I can only surmise that the script is being called three times.

I've tried altering the javascript to remove the
Expand|Select|Wrap|Line Numbers
  1. cgi-bin/load.cgi?
(displaying the result in the pop-up window to confirm my code) but, of course, this results in the script not being called at all.

I don't really understand the relationship between the href parameter and what happens with onclick.

I've spent ages searching the Internet to see if anyone else has tried to do a similar thing and to try to glean more understanding, with no luck. The cgi script runs on my ISP's server; I don't really want to set up a web server on my machine and spend hours experimenting - I want to get on with editing my audio play!

Can anyone explain why the count should be getting updated by 3? And how I can achieve the result I want? (I suppose I could just divide the count by 3 before displaying it, but that's not very elegant.)

I would have included the entire scripts but, since they are shareware, I'm not sure about the etiquette of doing that - I don't want to offend anyone.
Aug 14 '07 #1
2 2157
KevinADC
4,059 Expert 2GB
No way to tell why the counter is incremented incorrectly. My guess is the script is accessed three times for some unknown reason.
Aug 15 '07 #2
I've cheated and changed showload.cgi to divide the count by three if it's my audio file. But I'd really like to know why load.cgi is being executed three times - perhaps one of these days soon I'll install Apache and do some experimenting. Thanks for your reply though.
Aug 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: atse | last post by:
Hi, I want the MP3 audio files to be able to download by users only. Even I set the pages validated by session, anyone still can type the download url to get my files without access of the pages...
3
by: BOHICA | last post by:
I would like on my page when users click one of my mp3 files for the dialog box to pop up so they can choose to save the file to disk instead of trying to open through IE, but the dang thing won't...
4
by: Isaac Grover | last post by:
Hi everyone, I have recorded some conference calls for my business partners, put them online in Shockwave audio format using a player available from Shockwave. And I'm encountering an annoying...
1
by: Ron Provost | last post by:
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. ...
1
by: ray well | last post by:
hi, i'm looking for a .net audio player control, that can play wav, mp3, and some other common formats. i need to plays some audio in my app. i'm not looking for any whole audio studio, just...
4
by: Gary Morrison | last post by:
I need to create a lot of fairly-short audio files from the concatenation of a lot of even shorter audio files. I'd like to control that from a Perl script. The audio files would presumably be...
7
by: mistral | last post by:
I use htaccess to protect directory and granting access to download file only for the authorized users. Just want implement simple PHP file download counter for single file. I need track the number...
12
by: devospice | last post by:
Hi, I'm trying to create a download counter for individual files on a web site and I'm not sure how to do this. Right now I'm using Webalizer to just read the log files and see how many times...
4
by: =?Utf-8?B?U2F0eWE=?= | last post by:
My PC crashed and I have installed windows XP SP2 again. Now audio is distored (it runs too fast) with all applications like Windows Media Player, Real Player, WIN DVD player, CD player. etc. What...
1
by: itsthefocusman | last post by:
Hi, My name is Daniel, and im using flash 8. Im building a flash site and wanted to include my audio on a page. I wanted to use a flash player such as http://odeo.com/audio/7932783/players or...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.