This repository has been archived by the owner on Dec 10, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
253 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -3,3 +3,4 @@ | ||
/prod_tmp | /prod_tmp | ||
/demo | /demo | ||
/maps | /maps | ||
/server/maps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# Prevent maps from being evil | |||
Options -Indexes -ExecCGI | |||
php_flag engine off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
<?php | |||
|
|||
class components_game_upload extends owpcomponent { | |||
protected $templates; | |||
protected $mapGateway; | |||
|
|||
function __construct(k_TemplateFactory $templates, model_MapGateway $mapGateway) { | |||
$this->templates = $templates; | |||
$this->mapGateway = $mapGateway; | |||
} | |||
|
|||
function renderHTML() { | |||
$this->document->setTitle('Upload map'); | |||
|
|||
$t = $this->templates->create('upload-map'); | |||
return $t->render($this, array( | |||
)); | |||
} | |||
|
|||
function postMultipart() { | |||
// Konstrukt's file access crap won't give us a fucking file handle, | |||
// so we do things the old fashion way. | |||
$osz = @$_FILES['osz']; | |||
if ($osz) { | |||
if ($osz['error']) { | |||
return new k_HttpResponse(500, 'Error code ' . $osz['error']); | |||
} | |||
|
|||
$maps = null; | |||
$oszFilePath = $osz['tmp_name']; | |||
try { | |||
$maps = $this->mapGateway->saveOsz($oszFilePath); | |||
} catch (Exception $e) { | |||
// wtf finally | |||
unlink($oszFilePath); | |||
throw $e; | |||
} | |||
|
|||
if (empty($maps)) { | |||
return new k_HttpResponse(500); | |||
} | |||
|
|||
// TODO Uploaded maps page | |||
return new k_SeeOther($this->url(array('game', 'play'), $maps[0]->urlParams())); | |||
} else { | |||
return new k_HttpResponse(400, 'Bad request'); // Bad request | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,10 @@ | |||
<h1>owp maps</h1> | <h1>owp maps</h1> | ||
<p><a href="<?php e(url(array('game', 'upload'))); ?>">Upload custom map</a></p> | |||
|
|||
<p>Choose a map to play:</p> | <p>Choose a map to play:</p> | ||
|
|
||
<ul> | <ul> | ||
<?php foreach ($maps as $map) { ?> | <?php foreach ($maps as $map) { ?> | ||
<li><a href="<?php echo e(url(array('game', 'play'), $map->urlParams())); ?>"><?php echo e($map->title()); ?></a></li> | <li><a href="<?php e(url(array('game', 'play'), $map->urlParams())); ?>"><?php echo e($map->title()); ?></a></li> | ||
<?php } ?> | <?php } ?> | ||
</ul> | </ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<h1>Upload map</h1> | |||
|
|||
<form method="POST" enctype="multipart/form-data"> | |||
<p><label>Upload osu! <tt>.osz</tt> file:<br> | |||
<input type="file" required name="osz"></label> <input type="submit" value="Upload"></p> | |||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters