Skip to content

Commit

Permalink
add configurable server port TasmoAdmin#122 TasmoAdmin#131
Browse files Browse the repository at this point in the history
  • Loading branch information
reloxx13 committed Jun 20, 2018
1 parent 70034be commit 15f685c
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 67 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
- fix date in update #124
- change filename to load js file correctly (only firefox issue?)
- fixes the show more checkbox
- add configurable server port #122 #131

## v0.0.8
- add logo
Expand Down
1 change: 1 addition & 0 deletions tasmoadmin/includes/Config.php
Expand Up @@ -6,6 +6,7 @@ class Config {
private $defaultConfigs
= [
"ota_server_ip" => "",
"ota_server_port" => "",
"username" => "",
"password" => "",
"refreshtime" => "5",
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_de.ini
Expand Up @@ -57,6 +57,8 @@ ERROR_CANNOT_CREATE_FILE = "Konnte Datei nicht schreiben => %s"
CONFIG_SERVER_IP_HELP = "IP vom Server auf dem TasmoAdmin läuft"
MSG_USER_CONFIG_SAVED = "Einstellungen gespeichert"
CONFIG_SERVER_IP = "OTA Server IP"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port über dem TasmoAdmin erreichbar ist"
CONFIG_REFRESHTIME = "Aktualisierungsrate"
CONFIG_REFRESHTIME_NONE = "Nicht aktualisieren"
CONFIG_REFRESHTIME_SECOND = "Sekunde"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_en.ini
Expand Up @@ -58,6 +58,8 @@ ERROR_CANNOT_CREATE_FILE = "Could not write file => %s"
CONFIG_SERVER_IP_HELP = "The IP from the TasmoAdmin Server"
MSG_USER_CONFIG_SAVED = "Settings saved"
CONFIG_SERVER_IP = "OTA Server IP"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Refreshtime"
CONFIG_REFRESHTIME_NONE = "Dont Refresh"
CONFIG_REFRESHTIME_SECOND = "Second"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_es.ini
Expand Up @@ -57,6 +57,8 @@ ERROR_CANNOT_CREATE_FILE = "No se puede escribir el archivo => %s"
CONFIG_SERVER_IP_HELP = "Dirección IP del servidor TasmoAdmin"
MSG_USER_CONFIG_SAVED = "Configuración guardada"
CONFIG_SERVER_IP = "IP Servidor OTA"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Tiempo de Refresco"
CONFIG_REFRESHTIME_NONE = "No refrescar"
CONFIG_REFRESHTIME_SECOND = "Segundo"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_fr.ini
Expand Up @@ -58,6 +58,8 @@ ERROR_CANNOT_CREATE_FILE = "Erreur d'écriture du fichier => %s"
CONFIG_SERVER_IP_HELP = "Adresse IP du serveur TasmoAdmin"
MSG_USER_CONFIG_SAVED = "Configurations enregistrées"
CONFIG_SERVER_IP = "Adresse IP du serveur de mises a jour"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Temps de rafraichissement"
CONFIG_REFRESHTIME_NONE = "Ne pas rafraichir"
CONFIG_REFRESHTIME_SECOND = "Seconde"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_it.ini
Expand Up @@ -58,6 +58,8 @@ ERROR_CANNOT_CREATE_FILE = "Could not write file => %s"
CONFIG_SERVER_IP_HELP = "The IP from the TasmoAdmin Server"
MSG_USER_CONFIG_SAVED = "Settings saves"
CONFIG_SERVER_IP = "OTA Server IP"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Refreshtime"
CONFIG_REFRESHTIME_NONE = "Dont Refresh"
CONFIG_REFRESHTIME_SECOND = "Second"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_nl.ini
Expand Up @@ -58,6 +58,8 @@ ERROR_CANNOT_CREATE_FILE = "Bestand kon niet worden weggeschreven => %s"
CONFIG_SERVER_IP_HELP = "The IP from the TasmoAdmin Server"
MSG_USER_CONFIG_SAVED = "Instellingen opslaan"
CONFIG_SERVER_IP = "OTA Server IP"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Ververstijd"
CONFIG_REFRESHTIME_NONE = "Niet Verversen"
CONFIG_REFRESHTIME_SECOND = "Seconde"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_pl.ini
Expand Up @@ -58,6 +58,8 @@ ERROR_CANNOT_CREATE_FILE = "Nie można zapisać pliku => %s"
CONFIG_SERVER_IP_HELP = "Adres IP serwera TasmoAdmin"
MSG_USER_CONFIG_SAVED = "Zapisane ustawienia"
CONFIG_SERVER_IP = "Adres IP serwera OTA"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_REFRESHTIME = "Częstotliwość odświeżania"
CONFIG_REFRESHTIME_NONE = "Nie odświeżaj"
CONFIG_REFRESHTIME_SECOND = "Sekunda"
Expand Down
2 changes: 2 additions & 0 deletions tasmoadmin/lang/lang_ru.ini
Expand Up @@ -57,6 +57,8 @@ HELP_CHAT = "TasmoAdmin Discord (beta)"
ERROR_CANNOT_CREATE_FILE = "Не удается записать в файл => %s"
CONFIG_SERVER_IP_HELP = "The IP from the TasmoAdmin Server"
MSG_USER_CONFIG_SAVED = "Параметры успешно сохранены"
CONFIG_SERVER_PORT = "OTA Server Port"
CONFIG_SERVER_PORT_HELP = "Port to access TasmoAdmin"
CONFIG_SERVER_IP = "OTA Server IP"
CONFIG_REFRESHTIME = "Время Обновления"
CONFIG_REFRESHTIME_NONE = "Не обновлять"
Expand Down
38 changes: 21 additions & 17 deletions tasmoadmin/pages/device_update.php
@@ -1,17 +1,21 @@
<?php
// var_dump( $_POST );
$localIP = $Config->read( "ota_server_ip" );
$subdir = dirname( $_SERVER[ 'PHP_SELF' ] );
$subdir = str_replace( "\\", "/", $subdir );
$subdir = $subdir == "/" ? "" : $subdir;

$otaServer = $_SERVER['REQUEST_SCHEME']."://".$localIP.":".$_SERVER[ "SERVER_PORT" ]._BASEURL_."";

if ( isset( $_POST[ 'minimal_firmware_path' ] ) && !empty( $_POST[ 'minimal_firmware_path' ] ) ) {
$localIP = $Config->read( "ota_server_ip" );
$localPort = $Config->read( "ota_server_port" );
if( empty( $localPort ) ) {
$localPort = $_SERVER[ "SERVER_PORT" ];
}
$subdir = dirname( $_SERVER[ 'PHP_SELF' ] );
$subdir = str_replace( "\\", "/", $subdir );
$subdir = $subdir == "/" ? "" : $subdir;

$otaServer = $_SERVER[ 'REQUEST_SCHEME' ]."://".$localIP.":".$localPort._BASEURL_."";

if( isset( $_POST[ 'minimal_firmware_path' ] ) && !empty( $_POST[ 'minimal_firmware_path' ] ) ) {
$ota_minimal_firmware_url = $otaServer."data/firmwares/sonoff-minimal.bin";
}
$ota_new_firmware_url = $otaServer."data/firmwares/sonoff-full.bin";

$device_ids = isset( $_POST[ "device_ids" ] ) ? $_POST[ "device_ids" ] : FALSE;
?>
<div class='row justify-content-sm-center'>
Expand All @@ -23,7 +27,7 @@
</div>
<div class='row justify-content-center'>
<div class='col-12 col-md-10'>
<?php if ( !$device_ids ): ?>
<?php if( !$device_ids ): ?>
<div class="alert alert-danger alert-dismissible fade show mb-5" data-dismiss="alert" role="alert">
<?php echo __( "NO_DEVICES_SELECTED", "DEVICE_UPDATE" ); ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
Expand All @@ -32,22 +36,22 @@
</div>
<?php else: ?>
<div id='progressbox' class='mt-3 border border-dark p-3 pre-scrollable'>

</div>

<input type='hidden' id='ota_minimal_firmware_url'
value='<?php echo isset( $ota_minimal_firmware_url ) ? $ota_minimal_firmware_url : ""; ?>'>
<input type='hidden'
id='ota_new_firmware_url'
value='<?php echo isset( $ota_new_firmware_url ) ? $ota_new_firmware_url : ""; ?>'>


<script>
var device_ids = '<?php echo json_encode( $device_ids ); ?>';

</script>


<script type='text/javascript'
src='<?php echo _RESOURCESURL_; ?>js/device_update.js?<?php echo time(); ?>'></script>
<?php endif; ?>
Expand Down
78 changes: 50 additions & 28 deletions tasmoadmin/pages/site_config.php
@@ -1,31 +1,31 @@
<?php
$msg = FALSE;
if ( isset( $_POST ) && !empty( $_POST ) ) {
if ( isset( $_POST[ "save" ] ) ) {
if( isset( $_POST ) && !empty( $_POST ) ) {
if( isset( $_POST[ "save" ] ) ) {
$settings = $_POST;
unset( $settings[ "save" ] );
if ( !isset( $settings[ "login" ] ) ) {

if( !isset( $settings[ "login" ] ) ) {
$settings[ "login" ] = "0";
}
if ( !isset( $settings[ "password" ] ) || empty( $settings[ "password" ] )
|| $settings[ "password" ] == ""
|| $settings[ "login" ] == "0" ) {

if( !isset( $settings[ "password" ] ) || empty( $settings[ "password" ] )
|| $settings[ "password" ] == ""
|| $settings[ "login" ] == "0" ) {
unset( $settings[ "password" ] );
unset( $settings[ "username" ] );
} else {
$settings[ "password" ] = md5( $settings[ "password" ] );
}
foreach ( $settings as $settingKey => $settingVal ) {


foreach( $settings as $settingKey => $settingVal ) {
$Config->write( $settingKey, $settingVal );
}
$msg = __( "MSG_USER_CONFIG_SAVED", "USER_CONFIG" );
}
}

$config = $Config->readAll();

?>
Expand All @@ -36,7 +36,7 @@
<h2 class='text-sm-center mb-5'>
<?php echo $title; ?>
</h2>
<?php if ( isset( $msg ) && $msg != "" ): ?>
<?php if( isset( $msg ) && $msg != "" ): ?>
<div class="alert alert-success alert-dismissible fade show mb-5" data-dismiss="alert" role="alert">
<?php echo $msg; ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
Expand Down Expand Up @@ -79,27 +79,49 @@ class="form-control"
value=''
autocomplete="off">
</div>
<div class="form-group mt-5">
<label for="ota_server_ip">
<?php echo __( "CONFIG_SERVER_IP", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_ip"
name='ota_server_ip'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $config[ "ota_server_ip" ]; ?>'
>
<small id="from_ipHelp" class="form-text text-muted">
<?php echo __( "CONFIG_SERVER_IP_HELP", "USER_CONFIG" ); ?>
</small>


<div class="form-row mt-5">
<div class="form-group col-12 col-sm-8">
<label for="ota_server_ip">
<?php echo __( "CONFIG_SERVER_IP", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_ip"
name='ota_server_ip'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $config[ "ota_server_ip" ]; ?>'
>
<small id="from_ipHelp" class="form-text text-muted">
<?php echo __( "CONFIG_SERVER_IP_HELP", "USER_CONFIG" ); ?>
</small>
</div>
<div class="form-group col-12 col-sm-4">
<label for="ota_server_port">
<?php echo __( "CONFIG_SERVER_PORT", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_port"
name='ota_server_port'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo !empty( $config[ "ota_server_port" ] ) ? $config[ "ota_server_port" ]
: $_SERVER[ "SERVER_PORT" ]; ?>'
>
<small id="from_ipHelp" class="form-text text-muted">
<?php echo __( "CONFIG_SERVER_PORT_HELP", "USER_CONFIG" ); ?>
</small>
</div>
</div>


<div class="form-group">
<label for="update_automatic_lang">
<?php echo __( "CONFIG_AUTOMATIC_LANG", "USER_CONFIG" ); ?>
</label>
<select class="form-control custom-select" id="update_automatic_lang" name='update_automatic_lang'>
<?php if ( $config[ "update_automatic_lang" ] == "" ): ?>
<?php if( $config[ "update_automatic_lang" ] == "" ): ?>
<option><?php echo __( "PLEASE_SELECT" ); ?></option>
<?php endif; ?>
<option value='CN' <?php echo $config[ "update_automatic_lang" ] == "CN" ? "selected=\selected\""
Expand Down
60 changes: 38 additions & 22 deletions tasmoadmin/pages/upload_form.php
Expand Up @@ -7,10 +7,10 @@
curl_setopt( $ch, CURLOPT_URL, $changelogUrl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$changelog = curl_exec( $ch );


//$changelog = file_get_contents( _APPROOT_."CHANGELOG.md" );
if ( !$changelog || curl_error( $ch ) != "" || $changelog == "" ) {
if( !$changelog || curl_error( $ch ) != "" || $changelog == "" ) {
$changelog = "";
} else {
$changelog = substr( str_replace( [ "*/", "/*", " *\n" ], [ "", " * ", "\n" ], $changelog ), 0, 5000 )."...";
Expand All @@ -29,32 +29,48 @@
<?php echo __( "UPLOAD_DESCRIPTION", "DEVICE_UPDATE" ); ?><br/>
<a href='https://github.com/arendst/Sonoff-Tasmota/releases' target='_blank'>Tasmota Releases</a>
</div>


<form class='' name='update_form' method='post' enctype='multipart/form-data'
action='<?php echo _BASEURL_; ?>upload'>
<div class="form-group">
<label for="ota_server_ip">
<?php echo __( "CONFIG_SERVER_IP", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_ip"
name='ota_server_ip'
required
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $Config->read( "ota_server_ip" ); ?>'
>
<div class='form-row'>
<div class="form-group col-12 col-sm-8">
<label for="ota_server_ip">
<?php echo __( "CONFIG_SERVER_IP", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_ip"
name='ota_server_ip'
required
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $Config->read( "ota_server_ip" ); ?>'
>
</div>
<div class="form-group col-12 col-sm-4">
<label for="ota_server_ip">
<?php echo __( "CONFIG_SERVER_PORT", "USER_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="ota_server_port"
name='ota_server_port'
required
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo !empty( $Config->read( "ota_server_port" ) ) ? $Config->read(
"ota_server_port"
) : $_SERVER[ "SERVER_PORT" ]; ?>'
>
</div>
</div>

<div class="form-group">
<label for="minimal_firmware">
<?php echo __( "FORM_CHOOSE_MINIMAL_FIRMWARE", "DEVICE_UPDATE" ); ?>
</label>
<div class="custom-file">
<input type="file" class="custom-file-input" id="minimal_firmware" name='minimal_firmware'>
<label class="custom-file-label" for="minimal_firmware">

</label>
</div>
</div>
Expand All @@ -65,7 +81,7 @@ class="form-control"
<div class="custom-file">
<input type="file" class="custom-file-input" id="new_firmware" name='new_firmware' required>
<label class="custom-file-label" for="new_firmware">

</label>
</div>
</div>
Expand All @@ -86,8 +102,8 @@ class="form-control"
<span class='clearfix'></span>
</div>
</div>


</form>
<hr class='my-5'>
<div class='changelog'>
Expand Down

0 comments on commit 15f685c

Please sign in to comment.