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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.