Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code theft question

Status
Not open for further replies.

Netwrkengeer

IS-IT--Management
Apr 4, 2001
184
US
{statement}
When you write Javascript a person can view the source and steel the code.

{question 1}
If you write Javascript in a file then Include it with a Javascript SRC statement, can someone view the code and steel it?

Code:
i.e. <SCRIPT language=&quot;JavaScript&quot; SRC=&quot;[URL unfurl="true"]http://www.tek-tips.com/jscript/jxt1.js&quot;></SCRIPT>[/URL]

{question 2}
If you write Javascript in a file then Include it with a Php include statement, can someone view the code and steel it?

Code:
i.e. $page=getenv(SCRIPT_NAME) ;
 
javascript and html codes are always accessible. But PHP code not. Ion Filipski
1c.bmp


filipski@excite.com
 
also can you use javascript to activate a php function, i.e. someone goes to your website and clicks on an icon, a javascript countdown begins, once the countdown has reach 1, it executes a Php function and reloads that portion of the page to display the altered php?
 
Well... last time I said this inlandpac jumped all over me, but for you, I will stick my neck out again:

To be theoretically and technically correct you can't use Javascript to call a PHP function. But... since &quot;any sufficiently advanced technology is indistinguishable from magic&quot;, I will show you how to use some smoke and mirrors. See this thread at another forum
It contains some pretty circular-sounding logic, so it might take awhile to unravel, but once you get it, it can be one way (cough...'hack') to bridge the gap between client-side and server-side data. To really bridge the gap properly, though, Java is the right way.

If you want an example, just describe what you want to do in more detail, and I will be glad to demonstrate.

inlandpac -- JK, no hard feelings...;-)
 
I have some complex stuff in mind, I can email you the concept, but for the forum, I have a smaller example.

Ok I have some javascript that displays a realtime clock, it steals the time from your pc's internal clock.
can you alter the script or write a new script to grab the time off of a (my) server, and keep a session open, to display the servers clock in realtime?

Code:
<form name=&quot;time&quot;>
<input type=&quot;text&quot; name=&quot;time2&quot; size=15>
</form>
<script>
function liveclock(){
var curdate=new Date()
var hours=curdate.getHours()
var minutes=curdate.getMinutes()
var seconds=curdate.getSeconds()
var suffix=&quot;AM&quot;
if (hours>=12){
suffix=&quot;PM&quot;
if (hours>=13)
hours-=12
}
if (minutes<10)
minutes=&quot;0&quot;+minutes
if (seconds<10)
seconds=&quot;0&quot;+seconds
var thetime=hours+&quot;:&quot;+minutes+&quot;:&quot;+seconds+&quot; &quot;+suffix
document.time.time2.value=thetime
setTimeout(&quot;liveclock()&quot;,1000)
}
liveclock()
</script>
Thanks,
rycamor, I will email you.
 
if you do a kavascript src thingio then the peron can veiw the source and paste it into the adress bar which will then download the js script(I don't know if this was already answered I just didn't feal like reading all the other psots.) the same thing if you wite it as a PHP file and then include it cause when you include a PHP file it just writes the everything in the file to the page.
 
rycamor,

No offense taken at all!

Again, though, in my experience with working on extremely large projects, we have come to find something like this is very 'kludgy' (as the term goes at my work).

It does work and you have done a great job with providing people with this solution.

I am not one to not provide a user with a solution, no matter what my personal feelings are, but at the same time, sometimes I just can't get myself to do it due to past experience.

In any case, Netwrkengeer, rycamor's solution will most likely provide you with the functionality/results you are looking for.

Have fun...and good luck.

Chad. ICQ: 54380631
online.dll
 
Yes, there is definitely the kludginess factor here.

Actually, sooner or later I intend to finish another solution to this kind of problem that I have been cooking up. It involves using a very small generic Java applet to maintain a &quot;live&quot; stream to the server, which will simply grab variables and make them available to Javascript. Thus we solve the problem of live updating, but we aren't forced to use heavy Java graphics and display classes, since that is better handled by Javascript and the browser.

Now that PHP has WDDX, and can connect to Java, this shouldn't be that big a problem.

I will keep you all posted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top