# Site with file listing



## WhiteSuburban (Jul 24, 2012)

I'm gonna make a another site, yep.
Anyways, I'm just going to make a site that will simply get what files that are in a directory from its own server and link them for download.
So if I request what is in the directory of /files, it will pull what files in that directory and list them on the page.


----------



## CerbrusNL (Jul 24, 2012)

Okay, do you plan on the site having access to your entire PC, that way?


----------



## WhiteSuburban (Jul 24, 2012)

Ok, new stuff. The file types I seem to be using are not allowed, but they use the XML format, so I'm making a page that will convert the XML to readable text. Also found some tuts along with directory scanning.


----------



## WhiteSuburban (Jul 24, 2012)

CerbrusNL said:


> Okay, do you plan on the site having access to your entire PC, that way?


Nope, tried scanning a directory on dropbox cause permission errors.


----------



## WhiteSuburban (Jul 24, 2012)

Using code from my other pages and I noticed this.

```
$path = $_GET['textdoc'];
```
So I set $path but I still did the same function here

```
src="<?php echo $_GET['textdoc'];?>"
```
This isn't right.


```
src="<?php echo $path;?>"
```
Better.


----------



## CerbrusNL (Jul 24, 2012)

Dude, really, stop using dropbox to "host" a site.
It doesn't work with php. And you're going to have to use php, or some other server-side language to create a directory listing.


----------



## WhiteSuburban (Jul 24, 2012)

The site is no longer hosted on DropBox anymore.

This site is planed to pull files from the server itself, not dropbox.

However my other site pulls some stuff from there because I can edit a file without needing to connect to the FTP as much.
These include my stories and the list of them.


----------



## WhiteSuburban (Jul 24, 2012)

Again, problems, SAFE MODE is on. People say that it can be disabled by a .htcaccess command.


----------



## Elim Garak (Jul 24, 2012)

WhiteSuburban said:


> Again, problems, SAFE MODE is on. People say that it can be disabled by a .htcaccess command.


Safe mode is removed in PHP 5.4.0 and is a shitty way for security, and for old PHP versions.
[FONT=Verdana, Arial, Helvetica, sans-serif]php_value safe_mode "0"should fix it but only if your webhost provider allows overrides.[/FONT]
[FONT=Verdana, Arial, Helvetica, sans-serif]Seeing the webhost is retarded enough to not allow XML(Which is retarded beyond believe) they probably don't.
Also its easier to just turn on indexing for a directory in .htaccess so you don't need a PHP file and just open the directory, if you want security just use htaccess for that.[/FONT]​


----------



## CerbrusNL (Jul 24, 2012)

[edit] This ^ (The button's broken) [/edit]

So, in the end, you'll want something like this? (Only contains dummy folders. It is automatically generated, though, when hosted on my own server, but I can't do that in my fa webspace.)
http://cerberusnl.furaffinity.net/files/dirtool/index.html

