master
pecesama 2007-07-12 05:17:52 +00:00
parent 54c4eb203c
commit 12a7f489fa
23 changed files with 648 additions and 252 deletions

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -11,6 +12,7 @@
<?php
require_once('../config.php');
include("../classes/user.class.php");
include("../classes/functions.php");
require_once("../classes/configuration.class.php");
$user = new user();
@ -24,6 +26,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: admin users</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/mootools.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/sortable.js"></script>

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -10,54 +11,64 @@
?>
<?php
require_once('../config.php');
include("../classes/functions.php");
include("../classes/user.class.php");
require_once("../classes/configuration.class.php");
session_start();
$user = new user();
$conf = new configuration();
$user->closeSession()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!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</title>
<title>gelato :: logout</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="../images/favicon.ico" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta http-equiv="Refresh" content="3;URL=../login.php" />
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
<style type="text/css" media="screen">
@import "css/style-codice.css";
@import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
</style>
</head>
<body>
<div id="titulo">
<img src="../images/logo.jpg" alt="gelato CMS" title="gelato CMS" />
<div id="cont">
<div id="head">
<h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: home">gelato cms</a></h1>
<ul id="nav">
<li><a href="<?php echo $conf->urlGelato;?>/" title="Take me to the tumblelog">Back to the Tumblelog</a></li>
</ul>
</div>
<div id="main">
<div id="contenido">
<div class="piccola">
<div class="ventana">
<p class="titulo"><span class="handle" style="cursor:move;">Closing session</span></p>
<div class="box">
<ul class="menu manage">
<h3>Closing session</h3>
<li class="selected"><a>logoff</a></li>
</ul>
<div class="tabla">
<p>
<?php
if (@session_destroy()) {
?>
</p>
<h3>Ending session...</h3>
<h2>Ending session...</h2>
<?php
} else {
?>
<h3>Has happened an error when closing the session.</h3>
<h2>Has happened an error when closing the session.</h2>
<?php
}
?>
</p>
</div>
<div class="footer-box">&nbsp;</div>
</div>
<div id="pie">
<p>
</div>
<div id="foot">
<a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
</p>
</div>
</div>
</div>
</body>

View File

