public function set_user($network_id, $user_id)
 {
     $this->network = FALSE;
     $this->user = FALSE;
     $n = new network();
     if (!$n->LOAD_by_id($network_id)) {
         return FALSE;
     }
     if (!($u = $n->get_user_by_id($user_id))) {
         return FALSE;
     }
     $this->network = $n;
     $this->user = $u;
     return TRUE;
 }
示例#2
0
文件: epochs.class.php 项目: 0-php/AI
 function clearHistory($id, $user)
 {
     Model::loadProxy("network");
     if (network::validate($id)) {
         db::init()->query("epoch.clear", array("id" => $_GET['n']));
     }
 }
示例#3
0
 public static function initializeLocation($accountId, $options)
 {
     // Figure out the proper domain name. We could do a lot more here...
     // Is this a real domain name? If not, use the IP address instead, by default, or initial setup is a pain
     $domain = isset($options['domain']) ? $options['domain'] : network::guessServerIP();
     $location = new Location();
     $location['account_id'] = $accountId;
     $location['name'] = isset($options['name']) ? $options['name'] : 'Main Location';
     $location['domain'] = $domain;
     $location->save();
     return $location->location_id;
 }
示例#4
0
 protected function prepareUpdateView()
 {
     $allowList = empty($_POST['ips']['allow']) ? array() : array_flip($_POST['ips']['allow']);
     $denyList = empty($_POST['ips']['deny']) ? array() : array_flip($_POST['ips']['deny']);
     $options = array('127.0.0.1/32' => '127.0.0.1 (Loopback)', '10.0.0.0/8' => '10.0.0.0 - 10.255.255.255 (Private Network)', '172.16.0.0/12' => '172.16.0.0 - 172.31.255.255 (Private Network)', '192.168.0.0/16' => '192.168.0.0 - 192.168.255.255 (Private Network)');
     $allListItems = Doctrine::getTable('NetListItem')->findAll();
     foreach ($allListItems as $item) {
         $cidr = $item['record'];
         $range = network::cidr2range($cidr);
         if (empty($range)) {
             $description = $cidr;
         } else {
             if ($range['start'] == $range['end']) {
                 $description = $range['start'];
             } else {
                 $description = $range['start'] . ' - ' . $range['end'];
             }
         }
         if (!empty($item['description'])) {
             $description .= ' (' . $item['description'] . ')';
         }
         // all net lists go into the options list
         $options[$cidr] = $description;
         // check if it is in the selected list
         if ($this->netlist['net_list_id'] == $item['net_list_id']) {
             if (empty($item['allow'])) {
                 $denyList[$cidr] = $description;
             } else {
                 $allowList[$cidr] = $description;
             }
         }
     }
     $this->view->netListItems = array_unique($options);
     $this->view->netListAllow = array_keys($allowList);
     $this->view->netListDeny = array_keys($denyList);
     parent::prepareUpdateView();
 }
示例#5
0
 /**
  * @param array $mixed
  * @param array $mixed['obj']:             required - Tipo di media da validare (mediaType).
  * @param array $mixed['objId']:           required - Id del media da validare (mediaId).
  * @param array $mixed['userId']:          optional - Id dell'utente del quale verificare la visibilità.
  * @param array $mixed['cerebrumGroupId']: optional - Id del gruppo dell'utente del quale verificare la visibilità.
  * @param array $mixed['subGroupId']:      optional - Id del sottogruppo dell'utente del quale verificare la visibilità.
  */
 public function __construct(array $mixed = array())
 {
     // Verifica che il mediaId sia un intero valido, in caso contrario esce.
     if (!($this->mediaId = filter_var($mixed['objId'], FILTER_VALIDATE_INT))) {
         exit("[" . __METHOD__ . "] Invalid objId '" . $mixed['objId'] . "'.");
     }
     // Eseguo la validazione del campo mediaType
     if (!($this->mediaType = filter_var($mixed['obj'], FILTER_SANITIZE_STRING)) || !defined('media_type::' . $mixed['obj'])) {
         exit("[" . __METHOD__ . "] Invalid obj '" . $mixed['obj'] . "'.");
     }
     // Verifica che il userId sia un intero valido, in caso contrario utilizza quello dell'utente.
     if (!($this->userId = filter_var($mixed['userId'], FILTER_VALIDATE_INT))) {
         $this->userId = my_id();
     }
     // Verifica che il cerebrumGroupId sia un intero valido, in caso contrario utilizza quello dell'utente.
     if (!($this->cerebrumGroupId = filter_var($mixed['cerebrumGroupId'], FILTER_VALIDATE_INT))) {
         $this->cerebrumGroupId = network::getMyGroupId();
     }
     // Verifica che il subGroupId sia un intero valido, in caso contrario utilizza quello dell'utente.
     if (!($this->subGroupId = filter_var($mixed['subGroupId'], FILTER_VALIDATE_INT))) {
         $this->subGroupId = network::getMyNetworkSubgroups();
     }
     return $this;
 }
 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é');
 }
