=========================== */ ?> template); // My approach to MVC if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']); if (isset($_GET["post"])) { $id_post = $_GET["post"]; if (!is_numeric($id_post) || $id_post < 1 ){ header("Location: index.php"); } } else { 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; } else { $id_post = NULL; } } if (isset($_GET["page"])) { $page_num = $_GET["page"]; } else { 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; } else { $page_num = NULL; } } $gelato_includes = "\n"; $gelato_includes .= "\t\n"; $gelato_includes .= "\turlGelato."/images/favicon.ico\" />\n"; $gelato_includes .= "\turlGelato.($conf->urlFriendly?"/rss/":"/rss.php")."\"/>\n"; $gelato_includes .= "\turlGelato."/themes/".$conf->template."/style.css\"/>\n"; $gelato_includes .= "\turlGelato."/admin/css/lightbox.css\" />\n"; $gelato_includes .= "\t\n"; $gelato_includes .= "\t"; $page_title = $conf->title; $page_title_divisor = " » "; // it should be set in configuration $page_title_len = 50; // it should be set in configuration if ($id_post) { $register = $tumble->getPost($id_post); $textile = new Textile(); if (empty($register["title"])) { if (!empty($register["description"])) { if (strlen($register["description"]) > $page_title_len) { $page_title_data = substr($register["description"], 0, $page_title_len)."..."; } } } else { $page_title_data = $register["title"]; } $page_title_data = strip_tags($textile->TextileThis($page_title_data)); if (!empty($page_title_data)) { $page_title .= $page_title_divisor.stripslashes($page_title_data); } } $input = array("{Gelato_includes}","{Title}", "{Page_Title}", "{Description}", "{URL_Tumble}", "{Template_name}"); $output = array($gelato_includes, $conf->title, $page_title, $conf->description, $conf->urlGelato, $conf->template); $template->cargarPlantilla($input, $output, "template_header"); $template->mostrarPlantilla(); if ($user->isAuthenticated()) { $input = array("{User}", "{URL_Tumble}"); $output = array($_SESSION["user_login"], $conf->urlGelato); $template->cargarPlantilla($input, $output, "template_isadmin"); $template->mostrarPlantilla(); } if (!$id_post) { $limit=$conf->postLimit; if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric? $from = (($page_num-1) * $limit); } else { $from = 0; } $rs = $tumble->getPosts($limit, $from); if ($tumble->contarRegistros()>0) { $dateTmp = null; while($register = mysql_fetch_array($rs)) { $formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime)); if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; } $strEnd=($conf->urlFriendly) ? "/" : ""; $permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd; $conversation = $register["description"]; $register["description"] = $register["description"]; $register["title"] = stripslashes($register["title"]); $register["description"] = stripslashes($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 = str_replace("../", $conf->urlGelato."/", $register["url"]); } $effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\""; $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": 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"]; $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($conversation), $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); if($conf->urlFriendly){ $p->urlFriendly('[...]'); $p->target($conf->urlGelato."/page/[...]"); }else $p->target($conf->urlGelato); $p->currentPage(isset($page_num) ? $page_num : 1); $p->show(); } else { $template->renderizaEtiqueta("No posts in this tumblelog.", "div","error"); } } else { $register = $tumble->getPost($id_post); $formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime)); $strEnd=($conf->urlFriendly) ? "/" : ""; $permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd; $conversation = $register["description"]; $register["description"] = $register["description"]; $register["title"] = stripslashes($register["title"]); $register["description"] = stripslashes($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 = str_replace("../", $conf->urlGelato."/", $register["url"]); } $effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\""; $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": 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"]; $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($conversation), $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; } if ($conf->allowComments) { $comment = new comments(); $rsComments = $comment->getComments($register["id_post"]); $textile = new Textile(); if (empty($register["title"])) { if (!empty($register["description"])) { if (strlen($register["description"]) > 30) { $postTitle = substr($register["description"], 0, 30)."..."; } } } else { $postTitle = $register["title"]; } $postTitle = strip_tags($textile->TextileThis($postTitle)); $input = array("{Comments_Number}", "{Post_Title}"); $output = array($comment->countComments($register["id_post"]), $postTitle); $template->precargarPlantillaConBloque($input, $output, "template_comments", "comments"); while($rowComment = mysql_fetch_assoc($rsComments)) { $commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "".$rowComment["username"].""; $input = array("{Id_Comment}", "{Comment_Author}", "{Date}", "{Comment}"); $output = array($rowComment["id_comment"], $commentAuthor, gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime)), $rowComment["content"]); $template->cargarPlantillaConBloque($input, $output, "template_comments", "comments"); } $template->mostrarPlantillaConBloque(); $input = array("{User_Cookie}", "{Email_Cookie}", "{Web_Cookie}", "{Id_Post}", "{Form_Action}", "{Date_Added}"); $output = array(isset($_COOKIE['cookie_gel_user'])?$_COOKIE['cookie_gel_user']:'', isset($_COOKIE['cookie_gel_email'])?$_COOKIE['cookie_gel_email']:'', isset($_COOKIE['cookie_gel_web'])?$_COOKIE['cookie_gel_web']:'', $register["id_post"], $conf->urlGelato."/admin/comments.php", gmmktime()); $template->cargarPlantilla($input, $output, "template_comment_post"); $template->mostrarPlantilla(); } } $input = array("{URL_Tumble}"); $output = array($conf->urlGelato); $template->cargarPlantilla($input, $output, "template_footer"); $template->mostrarPlantilla(); ?>