Browse Source

* Added: LoadEncryptedConfig

Giancarlo Voci 8 years ago
parent
commit
d1a507b2ea
4 changed files with 35 additions and 11 deletions
  1. 1 1
      TODO.txt
  2. 5 5
      composer.lock
  3. 1 5
      index.php
  4. 28 0
      src/OMUtils.php

+ 1 - 1
TODO.txt

@@ -2,7 +2,7 @@
 [✔] TODO Creare il file di log per i barcode non riconosciuti
 [✔] TODO Aggiungere la data nel menu a tendina della picking list
 [✔] TODO workaround di letture errate dello scanner: se nella picking list viene passato un labelID invece che un barcode, ricava il barcode dalla labelID
+[✘] TODO aggiungere un timetrack dell'operatore che parte da quando da l'ok sulla etichetta da 7" fino all'ultima etichetta
 [✘] TODO aggiungere alla fine della picking list, sulla 7" l'elenco delle quantità prelevate e delle quantità mancanti (Anomalie) e trimmare la descrizione che in alcuni casi è molto lunga
 [✘] TODO Parametrizzare nel file LABEL.INI i parametri del BlinkSpecial
 [✘] TODO creare la classe wrapper Parameters o Configuration, serve per leggere più velocemente i parametri dai file INI e nel caso manchino uno o l'intero file INI, a creare dei defaults
-[✘] TODO aggiungere un timetrack dell'operatore che parte da quando da l'ok sulla etichetta da 7" fino all'ultima etichetta

+ 5 - 5
composer.lock

@@ -8,16 +8,16 @@
     "packages": [
         {
             "name": "bcosca/fatfree",
-            "version": "3.6.3",
+            "version": "3.6.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/bcosca/fatfree.git",
-                "reference": "1d1fe8fee4ec868d9ce5f90973b722c9c2515428"
+                "reference": "dee4d73918a42076d5ac7db64d6d39706c7f328a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/bcosca/fatfree/zipball/1d1fe8fee4ec868d9ce5f90973b722c9c2515428",
-                "reference": "1d1fe8fee4ec868d9ce5f90973b722c9c2515428",
+                "url": "https://api.github.com/repos/bcosca/fatfree/zipball/dee4d73918a42076d5ac7db64d6d39706c7f328a",
+                "reference": "dee4d73918a42076d5ac7db64d6d39706c7f328a",
                 "shasum": ""
             },
             "require": {
@@ -35,7 +35,7 @@
             ],
             "description": "A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!",
             "homepage": "http://fatfreeframework.com/",
-            "time": "2017-12-31T14:47:25+00:00"
+            "time": "2018-04-19T17:23:25+00:00"
         }
     ],
     "packages-dev": [],

+ 1 - 5
index.php

@@ -11,11 +11,7 @@ require 'vendor/autoload.php';
 
 $f3 = \Base::instance();
 
-$config = gzuncompress(base64_decode(file_get_contents("config.bin")));
-$tmpcfg = $f3->get('TEMP') . 'cnf';
-file_put_contents($tmpcfg, $config);
-$f3->config($tmpcfg, true);
-unlink($tmpcfg);
+\OMUtils::Instance()->LoadEncryptedConfig('config.bin');
 
 $f3->config('labels.ini', true);
 

+ 28 - 0
src/OMUtils.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ * @author Open Mind
+ * @date 26/04/2018
+ * @time 11:11
+ */
+
+class OMUtils
+{
+  static public function Instance()
+  {
+    return new \OMUtils();
+  }
+
+  /**
+   * Load an encrypted file with the method "base64_encode(gzcompress(<path to config.ini>))", save it in a temporary file in temp folder of system and load with F3::config()
+   *
+   * @param string $path
+   */
+  public function LoadEncryptedConfig(string $path)
+  {
+    $tmpFilepath = tempnam(sys_get_temp_dir(), 'om');
+    $config = gzuncompress(base64_decode(file_get_contents($path)));
+    file_put_contents($tmpFilepath, $config);
+    \F3::config($tmpFilepath, true);
+    unlink($tmpFilepath);
+  }
+}