Move DB connection to header.php. Add initial SQL db file.
This commit is contained in:
parent
1686aa798d
commit
f08c5442a4
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
# OS generated files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Trashes
|
||||
Thumbs.db
|
||||
|
||||
# Ignore temporary office docs
|
||||
~$*
|
||||
|
||||
# The active config file copied from config-dist.php
|
||||
config.php
|
||||
|
||||
# Vim
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# SQLite
|
||||
*.sqlite
|
||||
|
||||
# sass generated files
|
||||
.sass-cache/
|
||||
install/.sass-cache/
|
||||
compressed
|
||||
*.map
|
||||
|
||||
# IDE generated
|
||||
.idea/
|
||||
|
||||
# Composer "vendor" libraries
|
||||
vendor/
|
||||
|
||||
# Single character PHP files
|
||||
?.php
|
|
@ -4,3 +4,9 @@ define('LEDADDRESS', '192.168.2.255');
|
|||
define('PACKETFILTER', array(4039196302, 3194769291));
|
||||
define('UDPPORT', 6565);
|
||||
define('MESSAGECOUNT', 10);
|
||||
|
||||
define("DBHOST", "dbserver.network.lan");
|
||||
define("DBNAME", "ledcolors");
|
||||
define("DBUSER", "ledcolors");
|
||||
define("DBPASS", "ledcolors");
|
||||
|
|
@ -2,14 +2,6 @@
|
|||
|
||||
require 'header.php';
|
||||
|
||||
define("DBHOST", "storage.basement.lan");
|
||||
define("DBNAME", "ledcolors");
|
||||
define("DBUSER", "root");
|
||||
define("DBPASS", "CeleryStalk");
|
||||
|
||||
// Make our PDO database connection which will be used in all scripts
|
||||
$globaldbh = new PDO("mysql:host=" . DBHOST . ";dbname=" . DBNAME, DBUSER, DBPASS);
|
||||
|
||||
$query = "SELECT id, name FROM patterns ORDER BY name";
|
||||
$sth = $globaldbh->prepare($query);
|
||||
$sth->execute();
|
||||
|
|
|
@ -12,4 +12,10 @@ if ( php_sapi_name() != "cli" ) {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
// Make our PDO database connection which will be used in all scripts
|
||||
try {
|
||||
$globaldbh = new PDO("mysql:host=" . DBHOST . ";dbname=" . DBNAME, DBUSER, DBPASS);
|
||||
} catch (Exception $e) {
|
||||
echo "Persistence error!";
|
||||
exit();
|
||||
}
|
||||
|
|
97
install/ledcolors.sql
Normal file
97
install/ledcolors.sql
Normal file
|
@ -0,0 +1,97 @@
|
|||
-- MySQL dump 10.15 Distrib 10.0.26-MariaDB, for Linux (x86_64)
|
||||
--
|
||||
-- Host: storage Database: ledcolors
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.2.20-MariaDB-1:10.2.20+maria~bionic-log
|
||||
|
||||
/*!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 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `patterncolors`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `patterncolors`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `patterncolors` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pattern_id` mediumint(8) unsigned NOT NULL,
|
||||
`red` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`green` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`blue` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`resttime` mediumint(8) unsigned NOT NULL DEFAULT 1000,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `patterncolors`
|
||||
--
|
||||
|
||||
LOCK TABLES `patterncolors` WRITE;
|
||||
/*!40000 ALTER TABLE `patterncolors` DISABLE KEYS */;
|
||||
INSERT INTO `patterncolors` VALUES (1,1,255,0,0,10000);
|
||||
INSERT INTO `patterncolors` VALUES (2,1,0,255,0,10000);
|
||||
INSERT INTO `patterncolors` VALUES (3,2,255,89,0,4000);
|
||||
INSERT INTO `patterncolors` VALUES (4,2,200,0,255,4000);
|
||||
INSERT INTO `patterncolors` VALUES (5,3,0,143,13,0);
|
||||
INSERT INTO `patterncolors` VALUES (6,3,139,0,8,0);
|
||||
INSERT INTO `patterncolors` VALUES (7,3,6,1,143,0);
|
||||
INSERT INTO `patterncolors` VALUES (8,3,143,2,84,0);
|
||||
INSERT INTO `patterncolors` VALUES (9,3,62,143,140,0);
|
||||
INSERT INTO `patterncolors` VALUES (10,5,0,0,0,200);
|
||||
INSERT INTO `patterncolors` VALUES (11,4,255,0,0,10000);
|
||||
INSERT INTO `patterncolors` VALUES (12,4,255,255,255,10000);
|
||||
INSERT INTO `patterncolors` VALUES (13,4,0,0,255,10000);
|
||||
/*!40000 ALTER TABLE `patterncolors` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `patterns`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `patterns`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `patterns` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`ramptime` mediumint(8) unsigned NOT NULL DEFAULT 1000,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `patterns`
|
||||
--
|
||||
|
||||
LOCK TABLES `patterns` WRITE;
|
||||
/*!40000 ALTER TABLE `patterns` DISABLE KEYS */;
|
||||
INSERT INTO `patterns` VALUES (1,'Christmas',500);
|
||||
INSERT INTO `patterns` VALUES (2,'Halloween',1000);
|
||||
INSERT INTO `patterns` VALUES (3,'Mellow',10000);
|
||||
INSERT INTO `patterns` VALUES (4,'Memorial',1000);
|
||||
INSERT INTO `patterns` VALUES (5,'Crazy',1);
|
||||
/*!40000 ALTER TABLE `patterns` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!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 */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2023-11-14 9:21:13
|
|
@ -7,14 +7,6 @@ if ( !isset($_REQUEST['t']) ) exit();
|
|||
$patternname = $_REQUEST['p'];
|
||||
$targets = $_REQUEST['t'];
|
||||
|
||||
define("DBHOST", "storage.basement.lan");
|
||||
define("DBNAME", "ledcolors");
|
||||
define("DBUSER", "root");
|
||||
define("DBPASS", "CeleryStalk");
|
||||
|
||||
// Make our PDO database connection which will be used in all scripts
|
||||
$globaldbh = new PDO("mysql:host=" . DBHOST . ";dbname=" . DBNAME, DBUSER, DBPASS);
|
||||
|
||||
class PatternColor {
|
||||
public $red = 0;
|
||||
public $green = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user