@ -1,6 +1,7 @@
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -12,7 +13,7 @@
require_once('../config.php');
include("../classes/functions.php");
include("../classes/user.class.php");
include("../classes/pagination.php");
include("../classes/pagination.class.php");
include("../classes/gelato.class.php");
include("../classes/textile.class.php");
include("../classes/templates.class.php");
@ -98,6 +99,7 @@ if ($user->isAdmin()) {
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<title>gelato :: control panel</title>
<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>
@ -315,6 +317,7 @@ if ($user->isAdmin()) {
<ul class="menu manage">
<h3>Manage</h3>
<li><a href="<?php echo $conf->urlGelato;?>/admin/settings.php">Settings</a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/options.php">Options</a></li>
<li><a href="<?php echo $conf->urlGelato;?>/admin/admin.php">Users</a></li>
<li class="selected"><a>Posts</a></li>
</ul>
@ -408,7 +411,11 @@ if ($user->isAdmin()) {
}
}
echo pagination($tumble->getPostsNumber(), $limit, isset($page_num) ? $page_num : 1, "index.php", 2);
$p = new pagination;
$p->items($tumble->getPostsNumber());
$p->limit($limit);
$p->currentPage(isset($page_num) ? $page_num : 1);
$p->show();
} else {

128
admin/options.php Normal file
View File

@ -0,0 +1,128 @@
<?php
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
=========================== */
?>
<?php
require_once('../config.php');
include("../classes/functions.php");
include("../classes/user.class.php");
include("../classes/gelato.class.php");
require_once("../classes/configuration.class.php");
$user = new user();
$tumble = new gelato();
$conf = new configuration();
if ($user->isAdmin()) {
if(isset($_POST["btnsubmit"])) {
unset($_POST["btnsubmit"]);
$tumble->saveOption($_POST["rich_text"], "rich_text");
$tumble->saveOption($_POST["urlFriendly"], "rich_text");
} else {
?>
<!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 :: options</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/mootools.js"></script>
<script type="text/javascript">
<!--
window.onload = function() {
contenedor = new Fx.Style('divMessages', 'opacity', {duration: 5000, onComplete:
function() {
document.getElementById('divMessages').style.display="none";
}
});
contenedor.custom(1,0);
}
-->
</script>
<style type="text/css" media="screen">
@import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
</style>
</head>
<body>
<div id="div-process" style="display:none;">Processing request...</div>
<div id="cont">
<div id="head">
<h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: home">gelato cms</a></h1>
<ul id="nav">
<li><a href="<?php echo $conf->urlGelato;?>/" title="Take me to the tumblelog">Back to the Tumblelog</a></li>
</ul>
</div>
<div id="main">
<div class="box">
<ul class="menu manage">
<h3>Tumblelog options</h3>
<li><a href="index.php">Post</a></li>
<li><a href="admin.php">Users</a></li>
<li><a href="settings.php">Settings</a></li>
<li class="selected"><a>Options</a></li>
</ul>
<p>&nbsp;</p>
<?php
if (isset($_GET["modified"])) {
if ($_GET["modified"]=="true") {
echo "<div class=\"exito\" id=\"divMessages\">The configuration has been modified successfully.</div>";
}
}
if (isset($_GET["error"])) {
if ($_GET["error"]==1) {
echo "<div class=\"error\" id=\"divMessages\"><strong>Error on the database server: </strong>".$_GET["des"]."</div>";
}
}
?>
<div class="tabla">
<form action="options.php" method="post" id="options_form" autocomplete="off" class="newpost">
<fieldset>
<ul>
<li><label for="rich_text">Rich text editor:</label>
<select name="rich_text" id="rich_text">
<option value="1" <?php if($conf->richText) echo "selected"; ?>>Active</option>
<option value="0" <?php if(!$conf->richText) echo "selected"; ?>>Deactive</option>
</select>
</li>
<li><label for="rich_text">URL friendly:</label>
<select name="url_friendly" id="url_friendly">
<option value="1" <?php if($conf->urlFriendly) echo "selected"; ?>>Active</option>
<option value="0" <?php if(!$conf->urlFriendly) echo "selected"; ?>>Deactive</option>
</select>
</li>
</ul>
</fieldset>
<p>
<input type="submit" name="btnsubmit" id="btnsubmit" value="Modify" class="submit"/>
</p>
</form>
</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

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -32,6 +33,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: settings</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/mootools.js"></script>
<script type="text/javascript">
@ -67,6 +69,7 @@ if ($user->isAdmin()) {
<h3>Tumblelog configuration</h3>
<li><a href="index.php">Post</a></li>
<li><a href="admin.php">Users</a></li>
<li><a href="options.php">Options</a></li>
<li class="selected"><a>Settings</a></li>
</ul>
<p>&nbsp;</p>
@ -105,23 +108,16 @@ if ($user->isAdmin()) {
<?php
$themes = getThemes();
foreach ($themes as $theme) {
echo "<option value=\"".$theme."\" selected=\"true\">".$theme."</option>\n";
$active = ($conf->template) ? "selected" : "";
echo "<option value=\"".$theme."\" ".$active.">".$theme."</option>\n";
}
?>
</select>
</li>
<li><label for="rich_text">Rich text editor:</label>
<select name="rich_text" id="rich_text">
<option value="1" <?php if($conf->richText) echo "selected"; ?>>Active</option>
<option value="0" <?php if(!$conf->richText) echo "selected"; ?>>Deactive</option>
</select>
</li>
</ul>
</fieldset>
<p>
<input type="hidden" name="url_friendly" id="url_friendly" value="0" />
<input type="submit" name="btnsubmit" id="btnsubmit" value="Modify" class="submit"/>
</p>
</form>

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -53,6 +54,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: add user</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/mootools.js"></script>
<script language="javascript" type="text/javascript">

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -18,28 +19,51 @@ class configuration extends Conexion_Mysql {
var $title;
var $description;
var $lang;
var $template;
var $urlFriendly;
var $richText;
var $template;
function configuration() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
global $isFeed;
if ($this->ejecutarConsulta("SELECT * FROM ".Table_prefix."config")) {
if ($this->contarRegistros()>0) {
$register=$this->obtenerRegistro();
$row=$this->obtenerRegistro();
$this->tablePrefix = Table_prefix;
$this->urlGelato = $register['url_installation'];
$this->postLimit = $register['posts_limit'];
$this->title = $register['title'];
$this->description = $register['description'];
$this->lang = $register['lang'];
$this->urlFriendly = $register['url_friendly'];
$this->richText = $register['rich_text'];
$this->template = $register['template'];
$this->urlGelato = $row['url_installation'];
$this->postLimit = $row['posts_limit'];
$this->title = $row['title'];
$this->description = $row['description'];
$this->lang = $row['lang'];
$this->template = $row['template'];
$this->urlFriendly = $this->get_option("url_friendly");
$this->richText = $this->get_option("rich_text");
} else {
if($isFeed) {
header("HTTP/1.0 503 Service Unavailable");
header("Retry-After: 60");
exit();
} else {
$message = "
<h3 class=\"important\">Error establishing a database connection</h3>
<p>The configuration info is not available.</p>";
die($message);
}
}
}
function get_option($name){
$sql = "SELECT * FROM ".Table_prefix."options WHERE name='".$name."' LIMIT 1";
$this->ejecutarConsulta($sql);
if ($this->contarRegistros()>0) {
$row=$this->obtenerRegistro();
return $row['val'];
} else {
return "0";
}
}
}
?>

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -10,7 +11,7 @@
?>
<?php
function version() {
return "0.8";
return "0.85";
}
function beginsWith($str, $sub) {

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -30,6 +31,17 @@ class gelato extends Conexion_Mysql {
}
}
function saveOption($value, $name) {
$sqlStr = "UPDATE ".$this->conf->tablePrefix."options SET val='".$value."' WHERE name='".$name."' LIMIT 1";
if ($this->ejecutarConsulta($sqlStr)) {
header("Location: ".$this->conf->urlGelato."/admin/options.php?modified=true");
die();
} else {
header("Location: ".$this->conf->urlGelato."/admin/options.php?error=1&des=".$this->merror);
die();
}
}
function addPost($fieldsArray) {
if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
return true;

View File

@ -0,0 +1,195 @@
<?php
class pagination{
/*
Script Name: *Digg Style Paginator Class
Script URI: http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/
Description: Class in PHP that allows to use a pagination like a digg or sabrosus style.
Script Version: 0.3
Author: Victor De la Rocha
Author URI: http://www.mis-algoritmos.com
*/
/*Default values*/
var $total_pages = null;
var $limit = null;
var $target = "";
var $page = 1;
var $adjacents = 2;
var $showCounter = false;
var $className = "pagination";
var $parameterName = "page";
var $urlF = false;//urlFriendly
/*Buttons next and previous*/
var $nextT = "Next";
var $nextI = "&#187;"; //&#9658;
var $prevT = "Previous";
var $prevI = "&#171;"; //&#9668;
/*****/
var $calculate = false;
#Total items
function items($value){$this->total_pages = intval($value);}
#how many items to show per page
function limit($value){$this->limit = intval($value);}
#Page to sent the page value
function target($value){$this->target = $value;}
#Current page
function currentPage($value){$this->page = intval($value);}
#How many adjacent pages should be shown on each side of the current page?
function adjacents($value){$this->adjacents = intval($value);}
#show counter?
function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
#to change the class name of the pagination div
function changeClass($value=""){$this->className=$value;}
function nextLabel($value){$this->nextT = $value;}
function nextIcon($value){$this->nextI = $value;}
function prevLabel($value){$this->prevT = $value;}
function prevIcon($value){$this->prevI = $value;}
#to change the class name of the pagination div
function parameterName($value=""){$this->parameterName=$value;}
#to change urlFriendly
function urlFriendly($value="%"){
if(eregi('^ *$',$value)){
$this->urlF=false;
return false;
}
$this->urlF=$value;
}
var $pagination;
function pagination(){}
function show(){
if(!$this->calculate)
if($this->calculate())
echo "<div class=\"$this->className\">$this->pagination</div>";
}
function get_pagenum_link($id){
if(strpos($this->target,'?')===false)
if($this->urlF)
return str_replace($this->urlF,$id,$this->target);
else
return "$this->target?$this->parameterName=$id";
else
return "$this->target&$this->parameterName=$id";
}
function calculate(){
$this->pagination = "";
$this->calculate == true;
$error = false;
if($this->urlF and $this->urlF != '%' and strpos($this->target,$this->urlF)===false){
//Es necesario especificar el comodin para sustituir
echo "Especificaste un wildcard para sustituir, pero no existe en el target<br />";
$error = true;
}elseif($this->urlF and $this->urlF == '%' and strpos($this->target,$this->urlF)===false){
echo "Es necesario especificar en el target el comodin % para sustituir el número de página<br />";
$error = true;
}
if($this->total_pages == null){
echo "It is necessary to specify the <strong>number of pages</strong> (\$class->items(1000))<br />";
$error = true;
}
if($this->limit == null){
echo "It is necessary to specify the <strong>limit of items</strong> to show per page (\$class->limit(10))<br />";
$error = true;
}
if($error)return false;
$n = trim($this->nextT.' '.$this->nextI);
$p = trim($this->prevI.' '.$this->prevT);
/* Setup vars for query. */
if($this->page)
$start = ($this->page - 1) * $this->limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($this->page == 0) $this->page = 1; //if no page var is given, default to 1.
$prev = $this->page - 1; //previous page is page - 1
$next = $this->page + 1; //next page is page + 1
$lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
if($lastpage > 1){
//anterior button
if($this->page > 1)
$this->pagination .= "<a href=\"".$this->get_pagenum_link($prev)."\">$p</a>";
else
$this->pagination .= "<span class=\"disabled\">$p</span>";
//pages
if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
for ($counter = 1; $counter <= $lastpage; $counter++){
if ($counter == $this->page)
$this->pagination .= "<span class=\"current\">$counter</span>";
else
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
}
}
elseif($lastpage > 5 + ($this->adjacents * 2)){//enough pages to hide some
//close to beginning; only hide later pages
if($this->page < 1 + ($this->adjacents * 2)){
for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++){
if ($counter == $this->page)
$this->pagination .= "<span class=\"current\">$counter</span>";
else
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
}
$this->pagination .= "...";
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)){
$this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
$this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
$this->pagination .= "...";
for ($counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter++)
if ($counter == $this->page)
$this->pagination .= "<span class=\"current\">$counter</span>";
else
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
$this->pagination .= "...";
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
}
//close to end; only hide early pages
else{
$this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
$this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
$this->pagination .= "...";
for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++)
if ($counter == $this->page)
$this->pagination .= "<span class=\"current\">$counter</span>";
else
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
}
}
//siguiente button
if ($this->page < $counter - 1)
$this->pagination .= "<a href=\"".$this->get_pagenum_link($next)."\">$n</a>";
else
$this->pagination .= "<span class=\"disabled\">$n</span>";
if($this->showCounter)$this->pagination .= "<div class=\"pagination_data\">($this->total_pages Pages)</div>";
}
return true;
}
}
?>

View File

@ -1,138 +0,0 @@
<?php
/*
Digg-Style Pagination
Autor: jason (http://www.strangerstudios.com/blog/2006/12/29/pagination-update/)
Update: Victor De la Rocha (http://www.mis-algoritmos.com/2006/11/23/paginacion-al-estilo-digg-y-sabrosus/)
*/
function pagination($total_pages,$limit,$page=1,$pagina="default.php",$adjacents=2){
/*
$adjacents -> How many adjacent pages should be shown on each side?
$total_pages -> items
$limit -> how many items to show per page
$page -> Current page
$pagina -> Pagina
*/
if(!is_array($pagina)&&!strstr($pagina,"?"))
$pagina = $pagina."?";
/* Setup vars for query. */
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1){
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$prev,$pagina[0]):$pagina."&page=$prev";
$pagination.= "<a href=\"".$pagina_uf."\"> Previous</a>";
}else
$pagination.= "<span class=\"disabled\"> Previous</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$counter,$pagina[0]):$pagina."&page=$counter";
$pagination.= "<a href=\"".$pagina_uf."\">$counter</a>";
}
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$counter,$pagina[0]):$pagina."&page=$counter";
$pagination.= "<a href=\"".$pagina_uf."\">$counter</a>";
}
}
$pagination.= "...";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$lpm1,$pagina[0]):$pagina."&page=$lpm1";
$pagination.= "<a href=\"".$pagina_uf."\">$lpm1</a>";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$counter,$pagina[0]):$pagina."&page=$counter";
$pagination.= "<a href=\"".$pagina_uf."\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],1,$pagina[0]):$pagina."&page=1";
$pagination.= "<a href=\"".$pagina_uf."\">1</a>";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],2,$pagina[0]):$pagina."&page=2";
$pagination.= "<a href=\"".$pagina_uf."\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$counter,$pagina[0]):$pagina."&page=$counter";
$pagination.= "<a href=\"".$pagina_uf."\">$counter</a>";
}
}
$pagination.= "...";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$lpm1,$pagina[0]):$pagina."&page=$lpm1";
$pagination.= "<a href=\"".$pagina_uf."\">$lpm1</a>";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$lastpage,$pagina[0]):$pagina."&page=$lastpage";
$pagination.= "<a href=\"".$pagina_uf."\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],1,$pagina[0]):$pagina."&page=1";
$pagination.= "<a href=\"".$pagina_uf."&page=1\">1</a>";
$pagina_uf = is_array($pagina)?str_replace($pagina[1],2,$pagina[0]):$pagina."&page=2";
$pagination.= "<a href=\"".$pagina_uf."&page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else{
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$counter,$pagina[0]):$pagina."&page=$counter";
$pagination.= "<a href=\"".$pagina_uf."\">$counter</a>";
}
}
}
}
//next button
if ($page < $counter - 1) {
$pagina_uf = is_array($pagina)?str_replace($pagina[1],$next,$pagina[0]):$pagina."&page=$next";
$pagination.= "<a href=\"".$pagina_uf."\">Next </a>";
}
else
$pagination.= "<span class=\"disabled\">Next </span>";
$pagination.= "</div>\n";
}
return $pagination;
}
?>

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)

