0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-24 17:43:48 +01:00

Various improvements and fixes

This commit is contained in:
peteruithoven 2013-09-30 17:34:27 +02:00
parent 5d5283c254
commit c0ed48b359
6 changed files with 53 additions and 17 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
credentials.php

4
.htaccess Normal file
View File

@ -0,0 +1,4 @@
# don't supress php errors
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

View File

@ -1,9 +1,9 @@
<?php
require 'credentials.php';
$database = "doodle3d_connect";
$dsn = "mysql:host=localhost;dbname=$database";
$username = "root";
$password = "mysql";
$table = "signins";
try {

View File

@ -2,15 +2,23 @@
require 'connect.php';
// exported structure using phpMyAdmin
$createsql = $db->prepare("CREATE TABLE IF NOT EXISTS $table (" .
"`id` varchar(151) NOT NULL," .
"`remoteip` varchar(15) NOT NULL," .
"`localip` varchar(15) NOT NULL," .
"`wifiboxid` varchar(140) NOT NULL," .
"`hidden` tinyint(1) NOT NULL DEFAULT '0'," .
"`date` datetime NOT NULL," .
"PRIMARY KEY (`id`)" .
") ENGINE=InnoDB DEFAULT CHARSET=latin1;");
$createsql->execute();
try {
// exported structure using phpMyAdmin
$createsql = $db->prepare("CREATE TABLE IF NOT EXISTS $table (" .
"`id` varchar(151) NOT NULL," .
"`remoteip` varchar(15) NOT NULL," .
"`localip` varchar(15) NOT NULL," .
"`wifiboxid` varchar(140) NOT NULL," .
"`hidden` tinyint(1) NOT NULL DEFAULT '0'," .
"`date` datetime NOT NULL," .
"PRIMARY KEY (`id`)" .
") ENGINE=InnoDB DEFAULT CHARSET=latin1;");
if($createsql->execute() == TRUE)
echo "$table created";
} catch (PDOException $e) {
$response = array( "status" => "error",
"msg" => $e->getMessage()." (".$e->getCode().")");
exit(json_encode($response)."\r\n");
}
?>

View File

@ -1,5 +1,6 @@
var retrieveListDelay; // retry setTimout instance
var retrieveListInterval = 5000;
var boxTimeoutTime = 300;
var $list;
$(function() {
@ -10,8 +11,9 @@ $(function() {
})
function retrieveList() {
$.ajax({
url: "/list.php",
url: "list.php",
dataType: 'json',
timeout: boxTimeoutTime,
success: function(response){
//console.log("retrieveList response: ",response);
if(response.status == "success") {
@ -27,9 +29,24 @@ function retrieveList() {
});
}
function updateList(boxes) {
//console.log("list: ",boxes);
$list.empty();
jQuery.each(boxes, function (index,box) {
$list.append("<li><a href='/"+box.localip+"'>"+box.wifiboxid+"</a></li>");
checkBox(box);
});
}
function checkBox(box) {
$.ajax({
url: "http://"+box.localip+"/d3dapi/network/status",
dataType: 'json',
success: function(response){
if(response.status == "success") {
var url = "http://"+box.localip;
if(boxIsListed(url)) return;
$list.append("<li><a href='"+url+"'>"+box.wifiboxid+"</a></li>");
}
}
});
}
function boxIsListed(url){
return $list.find("a[href|='"+url+"']").length > 0;
}

View File

@ -15,7 +15,12 @@
exit(json_encode($response)."\r\n");
}
$debug = array( "time" => time(),
"hourago" => $hourago,
"remoteip" => $remoteip);
$response = array( "status" => "success",
"data" => $boxes);
"data" => $boxes,
"debug" => $debug);
exit(json_encode($response)."\r\n");
?>