A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 = 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. if ( move_uploaded_file( $_FILES['photo']['tmp_name'], "../uploads/".sanitizeName($_FILES['photo']['name']) ) ) {
  28. $_POST["url"] = "../uploads/".util::sanitizeName($_FILES['photo']['name']);
  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 = 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::removeBadTags($_POST["title"],true);
  49. $_POST["description"] = util::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::isMP3($url)) {
  68. $postType = "mp3";
  69. } elseif (util::isGoEar($url)) {
  70. $postType = "mp3";
  71. } elseif (util::isImageFile($url)) {
  72. $postType = "photo";
  73. } elseif (util::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. ?>
  86. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  87. <html xmlns="http://www.w3.org/1999/xhtml">
  88. <head>
  89. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  90. <meta name="generator" content="gelato cms <?php echo util::version();?>" />
  91. <title>gelato :: <?php echo __("bookmarklet")?></title>
  92. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  93. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
  94. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
  95. <script type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/markitup/jquery.markitup.pack.js"></script>
  96. <script type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/markitup/sets/html/set.js"></script>
  97. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlGelato;?>/admin/scripts/markitup/skins/simple/style.css" />
  98. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlGelato;?>/admin/scripts/markitup/sets/html/style.css" />
  99. <script type="text/javascript" >
  100. $(document).ready(function() {
  101. $("#description").markItUp(my_html);
  102. });
  103. </script>
  104. <style type="text/css" media="screen">
  105. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  106. </style>
  107. </head>
  108. <body>
  109. <div id="cont">
  110. <div id="main">
  111. <div class="box">
  112. <h3><?php echo __("New Post")?></h3>
  113. <ul class="menu">
  114. <?php
  115. switch ($postType) {
  116. case "post":
  117. ?>
  118. <li class="selected"><a href="#"><img src="css/images/page.png" alt="New post" /> <?php echo __("Regular")?></a></li>
  119. <?php
  120. break;
  121. case "photo":
  122. ?>
  123. <li class="selected"><a href="#"><img src="css/images/image.png" alt="New picture" /> <?php echo __("Picture")?></a></li>
  124. <?php
  125. break;
  126. case "url":
  127. ?>
  128. <li class="selected"><a href="#"><img src="css/images/world.png" alt="New link" /> <?php echo __("Link")?></a></li>
  129. <?php
  130. break;
  131. case "video":
  132. ?>
  133. <li class="selected"><a href="#"><img src="css/images/film.png" alt="New video" /> <?php echo __("Video")?></a></li>
  134. <?php
  135. break;
  136. case "mp3":
  137. ?>
  138. <li class="selected"><a href="#"><img src="css/images/music.png" alt="New audio" /> <?php echo __("Audio")?></a></li>
  139. <?php
  140. break;
  141. }
  142. ?>
  143. </ul>
  144. <p>&nbsp;</p>
  145. <form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && $_GET["new"]=="photo") ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
  146. <fieldset>
  147. <?php
  148. $date = gmmktime();
  149. $title = "";
  150. $body = (isset($_GET["sel"])) ? $_GET["sel"] : "";
  151. $url = (isset($url)) ? $url : "";
  152. switch ($postType) {
  153. case "post":
  154. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editBody}");
  155. $output = array("1", $date, $_SESSION['user_id'], $title, $body);
  156. $template->cargarPlantilla($input, $output, "template_add_post");
  157. $template->mostrarPlantilla();
  158. break;
  159. case "photo":
  160. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  161. $output = array("2", $date, $_SESSION['user_id'], $url, $body);
  162. $template->cargarPlantilla($input, $output, "template_add_photo_bm");
  163. $template->mostrarPlantilla();
  164. break;
  165. case "url":
  166. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editUrl}", "{editBody}");
  167. $output = array("4", $date, $_SESSION['user_id'], $title, $url, $body);
  168. $template->cargarPlantilla($input, $output, "template_add_link");
  169. $template->mostrarPlantilla();
  170. break;
  171. case "video":
  172. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  173. $output = array("6", $date, $_SESSION['user_id'], $url, $body);
  174. $template->cargarPlantilla($input, $output, "template_add_video");
  175. $template->mostrarPlantilla();
  176. break;
  177. case "mp3":
  178. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  179. $output = array("7", $date, $_SESSION['user_id'], $url, $body);
  180. $template->cargarPlantilla($input, $output, "template_add_mp3");
  181. $template->mostrarPlantilla();
  182. break;
  183. }
  184. ?>
  185. <p>
  186. <span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
  187. <?php echo __("Some HTML allowed")?>:<br />
  188. &nbsp;&nbsp;&nbsp;&nbsp;
  189. <code>
  190. &lt;strong&gt; &lt;em&gt; &lt;del&gt; &lt;ul&gt; &lt;ol&gt; &lt;li&gt; &lt;a&gt;
  191. <br />
  192. &nbsp;&nbsp;&nbsp;&nbsp;&lt;blockquote&gt;
  193. &lt;code&gt; &lt;pre&gt; &lt;img&gt;
  194. </code>
  195. <br /><br />
  196. </span>
  197. </p>
  198. <p>
  199. <input class="btn" type="submit" name="btnAdd" value="Create post" />
  200. </p>
  201. </fieldset>
  202. </form>
  203. <div class="footer-box">&nbsp;</div>
  204. </div>
  205. </div>
  206. <?php
  207. }
  208. ?>
  209. <div id="foot">
  210. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  211. </div>
  212. </div>
  213. </body>
  214. </html>
  215. <?php
  216. } else {
  217. $target = (isset($_GET["url"]))? "/login.php?redirect_url=".$_GET["url"]."&sel=".$_GET["sel"] : "/login.php";
  218. header("Location: ".$conf->urlGelato.$target);
  219. }
  220. ?>