Browse Source

Comment feature (finished)

pecesama 17 years ago
parent
commit
9b617b7d4f

+ 203 - 0
admin/comments.php View File

@@ -0,0 +1,203 @@
1
+<?php
2
+/* ===========================
3
+
4
+  gelato CMS - A PHP based tumblelog CMS
5
+  development version
6
+  http://www.gelatocms.com/
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>&nbsp;</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">&nbsp;</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
+?>

+ 1 - 0
admin/index.php View File

@@ -321,6 +321,7 @@ if ($user->isAdmin()) {
321 321
 					<li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php"><?php echo __("Settings")?></a></li>
322 322
 					<li><a href="<?php echo $conf->urlGelato;?>/admin/options.php"><?php echo __("Options")?></a></li>
323 323
 					<li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php"><?php echo __("Users")?></a></li>
324
+					<li><a href="<?php echo $conf->urlGelato;?>/admin/comments.php"><?php echo __("Comments")?></a></li>
324 325
 					<li class="selected"><a><?php echo __("Posts")?></a></li>
325 326
 					</ul>
326 327
 

+ 8 - 0
admin/themes/admin/template_comment.htm View File

@@ -0,0 +1,8 @@
1
+			<div class="entry">
2
+				<div class="info"><span class="compact"><a href="{Permalink}">Link</a>&nbsp;<a href="{URL_Tumble}/admin/comments.php?edit={Id_Comment}"><img src="{URL_Tumble}/admin/css/images/edit.png" alt="" title="" /></a>&nbsp;<a href="{URL_Tumble}/admin/comments.php?delete={Id_Comment}"><img src="{URL_Tumble}/admin/css/images/delete.png" alt="" title="" /></a></span>
3
+					<p>{Comment_Author}</p>
4
+				</div>
5
+				<div class="post">
6
+					<p>{Comment}</p>
7
+				</div>
8
+			</div>

+ 28 - 0
admin/themes/admin/template_comment_post.htm View File

@@ -0,0 +1,28 @@
1
+		<form action="{Form_Action}" method="post" name="commentForm" id="commentForm" class="newpost">
2
+			<fieldset>
3
+			<p>
4
+				<label for="username">Name</label>
5
+				<input class="txt" name="username" id="username" value="{User}" size="22" tabindex="1" type="text" />				
6
+			</p>
7
+			<p>
8
+				<label for="email">E-mail</label>
9
+				<input class="txt" name="email" id="email" value="{Email}" size="22" tabindex="2" type="text" />				
10
+			</p>
11
+			<p>
12
+				<label for="web">Website</label>
13
+				<input class="txt" name="web" id="web" value="{Web}" size="22" tabindex="3" type="text" />				
14
+			</p>			
15
+			<p>
16
+				<label for="description">Body</label><br />
17
+				<textarea name="content" id="content" cols="50" rows="10" tabindex="4">{Comment}</textarea>
18
+			</p>
19
+			<p>
20
+				<input type="submit" value="Modify comment" name="btnAdd" id="btnAdd" tabindex="5" />
21
+			</p>
22
+			<p>
23
+				<input name="id_post" id="id_post" value="{Id_Post}" type="hidden" />
24
+				<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
25
+				<input name="id_comment" id="id_comment" value="{Id_Comment}" type="hidden" />
26
+			</p>
27
+			</fieldset>
28
+		</form>

+ 125 - 0
api.php View File

@@ -0,0 +1,125 @@
1
+<?php
2
+/* ===========================
3
+
4
+  gelato CMS - A PHP based tumblelog CMS
5
+  development version
6
+  http://www.gelatocms.com/
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
+	header("Content-type: text/xml; charset=utf-8");	
15
+	
16
+	require(dirname(__FILE__)."/config.php");
17
+	include("classes/configuration.class.php");
18
+	include("classes/gelato.class.php");
19
+	include("classes/textile.class.php");
20
+	$isFeed = true;
21
+	$tumble = new gelato();
22
+	$conf = new configuration();
23
+	
24
+	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
25
+?>
26
+	<gelato version="1.0">
27
+<?php
28
+	
29
+	if (isset($_GET["action"]) && $_GET["action"] == "read") {
30
+		if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
31
+		if (isset($_GET["num"])) { $num = $_GET["num"]; } else { $num = 20; }
32
+		if (isset($_GET["type"])) { $type = $_GET["type"]; } else { $type = null; }
33
+		if ($num > 50) { $num = 50; }		
34
+?>		
35
+		<tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php echo $conf->description;?></tumblelog>	
36
+
37
+<?php
38
+		switch ($type) {
39
+			case "post":
40
+				$_GET["type"] = "1";
41
+				break;
42
+			case "photo":
43
+				$_GET["type"] = "2";							   
44
+				break;
45
+			case "quote":
46
+				$_GET["type"] = "3";
47
+				break;
48
+			case "url":
49
+				$_GET["type"] = "4";
50
+				break;
51
+			case "conversation":
52
+				$_GET["type"] = "5";
53
+				break;
54
+			case "video":
55
+				$_GET["type"] = "6";
56
+				break;
57
+			case "mp3":
58
+				$_GET["type"] = "7";
59
+				break;								
60
+		}
61
+		$rs = $tumble->getPosts($num, $start);
62
+		if ($tumble->contarRegistros()>0) {
63
+?>
64
+			<posts start="<?php echo $start; ?>" total="<?php echo $num; ?>">
65
+<?php/*
66
+			while($register = mysql_fetch_array($rs)) {
67
+				
68
+				$textile = new Textile();				
69
+				$register["description"] = $textile->TextileThis($register["description"]);
70
+				
71
+				switch ($register["type"]) {
72
+					case "1":
73
+						$tit = ($register["title"]=="") ? strip_tags($register["description"]) : $register["title"];
74
+						$desc = $register["description"];
75
+						break;
76
+					case "2":
77
+						$tit = ($register["description"]=="") ? "Photo" : strip_tags($register["description"]);
78
+						$desc = "<img src=\"".$register["url"]."\"/>";
79
+						break;
80
+					case "3":
81
+						$tit = "\"".strip_tags($register["description"])."\"";
82
+						$tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".$register["title"]."</em>" : "";
83
+						$desc = "\"".$register["description"]."\"".$tmpStr;
84
+						break;
85
+					case "4":
86
+						$tit = ($register["title"]=="") ? $register["url"] : $register["title"];
87
+						$tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".$register["description"]."</em>" : "";
88
+						$desc = "<a href=\"".$register["url"]."\">".$tit."</a>".$tmpStr;
89
+						break;
90
+					case "5":
91
+						$lines = explode("\n", $register["description"]);
92
+						$line = $lines[0];
93
+						$tit = ($register["title"]=="") ? $line : $register["title"];
94
+						$desc = $tumble->formatConversation($register["description"]);
95
+						break;
96
+					case "6":
97
+						$tit = ($register["description"]=="") ? "Video" : strip_tags($register["description"]);
98
+						$desc = $tumble->getVideoPlayer($register["url"]);
99
+						break;
100
+					case "7":
101
+						$tit = ($register["description"]=="") ? "MP3" : strip_tags($register["description"]);
102
+						$desc = $tumble->getMp3Player($register["url"]);
103
+						break;
104
+				}
105
+				$url = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
106
+				$formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"]));
107
+?>
108
+
109
+				<item>
110
+					<title><?php echo $tit;?></title>
111
+					<description><![CDATA[<?php echo $desc;?>]]></description>
112
+					<link><?php echo $url;?></link>
113
+					<guid isPermaLink="true"><?php echo $conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>				
114
+					<pubDate><?php echo $formatedDate;?></pubDate>				
115
+				</item>
116
+
117
+<?php	
118
+			}		
119
+*/?>
120
+				</posts>
121
+<?php	
122
+		}
123
+	}
124
+?>
125
+		</gelato>

