A tumblelog CMS built on AJAX, PHP and MySQL.

comments.php 3.5KB

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