示例#7
0
 <div class="col-sm-6">
    <legend>DNS Jeedom</legend>
    <div class="alert alert-warning">{{Attention cette fonctionnalité n'est pas disponible dans le service pack community (voir votre service pack sur  votre page profils sur le market)}}</div>
    <div class="form-group">
        <label class="col-xs-4 control-label">{{Utiliser les DNS Jeedom}}</label>
        <div class="col-xs-8">
            <input type="checkbox" class="configKey bootstrapSwitch" data-l1key="market::allowDNS" />
        </div>
    </div>
    <div class="alert alert-info">{{Toute modification nécessite de redémarrer le service DNS Jeedom (ligne "Gestion" puis "Redémarrer")}}</div>
    <div class="form-group">
        <label class="col-xs-4 control-label">{{Statut http}}</label>
        <div class="col-xs-8">
            <?php 
if (config::byKey('market::allowDNS') == 1 && $externalTest) {
    echo '<span class="label label-success" style="font-size : 1em;">{{Démarré : }} <a href="' . network::getNetworkAccess('external') . '" target="_blank" style="color:white;text-decoration: underline;">' . network::getNetworkAccess('external') . '</a></span>';
} else {
    echo '<span class="label label-warning tooltips" title="{{Normal si vous n\'avez pas coché la case : Utiliser les DNS Jeedom}}">{{Arrêté}}</span>';
}
?>
       </div>
   </div>
   <div class="form-group">
       <label class="col-xs-4 control-label">{{Gestion}}</label>
       <div class="col-xs-8">
         <a class="btn btn-success" id="bt_restartNgrok"><i class='fa fa-play'></i> {{(Re)démarrer}}</a>
         <a class="btn btn-danger" id="bt_haltNgrok"><i class='fa fa-stop'></i> {{Arrêter}}</a>
     </div>

 </div>
</div>
 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é');
 }
示例#9
0
													<li><a href="index.php?v=d&logout=1"><i class="fa fa-sign-out"></i> {{Se déconnecter}}</a></li>
													<li class="divider"></li>
													<li><a href="#">{{Node JS}} <span class="span_nodeJsState binary red tooltips"></span></a></li>
													<li><a href="#" id="bt_jeedomAbout">{{Version}} v<?php 
    echo jeedom::version();
    ?>
</a></li>
												</ul>
											</li>

											<?php 
    if (network::ehtIsUp()) {
        echo '<li><a href="#"><i class="fa fa-sitemap tooltips" title="{{Connecté en filaire}}"></i></a></li>';
    }
    if (network::wlanIsUp()) {
        $signalStrength = network::signalStrength();
        if ($signalStrength !== '' && $signalStrength >= 0) {
            if ($signalStrength > 80) {
                echo '<li><a href="#"><i class="jeedom2-fdp1-signal5 tooltips" title="{{Connecté en wifi. Signal : ' . $signalStrength . '%}}"></i></a></li>';
            } else {
                if ($signalStrength > 60) {
                    echo '<li><a href="#"><i class="jeedom2-fdp1-signal4 tooltips" title="{{Connecté en wifi. Signal : ' . $signalStrength . '%}}"></i></a></li>';
                } else {
                    if ($signalStrength > 40) {
                        echo '<li><a href="#"><i class="jeedom2-fdp1-signal3 tooltips" title="{{Connecté en wifi. Signal : ' . $signalStrength . '%}}"></i></a></li>';
                    } else {
                        if ($signalStrength > 20) {
                            echo '<li><a href="#"><i class="jeedom2-fdp1-signal2 tooltips" title="{{Connecté en wifi. Signal : ' . $signalStrength . '%}}"></i></a></li>';
                        } else {
                            if ($signalStrength > 0) {
                                echo '<li><a href="#"><i class="jeedom2-fdp1-signal1 tooltips" title="{{Connecté en wifi. Signal : ' . $signalStrength . '%}}"></i></a></li>';
示例#10
0
        } catch (Exception $e) {
        }
    }
}
$urlMasterLocal = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterLocal = true;
    }
} catch (Exception $e) {
}
$urlMasterDistant = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:ip:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterDistant = true;
    }
} catch (Exception $e) {
}
?>
<form class="form-horizontal">
	<fieldset>
		<?php 
echo '<div class="form-group">';
echo '<label class="col-sm-4 control-label">{{Retour local}}</label>';
if (!$urlMasterLocal) {
    echo '<div class="col-sm-1"><span class="label label-danger tooltips" style="font-size : 1em;" title="{{Vérifiez votre configuration sur la page de configuration réseaux, celle-ci est incorrecte et le démon ne pourra communiquer avec Jeedom}}">NOK</span></div>';
} else {
示例#11
0
<?php

network::redirect('responsivecat.com', 'www.responsivecat.com', 301);
router::connect('default', 'rcat');
<?php

chdir(dirname(__FILE__));
require_once './helpers/func_main.php';
require_once './config.php';
session_start();
$db1 = new mysql($C->DB_HOST, $C->DB_USER, $C->DB_PASS, $C->DB_NAME);
$db2 =& $db1;
$network = new network();
$network->load();
$user = new user();
$user->load();
$page = new page();
$page->load();
示例#13
0
        	<br/><br/>

        	<?php 
$hdd = new hddPercentage();
$storagepercentage = $hdd->freeStorage();
?>
        	
        	<div class="clear"></div>
        	
        	<br/><br/>        	
            
            <?php 
//$net = networkUsage(); echo "Received: ".$net['rx']." Megabytes Sent: ".$net['tx']." Megabytes Total: ".($net['rx']+$net['tx'])." Megabytes";
?>
            <?php 
$network = new network();
$networkUseage = $network->networkUsage();
?>

            <div class="clear"></div>
        	
        	<br/><br/>

        	<?php 
$users = new usersLoggedIn();
$getusers = $users->getusersLoggedIn();
?>
       	</div>
       	<br/><br/>
    </div>
    
示例#14
0
			<td style="font-weight : bold;">{{Configuration réseaux interne}}</td>
			<?php 
if (network::test('internal')) {
    echo '<td class="alert alert-success">{{OK}}</td>';
    echo '<td></td>';
} else {
    echo '<td class="alert alert-danger">{{NOK}}</td>';
    echo '<td>{{Allez sur Général -> Administration -> Configuration puis configurez correctement la partie réseaux}}</td>';
}
?>
		</tr>

		<tr>
			<td style="font-weight : bold;">{{Configuration réseaux externe}}</td>
			<?php 
if (network::test('external')) {
    echo '<td class="alert alert-success">{{OK}}</td>';
    echo '<td></td>';
} else {
    echo '<td class="alert alert-danger">{{NOK}}</td>';
    echo '<td>{{Allez sur Général -> Administration -> Configuration puis configurez correctement la partie réseaux}}</td>';
}
?>
		</tr>
<!--
		<tr>
			<td style="font-weight : bold;">{{Configuration nginx}}</td>
			<?php 
if (exec('diff /etc/nginx/sites-available/default ' . dirname(__FILE__) . '/../../install/nginx_default | wc -l') == 0 || exec('diff /etc/nginx/sites-available/default ' . dirname(__FILE__) . '/../../install/nginx_default_without_jeedom | wc -l') == 0) {
    echo '<td class="alert alert-success">{{OK}}</td>';
    echo '<td></td>';
示例#15
0
        <div class="col-sm-9">
         <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Activer}}" data-l1key="isEnable" checked/>
         <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Visible}}" data-l1key="isVisible" checked/>
       </div>
     </div>
     <div class="form-group">
     <label class="col-sm-3 control-label">{{Domaine}}</label>
      <div class="col-sm-3">
        <input type="text" class="eqLogicAttr form-control" data-l1key="logicalId" placeholder="{{Nom du domaine}}"/>
      </div>
    </div>
    <div class="form-group">
      <label class="col-lg-3 control-label">{{URL de retour}}</label>
      <div class="col-lg-9">
        <span><?php 
