/
profile.php
66 lines (50 loc) · 1.32 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
<?php
require_once('fonctions.php');
if(isset($_POST["editName"]))
{
$th = new TouitosHandler($bd);
$connectedUser=$th->getByAttr("pseudo",$_SESSION['user'],PDO::PARAM_STR);
$connectedUser->_setNom($_POST['editName']);
$connectedUser->_setStatut($_POST['editStatut']);
if(!empty($_FILES['profile_pic_upload']['tmp_name']) )
{
$img = $_FILES['profile_pic_upload']['type'];
$type = explode("/", $img);
$extension = $type[1];
$FileDir = 'files/pictures/'.$_SESSION['id'].'.'.$extension;
$check = getimagesize($_FILES['profile_pic_upload']['tmp_name']);
if($check !== false)
{
foreach(glob("files/pictures/".$_SESSION['id'].".*") as $file)
{
unlink($file);
}
if (move_uploaded_file($_FILES['profile_pic_upload']['tmp_name'], $FileDir))
{
$connectedUser->_setPhoto(true);
}
}
}
setcookie("color", $_POST['editColor'], time()+100000);
setcookie("police", $_POST['editPolice'], time()+100000);
updateTouitos($bd,$connectedUser);
}
include('nav.php');
?>
<div id="pageDisplay">
<?php
if(isset($_GET['user']))
{
$th=new TouitosHandler($bd);
$usr=$th->getByAttr("pseudo",$_GET['user'],PDO::PARAM_STR);
if($usr!=null)
show_profile($usr,$bd);
}
else
{
searchByName("",$bd);
}
?>
</div>
</body>
</html>