[PATCH 1/1] Add Hood Listing page to keyserver

Tim Niemeyer tim.niemeyer at mastersword.de
Do Jan 28 19:42:14 CET 2016


Hi

Am Dienstag, den 26.01.2016, 12:31 +0100 schrieb Dominik Heidler:
> This will allow monitoring (and other tools) to
> maintain a recent list of hoods.
> 
> Signed-off-by: Dominik Heidler <dominik at heidler.eu>
Tested-by: Tim Niemeyer <tim.niemeyer at mastersword.de>

Und applied.

Tim

> ---
>  hoods.php | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>  create mode 100644 hoods.php
> 
> diff --git a/hoods.php b/hoods.php
> new file mode 100644
> index 0000000..37920ec
> --- /dev/null
> +++ b/hoods.php
> @@ -0,0 +1,27 @@
> +<?php
> +try {
> +	require ("config.inc.php");
> +	$db = new PDO("mysql:host=$mysql_server;dbname=$mysql_db;charset=utf8mb4", $mysql_user, $mysql_pass);
> +	$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
> +	$rs = $db->prepare ( "SELECT * FROM `hoods`" );
> +	$rs->execute ();
> +} catch ( PDOException $e ) {
> +	exit($e);
> +}
> +
> +$hoods = array();
> +while ( $result = $rs->fetch ( PDO::FETCH_ASSOC ) ) {
> +	$hood = array();
> +	$hood['id']   = intval($result['ID']);
> +	$hood['name'] = $result['name'];
> +	$hood['net']  = $result['net'];
> +	if ($result ['lat'] > 0 && $result ['lon'] > 0) {
> +		$hood['lat'] = floatval($result['lat']);
> +		$hood['lon'] = floatval($result['lon']);
> +	}
> +	array_push($hoods, $hood);
> +}
> +
> +header("Content-Type: application/json");
> +echo json_encode($hoods, JSON_PRETTY_PRINT);
> +?>
> -- 
> 2.7.0
> 

-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 473 bytes
Beschreibung: This is a digitally signed message part
URL         : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20160128/503b0741/attachment-0002.sig>


Mehr Informationen über die Mailingliste franken-dev