View File

@ -1,3 +1,5 @@
-- DB Gelato CMS v0.85
CREATE TABLE `gel_data` (
`id_post` int(11) NOT NULL auto_increment,
`title` text NULL,
@ -27,15 +29,38 @@ CREATE TABLE `gel_config` (
`lang` varchar(10) NOT NULL,
`template` varchar(100) NOT NULL,
`url_installation` varchar(250) NOT NULL,
`url_friendly` tinyint(1) NOT NULL,
`rich_text` tinyint(1) NOT NULL,
PRIMARY KEY (`title`)
) ENGINE = MYISAM ;
CREATE TABLE `gel_options` (
`name` varchar(100) NOT NULL,
`val` varchar(255) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE = MYISAM ;
CREATE TABLE `gel_comments` (
`id_comment` int(11) NOT NULL auto_increment,
`id_post` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`web` varchar(250) default NULL,
`content` text NOT NULL,
`ip_user` varchar(50) NOT NULL,
`comment_date` datetime NOT NULL,
`spam` tinyint(4) NOT NULL,
PRIMARY KEY (`id_comment`)
) ENGINE = MYISAM ;
-- Example data for table `gel_config`
INSERT INTO `gel_config` VALUES (10, 'Tumble title', 'tumble description', 'en', 'tumblr', 'http://localhost/gelato', 1, 1);
INSERT INTO `gel_config` VALUES (10, 'Tumble title', 'tumble description', 'en', 'tumblr', 'http://localhost/gelato');
-- Example data for table `gel_users`
-- The password is "demo" without the "
INSERT INTO `gel_users` VALUES (1, 'System administrator', 'admin', 'fe01ce2a7fbac8fafaed7c982a04e229', 'correo@correo.com', 'page', 'about');
-- Example data for table `gel_options`
INSERT INTO `gel_options` VALUES ('url_friendly', '1');
INSERT INTO `gel_options` VALUES ('rich_text', '0');

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -27,7 +28,7 @@
include("classes/textile.class.php");
include("classes/gelato.class.php");
include("classes/templates.class.php");
include("classes/pagination.php");
include("classes/pagination.class.php");
include("classes/user.class.php");
$user = new user();
@ -57,12 +58,14 @@
}
}
$gelato_includes = "<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/mootools.js\"></script>\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/slimbox.js\"></script>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/slimbox.css\" />\n";
$gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
$gelato_includes .= "\t<meta name=\"generator\" content=\"gelato cms ".version()."\" />\n";
$gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n";
$gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato."/rss.php\"/>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n";
$gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato."/rss.php\"/>";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/slimbox.css\" />\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/mootools.js\"></script>\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/slimbox.js\"></script>";
$input = array("{Gelato_includes}","{Title}", "{Description}", "{URL_Tumble}", "{Template_name}");
$output = array($gelato_includes, $conf->title, $conf->description, $conf->urlGelato, $conf->template);
@ -164,7 +167,15 @@
}
}
echo pagination($tumble->getPostsNumber(), $limit, isset($page_num) ? $page_num : 1, array($conf->urlGelato."/index.php/page/[...]/","[...]"), 2);
$p = new pagination;
$p->Items($tumble->getPostsNumber());
$p->limit($limit);
$p->urlFriendly('[...]');
$p->target($conf->urlGelato."/index.php/page/[...]/");
$p->currentPage(isset($page_num) ? $page_num : 1);
$p->show();
} else {

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -67,8 +68,7 @@ if ($action=="config") {
if (!$errors) {
if (installdb($_POST['login'], $_POST['password'], $_POST['email'], $_POST['title'], $_POST['description'], $_POST['url_installation'], $_POST['posts_limit'], $_POST['lang'], $_POST['template'], $_POST['website'], $_POST['about'], $_POST['url_friendly'], $_POST['rich_text'])) {
if (install_db($_POST['login'], $_POST['password'], $_POST['email'], $_POST['title'], $_POST['description'], $_POST['url_installation'], $_POST['posts_limit'], $_POST['lang'], $_POST['template'], $_POST['website'], $_POST['about'])) {
$showForm=false;
} else {
$errors=$errors.$sep_err."6";
@ -85,8 +85,8 @@ if ($action=="config") {
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<title>gelato :: installation</title>
<meta name="generator" content="sabros.us <?php echo version();?>" />
<link rel="shortcut icon" href="images/favicon.ico" />
<style type="text/css" media="screen">
@import "admin/css/style.css";
@ -159,8 +159,6 @@ if ($action=="config") {
<p>
<input type="hidden" name="website" id="website" value="" />
<input type="hidden" name="about" id="about" value="" />
<input type="hidden" name="url_friendly" id="url_friendly" value="0" />
<input type="hidden" name="rich_text" id="rich_text" value="0" />
<input type="hidden" name="action" id="action" value="config" />
<input type="submit" name="btnsubmit" id="btnsubmit" value="<< Install >>" class="submit"/>
</p>
@ -186,7 +184,7 @@ if ($action=="config") {
</html>
<?php
function installdb($login, $password, $email, $title, $description, $url_installation, $posts_limit, $lang, $template, $website, $about, $url_friendly, $rich_text){
function install_db($login, $password, $email, $title, $description, $url_installation, $posts_limit, $lang, $template, $website, $about){
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
@ -223,16 +221,37 @@ function installdb($login, $password, $email, $title, $description, $url_install
`lang` varchar(10) NOT NULL,
`template` varchar(100) NOT NULL,
`url_installation` varchar(250) NOT NULL,
`url_friendly` tinyint(1) NOT NULL,
`rich_text` tinyint(1) NOT NULL,
PRIMARY KEY (`title`)
) ENGINE = MYISAM ;";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "CREATE TABLE `".Table_prefix."options` (
`name` varchar(100) NOT NULL,
`val` varchar(255) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE = MYISAM ;";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "CREATE TABLE `".Table_prefix."comments` (
`id_comment` int(11) NOT NULL auto_increment,
`id_post` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`web` varchar(250) default NULL,
`content` text NOT NULL,
`ip_user` varchar(50) NOT NULL,
`comment_date` datetime NOT NULL,
`spam` tinyint(4) NOT NULL,
PRIMARY KEY (`id_comment`)
) ENGINE = MYISAM ;";
$db->ejecutarConsulta($sqlStr);
$url_installation = (endsWith($url_installation, "/")) ? substr($url_installation, 0, strlen($url_installation)-1) : $url_installation ;
$sqlStr = "INSERT INTO `".Table_prefix."config` VALUES (".$posts_limit.", '".$title."', '".$description."', '".$lang."', '".$template."', '".$url_installation."', ".$url_friendly.", ".$rich_text.");";
$sqlStr = "INSERT INTO `".Table_prefix."config` VALUES (".$posts_limit.", '".$title."', '".$description."', '".$lang."', '".$template."', '".$url_installation."');";
$db->ejecutarConsulta($sqlStr);
@ -240,20 +259,30 @@ function installdb($login, $password, $email, $title, $description, $url_install
$db->ejecutarConsulta($sqlStr);
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');";
$db->ejecutarConsulta($sqlStr);
return true;
}
function inerrors($errors,$n) {
if (strpos($errors,$n)===false)
if (strpos($errors,$n)===false) {
return false;
else
} else {
return true;
}
}
function mostrarerror($errors,$errors_d,$n) {
if (inerrors($errors,$n))
if (inerrors($errors,$n)) {
return '<span class="error">'.$errors_d[$n].'</span>';
else
} else {
return "";
}
}
?>

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -11,6 +12,7 @@
<?php
header("Cache-Control: no-cache, must-revalidate");
require( dirname(__FILE__) . '/config.php' );
include(dirname(__FILE__)."/classes/functions.php");
include(dirname(__FILE__)."/classes/user.class.php");
require_once(dirname(__FILE__)."/classes/configuration.class.php");
@ -33,6 +35,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: login screen</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/mootools.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/sortable.js"></script>
@ -55,7 +58,7 @@ if ($user->isAdmin()) {
<div class="box">
<ul class="menu manage">
<h3>Start session</h3>
<li class="selected"><a href="#">Login</a></li>
<li class="selected"><a>Login</a></li>
</ul>
<div class="tabla">

View File

@ -13,7 +13,7 @@
That's it! gelato should now be installed.
==== How to install gelato CMS (Manual) =====
==== How to install gelato CMS (Manually) =====
1) Download and unzip the gelato package, if you haven't already.
2) Create a database for gelato on your web server, as well as a MySQL user who has all privileges for accessing and modifying it.
@ -28,3 +28,14 @@ That's it! gelato should now be installed.
That's it! gelato should now be installed.
Demo user: admin
Demo pass: demo
==== How to update to v0.85 from any previous version =====
1) Download and unzip the gelato package, if you haven't already.
2) Create a backup of your config.php file.
3) Replace all the old files with those from the new 0.85 EXCEPT for the file config.php
3.1) If you do replace it by error, use the backup you create during step two.
4) Execute the update.php file.
7) Set CHMOD / permission ( Chmod 777 ) to the folder 'uploads'
That's it! gelato should now be updated.

View File

@ -1,7 +1,8 @@
<?php
/* ===========================
gelato CMS development version
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
@ -13,6 +14,7 @@
require(dirname(__FILE__)."/config.php");
include("classes/configuration.class.php");
$isFeed = true;
$conf = new configuration();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

View File

@ -2,7 +2,6 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
{Gelato_includes}
<title>{Title}</title>
<!--[if IE]>

71
update.php Normal file
View File

@ -0,0 +1,71 @@
<?php
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under GPL (General public license)
=========================== */
?>
<?php
$configFile = dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
if (!file_exists($configFile)) {
$mensaje = "
<h3 class=\"important\">Error reading configuration file</h3>
<p>There doesn't seem to be a <code>config.php</code> file. I need this before we can get started.</p>
<p>This either means that you did not rename the <code>config-sample.php</code> file to <code>config.php</code>.</p>";
die($mensaje);
} else {
require($configFile);
}
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$sqlStr = "CREATE TABLE `".Table_prefix."comments` (
`id_comment` int(11) NOT NULL auto_increment,
`id_post` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`web` varchar(250) default NULL,
`content` text NOT NULL,
`ip_user` varchar(50) NOT NULL,
`comment_date` datetime NOT NULL,
`spam` tinyint(4) NOT NULL,
PRIMARY KEY (`id_comment`)
) ENGINE = MYISAM ;";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "CREATE TABLE `".Table_prefix."options` (
`name` varchar(100) NOT NULL,
`val` varchar(255) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE = MYISAM ;";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "ALTER TABLE ".Table_prefix."config DROP url_friendly";
$db->ejecutarConsulta($sqlStr);
$sqlStr = "ALTER TABLE ".Table_prefix."config DROP rich_text";
$db->ejecutarConsulta($sqlStr);
echo "<p><em>Finished!</em></p>";
echo "<p>Now you are running on the new version!!!</p>";
?>