Can I read and edit files that belong to the website folder using only html and javascript? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am creating a website that must be able to login using the credentials that are saved in a text file(login.txt).After logging in the person must be able to add and remove images(images folder).
These images will then later be used to create a gallery that all users will be able to view.
What I want to know is can i achieve these results by only making use of HTML and JavaScript or must i also make use of server side languages like php or asp.net ?
note : I have done a good amount of research and still wasn't able to find an accurate answer for this question.
Any advice will be useful. Thanks ahead...

Short answer: You have to use a server
I assume you already know Javascript, so my advice is use Node.js.
You have to use a server side language because other users need to see the gallery , besides the ones that are uploading. So you can't use localStorage to save the images, because the front-end is private to the user, not global to every user (like a database or a server).
Some suggestions:
Use a database for user details, is faster, safer, and more maintainable
Define a Rest API on the server-side
On the front-end make a Single page application (using desired framework/libraries), using TDD principle

You should to use a server side language.
And if you save the credentials in a text file then anyone can reach these infos with that file url. ( Eg: http://yoursite.com/login.txt )

What I want to know is can i achieve these results by only making use of HTML and JavaScript or must i also make use of server side languages like php or asp.net ?
You'll need something on the server. That something might be:
Web server software that supports using the PUT verb to put files in a directory on the server. The general term for this is DAV or, in the web context, WebDAV. Apache, for instance, supports it with mod_dav. I've never tried it, but it may be possible to set up Apache with simple authentication (probably not with a plain text username/password file, though) and enable WebDAV for authenticated users. Your client-side code could then send PUT requests via ajax.
A server-side programming environment of some kind whether that's PHP, ASP.Net, NodeJS, or something else.
A content management system of some kind that already provides the ability you would otherwise write.

Related

How to make a working login functions for my website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I am just entered this game since last December. Now I finished HTML CSS and a little bit of Java Script yet I got stuck at this stage: I can do basic styling but I don't know how to make it interactive.
So my question is :
how can I make a login function for websites, which can gives visitor an account (sign up, login, forgot password) that can do basic things like comment , add to basket and favorite a product?
Don't need to be specific, please just highlight which language is involved in which stage.
Thanks ahead.
Now I finished HTML CSS and a little bit of Java Script
So your site is what is called a static website.
If you want to allow login and data storing, you need a dynamic website, that requires one of this technologies:
PHP
ASP (check also ASP.NET)
Node.js (with express or http module)
Django (Python's library)
A few others...
All this technologies are called server-side languages/technologies, and the most used for long years has been PHP, that now has some strong rivals in terms of usage.
You can use only html/js to create a website. But, if you need authentication, post comments, a server side is needed.
A js can call easely an API to authenticate (server side) and post comments with XHR. You have to create it. You need to know how Authentication headers works for server side. You need to have a database (sql, file or nosql, it's your choice) to save the users datas and rights.

Best practice about login [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have made a decent website using HTML, CSS and JavaScript. I'm new to programming.
Now I want to give some privacy to some users and create a login space. I saw that some people are using PHP, other JS or Node.js, but I haven't seen any good guide for the best practice.
I would like to make a robust website with up-to-date technologies. What is the best practice for this kind of request?
It is very wide question and have so many answers and techniques based on your requirements, for example if you need to implement it yourself you need to use token based authentication, AKA JSON Web Token, technique where you simply send a token to you client after validating their username/pass to be saved in the browser and later on you can send this token along with any further API/HTTP request(s) for validating your encoded token that was sent before by your authentication service.
Check JWT site to know more about different libraries that will help you implementing this technique in almost all known languages (PHP, NodejJ, Python, .NET, and Java) in just 10 minutes.
Backend server or used language should not be the issue as much as you should understand the technique itself.
If you want to use Amazon Cloud, you can totally depend on their authentication services they provide, its name is AWS Cognito
If you need to implement social based authentication, then you should use OAuth protocol for integration with different sites like Facebook/Twitter
If you're using JS for your website then I would suggest using Node.js for your database. What you'll be creating is an authentication front to your app to protect the data within. Here is a good link on getting started with authentication.
Check this out
You probably would like to take a look at PHP.
If you want good security for your database, you will want to take a look into hashing passwords so in case your database gets hacked, it's not so easy for a hacker to get everyone's information. Not only that, but you're not a safe site if you're not hashing user's passwords, you'd be a phishing site considering you'd be able to see their passwords. (DON'T DO THAT) Here
You will also want to learn SQL for handling the information that will needed to be saved to a database for access through queries. SQL

Implementing a live chat system in Website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to add a live chat support channel in my website, mainly focused on new users who have specific questions about my services and i´be been thinking about the best way to implement this solution myself. do note that i do not intend to use third party solutions.
What i´ve thought about retrieving messages: i can have a form on the page that will activate on user click (like a "start chat" button), once the button is clicked, i will GET all messages in the database related to the client's IP address (if it's not a logged in user) through a web service and load it into the DOM. after this, i will have a javascript function that will execute every XX seconds asking whether there are new messages.
to send messages: the user will have a textArea with a "send" button that will trigger a POST to a web service in order to save their message into the database, on the Support/web admin side, everything will work in a similar fashion but with the option of having several chats at the same time. Also i think I can achieve this by using JQUERY and ajax requests.
Is this a good idea to implement a live chat services? or am I far off from the ideal way of doing this? I have browsed around and all i get is suggestions to use third party service which i definitely do not want to use. Thanks!
You should have a look at websockets, especially at the socket.io library, which provides you an event based communication between the clients and the server.
They even have an example how to create a live chat:
http://socket.io/get-started/chat/
I you want a chat that is not just a "proof of concept", you should go for using XMPP, it's the most popular (and maybe the only-one) opensource instant-messaging protocol. There are several implementations in multiple languages and it has proven its robustness.
Wikipedia :
Extensible Messaging and Presence Protocol (XMPP) is a communications protocol for message-oriented middleware based on XML (Extensible Markup Language). It enables the near-real-time exchange of structured yet extensible data between any two or more network entities.
source
You could also take a look at IRC, which is quite old but still useful.

How to let people collaborate on same form with real time updates? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a html form with some fields that are linked to a database row that have to be modified at the same time by different users.
Every time one of the users edit an input field it may call a javascript onchange (or similar) function to update the specific column in the row, but the other users that have the same page opened don't see the change until they refresh the page.
What should I use to get it changed on all devices that are looking the page?
The backend is in PHP/MySQL.
Thank you
You have a way to send pushes to your backend server but now you need to get pulls from your server.
For this purpose, you need to maintain a constant communication channel between your client and server to get real time updates from your server. There are multiple options for this:
Websockets: A TCP websocket can be used for real time communication between server and client. See this thread to get more information about websocket support in PHP.
Polling (very dirty way): you can do frequent poll from your client to your server to see if there has been any updates or not. This way of implementation is really inefficient and not recommended at all but still, since some applications already have polls in their system, if your system is already doing frequent polls, you can attach the query to get form status with that poll.
There are a couple of possible approaches.
Have an ajax request in the client periodically poll the web server to retrieve the data. Though depending on how this is implemented, there could be some performance ramifications.
You could benefit from using WebSockets. Since you're using PHP and MySQL you might look into something like Ratchet. Depending on how far along the code base is you could potentially implement something with socket.io using node.
When you look for some already existing tools, this might something for you:
https://fusion-tables-api-samples.googlecode.com/svn/trunk/FusionTablesFormSync/docs/reference.html
When you do not find anything that matches your needs, you can write it on your own. Therefore you need Ajax (To transfer a change to the server), it is more easy to use in combination with jQuery.
http://www.w3schools.com/jquery/jquery_ajax_intro.asp
And you can also fetch the data from the server with ajax, but you have to do requests all the time, which is not very nice. An alternative would be websocket, but this need a lot of knowledge.

Convert a Qt C++ application to a web app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I wrote an application which connects to a MySQL database and queries/adds/deletes data in Qt Framework. I want to convert to a web application run inside a browser. I have some experience in PHP and I could code the whole app in it, but I have a problem: I would be forced to reload the page every time when I want to do something with the database. I want to make something like Facebook/GMail/Facebook Messenger where accessing a database is achieved without reloading the whole page. This is the part which I never done before.
I have some questions about this:
What are the JavaScript libraries out there which I could use?
What is the appropriate way to do this: create a backend which is between the web app and the database, or connect to the database directly?
I don't necessarily need to stick to that languages, I'm open to new technologies, programming languages.
Edit:
Based on suggestions and my own research I found two technologies which I think I could use: AJAX and PHP(thanks to Hugo Dias) or NodeJS. I didn't wrote any code yet, so which of them would be better for my app? A little more information: this app will used by only the small number of users at the same time, like max 10.
You need to use a web server, for eg. Apache Tomcat. If you want to keep your code in c++, you could convert it into a CGI. Otherwise, you can use java servlets or JSP along with JDBC. You can set it up so that when a button is clicked the CGI script is triggered and the database queries are run.
Short answer:
Yes,there are libraries that helps you with that.
JQuery and PrototypeJS are some of them.
There are some ways of do this, but in any way,you need of a Backend. It's inherent in architecture of Web(Client-Server).
Long answer:
Yes,there are ways of do that. What you're looking for is called AJAX(and stands for Asynchronous JavaScript and XML).
AJAX is a technics that gathers some technologies like XHR and Javascript, mainly.
It allows you work with asynchronous requests,what basically lets you update your page without reload it.
You'll find extensive documentation here about it,and here a simple example with PHP.
The architecture of App is of your choice. Under the Client-Server architecture,you can apply what is best for you,since a monolithic system until a MVC or MVVM pattern.

Categories