Source for file start.inc.php
Documentation is available at start.inc.php
* Script for defining all functions used by DNA Module
* @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
* @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1
* @license http://www.mozilla.org/MPL/ MPL
header('Content-Type: text/html; charset=utf-8');
* load defined SMTP path and port, include xml-parser (and xml file) from DNA_MODULE_PATH/load/
include("load/loadsmtp.php"); } else {
* load alternative SMTP path and port
include("../load/loadsmtp.php");}
* load configurations for DNA Module, include xml-parser (and xml file) from DNA_MODULE_PATH/load/
include("load/loadconfig.php"); } else {
* load alternative path for configurations
include("../load/loadconfig.php");}
$Path_Wiki =
'http://wiki.bgbm.org/dnabankwiki/index.php';
* Connection to database<br>load parameters, include xml-parser (and xml file) from DNA_MODULE_PATH/load/<br>if connection failed forwarding to createtables.php
* @param string $host DNA Database Host
* @param string $user DNA Database User
* @param string $passwd DNA Database Password
* @param string $dbname DNA Database Name
{include("load/loaddnaprovider.php"); }
else { include("../load/loaddnaprovider.php");}
if(!$connID) { header('Location: createtables.php');}
if(!$connection){ header('Location: createtables.php');} }
* Error handler, generates an email message with errormessage
* @param string $errno Error type
* @param string $errmsg Php/mysql error message
* @param string $filename Name of file caused error
* @param string $linenum Line in file caused error
$msg =
"Time: " .
date("Y-m-d H:i:s").
"\n";
$msg .=
"Error: " .
$errmsg.
"\n";
$msg .=
"File: " .
$filename.
"\n";
$msg .=
"Line: " .
$linenum;
case E_NOTICE:
case E_USER_NOTICE:
if(empty($Email_Admin) or !isset
($Email_Admin))
{$sendto =
"g.droege@bgbm.org"; }
else { $sendto =
$Email_Admin; }
$from =
"From: dnamodule@dnabank-network.org";
mail($sendto, $errmsg.
" ".
$filename, $msg, $from);
* Check content of all fields
* @param string $key element
* Generate randomised password, 8 characters
* @param string $randomPassword
$randnumber =
rand(48,120);
while (($randnumber >=
58 &&
$randnumber <=
64) ||
($randnumber >=
91 &&
$randnumber <=
96))
$randnumber =
rand(48,120);
$randomPassword .=
chr($randnumber);
* Build formatted hyperlink, with text-decoration and standard colours
* @param string $url domain and path
* @param string $query site and query parameters
* @param string $name hyperlink name
return "<a class='black' href=\"$url?" .
$query .
"\">" .
$name .
"</a>";
return "<a class='black' href=\"$url\">" .
$name .
"</a>";
* Build formatted hyperlink, without text-decoration and without special query parameters
* @param string $url domain and path
* @param string $name hyperlink name
return "<a class='ohne' style='text-decoration:none' target='_blank' href=\"$url\">" .
htmlentities($name) .
"</a>";
* Build a field list (<select>) from database, starting with an empty value
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectLong">';
echo
'<option value="">--------';
if($defaultitem==
$row[0]) echo
"selected ";
echo
"value=\"$row[0]\"> ", $row[1], "\n";
* Build a field list (<select>) from database, starting with an empty value, with large entry field
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="InputVeryLong2">';
echo
'<option value="">--------';
if($defaultitem==
$row[0]) echo
"selected ";
echo
"value=\"$row[0]\"> ", $row[1], "\n";
* Build a field list (<select>) from database with counted records, starting with an empty value
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectLong">';
echo
'<option value="">--------</option>';
if($defaultitem==
$row[0]) echo
"selected ";
echo
"value=\"$row[0]\"> ", $row[1].
" (".
$row[2].
")", "\n</option>";
* Build a field list (<select>) from database, starting with an empty value, short element (width)
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectShortOne">';
echo
'<option value="">--------</option>';
if($defaultitem==
$row[0]) echo
"selected ";
echo
"value=\"$row[0]\"> ", $row[1], "\n</option>";
* Build a field list (<select>) from database, starting with value=rack, short element (width)
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectShortTwo">';
echo
'<option value="">--------</option>';
if($defaultitem==
$row[0]) echo
"selected ";
echo
"value=\"$row[0]\"> ", $row[1], "\n</option>";
* Build a field list (<select>) from database, starting with value=Internal (list of specimen databases)
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectLong">';
echo
'<option value="">Internal</option>';
$Provider_ID_Provider =
$row[0];
$Provider_View_Test =
$row[1];
echo
"<option value=\"$Provider_ID_Provider\"";
if (isset
($_REQUEST['formSubmitClear'])) {
unset
($_REQUEST['formProviderIntern']); }
if (isset
($_REQUEST['formSubmitSave'])) {
unset
($_REQUEST['formProviderIntern']); }
if ($_POST["formProviderIntern"] ==
$Provider_ID_Provider) { echo
" selected"; } }
echo
"> $Provider_View_Test <br>\n</option>";
* Build a field list (<select>) from database, starting with value=External (list of specimen databases)
* @param string $formname name of element
* @param string $sql SQL query from database
* @param string $defaultitem Default item to be selected
echo
'<select name="', $formname, '" id="SelectLong">';
echo
'<option value="">External</option>';
$Provider_ID_Provider =
$row[0];
$Provider_View_Test =
$row[1];
echo
"<option value=\"$Provider_ID_Provider\"";
if (isset
($_REQUEST['formSubmitClear'])) {
unset
($_REQUEST['formProviderExtern']); }
if (isset
($_REQUEST['formSubmitSave'])) {
unset
($_REQUEST['formProviderExtern']); }
if ($_POST["formProviderExtern"] ==
$Provider_ID_Provider) { echo
" selected"; } }
echo
"> $Provider_View_Test <br>\n</option>";
* @param string $date format YYYY-MM-DD required
if (!preg_match('/^(\d{4})\-(\d{2})\-(\d{2})$/', trim($date), $matches)) {
return checkdate($matches[2], $matches[3], $matches[1]);
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
Documentation generated on Tue, 29 Nov 2011 10:45:18 +0100 by phpDocumentor 1.4.3