echo network::getNetworkAccess('external') . '/plugins/slack/core/php/jeeSlack.php?apikey=' . config::byKey('api');
?>
</span>
      </div>
    </div>
  </fieldset>
</form>

<legend>{{Commande}}</legend>
<a class="btn btn-success btn-sm cmdAction" data-action="add"><i class="fa fa-plus-circle"></i> {{Ajouter une commande}}</a><br/><br/>
<table id="table_cmd" class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>{{Nom}}</th><th>{{Webhook}}</th><th>{{Destination}}</th><th>{{Options}}</th>
    </tr>
  </thead>
示例#16
0
/**
 * Lesli Framework
 *
 * This program 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.
 *
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * PHP Version 5
 *
 * @category Starter
 * @package  LesliFramework
 * @author   Luis Gdonis <*****@*****.**>
 * @license  GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
 * @version  GIT: 2.0.0.0-alpha
 * @link     http://lesli.ldonis.com
 */
// *  Zona horaria
date_default_timezone_set('America/Guatemala');
// *  Configuración de la red (network)
network::connect('localhost', 'mywebsite.com');
network::connect('127.0.0.1', 'mywebsite.com');
示例#17
0
                    <label class="col-sm-4 control-label">{{Ne pas utiliser le widget spécifique}}</label>
                    <div class="col-sm-1">
                    <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-l1key="configuration" data-l2key="noSpecifyWidget" />
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <div class="col-sm-6">

    </div>
