Confuse about web hosting CPanel [closed] - spring-mvc

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've read some article about deploying a website to a host. It has something like cPanel and we put all the source code into the public_html folder. And we can access those file using hostname.com/index.html will be pointed to /public_html/index.html file. My question is:
In this case, people can totally access all my source code file inside the public_html directory? It's too dangerous
By the way, some modern web design today is not access page through a file, it's instead by route. For example with Java spring MVC project: if I design a route hostname.com/users will return a page with all user, hostname.com/user/1 will return a json with user no.1. Those are all accessed by url route so how can I deploy that website in cPanel.
Please explain to me if anyone knows. Thank you.

To answer your first question, no. Not technically. Static items such as HTML/CSS/Javascript/Media Files can be accessed if they know the URL (Or you leave the indexing option enabled. Use .htaccess to disable that). PHP files are safe. The only thing people would be able to see is the OUTPUT of those. I would recommend using PHP when creating websites if possible.
You can achieve similar results to your second question be utilizing the .htaccess file and it's rewrite properties. You can also use PHP's POST/GET methods to handle events like you're suggesting.
I hope this helps!

Take a look at the file permissions settings available in cPanel on LAMP:
r = read
w = write
x = execute
You have Owner, Group, & World settings each with read, write, & execute values that can enable fine grained permissions on code, files, & folders on production web servers.

Related

Is it a good practice to use Google Cloud App Engine + Firebase + Cloud Functions to serve HTML cache? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Gev here from Ucraft.
I am reaching out to ask you for some help with ideas on how we can realise the following:
Ucraft is a website builder, built on PHP on the backend, hosted on Google Cloud App Engine.
Now we want to develop a caching mechanism for our public views(Pure HTML hosted in Cloud Storage).
As our frontend websites are multilingual we will need cache for available languages, for which we are thinking to generate HTML cache on a certain step, if cache is not available, using the lang prefix, like Folder: Cache > www.aaa.com > en_GB > index.html/about-us.html…
As out frontend also supports location based layout changes, we will need to generate cache, like this: Cache Folder > www.aaa.com > en_GB > Global > index.html or smth like this: Cache Folder > www.aaa.com > en_GB > uk > index.html, which means that this folder includes cache specific to UK…
#
Scenario: As we need to detect the end user’s location to understand which cache to serve, we are thinking to use Cloud Functions + Firebase. In Firebase we will store DBs that describe if a website has got any location based cache(this will help us to determine the path of the cached folder). In Cloud Functions we want to write a small piece of code, a kind of a tiny load balancer with a logic, that will get the users location from the initial request, check in Firebase, if the website has any location specific cache, if the location of the user and the cache are the same it will serve the cache in the response. If there is no cache available, it will turn to App Engine, Get the HTML, cache it in Cloud Storage, and serve te request
Question: Is this a good practice to store the cache in Cloud Storage as html?
Thank you!

Designing a RESTful API for managing resources as directories and files [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I am designing a RESTful API that deals (among others) with managing directories and files.
Due to some tricky business rules (listed below) I have some troubles in finding a good structure of the resources and a good URI design...
There are many directories.
A directory has many files.
The list of files can be accessed only from their parent directory.
A specific file can be accessed "globally" (by its id only)
Files can be created, but the client should not be able to specify the parent folder (as new files are saved in a special directory and can only be moved later etc.)
Here's a possible URI design:
Get all directories:
GET /api/directories
Get properties a directory:
GET /api/directories/{directoryId}
Get files within a directory:
GET /api/directories/{directoryId}/files
Get a file:
GET /api/files/{fileId}
Delete a file:
DELETE /api/files/{fileId}
Create a file:
POST /api/files
Is this an awkward design? If yes, why?
Also, if it were to document this RESTful API, this would be a bit awkward too:
Directories resource
Resource URI:
/api/directories
Possible operations:
GET /api/directories
GET /api/directories/{directoryId}
Links to other resources:
(?) How to write this?
There is a link to the Files resource, but that is accessible only when using the second operation.
Files resource
Resource URI:
(?) ... there are two URIs... one for "get all" ("or get many") and one for the rest of the operations.
Possible operations:
GET /api/directories/{directoryId}/files
GET /api/files/{fileId}
DELETE /api/files/{fileId}
POST /api/files
Links to other resources:
Link to Directory resource - note the singular here (?)
Strictly speaking, there is no Directory resource, but there is a Directories one - should I treat these two (Directory VS Directories) separately? please see the question at the end.
Also, this link is available only in the first two operations... How to be more precise when specifying this?
Also, I've seen that some RESTful API documentations have separate entries for the collection-like resource and the instance / element-like resource (for example, see this).
Is such a granular documentation preferable? I guess one advantage would be that the "Links to other resources" (or "related resources") section of the documentation would be more precise. Or am I wrong?
Any idea is appreciated!
Thank you :)
I wouldn't say that what you have is particularly awkward. If it were me, I would support these URLs:
GET /directories
GET /directories/{directoryId} // includes a link to the files in the directory, such as /files?directoryId={directoryId}
GET /directories/{directoryId}?expand=files // includes a child collection with links to each individual file resource, and possibly other metadata as well
GET /files
GET /files?directoryId={directoryId}
POST /files
GET /files/{fileId}
DELETE /files/{fileId}
The /directories/{directoryId}/files paradigm is common, but not my favorite. If the user wants the files for a directory, they can use a query parameter on /files. If they want the files at the same time as the directory, they can use a query parameter on /directories/{directoryId}.
This is, of course, all subjective. Without knowing all the specifics, nobody's going to be able to give you a canonically correct answer.
As far as the documentation goes, there's no hard-and-fast structure. If you don't like what you have, change it to avoid the awkwardness. Also, you do have several Directory instances. Each resource that gets returned from /directories/{directoryId} is a Directory.

