Set site's /image folder to be protected [closed] - html

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a website which uses many files inside of /images and other /folder directories that the HTML files use to display on the page.
What I'd like to do is protect the images so that a user can't go to the root (/images) in this case, and see a directory listing of all of the files in the folder.
I only want the website to display the photo.
I found a perfect example:
http://edge2.mobafire.com/images/champion/icon/tryndamere.png
The image is used by the HTML page and displays perfectly when directly accessing the image in the URL, but the following links are all protected:
Example 1: http://edge2.mobafire.com/images/champion/icon
Example 2: http://edge2.mobafire.com/images
Thanks!

That is typically a webserver configuration paramater. I believe you can achieve the same thing with .htaccess rules (which I do not know off the top of my head).
Knowing what kind of webserver your website runs on and also if you are running the server yourself, or if you are using a shared hosting account will be necessary to further answer the question.
Assuming you are cool, and you run your own server using Apache2 -- you would edit your virtual host (or httpd.conf if you do not use virtual hosts) and find the definition for your root directory like so:
example vhost configuration /etc/apache2/vhost/mywebsite.com.conf:
<Directory "/var/www/website.com/htdocs">
Options Indexes FollowSymLinks
</Directory>
The Option "Indexes" is what tells the webserver that it's OK to view all files within a directory that has no index file. To disable this functionality like you are asking you would remove the word "Indexes" or prepend a hyphen (-) in front of the work Indexes.
If you do not use apache or have root access to your server -- good keywords for you to ask your hosting provider is "How do I disable indexing in folders that have no index file" or similar.

Drop a blank index.html file in the folder.

Related

