Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GeoHopper updates and concept of notification "events".
- Loading branch information
Showing
6 changed files
with
283 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 4.0.10deb1 | ||
-- http://www.phpmyadmin.net | ||
-- | ||
-- Host: localhost | ||
-- Generation Time: Mar 07, 2015 at 10:15 PM | ||
-- Server version: 5.5.41-0ubuntu0.14.04.1 | ||
-- PHP Version: 5.5.9-1ubuntu4.6 | ||
|
||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
SET time_zone = "+00:00"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
|
||
-- | ||
-- Database: `cam` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `cameras` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `cameras` ( | ||
`cid` int(11) NOT NULL AUTO_INCREMENT, | ||
`location` varchar(12) NOT NULL, | ||
`enabled` int(11) NOT NULL DEFAULT '1', | ||
`snapshot_url` varchar(200) NOT NULL, | ||
`ignore_ranges` varchar(100) NOT NULL, | ||
`ignoreHome` int(11) NOT NULL, | ||
`ignoreAway` int(11) NOT NULL, | ||
PRIMARY KEY (`cid`), | ||
UNIQUE KEY `name` (`location`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `images` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `images` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`image` varchar(500) NOT NULL, | ||
`date` datetime NOT NULL, | ||
`location` varchar(25) NOT NULL, | ||
`notified` int(11) NOT NULL DEFAULT '0', | ||
PRIMARY KEY (`image`), | ||
UNIQUE KEY `id` (`id`), | ||
UNIQUE KEY `image` (`image`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14221 ; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `suppress` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `suppress` ( | ||
`authkey` varchar(15) NOT NULL, | ||
`expiration` datetime NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `users` ( | ||
`uid` int(11) NOT NULL AUTO_INCREMENT, | ||
`user` varchar(12) NOT NULL, | ||
`authkey` varchar(20) NOT NULL, | ||
`enabled` int(1) NOT NULL DEFAULT '1', | ||
`admin` int(11) NOT NULL DEFAULT '0', | ||
`week` int(1) NOT NULL DEFAULT '1', | ||
`pushoverApp` varchar(30) NOT NULL, | ||
`pushoverKey` varchar(30) NOT NULL, | ||
`lastNotify` datetime NOT NULL, | ||
`isHome` int(11) DEFAULT '0', | ||
`homeTime` datetime NOT NULL, | ||
UNIQUE KEY `uid` (`uid`), | ||
UNIQUE KEY `user` (`user`), | ||
KEY `uid_2` (`uid`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; | ||
|
||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
require_once('config.php'); | ||
|
||
#ini_set('display_startup_errors',1); | ||
#ini_set('display_errors',1); | ||
#error_reporting(-1); | ||
|
||
|
||
$auth=0; | ||
|
||
if ($_REQUEST['auth'] && (!preg_match('/^[a-zA-Z0-9]+$/',$_REQUEST['auth']))) { | ||
exit; | ||
} | ||
$token=$_REQUEST['auth']; | ||
if ($token) { | ||
$conn = new mysqli($db_server, $db_username, $db_password, $db_database); | ||
$stmt = $conn->prepare("select count(uid),week,admin from users where authkey=? and enabled=1"); | ||
$stmt->bind_param("s", $token); | ||
$stmt->execute(); | ||
$stmt->bind_result($auth,$week,$is_admin); | ||
$stmt->fetch(); | ||
} | ||
|
||
if ($auth<1) { | ||
exit; | ||
} | ||
|
||
$data = json_decode(file_get_contents('php://input')); | ||
|
||
if (preg_match('/Home/',$data->location)) { | ||
if ($data->event == "LocationEnter") { | ||
$location = "1"; | ||
} else { | ||
$location = "0"; | ||
} | ||
} | ||
|
||
if ($location >= 0) { | ||
$conn = new mysqli($db_server, $db_username, $db_password, $db_database); | ||
$stmt = $conn->prepare("update users set isHome=?,homeTime=NOW() where authkey=?"); | ||
$stmt->bind_param("ss", $location,$token); | ||
$stmt->execute(); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.