In general, such a problem: this script does not work for VDS

define("H", $_SERVER["DOCUMENT_ROOT"].'/'); $opdirbase=opendir(H.'system/functions'); while ($filebase=readdir($opdirbase)) { if (eregi('\.php$',$filebase)) { require_once(H.'system/functions/'.$filebase); } } 

Is it possible to replace opendir, readdir? Or what needs to be done to make it work?

    1 answer 1

     $d = dir('system/functions'); while (false !== ($filebase = $d->read())) { if ($filebase!== '.' || $filebase!== '..'){ // чего-то делаем } } $d->close(); 

    Did you even understand why your option does not work? Some kind of error knocks? Maybe just the rights to the directory need to be set appropriate?


    Make a simple check and see if all the file paths are correct:

     define("H", $_SERVER["DOCUMENT_ROOT"].'/'); function get_files($path, $mask = '*'){ $sdir = array(); // получим все файлы из дирректории if (false !== ($files = scandir($path))){ foreach ($files as $i => $entry){ // если имя файла подходит под маску поика if ($entry != '.' && $entry != '..' && fnmatch($mask, $entry)){ $sdir[] = $path.'/'.$entry; } } } return ($sdir); } var_dump( get_files(H.'system/functions', '*.php') ); 
    • Here is the error in the log file - [06-Aug-2012 13:03:53] PHP Warning: opendir (/ home / vekto665 / public_html / system / functions) [<a href='function.opendir'> function.opendir < / a>]: failed to open dir: No such file or directory in /home/vekto665/public_html/portal/system/functions.php on line 3 And also the information was stored in the database - $ name = htmlspecialchars (trim ($ _ POST ['name'])); - for some reason it is not processed. - vitagame
    • one
      So you have a problem not in the script, but in the wrong ways. > No such file or directory This indicates that the path or file you specified was not found. And most likely, the "legs" of the problem grow from here: define ("H", $ _SERVER ["DOCUMENT_ROOT"]. '/'); Write simply: define ("H", "" ); - Deonis
    • I tried: [06-Aug-2012 15:21:58] PHP Warning: opendir ( ) [<a href='function.opendir'> function.opendir </a>]: failed to open dir: not implemented in /home/vekto665/public_html/portal/system/functions.php on line 4 [06-Aug-2012 15:21:58] PHP Warning: readdir (): resource in /home/vekto665/public_html/portal/system/functions.php on line 5 Not working. I need to do the loading of functions from the folder. Each function is in a separate file. - vitagame
    • > I need to do the loading of functions from the folder. Here bye ... And why are you just not to connect these files? include ('my_file.php'); - Deonis
    • Better require Connect a dozen files is not a problem. But now another question: why aren't post requests processed? Maybe the Apache is buggy? - vitagame