+ 35 - 23
classes/comments.class.php View File

@@ -23,7 +23,7 @@ class comments extends Conexion_Mysql {
23 23
 	}
24 24
 	
25 25
 	function addComment($fieldsArray) {		
26
-		if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
26
+		if ($this->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) {
27 27
 			return true;
28 28
 		} else {
29 29
 			return false;
@@ -55,35 +55,47 @@ class comments extends Conexion_Mysql {
55 55
 		return false;	
56 56
 	}
57 57
 	
58
-	function confirmacionEmail($email_autor_post, $tit_blog, $desc_blog, $url_blog, $id_post, $titulo_post, $usuario, $email, $pagina_web, $comentario, $ip_usuario) {
59
-		$msg =  "<br/><br/><font face=verdana><em><font size=2>Hay un nuevo comentario en el post #".$id_post." \"".$titulo_post."\"</font></em><br/><br/>";
60
-		$msg .=	"Autor : ".$usuario." (IP: ".$ip_usuario.")<br /><br />";
61
-		$msg .=	"E-mail : <a href=\"mailto:".$email."\">".$email."</a><br /><br />";
62
-		$msg .=	"URL &nbsp; &nbsp;: <a href=\"".$pagina_web."\" target=\"_blank\">".$pagina_web."</a><br /><br />";
63
-		$msg .=	"Whois &nbsp;: <a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=".$ip_usuario."\" target=\"_blank\">http://ws.arin.net/cgi-bin/whois.pl?queryinput=".$ip_usuario."</a><br /><br />";
64
-		$msg .=	"Comentario:<br /><br />".$comentario;
65
-		$msg .=	"<br /><br /><a href=\"".$url_blog."/index.php?id=".$id_post."\">".$url_blog."/index.php?id=".$id_post."</a><br /><br />";
66
-		
67
-		enviaMail($email_autor_post, "[".$desc_blog."] Nuevo mensaje en: ".$titulo_post."", $msg, EMAIL_ADMIN);
68
-	}	
69
-	
70
-	function obtenerComentarios($idArticulo="") {
71
-		$this->ejecutarConsulta("select * from ".tabla_prefijo."comentarios WHERE id_post=".$idArticulo." AND spam=0 order by fecha ASC");
58
+	function getComments($idPost=null, $limit=null, $from=null, $spam=null) {
59
+		if (isset($idPost)) {
60
+			$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0 order by comment_date ASC");
61
+		} else {			
62
+			if (isset($limit) && isset($from)) {
63
+				$limit = " LIMIT $from, $limit";
64
+			} else { ""; }
65
+			if (isset($spam)) { $sp = "1"; } else { $sp = "0"; } 
66
+			$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=".$sp." order by comment_date ASC".$limit);
67
+		}
72 68
 		return $this->mid_consulta;
73 69
 	}
74 70
 	
75
-	function contarComentarios($idArticulo="") {
76
-		$this->ejecutarConsulta("select * from ".tabla_prefijo."comentarios WHERE id_post=".$idArticulo." AND spam=0");
71
+	function getComment($id="") {
72
+		$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id);
73
+		return mysql_fetch_array($this->mid_consulta);
74
+	}
75
+	
76
+	function countComments($idPost=null) {
77
+		if (isset($idPost)) {
78
+			$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0");
79
+		} else {
80
+			$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=0");
81
+		}		
77 82
 		return $this->contarRegistros();
78 83
 	}
79 84
 	
80
-	function mostrarGravatar($email="") {
81
-		$emailg = $email;
82
-		$default = URL_CODICE."/images/noGravatar.jpg";
83
-		$size = 30;
84
-		$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($emailg)."&amp;default=".urlencode($default)."&amp;size=".$size;
85
-		return "<img src=\"".$grav_url."\" alt=\"Gravatar\" title=\"Gravatar\" />";
85
+	function deleteComment($idComment) {
86
+		if ($this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."comments WHERE id_comment=".$idComment)) {
87
+			return true;
88
+		} else {
89
+			return false;
90
+		}
86 91
 	}
87 92
 	
93
+	function modifyComment($fieldsArray, $id_comment) {
94
+		if ($this->modificarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray, "id_comment=$id_comment")) {
95
+			return true;
96
+		} else {
97
+			return false;
98
+		}
99
+	}
88 100
 } 
89 101
 ?>

+ 5 - 8
classes/templates.class.php View File

@@ -50,7 +50,7 @@ class plantillas {
50 50
 		}
51 51
 	}	
