View previous topic :: View next topic |
Author |
Message |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Sun Dec 02, 2012 6:30 pm Post subject: Ani would you mind making a PHP file for me? |
|
|
All it would need to do is take a single parameter which represents a relative directory (you can do absolute if that's easier) upon which it generates an XML file containing a listing of said directories files and folder (files and folders need to have a seperate tag so that I can tell the difference). Would that be too hard?
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
Back to top |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Sun Dec 02, 2012 6:31 pm Post subject: |
|
|
Because god forbid ftp.site.com
_________________
Brillia wrote: | I FUCKING FUCK SEX |
|
|
Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Sun Dec 02, 2012 6:31 pm Post subject: |
|
|
>speaking when not spoken to
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
Back to top |
|
 |
:^) Grandmaster Cheater Supreme
Reputation: 37
Joined: 30 Jun 2008 Posts: 1062
|
Posted: Sun Dec 02, 2012 7:06 pm Post subject: |
|
|
hi aviar, how you been
|
|
Back to top |
|
 |
PUSHEAX_PUSHEAX Grandmaster Cheater
Reputation: 72
Joined: 13 Apr 2009 Posts: 969
|
Posted: Sun Dec 02, 2012 8:19 pm Post subject: |
|
|
Let me know if this is right, I can append it easily (or you). Screenshot explains usage.
Code: | <?php
//don't use a trailing slash
$dir = htmlentities($_GET['dir']);
$xmlSaveLocation = $dir . '/structure.xml';
$domtree = new DOMDocument('1.0', 'UTF-8');
/* create the root element of the xml tree */
$xmlRoot = $domtree->createElement("directory");
/* append it to the document created */
$xmlRoot = $domtree->appendChild($xmlRoot);
$currentTrack = $domtree->createElement("list");
$currentTrack = $xmlRoot->appendChild($currentTrack);
/* you should enclose the following two lines in a cicle */
foreach(glob($dir . '/*') as $file)
{
if (basename($file) !== basename($_SERVER['PHP_SELF']) && basename($file) !== basename($xmlSaveLocation))
{
if (filetype($file) == 'file')
{
$currentTrack->appendChild($domtree->createElement('file', basename($file)));
}
elseif (filetype($file) == 'dir')
{
$currentTrack->appendChild($domtree->createElement('dir', basename($file)));
}
else
{
$currentTrack->appendChild($domtree->createElement('undefined', basename($file)));
}
}
}
$domtree->save($xmlSaveLocation);
?> |
Description: |
|
Filesize: |
55.19 KB |
Viewed: |
2405 Time(s) |

|
|
|
Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Sun Dec 02, 2012 11:55 pm Post subject: |
|
|
Thanks potaters. I haven't tested it myself, but based on the image it looks like exactly what I need. The only thing I'll probably change is so that it just responds back with the XML instead of storing it locally.
Hey Rozen, doing pretty good, you?
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
Back to top |
|
 |
Hero I'm a spammer
Reputation: 79
Joined: 16 Sep 2006 Posts: 7154
|
Posted: Mon Dec 03, 2012 12:09 am Post subject: |
|
|
fak you aviar y u no talk to me no moar?
|
|
Back to top |
|
 |
PUSHEAX_PUSHEAX Grandmaster Cheater
Reputation: 72
Joined: 13 Apr 2009 Posts: 969
|
Posted: Mon Dec 03, 2012 12:23 am Post subject: |
|
|
Aviar³ wrote: | Thanks potaters. I haven't tested it myself, but based on the image it looks like exactly what I need. The only thing I'll probably change is so that it just responds back with the XML instead of storing it locally.
Hey Rozen, doing pretty good, you? |
It doesn't. It stores it in structure.xml (overwrites the previous each time its run). I only opened it in the browser to show you the output.
|
|
Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Mon Dec 03, 2012 4:39 am Post subject: |
|
|
I was too late. Ah well.
Small note: I wouldn't use the DOM parser due to the fact that it loads the entire XML into the memory as an object. Meaning that a lot of directory entries will cause it to exceed the memory limit set by PHP. Especially with the DOM you'll exceed that memory limit relatively fast. Instead use PHP's XMLWriter class, and XMLReader to read the file. DOM is easier, but the XMLWriter and XMLReader classes are safer when you're dealing with growing XML files.
Just my two cents. If the file stays under a 100 entries this isn't information worth reading.
|
|
Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Mon Dec 03, 2012 6:36 am Post subject: |
|
|
Once again Ani, you are an inspiring light.
To potaters, I know it does not do it right now, but I imagine it would not be hard to serialize the resulting XML to be sent on the wire instead of storing it.
To Hero, you never talk to me either.
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
Back to top |
|
 |
|