public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function FileManager() { if (!FileManager::$instance) { FileManager::$instance = $this; } //initailze site $this->__RootFolder = $this->getCurrentFolder(); //register virtual folders $this->__VirtualFolders = array(); $curDir = $this->getCurrentFolder(); $this->addVirtualFolder($curDir, '$This', 1, 0); $this->addVirtualFolder($curDir . '/file_icons', '$Icons', 1, 0); $ds = $this->getDrives(); if (is_array($ds)) { foreach ($ds as $d) { $this->addVirtualFolder($d['drive'] . '/', '$' . substr($d['drive'], 0, 1), 1, 0); } } usort($this->__VirtualFolders, '_cmpPath'); //register application workspace $_app = ''; $_sid = ''; $b = true; $a = true; if ($b) { if (isset($_GET)) { if (isset($_GET['app'])) { $a = false; $_app = $_GET['app']; } if (isset($_GET['sid'])) { $b = false; $_sid = $_GET['sid']; } } } if (isset($_POST)) { if ($a) { if (isset($_POST['app'])) { $a = false; $_app = $_POST['app']; } } if ($b) { if (isset($_POST['sid'])) { $b = true; $_sid = $_POST['sid']; } } } //register icons $this->__IconExt = array(); $this->registerIconExt('zip', 'rar,gzip'); $this->registerIconExt('txt', 'ini'); $this->registerIconExt('bat', 'php,asp,aspx,cgi'); $this->registerIconExt('doc', 'rtf'); $this->registerIconExt('mp3', 'wav'); $this->registerIconExt('mdb', 'db,db2'); $this->registerIconExt('jpg', 'gif,png,jpeg'); $this->registerIconExt('htm', 'html'); //initialize instance if (FileManager::$instance === $this) { FileManager::$sid = $_sid; FileManager::$ip = $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $_SERVER['REMOTE_HOST']; if (!empty($_app)) { FileManager::$app = $this->deCrypt($_app); } } $this->__Initialized = true; }
/** * getInstance * * if an instance exists, it returns it, * if not, it creates a new one and returns * it * * @access public * @static * @return instance */ public static function getInstance() { if (!self::$instance) { self::$instance = new FileManager(); } return self::$instance; }