Browse Source

Merge branch 'remastering' of https://gitea.steelants.cz/SH/PHP_SMART_HOME_V3 into remastering

pull/1/head
GamerClassN7 1 year ago
parent
commit
1e9395f9e7
4 changed files with 51 additions and 40 deletions
  1. +3
    -1
      app/Bootstrap.php
  2. +18
    -6
      app/controllers/pluginsController.php
  3. +27
    -19
      app/views/templates/part/pluginButton.phtml
  4. +3
    -14
      app/views/templates/plugins.phtml

+ 3
- 1
app/Bootstrap.php View File

@ -4,9 +4,11 @@ error_reporting(E_ALL);
ini_set( 'display_errors','1');
//setup
parse_str($_SERVER['QUERY_STRING'], $params);
$urlSes = str_replace((!empty ($params['url']) ? $params['url'] : ""), "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI']));
session_set_cookie_params(
1209600,
str_replace('login', "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI'])),
$urlSes,
str_replace("/var/www/", "", $_SERVER['DOCUMENT_ROOT']),
true,
true

+ 18
- 6
app/controllers/pluginsController.php View File

@ -1,16 +1,28 @@
<?php
if (!empty ($_POST)){
if (
isset($_POST['name']) &&
isset ($_POST['name']) &&
$_POST['name'] != '' &&
isset($_POST['actualStatus'])
){
if ($_POST['actualStatus']) {
rename($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/' . $_POST['name'] . ".php", $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/!' . $_POST['name'] . ".php");
!isset ($_POST['remove'])
) {
if ($_POST['status'] == "true") {
if (file_exists ($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/!' . $_POST['name'] . ".php")) {
rename($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/!' . $_POST['name'] . ".php", $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/' . $_POST['name'] . ".php");
}
} else {
rename($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/!' . $_POST['name'] . ".php", $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/' . $_POST['name'] . ".php");
if (file_exists ($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/' . $_POST['name'] . ".php")) {
rename($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/' . $_POST['name'] . ".php", $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/!' . $_POST['name'] . ".php");
}
}
header('Location: ./plugins');
die();
}
if (
isset ($_POST['name']) &&
$_POST['name'] != '' &&
isset ($_POST['remove'])
) {
//
}
}

+ 27
- 19
app/views/templates/part/pluginButton.phtml View File

@ -1,21 +1,29 @@
<div class="col-12 col-md-6 col-xl-4 square-wrap">
<div class="rectangle-2">
<div class="square-content double <?php echo ($PLUGINSTATUS == 0 ? 'is-inactive' : ''); ?>" id="plugin-<?php echo $PLUGINID; ?>">
<div class="row">
<div class="col-1">
<h5 class="fa">
<?php echo $PLUGINNAME ?>
</h5>
</div>
</div>
<div class="row">
<div class="col">
<a class="button is-primary m-1" onClick="restartAutomation(<?php echo $PLUGINID; ?>);"><?php $LANGMNG->echo('b_restart')?></a>
</div>
<div class="col">
<a class="button is-primary m-1" onClick="toggleAutomation(<?php echo $PLUGINID; ?>);"><?php $LANGMNG->echo('b_disable')?></a>
</div>
</div>
</div>
</div>
<div class="rectangle-2">
<div class="square-content double <?php echo ($PLUGINSTATUS == false ? 'is-inactive' : ''); ?>">
<div class="row">
<div class="col-1">
<h5 class="fa">
<?php echo $PLUGINNAME ?>
</h5>
</div>
</div>
<div class="row">
<div class="col">
<form method="post" action="">
<input type="hidden" name="name" value="<?php echo $PLUGINNAME; ?>"/>
<input type="hidden" name="status" value="<?php echo ($PLUGINSTATUS == false ? "true" : "false"); ?>"/>
<a class="button is-primary m-1" onclick="$(this).closest('form').submit();"><?php echo ($PLUGINSTATUS == false ? $LANGMNG->get('b_approve') : $LANGMNG->get('b_disable')); ?></a>
</form>
</div>
<div class="col">
<form method="post" action="">
<input type="hidden" name="name" value="<?php echo $PLUGINNAME; ?>"/>
<input type="hidden" name="remove" value="1"/>
<a class="button is-primary m-1" onclick="$(this).closest('form').submit();"><?php $LANGMNG->echo('b_remove'); ?></a>
</form>
</div>
</div>
</div>
</div>
</div>

+ 3
- 14
app/views/templates/plugins.phtml View File

@ -27,27 +27,16 @@
<div class="row mb-4">
<?php if ($PLUGINS): ?>
<?php foreach ($PLUGINS as $plugin):
<?php foreach ($PLUGINS as $plugin):
//BUTTON
$partial = new Partial('pluginButton');
$partial->prepare('langMng',$LANGMNG);
$partial->prepare('pluginName',$plugin['name']);
$partial->prepare('pluginStatus',$plugin['status']);
$partial->render();
?>
<div class="content">
<form method="post" action="">
<input type="hidden" name="name" value="<?php echo $plugin['name']; ?>"/>
<input type="hidden" name="actualStatus" value="<?php echo $plugin['status']; ?>"/>
<a onclick="$(this).closest('form').submit();">
<div class="panel box content <?php echo ($plugin['status'] ? '' : 'disabled '); ?>p-4">
<h5><?php echo $plugin['name']; ?></h5>
</div>
</a>
</form>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>

Loading…
Cancel
Save