1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* rmarchiv.tk |
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
6
|
|
|
* (c) 2018 by Gabriel 'Ghabry' Kind |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace App\Http\Controllers; |
10
|
|
|
|
11
|
|
|
use App\Models\Game; |
12
|
|
|
use App\Models\GamesFile; |
13
|
|
|
use App\Models\PlayerIndexjson; |
14
|
|
|
|
15
|
|
|
class PlayerMvController extends Controller |
16
|
|
|
{ |
17
|
|
|
public function index($gamefileid) |
18
|
|
|
{ |
19
|
|
|
if (\Auth::check()) { |
20
|
|
|
$gamefile = GamesFile::whereId($gamefileid)->first(); |
21
|
|
|
$path = storage_path('app/public/'.$gamefile->filename); |
|
|
|
|
22
|
|
|
$game = Game::whereId($gamefile->game_id)->first(); |
|
|
|
|
23
|
|
|
|
24
|
|
|
$index = PlayerIndexjson::whereGamefileId($gamefileid)->first(); |
25
|
|
|
$zip = new \ZipArchive(); |
|
|
|
|
26
|
|
|
$zip->open($path); |
27
|
|
|
$fp = $zip->getFromName($index->value.'index.html'); |
28
|
|
|
|
29
|
|
|
return view('playermv.index', [ |
30
|
|
|
'gamefileid' => $gamefileid, |
31
|
|
|
'game' => $game, |
32
|
|
|
'index' => $fp, |
33
|
|
|
]); |
34
|
|
|
} else { |
35
|
|
|
return redirect()->action('IndexController@index'); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function deliver($gamefileid, $filename) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
// OrangeMouseData is broken outside of Chrome browser -_- |
42
|
|
|
if ($filename == 'js/plugins/OrangeMouseData.js') { |
43
|
|
|
$path = public_path('mv/'.$filename); |
44
|
|
|
|
45
|
|
|
return response()->download($path); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$gf = GamesFile::whereId($gamefileid)->first(); |
|
|
|
|
49
|
|
|
$index = PlayerIndexjson::whereGamefileId($gamefileid)->first(); |
50
|
|
|
|
51
|
|
|
$path = storage_path('app/public/'.$gf->filename); |
52
|
|
|
|
53
|
|
|
$zip = new \ZipArchive(); |
54
|
|
|
$zip->open($path); |
55
|
|
|
$fp = $zip->getFromName($index->value.$filename); |
56
|
|
|
|
57
|
|
|
$t = 'application/octet-stream'; |
58
|
|
|
// Loading fails when js or css have wrong mimetype |
59
|
|
|
if (ends_with($filename, '.js') == true) { |
|
|
|
|
60
|
|
|
$t = 'application/javascript'; |
61
|
|
|
} elseif (ends_with($filename, '.css') == true) { |
|
|
|
|
62
|
|
|
$t = 'text/css'; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return response($fp, 200)->header('Content-Type', $t); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.