Files
webgui/plugins/dynamix.plugin.manager/scripts/multiplugin
bergware 1a0e8de368 Revert "Plugin system update"
This reverts commit 8f8c75dc67.
2022-07-11 23:11:44 +02:00

56 lines
1.4 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$method = $argv[1];
$plugins = explode('*',$argv[2]);
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
$call = ['plg' => 'plugin', 'xml' => 'language', '' => 'language'];
function done() {
write('_DONE_');
exit(0);
}
function write($message){
global $console;
if ($console) {
echo $message;
} else {
$nchan = curl_init();
curl_setopt_array($nchan,[
CURLOPT_URL => 'http://localhost/pub/plugins?buffer_length=0',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $message,
CURLOPT_RETURNTRANSFER => true
]);
curl_exec($nchan);
curl_close($nchan);
}
}
usleep(50000);
foreach ($plugins as $plugin) {
if (!$plugin || (!$cmd = $call[pathinfo($plugin)['extension']])) continue;
$line = '';
$run = popen("$cmd $method $plugin",'r');
while (!feof($run)) {
$line .= fgetc($run);
if (in_array($line[-1],["\r","\n"])) {write($line); $line = '';}
}
pclose($run);
write("\n");
}
done();
?>