예제 #1
0
 if (init('action') == 'toggle') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $plugin = plugin::byId(init('id'));
     if (!is_object($plugin)) {
         throw new Exception(__('Plugin introuvable : ', __FILE__) . init('id'));
     }
     $plugin->setIsEnable(init('state'));
     ajax::success();
 }
 if (init('action') == 'all') {
     if (!isConnect()) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     ajax::success(utils::o2a(plugin::listPlugin()));
 }
 if (init('action') == 'pluginupload') {
     $uploaddir = dirname(__FILE__) . '/../../tmp';
     if (!file_exists($uploaddir)) {
         mkdir($uploaddir);
     }
     if (!file_exists($uploaddir)) {
         throw new Exception(__('Répertoire d\'upload non trouvé : ', __FILE__) . $uploaddir);
     }
     if (!isset($_FILES['file'])) {
         throw new Exception(__('Aucun fichier trouvé. Vérifié parametre PHP (post size limit)', __FILE__));
     }
     $extension = strtolower(strrchr($_FILES['file']['name'], '.'));
     if (!in_array($extension, array('.zip'))) {
         throw new Exception('Extension du fichier non valide (autorisé .zip) : ' . $extension);
예제 #2
0
파일: cmd.class.php 프로젝트: jimibi/core
 public function toHtml($_version = 'dashboard', $options = '', $_cmdColor = null, $_cache = 2)
 {
     $version = jeedom::versionAlias($_version);
     $html = '';
     $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.' . $this->getTemplate($version, 'default');
     $template = '';
     if (!isset(self::$_templateArray[$version . '::' . $template_name])) {
         if ($this->getTemplate($version, 'default') != 'default') {
             if (config::byKey('active', 'widget') == 1) {
                 $template = getTemplate('core', $version, $template_name, 'widget');
             }
             if ($template == '') {
                 foreach (plugin::listPlugin(true) as $plugin) {
                     $template = getTemplate('core', $version, $template_name, $plugin->getId());
                     if ($template != '') {
                         break;
                     }
                 }
             }
             if ($template == '') {
                 $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.default';
                 $template = getTemplate('core', $version, $template_name);
             }
         } else {
             $template = getTemplate('core', $version, $template_name);
         }
         self::$_templateArray[$version . '::' . $template_name] = $template;
     } else {
         $template = self::$_templateArray[$version . '::' . $template_name];
     }
     $replace = array('#id#' => $this->getId(), '#name#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#name_display#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#history#' => '', '#displayHistory#' => 'display : none;', '#unite#' => $this->getUnite(), '#minValue#' => $this->getConfiguration('minValue', 0), '#maxValue#' => $this->getConfiguration('maxValue', 100), '#logicalId#' => $this->getLogicalId());
     if ($_cmdColor == null && $version != 'scenario') {
         $eqLogic = $this->getEqLogic();
         $vcolor = $version == 'mobile' ? 'mcmdColor' : 'cmdColor';
         if ($eqLogic->getPrimaryCategory() == '') {
             $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:default:' . $vcolor);
         } else {
             $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:' . $eqLogic->getPrimaryCategory() . ':' . $vcolor);
         }
     } else {
         $replace['#cmdColor#'] = $_cmdColor;
     }
     if ($this->getDisplay('doNotShowNameOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) {
         $replace['#name_display#'] = '';
         $replace['#name#'] = '';
     } else {
         if ($this->getDisplay('doNotShowNameOnDashboard') == 1 && ($_version == 'mobile' || $_version == 'dashboard')) {
             $replace['#name_display#'] = '';
             $replace['#name#'] = '';
         } else {
             $replace['#name_display#'] .= '<br/>';
         }
     }
     if ($this->getType() == 'info') {
         $replace['#state#'] = '';
         $replace['#tendance#'] = '';
         $replace['#state#'] = $this->execCmd(null, $_cache);
         if (strpos($replace['#state#'], 'error::') !== false) {
             $template = getTemplate('core', $version, 'cmd.error');
             $replace['#state#'] = str_replace('error::', '', $replace['#state#']);
         } else {
             if ($this->getSubType() == 'binary' && $this->getDisplay('invertBinary') == 1) {
                 $replace['#state#'] = $replace['#state#'] == 1 ? 0 : 1;
             }
         }
         if (method_exists($this, 'formatValueWidget')) {
             $replace['#state#'] = $this->formatValueWidget($replace['#state#']);
         }
         $replace['#collectDate#'] = $this->getCollectDate();
         $replace['#valueDate#'] = $this->getValueDate();
         if ($this->getIsHistorized() == 1) {
             $replace['#history#'] = 'history cursor';
             if (config::byKey('displayStatsWidget') == 1 && strpos($template, '#displayHistory#') !== false) {
                 $showStat = true;
                 if ($this->getDisplay('doNotShowStatOnDashboard') == 1 && $_version == 'dashboard') {
                     $showStat = false;
                 }
                 if ($this->getDisplay('doNotShowStatOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) {
                     $showStat = false;
                 }
                 if ($this->getDisplay('doNotShowStatOnMobile') == 1 && $_version == 'mobile') {
                     $showStat = false;
                 }
                 if ($showStat) {
                     $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculPeriod') . ' hour'));
                     $replace['#displayHistory#'] = '';
                     $historyStatistique = $this->getStatistique($startHist, date('Y-m-d H:i:s'));
                     if ($historyStatistique['avg'] == 0 && $historyStatistique['min'] == 0 && $historyStatistique['max'] == 0) {
                         $replace['#averageHistoryValue#'] = round($replace['#state#'], 1);
                         $replace['#minHistoryValue#'] = round($replace['#state#'], 1);
                         $replace['#maxHistoryValue#'] = round($replace['#state#'], 1);
                     } else {
                         $replace['#averageHistoryValue#'] = round($historyStatistique['avg'], 1);
                         $replace['#minHistoryValue#'] = round($historyStatistique['min'], 1);
                         $replace['#maxHistoryValue#'] = round($historyStatistique['max'], 1);
                     }
                     $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculTendance') . ' hour'));
                     $tendance = $this->getTendance($startHist, date('Y-m-d H:i:s'));
                     if ($tendance > config::byKey('historyCalculTendanceThresholddMax')) {
                         $replace['#tendance#'] = 'fa fa-arrow-up';
                     } else {
                         if ($tendance < config::byKey('historyCalculTendanceThresholddMin')) {
                             $replace['#tendance#'] = 'fa fa-arrow-down';
                         } else {
                             $replace['#tendance#'] = 'fa fa-minus';
                         }
                     }
                 }
             }
         }
         $parameters = $this->getDisplay('parameters');
         if (is_array($parameters)) {
             foreach ($parameters as $key => $value) {
                 $replace['#' . $key . '#'] = $value;
             }
         }
         return template_replace($replace, $template);
     } else {
         $cmdValue = $this->getCmdValue();
         if (is_object($cmdValue) && $cmdValue->getType() == 'info') {
             $replace['#state#'] = $cmdValue->execCmd(null, 2);
             $replace['#valueName#'] = $cmdValue->getName();
             $replace['#unite#'] = $cmdValue->getUnite();
         } else {
             $replace['#state#'] = $this->getLastValue() != null ? $this->getLastValue() : '';
             $replace['#valueName#'] = $this->getName();
             $replace['#unite#'] = $this->getUnite();
         }
         $parameters = $this->getDisplay('parameters');
         if (is_array($parameters)) {
             foreach ($parameters as $key => $value) {
                 $replace['#' . $key . '#'] = $value;
             }
         }
         $replace['#valueName#'] .= '<br/>';
         $html .= template_replace($replace, $template);
         if (trim($html) == '') {
             return $html;
         }
         if ($options != '') {
             $options = jeedom::toHumanReadable($options);
             if (is_json($options)) {
                 $options = json_decode($options, true);
             }
             if (is_array($options)) {
                 foreach ($options as $key => $value) {
                     $replace['#' . $key . '#'] = $value;
                 }
             }
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'message') {
             if (!isset($replace['#title#'])) {
                 $replace['#title#'] = '';
             }
             if (!isset($replace['#message#'])) {
                 $replace['#message#'] = '';
             }
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#slider#'])) {
             $replace['#slider#'] = '';
         }
         if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#color#'])) {
             $replace['#color#'] = '';
         }
         $replace['#title_placeholder#'] = $this->getDisplay('title_placeholder', __('Titre', __FILE__));
         $replace['#message_placeholder#'] = $this->getDisplay('message_placeholder', __('Message', __FILE__));
         $replace['#message_disable#'] = $this->getDisplay('message_disable', 0);
         $replace['#title_disable#'] = $this->getDisplay('title_disable', 0);
         $replace['#title_possibility_list#'] = $this->getDisplay('title_possibility_list', '');
         $replace['#slider_placeholder#'] = $this->getDisplay('slider_placeholder', __('Valeur', __FILE__));
         $html = template_replace($replace, $html);
         return $html;
     }
 }
예제 #3
0
 * 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 (init('action') == 'getInfoApplication') {
        if (!isConnect()) {
            throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234);
        }
        $_SESSION['user']->refresh();
        $return = array();
        $return['user_id'] = $_SESSION['user']->getId();
        $return['nodeJsKey'] = config::byKey('nodeJsKey');
        $return['userProfils'] = $_SESSION['user']->getOptions();
        $return['plugins'] = array();
        foreach (plugin::listPlugin(true) as $plugin) {
            if ($plugin->getMobile() != '') {
                $return['plugins'][] = utils::o2a($plugin);
            }
        }
        $return['custom'] = array();
        $return['custom']['js'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.js');
        $return['custom']['css'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.css');
        ajax::success($return);
    }
    if (!isConnect('admin')) {
        throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234);
    }
    if (init('action') == 'ssh') {
        ajax::success(shell_exec(init('command')));
    }
예제 #4
0
파일: profils.php 프로젝트: saez0pub/core
<?php

if (!isConnect()) {
    throw new Exception('{{Error 401 Unauthorized');
}
$notifyTheme = array('info' => '{{Bleu}}', 'error' => '{{Rouge}}', 'success' => '{{Vert}}', 'warning' => '{{Jaune}}');
$homePage = array('core::dashboard' => '{{Dashboard}}', 'core::view' => '{{Vue}}', 'core::plan' => '{{Design}}');
foreach (plugin::listPlugin() as $pluginList) {
    if ($pluginList->isActive() == 1 && $pluginList->getDisplay() != '') {
        $homePage[$pluginList->getId() . '::' . $pluginList->getDisplay()] = $pluginList->getName();
    }
}
?>
<legend>{{Profil}}</legend>

<div class="panel-group" id="accordionConfiguration">
    <input style="display: none;" class="userAttr form-control" data-l1key="id" />
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionConfiguration" href="#config_themes">
                    Thèmes
                </a>
            </h3>
        </div>
        <div id="config_themes" class="panel-collapse collapse in">
            <div class="panel-body">
                <form class="form-horizontal">
                    <fieldset>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">{{Desktop}}</label>
예제 #5
0
파일: index.php 프로젝트: GaelGRIFFON/core
            $homeLink .= '&fullscreen=1';
        }
    } else {
        $homeLink = 'index.php?v=d&p=dashboard';
    }
}
$title = 'Jeedom';
if (init('p') == '' && isConnect()) {
    redirect($homeLink);
}
$page = '';
if (isConnect() && init('p') != '') {
    $page = init('p');
    $title = ucfirst($page) . ' - ' . $title;
}
$plugins_list = plugin::listPlugin(true, true);
$plugin_menu = '';
$panel_menu = '';
if (count($plugins_list) > 0) {
    foreach ($plugins_list as $category_name => $category) {
        $icon = '';
        if (isset($JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]) && isset($JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]['icon'])) {
            $icon = $JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]['icon'];
        }
        $name = $category_name;
        if (isset($JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]) && isset($JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]['name'])) {
            $name = $JEEDOM_INTERNAL_CONFIG['plugin']['category'][$category_name]['name'];
        }
        $plugin_menu .= '<li class="dropdown-submenu"><a data-toggle="dropdown"><i class="fa ' . $icon . '"></i> {{' . $name . '}}</a>';
        $plugin_menu .= '<ul class="dropdown-menu">';
        foreach ($category as $pluginList) {
예제 #6
0
 public static function saveTicket($_ticket)
 {
     $jsonrpc = self::getJsonRpc();
     $_ticket['user_plugin'] = '';
     foreach (plugin::listPlugin() as $plugin) {
         $_ticket['user_plugin'] .= $plugin->getId();
         $update = $plugin->getUpdate();
         if (is_object($update)) {
             $_ticket['user_plugin'] .= '[' . $update->getConfiguration('version', 'stable') . ',' . $update->getLocalVersion() . ']';
         }
         $_ticket['user_plugin'] .= ',';
     }
     trim($_ticket['user_plugin'], ',');
     if (isset($_ticket['options']['page'])) {
         $_ticket['options']['page'] = substr($_ticket['options']['page'], strpos($_ticket['options']['page'], 'index.php'));
     }
     if (isset($_ticket['allowRemoteAccess']) && $_ticket['allowRemoteAccess'] == 1) {
         $user = user::createTemporary(72);
         $_ticket['options']['remoteAccess'] = 'Http : ' . $user->getDirectUrlAccess();
         if (config::byKey('market::allowDNS') == 1 && config::byKey('market::redirectSSH') == 1 && config::byKey('ngrok::port') != '') {
             $_ticket['options']['remoteAccess'] .= ' | SSH : dns.jeedom.com:' . config::byKey('ngrok::port');
         }
     }
     $_ticket['options']['jeedom_version'] = jeedom::version();
     if (!$jsonrpc->sendRequest('ticket::save', array('ticket' => $_ticket))) {
         throw new Exception($jsonrpc->getErrorMessage());
     }
     return $jsonrpc->getResult();
 }
예제 #7
0
 public static function loadTranslation()
 {
     $return = array();
     if (file_exists(self::getPathTranslationFile(self::getLanguage()))) {
         $return = file_get_contents(self::getPathTranslationFile(self::getLanguage()));
         if (is_json($return)) {
             $return = json_decode($return, true);
         } else {
             $return = array();
         }
         foreach (plugin::listPlugin(true, false, false) as $plugin) {
             $return = array_merge($return, $plugin->getTranslation(self::getLanguage()));
         }
     }
     return $return;
 }
예제 #8
0
    public static function findNewUpdateObject()
    {
        foreach (plugin::listPlugin() as $plugin) {
            $plugin_id = $plugin->getId();
            $update = self::byTypeAndLogicalId('plugin', $plugin_id);
            if (!is_object($update)) {
                $update = new update();
                $update->setLogicalId($plugin_id);
                $update->setType('plugin');
                $update->setLocalVersion(date('Y-m-d H:i:s'));
                $update->save();
            }
            $find = array();
            if (method_exists($plugin_id, 'listMarketObject')) {
                foreach ($plugin_id::listMarketObject() as $logical_id) {
                    $find[$logical_id] = true;
                    $update = self::byTypeAndLogicalId($plugin_id, $logical_id);
                    if (!is_object($update)) {
                        $update = new update();
                        $update->setLogicalId($logical_id);
                        $update->setType($plugin_id);
                        $update->setLocalVersion(date('Y-m-d H:i:s'));
                        $update->save();
                    }
                }
                foreach (self::byType($plugin_id) as $update) {
                    if (!isset($find[$update->getLogicalId()])) {
                        $update->remove();
                    }
                }
            } else {
                $values = array('type' => $plugin_id);
                $sql = 'DELETE FROM `update`
						WHERE type=:type';
                DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
            }
        }
    }