Aaron Speer il y a 6 ans
Parent
commit
8f6ed35ad4
3 fichiers modifiés avec 14 ajouts et 5 suppressions
  1. 5 0
      app/Controllers/HomeController.php
  2. 4 1
      public/index.php
  3. 5 4
      views/upload.twig

+ 5 - 0
app/Controllers/HomeController.php

@@ -65,7 +65,12 @@ class HomeController extends Controller {
     $copies=escapeshellcmd($copies);
     $path=str_replace(" ", "\ ", escapeshellcmd($path));
     $path = __DIR__."/../../public".$path;
+
     $cmd = "lp -d ".$printer." -n ".$copies." ".$path;
     echo $cmd;
+    exec($cmd);
+    $this->model->setMessage("Printing Successful!", "That file was printed ".$copies." time(s) on printer ".$printer, "success");
+    header("Location: /");
+
   }
 }

+ 4 - 1
public/index.php

@@ -1,5 +1,9 @@
 <?php
 
+exec("find tmp -mmin +4 | sed 's/\s/\\&/g' | xargs rm -rf");
+exec("mkdir tmp");
+// awkward command to clear files older then 4 minutes from tmp
+
 use App\Controllers\HomeController;
 use App\Controller;
 //use App\Models\HomeModel;
@@ -37,7 +41,6 @@ $router->map('GET|POST','/print', "App\Controllers\HomeController#print", 'print
 $match = $router->match();
 
 
-// not sure if code after this comment  is the best way to handle matched routes
 list( $controller, $action ) = explode( '#', $match['target'] );
 if ( is_callable(array($controller, $action)) ) {
     $obj = new $controller($twig);

+ 5 - 4
views/upload.twig

@@ -38,7 +38,7 @@
           </select>
           <label for="copies">Select number of copies:</label>
           <select name="copies" class="form-control" id="copies">
-            <option>1</option>
+            <option selected="selected">1</option>
             <option>2</option>
             <option>3</option>
             <option>4</option>
@@ -59,9 +59,10 @@
             <option>19</option>
             <option>20</option>
           </select>
-        <input type="hidden" name="path" value="{{path}}">
-        <br>
-        <input type="submit" value="Submit" class="btn btn-success">
+          <input type="hidden" name="path" value="{{path}}">
+          <br>
+          <input type="submit" value="Submit" class="btn btn-success">
+        </div>
       </form>
     </div>
   </div>