ashkir Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/W9M-tej.gif) Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 36 Joined:
pmskypemsnyahoo | Using dummy index to hide directory, how can i? (2nd Feb 10 at 7:22pm UTC) | | 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? | |
|
Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: Using dummy index to hide directory, how can.. (2nd Feb 10 at 8:58pm UTC) | | You could just name it image_list.php or something | |
|
ashkir Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/W9M-tej.gif) Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 36 Joined:
pmskypemsnyahoo | Re: Using dummy index to hide directory, how can.. (2nd Feb 10 at 9:33pm UTC) | | 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. | |
|
Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: Using dummy index to hide directory, how can.. (2nd Feb 10 at 11:18pm UTC) | | 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. | |
|
|
dog199200 Guest | Re: Using dummy index to hide directory, how can.. (2nd Feb 10 at 11:27pm UTC) | | 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. | |
|
Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 12:32am UTC) | | 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! | |
|
dog199200 Guest | Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 12:41am UTC) | | Actually that would work wouldn't it, in the end the list is just an array call the array and its content, and it would work
| |
|
ashkir Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/W9M-tej.gif) Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 36 Joined:
pmskypemsnyahoo | Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 12:48am UTC) | | 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. | |
|
dog199200 Guest | Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 12:54am UTC) | | 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
| |
|
ashkir Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/W9M-tej.gif) Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 36 Joined:
pmskypemsnyahoo | Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 7:06pm UTC) | | they give me a blank page. | |
|