Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: functions.php new file: images/Raspberry_Pi_Logo-200x150.png new file: images/off.png new file: images/offline.jpg new file: images/on.png new file: images/siri-small.jpg new file: index.php new file: install/database.sql new file: install/index.php new file: install/install.php new file: main.php new file: scripts/gencert.sh new file: scripts/stats.sh new file: sms.php new file: sms/smspi.php new file: sms/textlocal.php
- Loading branch information
1 parent
e5c75a2
commit 60b20d9
Showing
17 changed files
with
1,027 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
###################################################### | ||
# RPI Control By Robert Wiggins # | ||
# # | ||
# http://www.github.com/txt3rob/RPI-Control/ # | ||
# # | ||
# Donate to txt3rob@gmail.com # | ||
# # | ||
######################################################+ | ||
|
||
|
||
// Mysql Config | ||
$dbuser = "root"; | ||
$dbpass = "raspberry"; | ||
$dbname = "rpicontrol"; | ||
$dbhost = "localhost"; | ||
|
||
try { | ||
// database connection | ||
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass); | ||
|
||
} catch (PDOException $e) { | ||
echo "Connection failed: " . $e->getMessage(); | ||
} | ||
?> |
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,98 @@ | ||
<?php | ||
###################################################### | ||
# RPI Control By Robert Wiggins # | ||
# # | ||
# http://www.github.com/txt3rob/RPI-Control/ # | ||
# # | ||
# Donate to txt3rob@gmail.com # | ||
# # | ||
###################################################### | ||
include ('config.php'); | ||
$filepath = dirname(dirname(__FILE__)); | ||
|
||
$uptime = shell_exec("cut -d. -f1 /proc/uptime"); | ||
$days = floor($uptime/60/60/24); | ||
$hours = $uptime/60/60%24; | ||
$mins = $uptime/60%60; | ||
|
||
$stats = shell_exec('.'.$filepath.'/scripts/stats.sh'); | ||
|
||
//List Devices | ||
$GLOBAL $dbh; | ||
$devices = $dbh->prepare("SELECT * FROM devices"); | ||
$devices->execute(); | ||
|
||
function updatestate ($dev,$state) | ||
{ | ||
// update database with state | ||
GLOBAL $dbh; | ||
$updatestate = $dbh->prepare("UPDATE `devices` SET `state` = :state WHERE `name` = :name"); | ||
$updatestate ->bindParam(':name', $dev); | ||
$updatestate ->bindParam(':state', $state); | ||
$updatestate->execute(); | ||
} | ||
|
||
function commandit ($brand,$remote,$channel,$state) | ||
{ | ||
// execute command | ||
passthru ('sudo pihat --brand='.$brand.' --repeats=15 --id='.$remote.' --channel='.$channel.' --state='.$state.''); | ||
} | ||
|
||
function insertsms ($user,$message) | ||
{ | ||
GLOBAL $dbh; | ||
$insertsms = $dbh->prepare ("INSERT INTO smshistory (user,command) VALUES (:user,:message)"); | ||
$insertsms->bindParam(':user', $user); | ||
$insertsms->bindParam(':message', $message); | ||
$insertsms->execute(); | ||
} | ||
|
||
function updatehistory ($command,$user) | ||
{ | ||
GLOBAL $dbh; | ||
$updatehistory = $dbh->prepare("UPDATE `smshistory` SET `completed` = 1 WHERE `command` = :command AND `user` = :user "); | ||
$updatehistory->bindParam(':command', $command); | ||
$updatehistory->bindParam(':user', $user); | ||
$updatehistory->execute(); | ||
} | ||
|
||
function wol ($computer) | ||
{ | ||
GLOBAL $dbh; | ||
$wol = $dbh->prepare("SELECT * FROM `wol` WHERE computer = :computer"); | ||
$wol->bindParam(':computer', $computer); | ||
$wol->execute(); | ||
$wol2 = $wol->fetch(PDO::FETCH_ASSOC); | ||
$mac = $wol2['mac']; | ||
passthru ('wakeonlan '.$mac.''); | ||
echo "Wake on Lan Command Sent"; | ||
} | ||
function addevice ($devicename,$devicebrand,$deviceremoteid,$deviceremoteid) { | ||
GLOBAL $dbh; | ||
$insertdevice = $dbh->prepare ("INSERT INTO `devices` (name,brand,remoteid,channel) VALUES (:name,:brand,:remoteid,:channel)"); | ||
$insertdevice->bindParam(':name', $devicename); | ||
$insertdevice->bindParam(':brand', $devicebrand); | ||
$insertdevice->bindParam(':remoteid', $deviceremoteid); | ||
$insertdevice->bindParam(':channel', $devicechannel); | ||
$insertdevice->execute(); | ||
echo "<br><b>Device Added to Database</b><br />"; | ||
} | ||
|
||
function addmac ($name,$mac) { | ||
GLOBAL $dbh; | ||
$insertmac= $dbh->prepare("INSERT INTO `wol` (`computer`, `mac`) VALUES (:computer, :mac)"); | ||
$insertmac->bindParam(':computer', $name); | ||
$insertmac->bindParam(':mac', $mac); | ||
$insertmac->execute(); | ||
echo "<br><b>WOL Added to Database</b><br />"; | ||
} | ||
|
||
function adduser ($name,$number) { | ||
GLOBAL $dbh; | ||
$insertuser= $dbh->prepare("INSERT INTO `users` (`name`, `number`) VALUES (:name, :number)"); | ||
$insertuser->bindParam(':name', $name); | ||
$insertuser->bindParam(':number', $number); | ||
$insertuser->execute(); | ||
echo "<br><b>User Added to Database</b><br />"; | ||
} | ||
?> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,61 @@ | ||
<?php | ||
###################################################### | ||
# RPI Control By Robert Wiggins # | ||
# # | ||
# http://www.github.com/txt3rob/RPI-Control/ # | ||
# # | ||
# Donate to txt3rob@gmail.com # | ||
# # | ||
###################################################### | ||
|
||
include ('config.php'); | ||
include ('main.php'); | ||
|
||
if (!empty($_POST['id'])) { | ||
exit(); | ||
} | ||
|
||
//Look for commands | ||
$url = $_POST["id"]; | ||
echo $url; | ||
|
||
exit(); die(); | ||
|
||
// is it an on or off command? | ||
if (strpos($url,'-') !== false) { | ||
$parts = explode("-", $url); | ||
$dev = $parts[0]; | ||
$onoroff = $parts[1]; | ||
|
||
|
||
// Set on or off state | ||
if ($onoroff == "on") { | ||
$state = "1"; | ||
} else { | ||
$state = "0"; | ||
} | ||
|
||
// Find Device in DB | ||
$devlookup = $dbh->prepare("SELECT * FROM `devices` WHERE `name` = :name"); | ||
$devlookup = bindParam(':name', $dev); | ||
$devlookup->execute(); | ||
$devlookup->fetch(PDO::FETCH_ASSOC); | ||
$brand = $devlookup['brand']; | ||
$remote = $devlookup['remote']; | ||
$channel = $devlookup['channel']; | ||
|
||
// execute command and update the state in DB | ||
commandit ($brand,$remote,$channel,$state); | ||
updatestate ($dev,$state); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
?> |
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,80 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 3.4.11.1deb2 | ||
-- http://www.phpmyadmin.net | ||
-- | ||
-- Host: localhost | ||
-- Generation Time: Dec 19, 2013 at 11:38 AM | ||
-- Server version: 5.5.31 | ||
-- PHP Version: 5.4.4-14+deb7u4 | ||
|
||
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: `rpicontrol` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `devices` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `devices` ( | ||
`name` varchar(11) NOT NULL, | ||
`brand` varchar(2) NOT NULL, | ||
`remoteid` varchar(20) NOT NULL, | ||
`channel` varchar(2) NOT NULL, | ||
`state` varchar(2) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `smshistory` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `smshistory` ( | ||
`user` varchar(25) NOT NULL, | ||
`command` varchar(160) NOT NULL, | ||
`completed` varchar(1) NOT NULL DEFAULT '0', | ||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `smsprovider` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `smsprovider` ( | ||
`provider` varchar(50) NOT NULL, | ||
`script` varchar(50) NOT NULL, | ||
`use` varchar(1) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `users` ( | ||
`name` varchar(25) NOT NULL, | ||
`number` varchar(25) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- | ||
-- Table structure for table `wol` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `wol` ( | ||
`computer` varchar(50) NOT NULL, | ||
`mac` varchar(50) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
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,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Installation Script</title> | ||
</head> | ||
<body> | ||
<?php | ||
$configfile = dirname( __FILE__ ) . '/../config.php'; | ||
|
||
if (file_exists($configfile)) { | ||
echo "RPI-Control is already installed."; | ||
exit(); | ||
} | ||
header('Location: install.php'); | ||
exit; | ||
?> | ||
<p>This is our site.</p> | ||
</body> | ||
</html> |
Oops, something went wrong.