Hendlers.php


<?php
//===================================  config.php  ==============================
$accepted_extensions = array("png", "jpg", "gif");  
$base_url ="localhost/111";
$dir_up="";
if(array_key_exists('dir_up', $_GET)){ $dir_up=$_GET['dir_up'];}
if(array_key_exists('dir_up', $_POST)){ $dir_up=$_POST['dir_up'];}
$uploads_dir = $_SERVER['DOCUMENT_ROOT'].$dir_up;
$uploads_access_dir = $_SERVER['DOCUMENT_ROOT'].$dir_up;
$capabilities = array(
    "move" => true,
    "rename" => true,
    "remove" => true,
    "mkdir" => true,
    "upload" => true
);
//===================================  common.php  ==============================
Config::getInstance()->setValidExtensions($accepted_extensions);
Config::getInstance()->setCapabilities($capabilities);
Config::getInstance()->setRootDir($uploads_dir);
Config::getInstance()->setPubDir($uploads_access_dir);
Config::getInstance()->setBaseUrl($base_url);
ResponseRouter::getInstance()->setHandler("404", new Response404());
ResponseRouter::getInstance()->setHandler("401", new Response401());
//====================================  handlers.php  =======================
ResponseRouter::getInstance()->setHandler("auth", new AuthHandler());
ResponseRouter::getInstance()->setHandler("list", new ListHandler());
ResponseRouter::getInstance()->setHandler("rename", new RenameHandler());
ResponseRouter::getInstance()->setHandler("remove", new RemoveHandler());
ResponseRouter::getInstance()->setHandler("mkdir", new MkdirHandler());
ResponseRouter::getInstance()->setHandler("mkFile", new MkFileHandler());
ResponseRouter::getInstance()->setHandler("move", new MoveHandler());
ResponseRouter::getInstance()->setHandler("upload", new UploadHandler());
//====================================  file-manager.php  =======================
ResponseRouter::getInstance()->run();
?>
 
<?php
Class ResponseRouter         //common.php  
    public function run ()     public function run () {
        if (array_key_exists('action', $_GET)) {
            if ($this->handlers[$_GET['action']]){$this->handle($this->handlers[$_GET['action']]);return true;}
                                               }
        else if (array_key_exists('action', $_POST)) {
            if ($this->handlers[$_POST['action']]){$this->handle($this->handlers[$_POST['action']]);return true;            }                                    }
        $this->handle($this->handlers["401"]);     }
?>    
<?php
    private function handle(ResponseHandler $obj) {
        if($obj->getStatusNumber($this) != 200) {
            header($_SERVER["SERVER_PROTOCOL"]." ".$obj->getStatus($this));
 
            // FastCGI, blecch
            header("Status: ".$obj->getStatus($this));
            $_SERVER['REDIRECT_STATUS'] = $obj->getStatusNumber($this);
            // end FastCGI                                                }
        $ret = $obj->getResponse($this);
        if($ret instanceof ResponseHandler) {$this->handle($ret);}
        else {json_response($ret);}                                                  }
        
?>    
        //запрос списка файлов
$.getJSON(self.handler, {"dir": self.curDir, "action": "list", "auth": cfg_fm.passw,"dir_up":cfg_fm.dir_up},...        
        dir -  
        foreach(new DirectoryIterator($router->getConfig()->getRootDir().$dir) as $info) {
        получается вот так.
$uploads_dir = $_SERVER['DOCUMENT_ROOT'].$GET_['dir_up'].$GET_['dir'];
cfg_fm.dir_up="/111/CONT"        
        $_SERVER['DOCUMENT_ROOT']=D:/WWW/ib35
        $_SERVER['DOCUMENT_ROOT'].$GET_['dir_up']=D:/WWW/ib35/111/CONT