-
Notifications
You must be signed in to change notification settings - Fork 0
/
editer_news.php
executable file
·47 lines (45 loc) · 1.67 KB
/
editer_news.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Yeep (re)post</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="styles.css" type="text/css" charset="utf-8" />
</head>
<body>
<center>
<div id="header">
<a href="http://native.chez.com/yeep/"><img
style="border: 0px solid ; width: 372px; height: 210px;" alt=""
src="http://native.chez.com/yeep/headr.png"></a>
</div>
<div id="content">
<?php
if(!isset($_GET['id'])) {
header('Location: home.php');
exit();
}
$news = unserialize(file_get_contents('news.txt'));
$newsAmodifier = (int) $_GET['id'];
if(isset($_POST['titre']) && isset($_POST['contenu'])) {
$news[$newsAmodifier]['titre'] = $_POST['titre'];
$news[$newsAmodifier]['contenu'] = $_POST['contenu'];
file_put_contents('news.txt', serialize($news));
echo 'La news a bien été editée.';
echo '<br />';
echo '<a href="home.php">Retour</a>';
} else {
?>
<form action="" method="POST">
Auteur : <strong><?php echo $news[$newsAmodifier]['auteur'] ?></strong><br />
<label for="titre">Titre de la news :</label> <input type="text" name="titre" id="titre" value="<?php echo $news[$newsAmodifier]['titre'] ?>" /><br />
<label for="contenu">Contenu de la news : </label><br />
<textarea name="contenu" id="contenu" rows="20" cols="60"><?php echo $news[$newsAmodifier]['contenu'] ?></textarea><br />
<input type="submit" value="Appliquer les modifications" />
</form>
<?php
}
?>
</div>
</center>
</body>
</html>