Browse Source

Fix WebUI
Debig v-add-fastcgi

Jaap Marcus 5 years ago
parent
commit
99f509516d
4 changed files with 15 additions and 13 deletions
  1. 3 3
      bin/v-add-fastcgi-cache
  2. 1 0
      bin/v-list-web-domain
  3. 10 9
      web/edit/web/index.php
  4. 1 1
      web/templates/admin/edit_web.html

+ 3 - 3
bin/v-add-fastcgi-cache

@@ -16,7 +16,7 @@
 # Argument definition
 user=$1
 domain=$2
-duration=${3-30m}
+duration=${3-2m}
 debug=${4-no}
 restart=${5-no}
 
@@ -71,7 +71,7 @@ status='$upstream_cache_status'
 
 cat << EOF > $fastcgi
     fastcgi_cache $domain;
-    fastcgi_cache_valid 200 2m;
+    fastcgi_cache_valid 200 $duration;
     fastcgi_cache_valid 301 302 10m;
     fastcgi_cache_valid 404 10m;
     fastcgi_cache_bypass $no_cache;
@@ -111,7 +111,7 @@ fi
 
 # Set FastCGI cache flag to enabled
 update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'yes'
-update_object_value 'web' 'DOMAIN' "$domain" 'FASTCGI_DURATION' "$duration"
+update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_DURATION' "$duration"
 
 if [ "$restart" = "yes" ]; then
     # Restart web server

+ 1 - 0
bin/v-list-web-domain

@@ -46,6 +46,7 @@ json_list() {
         "PROXY": "'$PROXY'",
         "PROXY_EXT": "'$PROXY_EXT'",
         "FASTCGI_CACHE": "'$FASTCGI_CACHE'",
+        "FASTCGI_DURATION": "'$FASTCGI_DURATION'",
         "REDIRECT": "'$REDIRECT'",
         "REDIRECT_CODE": "'$REDIRECT_CODE'",
         "CUSTOM_DOCROOT": "'$CUSTOM_DOCROOT'",

+ 10 - 9
web/edit/web/index.php

@@ -68,13 +68,14 @@ 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_DURATION'];
-$v_nginx_cache_check = ''
-if(empty($v_nginx_duration)){
-    $v_nginx_cache_length = '30m';
+$v_nginx_cache_duration = $data[$v_domain]['FASTCGI_DURATION'];
+$v_nginx_cache_check = '';
+if(empty($v_nginx_cache_duration)){
+    $v_nginx_cache_duration = '2m';
+    $v_nginx_cache_check = '';
+}else{
     $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']);
@@ -336,12 +337,12 @@ if (!empty($_POST['save'])) {
     }
 
     // Enable/Disable nginx cache
-    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 (($_SESSION['WEB_SYSTEM'] == 'nginx') && ($v_nginx_cache_check != $_POST['v_nginx_cache_check'] ) && ($v_nginx_cache_duration != $_POST['v_nginx_cache_duration'] && $_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'] = "2m";
+            if (empty ($_POST['v_nginx_cache_duration'])){
+                echo $_POST['v_nginx_cache_duration'] = "2m";
             }
-            exec (HESTIA_CMD."v-add-fastcgi-cache ".$v_username." ".escapeshellarg($v_domain).' '. escapeshellarg($_POST['v_nginx_duration']) , $output, $return_var);
+            exec (HESTIA_CMD."v-add-fastcgi-cache ".$v_username." ".escapeshellarg($v_domain).' '. escapeshellarg($_POST['v_nginx_cache_duration']) , $output, $return_var);
             check_return_code($return_var,$output);
             unset($output); 
         } else {

+ 1 - 1
web/templates/admin/edit_web.html

@@ -392,7 +392,7 @@
                                                         <?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>
+                                                        <td><input type="text" size="20" class="vst-input" name="v_nginx_cache_duration" value="<?=htmlentities(trim($v_nginx_cache_duration, "'"))?>"></td>
                                                     </tr>
                                                 </table>
                                             </td>