<?php
/*************************************************************
Desciption: Redireccionamento de artigos consoante categoria
File: /bsk/artigos/index.php
Project: Basikus.Net
Developers: João Vieira	
Start Date: 2009/05/21
**************************************************************/

if ( !isset($_GET['id']) ) exit();

$intId          = $_GET['id'];
$intCid         = 0;
$intResposta    = 0;
$strDestino     = '';

//Included main configuration file
require_once($_SERVER['DOCUMENT_ROOT'] . "/bsk/includes/configuracao.default.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/bsk/includes/funcoes.default.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/bsk/includes/classe.categorias.php");

//apanha categoria de conteudo que vem
$sqlStmt = "SELECT categorias_id FROM conteudos WHERE id = '" . $intId . "'";

$resultDb = $connectDb->pedido($sqlStmt);
if ($resultDb->rowCount() < 1) exit();
$rowResultDb    = $resultDb->fetch(PDO::FETCH_ASSOC);
$intCid         = $rowResultDb['categorias_id'];

$camRes = new BD_Categorias($connectDb);
$camRes->Caminho($intCid);
$arrCaminhoTmp  = explode("«|»", $camRes->resCaminho[count($camRes->resCaminho)-1]);
$intCid         = $arrCaminhoTmp[0];

switch ($intCid) {
    case 1:
            $strDestino = 'noticias';
            break;
    case 2:
            $strDestino = 'promocoes';
            break;
    case 3:
            $strDestino = 'eventos';
            break;
    default: 
                exit();
                break;
}

header('Location: /bsk/' . $strDestino . '/?' . $intId . '/alterar/#formPos');

?>
