A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 7.4KB

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