A tumblelog CMS built on AJAX, PHP and MySQL.

bm.php 7.2KB

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