A tumblelog CMS built on AJAX, PHP and MySQL.

index.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?
  2. /* ===========================
  3. gelato CMS development version
  4. http://www.gelatocms.com/
  5. gelato CMS is a free software licensed under GPL (General public license)
  6. =========================== */
  7. ?>
  8. <?
  9. require_once('../config.php');
  10. include("../classes/user.class.php");
  11. include("../classes/gelato.class.php");
  12. include("../classes/templates.class.php");
  13. require_once("../classes/configuration.class.php");
  14. $user = new user();
  15. $tumble = new gelato();
  16. $conf = new configuration();
  17. $template = new plantillas("admin");
  18. if ($user->isAdmin()) {
  19. if(isset($_POST["btnAdd"])) {
  20. unset($_POST["btnAdd"]);
  21. if ($_POST["type"]=="2") { // is Photo type
  22. if (isset($_POST["url"]) && $_POST["url"]!="") {
  23. $photoName = getFileName($_POST["url"]);
  24. if (!$tumble->savePhoto($_POST["url"])) {
  25. header("Location: ".$conf->urlGelato."/admin/index.php?photo=false");
  26. die();
  27. }
  28. $_POST["url"] = $conf->urlGelato."/uploads/".$photoName;
  29. }
  30. if ( move_uploaded_file( $_FILES['photo']['tmp_name'], "../uploads/".$_FILES['photo']['name'] ) ) {
  31. $_POST["url"] = $conf->urlGelato."/uploads/".$_FILES['photo']['name'];
  32. }
  33. unset($_POST["photo"]);
  34. unset($_POST["MAX_FILE_SIZE"]);
  35. }
  36. if ($_POST["type"]=="7") { // is MP3 type
  37. set_time_limit(300);
  38. $mp3Name = getFileName($_POST["url"]);
  39. if (!$tumble->saveMP3($_POST["url"])) {
  40. header("Location: ".$conf->urlGelato."/admin/index.php?mp3=false");
  41. die();
  42. }
  43. $_POST["url"] = $conf->urlGelato."/uploads/".$mp3Name;
  44. }
  45. if (get_magic_quotes_gpc()) {
  46. $_POST["title"] = htmlspecialchars(stripslashes($_POST["title"]));
  47. $_POST["description"] = htmlspecialchars(stripslashes($_POST["description"]));
  48. } else {
  49. $_POST["title"] = htmlspecialchars($_POST["title"]);
  50. $_POST["description"] = htmlspecialchars($_POST["description"]);
  51. }
  52. $_POST["title"] = strip_tags($_POST["title"]);
  53. $_POST["description"] = strip_tags($_POST["description"]);
  54. if (isset($_POST["id_post"])) {
  55. //$tumble->modifyPost($_POST, $_POST["id_post"]);
  56. } else {
  57. if ($tumble->addPost($_POST)) {
  58. header("Location: ".$conf->urlGelato."/admin/index.php?added=true");
  59. die();
  60. } else {
  61. header("Location: ".$conf->urlGelato."/admin/index.php?error=2&des=".$this->merror);
  62. die();
  63. }
  64. }
  65. }
  66. ?>
  67. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  68. <html xmlns="http://www.w3.org/1999/xhtml">
  69. <head>
  70. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  71. <title>gelato :: Control panel</title>
  72. <link rel="shortcut icon" href="<?=$conf->urlGelato;?>/images/favicon.ico" />
  73. <script language="javascript" type="text/javascript" src="<?=$conf->urlGelato;?>/admin/scripts/tools.js"></script>
  74. <script language="javascript" type="text/javascript" src="<?=$conf->urlGelato;?>/admin/scripts/mootools.js"></script>
  75. <script type="text/javascript">
  76. <!--
  77. function exit(el, path) {
  78. el = $(el);
  79. el.style.display="block";
  80. el.setHTML('Processing request...');
  81. new Ajax(path, {
  82. onComplete:function(e) {
  83. el.setHTML(e).effect('opacity').custom(0,1);
  84. window.location='../login.php';
  85. }
  86. }).request();
  87. return false;
  88. }
  89. window.onload = function() {
  90. contenedor = new Fx.Style('divMessages', 'opacity', {duration: 5000, onComplete:
  91. function() {
  92. document.getElementById('divMessages').style.display="none";
  93. document.getElementById('pMessages').style.display="none";
  94. }
  95. });
  96. contenedor.custom(1,0);
  97. }
  98. -->
  99. </script>
  100. <style type="text/css" media="screen">
  101. @import "<?=$conf->urlGelato;?>/admin/css/style.css";
  102. </style>
  103. </head>
  104. <body>
  105. <div id="div-process" style="display:none;">Processing request...</div>
  106. <div id="cont">
  107. <div id="head">
  108. <h1><a href="<?=$conf->urlGelato;?>/admin/index.php" title="gelato :: home">gelato cms</a></h1>
  109. <ul id="nav">
  110. <li><a href="<?=$conf->urlGelato;?>/" title="Take me to the tumblelog">View Tumblelog</a></li>
  111. <li><a href="close.php" onclick="return exit('div-process','<?=$conf->urlGelato;?>/admin/ajax.php?action=close');">Log out</a></li>
  112. </ul>
  113. </div>
  114. <div id="main">
  115. <div class="box">
  116. <ul class="menu">
  117. <h3>New Post</h3>
  118. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=conversation"><img src="css/images/comments.png" alt="New chat" /> Chat</a></li>
  119. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=quote"><img src="css/images/comments.png" alt="New qoute" /> Quote</a></li>
  120. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=url"><img src="css/images/world.png" alt="New link" /> Link</a></li>
  121. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=mp3"><img src="css/images/music.png" alt="New audio" /> Audio</a></li>
  122. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=video"><img src="css/images/film.png" alt="New video" /> Video</a></li>
  123. <li><a href="<?=$conf->urlGelato;?>/admin/index.php?new=photo"><img src="css/images/image.png" alt="New picture" /> Picture</a></li>
  124. <li class="selected"><a href="<?=$conf->urlGelato;?>/admin/index.php?new=post"><img src="css/images/page_white_text.png" alt="New post" /> Regular</a></li>
  125. </ul>
  126. <?
  127. if (isset($_GET["deleted"])) {
  128. if ($_GET["deleted"]=="true") {
  129. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"exito\" id=\"divMessages\">The article has been eliminated successfully.</div>";
  130. }
  131. }
  132. if (isset($_GET["modified"])) {
  133. if ($_GET["modified"]=="true") {
  134. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"exito\" id=\"divMessages\">The article has been modified successfully.</div>";
  135. }
  136. }
  137. if (isset($_GET["added"])) {
  138. if ($_GET["added"]=="true") {
  139. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"exito\" id=\"divMessages\">The article has been added successfully.</div>";
  140. }
  141. }
  142. if (isset($_GET["error"])) {
  143. if ($_GET["error"]==2) {
  144. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"error\"><strong>Error on the database server: </strong>".$_GET["des"]."</div>";
  145. }
  146. }
  147. if (isset($_GET["mp3"])) {
  148. if ($_GET["mp3"]=="false") {
  149. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"error\" id=\"divMessages\">Not an MP3 file or an upload problem.</div>";
  150. }
  151. }
  152. if (isset($_GET["photo"])) {
  153. if ($_GET["photo"]=="false") {
  154. echo "<p id=\"pMessages\">&nbsp;</p><div class=\"error\" id=\"divMessages\">Not a photo file or an upload problem.</div>";
  155. }
  156. }
  157. ?>
  158. <form action="index.php" method="post" <?=($_GET["new"]=="photo") ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
  159. <fieldset>
  160. <?
  161. switch ($_GET["new"]) {
  162. case "post":
  163. $input = array("{type}", "{date}", "{id_user}");
  164. $output = array("1", time(), $_SESSION['user_id']);
  165. $template->cargarPlantilla($input, $output, "template_add_post");
  166. $template->mostrarPlantilla();
  167. break;
  168. case "photo":
  169. $input = array("{type}", "{date}", "{id_user}");
  170. $output = array("2", time(), $_SESSION['user_id']);
  171. $template->cargarPlantilla($input, $output, "template_add_photo");
  172. $template->mostrarPlantilla();
  173. break;
  174. case "quote":
  175. $input = array("{type}", "{date}", "{id_user}");
  176. $output = array("3", time(), $_SESSION['user_id']);
  177. $template->cargarPlantilla($input, $output, "template_add_quote");
  178. $template->mostrarPlantilla();
  179. break;
  180. case "url":
  181. $input = array("{type}", "{date}", "{id_user}");
  182. $output = array("4", time(), $_SESSION['user_id']);
  183. $template->cargarPlantilla($input, $output, "template_add_link");
  184. $template->mostrarPlantilla();
  185. break;
  186. case "conversation":
  187. $input = array("{type}", "{date}", "{id_user}");
  188. $output = array("5", time(), $_SESSION['user_id']);
  189. $template->cargarPlantilla($input, $output, "template_add_conversation");
  190. $template->mostrarPlantilla();
  191. break;
  192. case "video":
  193. $input = array("{type}", "{date}", "{id_user}");
  194. $output = array("6", time(), $_SESSION['user_id']);
  195. $template->cargarPlantilla($input, $output, "template_add_video");
  196. $template->mostrarPlantilla();
  197. break;
  198. case "mp3":
  199. $input = array("{type}", "{date}", "{id_user}");
  200. $output = array("7", time(), $_SESSION['user_id']);
  201. $template->cargarPlantilla($input, $output, "template_add_mp3");
  202. $template->mostrarPlantilla();
  203. break;
  204. default:
  205. $input = array("{type}", "{date}", "{id_user}");
  206. $output = array("1", time(), $_SESSION['user_id']);
  207. $template->cargarPlantilla($input, $output, "template_add_post");
  208. $template->mostrarPlantilla();
  209. break;
  210. }
  211. ?>
  212. <p>
  213. <input class="btn" type="submit" name="btnAdd" value="Create post" />&nbsp;&nbsp;
  214. <a href="#" onclick="if (confirm('Cancel editing this post? All changes will be lost.'))
  215. {location.href='index.php';}; return false;">Cancel</a>
  216. </p>
  217. </fieldset>
  218. </form>
  219. <div class="footer-box">&nbsp;</div>
  220. </div>
  221. <div class="box">
  222. <ul class="menu manage">
  223. <h3>Manage</h3>
  224. <li><a href="#">Settings</a></li>
  225. <li><a href="<?=$conf->urlGelato;?>/admin/admin.php">Users</a></li>
  226. <li class="selected"><a href="#">Posts</a></li>
  227. </ul>
  228. <div class="entry">
  229. <div class="info"><form class="compact"><input type="submit" value="Edit" /> <input type="submit" value="Delete" /></form>
  230. <p>25/05 Regular Post (0 Comments) </p>
  231. </div>
  232. <div class="post">
  233. <span class="option">(no title)</span>
  234. <p>I just discovered Gelato</p>
  235. </div>
  236. </div>
  237. <div class="entry">
  238. <div class="info"><form class="compact"><input type="submit" value="Edit" /> <input type="submit" value="Delete" /></form>
  239. <p>25/05 Regular Post (0 Comments) </p>
  240. </div>
  241. <div class="post">
  242. <h4>One with a title</h4>
  243. <p>Another entry, this one has some varations in the content, even dares
  244. to be in two lines.</p>
  245. </div>
  246. </div>
  247. <div class="footer-box">&nbsp;</div>
  248. </div>
  249. </div>
  250. <div id="foot">
  251. <a href="http://www.gelatocms.com/" title="gelato CMS" target="_blank">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  252. </div>
  253. </div>
  254. </body>
  255. </html>
  256. <?
  257. } else {
  258. header("Location: ".$conf->urlGelato."/login.php");
  259. }
  260. ?>