</div>

<legend>Commandes</legend>
<div class="alert alert-info">Exemple d’URL à appeler avec tasker : <?php 
echo network::getNetworkAccess('external');
?>
/core/api/jeeApi.php?api=<?php 
echo config::byKey('api');
?>
&type=geoloc&id=#ID_CMD#&value=%LOCN</div>
<a class="btn btn-success btn-sm cmdAction" data-action="add"><i class="fa fa-plus-circle"></i> {{Commandes}}</a><br/><br/>
<table id="table_cmd" class="table table-bordered table-condensed">
    <thead>
        <tr>
            <th style="width: 50px;">{{ID}}</th>
            <th style="width: 200px;">{{Nom}}</th>
            <th style="width: 200px;">{{Type}}</th>
            <th>{{Options}}</th>
            <th style="width: 100px;">{{Paramètres}}</th>
            <th style="width: 150px;"></th>
示例#18
0
                network::dns_start();
                $jsonrpc->makeSuccess();
            }
            if ($jsonrpc->getMethod() == 'network::stopNgrok') {
                config::save('market::allowDNS', 0);
                network::dns_stop();
                $jsonrpc->makeSuccess();
            }
            if ($jsonrpc->getMethod() == 'network::ngrokRun') {
                if (!isset($params['proto'])) {
                    $params['proto'] = 'https';
                }
                if (!isset($params['port'])) {
                    $params['port'] = 80;
                }
                if (!isset($params['name'])) {
                    $params['name'] = '';
                }
                $jsonrpc->makeSuccess(network::dns_run());
            }
            /*             * ************************************************************************ */
        }
        throw new Exception('Aucune méthode correspondante : ' . $jsonrpc->getMethod(), -32500);
        /*         * *********Catch exeption*************** */
    } catch (Exception $e) {
        $message = $e->getMessage();
        $jsonrpc = new jsonrpc(init('request'));
        $errorCode = is_numeric($e->getCode()) ? -32000 - $e->getCode() : -32599;
        $jsonrpc->makeError($errorCode, $message);
    }
}
示例#19
0
 /**
  * Imposta la proprietà indicata.
  *
  * @param int $ID
  * @return \media_quota
  */
 public function setSubGroupId($ID)
 {
     // Verifica che userId sia un intero valido, in caso contrario esce.
     if (!($this->subGroupId = filter_var($ID, FILTER_VALIDATE_INT))) {
         $this->subGroupId = network::getMyNetworkSubGroups();
     }
     return $this;
 }
