...

View Full Version : Website statistic script adjustment



plasma
08-17-2004, 12:51 PM
I want use JavaScript for web site statistic(my hosting service does not provide such service), visitors statistic will be sent me by email; its required additionally to have a mailer.cgi script on a webserver.
I found the suitable JavaScript, but it should be slightly adjusted: its just a demo, and doesn't send out the actual email message (emailing feature is disabled). So, there just should be activated email feature.
My knowledge still not allow me make this independently. I was just wondering if someone could help me adjust the email feature (activate emailing). Also, where do obtain appropriate mailer.cgi script and what is best mailer cgi script for? Thanks.
------------------------------------------------------------



function main()

{

baseURL = "http://www.apci.net/cgi-bin/mailer/mailer.cgi?"
mailTo="name@mydomain.com";
mailFrom="";
SendMsg(mailTo, mailFrom, "Testing", infoTable());
return;

}
function SendMsg(to, from, subject, msg)

{

var sendmail_hack, URL;

sendmail_hack = new Image();

URL = baseURL;
URL = URL + "TO=" + escape(to) + "&";
URL = URL + "SUBJECT=" + escape(from + " " + subject) + "&";
URL = URL + "msg=" + escape(msg);
sendmail_hack.src = URL;
return;

}
function infoTable()

{

msg = "";
addVar("URL", location.href);
addVar("title", document.title);
addVar("referrer", document.referrer);
addVar("lastModified", document.lastModified);
addVar("cookie", document.cookie);
addVar("domain", document.domain);
addVar("windowName", window.name);
addVar("browserName", navigator.appName);
addVar("browserVersion", navigator.appVersion);
addVar("browserSignature", navigator.userAgent);
addVar("browserLanguage", navigator.language);
addVar("platform", navigator.platform);
addVar("javaEnabled", navigator.javaEnabled());
addVar("cookiesEnabled", navigator.cookieEnabled);
addVar("windowStatus", window.status);
addVar("windowDefaultStatus", window.defaultStatus);
if(document.links.length > 0)
{
addVar("linkCount", document.links.length);
addVar("link0URL", document.links[0].href);
}
addVar("screenHeight", screen.height);
addVar("screenWidth", screen.width);
addVar("screenColorDepth", screen.colorDepth);
addVar("screenUpdateInterval", screen.updateInterval);
addVar("historyLength", history.length);

return msg;

}
function addVar(name, value)

{

if(typeof(value) == "undefined")
return;
if(typeof(value) == "string")
{
str = name + " = " + '"' + value + '"';
}
else
{
str = name + " = " + value;
}
msg = msg + str + ";\n";
return;

}

Kor
08-17-2004, 12:58 PM
Try using a php aplication (as most of the servers accept php language as a server-side feathure).

You can use a pearl, C++, java either...

Go to the server-side development forums, you may find there what you need (or ask moderator to move there this thread)

plasma
08-17-2004, 02:09 PM
I dont want use php, C++, java etc, etc. I want use exactly what I post. That is JavaScript + mailer.cgi script.

Kor
08-17-2004, 05:10 PM
It looks like you don't see the difference between client-side and server-side languages. As far as I know, what you want is a server-side application, not a client-side one. Javascript can not send data to a mail address.

plasma
08-17-2004, 07:58 PM
As you can see from code JavaScript interact with cgi-script:

baseURL = "http://www.apci.net/cgi-bin/mailer/mailer.cgi?"

which mail all the data. Problem is how this JavaScript should communicate with cgi-script(redirect?)


It looks like you don't see the difference between client-side and server-side languages. As far as I know, what you want is a server-side application, not a client-side one. Javascript can not send data to a mail address.

Kor
08-18-2004, 09:09 AM
As you can see from code JavaScript interact with cgi-script:


No Sir, javascript can not interact with cgi. The interaction is made only by the submit action and method. It is true that javascript can emulate the submit() method but, in essence, it is nothing but a classic submit way of sending or getting data to/from a server application. You script just give values to some HTML attributes in a dynamical way, that is all.

I repeat, javascript is a client-side language, that means it can not read/write external files (other that HTML, CSS or JS) and even those only with some conditions. Furthermore, it can not intefere directly with a server-side application (unless it is mixted with ActiveX or XMLHttp methods).

To send form's data to an e-mail address you must use a server-side application (CGI type).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum