<?php

require ("constants.inc");

// --------------------------------------------------------------------
// class PortalHorNavi
//
// 2003-03-12 - version 0
//
//
// Modified 1.10.2025 for PHP 8.x compatibility - Jani E.
// + Internet Providers disable by default (for security reasons) GLOBALS.

class PortalHorNavi {

  var $parId;

  var $template = 0;
  var $indent = 0;
  var $title = "";
  var $bgcolor = "#ffffff";
  var $background = "";
  var $fill = "";

  var $metaAuthor = "";
  var $metaDescription = "";
  var $metaKeywords = "";
  var $metaRefresh = "";
//  var $metaCharset = "iso-8859-1";
  var $metaCharset = "utf-8";

  var $headerStyleSheet = "";
  var $headerJavascript = "";

  var $wwwPreContent ="";
  var $wwwContent = "<null>";
  var $wwwPostContent ="";
  var $wwwSubMenu ="";
  var $doc;

  var $naviItems = 0;
  var $lastnav = 0;
  var $navi;
  var $id;
  var $pid;
  var $nav;
  var $link;

  var $boxWidth = 700;
  var $boxBorderWidth = 2;
  var $boxColor = "#ffffff";
  var $boxBorderColor = "#000000";
  var $boxHeight = 0; // useless?

  var $menuHeight = 20;
  var $menuWidth;
  var $menuColor = "#ffffff";
  var $menuText = "#000000";
  var $menuSelColor = "#cccccc";
  var $menuSelText = "#000000";
  var $menuBorderWidth = 2;
  var $menuBorderColor = "#c0c0c0";

  var $naviWidth = 150;
  var $naviColor = "#ffffff";
  var $naviBackground = "";
  var $naviText = "#000000";
  var $naviSelColor = "#cccccc";
  var $naviBorderWidth = 2;
  var $naviBorderColor = "#c0c0c0";

  var $contentWidth;
  var $contentColor = "";
  var $contentBackground = "";
  var $contentText = "#000000";
  var $contentBorderWidth = 2;
  var $contentBorderColor = "#000000";

  var $bannerWidth;
  var $bannerBorderWidth = 2;
  var $bannerColor = "#ffffff";
  var $bannerBorderColor = "#444444";
  var $bannerHeight = 90;
  var $bannerPicture = "";
  var $bannerLink = "index.php";
  var $bannerSeparator = 0;

