-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.php
72 lines (69 loc) · 2.53 KB
/
params.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
<?php
error_reporting(E_ERROR);
include('include_haut.php');
if(isset($_POST['envoi']) && $_POST['envoi'] == 1)
{
if ($_FILES['photo']['error'] == 4) //On supprime la photo
mysql_query('UPDATE utilisateurs SET photo = NULL WHERE id = '.$_SESSION['id']);
elseif ($_FILES['photo']['error'] > 0)
echo 'Erreur lors de l\'envoi de la photo.';
elseif($_FILES['photo']['type'] != 'image/jpeg')
echo 'Erreur de format du fichier';
else
{
$nom = md5(uniqid(rand(), true));
move_uploaded_file($_FILES['photo']['tmp_name'],'images/photos/'.$nom.'.jpg');
mysql_query('UPDATE utilisateurs SET photo = "'.$nom.'" WHERE id = '.$_SESSION['id']);
}
} elseif(isset($_POST['envoi']) && $_POST['envoi'] == 2) //On syncro l'uid
{
$uid = intval($_POST['uid']);
$xml = new DOMDocument();
$xml->loadHTMLFile('http://forum.nolife-tv.com/member.php?u='.$uid);
$pseudo = $xml->getElementById('username_box')->getElementsByTagName('h1');
$pseudo = $pseudo->item(0)->nodeValue;
$pseudo = trim($pseudo);
if($pseudo == $_SESSION['pseudo']) //C'est gagné \o/
{
mysql_query('UPDATE utilisateurs SET uid = '.$uid.' WHERE id = '.$_SESSION['id']);
$_SESSION['uid'] = $uid;
header('location: resyncro.php');
exit();
} else
echo "Erreur de UID";
}
include("page_haut.php");
?>
<h1>Paramètres</h1>
<?php
$requete = mysql_query('SELECT * FROM utilisateurs WHERE id = '.$_SESSION['id']);
$donnees = mysql_fetch_array($requete);
echo $donnees['pseudo'].'<br />';
if($donnees['avatar'] != 0 && $donnees['uid'] != 0)
echo '<img src="http://forum.nolife-tv.com/customavatars/avatar'.$donnees['uid'].'_'.$donnees['avatar'].'.gif" alt="Avatar" /><br />';
if($_SESSION['uid'] == 0) //Pas de UID entré
{ ?>
<form method="post" action="params.php" enctype="multipart/form-data">
<p><label name="uid">UID : <br />
<input name="uid" /></label><br />
<input type="hidden" name="envoi" value="2" />
<input type="submit" name="Valider" />
</p></form>
<?php }
if($donnees['photo'] != NULL)
{
echo 'Photo :<br /><img src="images/photos/'.$donnees['photo'].'.jpg" alt="Photo" /><br />';
}
?>
<form method="post" action="params.php" enctype="multipart/form-data">
<p><label name="photo">Envoyer une nouvelle photo (jpeg uniquement) :<br />
<input type="file" name="photo" /></label><br />
<input type="hidden" name="envoi" value="1" />
<input type="submit" name="Valider" />
</p></form>
<div class="check_liste_complete_lien">
<?php if($_SESSION['uid'] != 0) { ?>
<a href="resyncro.php">Resyncroniser l'avatar</a>
<?php } ?>
</div>
<?php include("page_bas.php"); ?>