示例#20
0
 public static function checkAndCollect()
 {
     try {
         if (date('Gi') >= 500 && date('Gi') < 505) {
             history::archive();
         }
     } catch (Exception $e) {
         log::add('history', 'error', 'history::archive : ' . $e->getMessage());
     }
     try {
         network::cron();
     } catch (Exception $e) {
         log::add('network', 'error', 'network::cron : ' . $e->getMessage());
     }
     try {
         eqLogic::checkAlive();
         connection::cron();
         if (config::byKey('jeeNetwork::mode') != 'slave') {
             jeeNetwork::pull();
         }
     } catch (Exception $e) {
     }
     try {
         cmd::collect();
     } catch (Exception $e) {
         log::add('cmd', 'error', 'cmd::collect : ' . $e->getMessage());
     }
     try {
         history::historize();
     } catch (Exception $e) {
         log::add('history', 'error', 'history::archive : ' . $e->getMessage());
     }
 }
示例#21
0
 public static function cron()
 {
     if (config::byKey('market::allowDNS') == 1 && !network::test('external', false, 120)) {
         network::dns_start();
     }
     if (config::byKey('network::disableMangement') == 1) {
         return;
     }
     if (!jeedom::isCapable('sudo')) {
         return;
     }
     try {
         $gws = self::checkGw();
         if (count($gws) == 0) {
             log::add('network', 'error', __('Aucune interface réseau trouvée, je redemarre tous les réseaux', __FILE__));
             exec('sudo service networking restart');
             return;
         }
         foreach ($gws as $iface => $gw) {
             if ($gw['ping'] != 'ok') {
                 if (strpos($iface, 'tun') !== false) {
                     continue;
                 }
                 if (strpos($iface, 'br0') !== false) {
                     continue;
                 }
                 log::add('network', 'error', __('La passerelle distante de l\'interface ', __FILE__) . $iface . __(' est injoignable, je la redemarre pour essayer de corriger', __FILE__));
                 exec('sudo ifdown ' . $iface);
                 sleep(5);
                 exec('sudo ifup --force ' . $iface);
             }
         }
     } catch (Exception $e) {
     }
 }
