Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1285 → Rev 1286

/FileXch/branches/php-impl/lib/common.php
0,0 → 1,56
<?php
if(!$isEntryPoint) {
die("Not an entry point");
}
 
include("config/config.php");
include("lib/db.php");
include("lib/file.php");
include("lib/session.php");
include("lib/formatter.php");
include("lib/parser.php");
 
$dataAllowed = true; // interaction with DB or file system is allowed
 
$db = createDbInterface(Config::dbType, Config::dbHost, Config::dbUser, Config::dbPass, Config::dbDatabase);
$fm = new FileManager(Config::root, Config::umask);
$sm = new SessionManager($db, $fm);
$f = new Formatter();
$p = new Parser();
 
function debugMsg($msg)
{
//echo "$msg<br>\n";
}
 
function dataCollected()
{
global $dataAllowed, $db, $fm, $sm;
 
if($dataAllowed) {
// interaction with DB or file system is not more allowed
$dataAllowed = false;
$db->endTheLife();
$fm->endTheLife();
$sm->endTheLife();
}
}
 
function checkDataCollected()
{
global $dataAllowed;
 
if($dataAllowed) {
throw new Exception("Data collection is still allowed");
}
}
 
function generalError()
{
global $db;
 
$db->rollback();
dataCollected();
include("pages/general_error.php");
}
?>