Browse Source

Readme

master
Markus Becker 6 years ago
parent
commit
39f6c7b5c3
  1. 57
      README.md
  2. 20
      interface/exec/pulllib.php

57
README.md

@ -0,0 +1,57 @@
# Weather Monitoring System
## Configuration
You have to change the settings to fit this software to your database.
```bash
git clone https://github.com/tibyte/apewms.git
cd apewms/interface/exec/
cp _auth.php auth.php
nano auth.php
```
Enter the ip to your database, your username, password, and database name. The base dir variable is not used for anything as of now.
**You have to create your database tables manually**
```sql
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
-- create ENTRIES-FOLDER
CREATE TABLE IF NOT EXISTS `entries` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`fid` int(10) unsigned zerofill NOT NULL,
`remote` tinyint(1) NOT NULL,
`content` text NOT NULL,
`src` text NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `fid` (`fid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- create FOLDER-TABLE
CREATE TABLE IF NOT EXISTS `folders` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`folder` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
-- create ACCOUNT-TABLE
CREATE TABLE IF NOT EXISTS `logins` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`username` varchar(18) NOT NULL,
`desc` text NOT NULL COMMENT 'About Location e.g. "Hafenhaus"',
`pw` text NOT NULL,
`salt` text NOT NULL,
`speed` int(10) unsigned zerofill NOT NULL DEFAULT '0000000010',
`session` text,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
```
## Dependencies
- php5
- mysql
## Python API
Github-Repo: [WMS-API](https://github.com/tibyte/autowkid/blob/master/wmsapi.py)

20
interface/exec/pulllib.php

@ -1,4 +1,5 @@
<?
// FIXME correct spelling, lowercase
// Contains credential function:
// getServer(), getUser(), getPass(), getData(), getBaseDir()
@ -11,6 +12,7 @@ function getCon(){
$user = getUser();
$pass = getPass();
$data = getData();
// TODO create Tables if not exist
return new mysqli($server, $user, $pass, $data);
}
@ -18,7 +20,7 @@ function getFolderArray(){
$folders = array();
$con = getCon();
if ($con->connect_error) {
echo "Database Error";
println("database error");
}
$prep = $con->prepare("SELECT id, folder FROM folders");
$prep->bind_result($number,$folder);
@ -83,7 +85,7 @@ function directCheckSessionData(){
if(isset($_SESSION["username"]) && isset($_SESSION["session"])){
return checkSessionData($_SESSION["username"], $_SESSION["session"]);
}
println("Data NOT available");
println("data <b>not</b> available");
return false;
}
@ -91,16 +93,12 @@ function directCheckSessionData(){
function generateSessionData($username){
$con = getCon();
if ($con->connect_error) {
echo "Database Error";
println("database error");
}
println("Pre Prepare");
$prep = $con->prepare('UPDATE logins SET session=? WHERE username=?');
$prep->bind_param('ss', $hash, $username);
println("Pre Hash");
$hash=hash("sha256", time().$username);
println("Post Hash");
$prep->execute();
println("Execute");
return $hash;
$con->close();
}
@ -131,8 +129,6 @@ function validLogin(){
//used Form generate session code
$username = $_POST["username"];
$password = $_POST["password"];
// println($username); DAFUK?
// println($password);
//write session code in database, after confirm
if(!checkLoginData($username, $password)){
//if confirm fails return false
@ -157,7 +153,7 @@ function getFilesInFolderSQL($fid){
$frames = array();
$con = getCon();
if ($con->connect_error) {
echo "Database Error";
println("database error");
}
$prep = $con->prepare("SELECT content FROM entries WHERE fid=?");
$prep->bind_param('i',$fid);
@ -175,7 +171,7 @@ function getFilesInFolderSQL($fid){
function getSourceInFolderSQL($fid){$frames = array();
$con = getCon();
if ($con->connect_error) {
echo "Database Error";
println("database error");
}
$prep = $con->prepare("SELECT src FROM entries WHERE fid=?");
$prep->bind_param('i',$fid);
@ -194,7 +190,7 @@ function getInfoFilesInFolderSQL($fid){
$files = array();
$con = getCon();
if ($con->connect_error) {
echo "Database Error";
println("database error");
}
$prep = $con->prepare("SELECT id, content, src, created FROM entries WHERE fid=?");
$prep->bind_param('i',$fid);

Loading…
Cancel
Save