StavBN Posted May 3, 2010 Share Posted May 3, 2010 Hey my PHP code is: <?php require_once("class.get.files.php"); $ext = array("html"); $folder = "/"; $files = new getfiles($folder,$ext); $list = $files->getlist(); header("Content-Type: text/plain"); print "<?xml version=\"1.0\" ?>\n"; print "<images>\n"; for ($i = 0; $i< count($list); $i++) { print "\t<image filename=\"$list[$i]\" />\n"; } print "</images>"; ?> When running it I get: (http://the-memorables.com/getimages.php) "Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/sivn/:/tmp:/var/tmp:/usr/local/lib/php/) in /home/sivn/domains/the-memorables.com/public_html/class.get.files.php on line 23" The PHP is using another PHP to create a XML file. The problem is with the second PHP and the line: if(!is_dir($dir)) What can I do? what is the problem? Why the PHP can't access the local directory he inside? I am new to PHP and I only need it to complete Action Script code I am working on. Please help me, Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/ Share on other sites More sharing options...
Muddy_Funster Posted May 3, 2010 Share Posted May 3, 2010 Posting the php file that actualy has the error in it would be a great help. Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/#findComment-1052623 Share on other sites More sharing options...
StavBN Posted May 3, 2010 Author Share Posted May 3, 2010 <? // --------------------------------------------------------------------------- // Get Files In Folders and SubFolder by Juliano Carlos da Silva <[email protected]> // Copyright © 2004 Skull // Date: 2004-02-03 // --------------------------------------------------------------------------- class getfiles { function getfiles($dir,$ext) { $this->_fileList = array(); #aqui ele vai guardar todos os nomes dos arquivos $this->_fileListPath = array(); #aqui ele vai guardar todos os nomes dos arquivos com o caminho $this->returnPath = false; #se eh para retornar com ou caminho ou sem $this->_noList[] = array(); #arquivos que foram desconsiderados $this->_allFiles[] = array(); #todos os arquivos encontrados $this->_folders[] = array(); #mostra todas as pastas $this->_foldersPath[] = array(); #mostra todas as pastas com o caminho $this->recursive = true; #se vai mostrar os subdiretorios #verificar se o diretorio existe e se eh um diretorio $dir = str_replace("\\","/",$dir); if(!is_dir($dir)) { echo "<BR><B>ERROR $dir!</b><BR>"; exit; } else #se for um diretorio ja guarda os diretorios visitados { $this->_foldersPath[] = $dir; $this->_dir = $dir; } if(is_array($ext)) #grava as exteחץes dos arquivos para montar a lista $this->_ext = $ext; else $this->_ext = array($ext); $this->getFileList($this->_dir); } #vai montar a lista dos arquivos segundo os filtros acima function getFileList($dir) { $_dir = $dir; $aux = split("/",$dir); $dir = $aux[count($aux)-1]; $this->_folders[] = $dir; $path = str_replace($dir,"",$_dir); $d = dir($path.$dir); while (false !== ($entry = $d->read())) { if( ($entry != ".") && ($entry !="..") ) { if(is_dir($d->path."/".$entry)) { $this->_folders[] = $entry; if($this->recursive) $this->getFileList($path.$dir."/".$entry); } else { if($this->check($entry)) { $this->_fileList[] = $entry; $this->_fileListPath[] = $d->path."/".$entry; } else $this->_noList[] = $entry; $this->_allFiles[] = $entry; } } } $d->close(); } #checa as extenחץes dos arquivos para ver se vai adicionar ou nao function check($file) { foreach($this->_ext as $value) //Colaboracao de nosso amigo Ricardo Reis <[email protected]> { if (strtoupper($this->ext($file)) == strtoupper($value)) return true; } return false; /*foreach($this->_ext as $value) { $ok = 0; $aux = split("[.]",$file); $ext = $aux[1]; if(strtoupper($ext) == strtoupper($value)) return true; } return false;*/ } function ext($file) //Colaboracao de nosso amigo Ricardo Reis <[email protected]> { return array_pop(explode('.', basename($file))); } // end.ext(); #verifica se vai trazer o arquivo com o caminho ou nao function path($bool) { if(is_bool($bool)) $this->returnPath = $bool; else echo "Este valor de ser TRUE ou FALSE"; } #retorna a lista em array com ou sem o caminho function getList() { if($this->returnPath) return $this->_fileListPath; else return $this->_fileList; } #retorna apenas os nomes dos arquivos function getNameFiles() { return $this->_fileList; } #retorna os nomes dos arquivos com o caminho function getFilesPath() { return $this->_fileListPath; } #retorna apenas os nomes dos arquivos que estao no diretorio mas nao foram usado function getNoFiles() { return $this->_NoList; } #retorna todos os nomes dos arquivos function getAllFiles() { return $this->_allFiles; } #retorna todas as pastas function getFolders() { return $this->_folders; } #retorna todas as pastas com o caminho function getFolderPath() { return $this->_foldersPath; } } ?> I hope it will help you to help me Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/#findComment-1052632 Share on other sites More sharing options...
PFMaBiSmAd Posted May 3, 2010 Share Posted May 3, 2010 File(/) is not within the allowed path(s): $folder = "/"; A leading slash refers to the root of the current hard disk. I suspect that you want a ./ or even just a . Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/#findComment-1052636 Share on other sites More sharing options...
StavBN Posted May 3, 2010 Author Share Posted May 3, 2010 Thank you. I changed it to ./ And now I am getting: <?xml version="1.0" ?> <images> <image filename="corners_left.png" /> <image filename="corners_right.png" /> <image filename="corners_left.png" /> <image filename="corners_right.png" /> <image filename="created_by.png" /> <image filename="created_by.png" /> <image filename="no_image.png" /> <image filename="BG.png" /> </images> But the problem is that I got only "BG.png" file in that folder, and not all the others. Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/#findComment-1052643 Share on other sites More sharing options...
StavBN Posted May 3, 2010 Author Share Posted May 3, 2010 Well I changed "recursive" to false. Much thanks PFMaBiSmAd, you realy helped me. Quote Link to comment https://forums.phpfreaks.com/topic/200594-php-cant-access-the-directory-he-in/#findComment-1052663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.