New feature: Feed importer, there's some changes in the Db, so you must update, don't forget to chmod(777) the uploads/CACHE dir

master
ravenlp 2007-10-05 00:36:38 +00:00
parent f8da07dc4b
commit f0524983d9
12 changed files with 6115 additions and 290 deletions

View File

@ -69,6 +69,7 @@ form.newpost label{}
form.newpost input{ margin-bottom:10px;} form.newpost input{ margin-bottom:10px;}
form.newpost input.txt{ background: #fff url(images/grad-small.png) top left repeat-x; height:15px; border:1px solid #999; width:490px; padding:5px;} form.newpost input.txt{ background: #fff url(images/grad-small.png) top left repeat-x; height:15px; border:1px solid #999; width:490px; padding:5px;}
form.newpost input.btn{ } form.newpost input.btn{ }
form.newpost input.check{ vertical-align:middle;}
form.newpost textarea{background: #fff url(images/grad-big.png) top left repeat-x; height:190px; border:1px solid #999; width:490px; padding:5px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.8em;} form.newpost textarea{background: #fff url(images/grad-big.png) top left repeat-x; height:190px; border:1px solid #999; width:490px; padding:5px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.8em;}
form.newpost select{ position:absolute; right:10px; top:1px;} form.newpost select{ position:absolute; right:10px; top:1px;}
html > body form.newpost select{min-width:100px;} html > body form.newpost select{min-width:100px;}
@ -107,6 +108,16 @@ legend.install{font: normal 16.5px/17px georgia, "times new roman", serif; borde
a.linkFrm, a.linkFrm:link, a.linkFrm:visited, a.linkFrm:active{ color:#297aab; text-decoration:none; outline:none;} a.linkFrm, a.linkFrm:link, a.linkFrm:visited, a.linkFrm:active{ color:#297aab; text-decoration:none; outline:none;}
a.linkFrm:hover{ text-decoration:underline; color:#297aab; outline:none;} a.linkFrm:hover{ text-decoration:underline; color:#297aab; outline:none;}
/* Feeds */
#feedlist{}
#feedlist ul{ list-style-type:none;}
#feedlist li{ border-bottom:1px solid #999; font-size:12px; padding:2px 4px 2px 4px; margin:0 2px 0 2px;}
#feedlist li span{ font-weight:bold;}
#feedlist li.feederror{ background-color:#FFCCCC;}
#feedlist li.feederror span{ color:#CC0000;}
#feedlist li a img{border:none; padding:0 2px 2px 2px; vertical-align:middle;}
/* User messages */ /* User messages */
.error { width:80%; background: #FFF7F2 url('../../images/error.png') 15px center no-repeat; border-top: 2px solid #CC0000; border-bottom: 2px solid #CC0000; margin: 0 auto; padding: 5px 20px 5px 45px; } .error { width:80%; background: #FFF7F2 url('../../images/error.png') 15px center no-repeat; border-top: 2px solid #CC0000; border-bottom: 2px solid #CC0000; margin: 0 auto; padding: 5px 20px 5px 45px; }

138
admin/feeds.php Normal file
View File

@ -0,0 +1,138 @@
<?php
if(!defined('entry')) define('entry', true);
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */
?>
<?php
require('../entry.php');
global $user, $conf, $tumble;
$template = new plantillas("admin");
$user= new User();
if ($user->isAdmin()) {
$message = '';
$f = new feeds();
if(isset($_POST['add'], $_POST['url'])){
$credits =(isset($_POST['credits']))? 1 : 0;
if($f->addFeed($_POST['url'],$_POST['type'],$_POST['source'], $credits)){
$message = __('Feed added');
$messageStatus = 'exito';
}
}
if(isset($_GET['delete']) && is_numeric($_GET['delete'])){
if($f->removeFeed((int)$_GET['delete'])){
$message = __('Feed deleted');
$messageStatus = 'error';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>gelato :: <?php echo __("Feeds")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/mootools.js"></script>
<style type="text/css" media="screen">
@import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
</style>
</head>
<body>
<div id="cont">
<div id="head">
<h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: <?php echo __("home")?>">gelato cms</a></h1>
<ul id="nav">
<li><a href="<?php echo $conf->urlGelato;?>/" title="<?php echo __("Take me to the tumblelog")?>"><?php echo __("Back to the Tumblelog")?></a></li>
</ul>
</div>
<div id="main">
<div class="box">
<h3><?php echo __("Configure your feeds")?></h3>
<ul class="menu manage">
<li><a href="index.php"><?php echo __("Post")?></a></li>
<li><a href="options.php"><?php echo __("Options")?></a></li>
</ul>
<?php echo (!(empty($message))? '<div class="'.$messageStatus.'" id="divMessages"> '.$message.'</div>' : ''); ?>
<div class="tabla">
<form action="feeds.php" method="post" class="newpost">
<fieldset>
<ul>
<li>
<label for="source"><?php echo __("Import data from:")?></label>
<select name="source" id="source" onchange="selectFeedType('<?php echo __("Feed Url:")?>','<?php echo __(" username:")?>' )">
<option value="Rss" selected="selected">Rss/atom Feed</option>
<option value="Flickr">Flickr</option>
<option value="Twitter">Twitter</option>
<option value="Youtube">Youtube</option>
<option value="Last.fm">Last.fm</option>
<option value="Tumblr">Tumblr</option>
<option value="Wordpress.com">Wordpress.com</option>
<option value="Blogger">Blogger</option>
<option value="VOX">VOX</option>
</select>
</li>
<li id="import_as"><label for="type"><?php echo __("Import As:")?></label>
<select name="type" id="type">
<option value="1" selected="selected"><?php echo __("Text")?></option>
<option value="2"><?php echo __("Photos")?></option>
</select>
</li>
<li>
<label for="url" id="url_label"><?php echo __("Feed Url (double check):")?></label>
<input type="text" name="url" id="url" class="txt" />
</li>
<li><label for="credits"><?php echo __('Show credits on each post?')?></label><input type="checkbox" name="credits" checked="checked" class="check" /></li>
<li>
<input name="add" type="submit" value="<?php echo __("Add"); ?>" />
</li>
</ul>
</fieldset>
</form>
<div id="feedlist">
<ul>
<?php
$actual_feeds = $f->getFeedList();
foreach($actual_feeds as $feed){
if($feed['error']>0){
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>';
}else{
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>';
}
}
?>
</ul>
</div>
</div>
<div class="footer-box">&nbsp;</div>
</div>
</div>
<div id="foot">
<a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
</div>
</div>
</body>
</html>
<?php
} else {
header("Location: ".$conf->urlGelato."/login.php");
}
?>

View File

@ -317,6 +317,7 @@ if ($user->isAdmin()) {
<h3>Manage</h3> <h3>Manage</h3>
<li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php"><?php echo __("Settings")?></a></li> <li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php"><?php echo __("Settings")?></a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/options.php"><?php echo __("Options")?></a></li> <li><a href="<?php echo $conf->urlGelato;?>/admin/options.php"><?php echo __("Options")?></a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/feeds.php"><?php echo __("Feeds")?></a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php"><?php echo __("Users")?></a></li> <li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php"><?php echo __("Users")?></a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/comments.php"><?php echo __("Comments")?></a></li> <li><a href="<?php echo $conf->urlGelato;?>/admin/comments.php"><?php echo __("Comments")?></a></li>
<li class="selected"><a><?php echo __("Posts")?></a></li> <li class="selected"><a><?php echo __("Posts")?></a></li>

View File

@ -53,6 +53,11 @@ if ($user->isAdmin()) {
die(); die();
} }
if (!$tumble->saveOption($_POST["rss_import_frec"], "rss_import_frec")) {
header("Location: ".$conf->urlGelato."/admin/options.php?error=1&des=".$conf->merror);
die();
}
header("Location: ".$conf->urlGelato."/admin/options.php?modified=true"); header("Location: ".$conf->urlGelato."/admin/options.php?modified=true");
die(); die();
} else { } else {
@ -203,8 +208,25 @@ if ($user->isAdmin()) {
</li> </li>
<li class="select"><label for="shorten_links"><?php echo __("Shorten long URLs:")?></label> <li class="select"><label for="shorten_links"><?php echo __("Shorten long URLs:")?></label>
<select name="shorten_links" id="shorten_links"> <select name="shorten_links" id="shorten_links">
<option value="1" <?php if($conf->shorten_links) echo "selected"; ?>><?php echo __("Active")?></option> <option value="1" <?php if($conf->shorten_links) echo "selected=\"selected\""; ?>><?php echo __("Active")?></option>
<option value="0" <?php if(!$conf->shorten_links) echo "selected"; ?>><?php echo __("Deactive")?></option> <option value="0" <?php if(!$conf->shorten_links) echo "selected=\"selected\""; ?>><?php echo __("Deactive")?></option>
</select>
</li>
<li class="select"><label for="rss_import_frec"><?php echo __("Import feeds every:")?></label>
<select name="rss_import_frec" id="rss_import_frec">
<option value="5 minutes" <?php if($conf->rssImportFrec == '5 minutes') echo "selected=\"selected\""; ?>>5 <?php echo __("minutes");?></option>
<option value="10 minutes" <?php if($conf->rssImportFrec == '10 minutes') echo "selected=\"selected\""; ?>>10 <?php echo __("minutes");?></option>
<option value="15 minutes" <?php if($conf->rssImportFrec == '15 minutes') echo "selected=\"selected\""; ?>>15 <?php echo __("minutes");?></option>
<option value="30 minutes" <?php if($conf->rssImportFrec == '30 minutes') echo "selected=\"selected\""; ?>>30 <?php echo __("minutes");?></option>
<option value="45 minutes" <?php if($conf->rssImportFrec == '45 minutes') echo "selected=\"selected\""; ?>>45 <?php echo __("minutes");?></option>
<option value="1 hour" <?php if($conf->rssImportFrec == '1 hour') echo "selected=\"selected\""; ?>>1 <?php echo __("hour");?></option>
<option value="2 hours" <?php if($conf->rssImportFrec == '2 hours') echo "selected=\"selected\""; ?>>2 <?php echo __("hours");?></option>
<option value="3 hours" <?php if($conf->rssImportFrec == '3 hours') echo "selected=\"selected\""; ?>>3 <?php echo __("hours");?></option>
<option value="4 hours" <?php if($conf->rssImportFrec == '4 hours') echo "selected=\"selected\""; ?>>4 <?php echo __("hours");?></option>
<option value="6 hours" <?php if($conf->rssImportFrec == '6 hours') echo "selected=\"selected\""; ?>>6 <?php echo __("hours");?></option>
<option value="12 hours" <?php if($conf->rssImportFrec == '12 hours') echo "selected=\"selected\""; ?>>12 <?php echo __("hours");?></option>
<option value="1 day" <?php if($conf->rssImportFrec == '1 day') echo "selected=\"selected\""; ?>>24 <?php echo __("hours");?></option>
</select> </select>
</li> </li>
</ul> </ul>

View File

@ -29,8 +29,8 @@ class configuration extends Conexion_Mysql {
var $offset_city; var $offset_city;
var $offset_time; var $offset_time;
var $shorten_links; var $shorten_links;
var $rssImportFrec;
function configuration() { function configuration() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
@ -54,6 +54,8 @@ class configuration extends Conexion_Mysql {
$this->offsetTime = $this->get_option("offset_time"); $this->offsetTime = $this->get_option("offset_time");
$this->allowComments = $this->get_option("allow_comments"); $this->allowComments = $this->get_option("allow_comments");
$this->shorten_links = $this->get_option("shorten_links"); $this->shorten_links = $this->get_option("shorten_links");
$this->rssImportFrec = $this->get_option("rss_import_frec");
} else { } else {
if($isFeed) { if($isFeed) {
header("HTTP/1.0 503 Service Unavailable"); header("HTTP/1.0 503 Service Unavailable");

141
classes/feeds.class.php Normal file
View File

@ -0,0 +1,141 @@
<?php
if(!defined('entry') || !entry) die('Not a valid page');
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */
?>
<?php
require_once("configuration.class.php");
require_once("simplepie.class.php");
class feeds extends Conexion_Mysql {
var $conf;
function feeds() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$this->conf = new configuration();
}
function addFeed($url, $type, $source, $credits){
$f = array();
$f['updated_at'] = '0000-00-00 00:00:00';
$f['error'] = 0;
$f['title'] = '';
$f['url'] = '';
$f['credits'] = $credits;
$f['site_url'] = '';
$f['id_user'] = $_SESSION['user_id'];
switch($source){
case 'Rss': $f['url'] = $url; $f['type'] = $type; break;
case 'VOX': $f['url'] = 'http://{{username}}.vox.com/library/posts/atom.xml'; $f['type'] = 1; break;
case 'Digg': $f['url'] = 'http://digg.com/rss/{{username}}/index2.xml'; $f['type'] = 1; break;
case 'Tumblr': $f['url'] = 'http://{{username}}.tumblr.com/rss'; $f['type'] = 1; break;
/*>>*/ case 'Flickr': $f['url'] = 'http:/flickr.com/photos/{{username}}'; $f['type'] = 2; break;
/*>>*/ case 'Twitter': $f['url'] = 'http://twitter.com/{{username}}'; $f['type'] = 1; break;
case 'Last.fm': $f['url'] = 'http://ws.audioscrobbler.com/1.0/user/{{username}}/recenttracks.rss'; $f['type'] = 1; break;
case 'Blogger': $f['url'] = 'http://{{username}}.blogspot.com/feeds/posts/default'; $f['type'] = 1; break;
case 'Youtube': $f['url'] = 'http://www.youtube.com/rss/user/{{username}}/videos.rss'; $f['type'] = 1; break;
case 'Wordpress.com': $f['url'] = 'http://{{username}}.wordpress.com/feed/'; $f['type'] = 1; break;
default : $f['url'] = ''; break;
}
if(!empty($f['url'])){
$f['url'] = str_replace('{{username}}',$url,$f['url']);
return ($this->insertarDeFormulario($this->conf->tablePrefix."feeds", $f));
}
print_r($_POST);
print_r($f);
}
function removeFeed($id){
return ($this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."feeds WHERE id_feed=".$id));
}
function updateFeeds(){
$timeToUpdate = trim($this->conf->rssImportFrec). ' ago';
$feeds = $this->getFeedList("WHERE updated_at < '".date("Y-m-d H:i:s",strtotime($timeToUpdate))."'");
foreach($feeds as $feed){
$data = new SimplePie();
$data->feed_url($feed['url']);
$data->cache_location(Absolute_Path."/uploads/CACHE");
$data->init();
$temp = array();
$temp['updated_at'] = date("Y-m-d H:i:s");
if (!empty($data->error)){
// Error report
$temp['error'] = 1;
$this->modificarDeFormulario($this->conf->tablePrefix."feeds", $temp, 'id_feed = '.$feed['id_feed']);
}else{
if($data->data){
$timeFilter = strtotime($timeToUpdate);
foreach($data->get_items() as $post){
if (strtotime($post->get_date("Y-m-d H:i:s")) > strtotime($feed['updated_at'])) {
$newPost = array();
$newPost['id_user'] = $feed['id_user'];
$newPost['title'] = $post->get_title();
$newPost['date'] = $post->get_date("Y-m-d H:i:s");
if($feed['type'] == 1){ //TEXT
$newPost['type'] = 1;
if($post->get_title() != $post->get_description()){
if(strpos($feed['url'],'twitter.com') <= 0){
$newPost['description'] = $post->get_description();
}
}
}elseif($feed['type'] == 2){ //IMAGES
$ma = array();
$url_image = '';
@preg_match_all('/\<img ([^\>]+)/',$post->get_description(), $ma);
@preg_match_all('/src\=\"([^\"]+)\"/',$ma[0][0], $ma);
$url_image = $ma[1][0];
if(empty($url_image)){
/* Theres no image, lets make a text post */
$newPost['type'] = 1;
if($post->get_title() != $post->get_description()){
if(strpos($feed['url'],'twitter.com') <= 0){
$newPost['description'] = $post->get_description();
}
}
}else{
$newPost['type'] = 2;
$newPost['url'] = $url_image;
$newPost['description'] = $post->get_title();
}
}
if($feed['credits'] == 1 && !empty($feed['title'])){
$newPost['description'] .= '<p class="rss-credits">(via <a href="'.((empty($feed['site_url']))? $feed['url'] : $feed['site_url']).'" title="'.$feed['title'].'">'.$feed['title'].'</a>)</p>';
}
$this->insertarDeFormulario($this->conf->tablePrefix."data", $newPost);
}
}
$temp['title'] = (!empty($data->data['info']['title']))? $data->data['info']['title'] : '';
$temp['site_url'] = (!empty($data->data['info']['link']['alternate'][0]))? $data->data['info']['link']['alternate'][0] : $data->data['info']['link'];
$temp['error'] = 0;
$this->modificarDeFormulario($this->conf->tablePrefix."feeds", $temp, 'id_feed = '.$feed['id_feed']);
}
}
}
}
function getFeedList($condition = ''){
$feeds = array();
$this->ejecutarConsulta('SELECT * FROM '.$this->conf->tablePrefix.'feeds '.$condition.' ORDER BY id_feed DESC');
while($feed = mysql_fetch_assoc($this->mid_consulta)){
$feeds[] = $feed;
}
return $feeds;
}
}
?>

View File

@ -1,280 +1,294 @@
<?php <?php
if(!defined('entry') || !entry) die('Not a valid page'); if(!defined('entry') || !entry) die('Not a valid page');
require('classes/mysql_connection.class.php'); require('classes/mysql_connection.class.php');
class Install { class Install {
var $data = null; var $data = null;
var $errors = null; var $errors = null;
var $showForm; var $showForm;
var $errors_d = array(); var $errors_d = array();
function Install(){ function Install(){
$this->errors_d[1]="The login field cannot be empty"; $this->errors_d[1]="The login field cannot be empty";
$this->errors_d[2]="The password field cannot be empty"; $this->errors_d[2]="The password field cannot be empty";
$this->errors_d[3]="Password does not match the confirm password"; $this->errors_d[3]="Password does not match the confirm password";
$this->errors_d[4]="The e-mail field cannot be empty"; $this->errors_d[4]="The e-mail field cannot be empty";
$this->errors_d[5]="The installation URL field cannot be empty"; $this->errors_d[5]="The installation URL field cannot be empty";
$this->errors_d[6]="Error establishing a database connection"; $this->errors_d[6]="Error establishing a database connection";
$this->errors_d[7]="Please add a hostname for the database server"; $this->errors_d[7]="Please add a hostname for the database server";
$this->errors_d[8]="Please name the database"; $this->errors_d[8]="Please name the database";
} }
function run() { function run() {
if (empty($this->data)) false; if (empty($this->data)) false;
if (!$this->create_config()) return false; if (!$this->create_config()) return false;
$this->create_db(); $this->create_db();
if (!$this->install_db()) return false; if (!$this->install_db()) return false;
return true; return true;
} }
function create_db(){ function create_db(){
$link = mysql_connect($this->data['db_host'], $this->data['db_login'], $this->data['db_password']); $link = mysql_connect($this->data['db_host'], $this->data['db_login'], $this->data['db_password']);
if (!$link) { if (!$link) {
die('Could not connect: ' . mysql_error()); die('Could not connect: ' . mysql_error());
} }
$sql = 'CREATE DATABASE ' . $this->data['db_name']; $sql = 'CREATE DATABASE ' . $this->data['db_name'];
if (!mysql_query($sql, $link)) { if (!mysql_query($sql, $link)) {
$link = mysql_close($link); $link = mysql_close($link);
return false; return false;
} }
return true; return true;
} }
function install_db(){ function install_db(){
require('config.php'); require('config.php');
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); $db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$sqlStr = array(); $sqlStr = array();
$sqlStr[] = "CREATE TABLE `".Table_prefix."data` ( $sqlStr[] = "CREATE TABLE `".Table_prefix."data` (
`id_post` int(11) NOT NULL auto_increment, `id_post` int(11) NOT NULL auto_increment,
`title` text NULL, `title` text NULL,
`url` varchar(250) default NULL, `url` varchar(250) default NULL,
`description` text NULL, `description` text NULL,
`type` tinyint(4) NOT NULL default '1', `type` tinyint(4) NOT NULL default '1',
`date` datetime NOT NULL, `date` datetime NOT NULL,
`id_user` int(10) NOT NULL, `id_user` int(10) NOT NULL,
PRIMARY KEY (`id_post`) PRIMARY KEY (`id_post`)
) ENGINE = MYISAM ;"; ) ENGINE = MYISAM ;";
$sqlStr[] = "CREATE TABLE `".Table_prefix."users` ( $sqlStr[] = "CREATE TABLE `".Table_prefix."users` (
`id_user` int(10) unsigned NOT NULL auto_increment, `id_user` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) default NULL, `name` varchar(100) default NULL,
`login` varchar(100) NOT NULL default '', `login` varchar(100) NOT NULL default '',
`password` varchar(64) NOT NULL default '', `password` varchar(64) NOT NULL default '',
`email` varchar(100) default NULL, `email` varchar(100) default NULL,
`website` varchar(150) default NULL, `website` varchar(150) default NULL,
`about` text, `about` text,
PRIMARY KEY (`id_user`) PRIMARY KEY (`id_user`)
) ENGINE = MYISAM;"; ) ENGINE = MYISAM;";
$sqlStr[] = "CREATE TABLE `".Table_prefix."config` ( $sqlStr[] = "CREATE TABLE `".Table_prefix."config` (
`posts_limit` int(3) NOT NULL, `posts_limit` int(3) NOT NULL,
`title` varchar(250) NOT NULL, `title` varchar(250) NOT NULL,
`description` text NOT NULL, `description` text NOT NULL,
`lang` varchar(10) NOT NULL, `lang` varchar(10) NOT NULL,
`template` varchar(100) NOT NULL, `template` varchar(100) NOT NULL,
`url_installation` varchar(250) NOT NULL, `url_installation` varchar(250) NOT NULL,
PRIMARY KEY (`title`) PRIMARY KEY (`title`)
) ENGINE = MYISAM ;"; ) ENGINE = MYISAM ;";
$sqlStr[] = "CREATE TABLE `".Table_prefix."options` ( $sqlStr[] = "CREATE TABLE `".Table_prefix."options` (
`name` varchar(100) NOT NULL, `name` varchar(100) NOT NULL,
`val` varchar(255) NOT NULL, `val` varchar(255) NOT NULL,
PRIMARY KEY (`name`) PRIMARY KEY (`name`)
) ENGINE = MYISAM ;"; ) ENGINE = MYISAM ;";
$sqlStr[] = "CREATE TABLE `".Table_prefix."comments` ( $sqlStr[] = "CREATE TABLE `".Table_prefix."comments` (
`id_comment` int(11) NOT NULL auto_increment, `id_comment` int(11) NOT NULL auto_increment,
`id_post` int(11) NOT NULL, `id_post` int(11) NOT NULL,
`username` varchar(50) NOT NULL, `username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL, `email` varchar(100) NOT NULL,
`web` varchar(250) default NULL, `web` varchar(250) default NULL,
`content` text NOT NULL, `content` text NOT NULL,
`ip_user` varchar(50) NOT NULL, `ip_user` varchar(50) NOT NULL,
`comment_date` datetime NOT NULL, `comment_date` datetime NOT NULL,
`spam` tinyint(4) NOT NULL, `spam` tinyint(4) NOT NULL,
PRIMARY KEY (`id_comment`) PRIMARY KEY (`id_comment`)
) ENGINE = MYISAM ;"; ) ENGINE = MYISAM ;";
$sqlStr[] = "INSERT INTO `".Table_prefix."config` VALUES (". $this->data['posts_limit'] .", '".$this->data['title']."', '".$this->data['description']."', '".$this->data['lang']."', '".$this->data['template']."', '".$this->data['url_installation']."');"; $sqlStr[] = "CREATE TABLE `".Table_prefix."feeds` (
$sqlStr[] = "INSERT INTO `".Table_prefix."users` VALUES ('', '', '".$this->data['login']."', '".md5($this->data['password'])."', '".$this->data['email']."', '".$this->data['website']."', '".$this->data['about']."');"; `id_feed` int(11) NOT NULL auto_increment,
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');"; `url` varchar(255) NOT NULL,
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');"; `title` varchar(255) NOT NULL,
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');"; `type` tinyint(4) NOT NULL default '1',
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_city', '".$this->data['offset_city']."');"; `updated_at` datetime NOT NULL,
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '".$this->data['offset_time']."');"; `error` tinyint(1) NOT NULL default '0',
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');"; `credits` int(1) NOT NULL default '0',
foreach($sqlStr as $key => $query){ `site_url` varchar(255) NOT NULL,
if(!$db->ejecutarConsulta($query)){ `id_user` int(10) NOT NULL,
return false; PRIMARY KEY (`id_feed`)
} ) ENGINE=MyISAM ;";
}
return true; $sqlStr[] = "INSERT INTO `".Table_prefix."config` VALUES (". $this->data['posts_limit'] .", '".$this->data['title']."', '".$this->data['description']."', '".$this->data['lang']."', '".$this->data['template']."', '".$this->data['url_installation']."');";
} $sqlStr[] = "INSERT INTO `".Table_prefix."users` VALUES ('', '', '".$this->data['login']."', '".md5($this->data['password'])."', '".$this->data['email']."', '".$this->data['website']."', '".$this->data['about']."');";
$sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');";
function inerrors($n) { $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');";
if ( strpos($this->errors,$n)===false) { $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');";
return false; $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_city', '".$this->data['offset_city']."');";
} else { $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '".$this->data['offset_time']."');";
return true; $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');";
} $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rss_import_frec', '5 minutes');";
}
foreach($sqlStr as $key => $query){
function mostrarerror($n) { if(!$db->ejecutarConsulta($query)){
if ($this->inerrors($n)) { return false;
return '<span class="error">'.$this->errors_d[$n].'</span>'; }
} else { }
return "";
} return true;
} }
function is_gelato_installed(){ function inerrors($n) {
if (!$this->check_for_config()){ if ( strpos($this->errors,$n)===false) {
return false; return false;
} else {/* } else {
if (!$this->is_db_installed()){ return true;
return false; }
} }
*/
} function mostrarerror($n) {
if ($this->inerrors($n)) {
return true; return '<span class="error">'.$this->errors_d[$n].'</span>';
} } else {
/* return "";
function is_db_installed(){ }
}
global $db;
function is_gelato_installed(){
if (function_exists($db->ejecutarConsulta)){ if (!$this->check_for_config()){
$sqlStr = "SELECT * FROM `".Table_prefix."config`"; return false;
if($db->ejecutarConsulta($sqlStr)) { } else {
return ($db->contarRegistros() > 0); if (!$this->is_db_installed()){
} return false;
} else { }
false;
} }
} return true;
*/ }
function check_for_config(){
if(!file_exists('config.php')) return false; function is_db_installed(){
if(!defined('DB_Server')) return false; global $db;
if(!defined('DB_name')) return false; if (function_exists($db->ejecutarConsulta)){
if(!defined('DB_User')) return false; $sqlStr = "SELECT * FROM `".Table_prefix."config`";
if(!defined('DB_Password')) return false; if($db->ejecutarConsulta($sqlStr)) {
return ($db->contarRegistros() > 0);
return true; }
} } else {
false;
function create_config(){ }
$config = fopen("config.php", 'w+');
$contents = '<?php }
if(!defined(\'entry\') || !entry) die(\'Not a valid page\');
/* =========================== function check_for_config(){
if(!file_exists('config.php')) return false;
gelato CMS - A PHP based tumblelog CMS if(!defined('DB_Server')) return false;
development version if(!defined('DB_name')) return false;
http://www.gelatocms.com/ if(!defined('DB_User')) return false;
if(!defined('DB_Password')) return false;
gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com> return true;
}
=========================== */
function create_config(){
define(\'DB_Server\', \''. $this->data['db_host'] . '\'); $config = fopen("config.php", 'w+');
define(\'DB_name\', \''. $this->data['db_name'] . '\'); $contents = '<?php
define(\'DB_User\', \''. $this->data['db_login'] . '\'); if(!defined(\'entry\') || !entry) die(\'Not a valid page\');
define(\'DB_Password\', \''. $this->data['db_password'] . '\'); /* ===========================
define(\'Table_prefix\', \'gel_\');
define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR); gelato CMS - A PHP based tumblelog CMS
development version
?>'; http://www.gelatocms.com/
if (fwrite($config, $contents) === FALSE) { gelato CMS is a free software licensed under the GPL 2.0
$this->errors = "Could not write config file to directory"; Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
return false;
} =========================== */
fclose($config);
return true; define(\'DB_Server\', \''. $this->data['db_host'] . '\');
} define(\'DB_name\', \''. $this->data['db_name'] . '\');
define(\'DB_User\', \''. $this->data['db_login'] . '\');
function check_form(){ define(\'DB_Password\', \''. $this->data['db_password'] . '\');
define(\'Table_prefix\', \'gel_\');
$action=""; define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR);
if (isset($this->data['action'])){ ?>';
$action=$this->data['action'];
} if (fwrite($config, $contents) === FALSE) {
$this->errors = "Could not write config file to directory";
if (!$this->is_gelato_installed()){ return false;
}
$this->showForm = true; fclose($config);
return true;
}
if ($action=="config") {
function check_form(){
$sep_err="";
$this->errors = false; $action="";
if (!$this->data['login'] || !$this->data['db_login']) { if (isset($this->data['action'])){
$this->errors =$this->errors.$sep_err."1"; $action=$this->data['action'];
$sep_err="|"; }
}
if (!$this->data['password'] || !$this->data['db_password']) { if (!$this->is_gelato_installed()){
$this->errors=$this->errors.$sep_err."2";
$sep_err="|"; $this->showForm = true;
}
if (!$this->data['email']) {
$this->errors=$this->errors.$sep_err."4"; if ($action=="config") {
$sep_err="|";
} $sep_err="";
if (!$this->data['url_installation'] ) { $this->errors = false;
$this->errors=$this->errors.$sep_err."5";
$sep_err="|"; if (!$this->data['login'] || !$this->data['db_login']) {
} $this->errors =$this->errors.$sep_err."1";
if (!$this->data['db_host'] ) { $sep_err="|";
$this->errors=$this->errors.$sep_err."7"; }
$sep_err="|"; if (!$this->data['password'] || !$this->data['db_password']) {
} $this->errors=$this->errors.$sep_err."2";
if (!$this->data['db_name'] ) { $sep_err="|";
$this->errors=$this->errors.$sep_err."8"; }
$sep_err="|"; if (!$this->data['email']) {
} $this->errors=$this->errors.$sep_err."4";
if ($this->data['password']!=$_POST['password2'] || $_POST['db_password']!=$_POST['db_password2'] ) { $sep_err="|";
$this->errors=$this->errors.$sep_err."3"; }
$sep_err="|"; if (!$this->data['url_installation'] ) {
} $this->errors=$this->errors.$sep_err."5";
$off_r= split("," , $this->data['time_offsets']); $sep_err="|";
$this->data['offset_time'] = $off_r[0]; }
$this->data['offset_city'] = $off_r[1]; if (!$this->data['db_host'] ) {
unset($this->data['time_offsets']); $this->errors=$this->errors.$sep_err."7";
$sep_err="|";
if (!$this->errors) { }
if (!$this->data['db_name'] ) {
if ($this->run($this->data)) { $this->errors=$this->errors.$sep_err."8";
$this->showForm=false; $sep_err="|";
} else { }
$this->errors=$this->errors.$sep_err."6"; if ($this->data['password']!=$_POST['password2'] || $_POST['db_password']!=$_POST['db_password2'] ) {
$sep_err="|"; $this->errors=$this->errors.$sep_err."3";
$this->showForm=true; $sep_err="|";
} }
} else { $off_r= split("," , $this->data['time_offsets']);
$this->showForm=true; $this->data['offset_time'] = $off_r[0];
} $this->data['offset_city'] = $off_r[1];
} unset($this->data['time_offsets']);
}
} if (!$this->errors) {
}
if ($this->run($this->data)) {
$this->showForm=false;
} else {
$this->errors=$this->errors.$sep_err."6";
$sep_err="|";
$this->showForm=true;
}
} else {
$this->showForm=true;
}
}
}
}
}
?> ?>

5449
classes/simplepie.class.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,20 @@ CREATE TABLE `gel_comments` (
PRIMARY KEY (`id_comment`) PRIMARY KEY (`id_comment`)
) ENGINE = MYISAM ; ) ENGINE = MYISAM ;
CREATE TABLE `gel_feeds` (
`id_feed` int(11) NOT NULL auto_increment,
`url` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`type` tinyint(4) NOT NULL default '1',
`updated_at` datetime NOT NULL,
`error` tinyint(1) NOT NULL default '0',
`credits` int(1) NOT NULL default '0',
`site_url` varchar(255) NOT NULL,
`id_user` int(10) NOT NULL,
PRIMARY KEY (`id_feed`)
) ENGINE=MyISAM1 ;
-- Example data for table `gel_config` -- Example data for table `gel_config`
INSERT INTO `gel_config` VALUES (10, 'Tumble title', 'tumble description', 'en', 'tumblr', 'http://localhost/gelato'); INSERT INTO `gel_config` VALUES (10, 'Tumble title', 'tumble description', 'en', 'tumblr', 'http://localhost/gelato');
@ -66,4 +80,5 @@ INSERT INTO `gel_options` VALUES ('url_friendly', '1');
INSERT INTO `gel_options` VALUES ('rich_text', '0'); INSERT INTO `gel_options` VALUES ('rich_text', '0');
INSERT INTO `gel_options` VALUES ('allow_comments', '0'); INSERT INTO `gel_options` VALUES ('allow_comments', '0');
INSERT INTO `gel_options` VALUES ('offset_city', 'Mexico/General'); INSERT INTO `gel_options` VALUES ('offset_city', 'Mexico/General');
INSERT INTO `gel_options` VALUES ('offset_time', '-6'); INSERT INTO `gel_options` VALUES ('offset_time', '-6');
INSERT INTO `gel_options` VALUES ('rss_import_frec', '5 minutes');

View File

@ -19,8 +19,8 @@
* admin/admin.php * admin/admin.php
* admin/comments.php * admin/comments.php
* admin/users.php * admin/users.php
* admin/form.autosave.php
* classes/imgsize.php * classes/imgsize.php
* admin/feeds.php
*/ */
@ -43,6 +43,7 @@ require_once("classes/templates.class.php");
require_once("classes/pagination.class.php"); require_once("classes/pagination.class.php");
require_once("classes/user.class.php"); require_once("classes/user.class.php");
require_once("classes/comments.class.php"); require_once("classes/comments.class.php");
require_once("classes/feeds.class.php");
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'mysql_connection.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'mysql_connection.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'streams.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'streams.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gettext.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gettext.class.php');
@ -55,4 +56,8 @@ $tumble = new gelato();
session_start(); session_start();
$feeds = new feeds();
$feeds->updateFeeds();
unset($feeds);
?> ?>

View File

@ -5,7 +5,7 @@
3) Run the gelato installation script by accessing install.php in your favorite web browser. 3) Run the gelato installation script by accessing install.php in your favorite web browser.
* If you installed gelato in the root directory, you should visit: http://example.com/install.php * If you installed gelato in the root directory, you should visit: http://example.com/install.php
* If you installed gelato in its own subdirectory called tumblelog, for example, you should visit: http://example.com/tumblelog/install.php * If you installed gelato in its own subdirectory called tumblelog, for example, you should visit: http://example.com/tumblelog/install.php
4) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' 4) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' and the folder 'uploads/CACHE'
That's it! gelato should now be installed. That's it! gelato should now be installed.
@ -20,7 +20,7 @@ That's it! gelato should now be installed.
Note: The test data on the script /db/gelato_db.sql use the table prefix 'gel_' Note: The test data on the script /db/gelato_db.sql use the table prefix 'gel_'
6) Place the gelato files in the desired location on your web server. 6) Place the gelato files in the desired location on your web server.
Note: The test data on the script /db/gelato_db.sql point the installation to http://localhost/gelato Note: The test data on the script /db/gelato_db.sql point the installation to http://localhost/gelato
7) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' 7) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' and the folder 'uploads/CACHE'
That's it! gelato should now be installed. That's it! gelato should now be installed.
Demo user: admin Demo user: admin
@ -33,7 +33,7 @@ That's it! gelato should now be installed.
3) Replace all the old files with those from the new 0.90 EXCEPT for the file config.php 3) Replace all the old files with those from the new 0.90 EXCEPT for the file config.php
3.1) If you do replace it by error, use the backup you create during step two. 3.1) If you do replace it by error, use the backup you create during step two.
4) Execute the update.php file. 4) Execute the update.php file.
7) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' 7) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads' and the folder 'uploads/CACHE'
That's it! gelato should now be updated. That's it! gelato should now be updated.

View File

@ -27,7 +27,7 @@ if (!file_exists($configFile)) {
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); $db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');"; /*$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');";
$db->ejecutarConsulta($sqlStr); $db->ejecutarConsulta($sqlStr);
@ -43,7 +43,34 @@ $sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');"
$db->ejecutarConsulta($sqlStr); $db->ejecutarConsulta($sqlStr);
AFTER v0.90 */
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('rss_import_frec', '5 minutes');";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "CREATE TABLE `".Table_prefix."feeds` (
`id_feed` int(11) NOT NULL auto_increment,
`url` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`type` tinyint(4) NOT NULL default '1',
`updated_at` datetime NOT NULL,
`error` tinyint(1) NOT NULL default '0',
`credits` int(1) NOT NULL default '0',
`site_url` varchar(255) NOT NULL,
`id_user` int(10) NOT NULL,
PRIMARY KEY (`id_feed`)
) ENGINE=MyISAM ;";
$db->ejecutarConsulta($sqlStr);
if(!is_dir('upload/CACHE')){
mkdir('upload/CACHE');
chmod('upload/CACHE',777);
}
echo "<p><em>Finished!</em></p>"; echo "<p><em>Finished!</em></p>";
echo "<p>Now you are running on the new <strong>0.90</strong> version!!!</p>"; echo "<p>Now you are running on the new <strong>After 0.90</strong> version!!!</p>";
?> ?>