A tumblelog CMS built on AJAX, PHP and MySQL.

feeds.php 6.3KB

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