web.php 13.9 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1
2
<?php

3
use Illuminate\Support\Facades\Redis;
4
use Jenssegers\Agent\Agent;
Dominik Hebeler's avatar
Dominik Hebeler committed
5
use Prometheus\RenderTextFormat;
6

Dominik Hebeler's avatar
Dominik Hebeler committed
7
8
/*
|--------------------------------------------------------------------------
9
| Web Routes
Dominik Hebeler's avatar
Dominik Hebeler committed
10
11
|--------------------------------------------------------------------------
|
12
13
14
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
Dominik Hebeler's avatar
Dominik Hebeler committed
15
|
16
 */
17
18
19
20
21
22
23
24
25
26
27

Route::get("robots.txt", function(Request $request){
    $responseData = "";
    if(App::environment("production")){
        $responseData = view("robots.production");
    }else{
        $responseData = view("robots.development");
    }
    return response($responseData, 200, ["Content-Type" => "text/plain"]);
});

28
29
30
31
32
33
34
Route::group(
    [
        'prefix' => LaravelLocalization::setLocale(), /*,
    'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]*/
    ],
    function () {
        /** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
35

36
        Route::get('/', 'StartpageController@loadStartPage')->name("startpage")->middleware("removekey");
37

38
        Route::get('asso', function () {
39
40
41
            return view('assoziator.asso')
                ->with('title', trans('titles.asso'))
                ->with('navbarFocus', 'dienste');
42
43
        });
        Route::post('asso', 'Assoziator@asso');
44

45
46
47
48
49
50
51
52
        Route::get('impressum', function () {
            return view('impressum')
                ->with('title', trans('titles.impressum'))
                ->with('navbarFocus', 'kontakt');
        });
        Route::get('impressum.html', function () {
            return redirect(url('impressum'));
        });
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        Route::get('about', function () {
            return view('about')
                ->with('title', trans('titles.about'))
                ->with('navbarFocus', 'kontakt');
        });
        Route::get('team', function () {
            return view('team.team')
                ->with('title', trans('titles.team'))
                ->with('navbarFocus', 'kontakt');
        });
        Route::get('team/pubkey-wsb', function () {
            return view('team.pubkey-wsb')
                ->with('title', trans('titles.team'))
                ->with('navbarFocus', 'kontakt');
        });
69

70
        Route::get('kontakt/{url?}', function ($url = "") {
71
72
            return view('kontakt.kontakt')
                ->with('title', trans('titles.kontakt'))
73
                ->with('navbarFocus', 'kontakt')
74
                ->with('url', $url);
Dominik Hebeler's avatar
Dominik Hebeler committed
75
        })->name("contact");
Dominik Hebeler's avatar
Dominik Hebeler committed
76

77
        Route::post('kontakt', 'MailController@contactMail');
78

79
80
81
82
83
84
85
86
        Route::get('tor', function () {
            return view('tor')
                ->with('title', 'tor hidden service - MetaGer')
                ->with('navbarFocus', 'dienste');
        });
        Route::get('spende', function () {
            return view('spende.spende')
                ->with('title', trans('titles.spende'))
87
                ->with('js', [mix('/js/donation.js')])
88
89
                ->with('navbarFocus', 'foerdern');
        });
90
        Route::get('spende/danke/{data}', ['as' => 'danke', function ($data) {
91
92
93
            return view('spende.danke')
                ->with('title', trans('titles.spende'))
                ->with('navbarFocus', 'foerdern')
94
                ->with('css', [mix('/css/spende/danke.css')])
95
                ->with('data', unserialize(base64_decode($data)));
96
        }]);
97
98
99
        Route::get('partnershops', function () {
            return view('spende.partnershops')
                ->with('title', trans('titles.partnershops'))
100
                ->with('navbarFocus', 'foerdern');
101
        });
102

103
        Route::get('beitritt', function () {
104
            if (LaravelLocalization::getCurrentLocale() === "de") {
105
                return response()->download(storage_path('app/public/aufnahmeantrag-de.pdf'), "SUMA-EV_Beitrittsformular_" . (new \DateTime())->format("Y_m_d") . ".pdf", ["Content-Type" => "application/pdf"]);
106
            } else {
107
                return response()->download(storage_path('app/public/aufnahmeantrag-en.pdf'), "SUMA-EV_Membershipform_" . (new \DateTime())->format("Y_m_d") . ".pdf", ["Content-Type" => "application/pdf"]);
108
            }
109
        });
110

111
112
113
        Route::get('bform1.htm', function () {
            return redirect('beitritt');
        });
114

115
        Route::post('spende', 'MailController@donation');
116

117
        Route::get('datenschutz', function () {
118
            return view('datenschutz/datenschutz')
119
120
121
                ->with('title', trans('titles.datenschutz'))
                ->with('navbarFocus', 'datenschutz');
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
122

Dominik Hebeler's avatar
Dominik Hebeler committed
123
        Route::get('transparency', function () {
124
125
126
            return view('transparency')
                 ->with('title', trans('titles.transparency'))
                 ->with('navbarFocus', 'kontakt');
Dominik Hebeler's avatar
Dominik Hebeler committed
127
        });
128

129
130
131
        Route::get('hilfe', function () {
            return view('hilfe')
                ->with('title', trans('titles.hilfe'))
132
133
                ->with('navbarFocus', 'hilfe');
        });
134

Karl Hasselbring's avatar
Karl Hasselbring committed
135
        Route::get('hilfe/faktencheck', function () {
136
137
138
139
140
            return view('faktencheck')
                ->with('title', trans('titles.faktencheck'))
                ->with('navbarFocus', 'hilfe');
        });

141
        Route::get('faq', function () {
Dominik Hebeler's avatar
Dominik Hebeler committed
142
            return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/hilfe'));
143
        });
144

145
        Route::get('widget', function () {
146
            return view('widget.widget')
147
148
                ->with('title', trans('titles.widget'))
                ->with('navbarFocus', 'dienste');
karl's avatar
karl committed
149
        });
150
151
152

        Route::get('sitesearch', 'SitesearchController@loadPage');

153
        Route::get('websearch', function () {
154
155
            return view('widget.websearch')
                ->with('title', trans('titles.websearch'))
Dominik Hebeler's avatar
Dominik Hebeler committed
156
157
                ->with('navbarFocus', 'dienste')
                ->with('template', view('widget.websearch-template')->render());
158
159
        });

160
161
        Route::get('zitat-suche', 'ZitatController@zitatSuche');

Karl Hasselbring's avatar
Karl Hasselbring committed
162
163
164
165
166
        Route::get('jugendschutz', function () {
            return view('jugendschutz')
                ->with('title', trans('titles.jugendschutz'));
        });

Karl Hasselbring's avatar
Karl Hasselbring committed
167
168
169
170
171
        Route::get('ad-info', function () {
            return view('ad-info')
                ->with('title', trans('titles.ad-info'));
        });

Karl Hasselbring's avatar
Karl Hasselbring committed
172
173
174
175
176
177
178
179
180
181
182
183
        Route::get('age.xml', function () {
            $response = Response::make(file_get_contents(resource_path('age/age.xml')));
            $response->header('Content-Type', "application/xml");
            return $response;
        });

        Route::get('age-de.xml', function () {
            $response = Response::make(file_get_contents(resource_path('age/age-de.xml')));
            $response->header('Content-Type', "application/xml");
            return $response;
        });

184
185
186
187
        Route::get('plugin', function () {
            return view('plugin-page')
                ->with('title', trans('titles.plugin'))
                ->with('navbarFocus', 'dienste')
188
                ->with('agent', new Agent())
189
                ->with('browser', (new Agent())->browser())
Davide's avatar
Davide committed
190
                ->with('request', $this->input('request', 'GET'));
191
192
        });

Dominik Hebeler's avatar
Dominik Hebeler committed
193
        Route::group(['middleware' => ['auth.basic'], 'prefix' => 'admin'], function () {
194
            Route::get('/', 'AdminInterface@index');
Karl Hasselbring's avatar
Karl Hasselbring committed
195
            Route::match(['get', 'post'], 'count', 'AdminInterface@count');
Dominik Hebeler's avatar
Dominik Hebeler committed
196
            Route::get('timings', 'MetaGerSearch@searchTimings');
Dominik Hebeler's avatar
Dominik Hebeler committed
197
            Route::get('count/graphtoday.svg', 'AdminInterface@countGraphToday');
Dominik Hebeler's avatar
Dominik Hebeler committed
198
            Route::get('engine/stats.json', 'AdminInterface@engineStats');
199
200
            Route::get('check', 'AdminInterface@check');
            Route::get('engines', 'AdminInterface@engines');
Dominik Hebeler's avatar
Dominik Hebeler committed
201
            Route::get('ip', function () {
Dominik Hebeler's avatar
Dominik Hebeler committed
202
                dd(Request::ip(), $_SERVER["AGENT"]);
Dominik Hebeler's avatar
Dominik Hebeler committed
203
            });
204
205
            Route::get('bot', 'HumanVerification@botOverview');
            Route::post('bot', 'HumanVerification@botOverviewChange');
206
207
208
209
210
211
212
            Route::group(['prefix' => 'spam'], function () {
                Route::get('/', 'AdminSpamController@index');
                Route::post('/', 'AdminSpamController@ban');
                Route::get('jsonQueries', 'AdminSpamController@jsonQueries');
                Route::post('queryregexp', 'AdminSpamController@queryregexp');
                Route::post('deleteRegexp', 'AdminSpamController@deleteRegexp');
            });
Dominik Hebeler's avatar
Dominik Hebeler committed
213
            Route::post('service-desk', 'ServiceDesk@webhook');
214
            Route::get('stress', 'Stresstest@index');
Davide Aprea's avatar
Davide Aprea committed
215
            Route::get('stress/verify', 'Stresstest@index')->middleware('browserverification', 'humanverification');
216
217
218
            Route::get('adgoal', 'AdgoalTestController@index')->name("adgoal-index");
            Route::post('adgoal', 'AdgoalTestController@post')->name("adgoal-generate");
            Route::post('adgoal/generate-urls', 'AdgoalTestController@generateUrls')->name("adgoal-urls");
219
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
220

221
222
223
        Route::get('settings', function () {
            return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/'));
        });
karl's avatar
karl committed
224

225
        Route::match(['get', 'post'], 'meta/meta.ger3', 'MetaGerSearch@search')->middleware('removekey', 'browserverification', 'humanverification', 'useragentmaster')->name("resultpage");
Dominik Hebeler's avatar
Dominik Hebeler committed
226

227
        Route::get('meta/loadMore', 'MetaGerSearch@loadMore');
228
        Route::post('img/cat.png', 'HumanVerification@remove');
229
        Route::get('verify/metager/{id}/{uid}', ['as' => 'captcha', 'uses' => 'HumanVerification@captcha']);
Dominik Hebeler's avatar
Dominik Hebeler committed
230
        Route::get('r/metager/{mm}/{pw}/{url}', ['as' => 'humanverification', 'uses' => 'HumanVerification@removeGet']);
231
        Route::post('img/dog.jpg', 'HumanVerification@whitelist');
Dominik Hebeler's avatar
Dominik Hebeler committed
232
        Route::get('index.css', 'HumanVerification@browserVerification');
233
234
235
236
237
238
239
240
241
242
243
244
245
        Route::get('index.js', function () {
            $key = Request::input("id", "");

            // Verify that key is a md5 checksum
            if (!preg_match("/^[a-f0-9]{32}$/", $key)) {
                abort(404);
            }

            Redis::connection("cache")->pipeline(function ($redis) use ($key) {
                $redis->rpush("js" . $key, true);
                $redis->expire($key, 30);
            });

Dominik Hebeler's avatar
Dominik Hebeler committed
246
            return response("", 200)->header("Content-Type", "application/javascript");
247
        });
Karl Hasselbring's avatar
Karl Hasselbring committed
248

249
250
251
252
        Route::get('meta/picture', 'Pictureproxy@get');
        Route::get('clickstats', 'LogController@clicklog');
        Route::get('pluginClose', 'LogController@pluginClose');
        Route::get('pluginInstall', 'LogController@pluginInstall');
253

254
        Route::get('qt', 'MetaGerSearch@quicktips');
255
        Route::get('tips', 'MetaGerSearch@tips');
256
        Route::get('/plugins/opensearch.xml', 'StartpageController@loadPlugin');
257
258
259
        Route::get('owi', function () {
            return redirect('https://metager.de/klassik/en/owi/');
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
260
261
262
263
264
265
        Route::get('MG20', function () {
            return redirect('https://metager.de/klassik/MG20');
        });
        Route::get('databund', function () {
            return redirect('https://metager.de/klassik/databund');
        });
266
        Route::get('languages', 'LanguageController@createOverview');
267
        Route::get('synoptic/{exclude?}/{chosenFile?}', 'LanguageController@createSynopticEditPage');
268
        Route::post('synoptic/{exclude?}/{chosenFile?}', 'LanguageController@processSynopticPageInput');
269
        Route::get('languages/edit/{from}/{to}/{exclude?}/{email?}', 'LanguageController@createEditPage');
Aria Givi's avatar
Aria Givi committed
270
        Route::post('languages/edit/{from}/{to}/{exclude?}/{email?}', 'MailController@sendLanguageFile');
271
272
273
274
275
276
277
278

        Route::group(['prefix' => 'app'], function () {
            Route::get('/', function () {
                return view('app')
                    ->with('title', trans('titles.app'))
                    ->with('navbarFocus', 'dienste');
            });
            Route::get('metager', function () {
279
280
                return response()->streamDownload(function () {
                    $fh = null;
Dominik Hebeler's avatar
Dominik Hebeler committed
281
                    try {
Dominik Hebeler's avatar
Dominik Hebeler committed
282
                        $fh = fopen("https://gitlab.metager.de/open-source/app-en/-/raw/latest/app/release_manual/app-release_manual.apk", "r");
Dominik Hebeler's avatar
Dominik Hebeler committed
283
                        while (!feof($fh)) {
Dominik Hebeler's avatar
Dominik Hebeler committed
284
                            echo(fread($fh, 1024));
285
                        }
Dominik Hebeler's avatar
Dominik Hebeler committed
286
                    } catch (\Exception $e) {
287
                        abort(404);
Dominik Hebeler's avatar
Dominik Hebeler committed
288
289
                    } finally {
                        if ($fh != null) {
290
291
292
293
                            fclose($fh);
                        }
                    }
                }, 'MetaGerSearch.apk', ["Content-Type" => "application/vnd.android.package-archive"]);
294
295
            });
            Route::get('maps', function () {
296
297
                return response()->streamDownload(function () {
                    $fh = null;
Dominik Hebeler's avatar
Dominik Hebeler committed
298
                    try {
Dominik Hebeler's avatar
Dominik Hebeler committed
299
                        $fh = fopen("https://gitlab.metager.de/open-source/metager-maps-android/raw/latest/app/release/app-release.apk?inline=false", "r");
Dominik Hebeler's avatar
Dominik Hebeler committed
300
                        while (!feof($fh)) {
Dominik Hebeler's avatar
Dominik Hebeler committed
301
                            echo(fread($fh, 1024));
302
                        }
Dominik Hebeler's avatar
Dominik Hebeler committed
303
                    } catch (\Exception $e) {
304
                        abort(404);
Dominik Hebeler's avatar
Dominik Hebeler committed
305
306
                    } finally {
                        if ($fh != null) {
307
308
309
310
                            fclose($fh);
                        }
                    }
                }, 'MetaGerMaps.apk', ["Content-Type" => "application/vnd.android.package-archive"]);
311
            });
Dominik Hebeler's avatar
Dominik Hebeler committed
312

Dominik Hebeler's avatar
Dominik Hebeler committed
313
            Route::get('maps/version', function () {
314
                $filePath = env('maps_version');
Dominik Hebeler's avatar
Dominik Hebeler committed
315
316
317
318
                $fileContents = file_get_contents($filePath);
                return response($fileContents, 200)
                    ->header('Content-Type', 'text/plain');
            });
319
        });
320

Dominik Hebeler's avatar
Dominik Hebeler committed
321
        Route::get('metrics', function () {
322
323
324
325
326
327
            $registry = \Prometheus\CollectorRegistry::getDefault();

            $renderer = new RenderTextFormat();
            $result = $renderer->render($registry->getMetricFamilySamples());

            return response($result, 200)
Dominik Hebeler's avatar
Dominik Hebeler committed
328
                ->header('Content-Type', RenderTextFormat::MIME_TYPE);
329
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
330
331
    }
);