Upload file to server using class dll

It is fairly easy to upload a file using web form. But I need to accomplish this through DLL.
I have classic ASP page with file upload form and I need to create an object that handles the uploaded file from customer and save the file to the server. What would be the best way to approach this? I have been digging and came across Web.HttpPostedFile and HttpWebRequest. but I don't know which route to take.
Also, I am a bit confused about how to pass the uploaded file to DLL so my class can upload and manipulate the file. is there any sample code for this?
Thanks for any help or advice.
This question doesn't make much sense, as you kind of asking "I have old car's parts and I need to assemble one by using a wheel". What? That doesn't make sense.
A dll is a container for some code. You do not use a container per se to upload a file. You should search for "classic asp upload file sample", find a solution, give it a try and come back with a specific problem.
I also noticed HTTPS tag, the idea with S, is that you don't care whether it is secure or not from the programming perspective. If you are able to use HTTP, it is trivial to upload files to HTTPS - just change the URL in the UI. The server code itself wouldn't change. What will change is the server hosting configuration, you would have to add certificate details.

Physical Path for image saving. Asp.net

I have a web project and I saved my images in Physical folders in hdd Like d:\SecretImages\Imagename. But I can't open the files when I have to?
I thought if it can saves for examle d:\SecretImages\Temp.jpg, I can open when I have to but, I can't.
Help me please, thanks
You cannot use file paths to show your images. The browser doesn't know where to find the images and the server wouldn't serve them up anyway due to security concerns.
You could/should use an HttpHandler to show the images.
I answered a similar question here on SO how to do this.
its becus when iis get file, it get as ASP.NET user not local system user. just go to the folder and add IIS_IURS group to permission list. or just set folder accessible by everyone.
this type of problem mostly not occur when local debugging. but will happen in production or network storage.
Try this article
http://www.aspsnippets.com/Articles/Display-Images-in-GridView-Control-using-the-path-stored-in-SQL-Server-database.aspx

How to organize an ASP.NET project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I am a PHP developer moving into an ASP.NET environment. I would like to know the best way to organize the different types of files.
Right now in my project I have the following:
3 Master Files
5 User Controls
1 Base page class
Several Web Forms
The web forms are organized into directories based on the sites structure. But do I just leave the rest of these things on the root level?
The base class can go into the app_code folder, but where do masters and user controls go?
I usually make a /MasterPages/ folder for master pages and break content down into things like /Users/ for pages in the "Users" section of the site and /Users/Controls/ for controls for those pages.
So something like this:
../ root
/Admin/
/Admin/Controls/
/JavaScript/ (or a /Includes/)
/MasterPages/
/Users/
/Users/Controls/
etc.
Structure your site like you would if you were using PHP. The directory structure doesn't affect anything* until you get into something like ASP.NET MVP.
* aside from page linking
If you put the master files in any directory. It might be possible to make problem of path. So, If you are putting your web files in any directory then put master files also there. For the user and custom control, Make a directory for them and put them in that directory and go to web.config and make a "Controls" child tag in "Pages" tag like this.
By this thing you no need to put "Register" tag on each page where you are using user controls.

Resources