A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 8.3KB

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