<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2004 by Philippe Brunier   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
$header = 1;

function head() {
   global $slogan, $site_font, $Titlesitename, $banners, $Default_Theme, $gzhandler, $tiny_mce, $language;
   global $topic, $hlpfile, $user, $hr, $theme, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2, $bargif, $long_chain;

   if ($gzhandler==1) {ob_start("ob_gzhandler");}
   if (isset($user)) {
      global $cookie;
      if ($cookie[9]=="") $cookie[9]=$Default_Theme;
      if (isset($theme)) $cookie[9]=$theme;
      $tmp_theme=$cookie[9];
      if (!$file=@opendir("themes/$cookie[9]")) $tmp_theme=$Default_Theme;
   } else {
      $tmp_theme=$Default_Theme;
   }
   include("themes/$tmp_theme/theme.php");

   if (file_exists("meta/meta.php"))
      include ("meta/meta.php");
   echo "<title>$Titlesitename</title>\n";

   // Favicon
   if (file_exists("themes/$tmp_theme/images/favicon.ico")) {
      $favico="themes/$tmp_theme/images/favicon.ico";
   } else {
      $favico="images/favicon.ico";
   }
   echo "<link rel=\"shortcut icon\" href=\"$favico\" type=\"image/x-icon\" />\n";

   // Syndication RSS FF
   global $sitename;
   echo "<link href=\"backend.php?op=RSS0.91\" title=\"$sitename - RSS 0.91\" rel=\"alternate\" type=\"text/xml\" />\n";
   echo "<link href=\"backend.php?op=RSS1.0\" title=\"$sitename - RSS 1.0\" rel=\"alternate\" type=\"text/xml\" />\n";
   echo "<link href=\"backend.php?op=RSS2.0\" title=\"$sitename - RSS 2.0\" rel=\"alternate\" type=\"text/xml\" />\n";
   echo "<link href=\"backend.php?op=ATOM\" title=\"$sitename - ATOM\" rel=\"alternate\" type=\"application/atom+xml\" />\n";

   echo import_css($tmp_theme, $language, $site_font);

   if ($tiny_mce)
      echo aff_editeur("tiny_mce", "begin");
   echo "<script type=\"text/javascript\" language=\"JavaScript\">\n";
   echo "<!--\n";
   echo "function showimage() {\n";
   echo "if (!document.images)\n";
   echo "return\n";
   echo "document.images.avatar.src=\n";
   if ($ibid=theme_image("forum/avatar/blank.gif")) {$imgtmp=substr($ibid,0,strrpos($ibid,"/")+1);} else {$imgtmp="images/forum/avatar/";}
   echo "'$imgtmp' + document.Register.user_avatar.options[document.Register.user_avatar.selectedIndex].value\n";
   echo "}\n";
   echo "//-->\n";
   echo "</script>\n";
   echo "<script type=\"text/javascript\" language=\"JavaScript\">\n\n";
   echo "<!--\n";
   echo "function init() {\n\n";
      // include externe JAVASCRIPT file from modules/include or themes/.../include for functions, codes in the <body onload="..." event...
      if (file_exists("modules/include/body_onload.inc")) {include ("modules/include/body_onload.inc");}
      if (file_exists("themes/$tmp_theme/include/body_onload.inc")) {include ("themes/$tmp_theme/include/body_onload.inc");}
   echo "}\n";
   echo "//-->\n";
   echo "</script>\n";

   // include externe file from modules/include or themes/.../include for functions, codes ...
   if (file_exists("modules/include/header_head.inc")) {include ("modules/include/header_head.inc");}
   if (file_exists("themes/$tmp_theme/include/header_head.inc")) {include ("themes/$tmp_theme/include/header_head.inc");}
   echo "</head>\n\n";
   include("themes/$tmp_theme/header.php");
}

   // include externe file from modules/include for functions, codes ...
   if (file_exists("modules/include/header_before.inc")) {include ("modules/include/header_before.inc");}

   // Made the title and pdst value from the pages.php config file
   settype($PAGES, array());
   global $pdst, $Titlesitename, $PHP_SELF;
   require_once("themes/pages.php");
   $pages_ref=basename($PHP_SELF);
   if ($PAGES[$pages_ref][blocs]!="") {
      $pdst=$PAGES[$pages_ref][blocs];
   }
   // Static page and Module can have Title ....
   if ($pages_ref=="static.php") {
      global $REQUEST_URI;
      $pages_ref=substr($REQUEST_URI,strpos($REQUEST_URI,"static.php"));
   }
   if ($pages_ref=="modules.php") {
      global $REQUEST_URI;
      $pages_ref=substr($REQUEST_URI,strpos($REQUEST_URI,"modules.php"));
   }

   // block execution of page with run attribute = no
   if ($PAGES[$pages_ref][run]=="no") {
      if ($pages_ref=="index.php") {
          if (file_exists("meta/meta.php"))
             include("meta/meta.php");
         echo "<body bgcolor=\"white\"><br /><p align=\"center\"><span style=\"font-size: 14px; font-family: Arial; font-weight: bold; color: red;\">";
         echo "Web Site closed  / Site Web ferm&eacute;";
         if (cur_charset=="utf-8") echo" / &#x901A;&#x5165;&#x88AB;&#x5426;&#x8BA4;";
         echo "<br /><br />NPDS - Portal System";
         echo "</span></p></body></html>";
         die();
      } else {
         header("location: index.php");
      }
   } elseif (($PAGES[$pages_ref][run]!="yes") and (($PAGES[$pages_ref][run]!=""))) {
      header("location: ".$PAGES[$pages_ref][run]);
   }

   // Assure la gestion des titres ALTERNATIFS
   $tab_page_ref=explode("|",$PAGES[$pages_ref][title]);
   if (strlen($tab_page_ref[1])>1) {
      $PAGES[$pages_ref][title]=$tab_page_ref[1];
   } else {
      $PAGES[$pages_ref][title]=$tab_page_ref[0];
   }
   $PAGES[$pages_ref][title]=strip_tags($PAGES[$pages_ref][title]);

   if (substr($PAGES[$pages_ref][title],-1)=="+") {
      $TitlesitenameX=aff_langue(substr($PAGES[$pages_ref][title],0,strlen($PAGES[$pages_ref][title])-1));
      $TitlePageStats=$TitlesitenameX;
      $Titlesitename=$TitlesitenameX." - ".$Titlesitename;
   } else if (substr($PAGES[$pages_ref][title],-1)=="-") {
      $Titlesitename=aff_langue(substr($PAGES[$pages_ref][title],0,strlen($PAGES[$pages_ref][title])-1));
      $TitlePageStats=$Titlesitename;
   }
   if ($Titlesitename=="") {$Titlesitename=$sitename; $TitlePageStats="";}
   // globalisation de la variable title pour marquetapage mais protection pour la zone admin
   if ($pages_ref!="admin.php")
      global $title;
   if (!$title)
      $title=aff_langue(substr($PAGES[$pages_ref][title],0,strlen($PAGES[$pages_ref][title])-1));
   else
      $title=removeHack($title);

   head();

   // Menu dynamique des Rubriques - Alat 2004
   if (file_exists("sections.config.php")) {
      include ("sections.config.php");
      if ($sections_menudyn) { rubrique_menudyn(); }
   }

   global $httpref, $nuke_url, $httprefmax, $admin;
   if ($httpref==1) {
      $referer= removeHack(getenv("HTTP_REFERER"));
      if ($referer=="" OR strstr($referer,"unknown") OR stristr($referer,$nuke_url)) {
      } else {
         mysql_query("insert into referer values (NULL, '$referer')");
      }
      $result=mysql_fetch_array(mysql_query("select count(*) as total from referer"));
      if (($result[total]>=$httprefmax) and ($admin)) {
         echo " <span class=\"ROUGE\">".translate("Referer max count limit : Save your referer via Admin function.")."</span>";
      }
   }
   include("counter.php");

   // include externe file from modules/include for functions, codes ...
   if (file_exists("modules/include/header_after.inc")) {include ("modules/include/header_after.inc");}
?>