From f5a09e7c0fadb1c7595998285999e5dc21f49b43 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Fri, 27 Sep 2013 12:31:55 +0200 Subject: [PATCH] REST like interface (json responses), auto refreshing index page --- connect.php | 11 +++++-- index.php => index.html | 22 +++----------- js/libs/jquery-1.8.3.min.js | 2 ++ js/main.js | 35 ++++++++++++++++++++++ list.php | 21 +++++++++++++ signin.php | 59 ++++++++++++++++++++++++------------- 6 files changed, 108 insertions(+), 42 deletions(-) rename index.php => index.html (60%) create mode 100644 js/libs/jquery-1.8.3.min.js create mode 100644 js/main.js create mode 100644 list.php diff --git a/connect.php b/connect.php index cea46e1..292e8a6 100644 --- a/connect.php +++ b/connect.php @@ -6,7 +6,12 @@ $password = "mysql"; $table = "signins"; - $db = new PDO($dsn, $username, $password); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - + try { + $db = new PDO($dsn, $username, $password); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } catch (PDOException $e) { + $response = array( "status" => "error", + "msg" => $e->getMessage()." (".$e->getCode().")"); + exit(json_encode($response)); + } ?> diff --git a/index.php b/index.html similarity index 60% rename from index.php rename to index.html index ac78db3..0c9c2fc 100644 --- a/index.php +++ b/index.html @@ -1,15 +1,3 @@ -prepare("SELECT * FROM $table where date >= FROM_UNIXTIME(:hourago) AND remoteip = :remoteip"); - $statement->execute(array( ':hourago' => $hourago, - ':remoteip' => $remoteip)); - $boxes = $statement->fetchAll(); -?> @@ -24,15 +12,13 @@ + + +

Hi, we found the following Doodle3D WiFi boxes near you:

-