homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




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

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]

 

Birdman




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

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

ProductivePC




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

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

ProductivePC




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved