本文整理汇总了PHP中message::removeAll方法的典型用法代码示例。如果您正苦于以下问题:PHP message::removeAll方法的具体用法?PHP message::removeAll怎么用?PHP message::removeAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::removeAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runDeamon
public static function runDeamon()
{
if (!file_exists('/opt/homebridge/config.json')) {
$response = array();
$platform = array();
$response['description'] = "Configuration Jeedom";
$platform['platform'] = "Jeedom";
$platform['name'] = "Jeedom";
$platform['jeedom_ip'] = "127.0.0.1";
$platform['jeedom_port'] = config::byKey('internalPort');
$platform['jeedom_url'] = config::byKey('internalComplement');
$platform['jeedom_api_key'] = config::byKey('api');
$response['platforms'] = array();
$response['platforms'][] = $platform;
$response['accessories'] = array();
$fp = fopen('/opt/homebridge/config.json', 'w');
fwrite($fp, json_encode($response));
fclose($fp);
}
log::add('homebridge', 'info', 'Lancement du démon homebridge');
$cmd = 'nice -n 19 /usr/bin/nodejs /opt/homebridge/app.js';
log::add('homebridge', 'info', 'Lancement démon homebridge : ' . $cmd);
$result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('homebridge') . ' 2>&1 &');
if (!self::deamonRunning()) {
sleep(10);
if (!self::deamonRunning()) {
log::add('homebridge', 'error', 'Impossible de lancer le démon homebridge', 'unableStartDeamon');
return false;
}
}
message::removeAll('homebridge', 'unableStartDeamon');
log::add('homebridge', 'info', 'Démon homebridge lancé');
}
示例2: runDeamon
public static function runDeamon($_debug = false)
{
if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) {
return;
}
try {
self::stopDeamon();
} catch (Exception $e) {
}
log::add('openzwave', 'info', 'Lancement du démon openzwave');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port, true);
if (@(!file_exists($port))) {
throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__));
}
exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = realpath(dirname(__FILE__) . '/../../ressources/zwaveserver');
$config_path = realpath(dirname(__FILE__) . '/../../ressources/openzwave/config');
$log = $_debug ? 'Debug' : 'Info';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py --pidfile=/tmp/openzwave.pid --device=' . $port . ' --log=' . $log . ' --port=' . $port_server . ' --config=' . $config_path;
log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwave', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
if (self::deamonRunning()) {
break;
}
sleep(1);
$i++;
}
if ($i >= 30) {
log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwave', 'info', 'Démon openzwave lancé');
}
示例3: sleep
sleep(2);
openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['excluded']['value']);
}
if (isset($results['controller']['included'])) {
for ($i = 0; $i < 10; $i++) {
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Nouveau module Z-Wave détecté. Début de l\'intégration.Pause de ', __FILE__) . (10 - $i) . __(' pour synchronisation avec le module', __FILE__)));
sleep(1);
}
event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Inclusion en cours...', __FILE__)));
openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['included']['value']);
}
}
if (isset($results['message'])) {
log::add('openzwave', 'error', $results['message']);
}
if (isset($results['alert'])) {
switch ($results['alert']['type']) {
case 'node_dead':
$eqLogic = openzwave::getEqLogicByLogicalIdAndServerId($results['alert']['id'], $results['alert']['serverId']);
if (is_object($eqLogic)) {
$message = __('Le noeud', __FILE__) . ' ' . $eqLogic->getHumanName() . ' (' . $results['alert']['id'] . ') ' . __('est présumé mort', __FILE__);
} else {
$message = __('Le noeud', __FILE__) . ' ' . $results['alert']['id'] . ' ' . __('est présumé mort', __FILE__);
}
log::add('openzwave', 'error', $message, 'node_dead_' . $results['alert']['id'] . '_' . $results['alert']['serverId']);
break;
case 'node_alive':
message::removeAll('openzwave', 'node_dead_' . $results['alert']['id'] . '_' . $results['alert']['serverId']);
break;
}
}
示例4: runDeamon
public static function runDeamon($_debug = false)
{
if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) {
return;
}
try {
self::stop();
self::stopDeamon();
} catch (Exception $e) {
}
log::add('openzwave', 'info', 'Lancement du démon openzwave');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port, true);
if (@(!file_exists($port))) {
throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__));
}
exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1');
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
$serverId = config::byKey('jeeNetwork::slave::id');
$callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('jeeNetwork::master::apikey');
} else {
$serverId = 0;
$callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('api');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
$config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
$data_path = dirname(__FILE__) . '/../../data';
if (!file_exists($data_path)) {
exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
}
$log = $_debug ? 'Debug' : 'Error';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
$cmd .= ' --pidfile=/tmp/openzwave.pid';
$cmd .= ' --device=' . $port;
$cmd .= ' --log=' . $log;
$cmd .= ' --port=' . $port_server;
$cmd .= ' --config_folder=' . $config_path;
$cmd .= ' --data_folder=' . $data_path;
$cmd .= ' --callback=' . $callback;
$cmd .= ' --apikey=' . $apikey;
$cmd .= ' --serverId=' . $serverId;
log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwave', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
if (self::deamonRunning()) {
break;
}
sleep(1);
$i++;
}
if ($i >= 10) {
log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwave', 'info', 'Démon openzwave lancé');
}
示例5: isset
/* * ************************Log*************************** */
if ($jsonrpc->getMethod() == 'log::get') {
$jsonrpc->makeSuccess(log::get($params['log'], $params['start'], $params['nbLine']));
}
if ($jsonrpc->getMethod() == 'log::list') {
$jsonrpc->makeSuccess(log::liste());
}
if ($jsonrpc->getMethod() == 'log::empty') {
$jsonrpc->makeSuccess(log::clear($params['log']));
}
if ($jsonrpc->getMethod() == 'log::remove') {
$jsonrpc->makeSuccess(log::remove($params['log']));
}
/* * ************************Messages*************************** */
if ($jsonrpc->getMethod() == 'message::removeAll') {
message::removeAll();
$jsonrpc->makeSuccess('ok');
}
if ($jsonrpc->getMethod() == 'message::all') {
$jsonrpc->makeSuccess(utils::o2a(message::all()));
}
/* * ************************Interact*************************** */
if ($jsonrpc->getMethod() == 'interact::tryToReply') {
$jsonrpc->makeSuccess(interactQuery::tryToReply($params['query']));
}
/* * ************************USB mapping*************************** */
if ($jsonrpc->getMethod() == 'jeedom::getUsbMapping') {
$name = isset($params['name']) ? $params['name'] : '';
$gpio = isset($params['gpio']) ? $params['gpio'] : false;
$jsonrpc->makeSuccess(jeedom::getUsbMapping($name, $gpio));
}
示例6: __
echo __("Vérification de la mise à jour...", __FILE__);
update::checkAllUpdate('core', false);
config::save('version', jeedom::version());
echo __("OK\n", __FILE__);
} catch (Exception $ex) {
echo __("***ERREUR*** ", __FILE__) . $ex->getMessage() . "\n";
}
echo __("***************Jeedom est à jour en version ", __FILE__) . jeedom::version() . "***************\n";
}
if (init('level', -1) > -1) {
echo __("***************Mise à jour des plugins***************\n", __FILE__);
update::updateAll();
echo __("***************Mise à jour des plugins réussie***************\n", __FILE__);
}
try {
message::removeAll('update', 'newUpdate');
echo __("Vérification des mises à jour\n", __FILE__);
update::checkAllUpdate();
echo __("OK\n", __FILE__);
} catch (Exception $ex) {
echo __("***ERREUR*** ", __FILE__) . $ex->getMessage() . "\n";
}
try {
jeedom::start();
} catch (Exception $ex) {
echo __("***ERREUR*** ", __FILE__) . $ex->getMessage() . "\n";
}
} else {
/* * ***************************INSTALLATION************************** */
if (init('mode') != 'force') {
echo "Jeedom va être installé. Voulez-vous continuer ? [o/N] ";
示例7: deamon_start
public static function deamon_start($_debug = false)
{
self::deamon_stop();
$deamon_info = self::deamon_info();
if ($deamon_info['launchable'] != 'ok') {
throw new Exception(__('Veuillez vérifier la configuration', __FILE__));
}
log::remove('openzwavecmd');
$port = config::byKey('port', 'openzwave');
if ($port != 'auto') {
$port = jeedom::getUsbMapping($port);
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
$serverId = config::byKey('jeeNetwork::slave::id');
$callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('jeeNetwork::master::apikey');
} else {
$serverId = 0;
$callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
$apikey = config::byKey('api');
}
$port_server = config::byKey('port_server', 'openzwave', 8083);
$openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
$config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
$data_path = dirname(__FILE__) . '/../../data';
if (!file_exists($data_path)) {
exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
}
$log = $_debug ? 'Debug' : 'Error';
$cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
$cmd .= ' --pidfile=/tmp/openzwave.pid';
$cmd .= ' --device=' . $port;
$cmd .= ' --log=' . $log;
$cmd .= ' --port=' . $port_server;
$cmd .= ' --config_folder=' . $config_path;
$cmd .= ' --data_folder=' . $data_path;
$cmd .= ' --callback=' . $callback;
$cmd .= ' --apikey=' . $apikey;
$cmd .= ' --serverId=' . $serverId;
log::add('openzwavecmd', 'info', 'Lancement démon openzwave : ' . $cmd);
$result = exec($cmd . ' >> ' . log::getPathToLog('openzwavecmd') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('openzwavecmd', 'error', $result);
return false;
}
$i = 0;
while ($i < 30) {
$deamon_info = self::deamon_info();
if ($deamon_info['state'] == 'ok') {
break;
}
sleep(1);
$i++;
}
if ($i >= 30) {
log::add('openzwavecmd', 'error', 'Impossible de lancer le démon openzwave, relancer le démon en debug et vérifiez la log', 'unableStartDeamon');
return false;
}
message::removeAll('openzwave', 'unableStartDeamon');
log::add('openzwavecmd', 'info', 'Démon openzwave lancé');
}
示例8: runDeamon
public static function runDeamon()
{
log::add('mySensors', 'info', 'Lancement du démon mySensors');
$modem_serie_addr = config::byKey('usbGateway', 'mySensors');
if ($modem_serie_addr == "serie") {
$usbGateway = config::byKey('modem_serie_addr', 'mySensors');
} else {
$usbGateway = jeedom::getUsbMapping(config::byKey('usbGateway', 'mySensors'));
}
if ($modem_serie_addr == "network") {
$gateMode = "Network";
$netAd = explode(":", config::byKey('gateway_addr', 'mySensors'));
$usbGateway = $netAd[0];
$gatePort = $netAd[1];
} else {
$gateMode = "Serial";
$gatePort = "";
}
if ($usbGateway == '') {
throw new Exception(__('Le port : ', __FILE__) . $port . __(' n\'éxiste pas', __FILE__));
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
//Je suis l'esclave
$url = 'http://' . config::byKey('jeeNetwork::master::ip') . '/core/api/jeeApi.php?api=' . config::byKey('jeeNetwork::master::apikey');
} else {
if (stripos(config::byKey('internalAddr'), 'jeedom') !== FALSE) {
//on est pas sur une Mini
$jeeurl = "http://127.0.0.1/jeedom";
} else {
$jeeurl = "http://127.0.0.1";
}
$url = $jeeurl . '/core/api/jeeApi.php?api=' . config::byKey('api');
}
$sensor_path = realpath(dirname(__FILE__) . '/../../node');
$cmd = 'nice -n 19 node ' . $sensor_path . '/mysensors.js ' . $url . ' ' . $usbGateway . ' ' . $gateMode . ' ' . $gatePort;
log::add('mySensors', 'info', 'Lancement démon mySensors : ' . $cmd);
$result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('mySensors') . ' 2>&1 &');
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('mySensors', 'error', $result);
return false;
}
sleep(2);
if (!self::deamonRunning()) {
sleep(10);
if (!self::deamonRunning()) {
log::add('mySensors', 'error', 'Impossible de lancer le démon mySensors, vérifiez le port', 'unableStartDeamon');
return false;
}
}
message::removeAll('mySensors', 'unableStartDeamon');
log::add('mySensors', 'info', 'Démon mySensors lancé');
}
示例9: dirname
* 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/>.
*/
try {
require_once dirname(__FILE__) . '/../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (!isConnect()) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
if (init('action') == 'clearMessage') {
message::removeAll(init('plugin'));
ajax::success();
}
if (init('action') == 'nbMessage') {
ajax::success(message::nbMessage());
}
if (init('action') == 'all') {
if (init('plugin') == '') {
$messages = utils::o2a(message::all());
} else {
$messages = utils::o2a(message::byPlugin(init('plugin')));
}
foreach ($messages as &$message) {
$message['message'] = htmlentities($message['message']);
}
ajax::success($messages);
示例10: foreach
} else {
$message = $ui['noMessage'];
}
} else {
if (isset($_POST['messageId'])) {
foreach ($_POST['messageId'] as $id) {
message::remove($id);
}
header('location: message.php?action=list');
} else {
$message = $ui['insufficientData'];
}
}
break;
case 'removeAll':
$status = message::removeAll($_SESSION[$shortTitle . 'User']['id']);
if ($status == 'done') {
header('location: message.php?action=list');
} else {
$message = $ui[$status];
}
break;
case 'list':
$limit = 20;
if (isset($_GET['page'])) {
$offset = $limit * $_GET['page'];
} else {
$offset = 0;
}
$messages = message::getList($_SESSION[$shortTitle . 'User']['id'], $limit, $offset);
$pageCount = ceil($messages['count'] / $limit);
示例11: deamon_start
//.........这里部分代码省略.........
}
if (config::byKey('jeeNetwork::mode') == 'slave') {
$replace_config['#sockethost#'] = network::getNetworkAccess('internal', 'ip', '127.0.0.1');
$replace_config['#socketport#'] = 58300;
$replace_config['#trigger_url#'] = config::byKey('jeeNetwork::master::ip') . '/plugins/arduidom/core/php/jeeArduidom.php';
$replace_config['#trigger_nice#'] = str_replace('class', 'php', realpath(dirname(__FILE__))) . '/jeeArduidom.php';
$replace_config['#apikey#'] = config::byKey('jeeNetwork::master::apikey');
} else {
$replace_config['#sockethost#'] = '0.0.0.0';
//'127.0.0.1';
$replace_config['#socketport#'] = 58200;
$replace_config['#trigger_url#'] = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/arduidom/core/php/jeeArduidom.php';
$replace_config['#trigger_nice#'] = str_replace('class', 'php', realpath(dirname(__FILE__))) . '/jeeArduidom.php';
$replace_config['#apikey#'] = config::byKey('api');
}
$config = file_get_contents($ressource_path . '/config_template.xml');
$config = template_replace($replace_config, $config);
file_put_contents($ressource_path . '/config_arduidom.xml', $config);
chmod($ressource_path . '/config_arduidom.xml', 0777);
//// Verifie si le python est necessaire... (inutile si aucun arduino USB)
//$usb_arduinos = 0;
//if ($_debug) log::add('arduidom','DEBUG','strpos1:' . strpos(config::byKey('A1_port', 'arduidom', '', 1), "/dev"));
//if ($_debug) log::add('arduidom','DEBUG','strpos2:' . strpos(config::byKey('A2_port', 'arduidom', '', 1), "/dev"));
//for ($a = 1; $a <= 8; $a++) {
// if (strpos(config::byKey('A' . $a . '_port', 'arduidom', '', true), "dev/") != false) $usb_arduinos += 1;
//}
//if ($usb_arduinos > 0) {
if (true) {
$cmd = 'nohup nice -n 19 /usr/bin/python ' . $ressource_path . '/arduidomx.py';
if ($_debug) {
$cmd .= ' -lDEBUG';
}
unlink($ressource_path . '/arduidomx.kill');
$cmd .= ' >> ' . log::getPathToLog('arduidom_cmd') . ' 2>&1 &';
config::save('daemonstarted', 0, 'arduidom');
log::add('arduidom', 'info', 'Lancement démon : ' . $cmd);
//// Execution du Python...
$result = exec($cmd);
if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
log::add('arduidom', 'error', $result);
self::set_daemon_mode("ERROR");
return false;
}
log::add('arduidom', 'info', 'Attente du démarrage complet du démon... (30 secondes max.)');
$timeout = time();
while (config::byKey('daemonstarted', 'arduidom', 0, true) == 0) {
sleep(1);
if (time() - $timeout >= 30) {
self::set_daemon_mode("ERROR");
// daemonstarted = Etat du démon : 0=non demarré - 1=démon OK - 2=erreur version
if (config::byKey('daemonstarted', 'arduidom', 0, true) == 0) {
log::add('arduidom', 'error', ' Dépassement du délai de démarrage du démon...');
if (substr(jeedom::version(), 0, 1) == 2) {
event::add('jeedom::alert', array('level' => 'error', 'message' => __("Dépassement du délai de démarrage du démon...", __FILE__)));
}
}
return false;
}
}
if (config::byKey('daemonstarted', 'arduidom', 0, true) == 2) {
self::set_daemon_mode("ERROR");
// daemonstarted = Etat du démon : 0=non demarré - 1=démon OK - 2=erreur version
log::add('arduidom', 'error', " Un ou plusieurs Arduino n\\'ont pas la version du sketch requise ! Veuillez téléverser le sketch fourni avec le plugin.");
if (substr(jeedom::version(), 0, 1) == 2) {
event::add('jeedom::alert', array('level' => 'error', 'message' => __("Un ou plusieurs Arduino n\\'ont pas la version du sketch requise ! Veuillez téléverser le sketch fourni avec le plugin.", __FILE__)));
}
return false;
}
} else {
if ($_debug) {
log::add('arduidom', 'info', 'Skipping python program, no USB arduino configured.');
}
}
//// Verifications, SetPin, RestoreStates
$errorCounter = 0;
$nbArduinos = intval(config::byKey("ArduinoQty", "arduidom", 1));
self::set_daemon_mode("STARTED");
// necessaire pour le restorestates
for ($d = 1; $d <= $nbArduinos; $d++) {
$result = self::setPinMapping($d);
if ($result != "OK") {
$errorCounter += 1;
}
log::add('arduidom', 'debug', 'arduino ' . $d . ' : Pin Mapping = ' . $result);
$result = self::restoreStates($d);
if ($result != "OK") {
$errorCounter += 1;
}
log::add('arduidom', 'debug', 'arduino ' . $d . ' : Restore State = ' . $result);
}
if ($errorCounter > 0) {
self::set_daemon_mode("ERROR");
log::add('arduidom', 'error', $errorCounter . ' Erreur(s) pendant le lancement du démon...');
return false;
}
self::set_daemon_mode("OK");
message::removeAll('arduidom', 'unableStartDeamon');
log::add('arduidom', 'info', 'Démon arduidom lancé sans erreur.');
return true;
}