<?
#########################################################
# Simple Poll                                           #
#########################################################
#                                                       #
# Author: CodeMunkyX                                    #
#                                                       #
# This script and all included functions, images,       #
# and documentation are copyright 2003                  #
# free-php.net (http://free-php.net) unless             #
# otherwise stated in the module.                       #
#                                                       #
# Any copying, distribution, modification with          #
# intent to distribute as new code will result          #
# in immediate loss of your rights to use this          #
# program as well as possible legal action.             #
#                                                       #
#########################################################

function connect() {

  global $conn;

  $conn = mysql_connect( hostname, username, password  );

  if( !$conn ) {
	  echo "Couldn't connect to database!<BR>";
  }

    mysql_select_db(dbname);
}

function query($query) {
  // do query

  global $conn;

  $result = mysql_query($query, $conn);


  if (!$result) {
      echo "Invalid SQL: ".$query." :: ".$conn;
  }

  return $result;
}

function fetch($result) {

   if (isset($result)) {

     $row = mysql_fetch_array($result);

   } else {

     echo "Invalid Query Fetch";

   }

    return $row;
}

function num_rows($result) {

   // returns number of rows in query
   return mysql_num_rows($result);
}

function close() {

  // closes connection to the database

  return mysql_close();
}

function dooutput($template) {

    echo $template;

}

function storeoutput($template) {

    global $admincontent;

    $admincontent .= $template;

}

function gettemplate($templatedir,$template,$endung="html") {

    //echo "templatedir = ".$templatedir;
    //echo "<br>Template= ".$template;
    return str_replace("\"","\\\"",implode("",file($templatedir.$template.".".$endung)));

}

?>