define("DYDPHP",TRUE);
// Saca la ruta de donde nos han incluido
$paths=get_included_files();
foreach ($paths as $i) {
$name=basename($i);
if (strstr($name,'dydphp')) {
$path=dirname($i);
include($path.'/'.'config.php');
if (!$install_dir) {
# si no definen en la config el directorio donde reside la libreria, lo deducimos nosotros
$install_dir=$path.'/';
}
}
}
if (file_exists("./header.php")) {
include "./header.php";
} else {
include $install_dir."/header.php";
}
include($install_dir."/debug.php");
include($install_dir."/db.php");
include($install_dir."/session.php");
include($install_dir."/render.php");
include($install_dir."/utils.php");
include($install_dir."/htmleditor.php");
include($install_dir."/calendar.php");
include($install_dir."/menu.php");
include($install_dir."/form.php");
include($install_dir."/nicoform.php");
include($install_dir."/supertable.php");
include($install_dir."/supertable2/Supertable2.php");
include($install_dir."/mailMime.php");
include($install_dir."/tree.php");
include($install_dir."/formdraw.php");
include($install_dir."/list.php");
include($install_dir."/button.php");
include($install_dir."/date.php");
include($install_dir."/treemenu/treemenu.php");
include($install_dir."/fckeditor/fckeditor.php");
#include_once($install_dir."/phpmailer/class.phpmailer.php");
function run ($dir='')
{
global $session, $noautosession;
// Construye el objeto global de sesion
# No se puede: jode muchas cosas
#$session=new Session();
if ($noautosession==1) {
$session = new Session();
}
$result=render($dir);
if (!headers_sent()) {
echo $result;
}
}
?>
function obtener_sigla_idioma($idioma)
{
if($idioma && $idioma!="es")
return "_$idioma";
else
return "";
}
function screen_load_template()
{
$plantilla=arg("plantilla");
$idioma=arg("idioma");
$idioma=str_replace("'", "", $idioma);
$plantilla=str_replace("'", "", $plantilla);
$sigla_idioma=obtener_sigla_idioma($idioma);
switch ($plantilla) {
case 'noticias':
$t=array(
"body"=>load_noticias_novedades(1 , $idioma),
);
break;
case 'actualidad':
$t=array(
"body"=>load_noticias_novedades(2 , $idioma),
);
break;
default:
$t=array(
"body"=>ftemplate_v2("$plantilla$sigla_idioma.html"),
);
break;
}
return ftemplate_v2("index$sigla_idioma.html",$t);
}
function screen_load_novedades()
{
global $db;
$tipo_novedad=arg("tipo_novedad");
$idioma=arg("idioma");
return load_noticias_novedades($tipo_novedad , $idioma);
}
function load_noticias_novedades($tipo_novedad , $idioma)
{
global $db;
if(!$idioma)$idioma="es";
$db->exec("SELECT * FROM novedades WHERE id_tipo_novedad=$tipo_novedad ORDER BY fecha DESC");
for($x=0;$x<$db->count() && $x<=5;$x++)
{
$reg=$db->rowAs();
if($reg["imagen"])
if(strpos ( $reg["imagen"] , 'pdf') || strpos ( $reg["imagen"] , 'doc') )
$foto="Download PDF";
else
$foto="
";
else
$foto="";
$t=array(
"id"=>$reg["id"],
"titulo"=>$reg["titulo_$idioma"],
"fecha"=>iso2es ($reg["fecha"]),
"foto"=>$foto,
"noticia"=>$reg["desc_corta_$idioma"],
"ampliada"=>$reg["desc_larga_$idioma"],
);
$list_novedades.=ftemplate_v2("noticia.html",$t);
}
switch($tipo_novedad)
{
case 1:
if($idioma=="es")
{
$titnovnot="Nuestras Noticias";
}
else
{
$titnovnot="News";
}
break;
case 2:
if($idioma=="es")
{
$titnovnot="Actualidad";
}
else
{
$titnovnot="Actuality";
}
break;
}
$t2=array(
"titnovnot"=>$titnovnot,
"contenido-news"=>$list_novedades,
);
return ftemplate_v2("noticias.html",$t2);
}
function ftemplate_v2($templ,$data="")
{
global $template_dir;
$templ=str_replace(" ", "", $templ);
$templ=str_replace("'", "", $templ);
$filename1=$template_dir."/".$templ;
if (file_exists($filename1))
return ftemplate($templ,$data);
else
{
header('Location: index.php?jump=main');
exit;
}
}
?>