...

View Full Version : Protecting my Source Code



JAVAEOC
01-11-2004, 01:16 AM
how can I protect my source code?

if it is php or any thing else then js, html, or css then please give me the complete code cause I am to stupid to handle anything else

thanks for any help :)

COBOLdinosaur
01-11-2004, 01:34 AM
protect it from what?

If you mean prvent someone from stealing it then:

put it in an envelope put the envelope in a sfetedesosit box, and never under any circumstances put it on a web page.

No one has to steal it... you give it to them ever time you let them down load a page. The code is on their computer, and they can do anything they want with it.

You can make it more difficult, you can cripple your site by wrapping layerof nonsense around the code, but all you do is:

A make your site less usable.
B do a lot of extra work for nothing
C challenge all who take code without permission
D make yourself look silly.

JAVAEOC
01-11-2004, 01:59 AM
I just basically want to do what brothercake did

http://www.brothercake.com/dropdown/msdn.html

that is a style example of his cool dropdown menu and u cant get the source code...

thats all i want to do but how?

liorean
01-11-2004, 03:10 AM
? Can't get the source code? What are you speaking about, it's not even blocking right click, not to speak of all fifty-eleven other ways to get it.

JAVAEOC
01-11-2004, 03:53 AM
but you cant get the code for the menu... can you?

Jeff Mott
01-11-2004, 04:35 AM
Yes, you can. There are not even any petty attempts to stop you or obscure the code. It is called, quite plainly, menu.js. In fact, he even links directly to custom_msdn.js, which appears to be the foundation of the menu.

jujuraf
01-11-2004, 05:18 AM
Unfortunately none of these cocky replies you've received answers your question or helped you learn anything. I thought that's what this forum was for? :confused:

The reason why you can see the JS code on the page you listed, is because the owner provided a link to the file as a sample. This certainly is not normally done. I think what you meant to ask is how to hide/protect the code in a 'normal' HTML page from being stolen (your example was not a good one). The HTML can't be protected since it's needed to create the page, of course. The JS can be hidden by placing the code in a .js file and including it just like the HTML did on the page you referenced. This .js file is somewhere on the web server and the client machine can't access it. So if your HTML contains this, the code is hidden from the user.

<script language="JavaScript" src="../dirName/code/myStuff.js"></script>

This path above is physically on the web server which isn't accessible to the web page viewer.

Deb :thumbsup:

Jeff Mott
01-11-2004, 05:38 AM
The JS can be hidden by placing the code in a .js file and including it just like the HTML did on the page you referencedThis will not hide the code. It merely adds one additional step in retrieving it.
This .js file is somewhere on the web server and the client machine can't access itIf the client machine couldn't access it then the browser would not be able to execute it. In fact, the client machine accesses it every time it accesses the HTML document that imports it. And it can still be accessed directly with the URL for the script.

JAVAEOC
01-11-2004, 05:41 AM
ok

on the link i showed you, you can NOT see the source code of the menu(as far as I know).

so if you can post the WORKING menu in a zip file then i will feel stupid.

so if there is a way to get the code for the menu please please please post the whole zip folder here.

thanks

jujuraf
01-11-2004, 05:47 AM
Well YES the client machine can access the .js file, but the human client can not. The client machine needs it to render the page and do its thing. I don't see how the client can access a file in a directory on some distant server that he doesn't even have the path to. Even if you know it's in "../dir/dir/code/blah.js" how does that help viewer of the web page?

Wasn't that this person's question? Getting the JS code from the displayed page?

Deb

jujuraf
01-11-2004, 05:56 AM
I'm confused. The owner of this page GIVES you the source code! It's right there on the link at the bottom of the page. Just click it, reply to the pop-up message to open or save it. If you save it to your computer, just open it and view it with any text editor.

Deb


Originally posted by JAVAEOC
on the link i showed you, you can NOT see the source code of the menu(as far as I know).....

