A tumblelog CMS built on AJAX, PHP and MySQL.

feeds.php 6.3KB

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