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> <head>
<title>gelato :: <?php echo __("admin users")?></title> <title>gelato :: <?php echo __("admin users")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <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.js"></script>
<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/tools.js"></script>
@ -108,7 +108,7 @@ if ($user->isAdmin()) {
<?php <?php
$odd=false; $odd=false;
$rs = $user->getUsers(); $rs = $user->getUsers();
if ($user->contarRegistros()>0) { if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) { while($register = mysql_fetch_array($rs)) {
?> ?>
<tr <?php if ($odd) { echo 'class="odd"'; } $odd=!$odd; ?>> <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"]) {
if ($_GET["action"] == "close") { if ($_GET["action"] == "close") {
session_start();
if ($user->closeSession()) { if ($user->closeSession()) {
echo __("&nbsp;ending session&hellip;"); echo __("&nbsp;ending session&hellip;");
} else { } else {

View File

@ -29,11 +29,11 @@ if ($user->isAdmin()) {
header("Location: ".$conf->urlGelato."/admin/index.php?photo=false"); header("Location: ".$conf->urlGelato."/admin/index.php?photo=false");
die(); 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']) ) ) { 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"]); unset($_POST["photo"]);
@ -80,13 +80,13 @@ if ($user->isAdmin()) {
} }
if (isset($url)) { if (isset($url)) {
if (isMP3($url)) { if (util::isMP3($url)) {
$postType = "mp3"; $postType = "mp3";
} elseif (isGoEar($url)) { } elseif (util::isGoEar($url)) {
$postType = "mp3"; $postType = "mp3";
} elseif (isImageFile($url)) { } elseif (util::isImageFile($url)) {
$postType = "photo"; $postType = "photo";
} elseif (isVideo($url)) { } elseif (util::isVideo($url)) {
$postType = "video"; $postType = "video";
} else { } else {
if (isset($_GET["sel"]) && !$_GET["sel"]=="" ) { if (isset($_GET["sel"]) && !$_GET["sel"]=="" ) {
@ -104,7 +104,7 @@ if ($user->isAdmin()) {
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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> <title>gelato :: <?php echo __("bookmarklet")?></title>
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" /> <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.js"></script>

View File

@ -22,7 +22,7 @@ $closed = $user->closeSession();
<head> <head>
<title>gelato :: <?php echo __("logout")?></title> <title>gelato :: <?php echo __("logout")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <meta http-equiv="Refresh" content="3;URL=../login.php" />
<link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" /> <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
<style type="text/css" media="screen"> <style type="text/css" media="screen">

View File

@ -27,7 +27,7 @@ if(isset($_POST["btnAdd"])) {
$_POST["username"] = strip_tags($_POST["username"]); $_POST["username"] = strip_tags($_POST["username"]);
$_POST["email"] = strip_tags($_POST["email"]); $_POST["email"] = strip_tags($_POST["email"]);
$_POST["web"] = strip_tags($_POST["web"]); $_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 (isset($_POST["id_comment"])) {
if ($isAdmin) { if ($isAdmin) {
@ -73,7 +73,7 @@ if ($isAdmin) {
<head> <head>
<title>gelato :: <?php echo __("comments")?></title> <title>gelato :: <?php echo __("comments")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <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.js"></script>
<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/tools.js"></script>
@ -160,7 +160,7 @@ if ($isAdmin) {
$rs = $comment->getComments(null, $limit, $from, $sp); $rs = $comment->getComments(null, $limit, $from, $sp);
if ($comment->contarRegistros()>0) { if ($db->contarRegistros()>0) {
while($rowComment = mysql_fetch_array($rs)) { while($rowComment = mysql_fetch_array($rs)) {
$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"]." | ".$rowComment["email"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a> | ".$rowComment["email"]; $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'); require('../entry.php');
global $user, $conf, $tumble; global $user, $conf, $tumble;
$user= new User();
if ($user->isAdmin()) { if ($user->isAdmin()) {
$message = ''; $message = '';
$f = new feeds(); $f = new feeds();
@ -40,7 +39,7 @@ if ($user->isAdmin()) {
<head> <head>
<title>gelato :: <?php echo __("Feeds")?></title> <title>gelato :: <?php echo __("Feeds")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <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.js"></script>
<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/tools.js"></script>

View File

@ -105,7 +105,7 @@ if ($user->isAuthenticated()) {
$admin_includes = ""; $admin_includes = "";
$trigger->call('admin_includes'); $trigger->call('admin_includes');
$theme->set('admin_includes',$admin_includes); $theme->set('admin_includes',$admin_includes);
$theme->set('version',version()); $theme->set('version',util::version());
$theme->set('conf', array( $theme->set('conf', array(
'urlGelato'=>$conf->urlGelato, 'urlGelato'=>$conf->urlGelato,
'richText'=>$conf->richText 'richText'=>$conf->richText
@ -115,8 +115,8 @@ if ($user->isAuthenticated()) {
$theme->set('error',false); $theme->set('error',false);
if($conf->check_version){ if($conf->check_version){
$present = version(); $present = util::version();
$lastest = _file_get_contents("http://www.gelatocms.com/vgel.txt"); $lastest = util::_file_get_contents("http://www.gelatocms.com/vgel.txt");
if ($present < $lastest) 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>.")); $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; $from = 0;
$rs = $tumble->getPosts($limit, $from); $rs = $tumble->getPosts($limit, $from);
$theme->set('Posts_Number',$tumble->contarRegistros()); $theme->set('Posts_Number',$db->contarRegistros());
$rows = array(); $rows = array();
if ($tumble->contarRegistros()>0) { if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) { 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) ? "/" : ""; $strEnd=($conf->urlFriendly) ? "/" : "";
$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd; $permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;

View File

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

View File

@ -53,7 +53,7 @@ if ($user->isAdmin()) {
<head> <head>
<title>gelato :: <?php echo __("Plugins")?></title> <title>gelato :: <?php echo __("Plugins")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <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.js"></script>
<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/tools.js"></script>

View File

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

View File

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

View File

@ -54,15 +54,15 @@ if(!defined('entry')) define('entry',true);
$postType = type2Number($_GET["type"]); $postType = type2Number($_GET["type"]);
} }
$rs = $tumble->getPosts($total, $start); $rs = $tumble->getPosts($total, $start);
if ($tumble->contarRegistros()>0) { if ($db->contarRegistros()>0) {
?> ?>
<posts start="<?php echo $start; ?>" total="<?php echo $total; ?>"> <posts start="<?php echo $start; ?>" total="<?php echo $total; ?>">
<?php <?php
while($register = mysql_fetch_array($rs)) { while($register = mysql_fetch_array($rs)) {
$desc = trimString($register["description"]); $desc = util::trimString($register["description"]);
$strEnd = ($conf->urlFriendly) ? "/" : ""; $strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd; $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"]) { switch ($register["type"]) {
case "1": case "1":

View File

@ -23,11 +23,11 @@ $regular = array();
$video = array(); $video = array();
$rs = $tumble->getPosts($tumble->getPostsNumber()); $rs = $tumble->getPosts($tumble->getPostsNumber());
if ($tumble->contarRegistros()>0) { if ($db->contarRegistros()>0) {
while($register = mysql_fetch_assoc($rs)) { while($register = mysql_fetch_assoc($rs)) {
$output = handleNode($register); $output = handleNode($register);
$theType = type2Text($register["type"]); $theType = util::type2Text($register["type"]);
switch($theType) { switch($theType) {
case 'quote': case 'quote':
@ -55,13 +55,13 @@ if ($tumble->contarRegistros()>0) {
function handleNode($node) { function handleNode($node) {
global $user, $tumble, $conf; global $user, $tumble, $conf;
$dateTmp = null; $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 = array();
$output['url'] = $tumble->getPermalink($node["id_post"]); $output['url'] = $tumble->getPermalink($node["id_post"]);
$output['date'] = $formatedDate; $output['date'] = $formatedDate;
$theType = type2Text($node["type"]); $theType = util::type2Text($node["type"]);
switch($theType) { switch($theType) {
case 'quote': case 'quote':
@ -111,7 +111,7 @@ function handleNode($node) {
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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="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"); ?>"/> <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> <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; var $conf;
function comments() { function comments() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); global $db;
$this->conf = new configuration(); global $conf;
$this->db = $db;
$this->conf = $conf;
} }
function addComment($fieldsArray) { function addComment($fieldsArray) {
if ($this->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) { if ($this->db->insertarDeFormulario($this->conf->tablePrefix."comments", $fieldsArray)) {
return true; return true;
} else { } else {
return false; return false;
@ -55,33 +59,33 @@ class comments extends Conexion_Mysql {
function getComments($idPost=null, $limit=null, $from=null, $spam=null) { function getComments($idPost=null, $limit=null, $from=null, $spam=null) {
if (isset($idPost)) { 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 { } else {
if (isset($limit) && isset($from)) { if (isset($limit) && isset($from)) {
$limit = " LIMIT $from, $limit"; $limit = " LIMIT $from, $limit";
} else { ""; } } else { ""; }
if (isset($spam)) { $sp = "1"; } else { $sp = "0"; } 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="") { function getComment($id="") {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id); $this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."comments WHERE id_comment=".$id);
return mysql_fetch_array($this->mid_consulta); return mysql_fetch_array($this->db->mid_consulta);
} }
function countComments($idPost=null) { function countComments($idPost=null) {
if (isset($idPost)) { 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 { } 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) { 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; return true;
} else { } else {
return false; return false;
@ -89,7 +93,7 @@ class comments extends Conexion_Mysql {
} }
function modifyComment($fieldsArray, $id_comment) { 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; return true;
} else { } else {
return false; 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> 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; var $conf;
function gelato() { function gelato() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); global $db;
$this->conf = new configuration(); global $conf;
$this->db = $db;
$this->conf = $conf;
} }
function saveSettings($fieldsArray) { 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"); header("Location: ".$this->conf->urlGelato."/admin/settings.php?modified=true");
die(); die();
} else { } 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(); die();
} }
} }
function saveOption($value, $name) { function saveOption($value, $name) {
$sqlStr = "UPDATE ".$this->conf->tablePrefix."options SET val='".$value."' WHERE name='".$name."' LIMIT 1"; $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; return true;
} else { } else {
return true; return true;
@ -43,7 +43,7 @@ class gelato extends Conexion_Mysql {
} }
function addPost($fieldsArray) { function addPost($fieldsArray) {
if ($this->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) { if ($this->db->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
return true; return true;
} else { } else {
return false; return false;
@ -51,40 +51,40 @@ class gelato extends Conexion_Mysql {
} }
function modifyPost($fieldsArray, $id_post) { 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"); header("Location: ".$this->conf->urlGelato."/admin/index.php?modified=true");
die(); die();
} else { } 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(); die();
} }
} }
function deletePost($idPost) { 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") { function getPosts($limit="10", $from="0") {
$sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit"; $sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
$this->ejecutarConsulta($sqlStr); $this->db->ejecutarConsulta($sqlStr);
return $this->mid_consulta; return $this->db->mid_consulta;
} }
function getPost($id="") { function getPost($id="") {
$this->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id); $this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
return mysql_fetch_array($this->mid_consulta); return mysql_fetch_array($this->db->mid_consulta);
} }
function getPostsNumber() { function getPostsNumber() {
$this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data"); $this->db->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
$row = mysql_fetch_assoc($this->mid_consulta); $row = mysql_fetch_assoc($this->db->mid_consulta);
return $row['total']; return $row['total'];
} }
function getType($id) { function getType($id) {
if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) { if ($this->db->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
if ($this->contarRegistros()>0) { if ($this->db->contarRegistros()>0) {
while($registro = mysql_fetch_array($this->mid_consulta)) { while($registro = mysql_fetch_array($this->db->mid_consulta)) {
return $registro[0]; return $registro[0];
} }
} }
@ -185,7 +185,7 @@ class gelato extends Conexion_Mysql {
} }
function getMp3Player($url) { function getMp3Player($url) {
if (isMP3($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"; 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)) { } 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"; 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 <?php
if(!defined('entry') || !entry) die('Not a valid page'); if(!defined('entry') || !entry) die('Not a valid page');
/* ===========================
/** gelato CMS - A PHP based tumblelog CMS
* version 0.0.1 development version
* http://www.gelatocms.com/
* Clase plantillas
* gelato CMS is a free software licensed under the GPL 2.0
* @name Manejo de plantillas. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
* @version 0.0.1
* @link http://www.pecesama.net/weblog/ =========================== */
* @copyright MIT Licence
* @author Pedro Santana [pecesama]
*/
?>
<?php
require_once("functions.php");
class plantillas { class plantillas {

View File

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

View File

@ -12,6 +12,8 @@ if(!defined('entry') || !entry) die('Not a valid page');
=========================== */ =========================== */
?> ?>
<?php <?php
class util {
function version() { function version() {
return "1.0"; return "1.0";
} }
@ -34,7 +36,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isMP3($fileUrl) { function isMP3($fileUrl) {
if (endsWith($fileUrl, ".mp3")) { if (util::endsWith($fileUrl, ".mp3")) {
return true; return true;
} else { } else {
return false; return false;
@ -42,15 +44,15 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function getMP3File($remoteFileName) { function getMP3File($remoteFileName) {
if (isMP3($remoteFileName)) { if (util::isMP3($remoteFileName)) {
if (getFile($remoteFileName)) { if (util::getFile($remoteFileName)) {
return true; return true;
} else { } else {
return false; return false;
} }
} elseif (isGoEar($remoteFileName)) { } elseif (util::isGoEar($remoteFileName)) {
return true; return true;
} elseif (isOdeo($remoteFileName)) { } elseif (util::isOdeo($remoteFileName)) {
return true; return true;
} else { } else {
return false; return false;
@ -65,14 +67,14 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isGoEar($songUrl) { 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; return true;
else else
return false; return false;
} }
function isOdeo($songUrl){ 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; return true;
else else
return false; return false;
@ -85,15 +87,15 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isImageFile($photoUrl) { function isImageFile($photoUrl) {
if (endsWith($photoUrl, ".jpg")) { return true; } if (util::endsWith($photoUrl, ".jpg")) { return true; }
elseif (endsWith($photoUrl, ".gif")) { return true; } elseif (util::endsWith($photoUrl, ".gif")) { return true; }
elseif (endsWith($photoUrl, ".png")) { return true; } elseif (util::endsWith($photoUrl, ".png")) { return true; }
else { return false; } else { return false; }
} }
function getPhotoFile($remoteFileName) { function getPhotoFile($remoteFileName) {
if (isImageFile($remoteFileName)) { if (util::isImageFile($remoteFileName)) {
if (getFile($remoteFileName)) { if (util::getFile($remoteFileName)) {
return true; return true;
} else { } else {
return false; return false;
@ -104,8 +106,8 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function getFile($remoteFileName) { function getFile($remoteFileName) {
$fileName = "../uploads/".sanitizeName(getFileName($remoteFileName)); $fileName = "../uploads/".util::sanitizeName(util::getFileName($remoteFileName));
$str = _file_get_contents($remoteFileName); $str = util::_file_get_contents($remoteFileName);
if (!$handle = fopen($fileName, 'w')) { if (!$handle = fopen($fileName, 'w')) {
//die("no se abrio de escritura"); //die("no se abrio de escritura");
return false; return false;
@ -120,7 +122,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isVimeoVideo($videoUrl) { 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; return true;
else else
return false; return false;
@ -135,7 +137,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
function isYoutubeVideo($videoUrl) { function isYoutubeVideo($videoUrl) {
$url = explode("?", $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; return true;
else else
return false; return false;
@ -148,7 +150,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isYahooVideo($videoUrl){ 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; return true;
else else
return false; return false;
@ -163,7 +165,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isGoogleVideoUrl($videoUrl){ function isGoogleVideoUrl($videoUrl){
if (beginsWith($videoUrl, "http://video.google.com/videoplay?")){ if (util::beginsWith($videoUrl, "http://video.google.com/videoplay?")){
return true; return true;
} else { } else {
return false; return false;
@ -177,7 +179,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isMTVVideoUrl($videoUrl){ 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; return true;
} else { } else {
return false; return false;
@ -191,7 +193,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isDailymotionVideo($videoUrl) { 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; return true;
else else
return false; return false;
@ -204,7 +206,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isSlideSharePresentation($videoUrl) { function isSlideSharePresentation($videoUrl) {
if (beginsWith($videoUrl, "[slideshare id=")) if (util::beginsWith($videoUrl, "[slideshare id="))
return true; return true;
else else
return false; return false;
@ -218,13 +220,13 @@ if(!defined('entry') || !entry) die('Not a valid page');
} }
function isVideo($url) { function isVideo($url) {
if (isYoutubeVideo($url)) { return true; } if (util::isYoutubeVideo($url)) { return true; }
elseif (isVimeoVideo($url)) { return true; } elseif (util::isVimeoVideo($url)) { return true; }
elseif (isDailymotionVideo($url)) { return true; } elseif (util::isDailymotionVideo($url)) { return true; }
elseif (isYahooVideo($url)) { return true; } elseif (util::isYahooVideo($url)) { return true; }
elseif (isSlideSharePresentation($url)) { return true; } elseif (util::isSlideSharePresentation($url)) { return true; }
elseif (isGoogleVideoUrl($url)) { return true; } elseif (util::isGoogleVideoUrl($url)) { return true; }
elseif (isMTVVideoUrl($url)) { return true; } elseif (util::isMTVVideoUrl($url)) { return true; }
else { return false; } else { return false; }
} }
@ -295,7 +297,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
return false; return false;
} }
} else { } 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(); $ch = curl_init();
$timeout = 5; $timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $path); 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 (preg_match('|\.mo$|', $directory2)){
if(!in_array($directory2,$dirs)){ if(!in_array($directory2,$dirs)){
$dirs[$directory]=displayLanguage(trim($directory)); $dirs[$directory]=util::displayLanguage(trim($directory));
$i++; $i++;
} }
} }
@ -653,29 +655,17 @@ if(!defined('entry') || !entry) die('Not a valid page');
$actives = json_decode($conf->active_plugins,1); $actives = json_decode($conf->active_plugins,1);
$actives = $actives[1]; $actives = $actives[1];
foreach ($actives as $index => $plugin) { foreach ($actives as $index => $plugin) {
//echo "[".$index."] => ".$plugin."<br />";
if (!file_exists(Absolute_Path."plugins/".$plugin)) { if (!file_exists(Absolute_Path."plugins/".$plugin)) {
//echo "\tNo existe el archivo<br />";
unset($actives[$index]); unset($actives[$index]);
continue; continue;
}else{ }else{
require_once(Absolute_Path.'plugins/'.$plugin); require_once(Absolute_Path.'plugins/'.$plugin);
} }
//echo "\tSi existe el archivo<br />";
if (!class_exists($index)) { if (!class_exists($index)) {
//echo "\tNo existe la clase<br />";
continue; continue;
} }
//echo "\tSi existe la clase<br />";
plugins::$instances[$index] = new $index; 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 <?php
ob_start(); ob_start();
if(!defined('entry') || !entry) die('Not a valid page'); 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); error_reporting (E_ALL);
ini_set('display_errors', '1'); 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.'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.'gelato.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.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 // Globals to be used throughout the application
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password); $db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$user = new user();
$tumble = new gelato();
$conf = new configuration(); $conf = new configuration();
$tumble = new gelato();
$user = new user();
session_start(); session_start();
//print_r($conf->plugins); util::init_plugins();
//die();
init_plugins();
$trigger = plugin::instance(); $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'); $trigger->call('gelato_init');
$feeds = new feeds(); $feeds = new feeds();

View File

@ -13,7 +13,7 @@ if(!defined('entry'))define('entry', true);
?> ?>
<?php <?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'); require_once('entry.php');
global $user, $tumble, $conf; global $user, $tumble, $conf;
@ -50,7 +50,7 @@ $theme = new themes;
$feed_url = $conf->urlGelato.($conf->urlFriendly?"/rss/":"/rss.php"); $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\" />"; $gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />";
$page_title = $conf->title; $page_title = $conf->title;
@ -100,10 +100,10 @@ $theme = new themes;
$rs = $tumble->getPosts($limit, $from); $rs = $tumble->getPosts($limit, $from);
if ($tumble->contarRegistros()>0) { if ($db->contarRegistros()>0) {
$dateTmp = null; $dateTmp = null;
while($register = mysql_fetch_assoc($rs)) { 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; } if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; }
$permalink = $tumble->getPermalink($register["id_post"]); $permalink = $tumble->getPermalink($register["id_post"]);
@ -115,7 +115,7 @@ $theme = new themes;
$row['Date_Added'] = $formatedDate; $row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink; $row['Permalink'] = $permalink;
$row['postType'] = type2Text($register["type"]); $row['postType'] = util::type2Text($register["type"]);
switch ($register['type']){ switch ($register['type']){
case "1": case "1":
@ -199,7 +199,7 @@ $theme = new themes;
} else { } else {
$register = $tumble->getPost($id_post); $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"]); $permalink = $tumble->getPermalink($register["id_post"]);
$conversation = $register["description"]; $conversation = $register["description"];
@ -211,7 +211,7 @@ $theme = new themes;
$row['Date_Added'] = $formatedDate; $row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink; $row['Permalink'] = $permalink;
$row['postType'] = type2Text($register["type"]); $row['postType'] = util::type2Text($register["type"]);
switch ($register['type']) { switch ($register['type']) {
case "1": case "1":
@ -289,7 +289,7 @@ $theme = new themes;
$answers['Id_Comment'] = $rowComment["id_comment"]; $answers['Id_Comment'] = $rowComment["id_comment"];
$answers['Comment_Author'] = $commentAuthor; $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"]); $answers['Comment'] = nl2br($rowComment["content"]);
$comments[] = $answers; $comments[] = $answers;

View File

@ -40,7 +40,7 @@ if ($user->isAuthenticated()) {
<head> <head>
<title>gelato :: <?php echo __("login screen")?></title> <title>gelato :: <?php echo __("login screen")?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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" /> <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.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.validate.min.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> <title><?php echo htmlspecialchars($conf->title);?></title>
<link><?php echo $conf->urlGelato;?></link> <link><?php echo $conf->urlGelato;?></link>
<description><?php echo htmlspecialchars($conf->description);?></description> <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> <image>
<url><?php echo $conf->urlGelato;?>/images/information.png</url> <url><?php echo $conf->urlGelato;?>/images/information.png</url>
<title><?php echo htmlspecialchars($conf->description);?></title> <title><?php echo htmlspecialchars($conf->description);?></title>
@ -36,7 +36,7 @@ if(!defined('entry')) define('entry',true);
</image> </image>
<?php <?php
$rs = $tumble->getPosts("20"); $rs = $tumble->getPosts("20");
if ($tumble->contarRegistros()>0) { if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) { while($register = mysql_fetch_array($rs)) {
$register["description"] = $register["description"]; $register["description"] = $register["description"];
@ -76,10 +76,10 @@ if(!defined('entry')) define('entry',true);
$desc = $tumble->getMp3Player($register["url"]); $desc = $tumble->getMp3Player($register["url"]);
break; break;
} }
$tit = trimString($tit); $tit = util::trimString($tit);
$strEnd = ($conf->urlFriendly) ? "/" : ""; $strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd; $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> <item>
<title><?php echo $tit;?></title> <title><?php echo $tit;?></title>