52 52
 		
53
-	function precargarPlantillaConBloque($entrada, $salida, $plantilla_usar) {		
53
+	function precargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) {		
54 54
 		$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
55 55
 		
56 56
 		if (!file_exists($plantilla_usar)) {
@@ -64,15 +64,14 @@ class plantillas {
64 64
 				$salida_xhtml = stripslashes($salida_xhtml);
65 65
 				$this->texto_plantilla = $salida_xhtml;
66 66
 				
67
-				$this->cargaAntesBloque("comentarios");
68
-				$this->cargaDespuesBloque("comentarios");
67
+				$this->cargaAntesBloque($nombreBloque);
68
+				$this->cargaDespuesBloque($nombreBloque);
69 69
 				
70 70
 				$this->antesBloque = $this->procesaBloque($entrada, $salida, $this->antesBloque);
71 71
 				$this->despuesBloque = $this->procesaBloque($entrada, $salida, $this->despuesBloque);
72 72
 			} 
73 73
 		}
74
-	}
75
-	
74
+	}	
76 75
 	
77 76
 	function cargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) {		
78 77
 		$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
@@ -93,8 +92,7 @@ class plantillas {
93 92
 				$this->bloqueFinal .= $this->procesaBloque($entrada, $salida, $this->bloque);
94 93
 			} 
95 94
 		}
96
-	}
97
-	
95
+	}	
98 96
 	
99 97
 	function procesaBloque($entrada, $salida, $bloque) {
100 98
 		for ($i = 0; $i < count($entrada); $i++) {
@@ -139,5 +137,4 @@ class plantillas {
139 137
 		echo $texto;
140 138
 	}
141 139
 }
142
-
143 140
 ?>

+ 18 - 3
index.php View File

@@ -31,6 +31,7 @@
31 31
         include("classes/templates.class.php");
32 32
         include("classes/pagination.class.php");
33 33
         include("classes/user.class.php");
34
+		include("classes/comments.class.php");
34 35
                 
35 36
         $user = new user();
36 37
         $conf = new configuration();
@@ -47,7 +48,7 @@
47 48
                 } else {
48 49
                         $id_post = NULL;
49 50
                 }
