3 require 'includes/config.inc.php';
4 require INCLUDES_PATH
.'prepend.php';
6 if (isset($_GET['id'])) {
7 $idNews = intval($_GET['id']) ;
9 die('News id needed. Please use the back button.');
13 $tpl = new templates();
15 $tpl->action
= 'edit.php?id='.$idNews;
18 $q = $pdo->query('SELECT * FROM news WHERE id='.$pdo->quote($idNews));
19 $data = $q->fetch(PDO
::FETCH_ASSOC
);
21 die('Nothing in database. Please use the back button.');
24 $tpl->password_fail
= false;
25 $tpl->updated
= false;
26 if (isset($_POST['password']) && PASSWORD
!= sha1($_POST['password'])) {
27 $tpl->password_fail
= true;
28 } elseif (isset($_POST['password']) && PASSWORD
== sha1($_POST['password'])) {
29 $tpl->input_title
= (!empty($_POST['title'])) ?
trim($_POST['title']) : $data['title'];
30 $tpl->input_text
= (!empty($_POST['text'])) ?
trim($_POST['text']) : $data['text'];
31 $uq = $pdo->exec('UPDATE news SET text='. $tpl->input_title
.', title='. $tpl->input_text
.', editon='.$pdo->quote(time()).' WHERE id='.$pdo->quote($idNews));
33 echo "\nError on UPDATE : <br/>";
34 $x = $pdo->errorInfo();
35 echo 'errorCode: ',$x[0],'<br/>errorMessage: ',$x[2];
42 $tpl->addFile('_begin','header.tpl.php');
43 $tpl->addFile('_end','footer.tpl.php');
44 $tpl->addFile('save','save.tpl.php');
46 $tpl->input_title
= $data['title'];
47 $tpl->input_text
= $data['text'];
48 } catch (PDOException
$e) {
49 die("pdo: ".$e->getMessage());
52 define('ON_EDIT', true);
54 $tpl->title
= "AYANS edit news";