[Question] How use the crawldir function?
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
[Question] How use the crawldir function?
Hi,
I created a download page and for it I began in using this [url=http://fail.infinityhouse.org/pastebin.php?mode=view&s=5]function[/url]. But I don't understand his functionning.
A little help is welcome. Thanks per advance.
See you soon,
I created a download page and for it I began in using this [url=http://fail.infinityhouse.org/pastebin.php?mode=view&s=5]function[/url]. But I don't understand his functionning.
A little help is welcome. Thanks per advance.
See you soon,
Last edited by Dakin Quelia on 02 Nov 2009, 22:07, edited 1 time in total.
Re: [Question] How use the crawldir function?
To start, I'd recommend you read this topic a little bit. You'll see some things in there pertaining to crawldir.
http://phpbbmodders.net/board/viewtopic.php?f=55&t=2977&start=15
Also, that copy of crawldir in my pastebin is a bit old, there's another copy here that is updated and fixes an issue or two.
http://code.assembla.com/phpbb-xerxes/subversion/nodes/trunk/root/includes/crs/extension/extension_crawldir.php#ln43
Also, if you want to see an example of how crawldir is used within a working MOD, I'd recommend you tear [url=http://phpbbmodders.net/board/viewtopic.php?f=37&t=3128]this MOD[/url] apart.
http://phpbbmodders.net/board/viewtopic.php?f=55&t=2977&start=15
Also, that copy of crawldir in my pastebin is a bit old, there's another copy here that is updated and fixes an issue or two.
http://code.assembla.com/phpbb-xerxes/subversion/nodes/trunk/root/includes/crs/extension/extension_crawldir.php#ln43
Also, if you want to see an example of how crawldir is used within a working MOD, I'd recommend you tear [url=http://phpbbmodders.net/board/viewtopic.php?f=37&t=3128]this MOD[/url] apart.
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
I go to read this topic.
For the mod, I saw but my main goal is make a simple downloa page.
Thank you.
For the mod, I saw but my main goal is make a simple downloa page.
Thank you.
Re: [Question] How use the crawldir function?
What is it that you don't understand, specifically?
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
I took this [url=http://phpbbmodders.net/board/viewtopic.php?p=18076#p18076]code[/url].
I have some difficulties with that. I tested in download page, the function: crawldir('downloads'); but it doesn't work.
I'd also like to add a specific icon by extension and sort by dir before files.
My old code is (before changes):
But I prefer a code phpBB.
I have some difficulties with that. I tested in download page, the function: crawldir('downloads'); but it doesn't work.
I'd also like to add a specific icon by extension and sort by dir before files.
My old code is (before changes):
Code: Select all
$dirname = 'downloads';
$files = scandir($dirname);
foreach ($files as $file)
{
if ($file != '.' && $file != '..')
{
// Traitement si c'est un dossier
if (is_dir($dirname . '/' . $file))
{
$image = './theme/images/dir.gif';
$filename = $file;
$download = $dirname . '/' . $file;
}
else
{
$ext = strtolower(array_pop(explode('.', $file)));
// Traitement pour les fichiers TXT
if ($ext == 'txt')
{
$image = './theme/images/txt.gif';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers PDF
elseif ($ext == 'pdf')
{
$image = './theme/images/pdf.gif';
$filename = $file;
$filedate = date("F d Y H:i:s.", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers ZIP
elseif ($ext == 'zip')
{
$image = './theme/images/zip.gif';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers PHP
elseif ($ext == 'php')
{
$image = './theme/images/php.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers EXCEL
elseif ($ext == 'xls')
{
$image = './theme/images/excel.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers POWER POINT
elseif ($ext == 'ppt')
{
$image = './theme/images/powerpoint.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
}
}
else
{
$image = './theme/images/dir.gif';
}
// Bloque
$template->assign_block_vars('file', array(
'DESCRIPTION' => $description,
'FILENAME' => $filename,
'FILEDATE' => $filedate,
'FILESIZE' => $filesize,
'DOWNLOAD' => $download,
'FILESIZE' => $filesize,
'IMAGE' => $image,
));
} Â
But I prefer a code phpBB.
Re: [Question] How use the crawldir function?
Okay, can you turn on DEBUG and DEBUG_EXTRA for me please, when you test?
Also, try using this for the crawldir call:
Sorting by dir before files is actually impossible. Files and directories are returned separately, because crawldir is a full scan of a directory and its contents (and contents of subdirectories, and the contents of the directories in the subdirectories, etc.)
It's hard to explain, it makes more sense when you're looking at some example results.
With that function call above, put these line after it. I'd like to see the page output if you'd be so kind.
Also, try using this for the crawldir call:
Code: Select all
$results = crawldir('./downloads'); Â
Sorting by dir before files is actually impossible. Files and directories are returned separately, because crawldir is a full scan of a directory and its contents (and contents of subdirectories, and the contents of the directories in the subdirectories, etc.)
It's hard to explain, it makes more sense when you're looking at some example results.
With that function call above, put these line after it. I'd like to see the page output if you'd be so kind.
Code: Select all
echo '<pre>';
var_dump($results);
exit_handler('</pre'); Â
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
Obsidian wrote:Okay, can you turn on DEBUG and DEBUG_EXTRA for me please, when you test?
Also, try using this for the crawldir call:Code: Select all
$results = crawldir('./downloads'); Â
With that function call above, put these line after it.Code: Select all
echo '<pre>';
var_dump($results);
exit_handler('</pre'); Â
I tested and I get that.
Code: Select all
array(3) {
["dirs"]=>
array(2) {
[0]=>
string(11) "./downloads"
[1]=>
string(16) "./downloads/test"
}
["files"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(34) "./downloads/phpbb-astuces-mods.txt"
[1]=>
string(21) "./downloads/video.php"
}
}
["subdirs"]=>
array(1) {
[0]=>
array(1) {
[0]=>
string(16) "./downloads/test"
}
}
}
Obsidian wrote:With that function call above, put these line after it. I'd like to see the page output if you'd be so kind.
Is it the php page or the template page?
Re: [Question] How use the crawldir function?
PHP page. This will output what crawldir returns..
Also, that is the old crawldir you are using, I can tell by the results. There was a bug that was fixed with the 1.4.0 release of crawldir, for relative results.
I recommend updating the copy of crawldir that you have to the one that I linked earlier, to avoid the bug from cropping up in your site.
Also, that is the old crawldir you are using, I can tell by the results. There was a bug that was fixed with the 1.4.0 release of crawldir, for relative results.
I recommend updating the copy of crawldir that you have to the one that I linked earlier, to avoid the bug from cropping up in your site.
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
Here are my [url=http://www.megaupload.com/?d=670J5J28]download page[/url].
I replaced the previous function by the function upddated.
I get this error:
I replaced the previous function by the function upddated.
I get this error:
Code: Select all
Fatal error: Default value for parameters with array type hint can only be an array or NULL in C:\Users\Daniel Chals�che\Documents\phpBBPortable\App\phpbb\includes\functions_global.php on line 62
Re: [Question] How use the crawldir function?
Ah, crap.
For the crawldir call, use this:
For the crawldir call, use this:
Code: Select all
$results = crawldir('./downloads', NULL, NULL);
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
I tested but it doesn't work. It displays the same message.
Re: [Question] How use the crawldir function?
Odd.
Try this for the downloads file.
Try this for the downloads file.
Code: Select all
<?php
/**
*
* @author Daniel Chalsèche (Dakin Quelia) http://www.danielchalseche.be/
* @author Mickael Carlavan (Mika)
* @autho Ani'
*
* @package Downloads
* @version $Id: post.php 2009-08-12 02:31:25 Dakin Quelia $
* @copyright (c) 2009 Daniel Chalsèche
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('IN_SITE', true);
define('SITE_ROOT', './');
define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(SITE_ROOT . 'common.' . PHP_EXT);
include(SITE_ROOT . 'includes/functions_global.' . PHP_EXT);
include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT);
// Lance les sessions
$user->session_begin();
$auth->acl($user->data);
$user->setup('downloads');
/*$dirname = 'downloads';
$files = scandir($dirname);
foreach ($files as $file)
{
if ($file != '.' && $file != '..')
{
// Traitement si c'est un dossier
if (is_dir($dirname . '/' . $file))
{
$image = './theme/images/dir.gif';
$filename = $file;
$download = $dirname . '/' . $file;
}
else
{
$ext = strtolower(array_pop(explode('.', $file)));
// Traitement pour les fichiers TXT
if ($ext == 'txt')
{
$image = './theme/images/txt.gif';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers PDF
elseif ($ext == 'pdf')
{
$image = './theme/images/pdf.gif';
$filename = $file;
$filedate = date("F d Y H:i:s.", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers ZIP
elseif ($ext == 'zip')
{
$image = './theme/images/zip.gif';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers PHP
elseif ($ext == 'php')
{
$image = './theme/images/php.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers EXCEL
elseif ($ext == 'xls')
{
$image = './theme/images/excel.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
// Traitement pour les fichiers POWER POINT
elseif ($ext == 'ppt')
{
$image = './theme/images/powerpoint.png';
$filename = $file;
$filedate = date("d/m/Y h:m:s", filemtime($dirname . '/' . $file));
$filesize = filesize($dirname . '/' . $file);
$download = $dirname . '/' . $file;
}
}
}
else
{
$image = './theme/images/dir.gif';
}
// Bloque
$template->assign_block_vars('file', array(
'DESCRIPTION' => $description,
'FILENAME' => $filename,
'FILEDATE' => $filedate,
'FILESIZE' => $filesize,
'DOWNLOAD' => $download,
'FILESIZE' => $filesize,
'IMAGE' => $image,
));
}*/
$results = crawldir(SITE_ROOT . 'downloads', NULL, NULL);
echo '<pre>';
var_dump($results);
exit_handler('</pre');
die();
// Here we will actually process the crawldir results, but meh. Need to get this working first.
// Titre de la page
$site->page_header($user->lang['DOWNLOAD_PAGE']);
$template->assign_vars(array(
'TEST' => 'test',
));
$template->set_filenames(array(
'body' => 'download_body.html',
));
$site->page_footer();
?>
-
- New member
- Posts: 49
- Joined: 12 Nov 2008, 01:26
- Real name: Daniel
- Location: Belgique
Re: [Question] How use the crawldir function?
I'm sorry to disturb you but it doesn't always work.
Re: [Question] How use the crawldir function?
No problem. Uhm, there's a copy of a working crawldir over here, http://code.assembla.com/phpbb-xerxes/s ... .php#ln164
1.4.2 was problematic as I was attempting it to be PHP5 compatible only, iirc. This one, 1.4.1, has been field tested and should work.
1.4.2 was problematic as I was attempting it to be PHP5 compatible only, iirc. This one, 1.4.1, has been field tested and should work.