diff --git a/build/libifm.php b/build/libifm.php index 303daa5..6f717e6 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -19,7 +19,7 @@ class IFM { private $defaultconfig = array( // general config - "auth" => 0, + "auth" => 1, "auth_source" => 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC', "root_dir" => "", "tmp_dir" => "", @@ -52,36 +52,400 @@ class IFM { ); private $config = array(); + private $templates = array(); public $mode = ""; public function __construct( $config=array() ) { if( session_status() !== PHP_SESSION_ACTIVE ) session_start(); $this->config = array_merge( $this->defaultconfig, $config ); + + $templates = array(); + $templates['app'] = <<<'f00bar' + +
+ + + + + {{#config.download}} + + {{/config.download}} + {{#config.showlastmodified}} + + {{/config.showlastmodified}} + {{#config.showfilesize}} + + {{/config.showfilesize}} + {{#config.showpermissions}} + + {{/config.showpermissions}} + {{#config.showowner}} + + {{/config.showowner}} + {{#config.showgroup}} + + {{/config.showgroup}} + + + + + +
Filenamelast modifiedsize
+
+
+ +
+ +f00bar; + $templates['login'] = <<<'f00bar' + + +
+
+ + {{error}} + + + + + +
+
+ +f00bar; + $templates['filetable'] = <<<'f00bar' + +{{#items}} + + + + + {{linkname}} + + + {{#config.download}} + +
+ + + +
+ + + + + {{/config.download}} + {{#config.showlastmodified}} + {{lastmodified}} + {{/config.showlastmodified}} + {{#config.showfilesize}} + {{size}} + {{/config.showfilesize}} + {{#config.showpermissions}} + + + + {{/config.showpermissions}} + {{#config.showowner}} + + {{owner}} + + {{/config.showowner}} + {{#config.showgroup}} + + {{group}} + + {{/config.showgroup}} + + {{#button}} + + + + {{/button}} + + +{{/items}} + + +f00bar; + $templates['ajaxrequest'] = <<<'f00bar' +
+
+ +f00bar; + $templates['copymove'] = <<<'f00bar' +
+
+ + +
+
+ +f00bar; + $templates['createdir'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['deletefile'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['extractfile'] = <<<'f00bar' +
+
+ + +
+
+ +f00bar; + $templates['file'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['multidelete'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['remoteupload'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['renamefile'] = <<<'f00bar' + + +f00bar; + $templates['uploadfile'] = <<<'f00bar' +
+ + +
+ +f00bar; + $this->templates = $templates; } /** * This function contains the client-side application */ public function getApplication() { - print ' - - - IFM - improved file manager - - - '; - $this->getCSS(); - print ' - - -
'; + $this->getHTMLHeader(); + print '
'; $this->getJS(); - print ' - - - - '; + print ''; + $this->getHTMLFooter(); } public function getInlineApplication() { @@ -100,16 +464,16 @@ class IFM { /*# sourceMappingURL=bootstrap.min.css.map */ - - -

IFM - Login

-
'; - if($loginFailed){ print '
Login attempt failed. Please try again.
'; } - print '
-
- -
- - '; + $err = ""; + if( $loginFailed ) + $err = '
Login failed.
'; + $this->getHTMLHeader(); + print str_replace( "{{error}}", $err, $this->templates['login'] ); + $this->getHTMLFooter(); } private function filePermsDecode( $perms ) { @@ -2412,324 +2782,6 @@ function IFM( params ) { fclose($stdout_stream); } - private function getTemplates() { - $templates = array(); - $templates['app'] = <<<'f00bar' - -
- - - - - {{#config.download}} - - {{/config.download}} - {{#config.showlastmodified}} - - {{/config.showlastmodified}} - {{#config.showfilesize}} - - {{/config.showfilesize}} - {{#config.showpermissions}} - - {{/config.showpermissions}} - {{#config.showowner}} - - {{/config.showowner}} - {{#config.showgroup}} - - {{/config.showgroup}} - - - - - -
Filenamelast modifiedsize
-
-
- -
- -f00bar; - $templates['filetable'] = <<<'f00bar' - -{{#items}} - - - - - {{linkname}} - - - {{#config.download}} - -
- - - -
- - - - - {{/config.download}} - {{#config.showlastmodified}} - {{lastmodified}} - {{/config.showlastmodified}} - {{#config.showfilesize}} - {{size}} - {{/config.showfilesize}} - {{#config.showpermissions}} - - - - {{/config.showpermissions}} - {{#config.showowner}} - - {{owner}} - - {{/config.showowner}} - {{#config.showgroup}} - - {{group}} - - {{/config.showgroup}} - - {{#button}} - - - - {{/button}} - - -{{/items}} - - -f00bar; - $templates['ajaxrequest'] = <<<'f00bar' -
-
- -f00bar; - $templates['copymove'] = <<<'f00bar' -
-
- - -
-
- -f00bar; - $templates['createdir'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['deletefile'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['extractfile'] = <<<'f00bar' -
-
- - -
-
- -f00bar; - $templates['file'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['multidelete'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['remoteupload'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['renamefile'] = <<<'f00bar' - - -f00bar; - $templates['uploadfile'] = <<<'f00bar' -
- - -
- -f00bar; - - return $templates; - } } /* ======================================================================= diff --git a/ifm.php b/ifm.php index 7bf8061..d3e9451 100644 --- a/ifm.php +++ b/ifm.php @@ -19,7 +19,7 @@ class IFM { private $defaultconfig = array( // general config - "auth" => 0, + "auth" => 1, "auth_source" => 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC', "root_dir" => "", "tmp_dir" => "", @@ -52,36 +52,400 @@ class IFM { ); private $config = array(); + private $templates = array(); public $mode = ""; public function __construct( $config=array() ) { if( session_status() !== PHP_SESSION_ACTIVE ) session_start(); $this->config = array_merge( $this->defaultconfig, $config ); + + $templates = array(); + $templates['app'] = <<<'f00bar' + +
+ + + + + {{#config.download}} + + {{/config.download}} + {{#config.showlastmodified}} + + {{/config.showlastmodified}} + {{#config.showfilesize}} + + {{/config.showfilesize}} + {{#config.showpermissions}} + + {{/config.showpermissions}} + {{#config.showowner}} + + {{/config.showowner}} + {{#config.showgroup}} + + {{/config.showgroup}} + + + + + +
Filenamelast modifiedsize
+
+
+ +
+ +f00bar; + $templates['login'] = <<<'f00bar' + + +
+
+ + {{error}} + + + + + +
+
+ +f00bar; + $templates['filetable'] = <<<'f00bar' + +{{#items}} + + + + + {{linkname}} + + + {{#config.download}} + +
+ + + +
+ + + + + {{/config.download}} + {{#config.showlastmodified}} + {{lastmodified}} + {{/config.showlastmodified}} + {{#config.showfilesize}} + {{size}} + {{/config.showfilesize}} + {{#config.showpermissions}} + + + + {{/config.showpermissions}} + {{#config.showowner}} + + {{owner}} + + {{/config.showowner}} + {{#config.showgroup}} + + {{group}} + + {{/config.showgroup}} + + {{#button}} + + + + {{/button}} + + +{{/items}} + + +f00bar; + $templates['ajaxrequest'] = <<<'f00bar' +
+
+ +f00bar; + $templates['copymove'] = <<<'f00bar' +
+
+ + +
+
+ +f00bar; + $templates['createdir'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['deletefile'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['extractfile'] = <<<'f00bar' +
+
+ + +
+
+ +f00bar; + $templates['file'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['multidelete'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['remoteupload'] = <<<'f00bar' +
+ + +
+ +f00bar; + $templates['renamefile'] = <<<'f00bar' + + +f00bar; + $templates['uploadfile'] = <<<'f00bar' +
+ + +
+ +f00bar; + $this->templates = $templates; } /** * This function contains the client-side application */ public function getApplication() { - print ' - - - IFM - improved file manager - - - '; - $this->getCSS(); - print ' - - -
'; + $this->getHTMLHeader(); + print '
'; $this->getJS(); - print ' - - - - '; + print ''; + $this->getHTMLFooter(); } public function getInlineApplication() { @@ -100,16 +464,16 @@ class IFM { /*# sourceMappingURL=bootstrap.min.css.map */ - - -

IFM - Login

-
'; - if($loginFailed){ print '
Login attempt failed. Please try again.
'; } - print '
-
- -
- - '; + $err = ""; + if( $loginFailed ) + $err = '
Login failed.
'; + $this->getHTMLHeader(); + print str_replace( "{{error}}", $err, $this->templates['login'] ); + $this->getHTMLFooter(); } private function filePermsDecode( $perms ) { @@ -2412,324 +2782,6 @@ function IFM( params ) { fclose($stdout_stream); } - private function getTemplates() { - $templates = array(); - $templates['app'] = <<<'f00bar' - -
- - - - - {{#config.download}} - - {{/config.download}} - {{#config.showlastmodified}} - - {{/config.showlastmodified}} - {{#config.showfilesize}} - - {{/config.showfilesize}} - {{#config.showpermissions}} - - {{/config.showpermissions}} - {{#config.showowner}} - - {{/config.showowner}} - {{#config.showgroup}} - - {{/config.showgroup}} - - - - - -
Filenamelast modifiedsize
-
-
- -
- -f00bar; - $templates['filetable'] = <<<'f00bar' - -{{#items}} - - - - - {{linkname}} - - - {{#config.download}} - -
- - - -
- - - - - {{/config.download}} - {{#config.showlastmodified}} - {{lastmodified}} - {{/config.showlastmodified}} - {{#config.showfilesize}} - {{size}} - {{/config.showfilesize}} - {{#config.showpermissions}} - - - - {{/config.showpermissions}} - {{#config.showowner}} - - {{owner}} - - {{/config.showowner}} - {{#config.showgroup}} - - {{group}} - - {{/config.showgroup}} - - {{#button}} - - - - {{/button}} - - -{{/items}} - - -f00bar; - $templates['ajaxrequest'] = <<<'f00bar' -
-
- -f00bar; - $templates['copymove'] = <<<'f00bar' -
-
- - -
-
- -f00bar; - $templates['createdir'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['deletefile'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['extractfile'] = <<<'f00bar' -
-
- - -
-
- -f00bar; - $templates['file'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['multidelete'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['remoteupload'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['renamefile'] = <<<'f00bar' - - -f00bar; - $templates['uploadfile'] = <<<'f00bar' -
- - -
- -f00bar; - - return $templates; - } } /* ======================================================================= diff --git a/src/main.php b/src/main.php index f8b7f9f..e54c63a 100644 --- a/src/main.php +++ b/src/main.php @@ -19,7 +19,7 @@ class IFM { private $defaultconfig = array( // general config - "auth" => 0, + "auth" => 1, "auth_source" => 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC', "root_dir" => "", "tmp_dir" => "", @@ -52,36 +52,66 @@ class IFM { ); private $config = array(); + private $templates = array(); public $mode = ""; public function __construct( $config=array() ) { if( session_status() !== PHP_SESSION_ACTIVE ) session_start(); $this->config = array_merge( $this->defaultconfig, $config ); + + $templates = array(); + $templates['app'] = <<<'f00bar' +@@@src/templates/app.html@@@ +f00bar; + $templates['login'] = <<<'f00bar' +@@@src/templates/login.html@@@ +f00bar; + $templates['filetable'] = <<<'f00bar' +@@@src/templates/filetable.html@@@ +f00bar; + $templates['ajaxrequest'] = <<<'f00bar' +@@@src/templates/modal.ajaxrequest.html@@@ +f00bar; + $templates['copymove'] = <<<'f00bar' +@@@src/templates/modal.copymove.html@@@ +f00bar; + $templates['createdir'] = <<<'f00bar' +@@@src/templates/modal.createdir.html@@@ +f00bar; + $templates['deletefile'] = <<<'f00bar' +@@@src/templates/modal.deletefile.html@@@ +f00bar; + $templates['extractfile'] = <<<'f00bar' +@@@src/templates/modal.extractfile.html@@@ +f00bar; + $templates['file'] = <<<'f00bar' +@@@src/templates/modal.file.html@@@ +f00bar; + $templates['multidelete'] = <<<'f00bar' +@@@src/templates/modal.multidelete.html@@@ +f00bar; + $templates['remoteupload'] = <<<'f00bar' +@@@src/templates/modal.remoteupload.html@@@ +f00bar; + $templates['renamefile'] = <<<'f00bar' +@@@src/templates/modal.renamefile.html@@@ +f00bar; + $templates['uploadfile'] = <<<'f00bar' +@@@src/templates/modal.uploadfile.html@@@ +f00bar; + $this->templates = $templates; } /** * This function contains the client-side application */ public function getApplication() { - print ' - - - IFM - improved file manager - - - '; - $this->getCSS(); - print ' - - -
'; + $this->getHTMLHeader(); + print '
'; $this->getJS(); - print ' - - - - '; + print ''; + $this->getHTMLFooter(); } public function getInlineApplication() { @@ -110,6 +140,22 @@ class IFM { '; } + public function getHTMLHeader() { + print ' + + + IFM - improved file manager + + + '; + $this->getCSS(); + print ''; + } + + public function getHTMLFooter() { + print ''; + } + /* main functions */ @@ -130,7 +176,7 @@ class IFM { elseif( $_REQUEST["api"] == "getConfig" ) { $this->getConfig(); } elseif( $_REQUEST["api"] == "getTemplates" ) { - echo json_encode( $this->getTemplates() ); + echo json_encode( $this->templates ); } elseif( $_REQUEST["api"] == "logout" ) { unset( $_SESSION ); session_destroy(); @@ -732,30 +778,12 @@ class IFM { } private function loginForm($loginFailed=false) { - print ' - - - IFM - improved file manager - - - - -

IFM - Login

-
'; - if($loginFailed){ print '
Login attempt failed. Please try again.
'; } - print '
-
- -
- - '; + $err = ""; + if( $loginFailed ) + $err = '
Login failed.
'; + $this->getHTMLHeader(); + print str_replace( "{{error}}", $err, $this->templates['login'] ); + $this->getHTMLFooter(); } private function filePermsDecode( $perms ) { @@ -965,45 +993,4 @@ class IFM { fclose($stdout_stream); } - private function getTemplates() { - $templates = array(); - $templates['app'] = <<<'f00bar' -@@@src/templates/app.html@@@ -f00bar; - $templates['filetable'] = <<<'f00bar' -@@@src/templates/filetable.html@@@ -f00bar; - $templates['ajaxrequest'] = <<<'f00bar' -@@@src/templates/modal.ajaxrequest.html@@@ -f00bar; - $templates['copymove'] = <<<'f00bar' -@@@src/templates/modal.copymove.html@@@ -f00bar; - $templates['createdir'] = <<<'f00bar' -@@@src/templates/modal.createdir.html@@@ -f00bar; - $templates['deletefile'] = <<<'f00bar' -@@@src/templates/modal.deletefile.html@@@ -f00bar; - $templates['extractfile'] = <<<'f00bar' -@@@src/templates/modal.extractfile.html@@@ -f00bar; - $templates['file'] = <<<'f00bar' -@@@src/templates/modal.file.html@@@ -f00bar; - $templates['multidelete'] = <<<'f00bar' -@@@src/templates/modal.multidelete.html@@@ -f00bar; - $templates['remoteupload'] = <<<'f00bar' -@@@src/templates/modal.remoteupload.html@@@ -f00bar; - $templates['renamefile'] = <<<'f00bar' -@@@src/templates/modal.renamefile.html@@@ -f00bar; - $templates['uploadfile'] = <<<'f00bar' -@@@src/templates/modal.uploadfile.html@@@ -f00bar; - - return $templates; - } } diff --git a/src/templates/app.html b/src/templates/app.html index 3a60080..8fdaee7 100644 --- a/src/templates/app.html +++ b/src/templates/app.html @@ -41,6 +41,9 @@ {{#config.ajaxrequest}}
  • ajax request
  • {{/config.ajaxrequest}} + {{#config.auth}} +
  • logout
  • + {{/config.auth}} diff --git a/src/templates/login.html b/src/templates/login.html new file mode 100644 index 0000000..b1ca338 --- /dev/null +++ b/src/templates/login.html @@ -0,0 +1,54 @@ + + +
    +
    + + {{error}} + + + + + +
    +