A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 9.8KB

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