Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions core/ajax/plugin.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
throw new Exception(__('Plugin introuvable :', __FILE__) . ' ' . init('id'));
}
$plugin->setIsEnable(init('state'));
Expand All @@ -68,9 +69,10 @@
}

$return = array('state' => 'nok', 'log' => 'nok');
$plugin = plugin::byId(init('id'));
if (is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
$return = $plugin->dependancy_info();
} catch (Exception $e) {
}
ajax::success($return);
}
Expand All @@ -80,8 +82,9 @@
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
unautorizedInDemo();
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
ajax::success();
}
ajax::success($plugin->dependancy_install(true));
Expand All @@ -92,8 +95,9 @@
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
unautorizedInDemo();
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
ajax::success();
}
ajax::success($plugin->dependancy_changeAutoMode(init('mode')));
Expand All @@ -103,11 +107,12 @@
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$plugin_id = init('id');
$return = array('launchable_message' => '', 'launchable' => 'nok', 'state' => 'nok', 'log' => 'nok', 'auto' => 0);
$plugin = plugin::byId(init('id'));
if (is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
$return = $plugin->deamon_info();
} catch (Exception $e) {
$plugin = null;
}
$return['plugin'] = utils::o2a($plugin);
ajax::success($return);
Expand All @@ -118,9 +123,9 @@
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
unautorizedInDemo();
$plugin_id = init('id');
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
ajax::success();
}
ajax::success($plugin->deamon_start(init('forceRestart', 0)));
Expand All @@ -131,8 +136,9 @@
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
unautorizedInDemo();
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
ajax::success();
}
ajax::success($plugin->deamon_stop());
Expand All @@ -143,8 +149,9 @@
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
unautorizedInDemo();
$plugin = plugin::byId(init('id'));
if (!is_object($plugin)) {
try {
$plugin = plugin::byId(init('id'));
} catch (Exception $e) {
ajax::success();
}
ajax::success($plugin->deamon_changeAutoMode(init('mode')));
Expand Down
30 changes: 18 additions & 12 deletions core/api/jeeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,9 @@
if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) {
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess(array('state' => 'nok', 'log' => 'nok'));
}
$jsonrpc->makeSuccess($plugin->dependancy_info());
Expand All @@ -1180,8 +1181,9 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess();
}
$plugin->dependancy_install();
Expand All @@ -1192,8 +1194,9 @@
if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin', 'user'))) {
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess(array('launchable_message' => '', 'launchable' => 'nok', 'state' => 'nok', 'log' => 'nok', 'auto' => 0));
}
$jsonrpc->makeSuccess($plugin->deamon_info());
Expand All @@ -1216,8 +1219,9 @@
if (is_object($_USER_GLOBAL) && !in_array($_USER_GLOBAL->getProfils(), array('admin'))) {
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess();
}
if (!isset($params['debug'])) {
Expand All @@ -1235,8 +1239,9 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess();
}
$plugin->deamon_stop();
Expand All @@ -1248,8 +1253,9 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$plugin = plugin::byId($params['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($params['plugin_id']);
} catch (Exception $e) {
$jsonrpc->makeSuccess();
}
$plugin->deamon_changeAutoMode($params['mode']);
Expand Down
13 changes: 13 additions & 0 deletions core/class/jsonrpc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public function __construct($_jsonrpc) {
}
}

/**
* Sends an error response and ends execution
*
* @param int $_code Error code
* @param string $_message Error message
* @return never
*/
public function makeError($_code, $_message) {
$return = array(
'jsonrpc' => '2.0',
Expand All @@ -71,6 +78,12 @@ public function makeError($_code, $_message) {
exit;
}

/**
* Sends a success response and ends execution
*
* @param mixed $_result Data to send in response
* @return never
*/
public function makeSuccess($_result = null) {
if(is_object($_result)){
$_result = utils::o2a($_result);
Expand Down
5 changes: 3 additions & 2 deletions core/class/scenarioExpression.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,9 @@ public function execute(?scenario &$scenario = null) {
$cmd_parameters['message'] = __('Veuillez trouver ci-joint le rapport', __FILE__) . ' ' . $plan->getName() . ' ' . __('généré le', __FILE__) . ' ' . date('Y-m-d H:i:s');
break;
case 'plugin':
$plugin = plugin::byId($options['plugin_id']);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($options['plugin_id']);
} catch (Exception $e) {
throw new Exception(__('Panel introuvable - Vérifiez l\'id :', __FILE__) . ' ' . $options['plugin_id']);
}
self::setLog($scenario, __('Génération du rapport', __FILE__) . ' ' . $plugin->getName());
Expand Down
5 changes: 3 additions & 2 deletions core/php/jeePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
if ($plugin_id == '') {
throw new Exception(__('Le plugin ID ne peut être vide', __FILE__));
}
$plugin = plugin::byId($plugin_id);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($plugin_id);
} catch (Exception $e) {
throw new Exception(__('Plugin non trouvé :', __FILE__) . ' ' . init('plugin_id'));
}
$function = init('function');
Expand Down
5 changes: 3 additions & 2 deletions core/php/jeecli.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
}
$update->save();
$update->doUpdate();
$plugin = plugin::byId($argv[3]);
if (!is_object($plugin)) {
try {
$plugin = plugin::byId($argv[3]);
} catch (Exception $e) {
echo "Error plugin not found";
die();
}
Expand Down
14 changes: 8 additions & 6 deletions core/php/utils.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function redirect($_url, $_forceType = null) {
echo '</script>';
} else {
header("Location: $_url");
exit;
exit;
}
return;
}
Expand Down Expand Up @@ -1161,13 +1161,13 @@ function evaluate($_string) {
$string = str_replace($matches[0][$i], '--preparsed' . $i . '--', $string);
}

$expr = preg_replace("/([^=<>!])=([^=])/", "$1==$2", $string); // Replace all '=' by '==' and avoid '==' '===' '>=' '<=' '!=' '!=='
$expr = preg_replace("/([^=<>!])=([^=])/", "$1==$2", $string); // Replace all '=' by '==' and avoid '==' '===' '>=' '<=' '!=' '!=='
for ($i = 0; $i < $c; $i++) {
$expr = str_replace('--preparsed' . $i . '--', $matches[0][$i], $expr);
}
} else {
$expr = preg_replace("/([^=<>!])=([^=])/", "$1==$2", $string); // Replace all '=' by '==' and avoid '==' '===' '>=' '<=' '!=' '!=='
}
$expr = preg_replace("/([^=<>!])=([^=])/", "$1==$2", $string); // Replace all '=' by '==' and avoid '==' '===' '>=' '<=' '!=' '!=='
}
try {
return $GLOBALS['ExpressionLanguage']->evaluate($expr);
} catch (Exception $e) {
Expand Down Expand Up @@ -1807,11 +1807,13 @@ function endsWith($haystack, $needle) {
}

function getWhiteListFolders($_plugin = 'all') {
$pluginsAll = ($_plugin != 'all') ? array($_plugin) : plugin::listPlugin(true, false, true, true);
$pluginsAll = ($_plugin != 'all') ? array($_plugin) : plugin::listPlugin(true, false, true, true);
$result = array();
foreach ($pluginsAll as $pluginId) {
if (!plugin::isInstalled($pluginId)) {
continue;
}
$plugin = plugin::byId($pluginId);
if (!is_object($plugin)) continue;

$publicFolders = $plugin->getWhiteListFolders();
if (count($publicFolders) == 0) continue;
Expand Down