Fixed apostrophe's bug

master
pecesama 2007-07-18 04:39:24 +00:00
parent 8443382cb1
commit c6321c7d34
3 changed files with 254 additions and 245 deletions

View File

@ -236,8 +236,8 @@ if ($user->isAdmin()) {
} }
$date = ($isEdition) ? strtotime($post["date"]) : time(); $date = ($isEdition) ? strtotime($post["date"]) : time();
$title = ($isEdition) ? $post["title"] : ""; $title = ($isEdition) ? stripslashes($post["title"]) : "";
$body = ($isEdition) ? $post["description"] : ""; $body = ($isEdition) ? stripslashes($post["description"]) : "";
$url = ($isEdition) ? $post["url"] : ""; $url = ($isEdition) ? $post["url"] : "";
switch ($_GET["new"]) { switch ($_GET["new"]) {
@ -347,6 +347,9 @@ if ($user->isAdmin()) {
$textile = new Textile; $textile = new Textile;
$register["description"] = $textile->process($register["description"]); $register["description"] = $textile->process($register["description"]);
$register["title"] = stripslashes($register["title"]);
$register["description"] = stripslashes($register["description"]);
switch ($tumble->getType($register["id_post"])) { switch ($tumble->getType($register["id_post"])) {
case "1": case "1":
$input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}"); $input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");

View File

@ -197,7 +197,7 @@
return false; return false;
} }
$f = fsockopen($data['host'], ($data['port']) ? $data['port'] : 80, $e1, $e2, 3); $f = @fsockopen($data['host'], ($data['port']) ? $data['port'] : 80, $e1, $e2, 3);
if (!$f) { if (!$f) {
return false; return false;
} }

490
index.php
View File

@ -10,253 +10,259 @@
=========================== */ =========================== */
?> ?>
<?php <?php
// My approach to MVC // My approach to MVC
$configFile = dirname(__FILE__).DIRECTORY_SEPARATOR."config.php"; $configFile = dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
if (!file_exists($configFile)) { if (!file_exists($configFile)) {
$mensaje = " $mensaje = "
<h3 class=\"important\">Error reading configuration file</h3> <h3 class=\"important\">Error reading configuration file</h3>
<p>There doesn't seem to be a <code>config.php</code> file. I need this before we can get started.</p> <p>There doesn't seem to be a <code>config.php</code> file. I need this before we can get started.</p>
<p>This either means that you did not rename the <code>config-sample.php</code> file to <code>config.php</code>.</p>"; <p>This either means that you did not rename the <code>config-sample.php</code> file to <code>config.php</code>.</p>";
die($mensaje); die($mensaje);
} else { } else {
require(dirname(__FILE__).DIRECTORY_SEPARATOR."config.php"); require(dirname(__FILE__).DIRECTORY_SEPARATOR."config.php");
} }
include("classes/configuration.class.php"); include("classes/configuration.class.php");
include("classes/textile.class.php"); include("classes/textile.class.php");
include("classes/gelato.class.php"); include("classes/gelato.class.php");
include("classes/templates.class.php"); include("classes/templates.class.php");
include("classes/pagination.class.php"); include("classes/pagination.class.php");
include("classes/user.class.php"); include("classes/user.class.php");
$user = new user(); $user = new user();
$conf = new configuration(); $conf = new configuration();
$tumble = new gelato(); $tumble = new gelato();
$template = new plantillas($conf->template); $template = new plantillas($conf->template);
if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']); if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']);
if (isset($_GET["post"])) { if (isset($_GET["post"])) {
$id_post = $_GET["post"]; $id_post = $_GET["post"];
} else { } else {
if (isset($param_url[1]) && $param_url[1]=="post") { if (isset($param_url[1]) && $param_url[1]=="post") {
$id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL; $id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
} else { } else {
$id_post = NULL; $id_post = NULL;
} }
} }
if (isset($_GET["page"])) { if (isset($_GET["page"])) {
$page_num = $_GET["page"]; $page_num = $_GET["page"];
} else { } else {
if (isset($param_url[1]) && $param_url[1]=="page") { if (isset($param_url[1]) && $param_url[1]=="page") {
$page_num = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL; $page_num = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
} else { } else {
$page_num = NULL; $page_num = NULL;
} }
} }
$gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"; $gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
$gelato_includes .= "\t<meta name=\"generator\" content=\"gelato cms ".version()."\" />\n"; $gelato_includes .= "\t<meta name=\"generator\" content=\"gelato cms ".version()."\" />\n";
$gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n"; $gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n";
$gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato."/rss.php\"/>\n"; $gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato."/rss.php\"/>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n"; $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/slimbox.css\" />\n"; $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/slimbox.css\" />\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/mootools.js\"></script>\n"; $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/mootools.js\"></script>\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/slimbox.js\"></script>"; $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/slimbox.js\"></script>";
$input = array("{Gelato_includes}","{Title}", "{Description}", "{URL_Tumble}", "{Template_name}"); $input = array("{Gelato_includes}","{Title}", "{Description}", "{URL_Tumble}", "{Template_name}");
$output = array($gelato_includes, $conf->title, $conf->description, $conf->urlGelato, $conf->template); $output = array($gelato_includes, $conf->title, $conf->description, $conf->urlGelato, $conf->template);
$template->cargarPlantilla($input, $output, "template_header"); $template->cargarPlantilla($input, $output, "template_header");
$template->mostrarPlantilla(); $template->mostrarPlantilla();
if ($user->isAdmin()) { if ($user->isAdmin()) {
$input = array("{User}", "{URL_Tumble}"); $input = array("{User}", "{URL_Tumble}");
$output = array($_SESSION["user_login"], $conf->urlGelato); $output = array($_SESSION["user_login"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_isadmin"); $template->cargarPlantilla($input, $output, "template_isadmin");
$template->mostrarPlantilla(); $template->mostrarPlantilla();
} }
if (!$id_post) { if (!$id_post) {
$limit=$conf->postLimit; $limit=$conf->postLimit;
if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric? if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric?
$from = (($page_num-1) * $limit); $from = (($page_num-1) * $limit);
} else { } else {
$from = 0; $from = 0;
} }
$rs = $tumble->getPosts($limit, $from); $rs = $tumble->getPosts($limit, $from);
if ($tumble->contarRegistros()>0) { if ($tumble->contarRegistros()>0) {
$fecha = null; $fecha = null;
while($register = mysql_fetch_array($rs)) { while($register = mysql_fetch_array($rs)) {
$formatedDate = date("M d", strtotime($register["date"])); $formatedDate = date("M d", strtotime($register["date"]));
if ( $fecha != null && $formatedDate == $fecha ) { $formatedDate = ""; } else { $fecha = $formatedDate; } if ( $fecha != null && $formatedDate == $fecha ) { $formatedDate = ""; } else { $fecha = $formatedDate; }
$permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/"; $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
$textile = new Textile; $textile = new Textile;
$register["description"] = $textile->process($register["description"]); $register["description"] = $textile->process($register["description"]);
switch ($tumble->getType($register["id_post"])) {
case "1":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($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] > 500) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
} else {
$photoPath = $register["url"];
}
$effect = " onclick=\"Lightbox.show('".$register["url"]."', '".strip_tags($register["description"])."');\" ";
$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_photo");
$template->mostrarPlantilla();
break;
case "3":
$input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_quote");
$template->mostrarPlantilla();
break;
case "4":
$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_url");
$template->mostrarPlantilla();
break;
case "5":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_conversation");
$template->mostrarPlantilla();
break;
case "6":
$input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video");
$template->mostrarPlantilla();
break;
case "7":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3");
$template->mostrarPlantilla();
break;
}
}
$p = new pagination; $register["title"] = stripslashes($register["title"]);
$p->Items($tumble->getPostsNumber()); $register["description"] = stripslashes($register["description"]);
$p->limit($limit);
switch ($tumble->getType($register["id_post"])) {
$p->urlFriendly('[...]'); case "1":
$p->target($conf->urlGelato."/index.php/page/[...]/"); $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
$p->currentPage(isset($page_num) ? $page_num : 1);
$p->show(); $template->cargarPlantilla($input, $output, "template_regular_post");
$template->mostrarPlantilla();
break;
case "2":
$fileName = "uploads/".getFileName($register["url"]);
$x = @getimagesize($fileName);
if ($x[0] > 500) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
} else {
$photoPath = $register["url"];
}
$effect = " onclick=\"Lightbox.show('".$register["url"]."', '".strip_tags($register["description"])."');\" ";
$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_photo");
$template->mostrarPlantilla();
break;
case "3":
$input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_quote");
$template->mostrarPlantilla();
break;
case "4":
$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_url");
$template->mostrarPlantilla();
break;
case "5":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_conversation");
$template->mostrarPlantilla();
break;
case "6":
$input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video");
$template->mostrarPlantilla();
break;
case "7":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3");
$template->mostrarPlantilla();
break;
}
}
$p = new pagination;
$p->Items($tumble->getPostsNumber());
$p->limit($limit);
$p->urlFriendly('[...]');
$p->target($conf->urlGelato."/index.php/page/[...]/");
$p->currentPage(isset($page_num) ? $page_num : 1);
$p->show();
} else { } else {
$template->renderizaEtiqueta("No posts in this tumblelog.", "div","error"); $template->renderizaEtiqueta("No posts in this tumblelog.", "div","error");
} }
} else { } else {
$register = $tumble->getPost($id_post); $register = $tumble->getPost($id_post);
$formatedDate = date("M d", strtotime($register["date"])); $formatedDate = date("M d", strtotime($register["date"]));
$permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/"; $permalink = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
$textile = new Textile; $textile = new Textile;
$register["description"] = $textile->process($register["description"]); $register["description"] = $textile->process($register["description"]);
switch ($tumble->getType($register["id_post"])) {
case "1":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($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] > 500) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
} else {
$photoPath = $register["url"];
}
$effect = " onclick=\"Lightbox.show('".$register["url"]."', '".strip_tags($register["description"])."');\" "; $register["title"] = stripslashes($register["title"]);
$register["description"] = stripslashes($register["description"]);
$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato); switch ($tumble->getType($register["id_post"])) {
case "1":
$template->cargarPlantilla($input, $output, "template_photo"); $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$template->mostrarPlantilla(); $output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
break;
case "3": $template->cargarPlantilla($input, $output, "template_regular_post");
$input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}"); $template->mostrarPlantilla();
$output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato); break;
case "2":
$template->cargarPlantilla($input, $output, "template_quote"); $fileName = "uploads/".getFileName($register["url"]);
$template->mostrarPlantilla();
break; $x = @getimagesize($fileName);
case "4": if ($x[0] > 500) {
$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}"); $photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
$output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato); } else {
$photoPath = $register["url"];
$template->cargarPlantilla($input, $output, "template_url"); }
$template->mostrarPlantilla();
break; $effect = " onclick=\"Lightbox.show('".$register["url"]."', '".strip_tags($register["description"])."');\" ";
case "5":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}"); $input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato); $output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_conversation"); $template->cargarPlantilla($input, $output, "template_photo");
$template->mostrarPlantilla(); $template->mostrarPlantilla();
break; break;
case "6": case "3":
$input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}"); $input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato); $output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video"); $template->cargarPlantilla($input, $output, "template_quote");
$template->mostrarPlantilla(); $template->mostrarPlantilla();
break; break;
case "7": case "4":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}"); $input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato); $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3"); $template->cargarPlantilla($input, $output, "template_url");
$template->mostrarPlantilla(); $template->mostrarPlantilla();
break; break;
} case "5":
} $input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($register["description"]), $conf->urlGelato);
$input = array("{URL_Tumble}");
$output = array($conf->urlGelato); $template->cargarPlantilla($input, $output, "template_conversation");
$template->mostrarPlantilla();
$template->cargarPlantilla($input, $output, "template_footer"); break;
$template->mostrarPlantilla(); case "6":
?> $input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video");
$template->mostrarPlantilla();
break;
case "7":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3");
$template->mostrarPlantilla();
break;
}
}
$input = array("{URL_Tumble}");
$output = array($conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_footer");
$template->mostrarPlantilla();
?>