Jeff Mott
01-11-2004, 06:07 AM
but the human client can notYes, they can. All they need do is type the full URL, which would be given in the HTML source, in their address bar. OR, open their internet cache (temporary internet files) and retrieve the file from there.
I don't see how the client can access a file in a directory on some distant serverThe same way they would access anything else on the Web.
...that he doesn't even have the path toThe path is in the HTML source.
Even if you know it's in "../dir/dir/code/blah.js" how does that help viewer of the web page?By telling them where the file is, which is all they need.
The owner of this page GIVES you the source code!It's funny that you described liorean's and my reply as cocky, and yet you reply with nearly the same thing.

jujuraf
01-11-2004, 06:27 AM
This is TOO funny! Egos are very big with most programmers and they find it hard to explain things to beginners (as if they were never one themselves). I've read many posts to questions in this forum and many of them never answer the poster's questions, rather they make some smart remark to 'prove' their superior knowledge. I don't see how my answer was cocky since I clearly explained how and why the code is visible (it's only visible because the web page owner provided a button to view it as we know). After 18 years in the software business, I'm still disappointed at the superiority complexes carried around by so many people. It's one of the main reason so many software programs are so horrid to use for the beginner computer user.

Unfortunately this forum is like 90% of the forums out there. Little use for the folks who really need it. I have however found a fantastic forum that has great people on it, very knowledgeable who are very willing to help anyone understand and learn so many things. After being a member for 4 years I've never read any posts on that forum that come close to the things I've read here (or other places). I'm not about to tell anyone here where that forum is as I want to keep it great and useful.

Fortunately I answered the poster's question already... just click on the link and fetch the code for yourself. If you're so satisifed with your own answers, why couldn't you just tell him that nicely?

Don't bother flaming me back/forth with e-mails. I'm outta here, I have better things to do. If you think you're so great and all-knowing, try teaching a group of beginners.. that'll humble you right down to Earth.

liorean
01-11-2004, 06:52 AM
I would disagree with you. The code it right there, given by the url to the JavaScript files. Sure, it's not displayed at view-source, but everything he needs to know to get at it is there. He just needs to have a look at the JavaScript source files linked to the document. These can be found by looking at the source code, or using Mozilla's Venkman, or using my ViewScripts bookmarklet (see <http://liorean.web-graphics.com/>). It's not hidden in any way.

Jeff Mott
01-11-2004, 07:45 AM
I don't see how my answer was cockyI did not mean to imply so. The point I meant to make was that liorean's and mine were not.
it's only visible because the web page owner provided a button to view it as we knowIt would still be accessible without that link using any of the methods already described in this thread (viewing the HTML source to see the path to the script OR retrieve the script from internet cache). If you need a more detailed description or example then ask. We cannot always know the level of experience of the people we reply to and thus do not always describe things in the most specific detail.
this forum is like 90% of the forums out there. Little use for the folks who really need itThough this is only my opinion and I have no real source to back it up, I believe that if you created a poll asking users if they find this site useful that you would find an overwhelming majority do

liorean
01-11-2004, 07:49 AM
Jeff - wouldn't such a poll be heavily biased because those voting will be the ones that evidently like it well enough to remain here, as regulars?

Jeff Mott
01-11-2004, 08:04 AM
Probably ;)

I suppose then if you really wanted to see how useful people find it (based on how many remain) you'd have to analyze the site's stats (if the needed information exists). Such as the number of total registered users, and the percentage of those that remain active. Not perfectly accurate, but possibly good enough to get an idea.

rmedek
01-11-2004, 08:28 AM
jujuraf- As a hack programmer here, I can say that I find this forum extremely useful. I've also found that the thread replies differ from person to person. JAVAEOC is a regular here as well as liorean and COBOLdinosaur, so I can see why their replies were much more frank and what you percieved as "cocky." So relax and if you disagree with the discussions taking place I suggest you spend more constructive time on the forum you prefer and not waste your time here.

ANYWAY...

