Commit 6aecb324 authored by Aria Givi's avatar Aria Givi
Browse files

Zip Dateien können heruntergeladen werden, Zips manchmal corrupted

parent 3727641c
......@@ -9,6 +9,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use LaravelLocalization;
use Mail;
use ZipArchive;
class MailController extends Controller
{
......@@ -141,7 +142,7 @@ class MailController extends Controller
private function processKey($key)
{
$key = trim($key);
preg_match("/^(?:_new_)?(?:[^_]*)_(\w*#?\w*)/", $key, $matches);
preg_match("/^(?:_new_)?(?:[^_]*)_(\w*.?\w*#?.?\w*)/", $key, $matches);
foreach($matches as $processedKey) {
if(strpos($processedKey, "_") === FALSE) {
return $processedKey;
......@@ -237,9 +238,34 @@ class MailController extends Controller
public function downloadModifiedLanguagefiles(Request $request, $exclude = "") {
public function processSynopticPageInput(Request $request, $exclude = "") {
$filename = $request->input('filename');
if(isset($request['nextpage'])) {
$ex = [];
if ($exclude !== "") {
try {
$ex = unserialize(base64_decode($exclude));
} catch (\ErrorException $e) {
$ex = [];
}
if (!isset($ex["files"])) {
$ex["files"] = [];
}
}
if (!isset($ex["new"])) {
$ex["new"] = 0;
}
$ex['files'][] = basename($filename);
$ex = base64_encode(serialize($ex));
return redirect(url('synoptic', ['exclude' => $ex]));
}
$data = [];
$new = 0;
$editedFiles = [];
......@@ -257,7 +283,7 @@ class MailController extends Controller
if (strpos($key, "_new_") === 0 && $value !== "") {
$new++;
$editedFiles[$langdir] = $filename;
} else if ($this->isEdited($key, $value, $fn)) {
} else if ($this->isEdited($this->processKey($key), $value, $fn)) {
$new++;
$editedFiles[$langdir] = $filename;
}
......@@ -284,47 +310,31 @@ class MailController extends Controller
}
}
#Erstelle Ausgabedateien
foreach($data as $lang => $entries) {
$output[$lang] = json_encode($entries, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$output[$lang] = preg_replace("/\{/si", "[", $output[$lang]);
$output[$lang] = preg_replace("/\}/si", "]", $output[$lang]);
$output[$lang] = preg_replace("/\": ([\"\[])/si", "\"\t=>\t$1", $output[$lang]);
$output[$lang] = "<?php\n\nreturn $output[$lang];\n";
if(empty($data)) {
return redirect(url('synoptic', ['exclude' => $exclude]));
}
$zip = new ZipArchive();
$ex = [];
if ($exclude !== "") {
try {
$ex = unserialize(base64_decode($exclude));
} catch (\ErrorException $e) {
$ex = [];
}
if (!isset($ex["files"])) {
$ex["files"] = [];
}
}
if (!isset($ex["new"])) {
$ex["new"] = 0;
if ($zip->open("langfiles.zip", ZipArchive::OVERWRITE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$ex['files'][] = basename($filename);
$ex["new"] += $new;
if ($new > 0) {
#Erstelle Ausgabedateien
foreach($data as $lang => $entries) {
$output = json_encode($entries, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$output = preg_replace("/\{/si", "[", $output);
$output = preg_replace("/\}/si", "]", $output);
$output = preg_replace("/\": ([\"\[])/si", "\"\t=>\t$1", $output);
$output = "<?php\n\nreturn $output;\n";
$zip->addEmptyDir($lang);
$zip->addFromString($lang."/".$filename, $output);
}
$ex = base64_encode(serialize($ex));
$zip->close();
$zip = new ZipArchive();
return response()->download("langfiles.zip", "langfiles.zip");
return response()->make($output["fr"])
->header("Content-type","text/plain; charset=utf-8")
->header("Content-disposition","attachment; filename=\"".$filename."\"");
//return response()->download($output["fr"], $filename);
//return redirect(url('synoptic', ['exclude' => $ex]));
}
......
......@@ -33,7 +33,7 @@
@foreach($language as $lang => $languageValue)
@if($languageValue !== "")
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="{{base64_encode($lang."_".$key)}}">{{ $languageValue }} </textarea>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="{{base64_encode($lang."_".$key)}}">{{$languageValue}}</textarea>
</td>
@else
<td>
......@@ -52,8 +52,8 @@
<p>{!! trans('languages.hinweis.3') !!}</p>
<p>{!! trans('languages.email') !!}</p>
-->
<button class="btn btn-success" type="submit" form="submit">Dateien herunterladen</button>
<button class="btn btn-success" type="submit" form="submit">Nächste Seite</button>
<button name="download" class="btn btn-success" type="submit" form="submit">Dateien herunterladen</button>
<button name="nextpage" class="btn btn-success" type="submit" form="submit">Nächste Seite</button>
<script type="text/javascript" src="{{ elixir('js/lib.js') }}"></script>
<script type="text/javascript" src="{{ elixir('js/editLanguage.js') }}"></script>
@endsection
......@@ -159,7 +159,7 @@ Route::group(
});
Route::get('languages', 'LanguageController@createOverview');
Route::get('synoptic/{exclude?}', 'LanguageController@createSynopticEditPage');
Route::post('synoptic/{exclude?}', 'MailController@downloadModifiedLanguagefiles');
Route::post('synoptic/{exclude?}', 'MailController@processSynopticPageInput');
Route::get('languages/edit/{from}/{to}/{exclude?}/{email?}', 'LanguageController@createEditPage');
Route::post('languages/edit/{from}/{to}/{exclude?}/{email?}', 'MailController@sendLanguageFile');
Route::get('berlin', 'StartpageController@berlin');
......
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Sprachdateien bearbeiten - MetaGer</title>
<meta name="description" content="Sicher suchen und finden unter Wahrung der Privatsphäre. Das digitale Wissen der Welt muss ohne Bevormundung durch Staaten oder Konzerne frei zugänglich sein und bleiben." />
<meta name="keywords" content="Internetsuche, privatsphäre, privacy, Suchmaschine, Datenschutz, Anonproxy, anonym suchen, Bildersuche, Suchmaschine, anonym, MetaGer, metager, metager.de" />
<meta name="page-topic" content="Dienstleistung" />
<meta name="robots" content="index,follow" />
<meta name="revisit-after" content="7 days" />
<meta name="audience" content="all" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE" />
<link rel="search" type="application/opensearchdescription+xml" title="MetaGer: Sicher suchen &amp; finden, Privatsphäre schützen" href="http://localhost:8000/plugins/YTowOnt9/opensearch.xml">
<link type="text/css" rel="stylesheet" href="/css/themes/default.css" />
<link id="theme" type="text/css" rel="stylesheet" href="/css/theme.css.php" />
</head>
<body>
<header>
<a class="navbar-brand" href="http://localhost:8000/">
<div class="logo">
<h1>MetaGer</h1>
</div>
</a>
<nav id="navbar-static-pages" class="navbar-resultpage">
<ul id="metager-static-nav-list" class="list-inline pull-right">
<li id="toggle-nav-hide" class="hidden">
<a class="metager-navbar-toggle pull-right" href="#" data-original-title="" title="">
<span class="sr-only">Navigation anzeigen</span>
<i class="fa fa-bars" aria-hidden="true"></i>
</a>
<div class="clearfix"></div>
</li>
<li id="toggle-nav-show">
<a class="metager-navbar-toggle pull-right" href="#metager-static-nav-list" data-original-title="" title="">
<span class="sr-only">Navigation anzeigen</span>
<i class="fa fa-bars" aria-hidden="true"></i>
</a>
<div class="clearfix"></div>
</li>
<li class="active" >
<a href="http://localhost:8000/" tabindex="200" id="navigationSuche">Suche</a>
</li>
<li class="metager-dropdown" >
<a class="metager-dropdown-toggle" role="button" aria-expanded="false" tabindex="201">Fördern
<span class="caret"></span></a>
<ul class="metager-dropdown-menu">
<li>
<a href="http://localhost:8000/spende" tabindex="202">Spenden</a>
</li>
<li>
<a href="http://localhost:8000/beitritt" tabindex="203">Beitrittsformular SUMA-EV</a>
</li>
<li>
<a href="https://www.boost-project.com/de/shops?charity_id=1129&amp;tag=bl" tabindex="204">Einkaufen bei MetaGer-Fördershops</a>
</li>
</ul>
</li>
<li id="gutscheine" class="metager-dropdown" >
<a href="https://metager.de/gutscheine/">Gutscheine</a>
<a class="metager-dropdown-toggle" data-role="button" aria-expanded="false" tabindex="205"><span class="caret"></span></span>
<ul class="metager-dropdown-menu">
<li>
<a href="https://metager.de/gutscheine/congstar/" tabindex="206" >Congstar Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/check24/" tabindex="207" >Check24 Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/handyflash/" tabindex="208" >Handyflash Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/groupon/" tabindex="209" >Groupon Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/medion/" tabindex="210" >Medion Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/navabi/" tabindex="211" >Navabi Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/netcologne/" tabindex="212" >Netcologne Gutschein</a>
</li>
<li>
<a href="https://metager.de/gutscheine/teufel/" tabindex="213" >Teufel Gutschein</a>
</li>
<li role="separator" class="divider"></li>
<li>
<a href="https://metager.de/gutscheine/alle-gutscheine/" tabindex="214" >Alle Gutscheine</a>
</li>
</ul>
</li>
<li >
<a href="http://localhost:8000/datenschutz" id="navigationPrivacy" tabindex="215">Datenschutz</a>
</li>
<li class="metager-dropdown" >
<a class="metager-dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false" id="navigationHilfe" tabindex="216">Hilfe
<span class="caret"></span></a>
<ul class="metager-dropdown-menu">
<li>
<a href="http://localhost:8000/hilfe" tabindex="217">Hilfe</a>
</li>
<li>
<a href="http://localhost:8000/faq" tabindex="218">FAQ</a>
</li>
</ul>
</li>
<li class="metager-dropdown" >
<a class="metager-dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false" id="navigationKontakt" tabindex="219">Kontakt
<span class="caret"></span></a>
<ul class="metager-dropdown-menu">
<li>
<a href="http://forum.suma-ev.de/" tabindex="220">Forum</a>
</li>
<li>
<a href="http://localhost:8000/kontakt" tabindex="221">Kontakt</a>
</li>
<li>
<a href="http://localhost:8000/team" tabindex="222">Team</a>
</li>
<li>
<a href="http://localhost:8000/about" tabindex="223">Über uns</a>
</li>
<li>
<a href="http://localhost:8000/impressum" tabindex="224">Impressum</a>
</li>
</ul>
</li>
<li class="metager-dropdown" >
<a class="metager-dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" tabindex="225">Dienste
<span class="caret"></span></a>
<ul class="metager-dropdown-menu">
<li>
<a href="http://localhost:8000/widget" tabindex="226">Widget</a>
</li>
<li>
<a href="http://localhost:8000/zitat-suche" tabindex="227">Zitatsuche</a>
</li>
<li>
<a href="https://metager.de/klassik/asso/" tabindex="228">Assoziator</a>
</li>
<li>
<a href="http://code.metager.de/" tabindex="229">Code-Suche</a>
</li>
<li>
<a href="http://localhost:8000/app" tabindex="230">MetaGer App</a>
</li>
<li>
<a href="https://metager.to/" tabindex="231">URL-Verkürzer</a>
</li>
<li>
<a href="https://maps.metager.de" target="_blank" tabindex="232">Maps.MetaGer.de</a>
</li>
<li>
<a href="https://gitlab.metager3.de/open-source/MetaGer" tabindex="233">MetaGer Quellcode</a>
</li>
<li>
<a href="http://forum.suma-ev.de/viewtopic.php?f=3&amp;t=43" tabindex="234">TOR-Hidden-Service</a>
</li>
</ul>
</li>
<li class="metager-dropdown">
<a class="metager-dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false" id="navigationSprache" tabindex="235">Sprache (Deutsch)
<span class="caret"></span></a>
<ul class="metager-dropdown-menu">
<li>
<a rel="alternate" hreflang="de" href="http://localhost:8000/synoptic" tabindex="235">Deutsch</a>
</li>
<li>
<a rel="alternate" hreflang="en" href="http://localhost:8000/en/synoptic" tabindex="236">English</a>
</li>
<li>
<a rel="alternate" hreflang="es" href="http://localhost:8000/es/synoptic" tabindex="237">español</a>
</li>
<li>
<a rel="alternate" hreflang="fr" href="http://localhost:8000/fr/synoptic" tabindex="238">français</a>
</li>
</ul>
</li>
</ul>
</nav>
</header>
<div class="wrapper">
<main class="mg-panel container">
<h1>Übersicht</h1>
<h2>results.php</h2>
<form id="submit" method="POST">
<input type="hidden" name="filename" value="results.php" />
</form>
<table class="table">
<thead>
<tr>
<th>#ID</th>
<th>de</th>
<th>en</th>
<th>es</th>
<th>fr</th>
<th>nd</th>
</tr>
</thead>
<tbody>
<tr> <!--Key -->
<td class="name language-name">redirect</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZGVfcmVkaXJlY3Q=">(mit redirect) </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZW5fcmVkaXJlY3Q=">(with redirect) </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZXNfcmVkaXJlY3Q=">(con desviar) </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19mcl9yZWRpcmVjdA=="></textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19uZF9yZWRpcmVjdA=="></textarea>
</td>
</tr>
<tr> <!--Key -->
<td class="name language-name">weiter</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZGVfd2VpdGVy">Weitersuchen </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZW5fd2VpdGVy">more </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZXNfd2VpdGVy">Continuar </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19mcl93ZWl0ZXI="></textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19uZF93ZWl0ZXI="></textarea>
</td>
</tr>
<tr> <!--Key -->
<td class="name language-name">zurueck</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZGVfenVydWVjaw==">Zurück </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZW5fenVydWVjaw==">back </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZXNfenVydWVjaw==">Atrás </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19mcl96dXJ1ZWNr"></textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19uZF96dXJ1ZWNr"></textarea>
</td>
</tr>
<tr> <!--Key -->
<td class="name language-name">filter</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZGVfZmlsdGVy">Die Suchergebnisse wurden gefiltert: &lt;strong&gt;[:filter]&lt;/strong&gt;. &lt;a href=&quot;:link&quot; target=&quot;_blank&quot;&gt;Filter abschalten.&lt;/a&gt; </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZW5fZmlsdGVy">Results are filtered by language: &lt;strong&gt;[:filter]&lt;/strong&gt;. &lt;a href=&quot;:link&quot; target=&quot;_blank&quot;&gt;Disable this filter.&lt;/a&gt; </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZXNfZmlsdGVy">Resultados filtraban: &lt;strong&gt;[:filter]&lt;/strong&gt;. &lt;a href=&quot;:link&quot; target=&quot;_blank&quot;&gt;Desactivar filtro.&lt;/a&gt; </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19mcl9maWx0ZXI="></textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19uZF9maWx0ZXI="></textarea>
</td>
</tr>
<tr> <!--Key -->
<td class="name language-name">filter.default</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZGVfZmlsdGVyLmRlZmF1bHQ=">Sie erhalten die Benutzeroberfläche in &lt;strong&gt;:langName&lt;/strong&gt;, aber Ergebnisse in &lt;strong&gt;ALLEN&lt;/strong&gt; Sprachen. Für ausschließlich deutschsprachige Ergebnisse können Sie unter &lt;a href=&quot;/settings&quot; target=&quot;_blank&quot;&gt;anpassen&lt;/a&gt; die &quot;Sprache auswählen&quot;. </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZW5fZmlsdGVyLmRlZmF1bHQ=">The interface language is set to &lt;strong&gt;:langName&lt;/strong&gt; but you will receive results in &lt;strong&gt;ALL&lt;/strong&gt; languages. If you want to restrict the results to a specific language, please click &lt;a href=&quot;/en/settings&quot; target=&quot;_blank&quot;&gt;customize&lt;/a&gt; and choose your desired language there. </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="ZXNfZmlsdGVyLmRlZmF1bHQ=">Recibís el interfaz del usuario en &lt;strong&gt;:langName&lt;/strong&gt;, pero resultados en &lt;strong&gt;TODOS&lt;/strong&gt; idiomas. Usan &lt;a href=&quot;/settings&quot; target=&quot;_blank&quot;&gt;adjustar&lt;/a&gt; para seleccionar una idioma para los resultados. </textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19mcl9maWx0ZXIuZGVmYXVsdA=="></textarea>
</td>
<td>
<textarea class="language-text-area" rows="1" cols="20" form="submit" name="X25ld19uZF9maWx0ZXIuZGVmYXVsdA=="></textarea>
</td>
</tr>
</tbody>
</table>
<!--
<p>Sobald du mit deinen Texten zufrieden bist, kannst du uns diese mit einem Klick auf folgenden Knopf automatisch zusenden. Wenn es mehr fehlende Texte in der angegebenen Sprache gibt, wird dein Browser dich danach direkt zu diesen leiten.</p>
<p><b>Hinweis</b>: Die übermittelten Texte werden von diesem Tool erst erkannt, sobald diese von uns gesichtet und eingefügt wurden. Wenn du deine Arbeit sichern möchtest um diese zu einem späteren Zeitpunkt fortzusetzen (auch wenn wir deine bisherige Arbeit noch nicht übernehmen konnten), so reicht es vollkommen, den aktuellen Link aus deiner Browserleiste zu kopieren und zu einem späteren Zeitpunkt wieder aufzurufen.</p>
<p><b>Achtung</b>: Mit der Einsendung stimmst du einer <a href="https://gitlab.metager3.de/open-source/MetaGer" target="_blank" rel="noopener">Veröffentlichung</a> deiner Texte unter AGPL-v3-Lizenz durch uns zu. Falls du namentlich genannt werden möchtest, teile uns dies bitte in einer email an <a href="mailto:office@suma-ev.de">office@suma-ev.de</a> mit.</p>
<p><b>E-Mail-Adresse für Rückfragen</b> (optional):</p>
-->
<button class="btn btn-success" type="submit" form="submit">Dateien herunterladen</button>
<button class="btn btn-success" type="submit" form="submit">Nächste Seite</button>
<script type="text/javascript" src="/js/lib.js"></script>
<script type="text/javascript" src="/build/js/editLanguage-7a1cbfb2ba.js"></script>
</main>
<footer class="noprint">
<ul class="list-inline hidden-xs">
<li>
<a href="https://www.suma-ev.de/" >
<img src="/img/suma_ev_logo-m1-greyscale.png" alt="SUMA-EV Logo"></a>
</li>
<li id="info">
<a href="http://localhost:8000/kontakt">Kontakt</a> - <a href="http://localhost:8000/impressum">Impressum</a>
MetaGer wird entwickelt und betrieben vom <a href="https://www.suma-ev.de/">SUMA-EV - Verein für freien Wissenszugang.</a>
</li>
<li>
<a href="https://www.uni-hannover.de/" >
<img src="/img/luh_metager.png" alt="LUH Logo"></a>
</li>
</ul>
</footer>
<img src="http://localhost:8000/img/piwik.png?site=http%3A%2F%2Flocalhost%3A8000%2Fsynoptic" class="hidden" />
</div>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment