A tumblelog CMS built on AJAX, PHP and MySQL.

feeds.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. if ($user->isAdmin()) {
  14. $message = '';
  15. $f = new feeds();
  16. if (isset($_POST['add'], $_POST['url'])) {
  17. $credits =(isset($_POST['credits']))? 1 : 0;
  18. if ($f->addFeed($_POST['url'], $_POST['type'], $_POST['source'], $credits)) {
  19. $message = __('Feed added');
  20. $messageStatus = 'exito';
  21. }
  22. }
  23. if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
  24. if ($f->removeFeed((int)$_GET['delete'])) {
  25. $message = __('Feed deleted');
  26. $messageStatus = 'error';
  27. }
  28. } ?>
  29. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  30. <html xmlns="http://www.w3.org/1999/xhtml">
  31. <head>
  32. <title>sorbet :: <?php echo __("Feeds")?></title>
  33. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  34. <meta name="generator" content="sorbet cms <?php echo util::version(); ?>" />
  35. <link rel="shortcut icon" href="<?php echo $conf->urlSorbet; ?>/images/favicon.ico" />
  36. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/jquery.js"></script>
  37. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/tools.js"></script>
  38. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlSorbet; ?>/admin/scripts/jquery.validate.min.js"></script>
  39. <script type="text/javascript">
  40. $(document).ready(function(){
  41. $("#divMessages").fadeOut(5000,function(){
  42. $("#divMessages").css({display:"none"});
  43. });
  44. $("#source").change(function (){selectFeedType('<?php echo __("Feed Url:")?>','<?php echo __(" username:")?>')})
  45. $("#feedform").validate({
  46. rules: {
  47. url: {
  48. required: true
  49. }
  50. },
  51. errorElement: "span",
  52. errorClass: "validate_span",
  53. errorPlacement: function(label, element) {
  54. label.prependTo(element.prev())
  55. }
  56. });
  57. });
  58. </script>
  59. <style type="text/css" media="screen">
  60. @import "<?php echo $conf->urlSorbet; ?>/admin/css/style.css";
  61. </style>
  62. </head>
  63. <body>
  64. <div id="cont">
  65. <div id="head">
  66. <h1><a href="<?php echo $conf->urlSorbet; ?>/admin/index.php" title="sorbet :: <?php echo __("home")?>">sorbet cms</a></h1>
  67. <ul id="nav">
  68. <li><a href="<?php echo $conf->urlSorbet; ?>/" title="<?php echo __("Take me to the tumblelog")?>"><?php echo __("Back to the Tumblelog")?></a></li>
  69. </ul>
  70. </div>
  71. <div id="main">
  72. <div class="box">
  73. <h3><?php echo __("Configure your feeds")?></h3>
  74. <ul class="menu manage">
  75. <li><a href="index.php"><?php echo __("Post")?></a></li>
  76. <li><a href="options.php"><?php echo __("Options")?></a></li>
  77. </ul>
  78. <?php echo(!(empty($message))? '<div class="'.$messageStatus.'" id="divMessages"> '.$message.'</div>' : ''); ?>
  79. <div class="tabla">
  80. <form action="feeds.php" method="post" class="newpost" id="feedform">
  81. <fieldset>
  82. <ul>
  83. <li>
  84. <label for="source"><?php echo __("Import data from:")?></label>
  85. <select name="source" id="source">
  86. <option value="Rss" selected="selected">Rss/atom Feed</option>
  87. <option value="Twitter">Twitter</option>
  88. <option value="Youtube">Youtube</option>
  89. <option value="Last.fm">Last.fm</option>
  90. <option value="Tumblr">Tumblr</option>
  91. <option value="Del.icio.us">Del.icio.us</option>
  92. <option value="Wordpress.com">Wordpress.com</option>
  93. <option value="Blogger">Blogger</option>
  94. <option value="VOX">VOX</option>
  95. </select>
  96. </li>
  97. <li id="import_as"><label for="type"><?php echo __("Import As:")?></label>
  98. <select name="type" id="type">
  99. <option value="1" selected="selected"><?php echo __("Text")?></option>
  100. <option value="2"><?php echo __("Photos")?></option>
  101. </select>
  102. </li>
  103. <li>
  104. <label for="url" id="url_label"><?php echo __("Feed Url (double check):")?></label>
  105. <input type="text" name="url" id="url" class="txt" />
  106. </li>
  107. <li><label for="credits"><?php echo __('Show credits on each post?')?></label><input type="checkbox" name="credits" checked="checked" class="check" /></li>
  108. <li>
  109. <input name="add" type="submit" value="<?php echo __("Add"); ?>" />
  110. </li>
  111. </ul>
  112. </fieldset>
  113. </form>
  114. <div id="feedlist">
  115. <ul>
  116. <?php
  117. $actual_feeds = $f->getFeedList();
  118. foreach ($actual_feeds as $feed) {
  119. if ($feed['error']>0) {
  120. echo '<li class="feederror"><a href="feeds.php?delete='.$feed['id_feed'].'" title="'.__('Delete this Feed').'" class="action"><img title="" alt="" src="css/images/delete.png"/></a><span class="status">'.__('Error updating').'</span> '.((!empty($feed['title']))? $feed['title'] : $feed['url']).'</li>';
  121. } else {
  122. echo '<li><a href="feeds.php?delete='.$feed['id_feed'].'" title="'.__('Delete this Feed').'" class="action"><img title="" alt="" src="css/images/delete.png"/></a><span class="status" title="'.__('Last update').': '.$feed['updated_at'].'">'.__('Importing').'</span> '.((!empty($feed['title']))? $feed['title'] : $feed['url']).'</li>';
  123. }
  124. } ?>
  125. </ul>
  126. </div>
  127. </div>
  128. <div class="footer-box">&nbsp;</div>
  129. </div>
  130. </div>
  131. <div id="foot">
  132. Sorbet CMS :: PHP Tumblelog Content Management System.
  133. </div>
  134. </div>
  135. </body>
  136. </html>
  137. <?php
  138. } else {
  139. header("Location: ".$conf->urlSorbet."/login.php");
  140. }
  141. ?>