示例#22
0
 public static function setTags($_expression, &$_scenario = null, $_quote = false, $_nbCall = 0)
 {
     if ($_nbCall > 10) {
         return $_expression;
     }
     $replace1 = array('#seconde#' => (int) date('s'), '#heure#' => (int) date('G'), '#minute#' => (int) date('i'), '#jour#' => (int) date('d'), '#mois#' => (int) date('m'), '#annee#' => (int) date('Y'), '#time#' => date('Gi'), '#timestamp#' => time(), '#seconde#' => (int) date('s'), '#date#' => date('md'), '#semaine#' => date('W'), '#sjour#' => '"' . date_fr(date('l')) . '"', '#smois#' => '"' . date_fr(date('F')) . '"', '#njour#' => (int) date('w'), '#hostname#' => '"' . gethostname() . '"', '#IP#' => '"' . network::getNetworkAccess('internal', 'ip') . '"', '#trigger#' => '');
     if (is_object($_scenario)) {
         $cmd = cmd::byId(str_replace('#', '', $_scenario->getRealTrigger()));
         if (is_object($cmd)) {
             $replace1['#trigger#'] = $cmd->getHumanName();
         } else {
             $replace1['#trigger#'] = $_scenario->getRealTrigger();
         }
     }
     if ($_scenario != null) {
         $replace1 = array_merge($replace1, $_scenario->getTags());
     }
     $replace2 = array();
     preg_match_all("/([a-zA-Z][a-zA-Z_]*?)\\((.*?)\\)/", $_expression, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $function = $match[1];
         $replace_string = $match[0];
         if (substr_count($match[2], '(') != substr_count($match[2], ')')) {
             $pos = strpos($_expression, $match[2]) + strlen($match[2]);
             while (substr_count($match[2], '(') > substr_count($match[2], ')')) {
                 $match[2] .= $_expression[$pos];
                 $pos++;
                 if ($pos > strlen($_expression)) {
                     break;
                 }
             }
             $arguments = self::setTags($match[2], $_scenario, $_quote, $_nbCall++);
             $result = str_replace($match[2], $arguments, $_expression);
             while (substr_count($result, '(') > substr_count($result, ')')) {
                 $result .= ')';
             }
             $result = self::setTags($result, $_scenario, $_quote, $_nbCall++);
             return cmd::cmdToValue(str_replace(array_keys($replace1), array_values($replace1), $result), $_quote);
         } else {
             $arguments = explode(',', $match[2]);
         }
         if (method_exists(__CLASS__, $function)) {
             if ($function == 'trigger') {
                 if (!isset($arguments[0])) {
                     $arguments[0] = '';
                 }
                 $replace2[$replace_string] = self::trigger($arguments[0], $_scenario, $_quote);
             } else {
                 $replace2[$replace_string] = call_user_func_array(__CLASS__ . "::" . $function, $arguments);
             }
         } else {
             if (function_exists($function)) {
                 foreach ($arguments as &$argument) {
                     $argument = evaluate(self::setTags($argument, $_scenario, $_quote));
                 }
                 $replace2[$replace_string] = call_user_func_array($function, $arguments);
             }
         }
     }
     return cmd::cmdToValue(str_replace(array_keys($replace1), array_values($replace1), str_replace(array_keys($replace2), array_values($replace2), $_expression)), $_quote);
 }
示例#23
0
文件: cmd.class.php 项目: jimibi/core
 public function getDirectUrlAccess()
 {
     $url = '/core/api/jeeApi.php?apikey=' . config::byKey('api') . '&type=cmd&id=' . $this->getId();
     if ($this->getType() == 'action') {
         switch ($this->getSubType()) {
             case 'slider':
                 $url .= '&slider=50';
                 break;
             case 'color':
                 $url .= '&color=#123456';
                 break;
             case 'message':
                 $url .= '&title=montitre&message=monmessage';
                 break;
         }
     }
     return network::getNetworkAccess('external') . $url;
 }
示例#24
0
 */
