Skip to content

Commit

Permalink
+ bug fix - problems with umlauts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mausbiber committed Mar 27, 2016
1 parent 9e6e437 commit 08c0a24
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 79 deletions.
2 changes: 1 addition & 1 deletion html-frontend/includes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function getConnection(){
$this->conn = null;

try{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name . ";charset=utf8", $this->username, $this->password);
}catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
Expand Down
4 changes: 2 additions & 2 deletions html-frontend/includes/scheduler.data.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($db){

function create(){
$stmt = $this->conn->prepare( "SELECT switches.id FROM switches WHERE switches.title = ? " );
$stmt->execute((array($this->switchCommand)));
$stmt->execute(array(htmlentities($this->switchCommand)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->switchesID = $row['id'];

Expand Down Expand Up @@ -383,7 +383,7 @@ function readOne(){

function update(){
$stmt = $this->conn->prepare( "SELECT id FROM switches WHERE title = ? " );
$stmt->execute(array($this->switchCommand));
$stmt->execute(array(htmlentities($this->switchCommand)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->switchesID = $row['id'];

Expand Down
1 change: 0 additions & 1 deletion html-frontend/includes/switch_types.data.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,5 @@ function delete(){
return false;
}
}

}
?>
8 changes: 4 additions & 4 deletions html-frontend/includes/switches.data.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function __construct($db){

function create(){
$stmt = $this->conn->prepare( "SELECT clients.id FROM clients WHERE clients.title = ? " );
$stmt->execute((array($this->clientTitle)));
$stmt->execute(array(htmlentities($this->clientTitle)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->clientsID = $row['id'];

$stmt = $this->conn->prepare( "SELECT switch_types.id FROM switch_types WHERE switch_types.title = ? " );
$stmt->execute((array($this->switchTypTitle)));
$stmt->execute(array(htmlentities($this->switchTypTitle)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->switchTypesID = $row['id'];

Expand Down Expand Up @@ -133,12 +133,12 @@ function readOne(){

function update(){
$stmt = $this->conn->prepare( "SELECT clients.id FROM clients WHERE clients.title = ? " );
$stmt->execute((array($this->clientTitle)));
$stmt->execute(array(htmlentities($this->clientTitle)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->clientsID = $row['id'];

$stmt = $this->conn->prepare( "SELECT switch_types.id FROM switch_types WHERE switch_types.title = ? " );
$stmt->execute((array($this->switchTypTitle)));
$stmt->execute(array(htmlentities($this->switchTypTitle)));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$this->switchTypesID = $row['id'];

Expand Down
60 changes: 29 additions & 31 deletions html-frontend/scheduler/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@
$scheduler->duration = 'einmalig';
}

if($_POST){
$scheduler->title = htmlentities(strip_tags($_POST['title']));
$scheduler->switchCommand = $_POST['switch_command'];
$scheduler->strDateStart = $_POST['str_date_start'];
$scheduler->strTimeStart = $_POST['str_time_start'];
$scheduler->strTimeStop = $_POST['str_time_stop'];
$scheduler->strDateStop = $_POST['str_date_stop'];
$scheduler->duration = $_POST['duration'];
$scheduler->intervalNumber = $_POST['interval_number'];
$scheduler->intervalUnit = $_POST['interval_unit'];
$scheduler->weeklyMonday = $_POST['weekly_monday'];
$scheduler->weeklyTuesday = $_POST['weekly_tuesday'];
$scheduler->weeklyWednesday = $_POST['weekly_wednesday'];
$scheduler->weeklyThursday = $_POST['weekly_thursday'];
$scheduler->weeklyFriday = $_POST['weekly_friday'];
$scheduler->weeklySaturday = $_POST['weekly_saturday'];
$scheduler->weeklySunday = $_POST['weekly_sunday'];

if ($id<0) {
$tmp = $scheduler->create();
if($tmp>0) header("location: update_status.php?usage=timerswitch_new&id=".$tmp);
exit;
} else {
$tmp = $scheduler->update();
if($tmp) header("location: update_status.php?usage=timerswitch_update&id=".$scheduler->id);
exit;
}
}

?>
<!DOCTYPE html>
<html lang="de">
Expand All @@ -44,37 +73,6 @@
<![endif]-->


<?php
if($_POST){

$scheduler->title = htmlentities(strip_tags($_POST['title']));
$scheduler->switchCommand = $_POST['switch_command'];
$scheduler->strDateStart = $_POST['str_date_start'];
$scheduler->strTimeStart = $_POST['str_time_start'];
$scheduler->strTimeStop = $_POST['str_time_stop'];
$scheduler->strDateStop = $_POST['str_date_stop'];
$scheduler->duration = $_POST['duration'];
$scheduler->intervalNumber = $_POST['interval_number'];
$scheduler->intervalUnit = $_POST['interval_unit'];
$scheduler->weeklyMonday = $_POST['weekly_monday'];
$scheduler->weeklyTuesday = $_POST['weekly_tuesday'];
$scheduler->weeklyWednesday = $_POST['weekly_wednesday'];
$scheduler->weeklyThursday = $_POST['weekly_thursday'];
$scheduler->weeklyFriday = $_POST['weekly_friday'];
$scheduler->weeklySaturday = $_POST['weekly_saturday'];
$scheduler->weeklySunday = $_POST['weekly_sunday'];

if ($id<0) {
$tmp = $scheduler->create();
if($tmp>0) header("location: update_status.php?usage=timerswitch_new&id=".$tmp);
exit;
} else {
$tmp = $scheduler->update();
if($tmp) header("location: update_status.php?usage=timerswitch_update&id=".$scheduler->id);
exit;
}
}
?>
</head>

<body>
Expand Down
34 changes: 16 additions & 18 deletions html-frontend/settings/client_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@
$db = $database->getConnection();
$clients = new DataClients($db);

if (isset($_GET['id'])) {
if (isset($_GET['id'])) {
$clients->id = $_GET['id'];
$clients->readOne();
} else {
$id = -1;
}

if($_POST){
$clients->title = htmlentities(strip_tags($_POST['title']));
$clients->ip = $_POST['ip'];
$clients->description = htmlentities(strip_tags($_POST['description']));

if ($id<0) {
$tmp = $clients->create();
if($tmp>0) header("Location: index.php");
} else {
$tmp = $clients->update();
if($tmp) header("Location: index.php");
}
}


?>
<!DOCTYPE html>
<html lang="de">
Expand Down Expand Up @@ -74,23 +89,6 @@
</div>
</div>
<hr>
<?php
if($_POST){

$clients->title = htmlentities(strip_tags($_POST['title']));
$clients->ip = $_POST['ip'];
$clients->description = htmlentities(strip_tags($_POST['description']));

if ($id<0) {
$tmp = $clients->create();
if($tmp>0) header("Location: index.php");
} else {
$tmp = $clients->update();
if($tmp) header("Location: index.php");
}

}
?>
<form method="post">

<div class="row">
Expand Down
42 changes: 20 additions & 22 deletions html-frontend/settings/switch_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
$id = -1;
}

if($_POST){
$switches->title = htmlentities(strip_tags($_POST['title']));
$switches->description = htmlentities(strip_tags($_POST['description']));
$switches->clientTitle = $_POST['client_title'];
$switches->switchTypTitle = $_POST['switch_type_title'];
$switches->argA = htmlentities(strip_tags($_POST['arg_a']));
$switches->argB = htmlentities(strip_tags($_POST['arg_b']));
$switches->argC = htmlentities(strip_tags($_POST['arg_c']));
$switches->argD = htmlentities(strip_tags($_POST['arg_d']));

if ($id<0) {
$tmp = $switches->create();
if($tmp) header("Location: switches.php");
} else {
$tmp = $switches->update();
if($tmp) header("Location: switches.php");
}
}


?>
<!DOCTYPE html>
<html lang="de">
Expand Down Expand Up @@ -77,28 +97,6 @@
</div>
</div>
<hr>
<?php
if($_POST){

$switches->title = htmlentities(strip_tags($_POST['title']));
$switches->description = htmlentities(strip_tags($_POST['description']));
$switches->clientTitle = $_POST['client_title'];
$switches->switchTypTitle = $_POST['switch_type_title'];
$switches->argA = htmlentities(strip_tags($_POST['arg_a']));
$switches->argB = htmlentities(strip_tags($_POST['arg_b']));
$switches->argC = htmlentities(strip_tags($_POST['arg_c']));
$switches->argD = htmlentities(strip_tags($_POST['arg_d']));

if ($id<0) {
$tmp = $switches->create();
if($tmp) header("Location: switches.php");
} else {
$tmp = $switches->update();
if($tmp) header("Location: switches.php");
}

}
?>
<form method="post">

<div class="row">
Expand Down
Binary file modified libs/__pycache__/lib_timerswitch.cpython-35.pyc
Binary file not shown.

0 comments on commit 08c0a24

Please sign in to comment.