Fixed bugs
This commit is contained in:
parent
e984491d54
commit
4cca7ccdb2
@ -22,7 +22,7 @@ $aData[TABLE_USER] = array(
|
|||||||
'standard' => 'NOT NULL'
|
'standard' => 'NOT NULL'
|
||||||
),
|
),
|
||||||
|
|
||||||
'signal' => array(
|
'signalmessenger' => array(
|
||||||
'type' => 'VARCHAR',
|
'type' => 'VARCHAR',
|
||||||
'size' => 255,
|
'size' => 255,
|
||||||
'standard' => 'NOT NULL'
|
'standard' => 'NOT NULL'
|
||||||
|
112
static/form.php
112
static/form.php
@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
ini_set('display_startup_errors', 0);
|
||||||
|
error_reporting(E_ALL);
|
||||||
class Data{
|
class Data{
|
||||||
function __construct(){
|
function __construct(){
|
||||||
$this->link_database();
|
$this->link_database();
|
||||||
$this->em_check_database();
|
$this->em_check_database();
|
||||||
$this->read_variables();
|
$this->read_variables();
|
||||||
date_default_timezone_set($this->settings['timezone']);
|
date_default_timezone_set('Europe/Berlin');
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_variables() {
|
function read_variables() {
|
||||||
@ -54,6 +57,83 @@ class Data{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function em_check_database() {
|
||||||
|
/*
|
||||||
|
params:
|
||||||
|
None
|
||||||
|
returns:
|
||||||
|
None
|
||||||
|
This function compares the database structure to a predefined structure which is saved in db_array_config.php
|
||||||
|
and adds missing structures. Makes installation+updates easy
|
||||||
|
*/
|
||||||
|
$aTable=array();
|
||||||
|
//Alle Tabellen in Array lesen, inklusive aller Eigenschaften
|
||||||
|
$result=$this->databaselink->query("show tables from ".DB_DATABASE);
|
||||||
|
while($row = $result->fetch_array(MYSQLI_BOTH)){
|
||||||
|
$aTable[]=$row[0];
|
||||||
|
}
|
||||||
|
$aData=array();
|
||||||
|
$database_structure_path = __DIR__."/config/db_array.inc.php";
|
||||||
|
include($database_structure_path);
|
||||||
|
foreach($aData as $table=>$fields){
|
||||||
|
if(!in_array($table,$aTable)) {
|
||||||
|
//Add table to database
|
||||||
|
$mCounter=0;
|
||||||
|
$sCommand="CREATE TABLE IF NOT EXISTS `".$table."` (";
|
||||||
|
foreach($fields as $fieldname=>$properties){
|
||||||
|
$extra = "";
|
||||||
|
if($mCounter==0) {
|
||||||
|
$key="KEY `".$fieldname."` (`".$fieldname."`)";
|
||||||
|
}
|
||||||
|
if($properties["size"]!="") {
|
||||||
|
$size="(".$properties["size"].")";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$size="";
|
||||||
|
}
|
||||||
|
if((isset($properties["unique"])) and ($properties['unique']==true)) {
|
||||||
|
$unique="UNIQUE KEY `".$fieldname."_2` (`".$fieldname."`),";}
|
||||||
|
else {
|
||||||
|
$unique="";
|
||||||
|
}
|
||||||
|
if((isset($properties["extra"])) and ($properties != "")){
|
||||||
|
$extra = $properties['extra'];
|
||||||
|
}
|
||||||
|
$sCommand .= "`".$fieldname."` ".$properties["type"].$size." ".$properties["standard"]." ".$extra.",";
|
||||||
|
$mCounter++;
|
||||||
|
|
||||||
|
}
|
||||||
|
$sCommand.=$unique.$key.") ENGINE=InnoDB ;";
|
||||||
|
$this->last_query[]=$sCommand;
|
||||||
|
$updateresult=$this->databaselink->query($sCommand);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Felder checken und Tabelle updaten
|
||||||
|
$resultField=$this->databaselink->query("show fields from ".DB_DATABASE.".".$table);
|
||||||
|
while($aRowF = $resultField->fetch_array(MYSQLI_BOTH)){
|
||||||
|
$aTableFields[]=$aRowF[0];
|
||||||
|
}
|
||||||
|
foreach($fields as $fieldname=>$properties) {
|
||||||
|
if(!in_array($fieldname,$aTableFields)) {
|
||||||
|
if((isset($properties["size"]) and ($properties['size']!=""))) {
|
||||||
|
$size="(".$properties["size"].")";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$size="";
|
||||||
|
}
|
||||||
|
$sCommand="ALTER TABLE `".$table."` ADD `".$fieldname."` ".$properties["type"].$size." ".$properties["standard"];
|
||||||
|
$this->last_query[]=$sCommand;
|
||||||
|
$updateresult=$this->databaselink->query($sCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($aTableFields);
|
||||||
|
unset($aFields);
|
||||||
|
unset($properties);
|
||||||
|
}
|
||||||
|
unset($aData);
|
||||||
|
}
|
||||||
|
|
||||||
function store_data($sTable,$aFields,$sKey_ID,$mID) {
|
function store_data($sTable,$aFields,$sKey_ID,$mID) {
|
||||||
//updates or inserts data
|
//updates or inserts data
|
||||||
//returns ID or -1 if fails
|
//returns ID or -1 if fails
|
||||||
@ -126,6 +206,7 @@ class Data{
|
|||||||
Function will save user Information given in $aUser. If user exists it will
|
Function will save user Information given in $aUser. If user exists it will
|
||||||
overwrite existing data but not delete not-specified data
|
overwrite existing data but not delete not-specified data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$aFields = $aUser;
|
$aFields = $aUser;
|
||||||
if ((isset($this->r_user_ID))and ($this->r_user_ID != "")){
|
if ((isset($this->r_user_ID))and ($this->r_user_ID != "")){
|
||||||
$this->ID=$this->store_data(TABLE_USER, $aFields, 'user_ID' , $this->r_user_ID);
|
$this->ID=$this->store_data(TABLE_USER, $aFields, 'user_ID' , $this->r_user_ID);
|
||||||
@ -134,6 +215,14 @@ class Data{
|
|||||||
$this->ID=$this->store_data(TABLE_USER, $aFields, NULL , NULL);
|
$this->ID=$this->store_data(TABLE_USER, $aFields, NULL , NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_view($Datei) {
|
||||||
|
ob_start(); //startet Buffer
|
||||||
|
include($Datei);
|
||||||
|
$output=ob_get_contents(); //Buffer wird geschrieben
|
||||||
|
ob_end_clean(); //Buffer wird gelöscht
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//end of class
|
//end of class
|
||||||
@ -147,36 +236,36 @@ include ("config/config.inc.php");
|
|||||||
$oObject = new Data;
|
$oObject = new Data;
|
||||||
|
|
||||||
$oObject->output = "";
|
$oObject->output = "";
|
||||||
|
|
||||||
switch ($oObject->r_ac){
|
switch ($oObject->r_ac){
|
||||||
case 'save'
|
case 'user_save':
|
||||||
$aUser = array();
|
$aUser = array();
|
||||||
if(isset($oObject->r_user_ID)){
|
if(isset($oObject->r_user_ID)){
|
||||||
$aUser['user_ID'] = $oObject->r_user_ID;
|
$aUser['user_ID'] = $oObject->r_user_ID;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_name)){
|
if(isset($oObject->r_name)){
|
||||||
$aUser['name'] = $oObject->r_forename;
|
$aUser['name'] = $oObject->r_name;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_email)){
|
if(isset($oObject->r_email)){
|
||||||
$aUser['email'] = $oObject->r_email;
|
$aUser['email'] = $oObject->r_email;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_email)){
|
if(isset($oObject->r_email)){
|
||||||
$aUser['signal'] = $oObject->r_email;
|
$aUser['signalmessenger'] = $oObject->r_signalmessenger;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_email)){
|
if(isset($oObject->r_email)){
|
||||||
$aUser['sms'] = $oObject->r_email;
|
$aUser['sms'] = $oObject->r_sms;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_email)){
|
if(isset($oObject->r_email)){
|
||||||
$aUser['telegram'] = $oObject->r_email;
|
$aUser['telegram'] = $oObject->r_telegram;
|
||||||
}
|
}
|
||||||
if(isset($oObject->r_email)){
|
if(isset($oObject->r_email)){
|
||||||
$aUser['threema'] = $oObject->r_email;
|
$aUser['threema'] = $oObject->r_threema;
|
||||||
}
|
}
|
||||||
$oObject->save_user($aUser);
|
$oObject->save_user($aUser);
|
||||||
$oObject->output += "Erfolgreich gespeichert";
|
$oObject->output .= "Erfolgreich gespeichert";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$oObject->get_view("views/user_form.php");
|
$oObject->output = $oObject->get_view("views/user_form.php");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
function output($oObject){
|
function output($oObject){
|
||||||
echo $oObject->get_view("views/head.php");
|
echo $oObject->get_view("views/head.php");
|
||||||
@ -184,8 +273,5 @@ function output($oObject){
|
|||||||
}
|
}
|
||||||
output($oObject);
|
output($oObject);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -3,15 +3,15 @@ $form = '<form action="'.htmlspecialchars($_SERVER["PHP_SELF"]).'" method="post"
|
|||||||
$form .='
|
$form .='
|
||||||
<input type = hidden name="ac" value = "user_save">
|
<input type = hidden name="ac" value = "user_save">
|
||||||
<input type = hidden name="user_ID" value = "">';
|
<input type = hidden name="user_ID" value = "">';
|
||||||
$form .= 'Name: <input type="text" name="name" value=""><br>'.
|
$form .= 'Name: <input type="text" name="name" value=""><br>';
|
||||||
$form .= 'E-Mail: <input type="text" name="email" value=""><br>'.
|
$form .= 'E-Mail: <input type="text" name="email" value=""><br>';
|
||||||
$form .= 'Signal: <input type="text" name="signal" value=""><br>'.
|
$form .= 'Signal: <input type="text" name="signalmessenger" value=""><br>';
|
||||||
$form .= 'SMS: <input type="text" name="sms" value=""><br>'.
|
$form .= 'SMS: <input type="text" name="sms" value=""><br>';
|
||||||
$form .= 'Telegram: <input type="text" name="telegram" value=""><br>'.
|
$form .= 'Telegram: <input type="text" name="telegram" value=""><br>';
|
||||||
$form .= 'Threema: <input type="text" name="threema" value=""><br>'.
|
$form .= 'Threema: <input type="text" name="threema" value=""><br>';
|
||||||
$form .= '
|
$form .= '
|
||||||
<input type="submit" value="'.$this->oLang->texts['BUTTON_SEND'].'">
|
<input type="submit" value="Send">
|
||||||
<input type="reset" value="'.$this->oLang->texts['BUTTON_RESET'].'";
|
<input type="reset" value="Reset";
|
||||||
</form>';
|
</form>';
|
||||||
echo $form;
|
echo $form;
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user