50
-        }
51
+        }		
51 52
         
52 53
         if (isset($_GET["page"])) {
53 54
                 $page_num = $_GET["page"];
@@ -262,10 +263,24 @@
262 263
 				
263 264
 				if ($conf->allowComments) {
264 265
 					
265
-					// before the comments form must be the comments on the DB
266
+					$comment = new comments();
267
+					$rsComments = $comment->getComments($register["id_post"]);
268
+					
269
+					$input = array("{Comments_Number}", "{Post_Title}");				
270
+					$output = array($comment->countComments($register["id_post"]), $register["title"]);
271
+					$template->precargarPlantillaConBloque($input, $output, "template_comments", "comments");
272
+					while($rowComment = mysql_fetch_array($rsComments)) {
273
+						
274
+						$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
275
+						$input = array("{Id_Comment}", "{Comment_Author}", "{Date}", "{Comment}");				
276
+						$output = array($rowComment["id_comment"], $commentAuthor, date("d.m.y", strtotime($rowComment["comment_date"])), $rowComment["content"]);
277
+						$template->cargarPlantillaConBloque($input, $output, "template_comments", "comments");
278
+					}
279
+					$template->mostrarPlantillaConBloque();
280
+					
266 281
 										
267 282
 					$input = array("{User_Cookie}", "{Email_Cookie}", "{Web_Cookie}", "{Id_Post}", "{Form_Action}", "{Date_Added}");
268
-					$output = array($_COOKIE['cookie_gel_user'], $_COOKIE['cookie_gel_email'], $_COOKIE['cookie_gel_web'], $register["id_post"], $conf->urlGelato."/comments.php", gmmktime());
283
+					$output = array($_COOKIE['cookie_gel_user'], $_COOKIE['cookie_gel_email'], $_COOKIE['cookie_gel_web'], $register["id_post"], $conf->urlGelato."/admin/comments.php", gmmktime());
269 284
 					
270 285
 					$template->cargarPlantilla($input, $output, "template_comment_post");
271 286
 					$template->mostrarPlantilla(); 

+ 0 - 2
login.php View File

@@ -20,8 +20,6 @@ require_once(dirname(__FILE__)."/classes/configuration.class.php");
20 20
 $user = new user();
21 21
 $conf = new configuration();
22 22
 
23
-die($user->validateUser($_POST['login'], md5($_POST['pass']))."<");
24
-
25 23
 if ($user->isAdmin()) {
26 24
 	header("Location: ".$conf->urlGelato."/admin/index.php");
27 25
 } else {

+ 2 - 3
themes/tumblr/template_comment_post.htm View File

@@ -1,4 +1,3 @@
1
-	
2 1
 	<div class="containerFormComments">
3 2
 		<h3 id="respond">Add your comment</h3>
4 3
 		
@@ -30,8 +29,8 @@
30 29
 				<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
31 30
 			</p>
32 31
 			<p>
33
-				<input name="idPost" id="idPost" value="{Id_Post}" type="hidden" />
32
+				<input name="id_post" id="id_post" value="{Id_Post}" type="hidden" />
34 33
 				<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
35 34
 			</p>
36 35
 		</form>	
37
-	</div>			
36
+	</div>

+ 8 - 9
themes/tumblr/template_comments.htm View File

@@ -1,18 +1,17 @@
1 1
 	<div class="containerComments">
2
-		<h3 id="comments"><*NumeroDeComentarios*> Respuestas a &#8220;<*TituloPost*>&#8221;</h3>
2
+		<h3 id="comments">{Comments_Number} answers to &#8220;{Post_Title}&#8221;</h3>
3 3
 		<ol class="commentlist">
4
-			[bloque: comentarios]
5
-			<li class="alt" id="comment-<*IdComentario*>">
4
+			[bloque: comments]
5
+			<li class="alt" id="comment-{Id_Comment}">
6 6
 				<cite>
7
-					<a href="#comment-<*IdComentario*>" title="Enlace permanente a este comentario">#</a>&nbsp;&nbsp;
8
-					<*ImagenAvatar*>&nbsp;&nbsp;
9
-					<*AutorComentario*> dijo:
7
+					<a href="#comment-{Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;					
8
+					{Comment_Author} said:
10 9
 				</cite>
11 10
 				<br />
12
-				<span class="timestampComment"> el <*Fecha*></span><br /><br />
13
-				<*TextoComentario*>
11
+				<span class="timestampComment"> at {Date}</span><br /><br />
12
+				{Comment}
14 13
 				<br /><br />
15 14
 			</li>
16
-			[/bloque: comentarios]
15
+			[/bloque: comments]
17 16
 		</ol>
18 17
 	</div>