forked from jribbers/cvcreate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
103 lines (82 loc) · 3.11 KB
/
profile.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
include 'inc/package.php';
include 'inc/connection.php';
define('PAGE_TITLE', 'Profiel');
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$additionalCSS = ['profile', 'bootstrap-switch'];
$additionalJS = ['bootstrap-switch.js'];
$content = '';
if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {
if(isset($_GET['user'])){
$getItems = $connection->prepare('SELECT `image`, `public`, `personal_firstName`, `personal_gender`, `personal_birthDay`, `education_education`, `work_function`, `language_language`, `language_skill` FROM `concept` WHERE `user` = :user');
$getItems->bindValue(':user', $_GET['user'], PDO::PARAM_INT);
$getItems->execute();
$arr = $getItems->fetch(PDO::FETCH_ASSOC);
if($arr['public'] === "true") {
$firstname = $arr['personal_firstName'];
$gender = $arr['personal_gender'];
$profileImage = $arr['image'];
$age = $arr['personal_birthDay'];
if(preg_match('/^a:\d+:{.*?}$/', $arr['education_education'])) {
$education = unserialize($arr['education_education']);
} else {
$education = $arr['education_education'];
}
if(preg_match('/^a:\d+:{.*?}$/', $arr['work_function'])) {
$function = unserialize($arr['work_function']);
} else {
$work = $arr['work_function'];
}
if(preg_match('/^a:\d+:{.*?}$/', $arr['language_language'])) {
$language = unserialize($arr['language_language']);
} else {
$language = $arr['language_language'];
}
if(preg_match('/^a:\d+:{.*?}$/', $arr['language_skill'])) {
$skill = unserialize($arr['language_skill']);
} else {
$skill = $arr['language_skill'];
}
$message = false;
} else {
$message = true;
}
$view = 'views/profile.php';
} else {
include 'inc/classes/profileImage.php';
$getItems = $connection->prepare('SELECT * FROM `concept` WHERE `user` = :user');
$getItems->bindValue(':user', $_SESSION['id'], PDO::PARAM_STR);
$getItems->execute();
$arr = $getItems->fetch(PDO::FETCH_ASSOC);
$public = $arr['public'];
$profileImage = $arr['image'];
$arr = array_slice($arr, 4);
function saveSetting($type, $value) {
include 'inc/connection.php';
$setSetting = $connection->prepare('UPDATE `concept` SET `public` = :value WHERE user = :id');
// $setSetting->bindValue(':type', $type, PDO::PARAM_STR);
$setSetting->bindValue(':value', $value, PDO::PARAM_STR);
$id = $_SESSION['id'];
$setSetting->bindValue(':id', $id, PDO::PARAM_STR);
try {
$setSetting->execute();
} catch (PDOexception $e) {
}
header("Location: profile.php");
}
if(isset($_POST['submit'])) {
if(isset($_POST['public'])){
saveSetting('public', 'true');
} else {
saveSetting('public', 'false');
}
}
$view = 'views/profileSelf.php';
}
} else {
header('Location: login.php');
}
include $template;
?>