This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#8]
- Loading branch information
Showing
5 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
/** | ||
* Syncthing controller. | ||
* | ||
* @category apps | ||
* @package syncthing | ||
* @subpackage controllers | ||
* @author eGloo <developer@egloo.ca> | ||
* @copyright 2018 Avantech | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later | ||
* @link http://www.egloo.ca/clearos/marketplace/apps/syncthing | ||
*/ | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// 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/>. | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// B O O T S T R A P | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
$bootstrap = getenv('CLEAROS_BOOTSTRAP') ? getenv('CLEAROS_BOOTSTRAP') : '/usr/clearos/framework/shared'; | ||
require_once $bootstrap . '/bootstrap.php'; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// D E P E N D E N C I E S | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
use \clearos\apps\syncthing\Syncthing as SyncthingLibrary; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// C L A S S | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Syncthing controller. | ||
* | ||
* @category apps | ||
* @package syncthing | ||
* @subpackage controllers | ||
* @author eGloo <developer@egloo.ca> | ||
* @copyright 2018 Avantech | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later | ||
* @link http://www.egloo.ca/clearos/marketplace/apps/syncthing | ||
*/ | ||
|
||
class Access_Widget extends ClearOS_Controller | ||
{ | ||
/** | ||
* Syncthing users controller | ||
* | ||
* @return view | ||
*/ | ||
|
||
function index() | ||
{ | ||
// Load dependencies | ||
//------------------ | ||
|
||
$this->lang->load('syncthing'); | ||
$this->load->library('syncthing/Syncthing'); | ||
|
||
try { | ||
$data['status'] = $this->syncthing->get_users_config($this->session->userdata('username'))[$this->session->userdata('username')]; | ||
if ($data['gui_access'] != SyncthingLibrary::VIA_REVERSE_PROXY && !$this->syncthing->passwords_ok()) | ||
$data['gui_no_auth_warning'] = lang('syncthing_gui_no_auth'); | ||
$data['version'] = $this->syncthing->get_version(); | ||
$data['gui_access'] = $this->syncthing->get_gui_access(); | ||
$data['gui_access_options'] = $this->syncthing->get_gui_access_options(); | ||
} catch (Engine_Engine_Exception $e) { | ||
$this->page->view_exception($e); | ||
return; | ||
} | ||
|
||
if ($data['gui_access'] == SyncthingLibrary::VIA_REVERSE_PROXY) { | ||
$url = "https://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/syncthing/"; | ||
$data['gui_access'] = "<a href='$url' target='_blank'>$url</a>"; | ||
} else if ($data['gui_access'] == SyncthingLibrary::VIA_LOCALHOST) { | ||
$data['gui_access'] = lang('syncthing_console_access_only'); | ||
} else { | ||
$hostname = $_SERVER['SERVER_NAME']; | ||
if ($data['gui_access'] == SyncthingLibrary::VIA_LAN) | ||
$hostname = $this->syncthing->get_lan_ip(); | ||
$url = "https://" . $hostname . ":" . $data['status']['port']; | ||
$data['gui_access'] = "<a href='$url' target='_blank'>$url</a>"; | ||
} | ||
|
||
// Load views | ||
//----------- | ||
|
||
$this->page->view_form('syncthing/user_profile', $data, lang('syncthing_app_name')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/** | ||
* Syncthing user profile configuration. | ||
* | ||
* @category apps | ||
* @package syncthing | ||
* @subpackage views | ||
* @author eGloo <developer@egloo.ca> | ||
* @copyright 2018 Avantech | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 3 or later | ||
* @link http://www.egloo.ca/clearos/marketplace/apps/syncthing | ||
*/ | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// 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/>. | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Load dependencies | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
$this->lang->load('base'); | ||
$this->lang->load('syncthing'); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Form Header | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
echo form_header(lang('syncthing_app_name')); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Fields | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
echo field_view(lang('syncthing_version'), $version); | ||
echo field_view(lang('base_status'), $status['status']); | ||
echo field_view(lang('syncthing_gui_access'), $gui_access); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Form footer | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
echo form_footer(); | ||
|
||
// vi: expandtab shiftwidth=4 softtabstop=4 tabstop=4 |