<?php
  
// files older than 5 min in 'downloads' rm-ed by cron
  
define("RESULTS", "$DOCUMENT_ROOT/downloads" );
  
define("DOWNLOADS", "/downloads" );

  
define("TAR_BALL", "tarball.tgz" );
  
define("USER_INPUT", "form_input.txt" );
  
define("PROC_ROW", "process_row.phps" );
  
define("APPLY_ROW", "apply.phps" );
  
define("CSS_TEMPLATE", "style.css" );
  
define("CONNECT_TEMPLATE", "connect.phps" );
  
define("CONNECT", "tmp_connect.phps" );
  
define("HEADER", 1 );
  
define("TRAILER", 2 );
  
define("WEBTREE", "http://penguin.epfl.ch/" );
  
define("FROM", "mailto&#058;Denice&#046;Deatrich&#064;epfl.ch http://penguin.epfl.ch/" );
  
define("MAX_LINE_SZ", 2048 ); // arbitrary max length of an ascii buffer

  /**    Function : create a tmp pathname
   **    Returns:   pathname
   **/
  
function buildTmpPath( ) {
    
$tmpf = tempnam( "/tmp", "Z" );
    
$tmpf = basename( $tmpf );
    
$timestamp = microtime( );  // use # of usecs to randomize directory name
    
$arr = explode( " ", $timestamp );
    
$timestamp = $arr[1] . "_" . $arr[0];
    
$p = RESULTS . "/" . $tmpf . $timestamp;
    if( !
mkdir($p, 0700)) {
      
$p = "";
    }
    return
$p;
  }

  
/**    Function : insert an HTML header or trailer into document
   **    Returns:   n/a
   **/
  
function insertInto( $fd, $string, $type ) {
    global
$HTTP_REFERER, $PHP_SELF;
    if(
$type == HEADER ) {
      
$s = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n<html>\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
      
$s = "
<!--  Formatted via:     "
. $HTTP_REFERER . "
      Using PHP script:  "
. $PHP_SELF . "
      Contact:           "
. FROM . " -->\n<head>\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
      
$s = "  <link rel=\"stylesheet\" href=\"style.css\">\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
      
$s = "  <title>" . $string . "</title>\n</head>\n<body>\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
    }
    else {
      
$s = "\n<hr>\n<div class=\"footer\">\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
      
$s = "\n<address><a href=\"" .$string. "\">" .$string. "</a>\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
      
$s = "</address>\n Generation time/date: " . date("H:i d.m.y")
      .
"</div></body>\n</html>\n";
      
fputs( $fd, $s, MAX_LINE_SZ );
    }
  }

?>
<?php
/**
<!-- Created: Sun Jan 16 17:22:34 MET 2000 -->
<!-- hhmts start -->
Last modified: Sun Jul  2 16:46:02 MEST 2000
<!-- hhmts end -->
**/
?>