Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 4
There are 1 users currently browsing forums.
JavaScript Coding JavaScript allows rich, browser-based web-applications with interactivity and complex visual effects. For discussion on JavaScript, use this forum.

Reply
  #1  
Old 11-28-2009
vento's Avatar
Sexy monkey
 
Join Date: May 2009
Location: Lithuania
Age: 16
Posts: 183
Rep Power: 1
vento is on a distinguished road
Security

Hello. So I'm making something like a calculator using PHP, but the code becomes ugly as I place checking and type conversions everywhere to make it safe. But now I've got another idea. I have a really low experience of JS, but making some simple calculations with some logical operations can't be hard. But the problem is that I'm going to outpost some input data and the result on the screen.

The question would be. Is it safe (can someone hack my website using this (continue reading) to harm my website and/or its users) to allow writing the code on my website using that Javascript? Well, writing some security staff is pointless, I guess, because anyone can edit the code. And when you think about editing the code of the website, anyone, even I, can write any code on the website they are visiting, but it's not going to harm it as long as it's not saved in any database to be displayed by the server. The answer looks obvious, but, as I said earlier, my experience is really low on JS (and I hate scripting languages which makes my experience on them even lower) and I just want to be one hundred and one percent sure about that.

P.S. The question doesn't look hard to me, waiting for the answer.
__________________

I want to be a rep beast! Give me rep! Click at the top of my post.

How to set up portable C++ IDE (Dev-C++)
Reply With Quote
  #2  
Old 11-28-2009
Moderator
 
Join Date: Dec 2005
Posts: 1,863
Rep Power: 6
Umang is on a distinguished road
Re: Security

Quote:
Is it safe (can someone hack my website using this (continue reading) to harm my website and/or its users) to allow writing the code on my website using that Javascript? Well, writing some security staff is pointless, I guess, because anyone can edit the code. And when you think about editing the code of the website, anyone, even I, can write any code on the website they are visiting, but it's not going to harm it as long as it's not saved in any database to be displayed by the server
Sorry, didn't quite get that. Could you explain?
Reply With Quote
  #3  
Old 11-29-2009
vento's Avatar
Sexy monkey
 
Join Date: May 2009
Location: Lithuania
Age: 16
Posts: 183
Rep Power: 1
vento is on a distinguished road
Re: Security

OK, There is a form in which you enter some numbers, mark something from a drop-down menu and then the page reloads sending all that data in POST. Then PHP makes some simple calculation and prints something on the screen. I do filter all the data so it doesn't contain any harmful code and then it calculates the answer using some formulas.

I want to use JS instead of PHP because then, I would save server resources (not a lot, but anyway) and those calculations are simple enough that the JavaScript wouldn't run too slowly. Actually it should be nearly instant. So the question is if it is safe to use JS to publish something on the website? I'm not going to save any of that data on my server, so it looks like it can't make any harm to the website, but I just want to be sure.

Example.
So I usually type some numebrs in the form:
90
14
3

and it makes some calculations using those three. Then it prints the answer:

4

So, I want to use JS for this as it is very simple, but JS is done in a browser and so anyone can edit the code, so it's totally unsecured against publishing code on the website:

90
< b > test </ b >
3.

During the calculations it may print some errors as the input is not a number, but anyway.

P.S. I just wonder if JS can make any harm to the website. I mean should I still use PHP or is JS OK?

------Edited------
Delete this thread, found out about such thing as innerText
__________________

I want to be a rep beast! Give me rep! Click at the top of my post.

How to set up portable C++ IDE (Dev-C++)
Reply With Quote
  #4  
Old 11-29-2009
callumjones's Avatar
Powered by an API.
 
Join Date: Mar 2005
Location: Perth, Australia
Age: 19
Posts: 3,610
Rep Power: 9
callumjones has a spectacular aura aboutcallumjones has a spectacular aura about
Re: Security

JS won't harm your web page as I believe you aren't doing any post back to the server.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On