First changes on architecture

master
pecesama 2008-11-04 01:59:30 +00:00
parent 3bfc42a5eb
commit f95f856b49
22 changed files with 332 additions and 379 deletions

View File

@ -22,7 +22,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: <?php echo __("admin users")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
@ -108,7 +108,7 @@ if ($user->isAdmin()) {
<?php
$odd=false;
$rs = $user->getUsers();
if ($user->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
?>
<tr <?php if ($odd) { echo 'class="odd"'; } $odd=!$odd; ?>>

View File

@ -19,7 +19,6 @@ if(!defined('entry'))define('entry', true);
if ($_GET["action"]) {
if ($_GET["action"] == "close") {
session_start();
if ($user->closeSession()) {
echo __("&nbsp;ending session&hellip;");
} else {

View File

@ -29,11 +29,11 @@ if ($user->isAdmin()) {
header("Location: ".$conf->urlGelato."/admin/index.php?photo=false");
die();
}
$_POST["url"] = "../uploads/".sanitizeName($photoName);
$_POST["url"] = "../uploads/".util::sanitizeName($photoName);
}
if ( move_uploaded_file( $_FILES['photo']['tmp_name'], "../uploads/".sanitizeName($_FILES['photo']['name']) ) ) {
$_POST["url"] = "../uploads/".sanitizeName($_FILES['photo']['name']);
$_POST["url"] = "../uploads/".util::sanitizeName($_FILES['photo']['name']);
}
unset($_POST["photo"]);
@ -80,13 +80,13 @@ if ($user->isAdmin()) {
}
if (isset($url)) {
if (isMP3($url)) {
if (util::isMP3($url)) {
$postType = "mp3";
} elseif (isGoEar($url)) {
} elseif (util::isGoEar($url)) {
$postType = "mp3";
} elseif (isImageFile($url)) {
} elseif (util::isImageFile($url)) {
$postType = "photo";
} elseif (isVideo($url)) {
} elseif (util::isVideo($url)) {
$postType = "video";
} else {
if (isset($_GET["sel"]) && !$_GET["sel"]=="" ) {
@ -104,7 +104,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();?>" />
<meta name="generator" content="gelato cms <?php echo util::version();?>" />
<title>gelato :: <?php echo __("bookmarklet")?></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/jquery.js"></script>

View File

@ -22,7 +22,7 @@ $closed = $user->closeSession();
<head>
<title>gelato :: <?php echo __("logout")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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">

View File

@ -27,7 +27,7 @@ if(isset($_POST["btnAdd"])) {
$_POST["username"] = strip_tags($_POST["username"]);
$_POST["email"] = strip_tags($_POST["email"]);
$_POST["web"] = strip_tags($_POST["web"]);
$_POST["content"] = removeBadTags($_POST["content"], true);
$_POST["content"] = util::removeBadTags($_POST["content"], true);
if (isset($_POST["id_comment"])) {
if ($isAdmin) {
@ -73,7 +73,7 @@ if ($isAdmin) {
<head>
<title>gelato :: <?php echo __("comments")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
@ -160,7 +160,7 @@ if ($isAdmin) {
$rs = $comment->getComments(null, $limit, $from, $sp);
if ($comment->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
while($rowComment = mysql_fetch_array($rs)) {
$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"]." | ".$rowComment["email"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a> | ".$rowComment["email"];

View File

@ -15,7 +15,6 @@ if(!defined('entry')) define('entry', true);
require('../entry.php');
global $user, $conf, $tumble;
$user= new User();
if ($user->isAdmin()) {
$message = '';
$f = new feeds();
@ -40,7 +39,7 @@ if ($user->isAdmin()) {
<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();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>

View File

@ -105,7 +105,7 @@ if ($user->isAuthenticated()) {
$admin_includes = "";
$trigger->call('admin_includes');
$theme->set('admin_includes',$admin_includes);
$theme->set('version',version());
$theme->set('version',util::version());
$theme->set('conf', array(
'urlGelato'=>$conf->urlGelato,
'richText'=>$conf->richText
@ -115,8 +115,8 @@ if ($user->isAuthenticated()) {
$theme->set('error',false);
if($conf->check_version){
$present = version();
$lastest = _file_get_contents("http://www.gelatocms.com/vgel.txt");
$present = util::version();
$lastest = util::_file_get_contents("http://www.gelatocms.com/vgel.txt");
if ($present < $lastest)
$theme->set('information',__("A new gelato version has been released and is ready <a href=\"http://www.gelatocms.com/\">for download</a>."));
}
@ -225,14 +225,14 @@ if ($user->isAuthenticated()) {
$from = 0;
$rs = $tumble->getPosts($limit, $from);
$theme->set('Posts_Number',$tumble->contarRegistros());
$theme->set('Posts_Number',$db->contarRegistros());
$rows = array();
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
$row['postType'] = type2Text($tumble->getType($register["id_post"]));
$row['postType'] = util::type2Text($tumble->getType($register["id_post"]));
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
$formatedDate = gmdate("M d", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
$strEnd=($conf->urlFriendly) ? "/" : "";
$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;

View File

@ -69,7 +69,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: <?php echo __("options")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script type="text/javascript">

View File

@ -53,7 +53,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: <?php echo __("Plugins")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
@ -137,7 +137,7 @@ if ($user->isAdmin()) {
<option value="on" <?php if($activated) echo 'selected="selected"'; ?>><?php echo __("On")?></option>
<option value="off" <?php if(!$activated) echo 'selected="selected"'; ?>><?php echo __("Off")?></option>
</select>
</li>
</li>
<?php
}
?>

View File

@ -27,7 +27,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: <?php echo __("settings")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script type="text/javascript">
@ -90,7 +90,7 @@ if ($user->isAdmin()) {
<li><label for="lang"><?php echo __("Language:")?></label>
<select id="lang" name="lang">
<?php
$langs = getLangs();
$langs = util::getLangs();
foreach ($langs as $key=>$lang) {
$active = ($conf->lang==$key) ? "selected" : "";
echo "<option value=\"".$key."\" ".$active.">".$lang."</option>\n";
@ -102,7 +102,7 @@ if ($user->isAdmin()) {
<li><label for="template"><?php echo __("Template:")?></label>
<select id="template" name="template">
<?php
$themes = getThemes();
$themes = util::getThemes();
foreach ($themes as $theme) {
$active = ($conf->template==$theme) ? "selected" : "";
echo "<option value=\"".$theme."\" ".$active.">".$theme."</option>\n";

View File

@ -15,8 +15,6 @@ if(!defined('entry')) define('entry', true);
require('../entry.php');
global $user, $conf, $tumble;
$user = new user();
$conf = new configuration();
$isEdition = isset($_GET["edit"]);
$userId = ($isEdition) ? $_GET["edit"] : NULL;
if ($user->isAdmin()) {
@ -50,7 +48,7 @@ if ($user->isAdmin()) {
<head>
<title>gelato :: <?php echo __("add user")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>

View File

@ -54,15 +54,15 @@ if(!defined('entry')) define('entry',true);
$postType = type2Number($_GET["type"]);
}
$rs = $tumble->getPosts($total, $start);
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
?>
<posts start="<?php echo $start; ?>" total="<?php echo $total; ?>">
<?php
while($register = mysql_fetch_array($rs)) {
$desc = trimString($register["description"]);
$desc = util::trimString($register["description"]);
$strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd;
$formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"]) + transform_offset($conf->offsetTime));
$formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
switch ($register["type"]) {
case "1":

View File

@ -23,11 +23,11 @@ $regular = array();
$video = array();
$rs = $tumble->getPosts($tumble->getPostsNumber());
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
while($register = mysql_fetch_assoc($rs)) {
$output = handleNode($register);
$theType = type2Text($register["type"]);
$theType = util::type2Text($register["type"]);
switch($theType) {
case 'quote':
@ -55,13 +55,13 @@ if ($tumble->contarRegistros()>0) {
function handleNode($node) {
global $user, $tumble, $conf;
$dateTmp = null;
$formatedDate = gmdate("M d", strtotime($node["date"]) + transform_offset($conf->offsetTime));
$formatedDate = gmdate("M d", strtotime($node["date"]) + util::transform_offset($conf->offsetTime));
$output = array();
$output['url'] = $tumble->getPermalink($node["id_post"]);
$output['date'] = $formatedDate;
$theType = type2Text($node["type"]);
$theType = util::type2Text($node["type"]);
switch($theType) {
case 'quote':
@ -111,7 +111,7 @@ function handleNode($node) {
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato <?php echo codeName()." (".version().")"; ?>" />
<meta name="generator" content="gelato <?php echo util::codeName()." (".util::version().")"; ?>" />
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $conf->urlGelato.($conf->urlFriendly ? "/rss/" : "/rss.php"); ?>"/>
<title><?php echo $conf->title." &raquo; ".__(" archive"); ?></title>

View File

@ -11,16 +11,20 @@ if(!defined('entry') || !entry) die('Not a valid page');
=========================== */
class comments extends Conexion_Mysql {
class comments {
var $db;
var $conf;
function comments() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$this->conf = new configuration();
global $db;
global $conf;
$this->db = $db;
$this->conf = $conf;
}
function addComment($fieldsArray) {
if ($this->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) {
if ($this->db->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) {
return true;
} else {
return false;
@ -55,33 +59,33 @@ class comments extends Conexion_Mysql {
function getComments($idPost=null, $limit=null, $from=null, $spam=null) {
if (isset($idPost)) {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0 order by comment_date ASC");
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0 order by comment_date ASC");
} else {
if (isset($limit) && isset($from)) {
$limit = " LIMIT $from, $limit";
} else { ""; }
if (isset($spam)) { $sp = "1"; } else { $sp = "0"; }
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=".$sp." order by comment_date ASC".$limit);
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=".$sp." order by comment_date ASC".$limit);
}
return $this->mid_consulta;
return $this->db->mid_consulta;
}
function getComment($id="") {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id);
return mysql_fetch_array($this->mid_consulta);
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id);
return mysql_fetch_array($this->db->mid_consulta);
}
function countComments($idPost=null) {
if (isset($idPost)) {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0");
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_post=".$idPost." AND spam=0");
} else {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=0");
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE spam=0");
}
return $this->contarRegistros();
return $this->db->contarRegistros();
}
function deleteComment($idComment) {
if ($this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."comments WHERE id_comment=".$idComment)) {
if ($this->db->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."comments WHERE id_comment=".$idComment)) {
return true;
} else {
return false;
@ -89,7 +93,7 @@ class comments extends Conexion_Mysql {
}
function modifyComment($fieldsArray, $id_comment) {
if ($this->modificarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray, "id_comment=$id_comment")) {
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray, "id_comment=$id_comment")) {
return true;
} else {
return false;

View File

@ -10,32 +10,32 @@ if(!defined('entry') || !entry) die('Not a valid page');
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */
?>
<?php
require_once("configuration.class.php");
require_once("functions.php");
class gelato extends Conexion_Mysql {
class gelato {
var $db;
var $conf;
function gelato() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$this->conf = new configuration();
global $db;
global $conf;
$this->db = $db;
$this->conf = $conf;
}
function saveSettings($fieldsArray) {
if ($this->modificarDeFormulario($this->conf->tablePrefix."config", $fieldsArray)) {
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."config", $fieldsArray)) {
header("Location: ".$this->conf->urlGelato."/admin/settings.php?modified=true");
die();
} else {
header("Location: ".$this->conf->urlGelato."/admin/settings.php?error=1&des=".$this->merror);
header("Location: ".$this->conf->urlGelato."/admin/settings.php?error=1&des=".$this->db->merror);
die();
}
}
function saveOption($value, $name) {
$sqlStr = "UPDATE ".$this->conf->tablePrefix."options SET val='".$value."' WHERE name='".$name."' LIMIT 1";
if ($this->ejecutarConsulta($sqlStr)) {
if ($this->db->ejecutarConsulta($sqlStr)) {
return true;
} else {
return true;
@ -43,7 +43,7 @@ class gelato extends Conexion_Mysql {
}
function addPost($fieldsArray) {
if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
if ($this->db->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
return true;
} else {
return false;
@ -51,40 +51,40 @@ class gelato extends Conexion_Mysql {
}
function modifyPost($fieldsArray, $id_post) {
if ($this->modificarDeFormulario($this->conf->tablePrefix."data", $fieldsArray, "id_post=$id_post")) {
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."data", $fieldsArray, "id_post=$id_post")) {
header("Location: ".$this->conf->urlGelato."/admin/index.php?modified=true");
die();
} else {
header("Location: ".$this->conf->urlGelato."/admin/index.php?error=2&des=".$this->merror);
header("Location: ".$this->conf->urlGelato."/admin/index.php?error=2&des=".$this->db->merror);
die();
}
}
function deletePost($idPost) {
$this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."data WHERE id_post=".$idPost);
$this->db->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."data WHERE id_post=".$idPost);
}
function getPosts($limit="10", $from="0") {
$sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
$this->ejecutarConsulta($sqlStr);
return $this->mid_consulta;
$this->db->ejecutarConsulta($sqlStr);
return $this->db->mid_consulta;
}
function getPost($id="") {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
return mysql_fetch_array($this->mid_consulta);
$this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
return mysql_fetch_array($this->db->mid_consulta);
}
function getPostsNumber() {
$this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
$row = mysql_fetch_assoc($this->mid_consulta);
$this->db->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
$row = mysql_fetch_assoc($this->db->mid_consulta);
return $row['total'];
}
function getType($id) {
if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
if ($this->contarRegistros()>0) {
while($registro = mysql_fetch_array($this->mid_consulta)) {
if ($this->db->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
if ($this->db->contarRegistros()>0) {
while($registro = mysql_fetch_array($this->db->mid_consulta)) {
return $registro[0];
}
}
@ -185,7 +185,7 @@ class gelato extends Conexion_Mysql {
}
function getMp3Player($url) {
if (isMP3($url)) {
$playerUrl = $this->conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
$playerUrl = $conf->urlGelato."/admin/scripts/player.swf?soundFile=".$url;
return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
} elseif (isGoEar($url)) {
return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://www.goear.com/files/external.swf\" width=\"366\" height=\"130\"><param name=\"movie\" value=\"http://www.goear.com/files/external.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"file=".getGoEarCode($url)."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";

View File

@ -1,20 +1,15 @@
<?php
if(!defined('entry') || !entry) die('Not a valid page');
if(!defined('entry') || !entry) die('Not a valid page');
/* ===========================
/**
* version 0.0.1
*
* Clase plantillas
*
* @name Manejo de plantillas.
* @version 0.0.1
* @link http://www.pecesama.net/weblog/
* @copyright MIT Licence
* @author Pedro Santana [pecesama]
*/
?>
<?php
require_once("functions.php");
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>
=========================== */
class plantillas {

View File

@ -12,19 +12,21 @@ if(!defined('entry') || !entry) die('Not a valid page');
=========================== */
?>
<?php
require_once("configuration.class.php");
class user extends Conexion_Mysql {
class user {
var $conf;
var $db;
var $cookieString;
var $cookieTime;
var $persist = false;
function user() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
global $db;
global $conf;
$this->db = $db;
$this->conf = $conf;
$this->cookie_life = 60*24*3600;
$this->cookieTime = time();
$this->conf = new configuration();
}
function isAdmin() {
@ -47,9 +49,9 @@ class user extends Conexion_Mysql {
function validateUser($username="", $password="") {
if ($this->ejecutarConsulta("SELECT id_user, login, password FROM ".$this->conf->tablePrefix."users WHERE login='".$this->sql_escape($username)."' AND password='".$password."'")) {
if ($this->contarRegistros()>0) {
$register=$this->obtenerRegistro();
if ($this->db->ejecutarConsulta("SELECT id_user, login, password FROM ".$this->conf->tablePrefix."users WHERE login='".$this->db->sql_escape($username)."' AND password='".$password."'")) {
if ($this->db->contarRegistros()>0) {
$register = $this->db->obtenerRegistro();
$_SESSION['user_id']=$register["id_user"];
$_SESSION['user_login']=$register["login"];
$_SESSION['authenticated'] = true;
@ -72,8 +74,8 @@ class user extends Conexion_Mysql {
}
function userExist($user="") {
if ($this->ejecutarConsulta("SELECT * FROM ".$this->conf->tablePrefix."users WHERE login='".$user."'")) {
if ($this->contarRegistros()>0) {
if ($this->db->ejecutarConsulta("SELECT * FROM ".$this->conf->tablePrefix."users WHERE login='".$user."'")) {
if ($this->db->contarRegistros()>0) {
return true;
} else {
return false;
@ -86,11 +88,11 @@ class user extends Conexion_Mysql {
}
function addUser($fieldsArray) {
if ($this->ejecutarConsulta("SELECT id_user FROM ".$this->conf->tablePrefix."users WHERE login='".$fieldsArray['login']."'")) {
if ($this->contarRegistros()==0) {
if ($this->db->ejecutarConsulta("SELECT id_user FROM ".$this->conf->tablePrefix."users WHERE login='".$fieldsArray['login']."'")) {
if ($this->db->contarRegistros()==0) {
$realPassword = ($fieldsArray["password"]);
$fieldsArray["password"] = md5($fieldsArray["password"]);
if ($this->insertarDeFormulario($this->conf->tablePrefix."users", $fieldsArray)) {
if ($this->db->insertarDeFormulario($this->conf->tablePrefix."users", $fieldsArray)) {
$this->confirmationEmail($fieldsArray['email'], $fieldsArray['login'], $realPassword);
header("Location: ".$this->conf->urlGelato."/admin/admin.php?added=true");
die();
@ -107,7 +109,7 @@ class user extends Conexion_Mysql {
function modifyUser($fieldsArray, $id_user) {
$fieldsArray["password"] = md5($fieldsArray["password"]);
if ($this->modificarDeFormulario($this->conf->tablePrefix."users", $fieldsArray, "id_user=$id_user")) {
if ($this->db->modificarDeFormulario($this->conf->tablePrefix."users", $fieldsArray, "id_user=$id_user")) {
header("Location: ".$this->conf->urlGelato."/admin/admin.php?modified=true");
die();
} else {
@ -117,19 +119,19 @@ class user extends Conexion_Mysql {
}
function deleteUser($idUser) {
$this->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."users WHERE id_user=".$idUser);
$this->db->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."users WHERE id_user=".$idUser);
}
function getUsers($show="10", $from="0") {
$sqlStr = "select * from ".$this->conf->tablePrefix."users ORDER BY id_user DESC LIMIT $from,$show";
$this->ejecutarConsulta($sqlStr);
return $this->mid_consulta;
$this->db->ejecutarConsulta($sqlStr);
return $this->db->mid_consulta;
}
function getUserByID($idUser) {
if ($this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."users where id_user=".$idUser)) {
if ($this->contarRegistros()>0) {
return $registro=$this->obtenerRegistro();
if ($this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."users where id_user=".$idUser)) {
if ($this->db->contarRegistros()>0) {
return $registro=$this->db->obtenerRegistro();
} else {
return false;
}

View File

@ -12,6 +12,8 @@ if(!defined('entry') || !entry) die('Not a valid page');
=========================== */
?>
<?php
class util {
function version() {
return "1.0";
}
@ -34,7 +36,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isMP3($fileUrl) {
if (endsWith($fileUrl, ".mp3")) {
if (util::endsWith($fileUrl, ".mp3")) {
return true;
} else {
return false;
@ -42,15 +44,15 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function getMP3File($remoteFileName) {
if (isMP3($remoteFileName)) {
if (getFile($remoteFileName)) {
if (util::isMP3($remoteFileName)) {
if (util::getFile($remoteFileName)) {
return true;
} else {
return false;
}
} elseif (isGoEar($remoteFileName)) {
} elseif (util::isGoEar($remoteFileName)) {
return true;
} elseif (isOdeo($remoteFileName)) {
} elseif (util::isOdeo($remoteFileName)) {
return true;
} else {
return false;
@ -65,14 +67,14 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isGoEar($songUrl) {
if (beginsWith($songUrl, "http://www.goear.com/listen.php?v=") || beginsWith($songUrl, "http://goear.com/listen.php?v="))
if (util::beginsWith($songUrl, "http://www.goear.com/listen.php?v=") || util::beginsWith($songUrl, "http://goear.com/listen.php?v="))
return true;
else
return false;
}
function isOdeo($songUrl){
if (beginsWith($songUrl, "http://odeo.com/audio/") || beginsWith($songUrl, "http://www.odeo.com/audio/"))
if (util::beginsWith($songUrl, "http://odeo.com/audio/") || util::beginsWith($songUrl, "http://www.odeo.com/audio/"))
return true;
else
return false;
@ -85,15 +87,15 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isImageFile($photoUrl) {
if (endsWith($photoUrl, ".jpg")) { return true; }
elseif (endsWith($photoUrl, ".gif")) { return true; }
elseif (endsWith($photoUrl, ".png")) { return true; }
if (util::endsWith($photoUrl, ".jpg")) { return true; }
elseif (util::endsWith($photoUrl, ".gif")) { return true; }
elseif (util::endsWith($photoUrl, ".png")) { return true; }
else { return false; }
}
function getPhotoFile($remoteFileName) {
if (isImageFile($remoteFileName)) {
if (getFile($remoteFileName)) {
if (util::isImageFile($remoteFileName)) {
if (util::getFile($remoteFileName)) {
return true;
} else {
return false;
@ -104,8 +106,8 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function getFile($remoteFileName) {
$fileName = "../uploads/".sanitizeName(getFileName($remoteFileName));
$str = _file_get_contents($remoteFileName);
$fileName = "../uploads/".util::sanitizeName(util::getFileName($remoteFileName));
$str = util::_file_get_contents($remoteFileName);
if (!$handle = fopen($fileName, 'w')) {
//die("no se abrio de escritura");
return false;
@ -120,7 +122,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isVimeoVideo($videoUrl) {
if (beginsWith($videoUrl, "http://vimeo.com/") || beginsWith($videoUrl, "http://www.vimeo.com/"))
if (util::beginsWith($videoUrl, "http://vimeo.com/") || util::beginsWith($videoUrl, "http://www.vimeo.com/"))
return true;
else
return false;
@ -135,7 +137,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
function isYoutubeVideo($videoUrl) {
$url = explode("?", $videoUrl);
if((beginsWith($url[0], "http://") && endsWith($url[0], ".youtube.com/watch")) || beginsWith($url[0], "http://youtube.com/watch"))
if((util::beginsWith($url[0], "http://") && util::endsWith($url[0], ".youtube.com/watch")) || util::beginsWith($url[0], "http://youtube.com/watch"))
return true;
else
return false;
@ -148,7 +150,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isYahooVideo($videoUrl){
if (beginsWith($videoUrl, "http://video.yahoo.com/watch/") || beginsWith($videoUrl, "http://www.video.yahoo.com/watch/"))
if (util::beginsWith($videoUrl, "http://video.yahoo.com/watch/") || util::beginsWith($videoUrl, "http://www.video.yahoo.com/watch/"))
return true;
else
return false;
@ -163,7 +165,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isGoogleVideoUrl($videoUrl){
if (beginsWith($videoUrl, "http://video.google.com/videoplay?")){
if (util::beginsWith($videoUrl, "http://video.google.com/videoplay?")){
return true;
} else {
return false;
@ -177,7 +179,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isMTVVideoUrl($videoUrl){
if (beginsWith($videoUrl, "http://www.mtvmusic.com/video/?id=") || beginsWith($videoUrl, "http://mtvmusic.com/video/?id=")){
if (util::beginsWith($videoUrl, "http://www.mtvmusic.com/video/?id=") || util::beginsWith($videoUrl, "http://mtvmusic.com/video/?id=")){
return true;
} else {
return false;
@ -191,7 +193,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isDailymotionVideo($videoUrl) {
if (beginsWith($videoUrl, "http://www.dailymotion.com/video/") || beginsWith($videoUrl, "http://dailymotion.com/video/"))
if (util::beginsWith($videoUrl, "http://www.dailymotion.com/video/") || util::beginsWith($videoUrl, "http://dailymotion.com/video/"))
return true;
else
return false;
@ -204,7 +206,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isSlideSharePresentation($videoUrl) {
if (beginsWith($videoUrl, "[slideshare id="))
if (util::beginsWith($videoUrl, "[slideshare id="))
return true;
else
return false;
@ -218,13 +220,13 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
function isVideo($url) {
if (isYoutubeVideo($url)) { return true; }
elseif (isVimeoVideo($url)) { return true; }
elseif (isDailymotionVideo($url)) { return true; }
elseif (isYahooVideo($url)) { return true; }
elseif (isSlideSharePresentation($url)) { return true; }
elseif (isGoogleVideoUrl($url)) { return true; }
elseif (isMTVVideoUrl($url)) { return true; }
if (util::isYoutubeVideo($url)) { return true; }
elseif (util::isVimeoVideo($url)) { return true; }
elseif (util::isDailymotionVideo($url)) { return true; }
elseif (util::isYahooVideo($url)) { return true; }
elseif (util::isSlideSharePresentation($url)) { return true; }
elseif (util::isGoogleVideoUrl($url)) { return true; }
elseif (util::isMTVVideoUrl($url)) { return true; }
else { return false; }
}
@ -295,7 +297,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
return false;
}
} else {
if (extension_loaded('curl') && version_compare(get_curl_version(), '7.10.5', '>=')) {
if (extension_loaded('curl') && version_compare(util::get_curl_version(), '7.10.5', '>=')) {
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $path);
@ -417,7 +419,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
}
if (preg_match('|\.mo$|', $directory2)){
if(!in_array($directory2,$dirs)){
$dirs[$directory]=displayLanguage(trim($directory));
$dirs[$directory]=util::displayLanguage(trim($directory));
$i++;
}
}
@ -653,29 +655,17 @@ if(!defined('entry') || !entry) die('Not a valid page');
$actives = json_decode($conf->active_plugins,1);
$actives = $actives[1];
foreach ($actives as $index => $plugin) {
//echo "[".$index."] => ".$plugin."<br />";
if (!file_exists(Absolute_Path."plugins/".$plugin)) {
//echo "\tNo existe el archivo<br />";
unset($actives[$index]);
continue;
}else{
require_once(Absolute_Path.'plugins/'.$plugin);
}
//echo "\tSi existe el archivo<br />";
if (!class_exists($index)) {
//echo "\tNo existe la clase<br />";
continue;
}
//echo "\tSi existe la clase<br />";
plugins::$instances[$index] = new $index;
//print_r(plugins::$instances[$index]);
//echo "<br />";
}
/*echo "<br /><br />";
print_r(plugins::$instances);
echo "<br />";
die();*/
}
?>
}
?>

View File

@ -1,30 +1,7 @@
<?php
ob_start();
if(!defined('entry') || !entry) die('Not a valid page');
/*
* Created on Sep 15, 2007
* Modified on Oct 30, 2008
*
* Known Entry Points
* api.php
* archive.php
* install.php
* index.php
* login.php
* update.php
* rss.php
* admin/bm.php
* admin/index.php
* admin/close.php
* admin/ajax.php
* admin/settings.php
* admin/options.php
* admin/admin.php
* admin/comments.php
* admin/user.php
* admin/feeds.php
* classes/imgsize.php
*/
error_reporting (E_ALL);
ini_set('display_errors', '1');
@ -57,7 +34,8 @@ if($installed) {
}
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'configuration.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'functions.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'util.class.php');
//require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'functions.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gelato.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.class.php');
@ -76,27 +54,15 @@ if($installed){
// Globals to be used throughout the application
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$user = new user();
$tumble = new gelato();
$conf = new configuration();
$tumble = new gelato();
$user = new user();
session_start();
//print_r($conf->plugins);
//die();
init_plugins();
util::init_plugins();
$trigger = plugin::instance();
//echo "plugins.instances: ";
//print_r(plugins::$instances);
//echo "<br />";
//die();
//echo "plugin.actions: ";
//$plugEngine = plugin::instance();
//print_r($plugEngine->actions);
//die();
$trigger->call('gelato_init');
$feeds = new feeds();

View File

@ -13,7 +13,7 @@ if(!defined('entry'))define('entry', true);
?>
<?php
// Received a valid request, better start setting globals we'll need throughout the app in entry.php
// Received a valid request
require_once('entry.php');
global $user, $tumble, $conf;
@ -50,7 +50,7 @@ $theme = new themes;
$feed_url = $conf->urlGelato.($conf->urlFriendly?"/rss/":"/rss.php");
$gelato_includes = "<meta name=\"generator\" content=\"gelato ".codeName()." (".version().")\" />\n";
$gelato_includes = "<meta name=\"generator\" content=\"gelato ".util::codeName()." (".util::version().")\" />\n";
$gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />";
$page_title = $conf->title;
@ -100,10 +100,10 @@ $theme = new themes;
$rs = $tumble->getPosts($limit, $from);
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
$dateTmp = null;
while($register = mysql_fetch_assoc($rs)) {
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
$formatedDate = gmdate("M d", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; }
$permalink = $tumble->getPermalink($register["id_post"]);
@ -115,7 +115,7 @@ $theme = new themes;
$row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink;
$row['postType'] = type2Text($register["type"]);
$row['postType'] = util::type2Text($register["type"]);
switch ($register['type']){
case "1":
@ -199,7 +199,7 @@ $theme = new themes;
} else {
$register = $tumble->getPost($id_post);
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
$formatedDate = gmdate("M d", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
$permalink = $tumble->getPermalink($register["id_post"]);
$conversation = $register["description"];
@ -211,7 +211,7 @@ $theme = new themes;
$row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink;
$row['postType'] = type2Text($register["type"]);
$row['postType'] = util::type2Text($register["type"]);
switch ($register['type']) {
case "1":
@ -289,7 +289,7 @@ $theme = new themes;
$answers['Id_Comment'] = $rowComment["id_comment"];
$answers['Comment_Author'] = $commentAuthor;
$answers['Date'] = gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime));
$answers['Date'] = gmdate("d.m.y", strtotime($rowComment["comment_date"]) + util::transform_offset($conf->offsetTime));
$answers['Comment'] = nl2br($rowComment["content"]);
$comments[] = $answers;

View File

@ -40,7 +40,7 @@ if ($user->isAuthenticated()) {
<head>
<title>gelato :: <?php echo __("login screen")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="gelato cms <?php echo version();?>" />
<meta name="generator" content="gelato cms <?php echo util::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/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.validate.min.js"></script>

View File

@ -28,7 +28,7 @@ if(!defined('entry')) define('entry',true);
<title><?php echo htmlspecialchars($conf->title);?></title>
<link><?php echo $conf->urlGelato;?></link>
<description><?php echo htmlspecialchars($conf->description);?></description>
<generator>gelato CMS <?php echo codeName()." (".version().")"; ?></generator>
<generator>gelato CMS <?php echo util::codeName()." (".util::version().")"; ?></generator>
<image>
<url><?php echo $conf->urlGelato;?>/images/information.png</url>
<title><?php echo htmlspecialchars($conf->description);?></title>
@ -36,7 +36,7 @@ if(!defined('entry')) define('entry',true);
</image>
<?php
$rs = $tumble->getPosts("20");
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
$register["description"] = $register["description"];
@ -76,10 +76,10 @@ if(!defined('entry')) define('entry',true);
$desc = $tumble->getMp3Player($register["url"]);
break;
}
$tit = trimString($tit);
$tit = util::trimString($tit);
$strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd;
$formatedDate = gmdate("r", strtotime($register["date"]) + transform_offset($conf->offsetTime));
$formatedDate = gmdate("r", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
?>
<item>
<title><?php echo $tit;?></title>