reworked the compiler

This commit is contained in:
Marco Dickert 2017-07-31 11:34:07 +02:00
parent 2d9ceb7f6b
commit 8674dd3d12
4 changed files with 50 additions and 52 deletions

View File

@ -1,5 +1,4 @@
<?php
/* =======================================================================
* Improved File Manager
* ---------------------

View File

@ -8,39 +8,40 @@
chdir( realpath( dirname( __FILE__ ) ) );
$IFM_SRC_MAIN = "src/main.php";
$IFM_SRC_PHPFILES = array( "src/ifmarchive.php", "src/htpasswd.php" );
$IFM_SRC_JS = "src/ifm.js";
$IFM_SRC_PHP = array(
0 => "src/main.php",
1 => "src/ifmarchive.php",
2 => "src/htpasswd.php"
);
$IFM_BUILD_STANDALONE = "ifm.php";
$IFM_BUILD_STANDALONE_COMPRESSED = "ifm.min.php";
$IFM_BUILD_STANDALONE_COMPRESSED = "build/ifm.min.php";
$IFM_BUILD_LIB_PHP = "build/libifm.php";
/**
* Prepare main script
* Concat PHP Files
*/
$main = file_get_contents( $IFM_SRC_MAIN );
$includes = NULL;
preg_match_all( "/\@\@\@([^\@]+)\@\@\@/", $main, $includes, PREG_SET_ORDER );
foreach( $includes as $file ) {
$main = str_replace( $file[0], file_get_contents( $file[1] ), $main );
$compiled = array( "<?php" );
foreach( $IFM_SRC_PHP as $phpfile ) {
$lines = file( $phpfile );
unset( $lines[0] ); // remove <?php line
$compiled = array_merge( $compiled, $lines );
}
$compiled = join( $compiled );
/**
* Add PHP files
* Process includes
*/
$phpincludes = array();
foreach( $IFM_SRC_PHPFILES as $file ) {
$content = file( $file );
unset( $content[0] ); // remove <?php line
$phpincludes = array_merge( $phpincludes, $content );
$includes = NULL;
preg_match_all( "/\@\@\@file:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
foreach( $includes as $file ) {
$compiled = str_replace( $file[0], file_get_contents( $file[1] ), $compiled );
}
/**
* Build standalone script
*/
file_put_contents( $IFM_BUILD_STANDALONE, $main );
file_put_contents( $IFM_BUILD_STANDALONE, $phpincludes, FILE_APPEND );
file_put_contents( $IFM_BUILD_STANDALONE, $compiled );
file_put_contents( $IFM_BUILD_STANDALONE, '
/**
* start IFM
@ -57,5 +58,4 @@ $ifm->run();
/**
* Build library
*/
file_put_contents( $IFM_BUILD_LIB_PHP, $main );
file_put_contents( $IFM_BUILD_LIB_PHP, $phpincludes, FILE_APPEND );
file_put_contents( $IFM_BUILD_LIB_PHP, $compiled );

View File

@ -1,5 +1,4 @@
<?php
/* =======================================================================
* Improved File Manager
* ---------------------

View File

@ -97,55 +97,55 @@ class IFM {
$templates = array();
$templates['app'] = <<<'f00bar'
@@@src/templates/app.html@@@
@@@file:src/templates/app.html@@@
f00bar;
$templates['login'] = <<<'f00bar'
@@@src/templates/login.html@@@
@@@file:src/templates/login.html@@@
f00bar;
$templates['filetable'] = <<<'f00bar'
@@@src/templates/filetable.html@@@
@@@file:src/templates/filetable.html@@@
f00bar;
$templates['footer'] = <<<'f00bar'
@@@src/templates/footer.html@@@
@@@file:src/templates/footer.html@@@
f00bar;
$templates['task'] = <<<'f00bar'
@@@src/templates/task.html@@@
@@@file:src/templates/task.html@@@
f00bar;
$templates['ajaxrequest'] = <<<'f00bar'
@@@src/templates/modal.ajaxrequest.html@@@
@@@file:src/templates/modal.ajaxrequest.html@@@
f00bar;
$templates['copymove'] = <<<'f00bar'
@@@src/templates/modal.copymove.html@@@
@@@file:src/templates/modal.copymove.html@@@
f00bar;
$templates['createdir'] = <<<'f00bar'
@@@src/templates/modal.createdir.html@@@
@@@file:src/templates/modal.createdir.html@@@
f00bar;
$templates['deletefile'] = <<<'f00bar'
@@@src/templates/modal.deletefile.html@@@
@@@file:src/templates/modal.deletefile.html@@@
f00bar;
$templates['extractfile'] = <<<'f00bar'
@@@src/templates/modal.extractfile.html@@@
@@@file:src/templates/modal.extractfile.html@@@
f00bar;
$templates['file'] = <<<'f00bar'
@@@src/templates/modal.file.html@@@
@@@file:src/templates/modal.file.html@@@
f00bar;
$templates['multidelete'] = <<<'f00bar'
@@@src/templates/modal.multidelete.html@@@
@@@file:src/templates/modal.multidelete.html@@@
f00bar;
$templates['remoteupload'] = <<<'f00bar'
@@@src/templates/modal.remoteupload.html@@@
@@@file:src/templates/modal.remoteupload.html@@@
f00bar;
$templates['renamefile'] = <<<'f00bar'
@@@src/templates/modal.renamefile.html@@@
@@@file:src/templates/modal.renamefile.html@@@
f00bar;
$templates['search'] = <<<'f00bar'
@@@src/templates/modal.search.html@@@
@@@file:src/templates/modal.search.html@@@
f00bar;
$templates['searchresults'] = <<<'f00bar'
@@@src/templates/modal.searchresults.html@@@
@@@file:src/templates/modal.searchresults.html@@@
f00bar;
$templates['uploadfile'] = <<<'f00bar'
@@@src/templates/modal.uploadfile.html@@@
@@@file:src/templates/modal.uploadfile.html@@@
f00bar;
$this->templates = $templates;
}
@ -169,24 +169,24 @@ f00bar;
public function getCSS() {
print '
<style type="text/css">';?> @@@src/includes/bootstrap.min.css@@@ <?php print '</style>
<style type="text/css">';?> @@@src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
<style type="text/css">';?> @@@src/includes/fontello-embedded.css@@@ <?php print '</style>
<style type="text/css">';?> @@@src/includes/animation.css@@@ <?php print '</style>
<style type="text/css">';?> @@@src/style.css@@@ <?php print '</style>
<style type="text/css">';?> @@@file:src/includes/bootstrap.min.css@@@ <?php print '</style>
<style type="text/css">';?> @@@file:src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
<style type="text/css">';?> @@@file:src/includes/fontello-embedded.css@@@ <?php print '</style>
<style type="text/css">';?> @@@file:src/includes/animation.css@@@ <?php print '</style>
<style type="text/css">';?> @@@file:src/style.css@@@ <?php print '</style>
';
}
public function getJS() {
print '
<script>';?> @@@src/includes/ace.js@@@ <?php print '</script>
<script>';?> @@@src/includes/jquery.min.js@@@ <?php print '</script>
<script>';?> @@@src/includes/bootstrap.min.js@@@ <?php print '</script>
<script>';?> @@@src/includes/bootstrap-notify.min.js@@@ <?php print '</script>
<script>';?> @@@src/includes/bootstrap-treeview.min.js@@@ <?php print '</script>
<script>';?> @@@src/includes/BootstrapMenu.min.js@@@ <?php print '</script>
<script>';?> @@@src/includes/mustache.min.js@@@ <?php print '</script>
<script>';?> @@@src/ifm.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/ace.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/jquery.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/bootstrap.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/bootstrap-notify.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/bootstrap-treeview.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/BootstrapMenu.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/includes/mustache.min.js@@@ <?php print '</script>
<script>';?> @@@file:src/ifm.js@@@ <?php print '</script>
';
}