示例#1
0
文件: main.php 项目: gnlcosta/eTunnel
 function Index()
 {
     TemplVar('menu_left_active', -1);
     $str = file_get_contents(RootDir() . '/../../app.json');
     $appl = json_decode($str, true);
     ViewVar('cfg', FALSE);
     ViewVar('url', '');
     $post = TRUE;
     if (file_exists($this->cfg_file)) {
         $str = file_get_contents($this->cfg_file);
         $cfg = json_decode($str, true);
         if (isset($cfg['idn'])) {
             $post = FALSE;
             ViewVar('idn', $cfg['idn']);
             ViewVar('cfg', TRUE);
         }
         if (isset($cfg['scheme'])) {
             ViewVar('url', $cfg['scheme'] . '://' . $cfg['host'] . $cfg['path']);
         }
     }
     if ($post && $_SERVER['REQUEST_METHOD'] == 'POST') {
         $_POST = EsSanitize($_POST);
         if (isset($_POST['url'])) {
             $url = parse_url($_POST['url']);
             if ($url['scheme'] == null) {
                 EsMessage(_('Errore, URL errato'));
                 EsRedir('main');
             }
             $cfg['scheme'] = $url['scheme'];
             $cfg['host'] = $url['host'];
             if ($url['port'] != null) {
                 $cfg['host'] .= ':' . $url['port'];
             }
             if ($url['path'] == null) {
                 $cfg['path'] = '';
             } else {
                 $cfg['path'] = $url['path'];
             }
             $file = fopen($this->cfg_file, 'w');
             if ($file !== FALSE) {
                 fwrite($file, json_encode($cfg));
                 fclose($file);
                 EsMessage(_('Impostazioni salvate'));
             } else {
                 EsMessage(_('Errore nel salvataggio delle impostazioni'));
             }
             EsRedir('main');
         }
     }
     if (!isset($cfg['sn'])) {
         $sn = '---';
     } else {
         $sn = $cfg['sn'];
     }
     ViewVar('sn', $sn);
     ViewVar('appl', $appl);
 }
示例#2
0
文件: user.php 项目: gnlcosta/eTunnel
 function Add()
 {
     if ($this->usr_type == 3) {
         EsMessage(_('Acesso negato'));
         EsRedir('main');
     }
     TemplVar('title', 'Nuovo Utente');
     TemplVar('menu_left_active', 1);
     $types = $this->users->Types($this->usr_type);
     ViewVar('types', $types);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (isset($_POST['user']) && isset($_POST['password']) && isset($_POST['type'])) {
             $new = array();
             $new['user'] = EsSanitize($_POST['user']);
             $new['password'] = password_hash(EsSanitize($_POST['password'], PASSWORD_DEFAULT));
             $udata = $this->users->Search($new['user']);
             if ($udata !== FALSE) {
                 EsMessage(_('Nome Utente già presente'));
             } else {
                 if (!is_numeric($_POST['type']) || $_POST['type'] < $this->usr_type) {
                     EsMessage(_('Tipo utente non valido'));
                 } else {
                     if ($_POST['email'] != '' && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
                         EsMessage(_('Indirizzo email non valido'));
                     } else {
                         $new['email'] = $_POST['email'];
                         $new['type'] = $_POST['type'];
                         $this->users->Add($new);
                         EsRedir('user');
                     }
                 }
             }
         } else {
             EsMessage(_('Nome Utente e Password sono necessari'));
         }
     }
 }
示例#3
0
文件: main.php 项目: gnlcosta/eTunnel
 function NodeAdd()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $_POST = EsSanitize($_POST);
         $reg = $this->RegNodes();
         $data = $this->NodeCheck($_POST);
         if ($data == FALSE || !isset($_POST['sn']) || !isset($reg[$_POST['sn']])) {
             EsRedir('main', 'regist_list');
         }
         $idn = md5($_POST['sn'] . time());
         $enckey = md5($idn . time());
         $master_enckey = '';
         $this->nodes->Add($_POST['name'], $_POST['descrip'], $_POST['sn'], $idn, $enckey, $master_enckey, $_POST['phone']);
         EsMessage(_("Nodo Aggiunto"));
         EsRedir('main', 'nodes_list');
     } else {
         if (!isset($_GET['sn'])) {
             EsRedir('user', 'regist_list');
         }
         ViewVar('sn', $_GET['sn']);
     }
 }