diff --git a/ifm.php b/ifm.php index 5291e07..4e6c51b 100644 --- a/ifm.php +++ b/ifm.php @@ -194,16 +194,13 @@ class IFM { "auth" => 0,"auth_source" => 'inlineadmin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC', "root_dir" => "","defaulttimezone" => "Europe/Berlin","tmp_dir" => "","ajaxrequest" => 1 ); - private $config = array(); - public function __construct( $config ) { + private $config = array(); + public $mode = ""; + + public function __construct( $config=array() ) { session_start(); - if( ! is_array( $config ) ) { - trigger_error( "IFM: could not load config" ); - exit( 1 ); - } else { - $this->config = array_merge( $this->defaultconfig, $config ); - } + $this->config = array_merge( $this->defaultconfig, $config ); } /** @@ -216,16 +213,36 @@ class IFM { IFM - improved file manager - - - - - - - -
+ '; + } + + private function getJS() { + print ' - - '; } @@ -1654,7 +1665,7 @@ ifm.init( "ifm" ); $this->getFiles( "" ); } elseif( $_REQUEST["api"] == "getConfig" ) { - echo json_encode( $this->config ); + $this->getConfig(); } elseif( $_REQUEST["api"] == "getTemplates" ) { echo json_encode( $this->getTemplates() ); } else { @@ -1686,17 +1697,20 @@ ifm.init( "ifm" ); } } - public function run() { + public function run( $mode="standalone" ) { if ( $this->checkAuth() ) { // go to our root_dir if( ! is_dir( realpath( $this->config['root_dir'] ) ) || ! is_readable( realpath( $this->config['root_dir'] ) ) ) die( "Cannot access root_dir."); else chdir( realpath( $this->config['root_dir'] ) ); - if ( ! isset($_REQUEST['api']) ) { - $this->getApplication(); - } else { + $this->mode = $mode; + if ( isset($_REQUEST['api']) ) { $this->handleRequest(); + } elseif( $mode == "standalone" ) { + $this->getApplication(); + } else { + $this->getInlineApplication(); } } } @@ -1776,6 +1790,13 @@ ifm.init( "ifm" ); echo json_encode( array_merge( $dirs, $files ) ); } + private function getConfig() { + $ret = $this->config; + $ret['inline'] = ( $this->mode == "inline" ) ? true : false; + $ret['isDocroot'] = ( realpath( IFMConfig::root_dir ) == dirname( __FILE__ ) ) ? "true" : "false"; + echo json_encode( $ret ); + } + private function getFolderTreeRecursive( $start_dir ) { $ret = array(); $start_dir = realpath( $start_dir ); @@ -2472,7 +2493,11 @@ ifm.init( "ifm" ); private function getTemplates() { $templates = array(); $templates['app'] = <<<'f00bar' -