MyBB Community Forums

Full Version: List files in directory outside forum folder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi again,

I have installed MyBB forum on www.mysite.com/forum
I also have some other scripts uploaded onto www.mysite.com/scripts

/scripts contains a /tmp folder for storing data generated by those scripts www.mysite.com/scripts/tmp

I want to analyze that data from within my AdminCP for MyBB because I already spent much time there. Already added a custom module for Data Analysis into AdminCP, thanks to RateU.

Now, stuck with one problem, that is:
I want to display directory listing of www.mysite.com/scripts/tmp from within my custom module (www.mysite.net/forum/admin/modules/data_analysis). There are no sub directories inside /tmp, just text files containing data.


Thnx in advance.
Maybe something like this:
$dir = '../../scripts/tmp';
$d = opendir($dir);
while($file = @readdir($d)){
	$fpath = $dir.'/'.$file;
	if(is_file($fpath) && get_extension($file) == 'txt') $files[] = $file;
}
@closedir($d);
if(is_array($files)){
	natcasesort($files);
	reset($files);
	$i = 0;
	$table = new Table;
	$table->construct_header('#',array('width'=>'5%','class'=>'align_center'));
	$table->construct_header('Files');
	$table->construct_header($lang->controls,array('class'=>'align_center','width'=>'20%'));
	foreach($files as $file){
		++$i;
		$table->construct_cell($i,array('class'=>'align_center'));
		$table->construct_cell(htmlspecialchars_uni($file));
		$popup = new PopupMenu('f_'.$i,$lang->options);
		$popup->add_item('Action 1','');
		$popup->add_item('Action 2','');
		$table->construct_cell($popup->fetch(),array('class'=>'align_center'));
		$table->construct_row();
	}
	$table->output('My Files');
}
That was amazing. Thank you so much once again.