A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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/".sanitizeName($photoName);
  26. }
  27. if ( move_uploaded_file( $_FILES['photo']['tmp_name'], "../uploads/".sanitizeName($_FILES['photo']['name']) ) ) {
  28. $_POST["url"] = "../uploads/".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. $textile = new Textile();
  49. $_POST["title"] = $textile->TextileThis(removeBadTags($_POST["title"]));
  50. $_POST["description"] = $textile->TextileThis(removeBadTags($_POST["description"]));
  51. if ($tumble->addPost($_POST)) {
  52. $input = array("{type}");
  53. $output = array("1");
  54. $template->cargarPlantilla($input, $output, "template_bm");
  55. $template->mostrarPlantilla();
  56. die();
  57. } else {
  58. header("Location: ".$conf->urlGelato."/admin/index.php?error=2&des=".$this->merror);
  59. die();
  60. }
  61. } else {
  62. if (isset($_GET["url"])) {
  63. $url = $_GET["url"];
  64. } else {
  65. $url = null;
  66. }
  67. if (isset($url)) {
  68. if (isMP3($url)) {
  69. $postType = "mp3";
  70. } elseif (isGoEar($url)) {
  71. $postType = "mp3";
  72. } elseif (isImageFile($url)) {
  73. $postType = "photo";
  74. } elseif (isVideo($url)) {
  75. $postType = "video";
  76. } else {
  77. if (isset($_GET["sel"]) && !$_GET["sel"]=="" ) {
  78. $postType = "post";
  79. } else {
  80. $postType = "url";
  81. }
  82. }
  83. } else {
  84. die(__("Must be a valid URL"));
  85. }
  86. ?>
  87. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  88. <html xmlns="http://www.w3.org/1999/xhtml">
  89. <head>
  90. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  91. <meta name="generator" content="gelato cms <?php echo version();?>" />
  92. <title>gelato :: <?php echo __("bookmarklet")?></title>
  93. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  94. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
  95. <style type="text/css" media="screen">
  96. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  97. </style>
  98. </head>
  99. <body>
  100. <div id="cont">
  101. <div id="main">
  102. <div class="box">
  103. <h3><?php echo __("New Post")?></h3>
  104. <ul class="menu">
  105. <?php
  106. switch ($postType) {
  107. case "post":
  108. ?>
  109. <li class="selected"><a href="#"><img src="css/images/page.png" alt="New post" /> <?php echo __("Regular")?></a></li>
  110. <?php
  111. break;
  112. case "photo":
  113. ?>
  114. <li class="selected"><a href="#"><img src="css/images/image.png" alt="New picture" /> <?php echo __("Picture")?></a></li>
  115. <?php
  116. break;
  117. case "url":
  118. ?>
  119. <li class="selected"><a href="#"><img src="css/images/world.png" alt="New link" /> <?php echo __("Link")?></a></li>
  120. <?php
  121. break;
  122. case "video":
  123. ?>
  124. <li class="selected"><a href="#"><img src="css/images/film.png" alt="New video" /> <?php echo __("Video")?></a></li>
  125. <?php
  126. break;
  127. case "mp3":
  128. ?>
  129. <li class="selected"><a href="#"><img src="css/images/music.png" alt="New audio" /> <?php echo __("Audio")?></a></li>
  130. <?php
  131. break;
  132. }
  133. ?>
  134. </ul>
  135. <p>&nbsp;</p>
  136. <form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && $_GET["new"]=="photo") ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
  137. <fieldset>
  138. <?php
  139. $date = gmmktime();
  140. $title = "";
  141. $body = (isset($_GET["sel"])) ? $_GET["sel"] : "";
  142. $url = (isset($url)) ? $url : "";
  143. switch ($postType) {
  144. case "post":
  145. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editBody}");
  146. $output = array("1", $date, $_SESSION['user_id'], $title, $body);
  147. $template->cargarPlantilla($input, $output, "template_add_post");
  148. $template->mostrarPlantilla();
  149. break;
  150. case "photo":
  151. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  152. $output = array("2", $date, $_SESSION['user_id'], $url, $body);
  153. $template->cargarPlantilla($input, $output, "template_add_photo_bm");
  154. $template->mostrarPlantilla();
  155. break;
  156. case "url":
  157. $input = array("{type}", "{date}", "{id_user}", "{editTitle}", "{editUrl}", "{editBody}");
  158. $output = array("4", $date, $_SESSION['user_id'], $title, $url, $body);
  159. $template->cargarPlantilla($input, $output, "template_add_link");
  160. $template->mostrarPlantilla();
  161. break;
  162. case "video":
  163. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  164. $output = array("6", $date, $_SESSION['user_id'], $url, $body);
  165. $template->cargarPlantilla($input, $output, "template_add_video");
  166. $template->mostrarPlantilla();
  167. break;
  168. case "mp3":
  169. $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
  170. $output = array("7", $date, $_SESSION['user_id'], $url, $body);
  171. $template->cargarPlantilla($input, $output, "template_add_mp3");
  172. $template->mostrarPlantilla();
  173. break;
  174. }
  175. ?>
  176. <p>
  177. <span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;"><a href="http://hobix.com/textile/">Textile</a> <?php echo __("syntax is supported.")?></span>
  178. </p>
  179. <p>
  180. <input class="btn" type="submit" name="btnAdd" value="Create post" />
  181. </p>
  182. </fieldset>
  183. </form>
  184. <div class="footer-box">&nbsp;</div>
  185. </div>
  186. </div>
  187. <?php
  188. }
  189. ?>
  190. <div id="foot">
  191. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  192. </div>
  193. </div>
  194. </body>
  195. </html>
  196. <?php
  197. } else {
  198. header("Location: ".$conf->urlGelato."/login.php");
  199. }
  200. ?>