Use of MYSQL to edit elements in HTML [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
So, I'm making a website for a music collective that I'm in, and on that site there's a page where you can see all the albums (a simple 300 x 300px hyper link image) that redirects you to a bandcamp page.
As of now, if I want to add another album I must go into the HTML file and manually add it. My question is, is it possible to use MYSQL to add albums?
And by that I mean that everytime I "add an album" in MYSQL it will edit the HTML automatically? And if so, how do I do?
This is how the code looks:
HTML
<div class="product-box fade-in-drop">
<!-- album -->
<div class ="album">
<img src="exmaple.com">
</div>
</div>
EDIT:
It might be worth noting that I use a web hosting service that has a cPanel so I have database access, I just don't know how to write the code to make my plan possible.
I apologize if I am assuming too much here.
Your question implies that you want to move from a static website to a dynamic one where, instead of the HTML having static data, your information comes to the page by way of a web server making a connection to a database via some sort of intermediary, third party software. This is much more complicated than what you are doing now, but it is certainly not the most difficult task for creating a simple website that has outgrown the needs of a static page.
Here is a nice tutorial I have found, for an introduction. But I would recommend getting a book on LAMP development, particularly one that is more current than that article. You also might want to look into Drupal, though that might be overkill depending upon how simple your needs are.
It's not possible with pure HTML. You need some server side logic to query the database, like PHP, python, perl etc., and use the data to build the HTML dynamically.
You can't use HTML5 / Javascript dynamics because they are run by the client, your database is on the server.
What you can do based on the information you have given us is take the data that exists currently in the cPanel database access and find some way to copy that data into MySQL whether it's importing it directly, using Excel, or whatever. That would be the best way to go and then set up a connection to the MySQL database server. As mentioned you can use PHP, python, etc. to manipulate that data and have access to read/write that data through your site. Just by googling the basics you should be set on the right path to get a working dynamic website.

How to git a mysql database made on phpmyadmin [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I would like to use git on a database made with phpmyadmin for use it with my collaborators. Is there a way to use git together with phpmyadmin? If yes I have not found it through the web, so I would llike to init git in the folder where the database is stored, but I can't find this directory, where could it be? I'm working on ubuntu 13.10.
Thank you for the help.
I would recommend exporting the database (under the Export tab in phpMyAdmin), and store the exported form of your database as a flat file a directory you create as a git repo. Re-export when you want.
This also gives you the flexibility to export a specific database instead of the whole system. Just highlight the database you want to export before you click on the Export tab.
It's really not the intended use of git (or any distributed source control system) to store binary files. There's no way to merge them, so files just overwrite rather than merge. Add to this pushes from other people's local repos, and it just becomes a mess of people clobbering each others' work.
Also the data files in your data directory are updating continually. They would not update the committed copy in git until you do a git commit. There's no guarantee that you'd commit these files in a safe manner. That is, you could save the last table a few seconds later than the first table, and then you'd have an inconsistent snapshot of the data.
To ensure a consistent export, you'd have to make sure no applications are making any changes, or else lock all tables.
But to answer your question, you can find out the location of a given MySQL instance's data directory in phpMyAdmin, by clicking the Variables tab, and searching for the variable datadir. The value of that variable is the location of your data directory on the MySQL server.

Apache directory listing with upload button and search textbox

So i have a server, with apache 2 - running a directory browser(i think it's called. Where i can access my files), as my own dropbox server. However it does how some limitations, when i'm at school for instance, and i wish to upload a project, i gotta send it with email to myself to upload it, i cant delete or anything. So i wanted to add a delete button(least important), i wanted to add a search function since the files are beginning to stack up. I would also like an upload button. I didn't really understand apache, i followed a tutorial for the server. I have a very basic html knowledge, and i have tried and tried to create it myself, and i have been searching for a loooong time(trust me).
So could anyone post a solution/tutorial/tip or anything useful? Please try to help me instead of answering with rude answers. I'm 15 and hoping to get these features up and running as soon as possible. Thanks:)
Just use the open source FTP FileZilla software https://filezilla-project.org/ instead?

How will a CDN work with my site?

I have tried to look for answers for my question but haven't found anything conclusive.
I have a site which, among other things, stores member pictures & thumbnails. They are in separate directories, and within each directory are a cascade of folder names based on properties of the image. This is to prevent thousands of images being in one directory for performance reasons.
for example, a typical image has a URL like:
www.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
The file location and name are stored in a mysql database so they can be dynamically displayed.
How would a CDN be implemented for my images? Can I recursively select all the images in a directory to be uploaded to the CDN? How often would it update this file information?
And finally, what might happens when the database retrieves a url like the one above? Will the CDN automatically redirect the user to something like this?
www.cdn.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
Or will I have to design my database differently?
Thank you.
If you choose to migrate to a CDN and not change your URL scheme you would have to make sure requests to www.mysite.com/thumbs/ are routed to your CDN (at www.cdn.mysite.com/thumbs/).
You also need to change your method of saving images to also save a copy to the CDN, or you could create a synchronization script to run periodically, but then you would need to serve your resources from two locations; from your own if the file is not present on the CDN, which would increase the complexity of your setup.
I would make sure I store my resources directly at my CDN at the same time I backup locally and would migrate to a separate domain form my CDN (to allow more concurrent downloads from the user).

Wordpress theme editing

Well, I am a newbie with Wordpress.
I just got a free wordpress theme. I want to edit the pages to my customization. I have a shared host which provides MySQL database.
Can I edit this wordpress theme to connect to this MySQL database and pull/push data in to my database?
Is the whole process similar to working with normal php and MySQL? Whats so much difference with the set of php's being a Wordpress theme?
Thanks
Themes are just a bunch of php files which get executed in response to some particular event (basically when a particular kind of page nees to be rendered). You can do whatever you want in them, but everything which is not meant to be "aestethic" should probably be developed in a separate set of custom plugins. You then call those from your theme.
Once you have wordpress installed with the hosting provider and the database connection between the WP installation and the hosting provider MySQL database you can edit your theme through WP itself.
Make sure you set the permissions on the WP-Templates (I think thats what it is called) folder to read/write so that wordpress can write to the template files.
View the following link for any help editing the template. How to edit a WP Template
The theme is just the interfacce of your system, on your theme you only show the data, you need to run a select for instance in the apropriate part, also for the bussines logic.
If you do in the interface, in time your system will mess up.
In the official documentation have plenty of examples and How to's,..
The short answer - there are a number of different templates for the index, search, archive, page and article views of a Wordpress theme. Some themes don't include all of them - certain templates are the default for the other optional templates. You can edit them with software like Dreamweaver or a text editor of you choice, or you can alter them from the Wordpress admin panel.
Wordpress themes are a little too complicated to explain in one simple answer, but I can recommend a tutorial. It's a little dated, but it will explain the overall ideas and it's quite good.
Here's another - I've not read it over but it looks to be well done: http://themeshaper.com/wordpress-themes-templates-tutorial/
A theme is a collection of PHP files along with related files (CSS, JavaScript, images, etc.) that control the appearance of the WordPress site. The content (posts, pages, comments, options, plugin configuration, etc.) of the blog is stored in the database. Any themes on the site are thus separate from the content.
Themes can normally be edited directly from the WordPress admin console. Click on "Appearance" and then on "Editor". You can then edit any of the current theme's files from there. Useful for tweaking things if you know what you're doing, but dangerous in some ways because there's no easy way to undo your changes. Do a backup of your theme before noodling with it.
This entry in the WordPress Codex will help:
http://codex.wordpress.org/Editing_Files