projects
/
rock.divinelegy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f4374f
)
Merge changes from home PC
author
Cameron Ball
<c.ball1729@gmail.com>
Fri, 20 Feb 2015 12:19:52 +0000
(20:19 +0800)
committer
Cameron Ball
<c.ball1729@gmail.com>
Fri, 20 Feb 2015 12:19:52 +0000
(20:19 +0800)
DataAccess/DataMapper/DataMapper.php
patch
|
blob
|
history
Services/BannerExtracter.php
patch
|
blob
|
history
Services/IBannerExtracter.php
patch
|
blob
|
history
Services/ZipParser.php
patch
|
blob
|
history
files/banners/default.png
[deleted file]
patch
|
blob
|
history
public_html/upload.html
patch
|
blob
|
history
diff --git
a/DataAccess/DataMapper/DataMapper.php
b/DataAccess/DataMapper/DataMapper.php
index
5c817dc
..
a4e474c
100644
(file)
--- a/
DataAccess/DataMapper/DataMapper.php
+++ b/
DataAccess/DataMapper/DataMapper.php
@@
-153,14
+153,17
@@
class DataMapper implements IDataMapper
implode(', ', $info['columns']));
\r
}
\r
\r
implode(', ', $info['columns']));
\r
}
\r
\r
- $queries[$index] = $query;
\r
+ //The files table has hash and filename as a unique index.
\r
+ //Some packs share the same banner for every file, and we only
\r
+ //ever pull them out by hash. So this saves having loads of entries
\r
+ $queries[$index] = $query . ' ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id)';
\r
}
\r
\r
// if($queries['TYPE'] == AbstractPopulationHelper::QUERY_TYPE_CREATE)
\r
// {
\r
$idMap = [];
\r
foreach($queries as $index => $query)
\r
}
\r
\r
// if($queries['TYPE'] == AbstractPopulationHelper::QUERY_TYPE_CREATE)
\r
// {
\r
$idMap = [];
\r
foreach($queries as $index => $query)
\r
- {
\r
+ {
\r
$runQuery = true;
\r
//originally was preg_quote('%').'(.*?)'.preg_quote('%') but that failed with things like:
\r
//...VALUES ('Voyager Full 50%', %INDEX_REF_0%
\r
$runQuery = true;
\r
//originally was preg_quote('%').'(.*?)'.preg_quote('%') but that failed with things like:
\r
//...VALUES ('Voyager Full 50%', %INDEX_REF_0%
\r
diff --git
a/Services/BannerExtracter.php
b/Services/BannerExtracter.php
index
2c29373
..
c5fdc50
100644
(file)
--- a/
Services/BannerExtracter.php
+++ b/
Services/BannerExtracter.php
@@
-22,7
+22,7
@@
class BannerExtracter implements IBannerExtracter
$this->_configManager = $configManager;
}
$this->_configManager = $configManager;
}
- public function extractSongBanner($zipfile, $banner
Name
) {
+ public function extractSongBanner($zipfile, $banner
Index
) {
$za = new ZipArchive();
//XXX: We assume all files are zips. Should be enforced by validation elsewhere.
$res = $za->open($zipfile);
$za = new ZipArchive();
//XXX: We assume all files are zips. Should be enforced by validation elsewhere.
$res = $za->open($zipfile);
@@
-34,10
+34,10
@@
class BannerExtracter implements IBannerExtracter
$stat = $za->statIndex($i);
$type = @exif_imagetype('zip://' . realpath($zipfile) . '#' . $stat['name']);
//Sometimes simfiles specify a video as their banner. Fuck dat.
$stat = $za->statIndex($i);
$type = @exif_imagetype('zip://' . realpath($zipfile) . '#' . $stat['name']);
//Sometimes simfiles specify a video as their banner. Fuck dat.
- if(
basename($stat['name']) == $bannerName
&& $type !== false)
+ if(
$stat['name'] == $bannerIndex
&& $type !== false)
{
$this->_hash = md5_file('zip://' . $zipfile . '#' . $stat['name']);
{
$this->_hash = md5_file('zip://' . $zipfile . '#' . $stat['name']);
- $this->_destinationFileName = $this->_hash . '.' . pathinfo($banner
Name
, PATHINFO_EXTENSION);
+ $this->_destinationFileName = $this->_hash . '.' . pathinfo($banner
Index
, PATHINFO_EXTENSION);
$result = copy('zip://' . $zipfile . '#' . $stat['name'], $this->_configManager->getDirective('filesPath') . '/banners/' . $this->_destinationFileName);
break;
}
$result = copy('zip://' . $zipfile . '#' . $stat['name'], $this->_configManager->getDirective('filesPath') . '/banners/' . $this->_destinationFileName);
break;
}
@@
-51,7
+51,7
@@
class BannerExtracter implements IBannerExtracter
/* @var $fff \Domain\Entities\FileStepByStepBuilder */
return $this->_builder->With_Hash($this->_hash)
->With_Path('banners')
/* @var $fff \Domain\Entities\FileStepByStepBuilder */
return $this->_builder->With_Hash($this->_hash)
->With_Path('banners')
- ->With_Filename(
$bannerName
)
+ ->With_Filename(
basename($bannerIndex)
)
->With_Mimetype($mimetype)
->With_Size($size)
->With_UploadDate(time())
->With_Mimetype($mimetype)
->With_Size($size)
->With_UploadDate(time())
diff --git
a/Services/IBannerExtracter.php
b/Services/IBannerExtracter.php
index
a56a31f
..
ec963ee
100644
(file)
--- a/
Services/IBannerExtracter.php
+++ b/
Services/IBannerExtracter.php
@@
-4,6
+4,6
@@
namespace Services;
interface IBannerExtracter
{
interface IBannerExtracter
{
- public function extractSongBanner($zipfile, $banner
Name
);
+ public function extractSongBanner($zipfile, $banner
Index
);
public function extractPackBanner($zipfile, $packname);
}
public function extractPackBanner($zipfile, $packname);
}
diff --git
a/Services/ZipParser.php
b/Services/ZipParser.php
index
2286eb5
..
e349e6a
100644
(file)
--- a/
Services/ZipParser.php
+++ b/
Services/ZipParser.php
@@
-114,7
+114,7
@@
class ZipParser implements IZipParser
{
try
{
{
try
{
- $this->_smFiles[$index] = $this->SmDataToSmClass($data);
+ $this->_smFiles[$index] = $this->SmDataToSmClass($data
, $index
);
} catch(Exception $e) {
//Exceptions we care about at this stage
if(!$e instanceof InvalidSmFileException &&
} catch(Exception $e) {
//Exceptions we care about at this stage
if(!$e instanceof InvalidSmFileException &&
@@
-149,11
+149,14
@@
class ZipParser implements IZipParser
return $packName;
}
return $packName;
}
- private function SmDataToSmClass($smData)
- {
+ private function SmDataToSmClass($smData
, $index
)
+ {
$parser = $this->_smParser;
$parser->parse($smData);
$parser = $this->_smParser;
$parser->parse($smData);
- $banner = $this->_bannerExtracter->extractSongBanner(realpath($this->_configManager->getDirective('filesPath') . '/StepMania/' . $this->_file->getHash() . '.zip'), $parser->banner());
+
+ $bannerIndex = $this->resolveBannerIndex($parser->banner(), $index);
+ $banner = $this->_bannerExtracter->extractSongBanner(realpath($this->_configManager->getDirective('filesPath') . '/StepMania/' . $this->_file->getHash() . '.zip'), $bannerIndex);
+
$file = $this->isPack() ? null : $this->_file;
return $this->_smBuilder->With_Title($parser->title())
$file = $this->isPack() ? null : $this->_file;
return $this->_smBuilder->With_Title($parser->title())
@@
-169,4
+172,15
@@
class ZipParser implements IZipParser
->With_Banner($banner)
->build();
}
->With_Banner($banner)
->build();
}
+
+ private function resolveBannerIndex($bannerDirective, $smFileIndex)
+ {
+ if(strpos($bannerDirective, '../') !== false || strpos($bannerDirective, '..\\') !== false)
+ {
+ $pathInfo = pathinfo($smFileIndex);
+ return str_replace('..', dirname($pathInfo['dirname']), $bannerDirective);
+ }
+
+ return dirname($smFileIndex) . '/' . $bannerDirective;
+ }
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/files/banners/default.png
b/files/banners/default.png
deleted file mode 100644
(file)
index
68df6b7
..0000000
Binary files a/files/banners/default.png and /dev/null differ
diff --git
a/public_html/upload.html
b/public_html/upload.html
index
a551bb2
..
eb59711
100644
(file)
--- a/
public_html/upload.html
+++ b/
public_html/upload.html
@@
-2,7
+2,7
@@
<body>
<form action="/simfiles/upload" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<body>
<form action="/simfiles/upload" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
- <input type="hidden" name="token" value="CAAFdJomTiBABA
JqHJZBRqz3CMkFMfTlSbtUJsEeZCBUuPxl1ugT9Q4mVfwnYLdfAlwblEjFcYqliNwZBNIplbEZCNCEZBZCjX2Xp3bIvflBv0YYAATZCRgJkzq0S2SdfOY5pFEvRCWxZCH9SHBh1R6eqMmuDR1h5vSq4SDY9sMpf0G1nwtw5VRGz
" />
+ <input type="hidden" name="token" value="CAAFdJomTiBABA
Mx0eKHYDJ89mTFFTUirrFQhlziCHoUlbl5aNWbRZA9fLQxLfKDhS8KPRblAdZBXt6kDkYRiNH1v0WDDqgEDekIgv76wUelNCpi0x2PKxZCJQxpwop0N4MqpwAYgqlGHEOz4Ns4h66q2wJrujfCPExJyQrFaUbRZB5Li2FZCTkJKW5ZBUbY9AZD
" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
<input type="submit" name="submit" value="submit" />
</form>
</body>