Regarding safe mode, do you have root access to your server? (Aka, can you access the server's configuration file?)


----------



## WhiteSuburban (Jul 24, 2012)

Those clever sons of bitches. They don't allow overrides.
Welp, off to move this off to x10hosting.
Should be easy as pie.


----------



## WhiteSuburban (Jul 24, 2012)

CerbrusNL said:


> [edit] This ^ (The button's broken) [/edit]
> 
> So, in the end, you'll want something like this? (Only contains dummy folders. It is automatically generated, though, when hosted on my own server, but I can't do that in my fa webspace.)
> http://cerberusnl.furaffinity.net/files/dirtool/index.html
> ...


Yeah, pretty much, thanks.
Nope, I need to pack off to x10hosting since they have a more up to date php.


----------



## WhiteSuburban (Jul 24, 2012)

Just to make the page seem like its still on the clanteam address, any way to embed a full sized webpage?

Or how to allow the clanteam address to use the x10hosting's servers.

Just to note, because I forgot.

Clanteam uses a their own, basic as hell panel. Only useful thing is making databases.
x10hosting is hella more better as it uses cPanel. More useful for something I'm doing.

---

Can scandir work on remote servers?
Nope.


----------



## ArielMT (Jul 24, 2012)

WhiteSuburban said:


> Again, problems, SAFE MODE is on. People say that it can be disabled by a .htcaccess command.



Please learn to program well before going much further.

Safe mode existed in PHP (up until 5.4.0) because, without it, an attacker could own the entire network by way of one poorly-written PHP file on a shared host.  If the host has enabled it, DO NOT TRY TO DISABLE IT.  You know not the kind of trouble you're begging to bring in.


----------



## WhiteSuburban (Jul 24, 2012)

```
Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 32 bytes) in /home/thednet/public_html/directory/index.php on line 7
```
What.


----------



## WhiteSuburban (Jul 24, 2012)

ArielMT said:


> Please learn to program well before going much further.
> 
> Safe mode existed in PHP (up until 5.4.0) because, without it, an attacker could own the entire network by way of one poorly-written PHP file on a shared host. If the host has enabled it, DO NOT TRY TO DISABLE IT. You know not the kind of trouble you're begging to bring in.


Switched to a hoster with a new version of php.


----------



## CerbrusNL (Jul 24, 2012)

WhiteSuburban said:


> ```
> Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 32 bytes) in /home/thednet/public_html/directory/index.php on line 7
> ```
> What.



What's in that php file?


----------



## WhiteSuburban (Jul 24, 2012)

CerbrusNL said:


> What's in that php file?




```
<center>
<h1>Welcome to the [EXPUNGED]</h1>


<?php
$dir = "/contacts";
$dh  = opendir($dir);
while (false !== ($filename = readdir($dh))) {
    $files[] = $filename;
}


sort($files);


print_r($files);


rsort($files);


print_r($files);


?>


<h2>The site is still in development</h2>
```
I'm just as dumbfounded.
This page shares the space of a other site and that had some large content, which got removed after a spam attack so I can't see this being big for a server.


----------



## CerbrusNL (Jul 24, 2012)

And can you add a screenshot of the directory structure?


----------



## WhiteSuburban (Jul 24, 2012)

Getting. Might block out some stuff for the sake of my personal information.
Also, you just want the files that we are working with, yes?


----------



## CerbrusNL (Jul 24, 2012)

Yea, that'd be convenient, and also the structure of the directory you're trying to read.


----------



## WhiteSuburban (Jul 24, 2012)

CerbrusNL said:


> Yea, that'd be convenient, and also the structure of the directory you're trying to read.







This is what I got from Windows Explorer, same thing can be seen by FileZilla. If you want me to index them one by one, you have to suggest an idea to help me from straining myself.
The one highlighted by green is the files that we are working with.
We have quit on ClanTeam because they don't allow remote accessing.


----------



## WhiteSuburban (Jul 24, 2012)

Ok, fixed the error because I was using the incorrect method, but produces nothing

```
<?php 


$path = "/contacts";
$dir    = $path;
$files1 = scandir($dir);
$files2 = scandir($dir, 1);


print_r($files1);
print_r($files2);
?>
```
Wait, I did something incorrect, those "s need to be 's
Still blank...


----------



## Elim Garak (Jul 24, 2012)

Oh dynamic one page listing, you need PHP for that yeah.
http://skyedax.info/firestorm/ I just keep it simple myself.

Edit: I am not sure if windows explorer is your main upload "client", not sure how it handles chmod for linux hosts, which most web hosts are.


----------



## WhiteSuburban (Jul 24, 2012)

I just use it because it integrates well.
Also everything is not tiny like in FileZilla.


----------



## CerbrusNL (Jul 24, 2012)

Elim Garak said:


> Edit: I am not sure if windows explorer is your main upload "client", not sure how it handles chmod for linux hosts, which most web hosts are.



Windows explorer seems adequate.
It can show duplicate files when overwriting something, though, but a refresh should fix that, usually.


----------



## Elim Garak (Jul 24, 2012)

WhiteSuburban said:


> I just use it because it integrates well.
> Also everything is not tiny like in FileZilla.


Well, does it set the file permissions correctly?
I think Windows Explorer assumes the other host to be Windows, and Windows/NTFS permissions are way way way different fundamentally than chmod on linux. Filezilla keeps this in mind, and allows you to set whatever permission you need for the script or directory. File permissions matter on linux webhosts a lot, they are part of the security.


----------



## WhiteSuburban (Jul 24, 2012)

Elim Garak said:


> Well, does it set the file permissions correctly?
> I think Windows Explorer assumes the other host to be Windows, and Windows/NTFS permissions are way way way different fundamentally than chmod on linux. Filezilla keeps this in mind, and allows you to set whatever permission you need for the script or directory. File permissions matter on linux webhosts a lot, they are part of the security.







This is what I get if I wish to change FTP properties for a file.


----------



## ArielMT (Jul 24, 2012)

Are you getting any warning messages?

Have you verified that what scandir() returned really was an array?


----------



## Elim Garak (Jul 24, 2012)

WhiteSuburban said:


> This is what I get if I wish to change FTP properties for a file.


NP then, just a matter of setting them right.


----------



## WhiteSuburban (Jul 24, 2012)

Crap, the script tripped the resource limit.
Well, the waiting game begins.

Back up.

Not even sure if its getting any data, that requested file has some stuff in it.


----------



## WhiteSuburban (Jul 24, 2012)

Ok, something happened.

The sites progress has been canceled.


----------



## Runefox (Jul 24, 2012)

This... Would be so much easier... If you just set the server to serve indexes on the folder in question.

Boom! Instant file listings with download links. You can even set what information is shown. Hell, one time I even modified the output template and jazzed it up to look nice. I even modified the MIME types on the server to serve proper info on eccentric filetypes.

It's... Well, unless you need to know how to do this for something else, this is really a lot easier. :| It's what most repos do.


----------



## Aden (Jul 24, 2012)

Runefox said:


> This... Would be so much easier... If you just set the server to serve indexes on the folder in question.
> 
> Boom! Instant file listings with download links. You can even set what information is shown. Hell, one time I even modified the output template and jazzed it up to look nice. I even modified the MIME types on the server to serve proper info on eccentric filetypes.
> 
> It's... Well, unless you need to know how to do this for something else, this is really a lot easier. :| It's what most repos do.



I read this whole thread wondering why someone hasn't said exactly that


----------



## Elim Garak (Jul 25, 2012)

Aden said:


> I read this whole thread wondering why someone hasn't said exactly that


I did: 


Elim Garak said:


> Also its easier to just turn on indexing for a directory in .htaccess so you don't need a PHP file and just open the directory, if you want security just use htaccess for that.​


Though I opted for only certain directories of the structure because some people don't like it to be for every part of your public_html.


----------



## Runefox (Jul 25, 2012)

For the .htaccess to work, you'd need to be sure that ALLOW OVERRIDE ALL is set in the site, and that's assuming Apache and similar.


----------



## Elim Garak (Jul 25, 2012)

Runefox said:


> For the .htaccess to work, you'd need to be sure that ALLOW OVERRIDE ALL is set in the site, and that's assuming Apache and similar.


Yeah, most web hosts have this though. Often you don't have much of choice but to use it. Besides Apache is the most used for regular webhosts, with larger companies you see static content like on cache servers using nginx. IIS is not really common in regular web hosts.
Seeing that he's using a regular web host rather than a VPS or Dedi this should apply.


----------



## ArielMT (Jul 25, 2012)

Aden said:


> I read this whole thread wondering why someone hasn't said exactly that



I wanted to on three occasions, but I gave up on cargo-culting programmers.  He's just copying straight from the examples in the manual, verbatim in all but variable names, without any of the necessary error-checking to handle the simple challenges he's encountering.


----------



## Elim Garak (Jul 25, 2012)

ArielMT said:


> I wanted to on three occasions, but I gave up on cargo-culting programmers.  He's just copying straight from the examples in the manual, verbatim in all but variable names, without any of the necessary error-checking to handle the simple challenges he's encountering.


Yeah, I can see how it gets annoying. Personally I have written PHP scripts from scratch but all they are simple backends that connect to Mysql so I can store information from my LSL items in SL(I have lots of logging systems and the likes).


----------

