|
// | Rene Renk |
// +----------------------------------------------------------------------+
//
// $Id: index.php,v 1.1 2004/06/30 11:34:54 pueschel Exp $
//session_start
@session_start();
// read xml file
$filename = "survey.xml";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
preg_match("/()(.*)(<\/lang>)/i", $contents, $matches);
$surveylang = $matches[2];
preg_match("/()(.*)(<\/id>)/i", $contents, $matches);
$projectId = $matches[2];
// require all configuration files and libraries
$pos = strpos ($_SERVER["SCRIPT_NAME"], "/output/");
if($pos === false)
{
require_once("./../../../administration/config/config.inc.php"); // common config file
}
else
{
require_once("./../../administration/config/config.inc.php"); // common config file
}
require_once($cfgPathToConf."/file.inc.php"); // project files
require_once($cfgPathToSurveyFiles."/config/survey.config.inc.php"); // auth config file
require_once($cfgPathToSurveyFiles."/lib/security/security.inc.php"); // security functions
require_once($cfgPathToSurveyFiles."/lib/database/dbfunctions.inc.php"); // survey db functions
require_once($cfgPathToSurveyConfig."/survey.file.inc.php"); // modules files
require_once 'XML/XPath.php';
//unset control variables of form part
$_SESSION["qffControlPool"] = false;
session_unregister("qffControlPool");
// function to get hostname with timeout
function dns_timeout($ip)
{
$res=`host -W3 $ip`;
if (preg_match('/pointer(.*)/', $res, $out))
{
$host = preg_replace("/pointer/","","$out[0]");
return trim($host);
}
else
{
return "timeout";
}
}
// function to split Agentstring
function find_browser($info = 'browser')
{
$ua = $_SERVER["HTTP_USER_AGENT"]; // g?r det lidt nemmere
if ($info == 'browser' || $info == 'version') { // browser og version
if (eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $ua, $r) || eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $ua, $r)) {
$browser = "Opera";
$version = $r['2'];
} elseif (eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $ua, $r)) {
$browser = "Lynx";
$version = $r['2'];
} elseif (eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $ua, $r)) {
$browser = "MSIE";
$version = $r['2'];
} elseif (eregi("(netscape6)/(6.[0-9]{1,3})", $ua, $r)) {
$browser = "Netscape";
$version = $r['2'];
} elseif (eregi("(netscape)/([0-9]{1,2}.[0-9]{1,3})", $ua, $r)) {
$browser = "Netscape";
$version = $r['2'];
} elseif (eregi("(mozilla)/([0-9]{1,2}.[0-9]{1,3})", $ua, $r)) {
$browser = "Mozilla";
$version = $r['2'];
} else {
$browser = "Unknown";
$version = "3.0"; // pr. definition
}
} else { // os
if (eregi("linux", $ua)) {
$os = "Linux";
} elseif (eregi("win32", $ua)) {
$os = "Windows";
} elseif ((eregi("(win)([0-9]{2})", $ua, $r)) || (eregi("(windows) ([0-9]{2})", $ua, $r))) {
$os = "Windows " . $r['2'];
} elseif (eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}", $ua, $r)) {
$os = "Windows NT " . $r['2'];
} elseif (eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}", $ua, $r)) {
$os = "Windows NT " . $r['3'];
} elseif (eregi("mac", $ua)) {
$os = "Macintosh";
} elseif (eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}", $ua, $r)) {
$os = "SunOS " . $r['2'];
} elseif (eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}", $ua, $r)) {
$os = "BeOS " . $r['2'];
} elseif (eregi("freebsd", $ua)) {
$os = "FreeBSD";
} elseif (eregi("openbsd", $ua)) {
$os = "OpenBSD";
} elseif (eregi("irix", $ua)) {
$os = "IRIX";
} elseif (eregi("os/2", $ua)) {
$os = "OS/2";
} elseif (eregi("unix", $ua) || eregi("hp-ux", $ua)) {
$os = "Unix";
} else {
$os = "Ukendt";
}
}
// return?r relevant info
return $$info;
}
// store metadata to session
if(!$_SESSION["qffMetaPool"])
{
$_SESSION["qffMetaPool"]["httpReferer"] = $_SERVER["HTTP_REFERER"];
$_SESSION["qffMetaPool"]["remoteAddress"] = urlencode($_SERVER["REMOTE_ADDR"]);
$_SESSION["qffMetaPool"]["hostAddress"] = dns_timeout($_SERVER["REMOTE_ADDR"]);
$_SESSION["qffMetaPool"]["userBrowser"] = find_browser('browser')." ".find_browser('version');
$_SESSION["qffMetaPool"]["userOs"] = find_browser('os');
}
// save project id in session
$_SESSION["projectId"] = $projectId;
// save session id in session
$_SESSION["surveySessionId"] = session_id();
// get survey data
// init dbFunctions
$dbFunctions = &new dbFunctions;
// get survey data
$surveyData = $dbFunctions->tabToArrayWhithArg($cfgSrvyTabSurvey,array("PROJECT_ID_PK"=>"$projectId"));
//create new security object
$security = &new securityFunctions;
// set project id
$security->setProjectId($projectId);
// check if assessment
if($_GET["userId"])
{
$_SESSION["surveyId"] = $_GET["surveyId"];
// check if active
if($surveyData[0]["PROJECT_ACTIVE"] != "yes")
{
?>
writeCookie($cookieParams);
?>
checkForSecurityCookie();
if($userDenied)
{
?>
writeCookie($cookieParams)
// redirect to form display
?>