  var $dbhost; 
  var $db; 
  var $dbuser;
  var $dbpassword;
  var $dbtable;

// ----------
// contructor

function PortalHorNavi($argId, $argPid) {

//global $HOST, $DB, $WEBUSER, $WEBPASSWORD; 
//global $TRUE, $FALSE; 
         
$this->dbhost = $HOST; 
$this->db = $DB; 
$this->dbuser = $WEBUSER;
$this->dbpassword = $WEBPASSWORD; 

$argId = $_GET['id'];
$this->id = (int) $argId;
if ($argId == "") $this->id = 0;
if ($argId < 0) $this->id = 0;

$argPid = $_GET['pid']; 
$this->pid = (int) $argPid;
if ($argPid == "") $this->pid = 0;
if ($argPid < 0) $this->pid = 0;

$this->parId = $argId;
$this->wwwContent = "";

} // --


// -------------
// set-functions

function setTemplate($arg) { $this->template = $arg; }
function setTitle($arg) { $this->title = $arg; }
function setBgColor($arg) { $this->bgcolor = $arg; }
function setBgTexture($arg) { $this->background = $arg; }
function setFillerPixel($arg) { $this->fill = $arg; }
function setMetaAuthor($arg) { $this->metaAuthor = $arg; }
function setMetaDescription($arg) { $this->metaDescription = $arg; }
function setMetaKeywords($arg) { $this->metaKeywords = $arg; }
function setMetaRefresh($arg) { $this->metaRefresh = $arg; }
function setMetaCharset($arg) { $this->metaCharset = $arg; }
function setFileStylesheet($arg) { $this->headerStylesheet = $arg; }
function setFileJavascript($arg) { $this->headerJavascript = $arg; }

function setBoxWidth($arg) { $this->boxWidth = $arg; }
function setBoxBorderWidth($arg) { $this->boxBorderWidth = $arg; }
function setBoxColor($arg) { $this->boxColor = $arg; }
function setBoxBorderColor($arg) {  $this->boxBorderColor = $arg; }
function setIndent($arg) { $this->indent = $arg; }
function setBoxHeight($arg) { $this->boxHeight = $arg; }

function setBannerBorderWidth($arg) { $this->bannerBorderWidth = $arg; }
function setBannerColor($arg) {  $this->bannerColor = $arg; }
function setBannerBorderColor($arg) {  $this->bannerBorderColor = $arg; }
function setBannerHeight($arg) { $this->bannerHeight = $arg; }
function setBannerPicture($arg) { $this->bannerPicture = $arg; }
function setBannerLink($arg) { $this->bannerLink = $arg; }
function setBannerSeparator($arg) { $this->bannerSeparator = $arg; }

function setMenuHeight($arg) { $this->menuHeight = $arg; }
function setMenuColor($arg) { $this->menuColor = $arg; }
function setMenuText($arg) { $this->menuText = $arg; }
function setMenuSelColor($arg) { $this->menuSelColor = $arg; }
function setMenuSelText($arg) { $this->menuSelText = $arg; }
function setMenuBorderWidth($arg) { $this->menuBorderWidth = $arg; }
function setMenuBorderColor($arg) { $this->menuBorderColor = $arg; }

function setNaviWidth($arg) { $this->naviWidth = $arg; }
function setNaviColor($arg) { $this->naviColor = $arg; }
function setNaviText($arg) { $this->naviText = $arg; }
function setNaviSelColor($arg) { $this->naviSelColor = $arg; }
function setNaviBorderWidth($arg) { $this->naviBorderWidth = $arg; }
function setNaviBorderColor($arg) { $this->naviBorderColor = $arg; }
function setNaviBackground($arg) { $this->naviBackground = $arg; }

function setContentBorderWidth($arg) { $this->contentBorderWidth = $arg; } 
function setContentBorderColor($arg) { $this->contentBorderColor = $arg; }
function setContentColor($arg) { $this->contentColor = $arg; }
function setContentBackground($arg) { $this->contentBackground = $arg; }
function setContentText($arg) { $this->contentText = $arg; }

function setDbTable($arg) { $this->dbtable = $arg; }

// -----
// flush

function flush () {

  $this->doc ="";
  $this->forgeStartDoc();
  $this->forgeHeader();
  $this->forgeStartBody();
  $this->forgeBanner();
  $this->forgeMenu();
  $this->getPostContent();
  $this->forgeContent();
  $this->forgeEndBody();
  $this->forgeEndDoc();
  print $this->doc;

} // --


// -----------------------
// forge start of document

function forgeStartDoc () {

  // $f = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n";
  //$f = "<!DOCTYPE html>\n";
  $f = "<html>\n";
  $this->doc .= $f;

} // --


// -----------------
// forge header data

function forgeHeader () {

  $f = "<head>\n";
//  $f .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=$this->metaCharset\">\n";
  $f .= "<meta charset=\"$this->metaCharset\">\n";

  $f .= "<meta name=\"Author\" content=\"$this->metaAuthor\">\n";
  $f .= "<meta name=\"description\" content=\"$this->metaDescription\">\n";
  $f .= "<meta name=\"keywords\" content=\"$this->metaKeywords\">\n";
  $f .= ($this->metaRefresh != "") ? "<meta http-equiv=\"Refresh\" content=\"$this->metaRefresh\">\n" : "";
  $f .= "<title>$this->title</title>\n";
  $f .= ($this->headerStylesheet != "") ? "<link rel=StyleSheet href=\"$this->headerStylesheet\" type=\"text/css\" media=screen>\n" : "";
  $f .= ($this->headerJavascript != "") ? "<script src=\"scripts/$this->headerJavascript\" type=\"text/javascript\" language=\"javascript\"></script>\n" : "";
  $f .= "</head>\n";
  $this->doc .= $f;

} // --


// -------------------
// forge start of body

function forgeStartBody () {

  $f  = "<body ";
  $f .= ($this->background != "") ? "background=\"$this->background\" " : "";
  $f .= ($this->bgcolor != "") ? "bgcolor=\"$this->bgcolor\"" : "";
  $f .= ">\n";
  $f .= ($this->indent > 0) ? "" : "<center>\n";
  $f .= "<table leftmargin=0 topmargin=0 cellpadding=0 cellspacing=0 border=0>\n<tr>\n";
  $f .= ($this->indent > 0) ? "<td width=\"$this->indent\"><img src=\"$this->fill\" width=\"$this->indent\" alt=\"\"></td>\n" : "";
  $f .= "<td>";
  $this->doc .= $f;

} // --


// -----------------
// forge end of body

function forgeEndBody () {

  $f = ($this->indent == 0) ? "</center>\n" : "";
  $f .= "</td>\n</tr>\n</table>\n</body>\n";
  $this->doc .= $f;

} // --


// ----------------
// forge end of doc

function forgeEndDoc () {

  $f = "</html>";
  $this->doc .= $f;

} // --

// ------------
// forge banner

function forgeBanner () {

  $bannerAreaWidth = $this->boxWidth - (2 * $this->boxBorderWidth);
  $this->bannerWidth = $bannerAreaWidth - (2 * $this->bannerBorderWidth);

  // top box line
  $f = "<table leftmargin=\"0\" topmargin=\"0\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
  $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";

  // top banner line

  $f .= "<tr>\n";
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawHorLine($bannerAreaWidth, $this->bannerBorderWidth, $this->bannerBorderColor, "valign=top colspan=3 align=center");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= "</tr>\n";

  // banner 

  $f .= "<tr>\n";
  $f .= $this->drawVerLine($this->bannerHeight, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawVerLine($this->bannerHeight, $this->bannerBorderWidth, $this->bannerBorderColor, "");
  $f .= "<td align=center bgcolor=\"$this->bannerColor\">";
  $f .= ($this->bannerLink != "") ? "<a href=\"$this->bannerLink\">" : "";
  $f .= "<img src=\"$this->bannerPicture\" width=\"$this->bannerWidth\" height=\"$this->bannerHeight\" border=\"0\" alt=\"\">";
  $f .= ($this->bannerLink != "") ? "</a>" : "";
  $f .= "</td>\n";
  $f .= $this->drawVerLine($this->bannerHeight, $this->bannerBorderWidth, $this->bannerBorderColor, "");
  $f .= $this->drawVerLine($this->bannerHeight, $this->boxBorderWidth, $this->boxBorderColor, "") . "</tr>\n";

  // bottom banner line

  $f .= "<tr>\n";
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawHorLine($bannerAreaWidth, $this->bannerBorderWidth, $this->bannerBorderColor, "valign=top colspan=3 align=center");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= "</tr>\n";

  // bottom box line

  $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";
  
  // banner separator
  
  if ($this->bannerSeparator > 0) {
    $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";
    $f .= "<tr>\n" . $this->drawVerLine($this->bannerSeparator, 1, "", "valign=top colspan=5 align=center") . "</tr>\n";
    $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";
  }

  $f .= "</table>\n";
  $this->doc .= $f;
  
} // --

// ----------
// forge menu

function forgeMenu () {

  $menuAreaWidth = $this->boxWidth - (2 * $this->boxBorderWidth);
  $this->menuWidth = $menuAreaWidth - (2 * $this->menuBorderWidth);

  // top box line

  $f = "<table leftmargin=\"0\" topmargin=\"0\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
  // $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";

  // top menu area line
  //$f .= "<tr>\n";
  //$f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  //$f .= $this->drawHorLine($menuAreaWidth, $this->bannerBorderWidth, $this->menuBorderColor, "valign=top colspan=3 align=center");
  //$f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  //$f .= "</tr>\n";

  // menu items horizontally 

  // netscape 4.7x patch

  $f .= "<tr>\n";
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawHorLine($this->menuBorderWidth, $this->menuBorderWidth, $this->menuBorderColor, "");

  $f .= "<td height=\"$this->menuBorderWidth\">\n<table width=\"$this->menuWidth\" leftmargin=\"0\" topmargin=\"0\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n";

  if ($this->naviItems > 0) {

    $koko = $this->boxWidth - (2 * $this->boxBorderWidth) - (2 * $this->menuBorderWidth);
    $eka = $this->naviWidth - $this->naviBorderWidth;
    $loput = $koko - $eka;
    $kpl = $this->naviItems-1;
    $solu = intval($loput/$kpl);
    $jaannos = $loput - $kpl*$solu;
    $vika = $solu + $jaannos;

    for ($i = 0; $i < $this->naviItems; ++$i) {

      switch ($i) {

        case 0:
          $f .= $this->drawHorLine($eka, $this->menuBorderWidth, $this->menuBorderColor, "");
          $celw[$i] = $eka;
          break;

        case $this->naviItems-1:
          $f .= $this->drawHorLine($vika, $this->menuBorderWidth, $this->menuBorderColor, "");
          $celw[$i] = $vika;
          break;

        default:
          $f .= $this->drawHorLine($solu, $this->menuBorderWidth, $this->menuBorderColor, "");
          $celw[$i] = $solu;
      }

    }

    $f .=  "</tr>\n</table>\n";
  }

  $f .= "</td>\n";
  $f .= $this->drawHorLine($this->menuBorderWidth, $this->menuBorderWidth, $this->menuBorderColor, "");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "") . "</tr>\n";

  //  menu

  $f .= "<tr>\n";
  $f .= $this->drawVerLine($this->menuHeight, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawVerLine($this->menuHeight, $this->menuBorderWidth, $this->menuBorderColor, "");

  $f .= "<td bgcolor=\"$this->menuColor\" valign=\"top\">\n<table width=\"$this->menuWidth\" leftmargin=\"0\" topmargin=\"0\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n";
  if ($this->naviItems > 0) {

    for ($i = 0; $i < $this->naviItems; ++$i) {

      $ii = ($i+2) * 100; 
      if ($i==0 & $ii==200) $ii=0;
      if ($i==2 & $ii==400) $ii=401;
      $f .= "<td height=\"$this->menuHeight\" bgcolor=\"";
      $f .= ($this->nav[$i] == $this->id) ? "$this->menuSelColor" : "$this->menuColor";
      $f .= "\" align=\"center\" width=\"{$celw[$i]}\"><a href=\"";
      $f .= (($this->link[$i] == " ") ? "index.php" : "{$this->link[$i]}"); 
      $f .= "?id={$this->nav[$i]}&pid={$ii}\" class=\"menu\">"; 
      $f .= "{$this->navi[$i]}</a></td>\n";
    }
    $f .=  "</tr>\n</table>\n";
  }

  $f .= "</td>\n";
  $f .= $this->drawVerLine($this->menuHeight, $this->menuBorderWidth, $this->menuBorderColor, "");
  $f .= $this->drawVerLine($this->menuHeight, $this->boxBorderWidth, $this->boxBorderColor, "") . "</tr>\n";

  // bottom menu area line

  $f .= "<tr>\n";
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawHorLine($menuAreaWidth, $this->menuBorderWidth, $this->menuBorderColor, "valign=top colspan=3 align=center");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= "</tr>\n";
  $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=5 align=center") . "</tr>\n";
  $f .= "</table>\n";
  $this->doc .= $f;

} // --


// -------------
// forge content

function forgeContent() {

  // no top box line (***)

  $this->contentWidth = $this->boxWidth - (2 * $this->boxBorderWidth) - $this->naviWidth;
  $naviArea = $this->naviWidth - (2 * $this->naviBorderWidth);
  $contentArea = $this->contentWidth - (1 * $this->contentBorderWidth); // !!!
    
  $f = "<table leftmargin=\"0\" topmargin=\"0\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n";
  
  // content area top line
  
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");  
  $f .= $this->drawHorLine($this->naviWidth, $this->naviBorderWidth, $this->naviBorderColor, "valign=top colspan=3 align=center");
  $f .= $this->drawHorLine($this->contentWidth, $this->contentBorderWidth, $this->contentBorderColor, "valign=top colspan=2 align=center");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "") . "\n</tr>\n";  
  
  // left border
  
  $f .= "<tr>" . $this->drawVerLine("100%", $this->boxBorderWidth, $this->boxBorderColor, "");
  $f .= $this->drawVerLine("100%", $this->naviBorderWidth, $this->naviBorderColor, "");

  // navi area

  $f .= "<td valign=top ";
  $f .= ($this->naviBackground != "") ? "background=\"$this->naviBackground\" " : "";
  $f .= ($this->naviColor != "") ? "bgcolor=\"$this->naviColor\"" : "";
  $f .= ">\n<table width=\"$naviArea\" ";
  $f .= "leftmargin=\"0\" topmargin=\"0\" cellpadding=\"20\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td ";
  $f .= "valign=top height=\"100%\" class=\"text\">\n";
  $f .= $this->fetchTextFile();
  $f .= $this->fetchTextFile2();
  $f .= "</td>\n</tr>\n</table>\n</td>\n";

  // right border & left border
  
  $f .= $this->drawVerLine("100%", $this->naviBorderWidth, $this->naviBorderColor, ""); // . "<td></td>";
  // $f .= $this->drawVerLine("100%", $this->contentBorderWidth, $this->contentBorderColor, "");

  // content

  $f .= "<td valign=top ";
  $f .= ($this->contentBackground != "") ? "background=\"$this->contentBackground\" " : "";
  $f .= ($this->contentColor != "") ? "bgcolor=\"$this->contentColor\"" : "";
  $f .= ">\n<table width=\"$contentArea\" ";
  $f .= "leftmargin=\"0\" topmargin=\"0\" cellpadding=\"20\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td bgcolor=\"$this->contentColor\" ";
  $f .= "valign=top height=\"100%\" class=\"text\">\n";

  // forgeData

  $f .= $this->wwwPreContent;
  $f .= $this->wwwContent; 
  $f .= $this->wwwPostContent;
  $f .= "</td>\n</tr>\n</table>\n</td>\n";

  // right border

  $f .= $this->drawVerLine("100%", $this->contentBorderWidth, $this->contentBorderColor, "");  
  $f .= $this->drawVerLine("100%", $this->boxBorderWidth, $this->boxBorderColor, "") . "</tr>\n";

  // bottom border line

  $f .= "<tr>" . $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "");  
  $f .= $this->drawHorLine($this->naviWidth, $this->naviBorderWidth, $this->naviBorderColor, "valign=top colspan=3 align=center");
  $f .= $this->drawHorLine($this->contentWidth, $this->contentBorderWidth, $this->contentBorderColor, "valign=top colspan=2 align=center");
  $f .= $this->drawHorLine($this->boxBorderWidth, $this->boxBorderWidth, $this->boxBorderColor, "") . "</tr>\n";  

