-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_settings.php
62 lines (57 loc) · 1.96 KB
/
user_settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Created by PhpStorm.
* User: uyve7bo
* Date: 01.04.2016
* Time: 06:42
*/
require_once("config/config.php");
require_once("config/db_cnx.php");
require 'config/setup.php';
require 'config/functions.php';
forceSSL();
header('Content-Type: text/html; charset=utf-8');
session_start();
if($_SESSION["user"]["id"] == "1") {
error_reporting(E_ALL);
ini_set("display_errors", 1);
}
$smarty = new Smarty_mjam();
$smarty->assign('current_site', substr($_SERVER['SCRIPT_NAME'],1));
$smarty->assign('countUnlockedOrders', count(getUnlockedOrders()));
if(isset($_SESSION["user"])) {
$smarty->assign('success', FALSE);
$smarty->assign('error', FALSE);
$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_SPECIAL_CHARS);
if($page == "save") {
$id = $_SESSION["user"]["id"];
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_SPECIAL_CHARS);
if(filter_input(INPUT_POST, 'notify', FILTER_SANITIZE_SPECIAL_CHARS) == NULL) {
$notify = FALSE;
} else {
$notify = TRUE;
}
if(filter_input(INPUT_POST, 'active', FILTER_SANITIZE_SPECIAL_CHARS) == NULL) {
$active = FALSE;
} else {
$active = TRUE;
}
$update_settings = "UPDATE login SET email = ?, notify = ?, active = ? WHERE id = ?";
$stmt = $mysqli->prepare($update_settings);
$stmt->bind_param("ssss", $email, $notify, $active, $id);
if($stmt->execute()) {
$_SESSION["user"]["notify"] = $notify;
$_SESSION["user"]["active"] = $active;
$smarty->assign('success', TRUE);
header("Refresh:2; url=user_settings.php");
} else {
$smarty->assign('error', TRUE);
}
}
$smarty->assign('user', getUserData($_SESSION['user']['id']));
$smarty->display('user_settings.tpl');
} else {
$smarty->display('timeout.tpl');
}
$mysqli->close();
?>