Jump to content

Having a little trouble.


Domcsore

Recommended Posts

What I am trying to do is include all file in a folder. This works fine, however, it also tries to include a whole load of other folder? and I cant stop it.

 

Basically here it is:

 

public function engineload(){
	if ($handle = opendir('classes/subclasses')) {
    		while (false !== ($file = readdir($handle))) {
			include('classes/subclasses/'.$file);
    		}
    	}

    	closedir($handle);
}	

 

**EDIT** Sorry, I fixed this.:

public function engineload(){
	if ($handle = opendir('classes/subclasses')) {
    		while (false !== ($file = readdir($handle))) {
			if($file == "."){
				return false;
			}elseif($file == ".."){
				return false;
			}else{
				include('classes/subclasses/'.$file);
			}
    		}
    	}

    	closedir($handle);
}		

 

 

Link to comment
https://forums.phpfreaks.com/topic/196245-having-a-little-trouble/
Share on other sites

Just remeber to look into the PHP include vulnerability.  Make sure the variable is not accessible through your _GET and _POST globals otherwise someone could include malicious code on your site.

http://en.wikipedia.org/wiki/Include_vulnerability

 

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.