bug fixed

master
Victor De la Rocha 2008-10-29 03:15:39 +00:00
parent 94250eef66
commit 4e6faab461
1 changed files with 233 additions and 270 deletions

View File

@ -9,7 +9,7 @@ if(!defined('entry'))define('entry', true);
gelato CMS is a free software licensed under the GPL 2.0 gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com> Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */ =========================== */
?> ?>
<?php <?php
require('../entry.php'); require('../entry.php');
@ -23,319 +23,282 @@ $postId = ($isEdition) ? $_GET["edit"] : NULL;
$theme->set('isEdition',$isEdition); $theme->set('isEdition',$isEdition);
$theme->set('postId',$postId); $theme->set('postId',$postId);
$theme->set('pagination',''); $theme->set('pagination','');
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$get){ foreach($_GET as $k=>$get){
$_GET[$k]=stripslashes($get); $_GET[$k]=stripslashes($get);
} }
} }
if ($user->isAuthenticated()) { if ($user->isAuthenticated()) {
if (isset($_GET["delete"])) { if (isset($_GET["delete"])) {
$tumble->deletePost($_GET['delete']); $tumble->deletePost($_GET['delete']);
header("Location: index.php?deleted=true"); header("Location: index.php?deleted=true");
die(); die();
} }
if(isset($_POST["btnAdd"])){ if(isset($_POST["btnAdd"])){
unset($_POST["btnAdd"]); unset($_POST["btnAdd"]);
$_POST['type'] = type2Number($_POST['type']); $_POST['type'] = type2Number($_POST['type']);
if ($_POST["type"]=="2") { // is Photo type if ($_POST["type"]=="2") { // is Photo type
if (isset($_POST["url"]) && $_POST["url"]!="") { if (isset($_POST["url"]) && $_POST["url"]!="") {
$photoName = getFileName($_POST["url"]); $photoName = getFileName($_POST["url"]);
if (!$tumble->savePhoto($_POST["url"])) { if (!$tumble->savePhoto($_POST["url"])) {
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/".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/".sanitizeName($_FILES['photo']['name']);
} }
unset($_POST["photo"]); unset($_POST["photo"]);
unset($_POST["MAX_FILE_SIZE"]); unset($_POST["MAX_FILE_SIZE"]);
} }
if ($_POST["type"]=="7") { // is MP3 type if ($_POST["type"]=="7") { // is MP3 type
set_time_limit(300); set_time_limit(300);
$mp3Name = getFileName($_POST["url"]); $mp3Name = getFileName($_POST["url"]);
if (!$tumble->saveMP3($_POST["url"])) { if (!$tumble->saveMP3($_POST["url"])) {
header("Location: ".$conf->urlGelato."/admin/index.php?mp3=false"); header("Location: ".$conf->urlGelato."/admin/index.php?mp3=false");
die(); die();
} }
if (isMP3($remoteFileName)) { if (isMP3($remoteFileName)) {
$_POST["url"] = $conf->urlGelato."/uploads/".$mp3Name; $_POST["url"] = $conf->urlGelato."/uploads/".$mp3Name;
} }
} }
if (!get_magic_quotes_gpc()) { if (!get_magic_quotes_gpc()) {
$_POST["title"] = addslashes($_POST["title"]); $_POST["title"] = addslashes($_POST["title"]);
$_POST["description"] = addslashes($_POST["description"]); $_POST["description"] = addslashes($_POST["description"]);
} }
/* /*
$textile = new Textile(); $textile = new Textile();
$_POST["title"] = $textile->TextileThis(removeBadTags($_POST["title"],true)); $_POST["title"] = $textile->TextileThis(removeBadTags($_POST["title"],true));
$_POST["description"] = $textile->TextileThis(removeBadTags($_POST["description"])); $_POST["description"] = $textile->TextileThis(removeBadTags($_POST["description"]));
*/ */
$_POST["title"] = removeBadTags($_POST["title"],true); $_POST["title"] = removeBadTags($_POST["title"],true);
$_POST["description"] = removeBadTags($_POST["description"]); $_POST["description"] = removeBadTags($_POST["description"]);
if (isset($_POST["id_post"]) and is_numeric($_POST["id_post"]) and $_POST["id_post"]>0) {
$tumble->modifyPost($_POST, $_POST["id_post"]);
} else {
if ($tumble->addPost($_POST)) {
header("Location: ".$conf->urlGelato."/admin/index.php?added=true");
die();
} else {
header("Location: ".$conf->urlGelato."/admin/index.php?error=2&des=".$tumble->merror);
die();
}
}
} else {
if ($isEdition) {
$post = $tumble->getPost($postId);
}
$theme->set('version',version()); if (isset($_POST["id_post"]) and is_numeric($_POST["id_post"]) and $_POST["id_post"]>0) {
$theme->set('conf', array( $tumble->modifyPost($_POST, $_POST["id_post"]);
'urlGelato'=>$conf->urlGelato, } else {
'richText'=>$conf->richText if ($tumble->addPost($_POST)) {
)); header("Location: ".$conf->urlGelato."/admin/index.php?added=true");
$theme->set('new',isset($_GET['new'])?$_GET['new']:''); die();
$theme->set('information',false); } else {
$theme->set('error',false); header("Location: ".$conf->urlGelato."/admin/index.php?error=2&des=".$tumble->merror);
die();
}
}
} else {
if ($isEdition) {
$post = $tumble->getPost($postId);
}
if($conf->check_version){ $theme->set('version',version());
$present = version(); $theme->set('conf', array(
$lastest = _file_get_contents("http://www.gelatocms.com/vgel.txt"); 'urlGelato'=>$conf->urlGelato,
if ($present < $lastest) 'richText'=>$conf->richText
$theme->set('information',__("A new gelato version has been released and is ready <a href=\"http://www.gelatocms.com/\">for download</a>.")); ));
} $theme->set('new',isset($_GET['new'])?$_GET['new']:'');
$theme->set('information',false);
$theme->set('error',false);
$actions = array( if($conf->check_version){
'deleted'=>false, $present = version();
'modified'=>false, $lastest = _file_get_contents("http://www.gelatocms.com/vgel.txt");
'added'=>false 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>."));
}
if(isset($_GET['deleted']) and $_GET['deleted']=='true'){ $actions = array(
$theme->set('exito',__("The post has been eliminated successfully.")); 'deleted'=>false,
$actions['deleted'] = true; 'modified'=>false,
} 'added'=>false
);
if(isset($_GET["modified"]) and $_GET["modified"]==true){ if(isset($_GET['deleted']) and $_GET['deleted']=='true'){
$theme->set('exito',__("The post has been modified successfully.")); $theme->set('exito',__("The post has been eliminated successfully."));
$actions['modified']=true; $actions['deleted'] = true;
} }
if(isset($_GET["added"]) and $_GET["added"]==true) { if(isset($_GET["modified"]) and $_GET["modified"]==true){
$theme->set('exito',__("The post has been added successfully.")); $theme->set('exito',__("The post has been modified successfully."));
$actions['added']=true; $actions['modified']=true;
} }
$theme->set('action',$actions); if(isset($_GET["added"]) and $_GET["added"]==true) {
$theme->set('exito',__("The post has been added successfully."));
$actions['added']=true;
}
if (isset($_GET["error"]) and $_GET["error"]==2) $theme->set('action',$actions);
$theme->set('error',__("Error on the database server:")." </strong>".$_GET["des"]);
if (isset($_GET["mp3"]) and $_GET["mp3"]=='false') if (isset($_GET["error"]) and $_GET["error"]==2)
$theme->set('error',__("Not an MP3 file or an upload problem.")); $theme->set('error',__("Error on the database server:")." </strong>".$_GET["des"]);
if (isset($_GET["photo"]) and $_GET["photo"]=='false') if (isset($_GET["mp3"]) and $_GET["mp3"]=='false')
$theme->set('error',__("Not a photo file or an upload problem.")); $theme->set('error',__("Not an MP3 file or an upload problem."));
if ($isEdition) { if (isset($_GET["photo"]) and $_GET["photo"]=='false')
switch ($post["type"]) { $theme->set('error',__("Not a photo file or an upload problem."));
case "1": $_GET["new"] = "post"; break;
case "2": $_GET["new"] = "photo"; break;
case "3": $_GET["new"] = "quote"; break;
case "4": $_GET["new"] = "url"; break;
case "5": $_GET["new"] = "conversation"; break;
case "6": $_GET["new"] = "video"; break;
case "7": $_GET["new"] = "mp3"; break;
}
}
$date = ($isEdition) ? strtotime($post["date"]) : gmmktime(); if ($isEdition) {
$title = ($isEdition) ? htmlspecialchars(stripslashes($post["title"])) : ""; switch ($post["type"]) {
$body = ($isEdition) ? stripslashes($post["description"]) : ""; case "1": $_GET["new"] = "post"; break;
$url = ($isEdition) ? $post["url"] : ""; case "2": $_GET["new"] = "photo"; break;
case "3": $_GET["new"] = "quote"; break;
case "4": $_GET["new"] = "url"; break;
case "5": $_GET["new"] = "conversation"; break;
case "6": $_GET["new"] = "video"; break;
case "7": $_GET["new"] = "mp3"; break;
}
}
if (!isset($_GET['new'])) $_GET['new'] = 'post'; $date = ($isEdition) ? strtotime($post["date"]) : gmmktime();
$title = ($isEdition) ? htmlspecialchars(stripslashes($post["title"])) : "";
$body = ($isEdition) ? stripslashes($post["description"]) : "";
$url = ($isEdition) ? $post["url"] : "";
$theme->set('date',$date); if (!isset($_GET['new'])) $_GET['new'] = 'post';
$theme->set('id_user',$_SESSION['user_id']);
$theme->set('type',$_GET["new"]);
$theme->set('editBody',$body);
switch ($_GET["new"]) { $theme->set('date',$date);
case "post": $theme->set('id_user',$_SESSION['user_id']);
$theme->set('editTitle',$title); $theme->set('type',$_GET["new"]);
break; $theme->set('editBody',$body);
case "photo":
$url = str_replace("../", $conf->urlGelato."/", $url);
$theme->set('editUrl',$url);
break;
case "quote":
$theme->set('editTitle',$title);
break;
case "url":
$theme->set('editTitle',$title);
$theme->set('editUrl',$url);
break;
case "conversation":
$theme->set('editTitle',$title);
break;
case "video":
$theme->set('editUrl',$url);
break;
case "mp3":
$theme->set('editUrl',$url);
break;
}
if (!$isEdition){ switch ($_GET["new"]) {
if (isset($_GET["page"])) case "post":
$page_num = $_GET["page"]; $theme->set('editTitle',$title);
else break;
$page_num = NULL; case "photo":
$url = str_replace("../", $conf->urlGelato."/", $url);
$theme->set('editUrl',$url);
break;
case "quote":
$theme->set('editTitle',$title);
break;
case "url":
$theme->set('editTitle',$title);
$theme->set('editUrl',$url);
break;
case "conversation":
$theme->set('editTitle',$title);
break;
case "video":
$theme->set('editUrl',$url);
break;
case "mp3":
$theme->set('editUrl',$url);
break;
}
$limit=$conf->postLimit;
if(isset($page_num) && is_numeric($page_num) && $page_num>0)// Is defined the page and is numeric? if (!$isEdition){
$from = (($page_num-1) * $limit); if (isset($_GET["page"]))
else $page_num = $_GET["page"];
$from = 0; else
$page_num = NULL;
$rs = $tumble->getPosts($limit, $from); $limit=$conf->postLimit;
$theme->set('Posts_Number',$tumble->contarRegistros());
$rows = array(); if(isset($page_num) && is_numeric($page_num) && $page_num>0)// Is defined the page and is numeric?
if ($tumble->contarRegistros()>0) { $from = (($page_num-1) * $limit);
while($register = mysql_fetch_array($rs)) { else
$row['postType'] = type2Text($tumble->getType($register["id_post"])); $from = 0;
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime)); $rs = $tumble->getPosts($limit, $from);
$permalink = $tumble->getPermalink($register["id_post"]); $theme->set('Posts_Number',$tumble->contarRegistros());
$register["title"] = stripslashes($register["title"]); $rows = array();
$register["description"] = stripslashes($register["description"]); if ($tumble->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
$row['postType'] = type2Text($tumble->getType($register["id_post"]));
$row['Id_Post'] = $register["id_post"]; $formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
$row['Date_Added'] = $formatedDate; $strEnd=($conf->urlFriendly) ? "/" : "";
$row['Permalink'] = $permalink; $permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
switch ($tumble->getType($register["id_post"])) { $register["title"] = stripslashes($register["title"]);
case "1": $register["description"] = stripslashes($register["description"]);
$row['Title'] = $register["title"];
$row['Body'] = $register["description"];
break;
case "2":
$fileName = "../uploads/".getFileName($register["url"]);
$x = @getimagesize($fileName); $row['Id_Post'] = $register["id_post"];
if ($x[0] > 100) $row['Date_Added'] = $formatedDate;
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=100&img=".$register["url"]; $row['Permalink'] = $permalink;
else
$photoPath = $register["url"];
$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\""; switch ($tumble->getType($register["id_post"])) {
case "1":
$row['Title'] = $register["title"];
$row['Body'] = $register["description"];
break;
case "2":
$fileName = "../uploads/".getFileName($register["url"]);
$row['PhotoURL'] = $photoPath; $x = @getimagesize($fileName);
$row['PhotoAlt'] = strip_tags($register["description"]); if ($x[0] > 100)
$row['Caption'] = $register["description"]; $photoPath = $conf->urlGelato."/classes/imgsize.php?w=100&img=".$register["url"];
$row['Effect'] = $effect; else
break; $photoPath = $register["url"];
case "3":
$row['Quote'] = $register["description"];
$row['Source'] = $register["title"];
break;
case "4":
if($conf->shorten_links)
$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
$row['URL'] = $register["url"]; $effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
$row['Name'] = $register["title"];
$row['Description'] = $register["description"];
break;
case "5":
$row['Title'] = $register["title"];
$row['Conversation'] = $tumble->formatConversation($register["description"]);
break;
case "6":
$row['Video'] = $tumble->getVideoPlayer($register["url"]);
$row['Caption'] = $register["description"];
break;
case "7":
$row['Mp3'] = $tumble->getMp3Player($register["url"]);
$row['Caption'] = $register["description"];
break;
}
$rows[] = $row; $row['PhotoURL'] = $photoPath;
} $row['PhotoAlt'] = strip_tags($register["description"]);
$row['Caption'] = $register["description"];
$row['Effect'] = $effect;
break;
case "3":
$row['Quote'] = $register["description"];
$row['Source'] = $register["title"];
break;
case "4":
if($conf->shorten_links)
$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
$row['URL'] = $register["url"];
$limit=$conf->postLimit; $row['Name'] = $register["title"];
$row['Description'] = $register["description"];
if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric? break;
$from = (($page_num-1) * $limit); case "5":
} else { $row['Title'] = $register["title"];
$from = 0; $row['Conversation'] = $tumble->formatConversation($register["description"]);
} break;
case "6":
$rs = $tumble->getPosts($limit, $from); $row['Video'] = $tumble->getVideoPlayer($register["url"]);
$row['Caption'] = $register["description"];
if ($tumble->contarRegistros()>0) { break;
while($register = mysql_fetch_array($rs)) { case "7":
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime)); $row['Mp3'] = $tumble->getMp3Player($register["url"]);
$permalink = $tumble->getPermalink($register["id_post"]); $row['Caption'] = $register["description"];
$register["title"] = stripslashes($register["title"]); break;
$register["description"] = stripslashes($register["description"]); }
switch ($tumble->getType($register["id_post"])) {
case "1":
$input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($register["id_post"], $formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_regular_post");
$template->mostrarPlantilla();
break;
case "2":
$fileName = "../uploads/".getFileName($register["url"]);
$x = @getimagesize($fileName);
if ($x[0] > 100) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=100&img=".$register["url"];
} else {
$photoPath = $register["url"];
}
}
}
}
$p = new pagination; $rows[] = $row;
$p->items($tumble->getPostsNumber()); }
$p->limit($limit);
$p->currentPage(isset($page_num) ? $page_num : 1);
$theme->set('pagination',$p->getPagination()); $p = new pagination;
$theme->set('rows',$rows); $p->items($tumble->getPostsNumber());
}else{ $p->limit($limit);
$theme->set('error',__("No posts in this tumblelog.")); $p->currentPage(isset($page_num) ? $page_num : 1);
}
} $theme->set('pagination',$p->getPagination());
$theme->display(Absolute_Path.'admin/themes/admin/index.htm'); $theme->set('rows',$rows);
} }else{
$theme->set('error',__("No posts in this tumblelog."));
}
}
$theme->display(Absolute_Path.'admin/themes/admin/index.htm');
}
} else { } else {
header("Location: ".$conf->urlGelato."/login.php"); header("Location: ".$conf->urlGelato."/login.php");
} }
?> ?>