There's no real way to hide source code, although you can hide various programming functions (i.e. using ASP to do something on the server, and then output the result in HTML). Javascript, though, is client-side programming, so it's all done on the browser's computer. The browser's computer needs all the code (XHTML, HTML, Javascript, whatever) to interpret it and display it on the screen, so it's always going to be transmitted. You can make javascript harder to access by linking to it instead of putting it inline...
<script type="text/javascript" src="folder/folder/another_folder/cool_program.js"></script>... but to see it all you have to do it type the url and the folder destination to see the file.

So, JAVAOEC, to see brothercake's source code, use "view source" on your browser and you'll see
<script language="javascript1.2" src="resources/custom_msdn.js"></script> So go to your browser's address bar and type in http://www.brothercake.com/dropdown/resources/custom_msdn.js (the original URL is http://www.brothercake.com/dropdown/msdn.html) and there you have it.

I hope this helps...

-Rich

Philip M
01-11-2004, 08:40 AM
Originally posted by Jeff Mott
Though this is only my opinion and I have no real source to back it up, I believe that if you created a poll asking users if they find this site useful that you would find an overwhelming majority do

I certainly do. If the users did not find it useful presumably they would not be users.

jkd
01-11-2004, 09:16 AM
Wow, cool it juj...something. The only reason some of the replies come across as impatient is because this question has been asked hundreds of times on these forums. Anybody that would take 5 seconds and search the forums for their question before asking it would save so much time on everybody's part. We even have this thread stickied in the HTML forum or wherever.

Alright? And don't diss our community like that, I'm a member of well over a dozen forums of this sort, and this one is heads and shoulders above the rest beyond a shadow of a doubt.

JAVAEOC
01-11-2004, 01:25 PM
jkd, I DID search the forum and none of the posts answerd my question.

All of you have said that it is somehow posible to get the source code.
Fine, it is. The attached folder contains all the files. Custom.js, Menu.js... it has everything.

Yea I just copied the menu (cool), STOP - wait - but why is nothing showing up when i open the new file? Source code is prity good protected in my opinion.

so if anyone know why that is and how that is done please tell me.

JAVAEOC
01-11-2004, 01:35 PM
sorry the attachment didnt work the first time :(

sage45
01-11-2004, 03:23 PM
It's simple enough...

At first I couldn't get what you were carrying on about but now I do... And to give some credit to you, you are partly right...

The code may seem protected in the sense that since you just copied the files from his website, attempted to get them to work on your personal computer and you find that you don't get a menu...

The only person who is able give this secret is the person whom created the menu bar, as I am not at liberty and truthfully I am almost certain that he won't explain in great detail the inner workings of this... Reason being is that his progmatic validation requires that you have agreed to the terms of use and obtained a license to use the product (whether it is a free/trial version or a version that you paid for)... To obtain a free license simply read the Terms of Use, agree to them if you so choose to and download the complete set of .js files... You can do that here:

http://www.brothercake.com/dropdown/terms.php?license=free

Tis easy enough to accomplish...

Now once you have accomplised that, open the zipped archive that you downloaded, copy the custom_msdn.js and msdn.gif files that you previously downloaded to the new resources directory... After that change the template.html file so that this line:

<script type="text/javascript" language="javascript1.2" src="resources/custom.js"></script>

Now reads:

<script type="text/javascript" language="javascript1.2" src="resources/custom_msdn.js"></script>

Now, I may have broken the terms of use as laid out by Brothercake and if so then I appologize to Brothercake for this...

The main purpose here is to show you two things... First, no matter how hard you try, any code can be viewed... Now don't confuse viewed as saying used... The useablity of a piece of code can be depended upon many things from it's environmental dependancies to it's progmatic validations which are in place as a protection measure... The second thing is to show that even though the code may seem unusable, it can still be viewed for learning... As pointed out by JKD, we see these types of questions all the time... You cannot truly protect your source code... As you'll notice, Brothercake did not protect the source, just the output of the source... ;)

HTH,

-sage-

COBOLdinosaur
01-11-2004, 06:02 PM
I didn't bother trying to discuss anything with juju..whatever, because I learned a long time ago that it is not possible to to communicate with a rock laying in the warm sun, and unaware that there is any universe beyond.

Cd&



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum