/** * switchUnderConstruction * * switches the under cunstruction setting * * @return boolean */ public function switchUnderConstruction() { if ($this->adminUser) { $config = new config(); $underConstruction = $config->getByType('under_construction'); $underConstruction = $underConstruction[0]; if ($underConstruction) { $config->remove('under_construction', $underConstruction); $config->add('under_construction', '0'); } else { $config->remove('under_construction', $underConstruction); $config->add('under_construction', '1'); } } return true; }
function remove() { $cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL')); if (is_object($cron)) { $cron->remove(); } config::remove('xPLDeamonCronId', 'xPL'); }
public function remove() { $cache = cache::byKey('market::info::' . $this->getLogicalId()); if (is_object($cache)) { $cache->remove(); } switch ($this->getType()) { case 'plugin': try { $plugin = plugin::byId($this->getLogicalId()); if (is_object($plugin)) { try { $plugin->setIsEnable(0); } catch (Exception $e) { } foreach (eqLogic::byType($this->getLogicalId()) as $eqLogic) { try { $eqLogic->remove(); } catch (Exception $e) { } } } config::remove('*', $this->getLogicalId()); } catch (Exception $e) { } try { $cibDir = dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId(); if (file_exists($cibDir)) { rrmdir($cibDir); } } catch (Exception $e) { } break; default: $type = $this->getType(); if (class_exists($type) && method_exists($type, 'removeFromMarket')) { $type::removeFromMarket($this); } break; } $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); if (is_object($update)) { $update->remove(); } }
$configRemove[] = array('key' => $value['key'], 'plugin' => $value['plugin']); } try { $update->save(); } catch (Exception $ex) { } } $sql = 'SELECT * FROM config WHERE `key` = "installVersionDate"'; $values = DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL); foreach ($values as $value) { $update = new update(); if ($value['plugin'] != '') { $update->setLogicalId($value['plugin']); $update->setLocalVersion($value['value']); $update->setType('plugin'); try { $update->save(); $configRemove[] = array('key' => "installVersionDate", 'plugin' => $value['plugin']); } catch (Exception $ex) { } } } foreach ($configRemove as $remove) { if (isset($remove['plugin'])) { config::remove($remove['key'], $remove['plugin']); } else { config::remove($remove['key']); } }
} } else { if (network::dns_run()) { network::dns_stop(); } } } } ajax::success(); } if (init('action') == 'removeKey') { $keys = init('key'); if ($keys == '') { throw new Exception(__('Aucune clef demandée', __FILE__)); } if (is_json($keys)) { $keys = json_decode($keys, true); $return = array(); foreach ($keys as $key => $value) { config::remove($key, init('plugin', 'core')); } } else { config::remove(init('key'), init('plugin', 'core')); } ajax::success(); } throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
public static function MigrateDatas() { //log::add('arduidom', 'debug', 'MigrateDatas() called' log::add('arduidom', 'info', "*************************************************************************"); log::add('arduidom', 'info', "* Début de la migration des données arduidom pour la mise a jour > 1.07 *"); log::add('arduidom', 'info', "*************************************************************************"); self::deamon_stop(); $model = config::byKey('model', 'arduidom'); if ($model == "uno" || $model == "duemilanove328" || $model == "leo" || $model == "nano168" || $model == "nano328") { for ($i = 0; $i < 100; $i++) { // Migration des configs de pins DIGI et ANA $tomigrate = 'pin::' . $i; $DataToMigrate = config::byKey($tomigrate, 'arduidom', ''); if ($DataToMigrate != '') { log::add('arduidom', 'info', "Migration de " . $tomigrate . " vers A1_" . $tomigrate . "..."); config::save('A1_' . $tomigrate, $DataToMigrate, 'arduidom'); log::add('arduidom', 'info', "Suppression de " . $tomigrate . "..."); config::remove($tomigrate, 'arduidom'); } } for ($i = 101; $i < 130; $i++) { // Migration des configs de pins DHT $tomigrate = 'pin::' . $i; $DataToMigrate = config::byKey($tomigrate, 'arduidom', ''); if ($DataToMigrate != '') { log::add('arduidom', 'info', "Migration de " . $tomigrate . " vers A1_" . 'pin::' . ($i + 400) . "..."); config::save('A1_' . 'pin::' . ($i + 400), $DataToMigrate, 'arduidom'); log::add('arduidom', 'info', "Suppression de " . $tomigrate . "..."); config::remove($tomigrate, 'arduidom'); } } } if ($model == "mega1280" || $model == "mega2560") { } if ($model == "due") { } $tomigrate = "port"; // Migration de la config du Port du 1er Arduino $DataToMigrate = config::byKey($tomigrate, 'arduidom', ''); if ($DataToMigrate != '') { log::add('arduidom', 'info', "Migration de " . $tomigrate . " vers A1_" . $tomigrate . "..."); $DataToMigrate = config::byKey($tomigrate, 'arduidom', 'none'); config::save('A1_' . $tomigrate, $DataToMigrate, 'arduidom'); config::save('A2_' . $tomigrate, "none", 'arduidom'); config::save('A3_' . $tomigrate, "none", 'arduidom'); config::save('A4_' . $tomigrate, "none", 'arduidom'); config::save('A5_' . $tomigrate, "none", 'arduidom'); config::save('A6_' . $tomigrate, "none", 'arduidom'); config::save('A7_' . $tomigrate, "none", 'arduidom'); config::save('A8_' . $tomigrate, "none", 'arduidom'); log::add('arduidom', 'info', "Suppression de " . $tomigrate . "..."); config::remove($tomigrate, 'arduidom'); } $tomigrate = "daemonip"; // Migration de la config du Daemon du 1er Arduino $DataToMigrate = config::byKey($tomigrate, 'arduidom', ''); if ($DataToMigrate != '') { //log::add('arduidom', 'info', "Migration de " . $tomigrate . " vers A1_" . $tomigrate . "..."); //$DataToMigrate = config::byKey($tomigrate, 'arduidom', 'none'); log::add('arduidom', 'info', "Suppression de " . $tomigrate . "..."); config::remove($tomigrate, 'arduidom'); } config::save('A1_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A2_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A3_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A4_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A5_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A6_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A7_' . $tomigrate, "127.0.0.1", 'arduidom'); config::save('A8_' . $tomigrate, "127.0.0.1", 'arduidom'); $tomigrate = "daemonenable"; // Migration de la config du StopDaemon du 1er Arduino config::save('A1_' . $tomigrate, 0, 'arduidom'); config::save('A2_' . $tomigrate, 0, 'arduidom'); config::save('A3_' . $tomigrate, 0, 'arduidom'); config::save('A4_' . $tomigrate, 0, 'arduidom'); config::save('A5_' . $tomigrate, 0, 'arduidom'); config::save('A6_' . $tomigrate, 0, 'arduidom'); config::save('A7_' . $tomigrate, 0, 'arduidom'); config::save('A8_' . $tomigrate, 0, 'arduidom'); $tomigrate = "model"; // Migration de la config du Modele du 1er Arduino $DataToMigrate = config::byKey($tomigrate, 'arduidom', ''); if ($DataToMigrate != '') { log::add('arduidom', 'info', "Migration de " . $tomigrate . " vers A1_" . $tomigrate . "..."); $DataToMigrate = config::byKey($tomigrate, 'arduidom', 'none'); config::save('A1_' . $tomigrate, $DataToMigrate, 'arduidom'); config::save('A2_' . $tomigrate, "", 'arduidom'); config::save('A3_' . $tomigrate, "", 'arduidom'); config::save('A4_' . $tomigrate, "", 'arduidom'); config::save('A5_' . $tomigrate, "", 'arduidom'); config::save('A6_' . $tomigrate, "", 'arduidom'); config::save('A7_' . $tomigrate, "", 'arduidom'); config::save('A8_' . $tomigrate, "", 'arduidom'); log::add('arduidom', 'info', "Suppression de " . $tomigrate . "..."); config::remove($tomigrate, 'arduidom'); } foreach (eqLogic::byType('arduidom') as $eqLogic) { // Migration des LogicalPin du 1er Arduino foreach ($eqLogic->getCmd() as $cmd) { if ($cmd->getLogicalId() < 101) { $newvalue = $cmd->getLogicalId() + 1000; log::add('arduidom', 'info', '$$MIGRATION$$ ' . $cmd->getLogicalId() . ' => ' . $newvalue . ' pour l equipement ' . $cmd->getHumanName()); $cmd->setLogicalId($newvalue); $cmd->save(); } if ($cmd->getLogicalId() > 100 && $cmd->getLogicalId() < 1000) { $newvalue = $cmd->getLogicalId() + 1400; log::add('arduidom', 'info', '$$MIGRATION$$ ' . $cmd->getLogicalId() . ' => ' . $newvalue . ' pour l equipement ' . $cmd->getHumanName()); $cmd->setLogicalId($newvalue); $cmd->save(); } } } $oldlogfile = realpath(dirname(__FILE__)) . '/../../../../log/arduidom_daemon'; log::add('arduidom', 'info', "Delete old log file " . $oldlogfile . " => " . unlink($oldlogfile)); config::save('db_version', 124, 'arduidom'); // Inscrit la version de migration dans la config log::add('arduidom', 'info', "Migration des données pour v1.08 Terminée."); self::deamon_start(); return 1; }