Comment feature (finished)
parent
02794931ca
commit
9b617b7d4f
|
|
@ -0,0 +1,203 @@
|
||||||
|
<?php
|
||||||
|
/* ===========================
|
||||||
|
|
||||||
|
gelato CMS - A PHP based tumblelog CMS
|
||||||
|
development version
|
||||||
|
http://www.gelatocms.com/
|
||||||
|
|
||||||
|
gelato CMS is a free software licensed under the GPL 2.0
|
||||||
|
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
|
||||||
|
|
||||||
|
=========================== */
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
require_once('../config.php');
|
||||||
|
include("../classes/functions.php");
|
||||||
|
include("../classes/user.class.php");
|
||||||
|
include("../classes/comments.class.php");
|
||||||
|
include("../classes/templates.class.php");
|
||||||
|
include("../classes/pagination.class.php");
|
||||||
|
require_once("../classes/configuration.class.php");
|
||||||
|
|
||||||
|
$user = new user();
|
||||||
|
$comment = new comments();
|
||||||
|
$conf = new configuration();
|
||||||
|
$template = new plantillas("admin");
|
||||||
|
$isAdmin = $user->isAdmin();
|
||||||
|
$isEdition = isset($_GET["edit"]);
|
||||||
|
$commentId = ($isEdition) ? $_GET["edit"] : NULL;
|
||||||
|
|
||||||
|
if(isset($_POST["btnAdd"])) {
|
||||||
|
unset($_POST["btnAdd"]);
|
||||||
|
$_POST["username"] = strip_tags($_POST["username"]);
|
||||||
|
$_POST["email"] = strip_tags($_POST["email"]);
|
||||||
|
$_POST["web"] = strip_tags($_POST["web"]);
|
||||||
|
|
||||||
|
if (isset($_POST["id_comment"])) {
|
||||||
|
if ($isAdmin) {
|
||||||
|
if ($comment->modifyComment($_POST, $_POST["id_comment"])) {
|
||||||
|
header("Location: comments.php?modified=true");
|
||||||
|
die();
|
||||||
|
} else {
|
||||||
|
header("Location: comments.php?modified=false");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$comment->generateCookie($_POST);
|
||||||
|
$_POST["spam"] = ($comment->isSpam($_POST)) ? "1" : "0";
|
||||||
|
$_POST["ip_user"] = $_SERVER["REMOTE_ADDR"];
|
||||||
|
|
||||||
|
if ($comment->addComment($_POST)) {
|
||||||
|
header("Location: ".$conf->urlGelato."/index.php/post/".$_POST["id_post"]);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isAdmin) {
|
||||||
|
|
||||||
|
if (isset($_GET["delete"])) {
|
||||||
|
if ($comment->deleteComment($_GET['delete'])) {
|
||||||
|
header("Location: comments.php?deleted=true");
|
||||||
|
die();
|
||||||
|
} else {
|
||||||
|
header("Location: comments.php?deleted=false");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>gelato :: <?php echo __("comments")?></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="generator" content="gelato cms <?php echo version();?>" />
|
||||||
|
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
|
||||||
|
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/mootools.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
<!--
|
||||||
|
window.onload = function() {
|
||||||
|
contenedor = new Fx.Style('divMessages', 'opacity', {duration: 5000, onComplete:
|
||||||
|
function() {
|
||||||
|
document.getElementById('divMessages').style.display="none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contenedor.custom(1,0);
|
||||||
|
}
|
||||||
|
-->
|
||||||
|
</script>
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
@import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="div-process" style="display:none;"><?=__("Processing request...");?></div>
|
||||||
|
<div id="cont">
|
||||||
|
<div id="head">
|
||||||
|
<h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: <?=__("home")?>">gelato cms</a></h1>
|
||||||
|
<ul id="nav">
|
||||||
|
<li><a href="<?php echo $conf->urlGelato;?>/" title="<?=__("Take me to the tumblelog")?>"><?=__("Back to the Tumblelog")?></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<div class="box">
|
||||||
|
<ul class="menu manage">
|
||||||
|
<h3><?=__("Manage comments")?></h3>
|
||||||
|
<li><a href="index.php"><?=__("Posts")?></a></li>
|
||||||
|
<li <?php if (isset($_GET["spam"])) { ?> class="selected" <?php } ?>><a href="comments.php?spam=true"><?=__("Spam")?></a></li>
|
||||||
|
<li <?php if (!isset($_GET["spam"])) { ?> class="selected" <?php } ?> ><a href="comments.php"><?php echo ($isEdition) ? __("Edit") : __("List"); ?></a></li>
|
||||||
|
</ul>
|
||||||
|
<p> </p>
|
||||||
|
<?php
|
||||||
|
if (isset($_GET["deleted"])) {
|
||||||
|
if ($_GET["deleted"]=="true") {
|
||||||
|
echo "<div class=\"exito\" id=\"divMessages\">".__("The comment has been eliminated successfully.")."</div>";
|
||||||
|
}
|
||||||
|
if ($_GET["deleted"]=="false") {
|
||||||
|
echo "<div class=\"error\" id=\"divMessages\">".__("The post has NOT been eliminated.")."</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["modified"])) {
|
||||||
|
if ($_GET["modified"]=="true") {
|
||||||
|
echo "<div class=\"exito\" id=\"divMessages\">".__("The comment has been modified successfully.")."</div>";
|
||||||
|
}
|
||||||
|
if ($_GET["modified"]=="false") {
|
||||||
|
echo "<div class=\"error\" id=\"divMessages\">".__("The post has NOT been modified.")."</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="tabla">
|
||||||
|
<?php
|
||||||
|
if ($isEdition) {
|
||||||
|
|
||||||
|
$row = $comment->getComment($_GET["edit"]);
|
||||||
|
$date = strtotime($row["comment_date"]);
|
||||||
|
|
||||||
|
$input = array("{User}", "{Email}", "{Web}", "{Comment}", "{Id_Post}", "{Date_Added}", "{Id_Comment}", "{Form_Action}");
|
||||||
|
$output = array($row["username"], $row["email"], $row["web"], $row["content"], $row["id_post"], $date, $row["id_comment"], $conf->urlGelato."/admin/comments.php");
|
||||||
|
|
||||||
|
$template->cargarPlantilla($input, $output, "template_comment_post");
|
||||||
|
$template->mostrarPlantilla();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (isset($_GET["page"]) && is_numeric($_GET["page"]) ) {
|
||||||
|
$page_num = $_GET["page"];
|
||||||
|
} else {
|
||||||
|
$page_num = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit=$conf->postLimit;
|
||||||
|
|
||||||
|
if(isset($page_num) && is_numeric($page_num) && $page_num>0) {
|
||||||
|
$from = (($page_num-1) * $limit);
|
||||||
|
} else {
|
||||||
|
$from = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["spam"]) && $_GET["spam"]=="true") { $sp = "1"; } else { $sp = null; }
|
||||||
|
|
||||||
|
$rs = $comment->getComments(null, $limit, $from, $sp);
|
||||||
|
|
||||||
|
if ($comment->contarRegistros()>0) {
|
||||||
|
while($rowComment = mysql_fetch_array($rs)) {
|
||||||
|
|
||||||
|
$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"]." | ".$rowComment["email"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a> | ".$rowComment["email"];
|
||||||
|
|
||||||
|
$input = array("{Permalink}", "{URL_Tumble}", "{Id_Comment}", "{Comment_Author}", "{Comment}");
|
||||||
|
$output = array($conf->urlGelato."/index.php/post/".$rowComment["id_post"]."#comment-".$rowComment["id_comment"], $conf->urlGelato, $rowComment["id_comment"], $commentAuthor, $rowComment["content"]);
|
||||||
|
|
||||||
|
$template->cargarPlantilla($input, $output, "template_comment");
|
||||||
|
$template->mostrarPlantilla();
|
||||||
|
}
|
||||||
|
|
||||||
|
$p = new pagination;
|
||||||
|
$p->items($comment->countComments());
|
||||||
|
$p->limit($limit);
|
||||||
|
$p->currentPage(isset($page_num) ? $page_num : 1);
|
||||||
|
$p->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-box"> </div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="foot">
|
||||||
|
<a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
header("Location: ".$conf->urlGelato."/login.php");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
@ -321,6 +321,7 @@ if ($user->isAdmin()) {
|
||||||
<li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php"><?php echo __("Settings")?></a></li>
|
<li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php"><?php echo __("Settings")?></a></li>
|
||||||
<li><a href="<?php echo $conf->urlGelato;?>/admin/options.php"><?php echo __("Options")?></a></li>
|
<li><a href="<?php echo $conf->urlGelato;?>/admin/options.php"><?php echo __("Options")?></a></li>
|
||||||
<li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php"><?php echo __("Users")?></a></li>
|
<li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php"><?php echo __("Users")?></a></li>
|
||||||
|
<li><a href="<?php echo $conf->urlGelato;?>/admin/comments.php"><?php echo __("Comments")?></a></li>
|
||||||
<li class="selected"><a><?php echo __("Posts")?></a></li>
|
<li class="selected"><a><?php echo __("Posts")?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<div class="entry">
|
||||||
|
<div class="info"><span class="compact"><a href="{Permalink}">Link</a> <a href="{URL_Tumble}/admin/comments.php?edit={Id_Comment}"><img src="{URL_Tumble}/admin/css/images/edit.png" alt="" title="" /></a> <a href="{URL_Tumble}/admin/comments.php?delete={Id_Comment}"><img src="{URL_Tumble}/admin/css/images/delete.png" alt="" title="" /></a></span>
|
||||||
|
<p>{Comment_Author}</p>
|
||||||
|
</div>
|
||||||
|
<div class="post">
|
||||||
|
<p>{Comment}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<form action="{Form_Action}" method="post" name="commentForm" id="commentForm" class="newpost">
|
||||||
|
<fieldset>
|
||||||
|
<p>
|
||||||
|
<label for="username">Name</label>
|
||||||
|
<input class="txt" name="username" id="username" value="{User}" size="22" tabindex="1" type="text" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="email">E-mail</label>
|
||||||
|
<input class="txt" name="email" id="email" value="{Email}" size="22" tabindex="2" type="text" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="web">Website</label>
|
||||||
|
<input class="txt" name="web" id="web" value="{Web}" size="22" tabindex="3" type="text" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="description">Body</label><br />
|
||||||
|
<textarea name="content" id="content" cols="50" rows="10" tabindex="4">{Comment}</textarea>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="Modify comment" name="btnAdd" id="btnAdd" tabindex="5" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input name="id_post" id="id_post" value="{Id_Post}" type="hidden" />
|
||||||
|
<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
|
||||||
|
<input name="id_comment" id="id_comment" value="{Id_Comment}" type="hidden" />
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
<?php
|
||||||
|
/* ===========================
|
||||||
|
|
||||||
|
gelato CMS - A PHP based tumblelog CMS
|
||||||
|
development version
|
||||||
|
http://www.gelatocms.com/
|
||||||
|
|
||||||
|
gelato CMS is a free software licensed under the GPL 2.0
|
||||||
|
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
|
||||||
|
|
||||||
|
=========================== */
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
header("Content-type: text/xml; charset=utf-8");
|
||||||
|
|
||||||
|
require(dirname(__FILE__)."/config.php");
|
||||||
|
include("classes/configuration.class.php");
|
||||||
|
include("classes/gelato.class.php");
|
||||||
|
include("classes/textile.class.php");
|
||||||
|
$isFeed = true;
|
||||||
|
$tumble = new gelato();
|
||||||
|
$conf = new configuration();
|
||||||
|
|
||||||
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||||
|
?>
|
||||||
|
<gelato version="1.0">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_GET["action"]) && $_GET["action"] == "read") {
|
||||||
|
if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
|
||||||
|
if (isset($_GET["num"])) { $num = $_GET["num"]; } else { $num = 20; }
|
||||||
|
if (isset($_GET["type"])) { $type = $_GET["type"]; } else { $type = null; }
|
||||||
|
if ($num > 50) { $num = 50; }
|
||||||
|
?>
|
||||||
|
<tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php echo $conf->description;?></tumblelog>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
switch ($type) {
|
||||||
|
case "post":
|
||||||
|
$_GET["type"] = "1";
|
||||||
|
break;
|
||||||
|
case "photo":
|
||||||
|
$_GET["type"] = "2";
|
||||||
|
break;
|
||||||
|
case "quote":
|
||||||
|
$_GET["type"] = "3";
|
||||||
|
break;
|
||||||
|
case "url":
|
||||||
|
$_GET["type"] = "4";
|
||||||
|
break;
|
||||||
|
case "conversation":
|
||||||
|
$_GET["type"] = "5";
|
||||||
|
break;
|
||||||
|
case "video":
|
||||||
|
$_GET["type"] = "6";
|
||||||
|
break;
|
||||||
|
case "mp3":
|
||||||
|
$_GET["type"] = "7";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$rs = $tumble->getPosts($num, $start);
|
||||||
|
if ($tumble->contarRegistros()>0) {
|
||||||
|
?>
|
||||||
|
<posts start="<?php echo $start; ?>" total="<?php echo $num; ?>">
|
||||||
|
<?php/*
|
||||||
|
while($register = mysql_fetch_array($rs)) {
|
||||||
|
|
||||||
|
$textile = new Textile();
|
||||||
|
$register["description"] = $textile->TextileThis($register["description"]);
|
||||||
|
|
||||||
|
switch ($register["type"]) {
|
||||||
|
case "1":
|
||||||
|
$tit = ($register["title"]=="") ? strip_tags($register["description"]) : $register["title"];
|
||||||
|
$desc = $register["description"];
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
$tit = ($register["description"]=="") ? "Photo" : strip_tags($register["description"]);
|
||||||
|
$desc = "<img src=\"".$register["url"]."\"/>";
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
$tit = "\"".strip_tags($register["description"])."\"";
|
||||||
|
$tmpStr = ($register["title"]!="") ? "<br /><br /> - <em>".$register["title"]."</em>" : "";
|
||||||
|
$desc = "\"".$register["description"]."\"".$tmpStr;
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
$tit = ($register["title"]=="") ? $register["url"] : $register["title"];
|
||||||
|
$tmpStr = ($register["description"]!="") ? "<br /><br /> - <em>".$register["description"]."</em>" : "";
|
||||||
|
$desc = "<a href=\"".$register["url"]."\">".$tit."</a>".$tmpStr;
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
$lines = explode("\n", $register["description"]);
|
||||||
|
$line = $lines[0];
|
||||||
|
$tit = ($register["title"]=="") ? $line : $register["title"];
|
||||||
|
$desc = $tumble->formatConversation($register["description"]);
|
||||||
|
break;
|
||||||
|
case "6":
|
||||||
|
$tit = ($register["description"]=="") ? "Video" : strip_tags($register["description"]);
|
||||||
|
$desc = $tumble->getVideoPlayer($register["url"]);
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
|
$tit = ($register["description"]=="") ? "MP3" : strip_tags($register["description"]);
|
||||||
|
$desc = $tumble->getMp3Player($register["url"]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$url = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
|
||||||
|
$formatedDate = gmdate("D, d M Y H:i:s \G\M\T", strtotime($register["date"]));
|
||||||
|
?>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title><?php echo $tit;?></title>
|
||||||
|
<description><![CDATA[<?php echo $desc;?>]]></description>
|
||||||
|
<link><?php echo $url;?></link>
|
||||||
|
<guid isPermaLink="true"><?php echo $conf->urlGelato."/index.php/post/".$register["id_post"]."/";?></guid>
|
||||||
|
<pubDate><?php echo $formatedDate;?></pubDate>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
*/?>
|
||||||
|
</posts>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</gelato>
|
||||||
|
|
@ -23,7 +23,7 @@ class comments extends Conexion_Mysql {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addComment($fieldsArray) {
|
function addComment($fieldsArray) {
|
||||||
if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
|
if ($this->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -55,35 +55,47 @@ class comments extends Conexion_Mysql {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmacionEmail($email_autor_post, $tit_blog, $desc_blog, $url_blog, $id_post, $titulo_post, $usuario, $email, $pagina_web, $comentario, $ip_usuario) {
|
function getComments($idPost=null, $limit=null, $from=null, $spam=null) {
|
||||||
$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/>";
|
if (isset($idPost)) {
|
||||||
$msg .= "Autor : ".$usuario." (IP: ".$ip_usuario.")<br /><br />";
|
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0 order by comment_date ASC");
|
||||||
$msg .= "E-mail : <a href=\"mailto:".$email."\">".$email."</a><br /><br />";
|
} else {
|
||||||
$msg .= "URL : <a href=\"".$pagina_web."\" target=\"_blank\">".$pagina_web."</a><br /><br />";
|
if (isset($limit) && isset($from)) {
|
||||||
$msg .= "Whois : <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 />";
|
$limit = " LIMIT $from, $limit";
|
||||||
$msg .= "Comentario:<br /><br />".$comentario;
|
} else { ""; }
|
||||||
$msg .= "<br /><br /><a href=\"".$url_blog."/index.php?id=".$id_post."\">".$url_blog."/index.php?id=".$id_post."</a><br /><br />";
|
if (isset($spam)) { $sp = "1"; } else { $sp = "0"; }
|
||||||
|
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=".$sp." order by comment_date ASC".$limit);
|
||||||
enviaMail($email_autor_post, "[".$desc_blog."] Nuevo mensaje en: ".$titulo_post."", $msg, EMAIL_ADMIN);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function obtenerComentarios($idArticulo="") {
|
|
||||||
$this->ejecutarConsulta("select * from ".tabla_prefijo."comentarios WHERE id_post=".$idArticulo." AND spam=0 order by fecha ASC");
|
|
||||||
return $this->mid_consulta;
|
return $this->mid_consulta;
|
||||||
}
|
}
|
||||||
|
|
||||||
function contarComentarios($idArticulo="") {
|
function getComment($id="") {
|
||||||
$this->ejecutarConsulta("select * from ".tabla_prefijo."comentarios WHERE id_post=".$idArticulo." AND spam=0");
|
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id);
|
||||||
|
return mysql_fetch_array($this->mid_consulta);
|
||||||
|
}
|
||||||
|
|
||||||
|
function countComments($idPost=null) {
|
||||||
|
if (isset($idPost)) {
|
||||||
|
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0");
|
||||||
|
} else {
|
||||||
|
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=0");
|
||||||
|
}
|
||||||
return $this->contarRegistros();
|
return $this->contarRegistros();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mostrarGravatar($email="") {
|
function deleteComment($idComment) {
|
||||||
$emailg = $email;
|
if ($this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."comments WHERE id_comment=".$idComment)) {
|
||||||
$default = URL_CODICE."/images/noGravatar.jpg";
|
return true;
|
||||||
$size = 30;
|
} else {
|
||||||
$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($emailg)."&default=".urlencode($default)."&size=".$size;
|
return false;
|
||||||
return "<img src=\"".$grav_url."\" alt=\"Gravatar\" title=\"Gravatar\" />";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function modifyComment($fieldsArray, $id_comment) {
|
||||||
|
if ($this->modificarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray, "id_comment=$id_comment")) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -50,7 +50,7 @@ class plantillas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function precargarPlantillaConBloque($entrada, $salida, $plantilla_usar) {
|
function precargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) {
|
||||||
$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
|
$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
|
||||||
|
|
||||||
if (!file_exists($plantilla_usar)) {
|
if (!file_exists($plantilla_usar)) {
|
||||||
|
|
@ -64,15 +64,14 @@ class plantillas {
|
||||||
$salida_xhtml = stripslashes($salida_xhtml);
|
$salida_xhtml = stripslashes($salida_xhtml);
|
||||||
$this->texto_plantilla = $salida_xhtml;
|
$this->texto_plantilla = $salida_xhtml;
|
||||||
|
|
||||||
$this->cargaAntesBloque("comentarios");
|
$this->cargaAntesBloque($nombreBloque);
|
||||||
$this->cargaDespuesBloque("comentarios");
|
$this->cargaDespuesBloque($nombreBloque);
|
||||||
|
|
||||||
$this->antesBloque = $this->procesaBloque($entrada, $salida, $this->antesBloque);
|
$this->antesBloque = $this->procesaBloque($entrada, $salida, $this->antesBloque);
|
||||||
$this->despuesBloque = $this->procesaBloque($entrada, $salida, $this->despuesBloque);
|
$this->despuesBloque = $this->procesaBloque($entrada, $salida, $this->despuesBloque);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) {
|
function cargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) {
|
||||||
$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
|
$plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm";
|
||||||
|
|
@ -93,8 +92,7 @@ class plantillas {
|
||||||
$this->bloqueFinal .= $this->procesaBloque($entrada, $salida, $this->bloque);
|
$this->bloqueFinal .= $this->procesaBloque($entrada, $salida, $this->bloque);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function procesaBloque($entrada, $salida, $bloque) {
|
function procesaBloque($entrada, $salida, $bloque) {
|
||||||
for ($i = 0; $i < count($entrada); $i++) {
|
for ($i = 0; $i < count($entrada); $i++) {
|
||||||
|
|
@ -139,5 +137,4 @@ class plantillas {
|
||||||
echo $texto;
|
echo $texto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
21
index.php
21
index.php
|
|
@ -31,6 +31,7 @@
|
||||||
include("classes/templates.class.php");
|
include("classes/templates.class.php");
|
||||||
include("classes/pagination.class.php");
|
include("classes/pagination.class.php");
|
||||||
include("classes/user.class.php");
|
include("classes/user.class.php");
|
||||||
|
include("classes/comments.class.php");
|
||||||
|
|
||||||
$user = new user();
|
$user = new user();
|
||||||
$conf = new configuration();
|
$conf = new configuration();
|
||||||
|
|
@ -47,7 +48,7 @@
|
||||||
} else {
|
} else {
|
||||||
$id_post = NULL;
|
$id_post = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET["page"])) {
|
if (isset($_GET["page"])) {
|
||||||
$page_num = $_GET["page"];
|
$page_num = $_GET["page"];
|
||||||
|
|
@ -262,10 +263,24 @@
|
||||||
|
|
||||||
if ($conf->allowComments) {
|
if ($conf->allowComments) {
|
||||||
|
|
||||||
// before the comments form must be the comments on the DB
|
$comment = new comments();
|
||||||
|
$rsComments = $comment->getComments($register["id_post"]);
|
||||||
|
|
||||||
|
$input = array("{Comments_Number}", "{Post_Title}");
|
||||||
|
$output = array($comment->countComments($register["id_post"]), $register["title"]);
|
||||||
|
$template->precargarPlantillaConBloque($input, $output, "template_comments", "comments");
|
||||||
|
while($rowComment = mysql_fetch_array($rsComments)) {
|
||||||
|
|
||||||
|
$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
|
||||||
|
$input = array("{Id_Comment}", "{Comment_Author}", "{Date}", "{Comment}");
|
||||||
|
$output = array($rowComment["id_comment"], $commentAuthor, date("d.m.y", strtotime($rowComment["comment_date"])), $rowComment["content"]);
|
||||||
|
$template->cargarPlantillaConBloque($input, $output, "template_comments", "comments");
|
||||||
|
}
|
||||||
|
$template->mostrarPlantillaConBloque();
|
||||||
|
|
||||||
|
|
||||||
$input = array("{User_Cookie}", "{Email_Cookie}", "{Web_Cookie}", "{Id_Post}", "{Form_Action}", "{Date_Added}");
|
$input = array("{User_Cookie}", "{Email_Cookie}", "{Web_Cookie}", "{Id_Post}", "{Form_Action}", "{Date_Added}");
|
||||||
$output = array($_COOKIE['cookie_gel_user'], $_COOKIE['cookie_gel_email'], $_COOKIE['cookie_gel_web'], $register["id_post"], $conf->urlGelato."/comments.php", gmmktime());
|
$output = array($_COOKIE['cookie_gel_user'], $_COOKIE['cookie_gel_email'], $_COOKIE['cookie_gel_web'], $register["id_post"], $conf->urlGelato."/admin/comments.php", gmmktime());
|
||||||
|
|
||||||
$template->cargarPlantilla($input, $output, "template_comment_post");
|
$template->cargarPlantilla($input, $output, "template_comment_post");
|
||||||
$template->mostrarPlantilla();
|
$template->mostrarPlantilla();
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ require_once(dirname(__FILE__)."/classes/configuration.class.php");
|
||||||
$user = new user();
|
$user = new user();
|
||||||
$conf = new configuration();
|
$conf = new configuration();
|
||||||
|
|
||||||
die($user->validateUser($_POST['login'], md5($_POST['pass']))."<");
|
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
if ($user->isAdmin()) {
|
||||||
header("Location: ".$conf->urlGelato."/admin/index.php");
|
header("Location: ".$conf->urlGelato."/admin/index.php");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<div class="containerFormComments">
|
<div class="containerFormComments">
|
||||||
<h3 id="respond">Add your comment</h3>
|
<h3 id="respond">Add your comment</h3>
|
||||||
|
|
||||||
|
|
@ -30,8 +29,8 @@
|
||||||
<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
|
<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input name="idPost" id="idPost" value="{Id_Post}" type="hidden" />
|
<input name="id_post" id="id_post" value="{Id_Post}" type="hidden" />
|
||||||
<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
|
<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
<div class="containerComments">
|
<div class="containerComments">
|
||||||
<h3 id="comments"><*NumeroDeComentarios*> Respuestas a “<*TituloPost*>”</h3>
|
<h3 id="comments">{Comments_Number} answers to “{Post_Title}”</h3>
|
||||||
<ol class="commentlist">
|
<ol class="commentlist">
|
||||||
[bloque: comentarios]
|
[bloque: comments]
|
||||||
<li class="alt" id="comment-<*IdComentario*>">
|
<li class="alt" id="comment-{Id_Comment}">
|
||||||
<cite>
|
<cite>
|
||||||
<a href="#comment-<*IdComentario*>" title="Enlace permanente a este comentario">#</a>
|
<a href="#comment-{Id_Comment}" title="Comment permalink">#</a>
|
||||||
<*ImagenAvatar*>
|
{Comment_Author} said:
|
||||||
<*AutorComentario*> dijo:
|
|
||||||
</cite>
|
</cite>
|
||||||
<br />
|
<br />
|
||||||
<span class="timestampComment"> el <*Fecha*></span><br /><br />
|
<span class="timestampComment"> at {Date}</span><br /><br />
|
||||||
<*TextoComentario*>
|
{Comment}
|
||||||
<br /><br />
|
<br /><br />
|
||||||
</li>
|
</li>
|
||||||
[/bloque: comentarios]
|
[/bloque: comments]
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue