So I am hiding my images folder with a blank index.php so people cannot see it. But I love my listing when finding an image, but I have to remake the index.php file each time I rename it to see my images listing.
Is there a PHP way to make a second index in a location that only I will know about?
You could just name it
image_list.php
or something![]()
You could just name it
image_list.php
or something![]()
How can I get that to automatically list all my files in it?
I constantly keep renaming it to index2.php so I can use the index, then renaming it back. I am tired of doing this.
Hmmm, not tried this before but you could try using a .htaccess file to restrict access to the directory for anyone other than yourself. Something like:
RewriteEngine on # Turn on the rewrite engine
RewriteCond %{SCRIPT_FILENAME} !-f # Check we're not trying to access a file
RewriteCond %{REMOTE_ADDR} !145.149.123.458 # Check it's not from your IP address
RewriteRule .+ / [L,F] # Return a "Forbidden" message and stop checking for more rules
Failing that a php file could be used to read and list the contents of the current directory.
The problem with that Ross is that if ashkir does not have a static ip address, as soon as it changes he will be locked out of his own site.
I suppose if you are willing to put a little extra time into things, you would always write a small login system, or something simlar, wouldn't even need to by Mysql, for something small like that, flat file would work perfectly.
Just use some PHP to list the contents of the folder.... doesn't need to have any form of security really 'cause only he'll know the URL to the file!![]()
Actually that would work wouldn't it, in the end the list is just an arraycall the array and its content, and it would work
![]()
I don't know PHP to do this and don't exactly sure how to search for this.
Also! Good idea Ross, but hopping around from different internet connections will make it a pain over time.
hmm ok try this![]()
Code:
- <?php
- $dir = "Image File Directory Here";
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
- }
- closedir($dh);
- }
- }
- ?>
that will display the name and the file type, but if you wnat them linked to the images then try this:
Code:
- <?php
- $dir = "Image File Directory Here */dir/images/*";
- $url = "The URL Of The Site *http://www.yoursite.com*";
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- echo "filename: <a href=\"$url\">$file</a> : filetype: " . filetype($dir . $file) . "\n";
- }
- closedir($dh);
- }
- }
- ?>
I have no exactly tested this so if it doens't work let me know what it says and i'll fix it
they give me a blank page.