Jump to content

[SOLVED] readdir/closedir warning.


Bramme

Recommended Posts

Could anybody tell me why this code isn't working:

 

<?php
//admin/index.php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

require(ROOT.'/libs/Modular.class.php');
$core = new Modular();
$core->template_dir = ROOT.'/admin/templates';
$core->compile_dir = ROOT.'/admin/templates_c';


$uModules = array();
if ($handle = opendir(ROOT.'/admin/mods/') || die("Could not open Modules directory")) {
		while ($file = readdir($handle) !== false) {
			if($file != "." && $file != ".." && !is_dir(ROOT.'/admin/mods/'.$file)) {

				$Module = fopen(ROOT.'/admin/mods/'.$file, 'r');
				$modContent = fread($Module, 26);
				fclose($Module);


				$uModules[] = $file;
			}
		}
		closedir($handle);
	}
$core->assign('uModules', $uModules);

$core->display('index.tpl');
?>

I get two warnings:

Warning: readdir(): supplied argument is not a valid Directory resource in /path/index.php on line 14

Warning: closedir(): supplied argument is not a valid Directory resource in /path/index.php on line 25

 

Line 14 and 25 being the only ones with readdir and closedir in them...

Link to comment
https://forums.phpfreaks.com/topic/79544-solved-readdirclosedir-warning/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.