A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?php
  2. // Script BM (BookMarklet)
  3. if (!defined('entry')) {
  4. define('entry', true);
  5. }
  6. /* ===========================
  7. Sorbet CMS - A PHP based tumblelog CMS forked from Gelato CMS
  8. Sorbet CMS is a free software licensed under the GPL 3.0
  9. =========================== */
  10. ?>
  11. <?php
  12. require '../entry.php';
  13. global $user, $conf, $tumble;
  14. $template = new plantillas("admin");
  15. $util_class = new util();
  16. if ($user->isAdmin()) {
  17. if (isset($_POST["btnAdd"])) {
  18. unset($_POST["btnAdd"]);
  19. if ($_POST["type"]=="2") { // is Photo type
  20. if (isset($_POST["url"]) && $_POST["url"]!="") {
  21. $photoName = $util_class->getFileName($_POST["url"]);
  22. if (!$tumble->savePhoto($_POST["url"])) {
  23. header("Location: ".$conf->urlSorbet."/admin/index.php?photo=false");
  24. die();
  25. }
  26. $_POST["url"] = "../uploads/".$util_class->sanitizeName($photoName);
  27. }
  28. unset($_POST["photo"]);
  29. unset($_POST["MAX_FILE_SIZE"]);
  30. }
  31. if ($_POST["type"]=="7") { // is MP3 type
  32. set_time_limit(300);
  33. $mp3Name = $util_class->getFileName($_POST["url"]);
  34. if (!$tumble->saveMP3($_POST["url"])) {
  35. header("Location: ".$conf->urlSorbet."/admin/index.php?mp3=false");
  36. die();
  37. }
  38. if (isMP3($remoteFileName)) {
  39. $_POST["url"] = $conf->urlSorbet."/uploads/".$mp3Name;
  40. }
  41. }
  42. if (!get_magic_quotes_gpc()) {
  43. $_POST["title"] = addslashes($_POST["title"]);
  44. $_POST["description"] = addslashes($_POST["description"]);
  45. }
  46. $_POST["title"] = $util_class->removeBadTags($_POST["title"], true);
  47. $_POST["description"] = $util_class->removeBadTags($_POST["description"]);
  48. if ($tumble->addPost($_POST)) {
  49. $input = array("{type}");
  50. $output = array("1");
  51. $template->cargarPlantilla($input, $output, "template_bm");
  52. $template->mostrarPlantilla();
  53. die();
  54. } else {
  55. header("Location: ".$conf->urlSorbet."/admin/index.php?error=2&des=".$this->merror);
  56. die();
  57. }
  58. } else {
  59. if (isset($_GET["url"])) {
  60. $url = $_GET["url"];
  61. } else {
  62. $url = null;
  63. }
  64. if (isset($url)) {
  65. if ($util_class->isMP3($url)) {
  66. $postType = "mp3";
  67. } elseif ($util_class->isGoEar($url)) {
  68. $postType = "mp3";
  69. } elseif ($util_class->isImageFile($url)) {
  70. $postType = "photo";
  71. } elseif ($util_class->isVideo($url)) {
  72. $postType = "video";
  73. } else {
  74. if (isset($_GET["sel"]) && !$_GET["sel"]=="") {
  75. $postType = "post";
  76. } else {
  77. $postType = "url";
  78. }
  79. }
  80. } else {
  81. die(__("Must be a valid URL"));
  82. } ?>
  83. <!DOCTYPE html>
  84. <html>
  85. <head>
  86. <meta charset="utf-8" />
  87. <meta name="generator" content="Sorbet CMS <?= $util_class->version(); ?>" />
  88. <title><?= __("bookmarklet")?> - Sorbet CMS</title>
  89. <link rel="shortcut icon" href="<?php echo $conf->urlSorbet; ?>/images/favicon.ico" />
  90. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/jquery.js"></script>
  91. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/tools.js"></script>
  92. <script type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/markitup/jquery.markitup.pack.js"></script>
  93. <script type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/markitup/sets/html/set.js"></script>
  94. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlSorbet; ?>/admin/scripts/markitup/skins/simple/style.css" />
  95. <link rel="stylesheet" type="text/css" href="<?php echo $conf->urlSorbet; ?>/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->urlSorbet; ?>/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. </ul>
  140. <p>&nbsp;</p>
  141. <form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && ($_GET["new"]=="photo" || $_GET["new"]=="mp3")) ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
  142. <fieldset>
  143. <?php
  144. $date = time();
  145. $title = "";
  146. $body = (isset($_GET["sel"])) ? $_GET["sel"] : "";
  147. $url = (isset($url)) ? $url : "";
  148. switch ($postType) {
  149. case "post":
  150. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editBody}");
  151. $output = array("1", $date, $_SESSION['user_id'], $title, $body);
  152. $template->cargarPlantilla($input, $output, "template_add_post");
  153. $template->mostrarPlantilla();
  154. break;
  155. case "photo":
  156. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  157. $output = array("2", $date, $_SESSION['user_id'], $url, $body);
  158. $template->cargarPlantilla($input, $output, "template_add_photo_bm");
  159. $template->mostrarPlantilla();
  160. break;
  161. case "url":
  162. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editUrl}", "{editBody}");
  163. $output = array("4", $date, $_SESSION['user_id'], $title, $url, $body);
  164. $template->cargarPlantilla($input, $output, "template_add_link");
  165. $template->mostrarPlantilla();
  166. break;
  167. case "video":
  168. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  169. $output = array("6", $date, $_SESSION['user_id'], $url, $body);
  170. $template->cargarPlantilla($input, $output, "template_add_video");
  171. $template->mostrarPlantilla();
  172. break;
  173. case "mp3":
  174. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  175. $output = array("7", $date, $_SESSION['user_id'], $url, $body);
  176. $template->cargarPlantilla($input, $output, "template_add_mp3_bm");
  177. $template->mostrarPlantilla();
  178. break;
  179. } ?>
  180. <p>
  181. <span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
  182. <?php echo __("Some HTML allowed")?>:<br />
  183. &nbsp;&nbsp;&nbsp;&nbsp;
  184. <code>
  185. &lt;strong&gt; &lt;em&gt; &lt;del&gt; &lt;ul&gt; &lt;ol&gt; &lt;li&gt; &lt;a&gt;
  186. <br />
  187. &nbsp;&nbsp;&nbsp;&nbsp;&lt;blockquote&gt;
  188. &lt;code&gt; &lt;pre&gt; &lt;img&gt;
  189. </code>
  190. <br /><br />
  191. </span>
  192. </p>
  193. <p>
  194. <input class="btn" type="submit" name="btnAdd" value="Create post" />
  195. </p>
  196. </fieldset>
  197. </form>
  198. <div class="footer-box">&nbsp;</div>
  199. </div>
  200. </div>
  201. <?php
  202. } ?>
  203. <div id="foot">
  204. Sorbet CMS - PHP Tumblelog Content Management System.
  205. </div>
  206. </div>
  207. </body>
  208. </html>
  209. <?php
  210. } else {
  211. $target = (isset($_GET["url"]))? "/login.php?redirect_url=".$_GET["url"]."&sel=".$_GET["sel"] : "/login.php";
  212. header("Location: ".$conf->urlSorbet.$target);
  213. }