[FEAT] Erweiterung des Codes um 2 Auswahlstufen. Index.php enthält diese Metacommunity Auswahl und die eigentliche Firmware Auswahl ist in firmware.php gewandert.

This commit is contained in:
Caspar Armster 2016-07-17 11:37:14 +02:00
parent db2b06a140
commit b50a50a77d
5 changed files with 678 additions and 376 deletions

View File

@ -6,12 +6,85 @@
*
*/
$text_h1 = "Freifunk Hennef Firmware";
$text_h2 = "Auf dieser Seite können Sie die passende Firmware für ihren Router in Hennef auswählen und herunterladen!";
$link_h2_text = "Zurück zur Startseite";
$link_h2_url = "http://www.freifunk-hennef.de/";
$logo_url = "images/Freifunk-logo-hennef-klein-200.png";
$logo_alt = "Freifunk Hennef Logo";
$texte = array(
"ebene1_titel" => "Freifunk Community",
"ebene1_text" => "Freifunk Community auswählen",
"ebene2_titel" => "Bereich der Community",
"ebene2_text" => "Bereich der Community auswählen",
"ebene3_titel" => "Firmware Downloader",
"ebene3_text" => "Zur Firmware-Download Seite"
);
$firmware_download_path = "../firmware/";
$community = array(
0 => array(
"community_id" => 0,
"name" => "Freifunk Rhein-Sieg",
"head_titel" => "Freifunk Rhein-Sieg Firmware",
"head_text" => "Auf dieser Seite können Sie die passende Community für die Firmware für ihren Router aus dem Rhein-Sieg-Kreis auswählen!",
"link_text" => "Zurück zur Startseite",
"link_url" => "http://www.freifunk-rhein-sieg.de/",
"logo_alt" => "Freifunk Rhein-Sieg-Kreis Logo",
"logo_url" => "images/Freifunk-logo-rhein-sieg-klein-200.png",
"lang_titel" => "Freifunk Rhein-Sieg Community Auswahl",
"lang_text" => "Bitte suchen Sie die passende Community aus, indem Sie die Community und gegebenenfalls noch einen Bereich in der Community auswählen.<br />Sie werden dann weitergeleitet auf die eigentliche Firmware Download Seite für die gewähle Community.",
"download_path" => "",
"sub_auswahl" => ""
),
1 => array(
"community_id" => 1,
"name" => "Freifunk Hennef",
"head_titel" => "Freifunk Hennef Firmware",
"head_text" => "Auf dieser Seite können Sie die passende Firmware für ihren Router in Hennef auswählen und herunterladen!",
"link_text" => "Zurück zur Startseite",
"link_url" => "http://www.freifunk-hennef.de/",
"logo_alt" => "Freifunk Hennef Logo",
"logo_url" => "images/Freifunk-logo-hennef-klein-200.png",
"lang_titel" => "Freifunk Hennef Firmware Auswahl",
"lang_text" => "Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br /><br />Bitte wählen Sie -stable- im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!",
"download_path" => "../fwuploads/hennef/",
"sub_auswahl" => ""
),
2 => array(
"community_id" => 2,
"name" => "Freifunk Troisdorf",
"head_titel" => "Freifunk Troisdorf Fußgängerzone Firmware",
"head_text" => "Auf dieser Seite können Sie die passende Firmware für ihren Router in der Troisdorfer Fußgängerzone auswählen und herunterladen!",
"link_text" => "Zurück zur Startseite",
"link_url" => "http://www.freifunk-troisdorf.de/",
"logo_alt" => "Freifunk Troisdorf Logo",
"logo_url" => "images/Freifunk-logo-troisdorf-klein-200.png",
"lang_titel" => "Freifunk Troisdorf Firmware Auswahl",
"lang_text" => "Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br /><br />Bitte wählen Sie -stable- im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!",
"download_path" => "../fwuploads/troisdorf/inn/",
"sub_auswahl" => "Fußgängerzone"
),
3 => array(
"community_id" => 2,
"name" => "Freifunk Troisdorf",
"head_titel" => "Freifunk Troisdorf Firmware",
"head_text" => "Auf dieser Seite können Sie die passende Firmware für ihren Router in Troisdorf auswählen und herunterladen!",
"link_text" => "Zurück zur Startseite",
"link_url" => "http://www.freifunk-troisdorf.de/",
"logo_alt" => "Freifunk Troisdorf Logo",
"logo_url" => "images/Freifunk-logo-troisdorf-klein-200.png",
"lang_titel" => "Freifunk Troisdorf Firmware Auswahl",
"lang_text" => "Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br /><br />Bitte wählen Sie -stable- im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!",
"download_path" => "../fwuploads/troisdorf/tdf/",
"sub_auswahl" => "Troisdorf"
),
4 => array(
"community_id" => 2,
"name" => "Freifunk Troisdorf",
"head_titel" => "Freifunk Troisdorf Flüchtlingsunterkunft Firmware",
"head_text" => "Auf dieser Seite können Sie die passende Firmware für ihren Router in einer Troisdorfer Flüchtlingsunterkunft auswählen und herunterladen!",
"link_text" => "Zurück zur Startseite",
"link_url" => "http://www.freifunk-troisdorf.de/",
"logo_alt" => "Freifunk Troisdorf Logo",
"logo_url" => "images/Freifunk-logo-troisdorf-klein-200.png",
"lang_titel" => "Freifunk Troisdorf Firmware Auswahl",
"lang_text" => "Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br /><br />Bitte wählen Sie -stable- im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!",
"download_path" => "../fwuploads/troisdorf/flu/",
"sub_auswahl" => "Flüchtlingsunterkunft"
)
);
?>

489
firmware.php Normal file
View File

@ -0,0 +1,489 @@
<?php
/**
* @author Caspar Armster
* @copyright 2016 Caspar Armster, Freifunk Hennef/Freie Netzwerker e.V. (www.freifunk-hennef.de / www.freie-netzwerker.de)
* @license Licensed under GPLv3
*
*/
error_reporting (E_ALL | E_STRICT);
ini_set ('display_errors', 'On');
require_once('community-config.inc.php');
require_once('config.inc.php');
require_once('ffrouter.class.php');
require_once('ffrouter_parsen.function.php');
echo <<<EOT
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Freifunk Hennef Firmware Downloadseite</title>
<meta name="author" content="Caspar Armster">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
EOT;
try {
require_once('ffrouter_parsen.function.php');
} catch(Exception $e) {
echo("Fehler: ".$e->getMessage());
die();
}
$router_json = json_encode($router);
echo("\n<script>\n");
echo("var router_text = '".$router_json."';\n");
echo("var router_json = JSON.parse(router_text);\n");
echo("var anzahl_hersteller = ".$anzahl_hersteller.";\n");
echo("var herstellername = [");
for( $i=0; $i<$anzahl_hersteller; $i++) {
echo("\"".$hersteller[$i]['name']."\"");
if( $i != $anzahl_hersteller-1) {
echo(", ");
}
}
echo("];\n");
echo <<<EOT
function populateA(){
var s1 = document.getElementById("fw-dl-1");
var s2 = document.getElementById("fw-dl-2");
var s3 = document.getElementById("fw-dl-3");
var s4 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
var optionArray = new Array();
s2.innerHTML = "";
for(i=0; i<anzahl_hersteller; i++) {
if(s1.value == herstellername[i]) {
optionArray[0] = "|Modell auswählen";
var j = 0;
while(j < router_json.length) {
if(router_json[j].hersteller == herstellername[i]) {
optionArray[j+1] = router_json[j].modell+"|"+router_json[j].modell;
if(j<router_json.length-1) {
while(router_json[j].modell == router_json[j+1].modell) {
if(j<router_json.length-1) {
j++;
} else {
break;
}
}
}
}
j++;
}
}
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s3.length > 1) {
s3.remove(s3.length-1);
}
while(s4.length > 1) {
s4.remove(s4.length-1);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = "router_images/keinbild.jpg";
img_router_back.src = "router_images/keinbild.jpg";
}
function populateB(){
var s1 = document.getElementById("fw-dl-2");
var s2 = document.getElementById("fw-dl-3");
var s4 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
var optionArray = new Array();
optionArray[0] = "|Modell auswählen";
s2.innerHTML = "";
var i = 0;
while(i < router_json.length) {
if(router_json[i].modell == s1.value) {
optionArray[i+1] = i+"|"+router_json[i].version;
if(i<router_json.length-1) {
while(router_json[i].modell == router_json[i+1].modell) {
if(i<router_json.length-1) {
i++;
optionArray[i+1] = i+"|"+router_json[i].version;
} else {
break;
}
}
}
}
i++;
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s4.length > 1) {
s4.remove(s4.length-1);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = "router_images/keinbild.jpg";
img_router_back.src = "router_images/keinbild.jpg";
}
function populateC(){
var s1 = document.getElementById("fw-dl-3");
var s2 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
var optionArray = new Array();
optionArray[0] = "|Erstinstallation?";
s2.innerHTML = "";
var newImageFront = router_json[s1.value].imagefront;
var newImageBack = router_json[s1.value].imageback;
var i = 1;
if((router_json[s1.value].betafactory == 1) || (router_json[s1.value].brokenfactory == 1) || (router_json[s1.value].experimentalfactory == 1) || (router_json[s1.value].stablefactory == 1)) {
optionArray[i] = s1.value+"J|Ja";
i++;
}
if((router_json[s1.value].betasysupgrade == 1) || (router_json[s1.value].brokensysupgrade == 1) || (router_json[s1.value].experimentalsysupgrade == 1) || (router_json[s1.value].stablesysupgrade == 1)) {
optionArray[i] = s1.value+"N|Nein";
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = newImageFront;
img_router_back.src = newImageBack;
}
function populateD(){
var s1 = document.getElementById("fw-dl-4");
var s2 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var optionArray = new Array();
optionArray[0] = "|Entwicklungsstadium?";
s2.innerHTML = "";
var id = parseInt(s1.value.slice(0,s1.value.length));
var jein = s1.value.slice(-1);
var i = 1;
if(jein == "J") {
if(router_json[id].betafactory == 1) {
optionArray[i] = id+"Jbeta|Beta";
i++;
}
if(router_json[id].brokenfactory == 1) {
optionArray[i] = id+"Jbroken|Broken";
i++;
}
if(router_json[id].experimentalfactory == 1) {
optionArray[i] = id+"Jexp|Experimental";
i++;
}
if(router_json[id].stablefactory == 1) {
optionArray[i] = id+"Jstable|Stable";
i++;
}
}
if(jein == "N") {
if(router_json[id].betasysupgrade == 1) {
optionArray[i] = id+"Nbeta|Beta";
i++;
}
if(router_json[id].brokensysupgrade == 1) {
optionArray[i] = id+"Nbroken|Broken";
i++;
}
if(router_json[id].experimentalsysupgrade == 1) {
optionArray[i] = id+"Nexp|Experimental";
i++;
}
if(router_json[id].stablesysupgrade == 1) {
optionArray[i] = id+"Nstable|Stable";
i++;
}
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
}
function populateE(){
var s1 = document.getElementById("fw-dl-5");
var s2 = document.getElementById("fw-dl-6");
s2.innerHTML = "";
if(s1.value.lastIndexOf("Jbeta") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-4));
var link = router_json[id].betafactorylink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Jbroken") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].brokenfactorylink;
var linkclass = " btn-danger";
}
if(s1.value.lastIndexOf("Jexp") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-3));
var link = router_json[id].experimentalfactorylink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Jstable") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].stablefactorylink;
var linkclass = " btn-success";
}
if(s1.value.lastIndexOf("Nbeta") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-4));
var link = router_json[id].betasysupgradelink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Nbroken") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].brokensysupgradelink;
var linkclass = " btn-danger";
}
if(s1.value.lastIndexOf("Nexp") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-3));
var link = router_json[id].experimentalsysupgradelink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Nstable") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].stablesysupgradelink;
var linkclass = " btn-success";
}
s2.href = link;
s2.className = s2.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s2.className += linkclass;
s2.innerHTML = "Download Firmware";
}
</script>
</head>
<body>
<div class="container-fluid">
EOT;
for($i=0; $i<$err; $i++) {
echo("<div class=\"alert alert-warning alert-dismissible\" role=\"alert\">\n");
echo(" <span class=\"glyphicon glyphicon-exclamation-sign\" aria-hidden=\"true\"></span>\n");
echo(" <span class=\"sr-only\">Warning:</span>\n");
echo(" <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n");
echo(" <strong>Warning!</strong> ".$error_text[$i]."\n");
echo("</div>\n");
}
echo <<<EOT
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
EOT;
echo("<img src=\"".$logo_url."\" alt=\"".$logo_alt."\" style=\"float:right;\">");
echo <<<EOT
<h2>
EOT;
echo($text_h1);
echo <<<EOT
</h2>
<p>
EOT;
echo($text_h2);
echo <<<EOT
</p>
<p>
EOT;
echo("<a class=\"btn btn-primary btn-large\" href=\"".$link_h2_url."\">".$link_h2_text."</a>");
echo <<<EOT
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($text_h1);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
<img src="router_images/keinbild.jpg" id="img_router_back" alt="Router Rückseite" width=200px" style="float:right;">
<img src="router_images/keinbild.jpg" id="img_router_front" alt="Router Vorderseite" width=200px" style="float:right;">
Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />
Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br />
<br />
Bitte wählen Sie "stable" im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!
</div>
<div class="panel-footer">
<img src="images/ccbyncsa.png" alt="CC BY-NC-SA" width="60px"> Die Router Bilder sind von Daniel Krah und sind lizensiert unter einer <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target:"_blank">Creative Commons Namensnennung - Nicht-kommerziell - Weitergabe unter gleichen Bedingungen 4.0 International Lizenz</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Hersteller
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-1" name="fw-dl-1" onchange="populateA()">
<option value="">Hersteller auswählen</option>
EOT;
for($i=0; $i<$anzahl_hersteller; $i++) {
echo("<option value=\"".$hersteller[$i]['name']."\">".$hersteller[$i]['name']."</option>");
}
echo <<<EOT
</select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Modell
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-2" name="fw-dl-2" onchange="populateB()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Version
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-3" name="fw-dl-3" onchange="populateC()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Erstinstallation
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-4" name="fw-dl-4" onchange="populateD()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Entwicklungsstadium
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-5" name="fw-dl-5" onchange="populateE()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Download
</h3>
</div>
<div class="panel-body">
<a href="#" id="fw-dl-6" name="fw-dl-6" role="button" class="btn btn-primary disabled">Download Firmware</a>
</div>
<div class="panel-footer">
Licensed under GPLv3 / Copyright 2016 by Caspar Armster, <a href="http://www.freifunk-hennef.de/">Freifunk Hennef</a> / <a href="http://www.freie-netzwerker.de/">Freie Netzwerker e.V.</a>
</div>
</div>
</div>
</div>
</div>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- <script src="js/scripts.js"></script> -->
</body>
</html>
EOT;
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

478
index.php
View File

@ -1,4 +1,4 @@
<?php
<?php
/**
* @author Caspar Armster
* @copyright 2016 Caspar Armster, Freifunk Hennef/Freie Netzwerker e.V. (www.freifunk-hennef.de / www.freie-netzwerker.de)
@ -6,11 +6,9 @@
*
*/
error_reporting (E_ALL | E_STRICT);
ini_set ('display_errors', 'On');
ini_set ('display_errors', 'On');
require_once('community-config.inc.php');
require_once('config.inc.php');
require_once('ffrouter.class.php');
require_once('ffrouter_parsen.function.php');
require_once('config.inc.php');
echo <<<EOT
<!DOCTYPE html>
@ -19,10 +17,11 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
EOT;
echo("<title>".$community[0]["head_titel"]."</title>");
echo <<<EOT
<title>Freifunk Hennef Firmware Downloadseite</title>
<meta name="author" content="LayoutIt!">
<meta name="author" content="Caspar Armster">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
@ -31,60 +30,44 @@
<link rel="icon" href="favicon.ico" type="image/x-icon">
EOT;
try {
require_once('ffrouter_parsen.function.php');
} catch(Exception $e) {
echo("Fehler: ".$e->getMessage());
die();
}
$router_json = json_encode($router);
echo("\n<script>\n");
echo("var router_text = '".$router_json."';\n");
echo("var router_json = JSON.parse(router_text);\n");
echo("var anzahl_hersteller = ".$anzahl_hersteller.";\n");
echo("var herstellername = [");
for( $i=0; $i<$anzahl_hersteller; $i++) {
echo("\"".$hersteller[$i]['name']."\"");
if( $i != $anzahl_hersteller-1) {
echo(", ");
}
}
echo("];\n");
$community_json = json_encode($community);
$texte_json = json_encode($texte);
echo("\n<script>\n");
echo("var community_text = '".$community_json."';\n");
echo("var community_json = JSON.parse(community_text);\n");
echo("var texte_text = '".$texte_json."';\n");
echo("var texte_json = JSON.parse(texte_text);\n");
echo("var community_anzahl = ".count($community).";\n");
echo <<<EOT
function populateA(){
var s1 = document.getElementById("fw-dl-1");
var s2 = document.getElementById("fw-dl-2");
var s3 = document.getElementById("fw-dl-3");
var s4 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
s3.className = s3.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s3.className = s3.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s3.className = s3.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
var optionArray = new Array();
s2.innerHTML = "";
for(i=0; i<anzahl_hersteller; i++) {
if(s1.value == herstellername[i]) {
optionArray[0] = "|Modell auswählen";
var j = 0;
while(j < router_json.length) {
if(router_json[j].hersteller == herstellername[i]) {
optionArray[j+1] = router_json[j].modell+"|"+router_json[j].modell;
if(j<router_json.length-1) {
while(router_json[j].modell == router_json[j+1].modell) {
if(j<router_json.length-1) {
j++;
} else {
break;
}
}
}
}
j++;
}
}
var i=1;
var j=1;
var skip_sub = 0;
while(i<community_anzahl) {
if(s1.value == community_json[i]["name"]) {
if(community_json[i]["sub_auswahl"] != "") {
optionArray[j] = i+"|"+community_json[i]["sub_auswahl"];
$('#fw-dl-2').prop('disabled', false);
optionArray[0] = "|"+texte_json["ebene2_text"];
} else {
$('#fw-dl-2').prop('disabled', true);
optionArray[0] = "|";
var link = "firmware.php?id="+i;
var linkclass = " btn-success";
skip_sub = 1;
}
j++;
}
i++;
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
@ -93,267 +76,55 @@ function populateA(){
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s3.length > 1) {
s3.remove(s3.length-1);
s3.innerHTML = "";
if(skip_sub == 1) {
s3.href = link;
s3.className += linkclass;
} else {
s3.href = "#";
s3.className += " btn-primary disabled";
}
while(s4.length > 1) {
s4.remove(s4.length-1);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = "router_images/keinbild.jpg";
img_router_back.src = "router_images/keinbild.jpg";
s3.innerHTML = texte_json["ebene3_text"];
}
function populateB(){
var s1 = document.getElementById("fw-dl-2");
var s2 = document.getElementById("fw-dl-3");
var s4 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
var optionArray = new Array();
optionArray[0] = "|Modell auswählen";
s2.innerHTML = "";
var i = 0;
while(i < router_json.length) {
if(router_json[i].modell == s1.value) {
optionArray[i+1] = i+"|"+router_json[i].version;
if(i<router_json.length-1) {
while(router_json[i].modell == router_json[i+1].modell) {
if(i<router_json.length-1) {
i++;
optionArray[i+1] = i+"|"+router_json[i].version;
} else {
break;
}
}
}
}
i++;
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s4.length > 1) {
s4.remove(s4.length-1);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = "router_images/keinbild.jpg";
img_router_back.src = "router_images/keinbild.jpg";
}
function populateC(){
var s1 = document.getElementById("fw-dl-3");
var s2 = document.getElementById("fw-dl-4");
var s5 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var img_router_front = document.getElementById("img_router_front");
var img_router_back = document.getElementById("img_router_back");
var optionArray = new Array();
optionArray[0] = "|Erstinstallation?";
s2.innerHTML = "";
var newImageFront = router_json[s1.value].imagefront;
var newImageBack = router_json[s1.value].imageback;
var i = 1;
if((router_json[s1.value].betafactory == 1) || (router_json[s1.value].brokenfactory == 1) || (router_json[s1.value].experimentalfactory == 1) || (router_json[s1.value].stablefactory == 1)) {
optionArray[i] = s1.value+"J|Ja";
i++;
}
if((router_json[s1.value].betasysupgrade == 1) || (router_json[s1.value].brokensysupgrade == 1) || (router_json[s1.value].experimentalsysupgrade == 1) || (router_json[s1.value].stablesysupgrade == 1)) {
optionArray[i] = s1.value+"N|Nein";
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
while(s5.length > 1) {
s5.remove(s5.length-1);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
img_router_front.src = newImageFront;
img_router_back.src = newImageBack;
}
function populateD(){
var s1 = document.getElementById("fw-dl-4");
var s2 = document.getElementById("fw-dl-5");
var s6 = document.getElementById("fw-dl-6");
var optionArray = new Array();
optionArray[0] = "|Entwicklungsstadium?";
s2.innerHTML = "";
var id = parseInt(s1.value.slice(0,s1.value.length));
var jein = s1.value.slice(-1);
var i = 1;
if(jein == "J") {
if(router_json[id].betafactory == 1) {
optionArray[i] = id+"Jbeta|Beta";
i++;
}
if(router_json[id].brokenfactory == 1) {
optionArray[i] = id+"Jbroken|Broken";
i++;
}
if(router_json[id].experimentalfactory == 1) {
optionArray[i] = id+"Jexp|Experimental";
i++;
}
if(router_json[id].stablefactory == 1) {
optionArray[i] = id+"Jstable|Stable";
i++;
}
}
if(jein == "N") {
if(router_json[id].betasysupgrade == 1) {
optionArray[i] = id+"Nbeta|Beta";
i++;
}
if(router_json[id].brokensysupgrade == 1) {
optionArray[i] = id+"Nbroken|Broken";
i++;
}
if(router_json[id].experimentalsysupgrade == 1) {
optionArray[i] = id+"Nexp|Experimental";
i++;
}
if(router_json[id].stablesysupgrade == 1) {
optionArray[i] = id+"Nstable|Stable";
i++;
}
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
s6.href = "#";
s6.className = s6.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s6.className = s6.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s6.className += " btn-primary disabled";
s6.innerHTML = "Download Firmware";
}
function populateE(){
var s1 = document.getElementById("fw-dl-5");
var s2 = document.getElementById("fw-dl-6");
s2.innerHTML = "";
if(s1.value.lastIndexOf("Jbeta") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-4));
var link = router_json[id].betafactorylink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Jbroken") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].brokenfactorylink;
var linkclass = " btn-danger";
}
if(s1.value.lastIndexOf("Jexp") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-3));
var link = router_json[id].experimentalfactorylink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Jstable") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].stablefactorylink;
var s1 = document.getElementById("fw-dl-1");
var s2 = document.getElementById("fw-dl-2");
var s3 = document.getElementById("fw-dl-3");
s3.innerHTML = "";
if(s2.value != 0) {
var link = "firmware.php?id="+s2.value;
var linkclass = " btn-success";
}
if(s1.value.lastIndexOf("Nbeta") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-4));
var link = router_json[id].betasysupgradelink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Nbroken") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].brokensysupgradelink;
var linkclass = " btn-danger";
}
if(s1.value.lastIndexOf("Nexp") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-3));
var link = router_json[id].experimentalsysupgradelink;
var linkclass = " btn-warning";
}
if(s1.value.lastIndexOf("Nstable") != -1) {
var id = parseInt(s1.value.slice(0,s1.value.length-6));
var link = router_json[id].stablesysupgradelink;
var linkclass = " btn-success";
}
s2.href = link;
s2.className = s2.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-danger(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-warning(?!\S)/g , '' );
s2.className = s2.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s2.className += linkclass;
s2.innerHTML = "Download Firmware";
s3.href = link;
s3.className = s3.className.replace( /(?:^|\s)disabled(?!\S)/g , '' );
s3.className = s3.className.replace( /(?:^|\s)btn-primary(?!\S)/g , '' );
s3.className = s3.className.replace( /(?:^|\s)btn-success(?!\S)/g , '' );
s3.className += linkclass;
s3.innerHTML = texte_json["ebene3_text"];
}
</script>
</head>
<body>
<div class="container-fluid">
EOT;
for($i=0; $i<$err; $i++) {
echo("<div class=\"alert alert-warning alert-dismissible\" role=\"alert\">\n");
echo(" <span class=\"glyphicon glyphicon-exclamation-sign\" aria-hidden=\"true\"></span>\n");
echo(" <span class=\"sr-only\">Warning:</span>\n");
echo(" <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n");
echo(" <strong>Warning!</strong> ".$error_text[$i]."\n");
echo("</div>\n");
}
echo <<<EOT
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
EOT;
echo("<img src=\"".$logo_url."\" alt=\"".$logo_alt."\" style=\"float:right;\">");
echo("<img src=\"".$community[0]["logo_url"]."\" alt=\"".$community[0]["logo_alt"]."\" style=\"float:right;\">");
echo <<<EOT
<h2>
EOT;
echo($text_h1);
echo($community[0]["head_titel"]);
echo <<<EOT
</h2>
<p>
EOT;
echo($text_h2);
echo($community[0]["head_text"]);
echo <<<EOT
</p>
<p>
EOT;
echo("<a class=\"btn btn-primary btn-large\" href=\"".$link_h2_url."\">".$link_h2_text."</a>");
echo("<a class=\"btn btn-primary btn-large\" href=\"".$community[0]["link_url"]."\">".$community[0]["link_text"]."</a>");
echo <<<EOT
</p>
</div>
@ -365,20 +136,16 @@ echo <<<EOT
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($text_h1);
echo($community[0]["lang_titel"]);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
<img src="router_images/keinbild.jpg" id="img_router_back" alt="Router Rückseite" width=200px" style="float:right;">
<img src="router_images/keinbild.jpg" id="img_router_front" alt="Router Vorderseite" width=200px" style="float:right;">
Bitte suchen Sie den passenden Router aus, indem Sie den Hersteller, das Modell und die Version auswählen.<br />
Legen Sie anschließend fest, ob sie den Router zum ersten Mal mit einer Freifunk Firmware flashen und welches Entwicklungsstadium die Firmware haben soll.<br />
<br />
Bitte wählen Sie "stable" im Entwicklungsstadium aus, wenn Sie nicht genau wissen was Sie sonst erwartet!
EOT;
echo($community[0]["lang_text"]);
echo <<<EOT
</div>
<div class="panel-footer">
<img src="images/ccbyncsa.png" alt="CC BY-NC-SA" width="60px"> Die Router Bilder sind von Daniel Krah und sind lizensiert unter einer <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target:"_blank">Creative Commons Namensnennung - Nicht-kommerziell - Weitergabe unter gleichen Bedingungen 4.0 International Lizenz</a>
</div>
</div>
</div>
@ -387,20 +154,31 @@ echo <<<EOT
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Hersteller
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-1" name="fw-dl-1" onchange="populateA()">
<option value="">Hersteller auswählen</option>
<h3 class="panel-title">
EOT;
for($i=0; $i<$anzahl_hersteller; $i++) {
echo("<option value=\"".$hersteller[$i]['name']."\">".$hersteller[$i]['name']."</option>");
echo($texte["ebene1_titel"]);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-1" name="fw-dl-1" class="form-control" onchange="populateA()">
EOT;
echo("<option value=\"\">".$texte["ebene1_text"]."</option>");
for($i=1; $i<count($community); $i++) {
echo("<option value=\"".$community[$i]['name']."\">".$community[$i]['name']."</option>");
if($i<count($community)) {
while($community[$i]['name'] == $community[$i+1]['name']) {
if($i<count($community)-1) {
$i++;
} else {
break;
}
}
}
}
echo <<<EOT
</select>
</div>
</div>
<div class="panel-footer">
</div>
</div>
@ -408,12 +186,14 @@ EOT;
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Modell
<h3 class="panel-title">
EOT;
echo($texte["ebene2_titel"]);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-2" name="fw-dl-2" onchange="populateB()"></select>
</div>
<div class="panel-body">
<select id="fw-dl-2" name="fw-dl-2" class="form-control" disabled onchange="populateB()"></select>
</div>
<div class="panel-footer">
</div>
@ -421,61 +201,21 @@ EOT;
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Router Version
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-3" name="fw-dl-3" onchange="populateC()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Erstinstallation
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-4" name="fw-dl-4" onchange="populateD()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Entwicklungsstadium
</h3>
</div>
<div class="panel-body">
<select id="fw-dl-5" name="fw-dl-5" onchange="populateE()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Download
</h3>
</div>
<div class="panel-body">
<a href="#" id="fw-dl-6" name="fw-dl-6" role="button" class="btn btn-primary disabled">Download Firmware</a>
</div>
<div class="panel-footer">
Licensed under GPLv3 / Copyright 2016 by Caspar Armster, <a href="http://www.freifunk-hennef.de/">Freifunk Hennef</a> / <a href="http://www.freie-netzwerker.de/">Freie Netzwerker e.V.</a>
</div>
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($texte["ebene3_titel"]);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
EOT;
echo("<a href=\"#\" id=\"fw-dl-3\" name=\"fw-dl-3\" role=\"button\" class=\"btn btn-primary disabled\">".$texte["ebene3_text"]."</a>");
echo <<<EOT
</div>
<div class="panel-footer">
Licensed under GPLv3 / Copyright 2016 by Caspar Armster, <a href="http://www.freifunk-hennef.de/">Freifunk Hennef</a> / <a href="http://www.freie-netzwerker.de/">Freie Netzwerker e.V.</a>
</div>
</div>
</div>
</div>