Source of file marketApi.php

Size: 1,788 Bytes - Last Modified: 2020-10-24T02:46:31+00:00

/home/travis/build/NextDom/nextdom-core/src/Api/marketApi.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
<?php

/* This file is part of Jeedom.
 *
 * Jeedom is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
header('Access-Control-Allow-Origin: *');
require_once __DIR__ . "/../../src/core.php";
if (user::isBan() && false) {
    header("Status: 404 Not Found");
    header('HTTP/1.0 404 Not Found');
    $_SERVER['REDIRECT_STATUS'] = 404;
    require(NEXTDOM_ROOT . '/public/404.html');
    die();
}
try {
    if (!nextdom::apiAccess(init('apikey'), 'apimarket')) {
        user::failedLogin();
        sleep(5);
        throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action 1, IP : ', __FILE__) . getClientIp());
    }
    if (init('action') == 'resync') {
        if (nextdom::isStarted() && config::byKey('enableCron', 'core', 1, true) == 0) {
            die(__('Tous les crons sont actuellement désactivés', __FILE__));
        }
        $cron = new cron();
        $cron->setClass('repo_market');
        $cron->setFunction('test');
        $cron->setOnce(1);
        $cron->setSchedule(cron::convertDateToCron(strtotime('now')));
        $cron->save();
        $cron->start();
    }
} catch (Exception $e) {
    echo $e->getMessage();
    log::add('jeeEvent', 'error', $e->getMessage());
}