-
Notifications
You must be signed in to change notification settings - Fork 0
/
change.php~
62 lines (61 loc) · 1.89 KB
/
change.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
session_start();
include('set_lang.php');
include('translate.php');
include("connect_db.php");
$id = (int)$_GET['id'];
if ($id < 1) {
$id = 1;
}
$STH = $DBH->query('SELECT * from post WHERE id='.$id);
$STH->setFetchMode(PDO::FETCH_ASSOC);
$row = $STH->fetch();
if (($_SESSION['ent'] == 2 && $row['author'] == $_SESSION['login']) || in_array('admin',$_SESSION['roles'])){
if (isset($_POST['exit'])){
$_SESSION['ent'] = 3;
}
if (isset($_POST['change'])){
$text = $_POST['text'];
$short_text = substr($text,0,150);
$title = $_POST['title'];
$STH = $DBH->prepare("UPDATE post SET text= :text WHERE id=$id");
$STH->bindParam(':text', $text, PDO::PARAM_STR);
$STH->execute();
$STH = $DBH->prepare("UPDATE post SET title= :title WHERE id=$id");
$STH->bindParam(':title', $title, PDO::PARAM_STR);
$STH->execute();
$STH = $DBH->prepare("UPDATE post SET short_text= :short_text WHERE id=$id");
$STH->bindParam(':short_text', $short_text, PDO::PARAM_STR);
$STH->execute();
$s = "news.php?id=".$id;
Header("Location: ".$s);
}
$STH = $DBH->query('SELECT * from post WHERE id='.$id);
$STH->setFetchMode(PDO::FETCH_ASSOC);
while($row = $STH->fetch()){
include('header.html');
include('leftside.html');
echo '<div class="center">';
if ($_SESSION['ent'] == 2 && $_SESSION['login'] == $row['author']){
echo'
<FORM ACTION="" METHOD="POST">
<input type="text" name="title" value='.$row['title'].'>
<p>
<textarea name="text">'.$row['text'].'</textarea>
<p>
<input type="text" name="title_ukr" value='.$row['title_ukr'].'>
<p>
<textarea name="text_ukr">'.$row['text_ukr'].'</textarea>
<p>
<input type="submit" name="change" value='.t($lang,'change').'>';
}else{
echo 'you cant change this news';
}
echo'</div>';
}
echo ' </div>';
include('rightside.php');
}else{
echo"you cant change this news<a href='index.php'>Home</a>";
}
?>