Storm patrik Fixes

This commit is contained in:
JonatanRek
2020-04-28 11:43:07 +02:00
parent 57501e2847
commit 2560800efb
10 changed files with 4 additions and 21 deletions

View File

@@ -1,17 +0,0 @@
<?php
if (isset($_POST) && !empty($_POST)){
if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
$oldPassword = $_POST['oldPassword'];
$newPassword = $_POST['newPassword1'];
$newPassword2 = $_POST['newPassword2'];
UserManager::changePassword($oldPassword, $newPassword, $newPassword2);
header('Location: ' . BASEDIR . 'logout');
die();
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
$userName = $_POST['userName'];
$password = $_POST['userPassword'];
UserManager::createUser($userName, $password);
header('Location: ' . BASEDIR . 'setting');
die();
}
}

View File

@@ -1,98 +0,0 @@
<?php
class Db{
private static $join;
private static $commandDatabase = array (
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::ATTR_EMULATE_PREPARES => false
);
public static function connect ($host, $user, $password, $database) {
if (!isset (self::$join)) {
self::$join = @new PDO(
"mysql:host=$host;dbname=$database;charset=utf8",
$user,
$password,
self::$commandDatabase
);
self::$join->exec ("set names utf8");
}
}
public static function disconect(){
self::$join = null;
}
public static function loadOne ($sql, $values = array (), $numberKey = false) {
$answer = self::$join->prepare ($sql);
$answer->execute ($values);
if (!$numberKey) {
return $answer->fetch (PDO::FETCH_ASSOC);
} else {
return $answer->fetch (PDO::FETCH_NUM);
}
}
public static function command ($sql, $values = array()) {
$answer = self::$join->prepare ($sql);
return $answer->execute ($values);
}
public static function loadAll ($sql, $values = array(), $numberKey = false) {
$answer = self::$join->prepare ($sql);
$answer->execute ($values);
if (!$numberKey) {
return $answer->fetchALL (PDO::FETCH_ASSOC);
} else {
return $answer->fetchALL (PDO::FETCH_NUM);
}
}
public static function loadAlone ($sql, $values = array()) {
$answer = self::$join->prepare ($sql);
$answer->execute ($values);
return $answer->fetch (PDO::FETCH_NUM)[0];
}
public static function add ($table, $values = array()) {
return self::command (
"INSERT INTO `$table` (`" .
implode('`, `', array_keys($values)) .
"`) VALUES (" .
str_repeat('?,', (count($values) > 0 ? count($values)-1 : 0)) .
"?)"
, array_values ($values)
);
}
// TODO: pokud vlozim prazdne pole tak chyba ??
public static function addAll ($table, $values = array ()) {
try {
foreach ($values as $value) {
self::add ($table, $value);
}
} catch (PDOException $ex) {
throw new PDOException ($ex->getMessage());
}
}
public static function edit ($table, $values = array(), $conditions, $values2 = array()) {
return self::command (
"UPDATE `$table` SET `" .
implode('` =?, `', array_keys($values)) .
"` =? " .
$conditions
, array_merge (array_values ($values), $values2)
);
}
public static function insertId () {
return self::$join->lastInsertId ();
}
public static function addId ($lastTable, $lastIdName) {
$answer = self::$join->prepare ("SELECT `$lastIdName` FROM `$lastTable` ORDER BY `$lastIdName` DESC");
$answer->execute ();
return $answer->fetch (PDO::FETCH_NUM)[0];
}
}

View File

@@ -7,7 +7,7 @@ class Partial{
function __construct($path = "", $debug = false) {
$this->debug = $debug;
if (!empty('../app/templates/part/' . $path . '.phtml') && file_exists('../app/templates/part/' . $path . '.phtml')) {
if (!empty('../app/views/templates/part/' . $path . '.phtml') && file_exists('../app/views/templates/part/' . $path . '.phtml')) {
$this->path = $path;
} else {
echo '<pre>';
@@ -29,6 +29,6 @@ class Partial{
extract($this->assignedValues);
}
require('../app/templates/part/' . $this->path . '.phtml');
require('../app/views/templates/part/' . $this->path . '.phtml');
}
}