Welcome to WebmasterWorld Guest from 54.166.220.138

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Converting JavaScript to PHP

Converting a few javaScript specfic functions to PHP such as math.random();

     
6:11 am on May 30, 2004 (gmt 0)

10+ Year Member



I am trying to convert some javaSripting over to PHP and have run into a snag.

This is what I have left to convert and I am not sure how to do it.

JavaScript specific functions:
1.
math.random();
Here is the javaScript most of the way converted except for the last part
$sc_tracking_url = $sc_base_dir+"&resolution="+$sc_width+"&camefrom="
+$sc_referer+"&u="+$sc_url+"&t="+$sc_title+"&java=1"
+"&browser="+$sc_browser+"&version="+$sc_version+"
&os="+$sc_os+"&sc_random="+Math.random();

Any idea on how to rewrite that last part on the above?

2.
sc_time = sc_date.getTime();

3.
sc_agent = sc_agent.toUpperCase();

4.
sc_img = new Image();
sc_img.src = sc_tracking_url;

I am pretty lost. I cannot find those. Any help would be greatly appreciated. Thanks

Wayne

[edited by: jatar_k at 4:49 pm (utc) on May 30, 2004]
[edit reason] no sigs thanks [/edit]

11:51 am on May 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

Welcome to Webmaster World!

1) mt_rand(} [php.net]

2) date() [php.net] and time() [php.net]

3) strtoupper() [php.net]

The last one is probably the webbug, which you don't need if you're writing a server-side tracking script.

BTW, you're not supposed to promote your website here.

Regards,
Birdman

5:46 pm on May 30, 2004 (gmt 0)

10+ Year Member



Thank you for the answers. I apologize for the website promotion... out of habit I sign it that way. I will make sure it does not happen again.

What is the webbug?

Thanks

Wayne

6:10 pm on May 30, 2004 (gmt 0)

10+ Year Member



Thank you for the answers. I apologize for the website promotion... out of habit I sign it that way. I will make sure it does not happen again.

What is the webbug?

Just to be clear on this..

I would write these as follows:

JavaScript specific functions:
1.
math.random();
Here is the javaScript most of the way converted except for the last part
$sc_tracking_url = $sc_base_dir+"&resolution="+$sc_width+"&camefrom="
+$sc_referer+"&u="+$sc_url+"&t="+$sc_title+"&java=1"
+"&browser="+$sc_browser+"&version="+$sc_version+"
&os="+$sc_os+"&sc_random="+mt_random();

2.
$sc_time=time();

3.
$sc_agent=strtoupper(); (If I wanted to use it)

How would I rewrite the following?

4.
sc_img = new Image();
sc_img.src = sc_tracking_url;

I am rewriting what someone else already has in place. Currently they are using JavaScripting without support of SSL. So their references to http make it very difficult to track our https pages.
I am hoping that because we support SSL and they do not that Ican rewrite their script in PHP, collect all of the information froma secure source on our web server and then send it over to them server side. The browser would not have to know about the sernding of the information and therefore should not care if I am sending it to a non-SSL related reference at that point in time so I have to keep all references of what they have in tact just in case their system is depending on it plus I have to all data come back exactly or close to exactly like the javaScript would bring it up as not to mess up their system.

Thanks

Wayne

 

Featured Threads

Hot Threads This Week

Hot Threads This Month