  // bottom box line
  $f .= "<tr>\n" . $this->drawHorLine($this->boxWidth, $this->boxBorderWidth, $this->boxBorderColor, "valign=top colspan=7 align=center") . "</tr>\n";
  $f .= "</table>\n";
  $this->doc .= $f;

} // --

// --------------------
// draw horizontal line

function drawHorLine ($argLength, $argThick, $argColor, $argArg) {

  $s = "";
  $s .= ($argColor == "") ? "<td " : "<td bgcolor=\"$argColor\" ";
  $s .= "width=\"$argLength\" height=\"";
  $s .= "$argThick\" $argArg><img src=\"$this->fill\" width=\"$argLength\" height=\"$argThick\" alt=\"\"></td>\n";
  return $s;

} // --

// ------------------
// draw vertical line

function drawVerLine ($argLength, $argThick, $argColor, $argArg) {

  $s = "";
  $s .= ($argColor == "") ? "<td " : "<td bgcolor=\"$argColor\" ";
  $s .= " width=\"$argThick\" height=\"";
  $s .= "$argLength\" $argArg><img src=\"$this->fill\" width=\"$argThick\" height=\"$argLength\" alt=\"\"></td>\n";
  return $s;

} // --

// -----------
// add to menu

function addToMenu ($argPosition, $argMenu, $argLink) {

  $this->navi[$this->naviItems] = $argMenu;
  $this->nav[$this->naviItems] = $argPosition;
  $this->link[$this->naviItems] = $argLink;
  ++$this->naviItems;

} // --

//--------------------------
// (virtual) get pre content
function getPreContent() { return $this->wwwPreContent; }

//----------------------
// (virtual) get content
function getContent() { $this->wwwContent = ""; }

//---------------------------
// (virtual) get post content
function getPostContent() { return ; }
// $this->wwwPostContent = ($this->pid != 702) ? "<br><img src=\"/cgi-sys/Count.cgi?df=ufofinla-ufofinla.dat|display=Counter|ft=0|md=5|frgb=100;
// 139;216|dd=E|sh=F\">" : "" ; }

//----------------------
// (virtual) get content

function fetchTextFile() { 

  if (!isset($_GET['id']))  
  {
	$id = 0;
  }
  else
  {
	$id = $_GET['id'];
  }

  //  $filename = "https://www.ufofinland.fi/data/menu-" . $this->id . ".txt";

  $filename = "data/menu-" . $id . ".txt";

  $handle = @fopen ($filename, "r");
  $this->wwwSubMenu = ($handle == FALSE) ? "<tt>File '$filename' not found.</tt>" : fread ($handle, filesize ($filename));
  
  if ($handle)
  {
	fclose ($handle);
  }
  return $this->wwwSubMenu;

} // --

function fetchTextFile2() { 
  $filename = "data/c.txt";
  $handle = @fopen ($filename, "r");
  $this->wwwSubMenu = ($handle == FALSE) ? "<tt>File '$filename' not found.</tt>" : fread ($handle, filesize ($filename));
  @fclose ($handle);
  return $this->wwwSubMenu;
  
} // --


} // -- end of PortalHorNavi class

// ***************************************************************


class Portal extends PortalHorNavi {

// ----------
// getContent
// ----------

function getContent() {

//  $arg = $this->pid;

  if (!isset($_GET['pid']))  
  {
	$arg = 0;
  }
  else
  {
	$arg = $_GET['pid'];
  }

  $connection = mysqli_connect("localhost","c2yksnbr_ufolasse","b6[0er6?!ta3e(NA","c2yksnbr_kotisivut");
  $connection-> set_charset("utf8");

  if ($connection == FALSE) {
     $this->wwwContent = "<p class=body>mysql_connect error: " . mysqli_error($connection) . "</p>";
     return;
  }
  if (mysqli_select_db($connection,"c2yksnbr_kotisivut") == FALSE) {
     $this->wwwContent = "<p class=body>The service is out-of-order: mysql_select_db error</p>";
     return;
  }
  $query = "select * from $this->dbtable where id='$arg'";
  $result = mysqli_query($connection,$query);
  if ($result == FALSE) {
     $this->wwwContent = "<p class=body>The service is out-of-order: mysql_query error</p>";
     return;
  }
  $row = mysqli_fetch_row($result);
  //if ($row == FALSE) {
  //   $this->wwwContent = "<p class=body>The service is out-of-order: mysql_fetch_row error</p>";
  //   return;
  //}
  $this->wwwContent = $row[1];
  if (mysqli_close($connection) == FALSE) {
     $this->wwwContent = "<p class=body>The service is out-of-order: mysql_close error</p>";
  }

  // return $this->wwwContent;
 
}  // end of function

} // end of class

?>