]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving unienv.php
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 27 Aug 2025 16:18:26 +0000 (12:18 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 27 Aug 2025 16:18:26 +0000 (12:18 -0400)
www/unienv.php

index 6486e4b5872d3544eedc587b7f6966b38c735d61..37ca0815c0f11c50a3244b2753b38c9cdaea2e9f 100644 (file)
@@ -8,28 +8,35 @@
 function loadenv()
 
 {
+$env_file_path="/etc/mailleur/mailleur.conf";
 $var_arrs=array();
 $phase=0;
 $proceed=true;
 while ($proceed==true) {
+  echo ("unienv.c:loadenv JMPDBG phase='$phase'\n");
   switch ($phase) {
-    case 0     :               //Loading environment variable
-      $env_file_path=realpath("/etc/mailleur/"."mailleur.conf");
-      echo $env_file_path;
-      break;
-    case 1     :               //checking if file exist
+    case 0     :               //checking if file exist
       if(!is_file($env_file_path)){
         throw new ErrorException("Environment File is Missing.");
        $phase=999;             //no need to go further
         }
       break;
-    case 2     :               //opening file 
+    case 1     :               //opening file 
       $fopen=fopen($env_file_path,'r');
       if (!$fopen) {
        throw new ErrorException("Unable to read file <".($env_file_path).">");
        $phase=999;
+       }
       break;
     case 3     :               //scanning file
+      while (($line=fgets($fopen))!==false) {
+       if ((substr(trim($line),0,1)=='#')
+         continue;
+       if (empty(trim($line)))
+         continue;
+       $line_no_comment=explode("#",$line,2)[0];
+       echo ("no_com=<$line_no_comment>\n");
+       }
       break;
     case 4     :               //closing file
       fclose($fopen);
@@ -42,4 +49,5 @@ while ($proceed==true) {
   }
 }
 
+loadenv();
 ?>