Skip to content

Commit

Permalink
fix: plugin loading, fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed May 9, 2024
1 parent e3e993c commit 377402c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mkdir -p /var/www/html/plugins-enabled || true

number=1
for PLUGIN in $ADMINER_PLUGINS; do
php plugin-loader.php "$PLUGIN" > /var/www/html/plugins-enabled/$(printf "%03d" $number)-$PLUGIN.php
php /var/www/html/plugin-loader.php "$PLUGIN" > /var/www/html/plugins-enabled/$(printf "%03d" $number)-$PLUGIN.php
number=$(($number+1))
done

Expand Down
8 changes: 4 additions & 4 deletions rootfs/var/www/html/plugin-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
fwrite(STDERR, 'Refusing to load plugin file "'.$name.'" for security reasons.'."\n");
exit(1);
}
if (!is_readable('plugins/'.$name.'.php')) {
if (!is_readable('/var/www/html/plugins/'.$name.'.php')) {
fwrite(STDERR, 'Unable to find plugin file "'.$name.'".'."\n");
exit(1);
}

// Try to find class.
$file = 'plugins/'.$name.'.php';
$code = file_get_contents('plugins/'.$name.'.php');
$file = '/var/www/html/plugins/'.$name.'.php';
$code = file_get_contents('/var/www/html/plugins/'.$name.'.php');
$tokens = token_get_all($code);

$classFound = false;
Expand Down Expand Up @@ -51,7 +51,7 @@
fwrite(STDERR, 'Unable to load plugin file "'.$name.'", because it has required parameters: '.implode(', ', array_map(function ($item) {
return $item->getName();
}, $requiredParameters))."\n".
'Create a file "'.getcwd().'/plugins-enabled/'.$name.'.php" with the following contents to load the plugin:'."\n\n".
'Create a file /var/www/html/plugins-enabled/'.$name.'.php" with the following contents to load the plugin:'."\n\n".
'<?php
require_once('.var_export($file, true).');
Expand Down

0 comments on commit 377402c

Please sign in to comment.