vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Using dummy index to hide directory, how can i? - View Topic
Topic Rating: *****
Printable View
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
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]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
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 {Smile}
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
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 {Smile}


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]

Posts: 3,709
Status: Offline
Gender: Male
Age: 9 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
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.

Image
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]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
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! {Tongue Out}
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 {Unsure} call the array and its content, and it would work {Unsure}
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
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 {Tongue Out}

Code:
 
  1. <?php
  2. $dir = "Image File Directory Here";
  3.  
  4. if (is_dir($dir)) {
  5.     if ($dh = opendir($dir)) {
  6.         while (($file = readdir($dh)) !== false) {
  7.             echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
  8.         }
  9.         closedir($dh);
  10.     }
  11. }
  12. ?>
 


that will display the name and the file type, but if you wnat them linked to the images then try this:

Code:
 
  1. <?php
  2. $dir = "Image File Directory Here */dir/images/*";
  3. $url = "The URL Of The Site *http://www.yoursite.com*";
  4.  
  5.  
  6. if (is_dir($dir)) {
  7.     if ($dh = opendir($dir)) {
  8.         while (($file = readdir($dh)) !== false) {
  9.             echo "filename: <a href=\"$url\">$file</a> : filetype: " . filetype($dir . $file) . "\n";
  10.         }
  11.         closedir($dh);
  12.     }
  13. }
  14. ?>
 


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]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
Re: Using dummy index to hide directory, how can.. (3rd Feb 10 at 7:06pm UTC)
they give me a blank page.
 Printable View

All times are GMT+0 :: The current time is 2:42pm
Page generated in 1.1821 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums