Merge pull request #1 from anoymouserver/master

beautify and unify code
This commit is contained in:
Caspar Armster 2016-07-24 22:13:24 +02:00 committed by GitHub
commit e987207218
10 changed files with 1277 additions and 1375 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
# EditorConfig is awesome: http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
[*.md]
trim_trailing_whitespace = false
[*.js]
indent_size = 2

View File

@ -48,7 +48,7 @@
"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.",
"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ählte Community.",
"download_path" => "",
"sub_auswahl" => ""
),
@ -249,4 +249,3 @@
"sub_auswahl" => ""
)
);
?>

View File

@ -6,120 +6,120 @@
*/
$entwicklung = array(
0 => "beta",
1 => "broken",
2 => "experimental",
3 => "stable"
"beta",
"broken",
"experimental",
"stable"
);
$installation = array(
0 => "factory",
1 => "sysupgrade"
"factory",
"sysupgrade"
);
for( $i=0; $i<count($entwicklung); $i++ ) {
for( $j=0; $j<count($installation); $j++ ) {
for ($i = 0; $i < count($entwicklung); $i++) {
for ($j = 0; $j < count($installation); $j++) {
$variante[$entwicklung[$i]][$installation[$j]] = 0;
}
}
$hersteller = array(
0 => array(
array(
"name" => "8devices",
"filename" => "8devices",
"offset_modell" => 9,
"offset_version" => 3
),
1 => array(
array(
"name" => "Alfa",
"filename" => "alfa",
"offset_modell" => 5,
"offset_version" => 4
),
2 => array(
array(
"name" => "Allnet",
"filename" => "allnet",
"offset_modell" => 7,
"offset_version" => 4
),
3 => array(
array(
"name" => "Buffalo",
"filename" => "buffalo",
"offset_modell" => 8,
"offset_version" => 4
),
4 => array(
array(
"name" => "D-Link",
"filename" => "d-link",
"offset_modell" => 7,
"offset_version" => -1
),
5 => array(
array(
"name" => "GL-Inet",
"filename" => "gl-inet",
"offset_modell" => 8,
"offset_version" => -1
),
6 => array(
array(
"name" => "LeMaker",
"filename" => "lemaker",
"offset_modell" => 8,
"offset_version" => 4
),
7 => array(
array(
"name" => "Linksys",
"filename" => "linksys",
"offset_modell" => 8,
"offset_version" => 4
),
8 => array(
array(
"name" => "Meraki",
"filename" => "meraki",
"offset_modell" => 7,
"offset_version" => 4
),
9 => array(
array(
"name" => "Netgear",
"filename" => "netgear",
"offset_modell" => 8,
"offset_version" => 4
),
10 => array(
array(
"name" => "Onion",
"filename" => "onion",
"offset_modell" => 6,
"offset_version" => 4
),
11 => array(
array(
"name" => "Openmesh",
"filename" => "openmesh",
"offset_modell" => 9,
"offset_version" => 4
),
12 => array(
array(
"name" => "Raspberry Pi",
"filename" => "raspberry-pi",
"offset_modell" => 13,
"offset_version" => 4
),
13 => array(
array(
"name" => "TP-Link",
"filename" => "tp-link",
"offset_modell" => 8,
"offset_version" => -1
),
14 => array(
array(
"name" => "Ubiquiti",
"filename" => "ubiquiti",
"offset_modell" => 9,
"offset_version" => 4
),
15 => array(
array(
"name" => "Western Digital",
"filename" => "-wd-",
"offset_modell" => 5,
"offset_version" => 4
),
16 => array(
array(
"name" => "x86",
"filename" => "x86",
"offset_modell" => 4,
@ -132,4 +132,3 @@
0 => 0,
1 => 11
);
?>

12
css/bootstrap.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -4,16 +4,36 @@
* @license Licensed under GPLv3
*
*/
@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic");
body {
font-family: "Source Sans Pro","Helvetica Neue",Helvetica,Arial,sans-serif;
color:#555555;
}
.panel-default > .panel-heading {
background-color: #111;
color: #fff;
}
.panel-footer {
font-size: 80%;
}
.btn {
font-variant: small-caps;
font-weight: bold;
}
.btn-primary {
background-color: #dc0067 !important;
border-color: #cc0057 !important;
}
.panel-primary > .panel-heading {
background-color: #000000 !important;
.img-box {
width: 175px;
height: 175px;
object-fit: contain;
margin: 5px;
}
@media (min-width: 1200px) {
.container{
width:auto;

View File

@ -32,4 +32,3 @@ class ffrouter {
$this->stablesysupgradelink = "";
}
}
?>

View File

@ -121,4 +121,3 @@ for( $i=0; $i<count($router); $i++ ) { // Routerbilder einbauen
$router[$i]->imageback = "router_images/keinbild.jpg";
}
}
?>

View File

@ -4,34 +4,29 @@
* @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');
$community_id = $_REQUEST['id'];
echo <<<EOT
error_reporting (E_ALL ^ E_NOTICE);
require_once('community-config.inc.php');
require_once('config.inc.php');
require_once('ffrouter.class.php');
$community_id = $_REQUEST['id'];
?>
<!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">
<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><?php echo $community[$community_id]["head_titel"]?></title>
EOT;
echo("<title>".$community[$community_id]["head_titel"]."</title>");
echo <<<EOT
<meta name="author" content="Caspar Armster">
<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;
<?php
$firmware_download_path = $community[$community_id]["download_path"];
try {
@ -40,455 +35,391 @@ EOT;
echo("Fehler: ".$e->getMessage());
die();
}
$router_json = json_encode($router);
$texte_json = json_encode($texte);
?>
echo("\n<script>\n");
echo("var router_text = '".$router_json."';\n");
echo("var router_json = JSON.parse(router_text);\n");
echo("var texte_text = '".$texte_json."';\n");
echo("var texte_json = JSON.parse(texte_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(", ");
<script>
<?php
echo "var router_json = ".json_encode($router)."\n";
echo "var texte_json = ".json_encode($texte)."\n";
echo "var anzahl_hersteller = ".$anzahl_hersteller."\n";
$manufacturer = array();
foreach ($hersteller as $i => $value) {
array_push($manufacturer, $value['name']);
}
}
echo("];\n");
echo "var herstellername = ".json_encode($manufacturer)."\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++;
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 = [ ]
s2.innerHTML = ''
for (var 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;
break
}
}
}
}
j++;
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);
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 (s3.length > 1) {
s3.remove(s3.length - 1)
}
while(s4.length > 1) {
s4.remove(s4.length-1);
while (s4.length > 1) {
s4.remove(s4.length - 1)
}
while(s5.length > 1) {
s5.remove(s5.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;
s6.href = '#'
s6.classList.remove('disabled', 'btn-primary', 'btn-danger', 'btn-warning', 'btn-success')
s6.className.add('btn-primary', 'disabled')
s6.textContent = 'Download Firmware'
img_router_front.src = 'router_images/keinbild.jpg'
img_router_back.src = 'router_images/keinbild.jpg'
}
function populateB () {
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 = [ ]
optionArray[0] = '|Modell auswählen'
s3.innerHTML = ''
var i = 0
while (i < router_json.length) {
if (router_json[i].modell == s2.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;
break
}
}
}
}
i++;
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);
for (var option in optionArray) {
var pair = optionArray[option].split('|')
var newOption = document.createElement('option')
newOption.value = pair[0]
newOption.innerHTML = pair[1]
s3.options.add(newOption)
}
while(s4.length > 1) {
s4.remove(s4.length-1);
while (s4.length > 1) {
s4.remove(s4.length - 1)
}
while(s5.length > 1) {
s5.remove(s5.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++;
s6.href = '#'
s6.classList.remove('disabled', 'btn-primary', 'btn-danger', 'btn-warning', 'btn-success')
s6.className.add('btn-primary', 'disabled')
s6.textContent = 'Download Firmware'
img_router_front.src = 'router_images/keinbild.jpg'
img_router_back.src = 'router_images/keinbild.jpg'
}
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";
function populateC () {
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 = [ ]
optionArray[0] = '|Erstinstallation?'
s4.innerHTML = ''
var newImageFront = router_json[s3.value].imagefront
var newImageBack = router_json[s3.value].imageback
var i = 1
if ((router_json[s3.value].betafactory == 1) || (router_json[s3.value].brokenfactory == 1) || (router_json[s3.value].experimentalfactory == 1) || (router_json[s3.value].stablefactory == 1)) {
optionArray[i] = s3.value + 'J|Ja'
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);
if ((router_json[s3.value].betasysupgrade == 1) || (router_json[s3.value].brokensysupgrade == 1) || (router_json[s3.value].experimentalsysupgrade == 1) || (router_json[s3.value].stablesysupgrade == 1)) {
optionArray[i] = s3.value + 'N|Nein'
}
while(s5.length > 1) {
s5.remove(s5.length-1);
for (var option in optionArray) {
var pair = optionArray[option].split('|')
var newOption = document.createElement('option')
newOption.value = pair[0]
newOption.innerHTML = pair[1]
s4.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";
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++;
while (s5.length > 1) {
s5.remove(s5.length - 1)
}
if(router_json[id].brokenfactory == 1) {
optionArray[i] = id+"Jbroken|Broken";
i++;
s6.href = '#'
s6.classList.remove('disabled', 'btn-primary', 'btn-danger', 'btn-warning', 'btn-success')
s6.className.add('btn-primary', 'disabled')
s6.textContent = 'Download Firmware'
img_router_front.src = newImageFront
img_router_back.src = newImageBack
}
if(router_json[id].experimentalfactory == 1) {
optionArray[i] = id+"Jexp|Experimental";
i++;
function populateD () {
var s4 = document.getElementById('fw-dl-4')
var s5 = document.getElementById('fw-dl-5')
var s6 = document.getElementById('fw-dl-6')
var optionArray = [ ]
optionArray[0] = '|Entwicklungsstadium?'
s5.innerHTML = ''
var id = parseInt(s4.value.slice(0, s4.value.length))
var jein = s4.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].stablefactory == 1) {
optionArray[i] = id+"Jstable|Stable";
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 (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].brokensysupgrade == 1) {
optionArray[i] = id + 'Nbroken|Broken'
i++
}
if(router_json[id].experimentalsysupgrade == 1) {
optionArray[i] = id+"Nexp|Experimental";
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++;
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);
for (var option in optionArray) {
var pair = optionArray[option].split('|')
var newOption = document.createElement('option')
newOption.value = pair[0]
newOption.innerHTML = pair[1]
s5.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";
s6.href = '#'
s6.classList.remove('disabled', 'btn-primary', 'btn-danger', 'btn-warning', 'btn-success')
s6.className.add('btn-primary', 'disabled')
s6.textContent = 'Download Firmware'
}
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";
function populateE () {
var s5 = document.getElementById('fw-dl-5')
var s6 = document.getElementById('fw-dl-6')
var id = 0
var link = '#'
var linkclass = ''
if (s5.value.lastIndexOf('Jbeta') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 4))
link = router_json[id].betafactorylink
linkclass = ' btn-warning'
}
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 (s5.value.lastIndexOf('Jbroken') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 6))
link = router_json[id].brokenfactorylink
linkclass = ' btn-danger'
}
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 (s5.value.lastIndexOf('Jexp') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 3))
link = router_json[id].experimentalfactorylink
linkclass = ' btn-warning'
}
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 (s5.value.lastIndexOf('Jstable') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 6))
link = router_json[id].stablefactorylink
linkclass = ' btn-success'
}
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 (s5.value.lastIndexOf('Nbeta') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 4))
link = router_json[id].betasysupgradelink
linkclass = ' btn-warning'
}
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 (s5.value.lastIndexOf('Nbroken') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 6))
link = router_json[id].brokensysupgradelink
linkclass = ' btn-danger'
}
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";
if (s5.value.lastIndexOf('Nexp') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 3))
link = router_json[id].experimentalsysupgradelink
linkclass = ' btn-warning'
}
if (s5.value.lastIndexOf('Nstable') != -1) {
id = parseInt(s5.value.slice(0, s5.value.length - 6))
link = router_json[id].stablesysupgradelink
linkclass = ' btn-success'
}
s6.href = link
s6.classList.remove('disabled', 'btn-primary', 'btn-danger', 'btn-warning', 'btn-success')
s6.className.add(linkclass)
s6.textContent = 'Download Firmware'
}
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">
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">
</head>
<body>
<div class="jumbotron">
EOT;
echo("<img src=\"".$community[$community_id]["logo_url"]."\" alt=\"".$community[$community_id]["logo_alt"]."\" style=\"float:right;\">");
echo <<<EOT
<h2>
EOT;
echo($community[$community_id]["head_titel"]);
echo <<<EOT
</h2>
<div class="container">
<div class="col-xs-12">
<img src="<?php echo $community[$community_id]['logo_url']?>" alt="<?php echo $community[$community_id]['logo_alt']?>" class="pull-right img-box" />
<h2><?php echo $community[$community_id]['head_titel']?></h2>
<p><?php echo $community[$community_id]['head_text']?></p>
<p>
EOT;
echo($community[$community_id]["head_text"]);
echo <<<EOT
</p>
<p>
EOT;
echo("<a class=\"btn btn-primary btn-large\" href=\"".$community[$community_id]["link_url"]."\">".$community[$community_id]["link_text"]."</a>");
echo <<<EOT
<a class="btn btn-primary btn-large" href="<?php echo $community[$community_id]['link_url']?>"><?php echo $community[$community_id]['link_text']?></a>
</p>
</div>
</div>
</div>
<div class="container">
<?php for ($i = 0; $i < $err; $i++): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Warning:</span>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Warning!</strong> <?php echo $error_text[$i] ?>
</div>
<?php endfor ?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($community[$community_id]["lang_titel"]);
echo <<<EOT
</h3>
<h3 class="panel-title"><?php echo $community[$community_id]["lang_title"]?></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;">
EOT;
echo($community[$community_id]["lang_text"]);
echo <<<EOT
<img src="router_images/keinbild.jpg" class="pull-right img-box" id="img_router_back" alt="Router Rückseite" />
<img src="router_images/keinbild.jpg" class="pull-right img-box" id="img_router_front" alt="Router Vorderseite" />
<p><?php echo $community[$community_id]["lang_text"]?></p>
</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>
<img src="images/ccbyncsa.png" alt="CC BY-NC-SA" class="pull-left" style="width: 60px; margin-right: 15px;" />
<p>Die Router Bilder sind von Daniel Krah und unter <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> lizensiert.</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Router Hersteller
</h3>
<h3 class="panel-title">Router Hersteller</h3>
</div>
<div class="panel-body">
<select id="fw-dl-1" name="fw-dl-1" class="form-control" onchange="populateA()">
<select id="fw-dl-1" name="fw-dl-1" class="form-control" onchange="firmwarePage.onUpdate_1()">
<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
<?php foreach ($hersteller as $value): ?>
<option value="<?php echo $value['name']?>"><?php echo $value['name']?></option>
<?php endforeach ?>
</select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Router Modell
</h3>
<h3 class="panel-title">Router Modell</h3>
</div>
<div class="panel-body">
<select id="fw-dl-2" name="fw-dl-2" class="form-control" onchange="populateB()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Router Version
</h3>
<h3 class="panel-title">Router Version</h3>
</div>
<div class="panel-body">
<select id="fw-dl-3" name="fw-dl-3" class="form-control" 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 panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Erstinstallation
</h3>
<h3 class="panel-title">Firmware Erstinstallation</h3>
</div>
<div class="panel-body">
<select id="fw-dl-4" name="fw-dl-4" class="form-control" onchange="populateD()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Entwicklungsstadium
</h3>
<h3 class="panel-title">Firmware Entwicklungsstadium</h3>
</div>
<div class="panel-body">
<select id="fw-dl-5" name="fw-dl-5" class="form-control" onchange="populateE()"></select>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Firmware Download
</h3>
<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>
<a href="#" id="fw-dl-6" name="fw-dl-6" role="button" class="btn btn-primary btn-block disabled">Download Firmware</a>
</div>
</div>
</div>
</div>
</div>
<hr />
<footer>
<div class="col-xs-12 text-muted text-center">
<p>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></p>
</div>
</footer>
</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>
</body>
</html>
EOT;
?>

288
index.php
View File

@ -4,228 +4,170 @@
* @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');
error_reporting (E_ALL ^ E_NOTICE);
require_once('community-config.inc.php');
require_once('config.inc.php');
if(count($community) == 1) {
header('Location: firmware.php?id=0');
exit;
if (count($community) == 1) {
header('Location: firmware.php?id=0');
exit;
}
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">
EOT;
echo("<title>".$community[0]["head_titel"]."</title>");
echo <<<EOT
<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><?php echo $community[0]["head_titel"]?></title>
<meta name="author" content="Caspar Armster">
<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;
$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");
<script>
<?php
echo "var community_json = ".json_encode($community)."\n";
echo "var texte_json = ".json_encode($texte)."\n";
echo "var community_anzahl = ".count($community)."\n";
?>
function populateA () {
var s1 = document.getElementById('fw-dl-1')
var s2 = document.getElementById('fw-dl-2')
var s3 = document.getElementById('fw-dl-3')
s3.classList.remove('disabled', 'btn-primary', 'btn-success')
var optionArray = []
s2.innerHTML = ''
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('|')
var newOption = document.createElement('option')
newOption.value = pair[0]
newOption.innerHTML = pair[1]
s2.options.add(newOption)
}
if (skip_sub == 1) {
s3.href = link
s3.classList.add(linkclass)
} else {
s3.href = '#'
s3.classList.add('btn-primary', 'disabled')
}
s3.textContent = texte_json['ebene3_text']
}
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");
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 = "";
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;
function populateB () {
var s2 = document.getElementById('fw-dl-2')
var s3 = document.getElementById('fw-dl-3')
s3.classList.remove('disabled', 'btn-primary', 'btn-success')
if (s2.value != 0) {
s3.href = 'firmware.php?id=' + s2.value
s3.classList.add('btn-success')
}
j++;
s3.href = link
s3.textContent = texte_json['ebene3_text']
}
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);
}
s3.innerHTML = "";
if(skip_sub == 1) {
s3.href = link;
s3.className += linkclass;
} else {
s3.href = "#";
s3.className += " btn-primary disabled";
}
s3.innerHTML = texte_json["ebene3_text"];
}
function populateB(){
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";
}
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">
<div class="row">
<div class="col-md-12">
</head>
<body>
<div class="jumbotron">
EOT;
echo("<img src=\"".$community[0]["logo_url"]."\" alt=\"".$community[0]["logo_alt"]."\" style=\"float:right;\">");
echo <<<EOT
<h2>
EOT;
echo($community[0]["head_titel"]);
echo <<<EOT
</h2>
<div class="container">
<div class="col-xs-12">
<img src="<?php echo $community[0]['logo_url']?>" alt="<?php echo $community[0]['logo_alt']?>" class="pull-right img-box" />
<h2><?php echo $community[0]['head_titel']?></h2>
<p><?php echo $community[0]['head_text']?></p>
<p>
EOT;
echo($community[0]["head_text"]);
echo <<<EOT
</p>
<p>
EOT;
echo("<a class=\"btn btn-primary btn-large\" href=\"".$community[0]["link_url"]."\">".$community[0]["link_text"]."</a>");
echo <<<EOT
<a class="btn btn-primary btn-large" href="<?php echo $community[0]['link_url']?>"><?php echo $community[0]['link_text']?></a>
</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($community[0]["lang_titel"]);
echo <<<EOT
</h3>
</div>
<div class="panel-body">
EOT;
echo($community[0]["lang_text"]);
echo <<<EOT
</div>
<div class="panel-footer">
<h3 class="panel-title"><?php echo $community[0]["lang_titel"] ?></h3>
</div>
<div class="panel-body"><p><?php echo $community[0]["lang_text"] ?></p></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($texte["ebene1_titel"]);
echo <<<EOT
</h3>
<h3 class="panel-title"><?php echo $texte["ebene1_titel"]?></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)-1) {
while($community[$i]['name'] == $community[$i+1]['name']) {
if($i<count($community)-1) {
$i++;
} else {
break;
}
}
}
}
echo <<<EOT
<option value=""><?php echo $texte["ebene1_text"]?></option>
<?php $lastName = "" ?>
<?php foreach ($community as $i => $value): ?>
<?php if ($value['name'] != $lastName): ?>
<option value="<?php echo $value['name']?>"><?php echo $value['name']?></option>
<?php endif ?>
<?php $lastName = $value['name'] ?>
<?php endforeach ?>
</select>
</div>
<div class="panel-footer">
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $texte["ebene2_titel"]?></h3>
</div>
<div class="panel-body">
<select id="fw-dl-2" name="fw-dl-2" class="form-control" disabled="disabled" onchange="populateB()"></select>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
EOT;
echo($texte["ebene2_titel"]);
echo <<<EOT
</h3>
<h3 class="panel-title"><?php echo $texte["ebene3_titel"]?></h3>
</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>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary">
<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>
<a href="#" id="fw-dl-3" name="fw-dl-3" role="button" class="btn btn-primary btn-block disabled"><?php echo $texte["ebene3_text"]?></a>
</div>
</div>
</div>
</div>
</div>
<hr />
<footer>
<div class="col-xs-12 text-muted text-center">
<p>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></p>
</div>
</footer>
</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>
</body>
</html>
EOT;
?>

View File

@ -47,6 +47,7 @@ Den Freifunk Hennef Firmware Downloader in ein eigenes Unterverzeichnis des Webs
- $texte ist das Array mit den einzelnen Überschriften/Texten für die Auswahlstufen
- $community ist das Array mit den Metadaten für die Metacommunity und die einzelnen Subcommunites. Wenn hier nur eine Community angegeben wird wird die Communtiyauswahl übersprungen und direkt auf die Firmware Downloader Seite verwiesen.
```
0 => array( // ID die bei 0 Anfängt und hochgezählt wird
"community_id" => 0, // ID der Community, wiederholt sich bei den zusammengehörigen Subcommunities
"name" => "Name der Community",
@ -61,6 +62,7 @@ Den Freifunk Hennef Firmware Downloader in ein eigenes Unterverzeichnis des Webs
"download_path" => "Pfad zur Firmware", // Bleibt bei der Metacommunity leer
"sub_auswahl" => "Name der Subcommunity" // Wird nur verwendet wenn die Community Subcommunites/Technologien als Auswahl hat
),
```
In der config.inc.php sind die Angaben über die Hersteller, Entwicklungsstufen & Art der Firmware Installation. Hier muss man normalerweise nichts anpassen, außer man verwendet Firmwares für Router von Herstellern, die noch nicht integriert sind, dann bitte ich allerdings auch um Kontaktaufnahme (caspar@freifunk-hennef.de, bzw. im github).
- $entwicklung = Entwicklungsstufen der Firmware (beta/broken/experimental/stable) - (sollte man in Ruhe lassen normalerweise)