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

3
use Jenssegers\Agent\Agent;
Dominik Hebeler's avatar
Dominik Hebeler committed
4
use Prometheus\RenderTextFormat;
5

Dominik Hebeler's avatar
Dominik Hebeler committed
6 7
/*
|--------------------------------------------------------------------------
8
| Web Routes
Dominik Hebeler's avatar
Dominik Hebeler committed
9 10
|--------------------------------------------------------------------------
|
11 12 13
| 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
14
|
15 16 17 18 19 20 21 22
 */
Route::group(
    [
        'prefix' => LaravelLocalization::setLocale(), /*,
    'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]*/
    ],
    function () {
        /** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
23

24
        Route::get('/', 'StartpageController@loadStartPage');
25

26
        Route::get('asso', function () {
27 28 29
            return view('assoziator.asso')
                ->with('title', trans('titles.asso'))
                ->with('navbarFocus', 'dienste');
30 31
        });
        Route::post('asso', 'Assoziator@asso');
32

33 34 35 36 37 38 39 40
        Route::get('impressum', function () {
            return view('impressum')
                ->with('title', trans('titles.impressum'))
                ->with('navbarFocus', 'kontakt');
        });
        Route::get('impressum.html', function () {
            return redirect(url('impressum'));
        });
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
        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');
        });
57

58
        Route::get('kontakt/{url?}', function ($url = "") {
59 60
            return view('kontakt.kontakt')
                ->with('title', trans('titles.kontakt'))
61
                ->with('navbarFocus', 'kontakt')
62
                ->with('url', $url);
63
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
64

65
        Route::post('kontakt', 'MailController@contactMail');
66

67 68 69 70 71 72 73 74 75 76
        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'))
                ->with('navbarFocus', 'foerdern');
        });
77
        Route::get('spende/danke/{data}', ['as' => 'danke', function ($data) {
78 79 80 81
            return view('spende.danke')
                ->with('title', trans('titles.spende'))
                ->with('navbarFocus', 'foerdern')
                ->with('data', unserialize(base64_decode($data)));
82
        }]);
83 84 85
        Route::get('partnershops', function () {
            return view('spende.partnershops')
                ->with('title', trans('titles.partnershops'))
86
                ->with('navbarFocus', 'foerdern');
87
        });
88

89
        Route::get('beitritt', function () {
90
            if (LaravelLocalization::getCurrentLocale() === "de") {
91
                return response()->download(storage_path('app/public/aufnahmeantrag-de.pdf'), "SUMA-EV_Beitrittsformular_" . (new \DateTime())->format("Y_m_d") . ".pdf", ["Content-Type" => "application/pdf"]);
92
            } else {
93
                return response()->download(storage_path('app/public/aufnahmeantrag-en.pdf'), "SUMA-EV_Membershipform_" . (new \DateTime())->format("Y_m_d") . ".pdf", ["Content-Type" => "application/pdf"]);
94
            }
95
        });
96

97 98 99
        Route::get('bform1.htm', function () {
            return redirect('beitritt');
        });
100

101
        Route::post('spende', 'MailController@donation');
102

103
        Route::get('datenschutz', function () {
104
            return view('datenschutz/datenschutz')
105 106 107
                ->with('title', trans('titles.datenschutz'))
                ->with('navbarFocus', 'datenschutz');
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
108

109 110 111
        Route::get('hilfe', function () {
            return view('hilfe')
                ->with('title', trans('titles.hilfe'))
112 113
                ->with('navbarFocus', 'hilfe');
        });
114

Karl Hasselbring's avatar
Karl Hasselbring committed
115
        Route::get('hilfe/faktencheck', function () {
116 117 118 119 120
            return view('faktencheck')
                ->with('title', trans('titles.faktencheck'))
                ->with('navbarFocus', 'hilfe');
        });

121
        Route::get('faq', function () {
Dominik Hebeler's avatar
Dominik Hebeler committed
122
            return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/hilfe'));
123
        });
124

125
        Route::get('widget', function () {
126
            return view('widget.widget')
127 128
                ->with('title', trans('titles.widget'))
                ->with('navbarFocus', 'dienste');
129
        });
130 131 132

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

133
        Route::get('websearch', function () {
134 135
            return view('widget.websearch')
                ->with('title', trans('titles.websearch'))
Dominik Hebeler's avatar
Dominik Hebeler committed
136 137
                ->with('navbarFocus', 'dienste')
                ->with('template', view('widget.websearch-template')->render());
138 139
        });

140 141
        Route::get('zitat-suche', 'ZitatController@zitatSuche');

Karl Hasselbring's avatar
Karl Hasselbring committed
142 143 144 145 146
        Route::get('jugendschutz', function () {
            return view('jugendschutz')
                ->with('title', trans('titles.jugendschutz'));
        });

Karl Hasselbring's avatar
Karl Hasselbring committed
147 148 149 150 151
        Route::get('ad-info', function () {
            return view('ad-info')
                ->with('title', trans('titles.ad-info'));
        });

Karl Hasselbring's avatar
Karl Hasselbring committed
152 153 154 155 156 157 158 159 160 161 162 163
        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;
        });

164 165 166 167 168 169 170 171
        Route::get('plugin', function () {
            return view('plugin-page')
                ->with('title', trans('titles.plugin'))
                ->with('navbarFocus', 'dienste')
                ->with('browser', (new Agent())->browser())
                ->with('request', $this->input('request', 'GET'));
        });

Dominik Hebeler's avatar
Dominik Hebeler committed
172
        Route::group(['middleware' => ['auth.basic'], 'prefix' => 'admin'], function () {
173
            Route::get('/', 'AdminInterface@index');
Karl Hasselbring's avatar
Karl Hasselbring committed
174
            Route::match(['get', 'post'], 'count', 'AdminInterface@count');
Dominik Hebeler's avatar
Dominik Hebeler committed
175
            Route::get('timings', 'MetaGerSearch@searchTimings');
Dominik Hebeler's avatar
Dominik Hebeler committed
176
            Route::get('count/graphtoday.svg', 'AdminInterface@countGraphToday');
Dominik Hebeler's avatar
Dominik Hebeler committed
177
            Route::get('engine/stats.json', 'AdminInterface@engineStats');
178 179
            Route::get('check', 'AdminInterface@check');
            Route::get('engines', 'AdminInterface@engines');
Dominik Hebeler's avatar
Dominik Hebeler committed
180
            Route::get('ip', function () {
Dominik Hebeler's avatar
Dominik Hebeler committed
181
                dd(Request::ip(), $_SERVER["AGENT"]);
Dominik Hebeler's avatar
Dominik Hebeler committed
182
            });
183 184
            Route::get('bot', 'HumanVerification@botOverview');
            Route::post('bot', 'HumanVerification@botOverviewChange');
185 186 187 188 189 190 191
            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');
            });
192
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
193

194 195 196
        Route::get('settings', function () {
            return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/'));
        });
197

198
        Route::match(['get', 'post'], 'meta/meta.ger3', 'MetaGerSearch@search')->middleware('humanverification', 'useragentmaster');
Dominik Hebeler's avatar
Dominik Hebeler committed
199

200
        Route::get('meta/loadMore', 'MetaGerSearch@loadMore');
Dominik Hebeler's avatar
Dominik Hebeler committed
201
        Route::post('img/cat.jpg', 'HumanVerification@remove');
Dominik Hebeler's avatar
Dominik Hebeler committed
202
        Route::get('verify/metager/{id}/{uid}', ['as' => 'captcha', 'uses' => 'HumanVerification@captcha', 'middleware' => 'throttle:12,1']);
Dominik Hebeler's avatar
Dominik Hebeler committed
203
        Route::get('r/metager/{mm}/{pw}/{url}', ['as' => 'humanverification', 'uses' => 'HumanVerification@removeGet']);
204
        Route::post('img/dog.jpg', 'HumanVerification@whitelist');
Karl Hasselbring's avatar
Karl Hasselbring committed
205

206 207 208 209
        Route::get('meta/picture', 'Pictureproxy@get');
        Route::get('clickstats', 'LogController@clicklog');
        Route::get('pluginClose', 'LogController@pluginClose');
        Route::get('pluginInstall', 'LogController@pluginInstall');
210

211
        Route::get('qt', 'MetaGerSearch@quicktips');
212
        Route::get('tips', 'MetaGerSearch@tips');
213
        Route::get('/plugins/opensearch.xml', 'StartpageController@loadPlugin');
214 215 216
        Route::get('owi', function () {
            return redirect('https://metager.de/klassik/en/owi/');
        });
Dominik Hebeler's avatar
Dominik Hebeler committed
217 218 219 220 221 222
        Route::get('MG20', function () {
            return redirect('https://metager.de/klassik/MG20');
        });
        Route::get('databund', function () {
            return redirect('https://metager.de/klassik/databund');
        });
223
        Route::get('languages', 'LanguageController@createOverview');
224
        Route::get('synoptic/{exclude?}/{chosenFile?}', 'LanguageController@createSynopticEditPage');
225
        Route::post('synoptic/{exclude?}/{chosenFile?}', 'LanguageController@processSynopticPageInput');
226
        Route::get('languages/edit/{from}/{to}/{exclude?}/{email?}', 'LanguageController@createEditPage');
Aria Givi's avatar
Aria Givi committed
227
        Route::post('languages/edit/{from}/{to}/{exclude?}/{email?}', 'MailController@sendLanguageFile');
228 229 230 231 232 233 234 235

        Route::group(['prefix' => 'app'], function () {
            Route::get('/', function () {
                return view('app')
                    ->with('title', trans('titles.app'))
                    ->with('navbarFocus', 'dienste');
            });
            Route::get('metager', function () {
236 237
                return response()->streamDownload(function () {
                    $fh = null;
Dominik Hebeler's avatar
Dominik Hebeler committed
238
                    try {
Dominik Hebeler's avatar
Dominik Hebeler committed
239
                        $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
240
                        while (!feof($fh)) {
Dominik Hebeler's avatar
Dominik Hebeler committed
241
                            echo (fread($fh, 1024));
242
                        }
Dominik Hebeler's avatar
Dominik Hebeler committed
243
                    } catch (\Exception $e) {
244
                        abort(404);
Dominik Hebeler's avatar
Dominik Hebeler committed
245 246
                    } finally {
                        if ($fh != null) {
247 248 249 250
                            fclose($fh);
                        }
                    }
                }, 'MetaGerSearch.apk', ["Content-Type" => "application/vnd.android.package-archive"]);
251 252
            });
            Route::get('maps', function () {
253 254
                return response()->streamDownload(function () {
                    $fh = null;
Dominik Hebeler's avatar
Dominik Hebeler committed
255
                    try {
Dominik Hebeler's avatar
Dominik Hebeler committed
256
                        $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
257
                        while (!feof($fh)) {
Dominik Hebeler's avatar
Dominik Hebeler committed
258
                            echo (fread($fh, 1024));
259
                        }
Dominik Hebeler's avatar
Dominik Hebeler committed
260
                    } catch (\Exception $e) {
261
                        abort(404);
Dominik Hebeler's avatar
Dominik Hebeler committed
262 263
                    } finally {
                        if ($fh != null) {
264 265 266 267
                            fclose($fh);
                        }
                    }
                }, 'MetaGerMaps.apk', ["Content-Type" => "application/vnd.android.package-archive"]);
268
            });
Dominik Hebeler's avatar
Dominik Hebeler committed
269

Dominik Hebeler's avatar
Dominik Hebeler committed
270
            Route::get('maps/version', function () {
271
                $filePath = env('maps_version');
Dominik Hebeler's avatar
Dominik Hebeler committed
272 273 274 275
                $fileContents = file_get_contents($filePath);
                return response($fileContents, 200)
                    ->header('Content-Type', 'text/plain');
            });
276
        });
277

Dominik Hebeler's avatar
Dominik Hebeler committed
278
        Route::get('metrics', function () {
279 280 281 282 283 284
            $registry = \Prometheus\CollectorRegistry::getDefault();

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

            return response($result, 200)
Dominik Hebeler's avatar
Dominik Hebeler committed
285
                ->header('Content-Type', RenderTextFormat::MIME_TYPE);
286
        });
287
    });