diff --git a/admin/comments.php b/admin/comments.php new file mode 100644 index 0000000..29ca416 --- /dev/null +++ b/admin/comments.php @@ -0,0 +1,203 @@ + + + =========================== */ +?> +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(); + } + } + +?> + + + + gelato :: <?php echo __("comments")?> + + + + + + + + + + + +
+ +
+ +
+ +

 

+".__("The comment has been eliminated successfully.")."
"; + } + if ($_GET["deleted"]=="false") { + echo "
".__("The post has NOT been eliminated.")."
"; + } + } + + if (isset($_GET["modified"])) { + if ($_GET["modified"]=="true") { + echo "
".__("The comment has been modified successfully.")."
"; + } + if ($_GET["modified"]=="false") { + echo "
".__("The post has NOT been modified.")."
"; + } + } +?> +
+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"] : "".$rowComment["username"]." | ".$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(); + } + } +?> +
+ + +
+
+ + + + +urlGelato."/login.php"); +} +?> \ No newline at end of file diff --git a/admin/index.php b/admin/index.php index 21cacf0..fba1e52 100644 --- a/admin/index.php +++ b/admin/index.php @@ -321,6 +321,7 @@ if ($user->isAdmin()) {
  • +
  • diff --git a/admin/themes/admin/template_comment.htm b/admin/themes/admin/template_comment.htm new file mode 100644 index 0000000..125ef3a --- /dev/null +++ b/admin/themes/admin/template_comment.htm @@ -0,0 +1,8 @@ +
    +
    Link   +

    {Comment_Author}

    +
    +
    +

    {Comment}

    +
    +
    \ No newline at end of file diff --git a/admin/themes/admin/template_comment_post.htm b/admin/themes/admin/template_comment_post.htm new file mode 100644 index 0000000..0cf9389 --- /dev/null +++ b/admin/themes/admin/template_comment_post.htm @@ -0,0 +1,28 @@ +
    +
    +

    + + +

    +

    + + +

    +

    + + +

    +

    +
    + +

    +

    + +

    +

    + + + +

    +
    +
    \ No newline at end of file diff --git a/api.php b/api.php new file mode 100644 index 0000000..91d7e1a --- /dev/null +++ b/api.php @@ -0,0 +1,125 @@ + + + =========================== */ +?> +\n"; +?> + + 50) { $num = 50; } +?> + " timezone="offsetCity;?>" title="title;?>">description;?> + +getPosts($num, $start); + if ($tumble->contarRegistros()>0) { +?> + +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 = ""; + break; + case "3": + $tit = "\"".strip_tags($register["description"])."\""; + $tmpStr = ($register["title"]!="") ? "

    - ".$register["title"]."" : ""; + $desc = "\"".$register["description"]."\"".$tmpStr; + break; + case "4": + $tit = ($register["title"]=="") ? $register["url"] : $register["title"]; + $tmpStr = ($register["description"]!="") ? "

    - ".$register["description"]."" : ""; + $desc = "".$tit."".$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"])); +?> + + + <?php echo $tit;?> + ]]> + + urlGelato."/index.php/post/".$register["id_post"]."/";?> + + + + +
    + +
    \ No newline at end of file diff --git a/classes/comments.class.php b/classes/comments.class.php index 1aaf9d6..5ce67a5 100644 --- a/classes/comments.class.php +++ b/classes/comments.class.php @@ -23,7 +23,7 @@ class comments extends Conexion_Mysql { } function addComment($fieldsArray) { - if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) { + if ($this->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) { return true; } else { return false; @@ -55,35 +55,47 @@ class comments extends Conexion_Mysql { return false; } - function confirmacionEmail($email_autor_post, $tit_blog, $desc_blog, $url_blog, $id_post, $titulo_post, $usuario, $email, $pagina_web, $comentario, $ip_usuario) { - $msg = "

    Hay un nuevo comentario en el post #".$id_post." \"".$titulo_post."\"

    "; - $msg .= "Autor : ".$usuario." (IP: ".$ip_usuario.")

    "; - $msg .= "E-mail : ".$email."

    "; - $msg .= "URL    : ".$pagina_web."

    "; - $msg .= "Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=".$ip_usuario."

    "; - $msg .= "Comentario:

    ".$comentario; - $msg .= "

    ".$url_blog."/index.php?id=".$id_post."

    "; - - 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"); + function getComments($idPost=null, $limit=null, $from=null, $spam=null) { + if (isset($idPost)) { + $this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0 order by comment_date ASC"); + } else { + if (isset($limit) && isset($from)) { + $limit = " LIMIT $from, $limit"; + } else { ""; } + 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); + } return $this->mid_consulta; } - function contarComentarios($idArticulo="") { - $this->ejecutarConsulta("select * from ".tabla_prefijo."comentarios WHERE id_post=".$idArticulo." AND spam=0"); + function getComment($id="") { + $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(); } - function mostrarGravatar($email="") { - $emailg = $email; - $default = URL_CODICE."/images/noGravatar.jpg"; - $size = 30; - $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($emailg)."&default=".urlencode($default)."&size=".$size; - return "\"Gravatar\""; + function deleteComment($idComment) { + if ($this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."comments WHERE id_comment=".$idComment)) { + return true; + } else { + return false; + } } + function modifyComment($fieldsArray, $id_comment) { + if ($this->modificarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray, "id_comment=$id_comment")) { + return true; + } else { + return false; + } + } } ?> \ No newline at end of file diff --git a/classes/templates.class.php b/classes/templates.class.php index eadda3b..c6c0aad 100644 --- a/classes/templates.class.php +++ b/classes/templates.class.php @@ -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"; if (!file_exists($plantilla_usar)) { @@ -64,15 +64,14 @@ class plantillas { $salida_xhtml = stripslashes($salida_xhtml); $this->texto_plantilla = $salida_xhtml; - $this->cargaAntesBloque("comentarios"); - $this->cargaDespuesBloque("comentarios"); + $this->cargaAntesBloque($nombreBloque); + $this->cargaDespuesBloque($nombreBloque); $this->antesBloque = $this->procesaBloque($entrada, $salida, $this->antesBloque); $this->despuesBloque = $this->procesaBloque($entrada, $salida, $this->despuesBloque); } } - } - + } function cargarPlantillaConBloque($entrada, $salida, $plantilla_usar, $nombreBloque) { $plantilla_usar = "themes/".$this->plantilla."/".$plantilla_usar.".htm"; @@ -93,8 +92,7 @@ class plantillas { $this->bloqueFinal .= $this->procesaBloque($entrada, $salida, $this->bloque); } } - } - + } function procesaBloque($entrada, $salida, $bloque) { for ($i = 0; $i < count($entrada); $i++) { @@ -139,5 +137,4 @@ class plantillas { echo $texto; } } - ?> \ No newline at end of file diff --git a/index.php b/index.php index 4cb5a5a..bb3cb0c 100644 --- a/index.php +++ b/index.php @@ -31,6 +31,7 @@ include("classes/templates.class.php"); include("classes/pagination.class.php"); include("classes/user.class.php"); + include("classes/comments.class.php"); $user = new user(); $conf = new configuration(); @@ -47,7 +48,7 @@ } else { $id_post = NULL; } - } + } if (isset($_GET["page"])) { $page_num = $_GET["page"]; @@ -262,10 +263,24 @@ 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"] : "".$rowComment["username"].""; + $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}"); - $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->mostrarPlantilla(); diff --git a/login.php b/login.php index e2c089c..f1012f7 100644 --- a/login.php +++ b/login.php @@ -20,8 +20,6 @@ require_once(dirname(__FILE__)."/classes/configuration.class.php"); $user = new user(); $conf = new configuration(); -die($user->validateUser($_POST['login'], md5($_POST['pass']))."<"); - if ($user->isAdmin()) { header("Location: ".$conf->urlGelato."/admin/index.php"); } else { diff --git a/themes/tumblr/template_comment_post.htm b/themes/tumblr/template_comment_post.htm index 3f5dddc..01065b0 100644 --- a/themes/tumblr/template_comment_post.htm +++ b/themes/tumblr/template_comment_post.htm @@ -1,4 +1,3 @@ -

    Add your comment

    @@ -30,8 +29,8 @@

    - +

    -
    + \ No newline at end of file diff --git a/themes/tumblr/template_comments.htm b/themes/tumblr/template_comments.htm index 9fd4b65..59f2ba8 100644 --- a/themes/tumblr/template_comments.htm +++ b/themes/tumblr/template_comments.htm @@ -1,18 +1,17 @@
    -

    <*NumeroDeComentarios*> Respuestas a “<*TituloPost*>”

    +

    {Comments_Number} answers to “{Post_Title}”

      - [bloque: comentarios] -
    1. + [bloque: comments] +
    2. - #   - <*ImagenAvatar*>   - <*AutorComentario*> dijo: + #   + {Comment_Author} said:
      - el <*Fecha*>

      - <*TextoComentario*> + at {Date}

      + {Comment}

    3. - [/bloque: comentarios] + [/bloque: comments]