$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))
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)
{
$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;
}
}
{
public function success($message);
public function error($message);
- public function exception(Exception $exception);
+ public static function exception(Exception $exception);
public function json();
}
}
//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');
$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;
}
}
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