Fix docker, remove debug output from ifmarchive class

Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
Marco Dickert 2020-07-16 22:41:07 +02:00
parent 84c0fc764d
commit d1ec39fdfa
6 changed files with 53 additions and 35 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
*
!compiler.php
!src
!docker/docker-startup.sh

View File

@ -24,9 +24,13 @@ RUN echo "Set disable_coredump false" > /etc/sudo.conf
# prepare files
RUN rm -rf /var/www/html && \
mkdir -p /usr/local/share/webapps/ifm && \
ln -s /var/www /usr/local/share/webapps/ifm/www
COPY ifm.php /usr/local/share/webapps/ifm/index.php
COPY docker-startup.sh /usr/local/bin
ln -s /var/www /usr/local/share/webapps/ifm/www && \
mkdir -p /usr/src/ifm
COPY compiler.php src/ /usr/src/ifm/
RUN /usr/src/ifm/compiler.php --languages=all && \
cp /usr/src/ifm/dist/simple.ifm.php /usr/local/share/webapps/ifm/index.php
COPY docker/docker-startup.sh /usr/local/bin
# start php server
WORKDIR /usr/local/share/webapps/ifm

View File

@ -6,21 +6,20 @@
* This script compiles all sources into one single file.
*/
chdir( realpath( dirname( __FILE__ ) ) );
chdir(realpath(dirname(__FILE__)));
// output files and common attrs
define( "IFM_CDN", false );
define( "IFM_VERSION", "<a href='https://github.com/misterunknown/ifm/tree/cryol-2.6.1' target=_blank>v2.6.1</a>" );
define( "IFM_RELEASE_DIR", "dist/");
define( "IFM_STANDALONE", "ifm.php" );
define( "IFM_STANDALONE_GZ", "ifm.min.php" );
define( "IFM_LIB", "libifm.php" );
define("IFM_CDN", false);
define("IFM_VERSION", "<a href='https://github.com/misterunknown/ifm/releases/tag/v2.6.1' target=_blank>v2.6.1</a>" );
define("IFM_RELEASE_DIR", "dist/");
define("IFM_STANDALONE", "ifm.php" );
define("IFM_STANDALONE_GZ", "ifm.min.php" );
define("IFM_LIB", "libifm.php" );
if( IFM_CDN ){
if (IFM_CDN)
$IFM_ASSETS = "src/assets.cdn.part";
} else {
else
$IFM_ASSETS = "src/assets.part";
}
// php source files
$IFM_SRC_PHP = array(
@ -30,14 +29,38 @@ $IFM_SRC_PHP = array(
);
// get options
$options = getopt( null, array( "language::" ) );
$options = getopt(null, array("language::", "languages::", "cdn::"));
// process languages
$vars['languages'] = isset( $options['language'] ) ? explode( ',', $options['language'] ) : array( "en", "ru" );
$langs = array_unique(array_merge(explode(",", join(",", [$options['language']])), explode(",", join(",", [$options['languages']]))));
print_r($langs);
if (in_array("all", $langs)) {
$available_languages = array_map(
function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); },
glob("src/i18n/*.json")
);
// default language is english, if not given
if ($langs[0] == 'all' || !file_exists($lang[0]))
$default_lang = "en";
else
$default_lang = $lang[0];
unset($available_langs[array_search($default_lang, $available_langs)]);
$include_langs = array_merge($default_lang, $available_langs);
}
print_r($options['language']);
print_r($include_langs);
die();
// process languages
$vars['languages'] = isset($options['language']) ? explode(',', $options['language']) : ["all"];
$vars['defaultlanguage'] = $vars['languages'][0];
$vars['languageincludes'] = "";
foreach( $vars['languages'] as $l ) {
if( file_exists( "src/i18n/".$l.".json" ) )
foreach ($vars['languages'] as $l)
if (file_exists("src/i18n/".$l.".json"))
$vars['languageincludes'] .=
'$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n"
. file_get_contents( "src/i18n/".$l.".json" ) . "\n"
@ -45,11 +68,8 @@ foreach( $vars['languages'] as $l ) {
. '$i18n["'.$l.'"] = json_decode( $i18n["'.$l.'"], true );' . "\n" ;
else
print "WARNING: Language file src/i18n/".$l.".json not found.\n";
}
/**
* Concat PHP Files
*/
// Concat PHP Files
$compiled = array( "<?php" );
foreach( $IFM_SRC_PHP as $phpfile ) {
$lines = file( $phpfile );
@ -59,17 +79,14 @@ foreach( $IFM_SRC_PHP as $phpfile ) {
$compiled = join( $compiled );
$compiled = str_replace( "IFM_ASSETS", file_get_contents( $IFM_ASSETS ), $compiled );
/**
* Process file includes
*/
// Process file includes
$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 );
/**
* Process ace includes
*/
// Process ace includes
$includes = NULL;
$vars['ace_includes'] = "";
preg_match_all( "/\@\@\@acedir:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
@ -84,9 +101,7 @@ foreach( $includes as $dir ) {
$compiled = str_replace( $dir[0], $dircontent, $compiled );
}
/**
* Process variable includes
*/
// Process variable includes
$includes = NULL;
preg_match_all( "/\@\@\@vars:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
foreach( $includes as $var )

View File

@ -1,3 +0,0 @@
*
!ifm.php
!docker-startup.sh

0
docker/docker-startup.sh Normal file → Executable file
View File

View File

@ -55,8 +55,6 @@ class IFMArchive {
if (!is_array($src))
$src = array($src);
file_put_contents("debug.ifm.log", var_export(is_callable($exclude_callback), true)."\n");
foreach ($src as $s)
if (is_dir($s))
if (is_callable($exclude_callback))