|
@@ -0,0 +1,203 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+ gelato CMS - A PHP based tumblelog CMS
|
|
5
|
+ development version
|
|
6
|
+ http:
|
|
7
|
+
|
|
8
|
+ gelato CMS is a free software licensed under the GPL 2.0
|
|
9
|
+ Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
|
|
10
|
+
|
|
11
|
+ =========================== */
|
|
12
|
+?>
|
|
13
|
+<?php
|
|
14
|
+require_once('../config.php');
|
|
15
|
+include("../classes/functions.php");
|
|
16
|
+include("../classes/user.class.php");
|
|
17
|
+include("../classes/comments.class.php");
|
|
18
|
+include("../classes/templates.class.php");
|
|
19
|
+include("../classes/pagination.class.php");
|
|
20
|
+require_once("../classes/configuration.class.php");
|
|
21
|
+
|
|
22
|
+$user = new user();
|
|
23
|
+$comment = new comments();
|
|
24
|
+$conf = new configuration();
|
|
25
|
+$template = new plantillas("admin");
|
|
26
|
+$isAdmin = $user->isAdmin();
|
|
27
|
+$isEdition = isset($_GET["edit"]);
|
|
28
|
+$commentId = ($isEdition) ? $_GET["edit"] : NULL;
|
|
29
|
+
|
|
30
|
+if(isset($_POST["btnAdd"])) {
|
|
31
|
+ unset($_POST["btnAdd"]);
|
|
32
|
+ $_POST["username"] = strip_tags($_POST["username"]);
|
|
33
|
+ $_POST["email"] = strip_tags($_POST["email"]);
|
|
34
|
+ $_POST["web"] = strip_tags($_POST["web"]);
|
|
35
|
+
|
|
36
|
+ if (isset($_POST["id_comment"])) {
|
|
37
|
+ if ($isAdmin) {
|
|
38
|
+ if ($comment->modifyComment($_POST, $_POST["id_comment"])) {
|
|
39
|
+ header("Location: comments.php?modified=true");
|
|
40
|
+ die();
|
|
41
|
+ } else {
|
|
42
|
+ header("Location: comments.php?modified=false");
|
|
43
|
+ die();
|
|
44
|
+ }
|
|
45
|
+ }
|
|
46
|
+ } else {
|
|
47
|
+ $comment->generateCookie($_POST);
|
|
48
|
+ $_POST["spam"] = ($comment->isSpam($_POST)) ? "1" : "0";
|
|
49
|
+ $_POST["ip_user"] = $_SERVER["REMOTE_ADDR"];
|
|
50
|
+
|
|
51
|
+ if ($comment->addComment($_POST)) {
|
|
52
|
+ header("Location: ".$conf->urlGelato."/index.php/post/".$_POST["id_post"]);
|
|
53
|
+ die();
|
|
54
|
+ }
|
|
55
|
+ }
|
|
56
|
+}
|
|
57
|
+
|
|
58
|
+if ($isAdmin) {
|
|
59
|
+
|
|
60
|
+ if (isset($_GET["delete"])) {
|
|
61
|
+ if ($comment->deleteComment($_GET['delete'])) {
|
|
62
|
+ header("Location: comments.php?deleted=true");
|
|
63
|
+ die();
|
|
64
|
+ } else {
|
|
65
|
+ header("Location: comments.php?deleted=false");
|
|
66
|
+ die();
|
|
67
|
+ }
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+?>
|
|
71
|
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
72
|
+ <html xmlns="http://www.w3.org/1999/xhtml">
|
|
73
|
+ <head>
|
|
74
|
+ <title>gelato :: <?php echo __("comments")?></title>
|
|
75
|
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
76
|
+ <meta name="generator" content="gelato cms <?php echo version();?>" />
|
|
77
|
+ <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
|
|
78
|
+ <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/mootools.js"></script>
|
|
79
|
+ <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
|
|
80
|
+ <script language="javascript" type="text/javascript">
|
|
81
|
+ <!--
|
|
82
|
+ window.onload = function() {
|
|
83
|
+ contenedor = new Fx.Style('divMessages', 'opacity', {duration: 5000, onComplete:
|
|
84
|
+ function() {
|
|
85
|
+ document.getElementById('divMessages').style.display="none";
|
|
86
|
+ }
|
|
87
|
+ });
|
|
88
|
+ contenedor.custom(1,0);
|
|
89
|
+ }
|
|
90
|
+ -->
|
|
91
|
+ </script>
|
|
92
|
+ <style type="text/css" media="screen">
|
|
93
|
+ @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
|
|
94
|
+ </style>
|
|
95
|
+ </head>
|
|
96
|
+
|
|
97
|
+ <body>
|
|
98
|
+ <div id="div-process" style="display:none;"><?=__("Processing request...");?></div>
|
|
99
|
+ <div id="cont">
|
|
100
|
+ <div id="head">
|
|
101
|
+ <h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: <?=__("home")?>">gelato cms</a></h1>
|
|
102
|
+ <ul id="nav">
|
|
103
|
+ <li><a href="<?php echo $conf->urlGelato;?>/" title="<?=__("Take me to the tumblelog")?>"><?=__("Back to the Tumblelog")?></a></li>
|
|
104
|
+ </ul>
|
|
105
|
+ </div>
|
|
106
|
+ <div id="main">
|
|
107
|
+
|
|
108
|
+ <div class="box">
|
|
109
|
+ <ul class="menu manage">
|
|
110
|
+ <h3><?=__("Manage comments")?></h3>
|
|
111
|
+ <li><a href="index.php"><?=__("Posts")?></a></li>
|
|
112
|
+ <li <?php if (isset($_GET["spam"])) { ?> class="selected" <?php } ?>><a href="comments.php?spam=true"><?=__("Spam")?></a></li>
|
|
113
|
+ <li <?php if (!isset($_GET["spam"])) { ?> class="selected" <?php } ?> ><a href="comments.php"><?php echo ($isEdition) ? __("Edit") : __("List"); ?></a></li>
|
|
114
|
+ </ul>
|
|
115
|
+ <p> </p>
|
|
116
|
+<?php
|
|
117
|
+ if (isset($_GET["deleted"])) {
|
|
118
|
+ if ($_GET["deleted"]=="true") {
|
|
119
|
+ echo "<div class=\"exito\" id=\"divMessages\">".__("The comment has been eliminated successfully.")."</div>";
|
|
120
|
+ }
|
|
121
|
+ if ($_GET["deleted"]=="false") {
|
|
122
|
+ echo "<div class=\"error\" id=\"divMessages\">".__("The post has NOT been eliminated.")."</div>";
|
|
123
|
+ }
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ if (isset($_GET["modified"])) {
|
|
127
|
+ if ($_GET["modified"]=="true") {
|
|
128
|
+ echo "<div class=\"exito\" id=\"divMessages\">".__("The comment has been modified successfully.")."</div>";
|
|
129
|
+ }
|
|
130
|
+ if ($_GET["modified"]=="false") {
|
|
131
|
+ echo "<div class=\"error\" id=\"divMessages\">".__("The post has NOT been modified.")."</div>";
|
|
132
|
+ }
|
|
133
|
+ }
|
|
134
|
+?>
|
|
135
|
+ <div class="tabla">
|
|
136
|
+<?php
|
|
137
|
+ if ($isEdition) {
|
|
138
|
+
|
|
139
|
+ $row = $comment->getComment($_GET["edit"]);
|
|
140
|
+ $date = strtotime($row["comment_date"]);
|
|
141
|
+
|
|
142
|
+ $input = array("{User}", "{Email}", "{Web}", "{Comment}", "{Id_Post}", "{Date_Added}", "{Id_Comment}", "{Form_Action}");
|
|
143
|
+ $output = array($row["username"], $row["email"], $row["web"], $row["content"], $row["id_post"], $date, $row["id_comment"], $conf->urlGelato."/admin/comments.php");
|
|
144
|
+
|
|
145
|
+ $template->cargarPlantilla($input, $output, "template_comment_post");
|
|
146
|
+ $template->mostrarPlantilla();
|
|
147
|
+
|
|
148
|
+ } else {
|
|
149
|
+
|
|
150
|
+ if (isset($_GET["page"]) && is_numeric($_GET["page"]) ) {
|
|
151
|
+ $page_num = $_GET["page"];
|
|
152
|
+ } else {
|
|
153
|
+ $page_num = NULL;
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ $limit=$conf->postLimit;
|
|
157
|
+
|
|
158
|
+ if(isset($page_num) && is_numeric($page_num) && $page_num>0) {
|
|
159
|
+ $from = (($page_num-1) * $limit);
|
|
160
|
+ } else {
|
|
161
|
+ $from = 0;
|
|
162
|
+ }
|
|
163
|
+
|
|
164
|
+ if (isset($_GET["spam"]) && $_GET["spam"]=="true") { $sp = "1"; } else { $sp = null; }
|
|
165
|
+
|
|
166
|
+ $rs = $comment->getComments(null, $limit, $from, $sp);
|
|
167
|
+
|
|
168
|
+ if ($comment->contarRegistros()>0) {
|
|
169
|
+ while($rowComment = mysql_fetch_array($rs)) {
|
|
170
|
+
|
|
171
|
+ $commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"]." | ".$rowComment["email"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a> | ".$rowComment["email"];
|
|
172
|
+
|
|
173
|
+ $input = array("{Permalink}", "{URL_Tumble}", "{Id_Comment}", "{Comment_Author}", "{Comment}");
|
|
174
|
+ $output = array($conf->urlGelato."/index.php/post/".$rowComment["id_post"]."#comment-".$rowComment["id_comment"], $conf->urlGelato, $rowComment["id_comment"], $commentAuthor, $rowComment["content"]);
|
|
175
|
+
|
|
176
|
+ $template->cargarPlantilla($input, $output, "template_comment");
|
|
177
|
+ $template->mostrarPlantilla();
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ $p = new pagination;
|
|
181
|
+ $p->items($comment->countComments());
|
|
182
|
+ $p->limit($limit);
|
|
183
|
+ $p->currentPage(isset($page_num) ? $page_num : 1);
|
|
184
|
+ $p->show();
|
|
185
|
+ }
|
|
186
|
+ }
|
|
187
|
+?>
|
|
188
|
+ </div>
|
|
189
|
+
|
|
190
|
+ <div class="footer-box"> </div>
|
|
191
|
+ </div>
|
|
192
|
+ </div>
|
|
193
|
+ <div id="foot">
|
|
194
|
+ <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
|
|
195
|
+ </div>
|
|
196
|
+ </div>
|
|
197
|
+ </body>
|
|
198
|
+ </html>
|
|
199
|
+<?php
|
|
200
|
+} else {
|
|
201
|
+ header("Location: ".$conf->urlGelato."/login.php");
|
|
202
|
+}
|
|
203
|
+?>
|