From 18495dbbc344133736bfe732c7bec71bd67fc461 Mon Sep 17 00:00:00 2001 From: Martin Schuette Date: Sun, 29 Jun 2014 17:58:01 +0000 Subject: [PATCH 01/26] extra function ff_hh_beautify_hw_name --- freifunk-versions.php | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 7b5e567..da0b8a9 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -3,7 +3,7 @@ Plugin Name: Freifunk Hamburg Firmware List Shortcode Plugin URI: http://mschuette.name/ Description: Defines shortcodes to display Freifunk Hamburg Firmware versions -Version: 0.4 +Version: 0.4dev Author: Martin Schuette Author URI: http://mschuette.name/ Licence: 2-clause BSD @@ -94,23 +94,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { if ($grep && (false === strpos($hw, $grep))) { continue; } - // beautify HW model names - if (!strncmp($hw, 'tp-link', 7)) { - if ($grep) $hw = str_replace($grep, '', $hw); - $hw = strtoupper($hw); - $hw = str_replace('-', ' ', $hw); - $hw = str_replace('TP LINK TL ', 'TP-Link TL-', $hw); - } elseif (!strncmp($hw, 'ubiquiti', 8)) { - if ($grep) $hw = str_replace($grep, '', $hw); - $hw = str_replace('bullet-m', 'bullet-m / nanostation-loco-m', $hw); - $hw = str_replace('-m', ' M2', $hw); - $hw = str_replace('-', ' ', $hw); - $hw = ucwords($hw); - } elseif (!strncmp($hw, 'd-link', 6)) { - if ($grep) $hw = str_replace($grep, '', $hw); - $hw = str_replace('-', ' ', $hw); - $hw = str_replace('d link dir ', 'D-Link DIR-', $hw); - } + $hw = ff_hh_beautify_hw_name($hw, $grep); $outstr .= sprintf("\n%s", $hw); // factory versions @@ -138,3 +122,30 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { // $outstr .= '
'.print_r($manifest, true).'
'; return $outstr; } + +// some crude rules to add capitalization and whitespace to the +// hardware model name. +// set $discard_vendor to strip the vendor name +// (used for single-vendor lists, e.g. $discard_vendor = 'tp-link') +function ff_hh_beautify_hw_name($hw, $discard_vendor = "") { + if (!strncmp($hw, 'tp-link', 7)) { + if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); + $hw = strtoupper($hw); + $hw = str_replace('-', ' ', $hw); + $hw = str_replace('TP LINK ', 'TP-Link ', $hw); + $hw = str_replace(' TL ', ' TL-', $hw); + } elseif (!strncmp($hw, 'ubiquiti', 8)) { + if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); + $hw = str_replace('bullet-m', 'bullet-m / nanostation-loco-m', $hw); + $hw = str_replace('-m', ' M2', $hw); + $hw = str_replace('-', ' ', $hw); + $hw = ucwords($hw); + } elseif (!strncmp($hw, 'd-link', 6)) { + if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); + $hw = str_replace('-', ' ', $hw); + $hw = str_replace('d link ', 'D-Link ', $hw); + $hw = str_replace(' dir ', ' DIR-', $hw); + } + return $hw; +} + From 766b9a4d1e432fc3b1bb5f17a47e56ac151c402e Mon Sep 17 00:00:00 2001 From: Martin Schuette Date: Sun, 29 Jun 2014 17:58:24 +0000 Subject: [PATCH 02/26] add simple testing --- .travis.yml | 18 ++++++++++ bin/install-wp-tests.sh | 79 +++++++++++++++++++++++++++++++++++++++++ phpunit.xml | 15 ++++++++ tests/bootstrap.php | 15 ++++++++ tests/test-simple.php | 21 +++++++++++ 5 files changed, 148 insertions(+) create mode 100644 .travis.yml create mode 100755 bin/install-wp-tests.sh create mode 100644 phpunit.xml create mode 100644 tests/bootstrap.php create mode 100644 tests/test-simple.php diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..215bc4a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +env: + - WP_VERSION=3.8 + - WP_VERSION=latest + +before_script: + - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION + - fgrep wp_version /tmp/wordpress/wp-includes/version.php + +script: phpunit diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh new file mode 100755 index 0000000..2ed09d9 --- /dev/null +++ b/bin/install-wp-tests.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +if [ $# -lt 3 ]; then + echo "usage: $0 [db-host] [wp-version]" + exit 1 +fi + +DB_NAME=$1 +DB_USER=$2 +DB_PASS=$3 +DB_HOST=${4-localhost} +WP_VERSION=${5-latest} + +WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} +WP_CORE_DIR=/tmp/wordpress/ + +set -ex + +install_wp() { + mkdir -p $WP_CORE_DIR + + if [ $WP_VERSION == 'latest' ]; then + local ARCHIVE_NAME='latest' + else + local ARCHIVE_NAME="wordpress-$WP_VERSION" + fi + + wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz + tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR + + wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php +} + +install_test_suite() { + # portable in-place argument for both GNU sed and Mac OSX sed + if [[ $(uname -s) == 'Darwin' ]]; then + local ioption='-i .bak' + else + local ioption='-i' + fi + + # set up testing suite + mkdir -p $WP_TESTS_DIR + cd $WP_TESTS_DIR + svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/ + + wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php + sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php + sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php + sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php + sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php + sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php +} + +install_db() { + # parse DB_HOST for port or socket references + local PARTS=(${DB_HOST//\:/ }) + local DB_HOSTNAME=${PARTS[0]}; + local DB_SOCK_OR_PORT=${PARTS[1]}; + local EXTRA="" + + if ! [ -z $DB_HOSTNAME ] ; then + if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then + EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" + elif ! [ -z $DB_SOCK_OR_PORT ] ; then + EXTRA=" --socket=$DB_SOCK_OR_PORT" + elif ! [ -z $DB_HOSTNAME ] ; then + EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" + fi + fi + + # create database + mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA +} + +install_wp +install_test_suite +install_db + diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..aea0bcf --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,15 @@ + + + + ./tests/ + + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..e460912 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,15 @@ +assertEquals($item[2], trim(ff_hh_beautify_hw_name($item[0], $item[1]))); + } + } +} From 765dce07200e63c801c54c8b1d7390c0e2aeb93d Mon Sep 17 00:00:00 2001 From: Martin Schuette Date: Sun, 29 Jun 2014 18:02:34 +0000 Subject: [PATCH 03/26] update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 04a97fc..af83b1e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ freifunk-versions ================= +[![Build Status](https://travis-ci.org/freifunkhamburg/freifunk-versions.svg?branch=master)](https://travis-ci.org/freifunkhamburg/freifunk-versions) + Wordpress plugin to render latest (Hamburg-flavoured) [gluon firmware](https://github.com/freifunkhamburg/gluon) version table. From 7ed0325a9a0619efe8df901e91c5de349c0dad82 Mon Sep 17 00:00:00 2001 From: Martin Schuette Date: Sun, 29 Jun 2014 18:22:12 +0000 Subject: [PATCH 04/26] apply WP coding style --- freifunk-versions.php | 218 ++++++++++++++++++++++-------------------- tests/test-simple.php | 34 +++---- 2 files changed, 130 insertions(+), 122 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index da0b8a9..53e5e00 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -9,143 +9,149 @@ Author URI: http://mschuette.name/ Licence: 2-clause BSD */ -define('FF_HH_STABLE_BASEDIR', 'http://updates.hamburg.freifunk.net/stable/'); -define('FF_HH_CACHETIME', 15); +define( 'FF_HH_STABLE_BASEDIR', 'http://updates.hamburg.freifunk.net/stable/' ); +define( 'FF_HH_CACHETIME', 15 ); /* gets metadata from URL, handles caching */ -function ff_hh_getmanifest ($basedir) { - // Caching - if ( WP_DEBUG || ( false === ( $manifest = get_transient( "ff_hh_manifest" ) ) ) ) { - $manifest = array(); - $url = $basedir . 'sysupgrade/manifest'; - $http_response = wp_remote_get( $url ); // TODO: error handling - $input = wp_remote_retrieve_body( $http_response ); - foreach ( explode("\n", $input) as $line ) { - $ret = sscanf($line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename); - if ($ret === 4) { - if (preg_match('/^(.*)-v(\d+)$/', $hw, $matches)) { - $hw = $matches[1]; - $hw_ver = $matches[2]; - } else { - $hw_ver = '1'; - } - $manifest[$hw][$hw_ver] = $filename; - } - } +function ff_hh_getmanifest( $basedir ) { + // Caching + if ( WP_DEBUG || ( false === ( $manifest = get_transient( 'ff_hh_manifest' ) ) ) ) { + $manifest = array(); + $url = $basedir . 'sysupgrade/manifest'; + $http_response = wp_remote_get( $url ); // TODO: error handling + $input = wp_remote_retrieve_body( $http_response ); + foreach ( explode( "\n", $input ) as $line ) { + $ret = sscanf( $line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename ); + if ( $ret === 4 ) { + if ( preg_match( '/^(.*)-v(\d+)$/', $hw, $matches ) ) { + $hw = $matches[1]; + $hw_ver = $matches[2]; + } else { + $hw_ver = '1'; + } + $manifest[$hw][$hw_ver] = $filename; + } + } - $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; - set_transient( "ff_hh_manifest", $manifest, $cachetime ); - } - return $manifest; + $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; + set_transient( 'ff_hh_manifest', $manifest, $cachetime ); + } + return $manifest; } /* gets latest version from first manifest line */ -function ff_hh_getlatest ($basedir) { - // Caching - if ( false === ( $sw_ver = get_transient( "ff_hh_latestversion" ) ) ) { - $sw_ver = 'unknown'; - $input = wp_remote_retrieve_body( wp_remote_get($basedir . 'sysupgrade/manifest') ); - foreach ( explode("\n", $input) as $line ) { - $ret = sscanf($line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename); - if ($ret === 4) { - // break processing on first matching line - $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; - set_transient( "ff_hh_latestversion", $sw_ver, $cachetime ); - break; - } - } - } - return $sw_ver; +function ff_hh_getlatest( $basedir ) { + // Caching + if ( false === ( $sw_ver = get_transient( 'ff_hh_latestversion' ) ) ) { + $sw_ver = 'unknown'; + $input = wp_remote_retrieve_body( wp_remote_get( $basedir . 'sysupgrade/manifest' ) ); + foreach ( explode( "\n", $input ) as $line ) { + $ret = sscanf( $line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename ); + if ( $ret === 4 ) { + // break processing on first matching line + $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; + set_transient( 'ff_hh_latestversion', $sw_ver, $cachetime ); + break; + } + } + } + return $sw_ver; } if ( ! shortcode_exists( 'ff_hh_latestversion' ) ) { - add_shortcode( 'ff_hh_latestversion', 'ff_hh_shortcode_latestversion'); + add_shortcode( 'ff_hh_latestversion', 'ff_hh_shortcode_latestversion' ); } // Example: // [ff_hh_latestversion] function ff_hh_shortcode_latestversion( $atts, $content, $name ) { - $sw_ver = ff_hh_getlatest(FF_HH_STABLE_BASEDIR); - $outstr = "$sw_ver"; - return $outstr; + $sw_ver = ff_hh_getlatest( FF_HH_STABLE_BASEDIR ); + $outstr = "$sw_ver"; + return $outstr; } if ( ! shortcode_exists( 'ff_hh_versions' ) ) { - add_shortcode( 'ff_hh_versions', 'ff_hh_shortcode_versions'); + add_shortcode( 'ff_hh_versions', 'ff_hh_shortcode_versions' ); } // Example: // [ff_hh_versions] // [ff_hh_versions grep="ubiquiti"] function ff_hh_shortcode_versions( $atts, $content, $name ) { - $manifest = ff_hh_getmanifest(FF_HH_STABLE_BASEDIR); + $manifest = ff_hh_getmanifest( FF_HH_STABLE_BASEDIR ); - $outstr = "
"; - $outstr .= ''; + $outstr = "
"; + $outstr .= '
ModellErstinstallationAktualisierung
'; - # optionally filter output by given substring - if (is_array($atts) - && array_key_exists('grep', $atts) - && !empty($atts['grep'])) { - $grep = $atts['grep']; - } else { - $grep = false; - } + # optionally filter output by given substring + if ( is_array( $atts ) + && array_key_exists( 'grep', $atts ) + && ! empty( $atts['grep'] ) ) { + $grep = $atts['grep']; + } else { + $grep = false; + } - foreach ($manifest as $hw => $versions) { - // filter - if ($grep && (false === strpos($hw, $grep))) { - continue; - } - $hw = ff_hh_beautify_hw_name($hw, $grep); - $outstr .= sprintf("\n", $hw); + foreach ( $manifest as $hw => $versions ) { + // filter + if ( $grep && ( false === strpos( $hw, $grep ) ) ) { + continue; + } + $hw = ff_hh_beautify_hw_name( $hw, $grep ); + $outstr .= sprintf( "\n", $hw ); - // factory versions - $hw_ver_links = array(); - foreach ($versions as $hw_ver => $filename) { - $filename = str_replace('-sysupgrade', '', $filename); - $hw_ver_links[] = sprintf('%s.x', - FF_HH_STABLE_BASEDIR.'factory/', $filename, $hw_ver); - } - $outstr .= ''; + // factory versions + $hw_ver_links = array(); + foreach ( $versions as $hw_ver => $filename ) { + $filename = str_replace( '-sysupgrade', '', $filename ); + $hw_ver_links[] = sprintf( + '%s.x', + FF_HH_STABLE_BASEDIR.'factory/', + $filename, $hw_ver + ); + } + $outstr .= ''; - // sysupgrade versions - $hw_ver_links = array(); - foreach ($versions as $hw_ver => $filename) { - $hw_ver_links[] = sprintf('%s.x', - FF_HH_STABLE_BASEDIR.'sysupgrade/', $filename, $hw_ver); - } - $outstr .= ''; + // sysupgrade versions + $hw_ver_links = array(); + foreach ( $versions as $hw_ver => $filename ) { + $hw_ver_links[] = sprintf( + '%s.x', + FF_HH_STABLE_BASEDIR.'sysupgrade/', + $filename, $hw_ver + ); + } + $outstr .= ''; - $outstr .= ''; - } + $outstr .= ''; + } - $outstr .= '
ModellErstinstallationAktualisierung
%s
%sHardware Version ' . join(', ', $hw_ver_links) . 'Hardware Version ' . join( ', ', $hw_ver_links ) . 'Hardware Version ' . join(', ', $hw_ver_links) . 'Hardware Version ' . join( ', ', $hw_ver_links ) . '
'; - $outstr .= '
'; - // $outstr .= '
'.print_r($manifest, true).'
'; - return $outstr; + $outstr .= ''; + $outstr .= ''; + // $outstr .= '
'.print_r( $manifest, true ).'
'; + return $outstr; } // some crude rules to add capitalization and whitespace to the // hardware model name. // set $discard_vendor to strip the vendor name -// (used for single-vendor lists, e.g. $discard_vendor = 'tp-link') -function ff_hh_beautify_hw_name($hw, $discard_vendor = "") { - if (!strncmp($hw, 'tp-link', 7)) { - if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); - $hw = strtoupper($hw); - $hw = str_replace('-', ' ', $hw); - $hw = str_replace('TP LINK ', 'TP-Link ', $hw); - $hw = str_replace(' TL ', ' TL-', $hw); - } elseif (!strncmp($hw, 'ubiquiti', 8)) { - if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); - $hw = str_replace('bullet-m', 'bullet-m / nanostation-loco-m', $hw); - $hw = str_replace('-m', ' M2', $hw); - $hw = str_replace('-', ' ', $hw); - $hw = ucwords($hw); - } elseif (!strncmp($hw, 'd-link', 6)) { - if ($discard_vendor) $hw = str_replace($discard_vendor, '', $hw); - $hw = str_replace('-', ' ', $hw); - $hw = str_replace('d link ', 'D-Link ', $hw); - $hw = str_replace(' dir ', ' DIR-', $hw); - } - return $hw; +// (used for single-vendor lists, e.g. $discard_vendor = 'tp-link' ) +function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { + if ( ! strncmp( $hw, 'tp-link', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', ' ', $hw ); + $hw = str_replace( 'TP LINK ', 'TP-Link ', $hw ); + $hw = str_replace( ' TL ', ' TL-', $hw ); + } elseif ( ! strncmp( $hw, 'ubiquiti', 8 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = str_replace( 'bullet-m', 'bullet-m / nanostation-loco-m', $hw ); + $hw = str_replace( '-m', ' M2', $hw ); + $hw = str_replace( '-', ' ', $hw ); + $hw = ucwords( $hw ); + } elseif ( ! strncmp( $hw, 'd-link', 6 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = str_replace( '-', ' ', $hw ); + $hw = str_replace( 'd link ', 'D-Link ', $hw ); + $hw = str_replace( ' dir ', ' DIR-', $hw ); + } + return $hw; } diff --git a/tests/test-simple.php b/tests/test-simple.php index fa25192..0c9b5a5 100644 --- a/tests/test-simple.php +++ b/tests/test-simple.php @@ -1,21 +1,23 @@ assertEquals($item[2], trim(ff_hh_beautify_hw_name($item[0], $item[1]))); + function test_beautify() { + $cmplist = array( // examples with and without grep param + array( 'tp-link-tl-wr740n-nd', '', 'TP-Link TL-WR740N ND' ), + array( 'tp-link-tl-wr740n-nd', 'tp-link', 'TL-WR740N ND' ), + array( 'tp-link-tl-wdr4300', '', 'TP-Link TL-WDR4300' ), + array( 'tp-link-tl-wdr4300', 'tp-link', 'TL-WDR4300' ), + array( 'ubiquiti-unifi', '', 'Ubiquiti Unifi' ), + array( 'ubiquiti-unifi', 'ubiquiti', 'Unifi' ), + array( 'ubiquiti-bullet-m', '', 'Ubiquiti Bullet M2 / Nanostation Loco M2' ), + array( 'ubiquiti-bullet-m', 'ubiquiti', 'Bullet M2 / Nanostation Loco M2' ), + array( 'd-link-dir-615-rev-e1', '', 'D-Link DIR-615 rev e1' ), + array( 'd-link-dir-615-rev-e1', 'd-link', 'DIR-615 rev e1' ), + ); + foreach ( $cmplist as $item ) { + $expect = $item[2]; + $result = ff_hh_beautify_hw_name( $item[0], $item[1] ); + $this->assertEquals( $expect, trim( $result ) ); + } } - } } From 21fce8e59ac765b7f61daf153f33595dc53ca01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Thu, 7 Aug 2014 16:57:21 +0200 Subject: [PATCH 05/26] add linksys string replacements --- freifunk-versions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index 53e5e00..467462b 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -151,6 +151,11 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace( '-', ' ', $hw ); $hw = str_replace( 'd link ', 'D-Link ', $hw ); $hw = str_replace( ' dir ', ' DIR-', $hw ); + } elseif ( ! strncmp( $hw, 'linksys', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = str_replace( '-', ' ', $hw ); + $hw = str_replace( 'linksys ', 'Linksys ', $hw ); + $hw = str_replace( ' wrt', ' WRT-', $hw ); } return $hw; } From 10316f59eed26d938a1bb1ae1ddd61ca849d5686 Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Wed, 17 Dec 2014 16:38:44 +0100 Subject: [PATCH 06/26] =?UTF-8?q?manifest=20Datei=20in=20stable.manifest?= =?UTF-8?q?=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wird jetzt als stable.manifest beim firmware bauen erzeugt --- freifunk-versions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 467462b..ae0edc2 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -17,7 +17,7 @@ function ff_hh_getmanifest( $basedir ) { // Caching if ( WP_DEBUG || ( false === ( $manifest = get_transient( 'ff_hh_manifest' ) ) ) ) { $manifest = array(); - $url = $basedir . 'sysupgrade/manifest'; + $url = $basedir . 'sysupgrade/stable.manifest'; $http_response = wp_remote_get( $url ); // TODO: error handling $input = wp_remote_retrieve_body( $http_response ); foreach ( explode( "\n", $input ) as $line ) { @@ -44,7 +44,7 @@ function ff_hh_getlatest( $basedir ) { // Caching if ( false === ( $sw_ver = get_transient( 'ff_hh_latestversion' ) ) ) { $sw_ver = 'unknown'; - $input = wp_remote_retrieve_body( wp_remote_get( $basedir . 'sysupgrade/manifest' ) ); + $input = wp_remote_retrieve_body( wp_remote_get( $basedir . 'sysupgrade/stable.manifest' ) ); foreach ( explode( "\n", $input ) as $line ) { $ret = sscanf( $line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename ); if ( $ret === 4 ) { From e233ea15303491b541bc3ab70224925a65cb8394 Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Sun, 18 Jan 2015 22:25:35 +0100 Subject: [PATCH 07/26] =?UTF-8?q?Buffalo=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index ae0edc2..a6ec711 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -156,6 +156,10 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace( '-', ' ', $hw ); $hw = str_replace( 'linksys ', 'Linksys ', $hw ); $hw = str_replace( ' wrt', ' WRT-', $hw ); + } elseif ( ! strncmp( $hw, 'buffalo', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = str_replace( 'wzr-', 'WZR-', $hw ); + $hw = str_replace( '-', ' ', $hw ); } return $hw; } From 1499e14370cd2c0f39733ec18b350c26ba2014b3 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 Jan 2015 22:55:17 +0100 Subject: [PATCH 08/26] =?UTF-8?q?Buffalo=20strings=20sch=C3=B6ner=20gemach?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index a6ec711..ce5d665 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -158,8 +158,9 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace( ' wrt', ' WRT-', $hw ); } elseif ( ! strncmp( $hw, 'buffalo', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = str_replace( 'wzr-', 'WZR-', $hw ); - $hw = str_replace( '-', ' ', $hw ); + $hw = str_replace( 'buffalo', 'Buffalo', $hw ); + $hw = str_replace( 'hp-ag300h-wzr-600dhp', 'HP-AG300H & WZR-600DHP', $hw ); + $hw = str_replace( '-wzr', 'WZR', $hw ); } return $hw; } From af55ec2a698c2de24be225c4a48fe53f2f762405 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 Jan 2015 23:15:39 +0100 Subject: [PATCH 09/26] =?UTF-8?q?alle=20strings=20versch=C3=B6nert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index ce5d665..d4d3c30 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -148,19 +148,22 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = ucwords( $hw ); } elseif ( ! strncmp( $hw, 'd-link', 6 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); - $hw = str_replace( 'd link ', 'D-Link ', $hw ); - $hw = str_replace( ' dir ', ' DIR-', $hw ); + $hw = str_replace( 'D LINK ', 'D-Link ', $hw ); + $hw = str_replace( ' DIR ', ' DIR-', $hw ); } elseif ( ! strncmp( $hw, 'linksys', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); - $hw = str_replace( 'linksys ', 'Linksys ', $hw ); - $hw = str_replace( ' wrt', ' WRT-', $hw ); + $hw = str_replace( 'LINKSYS', 'Linksys ', $hw ); + $hw = str_replace( ' WRT', ' WRT-', $hw ); } elseif ( ! strncmp( $hw, 'buffalo', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = str_replace( 'buffalo', 'Buffalo', $hw ); - $hw = str_replace( 'hp-ag300h-wzr-600dhp', 'HP-AG300H & WZR-600DHP', $hw ); - $hw = str_replace( '-wzr', 'WZR', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace('BUFFALO', 'Buffalo', $hw ); + $hw = str_replace( 'HP-AG300H-WZR-600DHP', 'HP-AG300H & WZR-600DHP', $hw ); + $hw = str_replace( '-WZR', 'WZR', $hw ); } return $hw; } From 2d0e184f81a71a71f193c50eaa09f27c7bbb9340 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 31 May 2015 17:40:57 +0200 Subject: [PATCH 10/26] =?UTF-8?q?Netgear,=20ALLNET=20&=20Gl.iNet=20hinzuge?= =?UTF-8?q?f=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index d4d3c30..b7b4de1 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -10,7 +10,7 @@ Licence: 2-clause BSD */ define( 'FF_HH_STABLE_BASEDIR', 'http://updates.hamburg.freifunk.net/stable/' ); -define( 'FF_HH_CACHETIME', 15 ); +define( 'FF_HH_CACHETIME', 1 ); /* gets metadata from URL, handles caching */ function ff_hh_getmanifest( $basedir ) { @@ -164,6 +164,20 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace('BUFFALO', 'Buffalo', $hw ); $hw = str_replace( 'HP-AG300H-WZR-600DHP', 'HP-AG300H & WZR-600DHP', $hw ); $hw = str_replace( '-WZR', 'WZR', $hw ); + } elseif ( ! strncmp( $hw, 'netgear', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace('NETGEAR', 'Netgear', $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'allnet', 6 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'gl-inet', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace('GL-INET', 'Gl.iNet', $hw ); + $hw = str_replace( '-', '', $hw ); } return $hw; } From 026d4aafe14d24a8b17e90a7b27d8cdc6993ec4b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 15 Jul 2015 21:02:09 +0200 Subject: [PATCH 11/26] =?UTF-8?q?.bin=20&=20.tar=20werden=20f=C3=BCr=20net?= =?UTF-8?q?gear=20bei=20factory=20durch=20.img=20ersetzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index b7b4de1..07b27a4 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -101,6 +101,10 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $hw_ver_links = array(); foreach ( $versions as $hw_ver => $filename ) { $filename = str_replace( '-sysupgrade', '', $filename ); + if (strpos($filename,'netgear') !== false) { + $filename = str_replace( '.bin', '.img', $filename ); + $filename = str_replace( '.tar', '.img', $filename ); + } $hw_ver_links[] = sprintf( '%s.x', FF_HH_STABLE_BASEDIR.'factory/', From d810b983d8fef6fbaf42a13cc2fbd299ca491549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Fri, 25 Sep 2015 10:16:39 +0200 Subject: [PATCH 12/26] fix tests broken since af55ec2 --- tests/test-simple.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-simple.php b/tests/test-simple.php index 0c9b5a5..a991332 100644 --- a/tests/test-simple.php +++ b/tests/test-simple.php @@ -11,8 +11,8 @@ class SimpleTests extends WP_UnitTestCase { array( 'ubiquiti-unifi', 'ubiquiti', 'Unifi' ), array( 'ubiquiti-bullet-m', '', 'Ubiquiti Bullet M2 / Nanostation Loco M2' ), array( 'ubiquiti-bullet-m', 'ubiquiti', 'Bullet M2 / Nanostation Loco M2' ), - array( 'd-link-dir-615-rev-e1', '', 'D-Link DIR-615 rev e1' ), - array( 'd-link-dir-615-rev-e1', 'd-link', 'DIR-615 rev e1' ), + array( 'd-link-dir-615-rev-e1', '', 'D-Link DIR-615 REV E1' ), + array( 'd-link-dir-615-rev-e1', 'd-link', 'DIR-615 REV E1' ), ); foreach ( $cmplist as $item ) { $expect = $item[2]; From 39d45818f00c67c0fa45527d809eb8b03c1e7ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Fri, 25 Sep 2015 10:27:48 +0200 Subject: [PATCH 13/26] update travis-ci to docker infrastructure http://docs.travis-ci.com/user/migrating-from-legacy/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 215bc4a..38b233c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: php +sudo: false php: - 5.3 From 7c3ef2775d95a4d45dceae38e02101643e91e4c0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 6 Nov 2015 23:30:13 +0100 Subject: [PATCH 14/26] =?UTF-8?q?Loco=20aus=20bullet=20genommen,=20da=20es?= =?UTF-8?q?=20daf=C3=BCr=20jetzt=20'eigene'=20firmware=20gibt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 07b27a4..e4bbb5b 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -146,7 +146,7 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace( ' TL ', ' TL-', $hw ); } elseif ( ! strncmp( $hw, 'ubiquiti', 8 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = str_replace( 'bullet-m', 'bullet-m / nanostation-loco-m', $hw ); + $hw = str_replace( 'bullet-m', 'bullet-m', $hw ); $hw = str_replace( '-m', ' M2', $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = ucwords( $hw ); From 9eb14ecfc5cdd11f7c6c98cce9fde8ab03265e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Fri, 11 Mar 2016 15:15:38 +0100 Subject: [PATCH 15/26] fix test --- tests/test-simple.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-simple.php b/tests/test-simple.php index a991332..931184b 100644 --- a/tests/test-simple.php +++ b/tests/test-simple.php @@ -9,8 +9,8 @@ class SimpleTests extends WP_UnitTestCase { array( 'tp-link-tl-wdr4300', 'tp-link', 'TL-WDR4300' ), array( 'ubiquiti-unifi', '', 'Ubiquiti Unifi' ), array( 'ubiquiti-unifi', 'ubiquiti', 'Unifi' ), - array( 'ubiquiti-bullet-m', '', 'Ubiquiti Bullet M2 / Nanostation Loco M2' ), - array( 'ubiquiti-bullet-m', 'ubiquiti', 'Bullet M2 / Nanostation Loco M2' ), + array( 'ubiquiti-bullet-m', '', 'Ubiquiti Bullet M2' ), + array( 'ubiquiti-bullet-m', 'ubiquiti', 'Bullet M2' ), array( 'd-link-dir-615-rev-e1', '', 'D-Link DIR-615 REV E1' ), array( 'd-link-dir-615-rev-e1', 'd-link', 'DIR-615 REV E1' ), ); From 741b5c721fde79fe0213d52008c31162b6a8d5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sch=C3=BCtte?= Date: Fri, 11 Mar 2016 15:27:35 +0100 Subject: [PATCH 16/26] only test for latest WP version WP version 3.8 was _really_ outdated --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38b233c..4721428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ php: - hhvm env: - - WP_VERSION=3.8 - WP_VERSION=latest before_script: From e277c230976b323d1bda0ead3b2b533f83fbb9da Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Sat, 7 May 2016 14:57:00 +0200 Subject: [PATCH 17/26] =?UTF-8?q?Neue=20Ger=C3=A4te=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Onion-Omega, ALFA & Western Digital --- freifunk-versions.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index e4bbb5b..9178ee0 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -111,7 +111,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $filename, $hw_ver ); } - $outstr .= 'Hardware Version ' . join( ', ', $hw_ver_links ) . ''; + $outstr .= 'Hardware Ver. ' . join( ', ', $hw_ver_links ) . ''; // sysupgrade versions $hw_ver_links = array(); @@ -122,7 +122,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $filename, $hw_ver ); } - $outstr .= 'Hardware Version ' . join( ', ', $hw_ver_links ) . ''; + $outstr .= 'Hardware Ver. ' . join( ', ', $hw_ver_links ) . ''; $outstr .= ''; } @@ -142,7 +142,6 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); - $hw = str_replace( 'TP LINK ', 'TP-Link ', $hw ); $hw = str_replace( ' TL ', ' TL-', $hw ); } elseif ( ! strncmp( $hw, 'ubiquiti', 8 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); @@ -154,24 +153,20 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); - $hw = str_replace( 'D LINK ', 'D-Link ', $hw ); $hw = str_replace( ' DIR ', ' DIR-', $hw ); } elseif ( ! strncmp( $hw, 'linksys', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); - $hw = str_replace( 'LINKSYS', 'Linksys ', $hw ); $hw = str_replace( ' WRT', ' WRT-', $hw ); } elseif ( ! strncmp( $hw, 'buffalo', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); - $hw = str_replace('BUFFALO', 'Buffalo', $hw ); $hw = str_replace( 'HP-AG300H-WZR-600DHP', 'HP-AG300H & WZR-600DHP', $hw ); $hw = str_replace( '-WZR', 'WZR', $hw ); } elseif ( ! strncmp( $hw, 'netgear', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); - $hw = str_replace('NETGEAR', 'Netgear', $hw ); $hw = str_replace( '-', '', $hw ); } elseif ( ! strncmp( $hw, 'allnet', 6 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); @@ -180,9 +175,17 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { } elseif ( ! strncmp( $hw, 'gl-inet', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); - $hw = str_replace('GL-INET', 'Gl.iNet', $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'onion-omega', 11 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + } elseif ( ! strncmp( $hw, 'alfa', 4 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'wd', 2 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); $hw = str_replace( '-', '', $hw ); } return $hw; } - From 119b2d9edbb4ce849b8c802ef752ef0d83abfbc9 Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Sat, 7 May 2016 22:44:43 +0200 Subject: [PATCH 18/26] =?UTF-8?q?Neue=20Ger=C3=A4te=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cisco Meraki & 8devices --- freifunk-versions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index 9178ee0..977ccbb 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -186,6 +186,16 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, '8devices', 8 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'CARAMBOLA2-BOARD', 'Carambola 2', $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'meraki', 6 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'meraki', '', $hw ); + $hw = str_replace( '-', '', $hw ); } return $hw; } From 6fff11b78a8e740ebbb1747ea4f72d75c2c95d15 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Jan 2017 16:07:53 +0100 Subject: [PATCH 19/26] updates URL auf https umgestellt --- freifunk-versions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 977ccbb..09dca23 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -9,7 +9,7 @@ Author URI: http://mschuette.name/ Licence: 2-clause BSD */ -define( 'FF_HH_STABLE_BASEDIR', 'http://updates.hamburg.freifunk.net/stable/' ); +define( 'FF_HH_STABLE_BASEDIR', 'https://updates.hamburg.freifunk.net/stable/' ); define( 'FF_HH_CACHETIME', 1 ); /* gets metadata from URL, handles caching */ From 3cf796170971d52b76ce321e3aa7acb387eafd74 Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Fri, 21 Apr 2017 20:11:35 +0200 Subject: [PATCH 20/26] =?UTF-8?q?Aktualisiert=20f=C3=BCr=20firmware=200.8.?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freifunk-versions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 09dca23..9941cc1 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -146,7 +146,6 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { } elseif ( ! strncmp( $hw, 'ubiquiti', 8 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = str_replace( 'bullet-m', 'bullet-m', $hw ); - $hw = str_replace( '-m', ' M2', $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = ucwords( $hw ); } elseif ( ! strncmp( $hw, 'd-link', 6 ) ) { @@ -196,6 +195,11 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = strtoupper( $hw ); $hw = str_replace( 'meraki', '', $hw ); $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'openmesh', 8 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'openmesh', '', $hw ); + $hw = str_replace( '-', '', $hw ); } return $hw; } From ffc5ca3583d122fa71828b188b68e8809c87eb1c Mon Sep 17 00:00:00 2001 From: Leo Krueger Date: Mon, 16 Oct 2017 21:20:14 +0200 Subject: [PATCH 21/26] show hint if there is no factory image for certain routers --- freifunk-versions.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 9941cc1..e0fc1a4 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -100,6 +100,10 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { // factory versions $hw_ver_links = array(); foreach ( $versions as $hw_ver => $filename ) { + if ( strpos( $hw, 'Unifi Ac Pro' ) || strpos( $hw, 'Unifi Ac Lite' ) ) { + continue; + } + $filename = str_replace( '-sysupgrade', '', $filename ); if (strpos($filename,'netgear') !== false) { $filename = str_replace( '.bin', '.img', $filename ); @@ -111,7 +115,11 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $filename, $hw_ver ); } - $outstr .= 'Hardware Ver. ' . join( ', ', $hw_ver_links ) . ''; + if ( count($hw_ver_links) > 0) { + $outstr .= 'Hardware Ver. ' . join( ', ', $hw_ver_links ) . ''; + } else { + $outstr .= 'Benutze das Image
zur Aktualisierung
'; + } // sysupgrade versions $hw_ver_links = array(); From a66ba3a361deeb4ff2ad33bb04ce8723104012f1 Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Fri, 17 Nov 2017 21:37:10 +0100 Subject: [PATCH 22/26] Add "domain" and "branch" arguments --- README.md | 25 ++++++- freifunk-versions.php | 154 ++++++++++++++++++++++++------------------ 2 files changed, 112 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index af83b1e..b6e9fd0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ Wordpress plugin to render latest (Hamburg-flavoured) [gluon firmware](https://github.com/freifunkhamburg/gluon) version table. Provides shortcode `[ff_hh_versions]` to display table. -Input data is read from http://updates.hamburg.freifunk.net/stable/sysupgrade/manifest +Input data is read from i.e. +https://updates.hamburg.freifunk.net/ffhh/stable/sysupgrade/stable.manifest Output looks like this: @@ -15,7 +16,26 @@ Output looks like this: Arguments --------- -An optional argument `grep` allows you show a subset of hardware versions, +The optional argument `domain` (default: `ffhh`) allows you to choose the +firmware's domain. + +Example: + +``` + Hamburg-Süd Firmware: [ff_hh_versions domain="ffhh-sued"] +``` + +The optional argument `branch` (default: `stable`) allows you to choose the +firmware's branch. + +Example: + +``` + Experimental Firmware: [ff_hh_versions branch="experimental"] +``` + +The optional argument `grep` allows you show a subset of hardware versions. + Example: ``` @@ -23,4 +43,3 @@ Example: Ubiquiti Firmware: [ff_hh_versions grep="ubiquiti"] ``` - diff --git a/freifunk-versions.php b/freifunk-versions.php index e0fc1a4..e5ecce7 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -3,23 +3,24 @@ Plugin Name: Freifunk Hamburg Firmware List Shortcode Plugin URI: http://mschuette.name/ Description: Defines shortcodes to display Freifunk Hamburg Firmware versions -Version: 0.4dev +Version: 0.5dev Author: Martin Schuette Author URI: http://mschuette.name/ Licence: 2-clause BSD */ -define( 'FF_HH_STABLE_BASEDIR', 'https://updates.hamburg.freifunk.net/stable/' ); +define( 'FF_HH_UPDATES_URL', 'https://updates.hamburg.freifunk.net/' ); define( 'FF_HH_CACHETIME', 1 ); /* gets metadata from URL, handles caching */ -function ff_hh_getmanifest( $basedir ) { +function ff_hh_getmanifest( $branch_url, $domain, $branch ) { // Caching - if ( WP_DEBUG || ( false === ( $manifest = get_transient( 'ff_hh_manifest' ) ) ) ) { - $manifest = array(); - $url = $basedir . 'sysupgrade/stable.manifest'; + $cache_key = 'ff_hh_manifest_' . $domain . '_' . $branch; + if ( WP_DEBUG || ( false === ( $manifest = get_transient( $cache_key ) ) ) ) { + $manifest = array(); + $url = $branch_url . '/sysupgrade/' . $branch . '.manifest'; $http_response = wp_remote_get( $url ); // TODO: error handling - $input = wp_remote_retrieve_body( $http_response ); + $input = wp_remote_retrieve_body( $http_response ); foreach ( explode( "\n", $input ) as $line ) { $ret = sscanf( $line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename ); if ( $ret === 4 ) { @@ -34,23 +35,25 @@ function ff_hh_getmanifest( $basedir ) { } $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; - set_transient( 'ff_hh_manifest', $manifest, $cachetime ); + set_transient( $cache_key, $manifest, $cachetime ); } return $manifest; } /* gets latest version from first manifest line */ -function ff_hh_getlatest( $basedir ) { +function ff_hh_getlatest( $branch_url, $domain, $branch ) { // Caching - if ( false === ( $sw_ver = get_transient( 'ff_hh_latestversion' ) ) ) { + $cache_key = 'ff_hh_latestversion_' . $domain . '_' . $branch; + if ( false === ( $sw_ver = get_transient( $cache_key ) ) ) { $sw_ver = 'unknown'; - $input = wp_remote_retrieve_body( wp_remote_get( $basedir . 'sysupgrade/stable.manifest' ) ); + $url = $branch_url . '/sysupgrade/' . $branch . '.manifest'; + $input = wp_remote_retrieve_body( wp_remote_get( $url ) ); foreach ( explode( "\n", $input ) as $line ) { $ret = sscanf( $line, '%s %s %s %s', $hw, $sw_ver, $hash, $filename ); if ( $ret === 4 ) { // break processing on first matching line $cachetime = FF_HH_CACHETIME * MINUTE_IN_SECONDS; - set_transient( 'ff_hh_latestversion', $sw_ver, $cachetime ); + set_transient( $cache_key, $sw_ver, $cachetime ); break; } } @@ -63,32 +66,53 @@ if ( ! shortcode_exists( 'ff_hh_latestversion' ) ) { } // Example: // [ff_hh_latestversion] +// [ff_hh_latestversion domain="ffhh-sued" branch="experimental"] function ff_hh_shortcode_latestversion( $atts, $content, $name ) { - $sw_ver = ff_hh_getlatest( FF_HH_STABLE_BASEDIR ); + $domain = 'ffhh'; + $branch = 'stable'; + if ( is_array( $atts ) ) { + if ( array_key_exists( 'domain', $atts ) && ! empty( $atts['domain'] ) ) { + $domain = $atts['domain']; + } + if ( array_key_exists( 'branch', $atts ) && ! empty( $atts['branch'] ) ) { + $branch = $atts['branch']; + } + } + + $branch_url = FF_HH_UPDATES_URL . $domain . '/' . $branch; + $sw_ver = ff_hh_getlatest( $branch_url, $domain, $branch ); $outstr = "$sw_ver"; return $outstr; } + if ( ! shortcode_exists( 'ff_hh_versions' ) ) { add_shortcode( 'ff_hh_versions', 'ff_hh_shortcode_versions' ); } // Example: // [ff_hh_versions] -// [ff_hh_versions grep="ubiquiti"] +// [ff_hh_versions domain="ffhh-sued" branch="experimental" grep="ubiquiti"] function ff_hh_shortcode_versions( $atts, $content, $name ) { - $manifest = ff_hh_getmanifest( FF_HH_STABLE_BASEDIR ); + $domain = 'ffhh'; + $branch = 'stable'; + $grep = false; + if ( is_array( $atts ) ) { + if ( array_key_exists( 'domain', $atts ) && ! empty( $atts['domain'] ) ) { + $domain = $atts['domain']; + } + if ( array_key_exists( 'branch', $atts ) && ! empty( $atts['branch'] ) ) { + $branch = $atts['branch']; + } + if ( array_key_exists( 'grep', $atts ) && ! empty( $atts['grep'] ) ) { + $grep = $atts['grep']; + } + } + + $branch_url = FF_HH_UPDATES_URL . $domain . '/' . $branch; + $manifest = ff_hh_getmanifest( $branch_url, $domain, $branch ); $outstr = "
"; $outstr .= ''; - # optionally filter output by given substring - if ( is_array( $atts ) - && array_key_exists( 'grep', $atts ) - && ! empty( $atts['grep'] ) ) { - $grep = $atts['grep']; - } else { - $grep = false; - } - foreach ( $manifest as $hw => $versions ) { // filter if ( $grep && ( false === strpos( $hw, $grep ) ) ) { @@ -107,12 +131,13 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $filename = str_replace( '-sysupgrade', '', $filename ); if (strpos($filename,'netgear') !== false) { $filename = str_replace( '.bin', '.img', $filename ); - $filename = str_replace( '.tar', '.img', $filename ); + $filename = str_replace( '.tar', '.img', $filename ); } $hw_ver_links[] = sprintf( '%s.x', - FF_HH_STABLE_BASEDIR.'factory/', - $filename, $hw_ver + $branch_url . '/factory/', + $filename, + $hw_ver ); } if ( count($hw_ver_links) > 0) { @@ -126,8 +151,9 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { foreach ( $versions as $hw_ver => $filename ) { $hw_ver_links[] = sprintf( '%s.x', - FF_HH_STABLE_BASEDIR.'sysupgrade/', - $filename, $hw_ver + $branch_url . '/sysupgrade/', + $filename, + $hw_ver ); } $outstr .= ''; @@ -171,43 +197,43 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = strtoupper( $hw ); $hw = str_replace( 'HP-AG300H-WZR-600DHP', 'HP-AG300H & WZR-600DHP', $hw ); $hw = str_replace( '-WZR', 'WZR', $hw ); - } elseif ( ! strncmp( $hw, 'netgear', 7 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'allnet', 6 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'gl-inet', 7 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'onion-omega', 11 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + } elseif ( ! strncmp( $hw, 'netgear', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'allnet', 6 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'gl-inet', 7 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'onion-omega', 11 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); } elseif ( ! strncmp( $hw, 'alfa', 4 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( '-', '', $hw ); + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); } elseif ( ! strncmp( $hw, 'wd', 2 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, '8devices', 8 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( 'CARAMBOLA2-BOARD', 'Carambola 2', $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'meraki', 6 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( 'meraki', '', $hw ); - $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'openmesh', 8 ) ) { - if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); - $hw = strtoupper( $hw ); - $hw = str_replace( 'openmesh', '', $hw ); - $hw = str_replace( '-', '', $hw ); + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, '8devices', 8 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'CARAMBOLA2-BOARD', 'Carambola 2', $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'meraki', 6 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'meraki', '', $hw ); + $hw = str_replace( '-', '', $hw ); + } elseif ( ! strncmp( $hw, 'openmesh', 8 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = strtoupper( $hw ); + $hw = str_replace( 'openmesh', '', $hw ); + $hw = str_replace( '-', '', $hw ); } return $hw; } From b40f2878b705c50cdc4eea55881b631ae858b4dc Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Mon, 4 Dec 2017 21:56:43 +0100 Subject: [PATCH 23/26] Add "filter" argument --- freifunk-versions.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index e5ecce7..93b65bb 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -95,6 +95,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $domain = 'ffhh'; $branch = 'stable'; $grep = false; + $filter = false; if ( is_array( $atts ) ) { if ( array_key_exists( 'domain', $atts ) && ! empty( $atts['domain'] ) ) { $domain = $atts['domain']; @@ -105,6 +106,9 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { if ( array_key_exists( 'grep', $atts ) && ! empty( $atts['grep'] ) ) { $grep = $atts['grep']; } + if ( array_key_exists( 'filter', $atts ) && ! empty( $atts['filter'] ) ) { + $filter = explode ( ',', $atts['filter'] ); + } } $branch_url = FF_HH_UPDATES_URL . $domain . '/' . $branch; @@ -114,10 +118,24 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $outstr .= '
ModellErstinstallationAktualisierung
Hardware Ver. ' . join( ', ', $hw_ver_links ) . '
'; foreach ( $manifest as $hw => $versions ) { - // filter + // select some models if ( $grep && ( false === strpos( $hw, $grep ) ) ) { continue; } + // filter others + if ( $filter ) { + $filtered = false; + foreach ( $filter as $flt ) { + if ( strpos ( $hw, $flt ) !== false ) { + $filtered = true; + break; + } + } + if ( $filtered ) { + continue; + } + } + $hw = ff_hh_beautify_hw_name( $hw, $grep ); $outstr .= sprintf( "\n", $hw ); From 95cde2e10fed920f0d5096473d0064a4e1d22fe0 Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Mon, 15 Oct 2018 22:51:46 +0200 Subject: [PATCH 24/26] Add UBNT naming, sort models alphabetically --- freifunk-versions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index 93b65bb..197059f 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -117,6 +117,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { $outstr = "
"; $outstr .= '
ModellErstinstallationAktualisierung
%s
'; + ksort($manifest); foreach ( $manifest as $hw => $versions ) { // select some models if ( $grep && ( false === strpos( $hw, $grep ) ) ) { @@ -200,6 +201,12 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { $hw = str_replace( 'bullet-m', 'bullet-m', $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = ucwords( $hw ); + } elseif ( ! strncmp( $hw, 'ubnt', 4 ) ) { + if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); + $hw = str_replace( 'erx', 'ER-X', $hw ); + $hw = str_replace( 'sfp', 'SFP', $hw ); + $hw = trim( $hw, ' -' ); + $hw = ucwords( $hw ); } elseif ( ! strncmp( $hw, 'd-link', 6 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); From a5eab032fd2da2ea1de17427f949411ff7655243 Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Fri, 15 Feb 2019 21:57:02 +0100 Subject: [PATCH 25/26] Change Gl.iNet name mangling, because OpenWrt is awesome at naming --- freifunk-versions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freifunk-versions.php b/freifunk-versions.php index 197059f..ab811a5 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -230,7 +230,7 @@ function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', '', $hw ); - } elseif ( ! strncmp( $hw, 'gl-inet', 7 ) ) { + } elseif ( ! strncmp( $hw, 'gl-', 3 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', '', $hw ); From e156d1fc35b35dcf3a7d21fb84606f41c844bf0f Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Fri, 15 Mar 2019 22:16:52 +0100 Subject: [PATCH 26/26] Add URL workaround for multi-domain firmware --- freifunk-versions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/freifunk-versions.php b/freifunk-versions.php index ab811a5..b3190c0 100644 --- a/freifunk-versions.php +++ b/freifunk-versions.php @@ -80,6 +80,7 @@ function ff_hh_shortcode_latestversion( $atts, $content, $name ) { } $branch_url = FF_HH_UPDATES_URL . $domain . '/' . $branch; + if ( $domain === 'multi' ) { $branch_url = $branch_url . '/images'; } $sw_ver = ff_hh_getlatest( $branch_url, $domain, $branch ); $outstr = "$sw_ver"; return $outstr; @@ -112,6 +113,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) { } $branch_url = FF_HH_UPDATES_URL . $domain . '/' . $branch; + if ( $domain === 'multi' ) { $branch_url = $branch_url . '/images'; } $manifest = ff_hh_getmanifest( $branch_url, $domain, $branch ); $outstr = "
";
ModellErstinstallationAktualisierung