Browse Source

Convert from select to checkbox

Jaap Marcus 5 years ago
parent
commit
c85ce0a18d
2 changed files with 22 additions and 15 deletions
  1. 11 8
      web/edit/web/index.php
  2. 11 7
      web/templates/admin/edit_web.html

+ 11 - 8
web/edit/web/index.php

@@ -68,10 +68,13 @@ if (empty($v_letsencrypt)) $v_letsencrypt = 'no';
 $v_ssl_home = $data[$v_domain]['SSL_HOME'];
 $v_backend_template = $data[$v_domain]['BACKEND'];
 $v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'];
-$v_nginx_cache_length = $data[$v_domain]['FASTCGI_CACHE_LENGTH'];
-if(empty($v_nginx_cache_length)){
+$v_nginx_cache_length = $data[$v_domain]['FASTCGI_DURATION'];
+$v_nginx_cache_check = ''
+if(empty($v_nginx_duration)){
     $v_nginx_cache_length = '30m';
+    $v_nginx_cache_check = 'on';
 }
+;
 $v_proxy = $data[$v_domain]['PROXY'];
 $v_proxy_template = $data[$v_domain]['PROXY'];
 $v_proxy_ext = str_replace(',', ', ', $data[$v_domain]['PROXY_EXT']);
@@ -333,12 +336,12 @@ if (!empty($_POST['save'])) {
     }
 
     // Enable/Disable nginx cache
-    if (($_SESSION['WEB_SYSTEM'] == 'nginx') && ($v_nginx_cache != $_POST['v_nginx_cache'] ) && ($v_nginx_cache_length != $_POST['v_nginx_cache_length'] && $_POST['v_nginx_cache'] = "yes" ) && (empty($_SESSION['error_msg']))) {
-        if ( $_POST['v_nginx_cache'] == 'yes' ) {
+    if (($_SESSION['WEB_SYSTEM'] == 'nginx') && ($v_nginx_cache_check != $_POST['v_nginx_cache_check'] ) && ($v_nginx_cache_length != $_POST['v_nginx_cache_length'] && $_POST['v_nginx_cache'] = "yes" ) && (empty($_SESSION['error_msg']))) {
+        if ( $_POST['v_nginx_cache_check'] == 'on' ) {
             if (!empty ($_POST['v_nginx_cache_length'])){
-                echo $_POST['v_nginx_cache_length'] = "30m";
+                echo $_POST['v_nginx_cache_length'] = "2m";
             }
-            exec (HESTIA_CMD."v-add-fastcgi-cache ".$v_username." ".escapeshellarg($v_domain).' '. escapeshellarg($_POST['v_nginx_cache_length']) , $output, $return_var);
+            exec (HESTIA_CMD."v-add-fastcgi-cache ".$v_username." ".escapeshellarg($v_domain).' '. escapeshellarg($_POST['v_nginx_duration']) , $output, $return_var);
             check_return_code($return_var,$output);
             unset($output); 
         } else {
@@ -346,7 +349,7 @@ if (!empty($_POST['save'])) {
             check_return_code($return_var,$output);
             unset($output); 
         }
-        $restart_proxy = 'yes';
+        $restart_web = 'yes';
     }
 
     // Delete proxy support
@@ -355,7 +358,7 @@ if (!empty($_POST['save'])) {
         check_return_code($return_var,$output);
         unset($output);
         unset($v_proxy);
-        $restart_proxy = 'yes';
+        $restart_web = 'yes';
     }
 
     // Change proxy template / Update extension list

+ 11 - 7
web/templates/admin/edit_web.html

@@ -381,16 +381,20 @@
                                         </tr>
                                         <?php if($_SESSION['WEB_SYSTEM'] == 'nginx'){?>
                                         <tr>
-                                            <td class="vst-text input-label">
-                                                <?php print _('Enable Fast CGI Cache'); ?> <a href="https://docs.hestiacp.com/admin_docs/nginx_caching.html" target="_blank"><i class="fas fa-question-circle"></i></a>
+                                            <td class="vst-text">
+                                                <label><input type="checkbox" size="20" class="vst-checkbox" name="v_nginx_cache_check" <?php if (!empty($v_nginx_cache)) echo "checked=yes" ?> onclick="javascript:elementHideShow('v_nginx_duration');"><?php print _('Enable FastCGI Cache'); ?> <a href="https://docs.hestiacp.com/admin_docs/nginx_caching.html" target="_blank"><i class="fas fa-question-circle"></i></a></label>
                                             </td>
                                         </tr>
                                         <tr>
-                                            <td>
-                                                <select class="vst-list" name="v_nginx_cache">
-                                                    <option value="no"><?php echo _('No');?></option>
-                                                    <option value="yes" <?php if ( $v_nginx_cache == "yes") { echo 'selected'; }?>><?php echo _('Yes');?></option>
-                                                </select>
+                                            <td class="step-left">
+                                                <table id="v_nginx_duration" style="display:<?php if ($v_nginx_cache != 'yes' ) { echo 'none';} else {echo 'block';}?> ;" >
+                                                    <td class="vst-text input-label">
+                                                        <?php print _('Cache Duration'); ?> <span class="optional"><?=_('For example: 30s, 10m or 1d');?>
+                                                    </td>
+                                                    <tr>
+                                                        <td><input type="text" size="20" class="vst-input" name="v_nginx_duration" value="<?=htmlentities(trim($v_nginx_duration, "'"))?>"></td>
+                                                    </tr>
+                                                </table>
                                             </td>
                                         </tr>
                                         <?php } ?>