A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. if (!defined('entry')) {
  3. define('entry', true);
  4. }
  5. /* ===========================
  6. gelato CMS - A PHP based tumblelog CMS
  7. development version
  8. http://www.gelatocms.com/
  9. gelato CMS is a free software licensed under the GPL 2.0
  10. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  11. =========================== */
  12. ?>
  13. <?php
  14. require('../entry.php');
  15. global $user, $conf, $tumble;
  16. $template = new plantillas("admin");
  17. $util_class = new util();
  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 = $util_class->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"] = "../uploads/".$util_class->sanitizeName($photoName);
  29. }
  30. unset($_POST["photo"]);
  31. unset($_POST["MAX_FILE_SIZE"]);
  32. }
  33. if ($_POST["type"]=="7") { // is MP3 type
  34. set_time_limit(300);
  35. $mp3Name = $util_class->getFileName($_POST["url"]);
  36. if (!$tumble->saveMP3($_POST["url"])) {
  37. header("Location: ".$conf->urlGelato."/admin/index.php?mp3=false");
  38. die();
  39. }
  40. if (isMP3($remoteFileName)) {
  41. $_POST["url"] = $conf->urlGelato."/uploads/".$mp3Name;
  42. }
  43. }
  44. if (!get_magic_quotes_gpc()) {
  45. $_POST["title"] = addslashes($_POST["title"]);
  46. $_POST["description"] = addslashes($_POST["description"]);
  47. }
  48. $_POST["title"] = $util_class->removeBadTags($_POST["title"], true);
  49. $_POST["description"] = $util_class->removeBadTags($_POST["description"]);
  50. if ($tumble->addPost($_POST)) {
  51. $input = array("{type}");
  52. $output = array("1");
  53. $template->cargarPlantilla($input, $output, "template_bm");
  54. $template->mostrarPlantilla();
  55. die();
  56. } else {
  57. header("Location: ".$conf->urlGelato."/admin/index.php?error=2&des=".$this->merror);
  58. die();
  59. }
  60. } else {
  61. if (isset($_GET["url"])) {
  62. $url = $_GET["url"];
  63. } else {
  64. $url = null;
  65. }
  66. if (isset($url)) {
  67. if ($util_class->isMP3($url)) {
  68. $postType = "mp3";
  69. } elseif ($util_class->isGoEar($url)) {
  70. $postType = "mp3";
  71. } elseif ($util_class->isImageFile($url)) {
  72. $postType = "photo";
  73. } elseif ($util_class->isVideo($url)) {
  74. $postType = "video";
  75. } else {
  76. if (isset($_GET["sel"]) && !$_GET["sel"]=="") {
  77. $postType = "post";
  78. } else {
  79. $postType = "url";
  80. }
  81. }
  82. } else {
  83. die(__("Must be a valid URL"));
  84. } ?>
  85. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  86. <html xmlns="http://www.w3.org/1999/xhtml">
  87. <head>
  88. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  89. <meta name="generator" content="gelato cms <?php echo $util_class->version(); ?>" />
  90. <title>gelato :: <?php echo __("bookmarklet")?></title>
  91. <link rel="shortcut icon" href="<?php echo $conf->urlGelato; ?>/images/favicon.ico" />
  92. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato; ?>/admin/scripts/jquery.js"></script>
  93. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato; ?>/admin/scripts/tools.js"></script>
  94. <script type="text/javascript" src="<?php echo $conf->urlGelato; ?>/admin/scripts/markitup/jquery.markitup.pack.js"></script>
  95. <script type="text/javascript" src="<?php echo $conf->urlGelato; ?>/admin/scripts/markitup/sets/html/set.js"></script>
  96. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlGelato; ?>/admin/scripts/markitup/skins/simple/style.css" />
  97. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlGelato; ?>/admin/scripts/markitup/sets/html/style.css" />
  98. <script type="text/javascript" >
  99. $(document).ready(function() {
  100. $("#description").markItUp(my_html);
  101. });
  102. </script>
  103. <style type="text/css" media="screen">
  104. @import "<?php echo $conf->urlGelato; ?>/admin/css/style.css";
  105. </style>
  106. </head>
  107. <body>
  108. <div id="cont">
  109. <div id="main">
  110. <div class="box">
  111. <h3><?php echo __("New Post")?></h3>
  112. <ul class="menu">
  113. <?php
  114. switch ($postType) {
  115. case "post":
  116. ?>
  117. <li class="selected"><a href="#"><img src="css/images/page.png" alt="New post" /> <?php echo __("Regular")?></a></li>
  118. <?php
  119. break;
  120. case "photo":
  121. ?>
  122. <li class="selected"><a href="#"><img src="css/images/image.png" alt="New picture" /> <?php echo __("Picture")?></a></li>
  123. <?php
  124. break;
  125. case "url":
  126. ?>
  127. <li class="selected"><a href="#"><img src="css/images/world.png" alt="New link" /> <?php echo __("Link")?></a></li>
  128. <?php
  129. break;
  130. case "video":
  131. ?>
  132. <li class="selected"><a href="#"><img src="css/images/film.png" alt="New video" /> <?php echo __("Video")?></a></li>
  133. <?php
  134. break;
  135. case "mp3":
  136. ?>
  137. <li class="selected"><a href="#"><img src="css/images/music.png" alt="New audio" /> <?php echo __("Audio")?></a></li>
  138. <?php
  139. break;
  140. } ?>
  141. </ul>
  142. <p>&nbsp;</p>
  143. <form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && $_GET["new"]=="photo") ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
  144. <fieldset>
  145. <?php
  146. $date = time();
  147. $title = "";
  148. $body = (isset($_GET["sel"])) ? $_GET["sel"] : "";
  149. $url = (isset($url)) ? $url : "";
  150. switch ($postType) {
  151. case "post":
  152. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editBody}");
  153. $output = array("1", $date, $_SESSION['user_id'], $title, $body);
  154. $template->cargarPlantilla($input, $output, "template_add_post");
  155. $template->mostrarPlantilla();
  156. break;
  157. case "photo":
  158. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  159. $output = array("2", $date, $_SESSION['user_id'], $url, $body);
  160. $template->cargarPlantilla($input, $output, "template_add_photo_bm");
  161. $template->mostrarPlantilla();
  162. break;
  163. case "url":
  164. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editUrl}", "{editBody}");
  165. $output = array("4", $date, $_SESSION['user_id'], $title, $url, $body);
  166. $template->cargarPlantilla($input, $output, "template_add_link");
  167. $template->mostrarPlantilla();
  168. break;
  169. case "video":
  170. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  171. $output = array("6", $date, $_SESSION['user_id'], $url, $body);
  172. $template->cargarPlantilla($input, $output, "template_add_video");
  173. $template->mostrarPlantilla();
  174. break;
  175. case "mp3":
  176. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  177. $output = array("7", $date, $_SESSION['user_id'], $url, $body);
  178. $template->cargarPlantilla($input, $output, "template_add_mp3");
  179. $template->mostrarPlantilla();
  180. break;
  181. } ?>
  182. <p>
  183. <span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
  184. <?php echo __("Some HTML allowed")?>:<br />
  185. &nbsp;&nbsp;&nbsp;&nbsp;
  186. <code>
  187. &lt;strong&gt; &lt;em&gt; &lt;del&gt; &lt;ul&gt; &lt;ol&gt; &lt;li&gt; &lt;a&gt;
  188. <br />
  189. &nbsp;&nbsp;&nbsp;&nbsp;&lt;blockquote&gt;
  190. &lt;code&gt; &lt;pre&gt; &lt;img&gt;
  191. </code>
  192. <br /><br />
  193. </span>
  194. </p>
  195. <p>
  196. <input class="btn" type="submit" name="btnAdd" value="Create post" />
  197. </p>
  198. </fieldset>
  199. </form>
  200. <div class="footer-box">&nbsp;</div>
  201. </div>
  202. </div>
  203. <?php
  204. } ?>
  205. <div id="foot">
  206. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  207. </div>
  208. </div>
  209. </body>
  210. </html>
  211. <?php
  212. } else {
  213. $target = (isset($_GET["url"]))? "/login.php?redirect_url=".$_GET["url"]."&sel=".$_GET["sel"] : "/login.php";
  214. header("Location: ".$conf->urlGelato.$target);
  215. }
  216. ?>