Skip to content
Open
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
2 changes: 1 addition & 1 deletion core/ajax/cache.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

if (init('action') == 'set') {
unautorizedInDemo();
cache::set(init('key'), init('value'), init('lifetime', 0), init('options', null));
cache::set(init('key'), init('value'), init('lifetime', 0));
ajax::success();
}

Expand Down
2 changes: 1 addition & 1 deletion core/ajax/cmd.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
$data[] = $info_history;
}
} else {
$histories = history::getHistoryFromCalcul(jeedom::fromHumanReadable(init('id')), $dateStart, $dateEnd, init('allowZero', false), init('groupingType'), init('addFirstPreviousValue', false));
$histories = history::getHistoryFromCalcul(jeedom::fromHumanReadable(init('id')), $dateStart, $dateEnd, init('allowZero', false), init('groupingType'));
if (is_array($histories)) {
foreach ($histories as $datetime => $value) {
$info_history = array();
Expand Down
2 changes: 1 addition & 1 deletion core/ajax/eqLogic.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@
$eqLogicsSave = json_decode($eqLogicSaves, true);
$nbrSave = count($eqLogicsSave);
$return = array();

$eqLogic = null;
foreach ($eqLogicsSave as $eqLogicSave) {

if (!is_array($eqLogicSave)) {
Expand Down
4 changes: 2 additions & 2 deletions core/ajax/interact.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$results = utils::o2a(interactDef::all());
foreach ($results as &$result) {
$result['nbInteractQuery'] = count(interactQuery::byInteractDefId($result['id']));
$result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id'], true));
$result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id']));
if (isset($result['link_type']) && $result['link_type'] == 'cmd' && $result['link_id'] != '') {
$link_id = '';
foreach (explode('&&', $result['link_id']) as $cmd_id) {
Expand All @@ -49,7 +49,7 @@
if (init('action') == 'byId') {
$result = utils::o2a(interactDef::byId(init('id')));
$result['nbInteractQuery'] = count(interactQuery::byInteractDefId($result['id']));
$result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id'], true));
$result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id']));
ajax::success(jeedom::toHumanReadable($result));
}

Expand Down
2 changes: 1 addition & 1 deletion core/ajax/listener.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

if (init('action') == 'all') {
$listeners = utils::o2a(listener::all(true));
$listeners = utils::o2a(listener::all());
foreach ($listeners as &$listener) {
$listener['event_str'] = '';
foreach ($listener['event'] as $event) {
Expand Down
2 changes: 1 addition & 1 deletion core/ajax/object.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function jeeAjax_objectToHtml($_id = -1, $_version = 'dashboard', $_category = '
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
ajax::success(jeeObject::getUISelectList(init('none'), true));
ajax::success(jeeObject::getUISelectList(init('none')));
}

if (init('action') == 'getSummaryHtml') {
Expand Down
2 changes: 1 addition & 1 deletion core/ajax/queue.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

if (init('action') == 'all') {
$queues = queue::all(true);
$queues = queue::all();
foreach ($queues as $queue) {
$queue->refresh();
}
Expand Down
2 changes: 1 addition & 1 deletion core/ajax/report.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
foreach (ls($path, '*') as $value) {
unlink($path . $value);
}
ajax::success($return);
ajax::success();
}

throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action'));
Expand Down
1 change: 1 addition & 0 deletions core/ajax/scenario.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
if (init('action') == 'applyTemplate') {
unautorizedInDemo();
$path = __DIR__ . '/../../data/scenario';
$converts = [];
if (!file_exists($path . '/' . init('template'))) {
throw new Exception(__('Fichier non trouvé :', __FILE__) . ' ' . $path . '/' . init('template'));
}
Expand Down
4 changes: 3 additions & 1 deletion core/ajax/user.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

if (!isConnect()) {
if (config::byKey('sso:allowRemoteUser') == 1) {
$configs = config::byKeys(array('session_lifetime', 'sso:allowRemoteUser', 'sso:remoteUserHeader'));
$header = $configs['sso:remoteUserHeader'];
$header_value = $_SERVER[$header];
$user = user::byLogin($header_value);
Expand Down Expand Up @@ -343,7 +344,8 @@

if (init('action') == 'removeBanIp') {
unautorizedInDemo();
ajax::success(user::removeBanIp());
user::removeBanIp();
ajax::success();
}

if (init('action') == 'supportAccess') {
Expand Down
9 changes: 7 additions & 2 deletions core/api/jeeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
if (is_object($_USER_GLOBAL) && $_USER_GLOBAL->getProfils() != 'admin') {
throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action', __FILE__) . ' ' . $jsonrpc->getMethod(), -32001);
}
jeedom::update($params['options'], 0);
jeedom::update($params['options']);
$jsonrpc->makeSuccess('ok');
}

Expand Down Expand Up @@ -497,6 +497,7 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$object = null;
if (isset($params['id'])) {
$object = jeeObject::byId($params['id']);
}
Expand Down Expand Up @@ -836,6 +837,7 @@

if ($jsonrpc->getMethod() == 'cmd::save') {
unautorizedInDemo();
$cmd = null;
if (isset($params['id'])) {
$cmd = cmd::byId($params['id']);
if (is_object($_USER_GLOBAL) && !$cmd->hasRight($_USER_GLOBAL)) {
Expand Down Expand Up @@ -979,6 +981,7 @@

if ($jsonrpc->getMethod() == 'scenario::save') {
unautorizedInDemo();
$scenario = null;
if (isset($params['id'])) {
$scenario = scenario::byId($params['id']);
}
Expand Down Expand Up @@ -1152,6 +1155,7 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$update = null;
if (isset($params['plugin_id'])) {
$update = update::byId($params['plugin_id']);
}
Expand Down Expand Up @@ -1277,7 +1281,7 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
jeedom::update('', 0);
jeedom::update('');
$jsonrpc->makeSuccess('ok');
}

Expand All @@ -1294,6 +1298,7 @@
throw new Exception(__('Vous n\'avez pas les droits de faire cette action', __FILE__), -32701);
}
unautorizedInDemo();
$update = null;
if (isset($params['plugin_id'])) {
$update = update::byId($params['plugin_id']);
}
Expand Down
12 changes: 6 additions & 6 deletions core/api/proApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
}

if ($jsonrpc->getMethod() == 'jeeNetwork::update') {
jeedom::update('', 0);
jeedom::update('');
$jsonrpc->makeSuccess('ok');
}

Expand Down Expand Up @@ -751,7 +751,7 @@
}

if ($jsonrpc->getMethod() == 'backup::restoreMarket') {
repo_market::backup_restore($params['backup'], true);
repo_market::backup_restore($params['backup']);
$jsonrpc->makeSuccess();
}

Expand Down Expand Up @@ -815,9 +815,9 @@
/* * ************************Plugin*************************** */
if ($jsonrpc->getMethod() == 'plugin::install') {
try {
$market = market::byId($params['plugin_id']);
$market = repo_market::byId($params['plugin_id']);
} catch (Exception $e) {
$market = market::byLogicalId($params['plugin_id']);
$market = repo_market::byLogicalId($params['plugin_id']);
}
if (!is_object($market)) {
throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id']));
Expand All @@ -830,7 +830,7 @@
}

if ($jsonrpc->getMethod() == 'plugin::remove') {
$market = market::byId($params['plugin_id']);
$market = repo_market::byId($params['plugin_id']);
if (!is_object($market)) {
throw new Exception(__('Impossible de trouver l\'objet associé :', __FILE__) . ' ' . secureXSS($params['plugin_id']));
}
Expand Down Expand Up @@ -858,7 +858,7 @@
}

if ($jsonrpc->getMethod() == 'update::update') {
jeedom::update('', 0);
jeedom::update('');
$jsonrpc->makeSuccess('ok');
}

Expand Down
13 changes: 10 additions & 3 deletions core/class/cmd.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ public function pushInflux($_value = null) {
return;
}

public function dropInfluxDatabase() {
public static function dropInfluxDatabase() {
try {
$database = cmd::getInflux();
if ($database == '') {
Expand Down Expand Up @@ -2354,8 +2354,15 @@ public function dropInflux() {
return;
}

public function historyInfluxAll() {
cmd::historyInflux('all');
public static function historyInfluxAll() {
$cron = new cron();
$cron->setClass('cmd');
$cron->setFunction('sendHistoryInflux');
$cron->setOption(array('cmd_id' => 'all'));
$cron->setLastRun(date('Y-m-d H:i:s'));
$cron->setOnce(1);
$cron->setSchedule(cron::convertDateToCron(strtotime("now") + 60));
$cron->save();
}

public static function sendHistoryInflux($_params) {
Expand Down
4 changes: 4 additions & 0 deletions core/class/event.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
/* * ***************************Includes********************************* */
require_once __DIR__ . '/../../core/php/core.inc.php';

/**
* @see https://github.com/phpstan/phpstan/issues/13556
* @method static void add(string $_event, $_option = [], bool $_clean = true)
*/
class event {
/* * *************************Attributs****************************** */

Expand Down
1 change: 1 addition & 0 deletions core/class/history.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public static function all($_cmd_id, $_startTime = null, $_endTime = null, $_gro
$values['endTime'] = $_endTime;
}
$sql='';
$goupingType = [];
if ($_groupingType == null || strpos($_groupingType, '::') === false) {
$sql .= 'SELECT ' . DB::buildField(__CLASS__);
} else {
Expand Down
5 changes: 4 additions & 1 deletion core/class/interactQuery.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static function removeByInteractDefId($_interactDef_id) {
}

public static function recognize($_query) {
$closest = null;
$_query = trim(interactDef::sanitizeQuery($_query));
if (trim($_query) == '') {
return null;
Expand Down Expand Up @@ -248,6 +249,7 @@ public static function findInQuery($_type, $_query, $_data = null) {
$return['query'] = strtolower(sanitizeAccent($_query));
$return[$_type] = null;
$synonyms = self::getQuerySynonym($return['query'], $_type);
$objects = [];
if ($_type == 'object') {
$objects = jeeObject::all();
} elseif ($_type == 'eqLogic') {
Expand Down Expand Up @@ -332,6 +334,7 @@ public static function autoInteract($_query, $_parameters = array()) {
$data = array_merge($data, self::findInQuery('eqLogic', $data['query'], $data));
$data = array_merge($data, self::findInQuery('cmd', $data['query'], $data));
if (isset($data['eqLogic']) && is_object($data['eqLogic']) && (!isset($data['cmd']) || !is_object($data['cmd']))) {
$cmd = null;
foreach ($data['eqLogic']->getCmd('action') as $cmd) {
if ($cmd->getSubtype() == 'slider') {
break;
Expand Down Expand Up @@ -667,7 +670,7 @@ public static function contextualReply($_query, $_parameters = array(), $_lastCm
return $return;
}

public function replaceForContextual($_replace, $_by, $_in) {
public static function replaceForContextual($_replace, $_by, $_in) {
return str_replace(strtolower(sanitizeAccent($_replace)), strtolower(sanitizeAccent($_by)), str_replace($_replace, $_by, $_in));
}

Expand Down
3 changes: 2 additions & 1 deletion core/class/jeeObject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static function checkSummaryUpdate($_cmd_id) {
}
$toRefreshCmd = array();
$global = array();
$events = [];
foreach ($objects as $object) {
$summaries = $object->getConfiguration('summary');
if (!is_array($summaries)) {
Expand Down Expand Up @@ -581,7 +582,7 @@ public static function createSummaryToVirtual($_key = '') {
if (!$plugin->isActive()) {
$plugin->setIsEnable(1);
}
if (!is_object($plugin)) {
if (!is_object($plugin) || !class_exists('virtual') || !class_exists('virtualCmd')) {
throw new Exception(__('Le plugin virtuel doit être installé', __FILE__));
}
if (!$plugin->isActive()) {
Expand Down
30 changes: 15 additions & 15 deletions core/class/jsonrpcClient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private function send($_request, $_timeout = 15, $_file = null, $_maxRetry = 2)
}
}
$nbRetry = 0;
while ($nbRetry < $_maxRetry) {
do {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiAddr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Expand All @@ -140,19 +140,19 @@ private function send($_request, $_timeout = 15, $_file = null, $_maxRetry = 2)
}
if(config::byKey('proxyEnabled')) {
if(config::byKey('proxyAddress') == ''){
// throw new Exception(__('renseigne l\'adresse', __FILE__));
$this->error = 'Erreur address ';
} else if (config::byKey('proxyPort') == ''){
// throw new Exception(__('renseigne le port', __FILE__));
} else {
curl_setopt($ch, CURLOPT_PROXY, config::byKey('proxyAddress'));
curl_setopt($ch, CURLOPT_PROXYPORT, config::byKey('proxyPort'));
if(!empty(config::byKey('proxyLogin') || config::byKey('proxyPassword'))){
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'proxyLogin:proxyPassword');
}
log::add('Connection', 'debug', $ch);
}
}
// throw new Exception(__('renseigne l\'adresse', __FILE__));
$this->error = 'Erreur address ';
} else if (config::byKey('proxyPort') == ''){
// throw new Exception(__('renseigne le port', __FILE__));
} else {
curl_setopt($ch, CURLOPT_PROXY, config::byKey('proxyAddress'));
curl_setopt($ch, CURLOPT_PROXYPORT, config::byKey('proxyPort'));
if(!empty(config::byKey('proxyLogin') || config::byKey('proxyPassword'))){
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'proxyLogin:proxyPassword');
}
log::add('Connection', 'debug', $ch);
}
}
$response = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$nbRetry++;
Expand All @@ -162,7 +162,7 @@ private function send($_request, $_timeout = 15, $_file = null, $_maxRetry = 2)
} else {
$nbRetry = $_maxRetry + 1;
}
}
} while ($nbRetry < $_maxRetry);
if ($http_status == 301) {
if (preg_match('/<a href="(.*)">/i', $response, $r)) {
$this->apiAddr = trim($r[1]);
Expand Down
2 changes: 1 addition & 1 deletion core/class/network.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static function dns_create() {
$update->doUpdate();
$plugin = plugin::byId('openvpn');
}
if (!is_object($plugin)) {
if (!is_object($plugin) || !class_exists('openvpn')) {
throw new Exception(__('Le plugin OpenVPN doit être installé', __FILE__));
}
if (!$plugin->isActive()) {
Expand Down
2 changes: 1 addition & 1 deletion core/class/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static function listPlugin($_activateOnly = false, $_orderByCategory = fa
}
return $return;
} else {
if (isset($listPlugin) && is_array($listPlugin) && count($listPlugin) > 0) {
if (is_array($listPlugin) && count($listPlugin) > 0) {
usort($listPlugin, 'plugin::orderPlugin');
return $listPlugin;
} else {
Expand Down
4 changes: 3 additions & 1 deletion core/class/scenario.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ public function export($_mode = 'text') {
$return .= " " . $export . "\n";
}
}
return $return;
}
if ($_mode == 'array') {
$return = utils::o2a($this);
Expand Down Expand Up @@ -1426,8 +1427,9 @@ public function export($_mode = 'text') {
if (isset($return['_elements'])) {
unset($return['_elements']);
}
return $return;
}
return $return;
return null;
}
/**
*
Expand Down
Loading