php Related question.

Here non-phpBB topics can be discussed.
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
nads
New member
New member
Posts: 17
Joined: 15 Sep 2006, 16:27
Contact:

php Related question.

Postby nads » 15 Sep 2006, 16:37


nads
New member
New member
Posts: 17
Joined: 15 Sep 2006, 16:27
Contact:

Postby nads » 15 Sep 2006, 18:18

Right guys... ive managed to get a working script....

[php]<?

//define the path as relative
$path = "/home/codanc/public_html/images/thedir";

//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");

echo "Directory Listing of $path<br/><br/>";

//running the while loop
while ($file = readdir($dir_handle))
{
echo "[img]http://www.yourweb.co.uk/images/thedir/";
echo "$file";
echo "[/img]<br/><br/>";
}

//closing the directory
closedir($dir_handle);

?> [/php]

Now this is really simple and everytime I upload a new folder full of images I have to login to my ftp and change the code around...

Would it be possible to make it so that when I run it... it shows a text box... then all i do is enter the path to the directory I want the output to be for??

Thanks again :)
Last edited by nads on 18 Sep 2006, 13:41, edited 1 time in total.

User avatar
Noobarmy
Past Contributor
Past Contributor
Posts: 545
Joined: 02 Jun 2006, 11:19
Real name: Anthony Chu
Location: UK
Contact:

Postby Noobarmy » 16 Sep 2006, 04:58


User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Postby igorw » 16 Sep 2006, 11:30

Looks fine ;) FYI, you can also use [php] tags ;)

- we're poor!

nads
New member
New member
Posts: 17
Joined: 15 Sep 2006, 16:27
Contact:

Postby nads » 18 Sep 2006, 13:40


User avatar
Noobarmy
Past Contributor
Past Contributor
Posts: 545
Joined: 02 Jun 2006, 11:19
Real name: Anthony Chu
Location: UK
Contact:

Postby Noobarmy » 18 Sep 2006, 14:29

ok you were suppose to run those commands as you would for installing a mod.

So you FIND:$path = "/home/codanc/public_html/images"; replacing it with:$path = $_GET['PATH'];

ect...

nads
New member
New member
Posts: 17
Joined: 15 Sep 2006, 16:27
Contact:

Postby nads » 18 Sep 2006, 15:48

Feel free to call me retarded... but that post makes no sense to me.

What exactly are you saying I need to do. :)

User avatar
Noobarmy
Past Contributor
Past Contributor
Posts: 545
Joined: 02 Jun 2006, 11:19
Real name: Anthony Chu
Location: UK
Contact:

Postby Noobarmy » 18 Sep 2006, 16:51

Ok screw it i'll just tell you what to make it :P

Replace your file with the following:

[php]<?

//define the path as relative
$path = $_GET['PATH'];

//using the opendir function
if ($path != '')
{
$dir_handle = @opendir($path) or die("Unable to open $path");

echo "Directory Listing of $path<br/><br/>";

//running the while loop
while ($file = readdir($dir_handle))
{
echo "[img]" . $path;
echo "$file";
echo "[/img]<br/><br/>";
}

//closing the directory
closedir($dir_handle);
}
else
{
$file = basename(__FILE__);
echo '<html><head></head><body><form action="' . $file . '" method="GET"><input type="text" value="" name="PATH" /></form></body></html>';
}

?>[/php]

nads
New member
New member
Posts: 17
Joined: 15 Sep 2006, 16:27
Contact:

Postby nads » 19 Sep 2006, 23:42

you, sir .... are awesome!!

thanks very much.


[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests