<?php

// STD Page Generation System[tm]
// Copyright (C) 2004, Cockos Incorporated
// License: public domain

// to use this code to make new pages, do:
//   include("std.php");
//   standardheaders("MyAppName"); // the parameter can be "" for the main page
//   displayfile("index.txt");
//   standardfooters();
//
//   index.txt is the content, and if the line begins with ^ it is centered.
//   by default the minimum page size is 80x25. you can tweak below, too.

$company_name "Cockos Incorporated";






function 
padoutstring($x$indent$outlen)
{
  
$buf="";
  
$mylen=strlen(strip_tags($x));
  if (
$indent 0$indent=(($outlen-$mylen)/2)|0;

  for (
$pos 0$pos $indent$pos ++) $buf.=" ";
  
$buf .= $x;
  for (
$pos $indent $mylen$pos $outlen$pos++) $buf.=" ";
  return 
$buf;
}

function 
drawframe($xdim$ydim$lines$indents)
{
  echo 
"/";
  for (
$x 1$x $xdim-1$x++) echo "-";
  echo 
"\\\n";

  for (
$y 1$y $ydim-1$y++)
  {
    if (
$indents[$y] == ''$si=1;
    else 
$si=$indents[$y];

    echo 
"|";
    echo 
padoutstring($lines[$y],$si,$xdim-2);
    echo 
"|\n";
  }

  echo 
"\\";
  for (
$x 1$x $xdim-1$x++) echo "-";
  echo 
"/\n";
}

function 
displayfile($filename)
{
  
$xdim 76;
  
$ydim 0;
  
$fp fopen($filename,"r");
  if (
$fp)
  {
    while ((
$x=fgets($fp,1024)))
    {
      
$x=rtrim($x);
      if (
substr($x,0,1) == "^") { $indents[$ydim]=-1$x=substr($x,1); }
      
$l=strlen(strip_tags($x));
      if (
$l $xdim$xdim=$l;
      
$lines[$ydim++]=$x;
    }
    
fclose($fp);

    while (
$ydim 23$lines[$ydim++]="";

    
drawframe($xdim+4,$ydim+2,$lines,$indents);
  }
}

function 
standardheaders($title)
{
  global 
$company_name;
  echo 
"<HTML><HEAD><TITLE>";
  if (
$title != "") echo "$title | ";
  echo 
"$company_name</TITLE>";
  echo 
"</HEAD><BODY BGCOLOR=\"#000000\" TEXT=\"#8f8f8f\" LINK=\"#8f8f8f\" VLINK=\"#8f8f8f\" ALINK=\"#8f8f8f\">";
  echo 
"<TABLE width=100% height=100% valign=center><TR><TD align=center><CENTER>";
  echo 
"<PRE>";
}

function 
standardfooters()
{
  echo 
"</pre></TD></TR></TABLE></BODY></HTML>";
}

?>