A tumblelog CMS built on AJAX, PHP and MySQL.

feeds.php 6.3KB

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