Fucking Windows bullshit.
authorCameron Ball <c.ball1729@gmail.com>
Sat, 13 Dec 2014 08:45:33 +0000 (16:45 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Sat, 13 Dec 2014 08:45:33 +0000 (16:45 +0800)
Controllers/FileController.php
Services/BannerExtracter.php
Services/IStatusReporter.php
Services/StatusReporter.php
Services/ZipParser.php
public_html/index.php

index c50a623..22b000f 100644 (file)
@@ -53,9 +53,10 @@ class FileController implements IDivineController
         $file = $this->_fileRepository->findByHash($hash);
         if($hash == 'default') $this->serveDefaultBanner();
         if(!$file) $this->notFound();
-                
-        $match = reset(glob('../files/' . $file->getPath() . '/' . $file->getHash() . '.*'));
-        
+
+        $matches = glob(realpath('../files/' . $file->getPath()) . '/' . $file->getHash() . '.*');
+        $match = reset($matches);
+
         $this->_response->setHeader('Content-Type', $file->getMimetype())
                         ->setHeader('Content-Length', $file->getSize())
                         ->setBody(file_get_contents($match))
index 2de532d..63fce25 100644 (file)
@@ -65,7 +65,7 @@ class BannerExtracter implements IBannerExtracter
         for($i=0; $i<$za->numFiles; $i++)
         {
             $stat = $za->statIndex($i);
-            $type = @exif_imagetype('zip://' . $zipfile . '#' . $stat['name']);
+            $type = @exif_imagetype('zip://' . realpath($zipfile) . '#' . $stat['name']);
 
             if($type !== false)
             {
@@ -77,7 +77,7 @@ class BannerExtracter implements IBannerExtracter
                     $this->_hash = $this->randomFilename($stat['name']);
                     $this->_destinationFileName = $this->_hash . '.' . pathinfo($stat['name'], PATHINFO_EXTENSION);
                     $bannerName = $pathComponents[1];
-                    $result = copy('zip://' . $zipfile . '#' . $stat['name'], '../files/banners/' . $this->_destinationFileName);
+                    $result = copy('zip://' . realpath($zipfile) . '#' . $stat['name'], '../files/banners/' . $this->_destinationFileName);
                     break;
                 }
             }
index 97d5da8..3214a41 100644 (file)
@@ -8,6 +8,6 @@ interface IStatusReporter
 {
     public function success($message);
     public function error($message);
-    public function exception(Exception $exception);
+    public static function exception(Exception $exception);
     public function json();
 }
index b36a53d..3667c88 100644 (file)
@@ -41,7 +41,7 @@ class StatusReporter implements IStatusReporter
     }
     
     //no need to exit here, exceptions stop the program.
-    public function exception(Exception $exception)
+    public static function exception(Exception $exception)
     {       
         //we'll be instatic context here so I have to do it this way.
         header('Content-Type: application/json');
index f3a55f4..3abc391 100644 (file)
@@ -89,7 +89,8 @@ class ZipParser implements IZipParser
             $stat = $this->_za->statIndex($i);
             if(pathinfo($stat['name'], PATHINFO_EXTENSION) == 'sm')
             {
-                $smData = file_get_contents('zip://../files/StepMania/' . $this->_file->getHash() . '.zip#' . $stat['name']);
+                $path = realpath('../files/StepMania/' . $this->_file->getHash() . '.zip');
+                $smData = file_get_contents('zip://' . $path . '#' . $stat['name']);
                 $this->_smFiles[$stat['name']] = $smData;
             }
         }
index 2aa5c39..f6afb25 100644 (file)
@@ -8,7 +8,11 @@ $config = require('../config/app.php');
 header("Access-Control-Allow-Origin: " . $config['allow-origin']);\r
 \r
 // Nice exceptions\r
-if($config['mode'] == 'production') set_exception_handler(array('\Services\StatusReporter', 'exception'));\r
+if($config['mode'] == 'production')\r
+{\r
+    ini_set('display_errors', 0);\r
+    set_exception_handler(array('\Services\StatusReporter', 'exception'));\r
+}\r
 \r
 // Everything time related should be UTC+0 based\r
 date_default_timezone_set('UTC');\r