try {
    require_once dirname(__FILE__) . '/../../core/php/core.inc.php';
    include_file('core', 'authentification', 'php');
    if (!isConnect('admin')) {
        throw new Exception(__('401 - Accès non autorisé', __FILE__));
    }
    if (init('action') == 'restartNgrok') {
        config::save('market::allowDNS', 1);
        if (network::dns_run()) {
            network::dns_stop();
        }
        network::dns_start();
        ajax::success();
    }
    if (init('action') == 'stopNgrok') {
        config::save('market::allowDNS', 0);
        network::dns_stop();
        ajax::success();
    }
    if (init('action') == 'listWifi') {
        ajax::success(network::listWifi());
    }
    if (init('action') == 'writeInterfaceFile') {
        ajax::success(network::writeInterfaceFile());
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
    ajax::error(displayExeption($e), $e->getCode());
}
示例#25
0
文件: LOADER.php 项目: chaobj001/tt
<?php

$SCRIPT_START_TIME = microtime(TRUE);
chdir(dirname(__FILE__));
require_once './helpers/func_main.php';
require_once './conf_system.php';
session_start();
$cache = new cache();
$db1 = new mysql($C->DB_HOST, $C->DB_USER, $C->DB_PASS, $C->DB_NAME);
$db2 =& $db1;
if (!$C->INSTALLED) {
    exit;
}
$network = new network();
$network->LOAD();
$user = new user();
$user->LOAD();
ob_start('ob_gzhandler', 6);
$page = new page();
$page->LOAD();
示例#26
0
<?php

echo form::open_section('Location Information');
?>

    <div class="field">
    <?php 
echo form::label('location[name]', 'Name:');
echo form::input('location[name]', isset($location['name']) ? $location['name'] : 'Main Location');
?>
    </div>

    <div class="field">
    <?php 
echo form::label('location[domain]', 'Domain:');
echo form::input('location[domain]', isset($location['domain']) ? $location['domain'] : network::guessServerIP());
?>
    </div>

    <div class="field">
    <?php 
echo form::label('location[registry][areacode]', 'Area code:');
echo form::input('location[registry][areacode]', isset($location['registry']['areacode']) ? $location['registry']['areacode'] : '');
?>
    </div>

<?php 
echo form::close_section();
 public static function removeNginxRedirection()
 {
     foreach (self::listServerZwave(false) as $zwave) {
         $urlPath = config::byKey('urlPath' . $zwave['id'], 'openzwave');
         $rules = array("location /" . $urlPath . "/ {\n");
         network::nginx_removeRule($rules);
         config::save('urlPath' . $zwave['id'], '', 'openzwave');
     }
 }
示例#28
0
 public static function postJsonRpc(&$_result)
 {
     if (is_array($_result)) {
         if (config::byKey('market::allowDNS') == 1) {
             $dnsRestart = false;
             if (isset($_result['register::ngrokAddr']) && config::byKey('ngrok::addr') != $_result['register::ngrokAddr']) {
                 config::save('ngrok::addr', $_result['register::ngrokAddr']);
                 $dnsRestart = true;
             }
             if (isset($_result['register::ngrokToken']) && config::byKey('ngrok::token') != $_result['register::ngrokToken']) {
                 config::save('ngrok::token', $_result['register::ngrokToken']);
                 $dnsRestart = true;
             }
             if ($dnsRestart) {
                 if (network::dns_run()) {
                     network::dns_stop();
                 }
                 network::dns_start();
             }
             if (isset($_result['jeedom::url']) && config::byKey('jeedom::url') != $_result['jeedom::url']) {
                 config::save('jeedom::url', $_result['jeedom::url']);
             }
         }
         if (isset($_result['register::ngrokAddr'])) {
             unset($_result['register::ngrokAddr']);
         }
         if (isset($_result['register::ngrokPort'])) {
             unset($_result['register::ngrokPort']);
         }
         if (isset($_result['register::ngrokToken'])) {
             unset($_result['register::ngrokToken']);
         }
         if (isset($_result['jeedom::url'])) {
             unset($_result['jeedom::url']);
         }
         if (isset($_result['register::hwkey_nok']) && $_result['register::hwkey_nok'] == 1) {
             config::save('jeedom::installKey', '');
         }
     }
 }
示例#29
0
 public function getDirectUrlAccess()
 {
     return network::getNetworkAccess('external') . '/core/php/authentification.php?login='******'&smdp=' . $this->getPassword();
 }
示例#30
0
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
require '../classes/_ram.php';
require '../classes/_pitemp.php';
require '../classes/_hdd.php';
require '../classes/_cpu.php';
require '../classes/_uptime.php';
require '../classes/_network.php';
require '../classes/_who.php';
echo '{';
echo '"uptime" : ';
$uptime = new systemUptime();
$getSystemUptime = $uptime->getSystemUptime(true);
echo ', "CPU" : ';
$load = new cpuLoad();
$getLoad = $load->getCpuLoad(true);
echo ', "memory" : {';
$ram = new ramPercentage();
$percentage = $ram->freeMemory(true);
echo ',';
$percentage = $ram->freeSwap(true);
echo '}, "storage" : ';
$hdd = new hddPercentage();
$storagepercentage = $hdd->freeStorage(true);
echo ',';
$network = new network();
$networkUseage = $network->networkUsage(true);
echo ', "users" : ';
$users = new usersLoggedIn();
$getusers = $users->getusersLoggedIn(true);
echo '}';