A tumblelog CMS built on AJAX, PHP and MySQL.

comments.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. if(!defined('entry') || !entry) die('Not a valid page');
  3. /* ===========================
  4. gelato CMS - A PHP based tumblelog CMS
  5. development version
  6. http://www.gelatocms.com/
  7. gelato CMS is a free software licensed under the GPL 2.0
  8. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  9. =========================== */
  10. ?>
  11. <?php
  12. require_once('config.php');
  13. include("classes/functions.php");
  14. include("classes/comments.class.php");
  15. require_once("classes/configuration.class.php");
  16. $comment = new comments();
  17. $conf = new configuration();
  18. $isEdition = isset($_GET["edit"]);
  19. $commentId = ($isEdition) ? $_GET["edit"] : NULL;
  20. if (isset($_GET["delete"])) {
  21. $comment->deleteComment($_GET['delete']);
  22. header("Location: comments.php?delete=true");
  23. die();
  24. }
  25. if(isset($_POST["btnAdd"])) {
  26. unset($_POST["btnAdd"]);
  27. $_POST["username"] = strip_tags($_POST["username"]);
  28. $_POST["email"] = strip_tags($_POST["email"]);
  29. $_POST["web"] = strip_tags($_POST["web"]);
  30. if (isset($_POST["id_comment"])) {
  31. $comment->modifyComment($_POST, $_POST["id_comment"]);
  32. } else {
  33. $comment->generateCookie($_POST);
  34. $_POST["spam"] = ($comment->isSpam($_POST)) ? "1" : "0";
  35. $_POST["ip_user"] = $_SERVER["REMOTE_ADDR"];
  36. if ($comment->addComment($_POST)) {
  37. header("Location: comments.php?added=true");
  38. die();
  39. } else {
  40. header("Location: comments.php?added=false");
  41. die();
  42. }
  43. }
  44. } else {
  45. if ($isEdition) {
  46. $row = $comment->getCommentByID($userId);
  47. }
  48. ?>
  49. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  50. <html xmlns="http://www.w3.org/1999/xhtml">
  51. <head>
  52. <title>gelato :: <?php echo __("add user")?></title>
  53. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  54. <meta name="generator" content="gelato cms <?php echo version();?>" />
  55. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  56. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/mootools.js"></script>
  57. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
  58. <style type="text/css" media="screen">
  59. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  60. </style>
  61. </head>
  62. <body>
  63. <div id="div-process" style="display:none;"><?=__("Processing request...");?></div>
  64. <div id="cont">
  65. <div id="head">
  66. <h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: <?=__("home")?>">gelato cms</a></h1>
  67. <ul id="nav">
  68. <li><a href="<?php echo $conf->urlGelato;?>/" title="<?=__("Take me to the tumblelog")?>"><?=__("Back to the Tumblelog")?></a></li>
  69. </ul>
  70. </div>
  71. <div id="main">
  72. <div class="box">
  73. <ul class="menu manage">
  74. <h3><?=__("Start session")?></h3>
  75. <li><a href="index.php"><?=__("Post")?></a></li>
  76. <li><a href="admin.php"><?=__("Users")?></a></li>
  77. <li class="selected"><a><?php echo ($isEdition) ? __("Edit") : __("Add"); ?></a></li>
  78. </ul>
  79. <div class="tabla">
  80. <?php
  81. if ($isEdition) {
  82. ?>
  83. <input type="hidden" name="id_user" id="id_user" value="<?php echo $userId;?>" />
  84. <?php
  85. }
  86. ?>
  87. </div>
  88. <div class="footer-box">&nbsp;</div>
  89. </div>
  90. </div>
  91. <div id="foot">
  92. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  93. </div>
  94. </div>
  95. </body>
  96. </html>
  97. <?php
  98. }
  99. ?>