// Configuration
require_once('config/config.inc');
require_once('front/config.php');
require_once('config/general.inc');
// Startup
require_once(DIR_SYSTEM . 'startup.php');
// Application Classes
require_once(DIR_SYSTEM . 'library/user.php');
require_once(DIR_SYSTEM . 'engine/form.php');
require_once(DIR_CORE . 'languageController.php');
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Database
$db = new DB('mysql', DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db',$db);
$url = new Url(HTTP_FRONT, HTTP_FRONT);
$registry->set('url', $url);
// Log
$log = new Log(DIR_LOGS.'log-'.date("Y-m-d").'.txt');
$registry->set('log', $log);
// Error Handler
function error_handler($errno, $errstr, $errfile, $errline)
{
global $config, $log;
switch ($errno) {
case E_NOTICE:
case E_USER_NOTICE:
$error = 'Notice';
break;
case E_WARNING:
case E_USER_WARNING:
$error = 'Warning';
break;
case E_ERROR:
case E_USER_ERROR:
$error = 'Fatal Error';
break;
default:
$error = 'Unknown';
break;
}
echo '' . $error . ': ' . $errstr . ' in ' . $errfile . ' on line ' . $errline . '';
$log->write('PHP ' . $error . ': ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
return TRUE;
}
// Error Handler
set_error_handler('error_handler');
// Request
$request = new Request();
$registry->set('request', $request);
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$registry->set('response', $response);
// Session
$registry->set('session', $session=new Session());
// User
$user=new User($registry);
$registry->set('user', $user);
//Language
$limbi=new languageController($registry);
$limbi->setLanguage();
$limbi->loadVariables();
//$language=$limbi->loadLanguages();
// Front Controller
$controller = new Front($registry);
// Router
$url_site=isset($request->get['url'])?$request->get['url']:'';
if (isset($url_site))
{
$url=explode("/",$url_site);
//setez chestiile SEO
$registry->set('TITLU_SEO','');
$registry->set('META_KEYWORDS',META_KEYWORDS);
$registry->set('META_DESCRIPTION',META_DESCRIPTION);
$registry->set('BREADCRUMB','');
//end
require_once(DIR_CORE.'masterController.php');
if ($url_site!='')
{
//daca nu exact functia pe care vrea sa apelez,execut functia list
if (!isset($url[1]) OR $url[1]==''){if (isset($url[1]) AND $url[1]==''){$url_site.="lista";}else{$url_site.="/lista";}}
//daca este galerie foto incarc fara elementele de pe partea stanga/dreapta//
if (isset($url[0]) AND ($url[0]=='foto' OR $url[0]=='foto/'))
{
$action = new Action($url_site);
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->galleryPage($continut);
//END MASTER CLASS
}
elseif (isset($url[0]) AND ($url[0]=='video' OR $url[0]=='video/'))
{
$action = new Action($url_site);
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->galleryPage($continut);
//END MASTER CLASS
}
elseif (isset($url[0]) AND ($url[0]=='mesajcarteoaspeti'))
{
$action = new Action('carteoaspeti/form');
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->popupPage($continut);
//END MASTER CLASS
}
elseif (isset($url[0]) AND ($url[0]=='mesajpetitii'))
{
$action = new Action('petitii/form');
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->popupPage($continut);
//END MASTER CLASS
}
elseif(isset($url[0]) AND ($url[0]=='print'))
{
if (isset($request->get['modul']) AND isset($request->get['link']))
{
$action = new Action('print/showPrintPage');
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
$master=new ControllerMaster($registry);
$master->popupPage($continut);
}
}
elseif(isset($url[0]) AND ($url[0]=='pdf'))
{
if (isset($request->get['modul']) AND isset($request->get['link']))
{
require_once(DIR_SYSTEM . 'pdf/html2pdf.class.php');
require_once(DIR_CORE.'pdfController.php');
$continut=new ControllerPdf($registry);
$pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', 0);
$pdf->pdf->SetDisplayMode('fullpage');
$pdf->WriteHTML($continut->showPdfPage());
$pdf->Output($continut->numepdf(), 'D');
}
}
elseif (isset($url[0]) AND ($url[0]=='email'))
{
if (isset($request->get['link']))
{
$action = new Action('message/sendtofriend');
$continut=$controller->dispatch_return($action, '');
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->popupPage($continut);
//END MASTER CLASS
}
}
else
{
$action = new Action($url_site);
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->masterPage($continut);
//END MASTER CLASS
}
}
else
{
$action = new Action('home/home');
$continut=$controller->dispatch_return($action, new Action('home/notfound'));
//MASTER CLASS
$master=new ControllerMaster($registry);
$master->indexPage($continut);
//END MASTER CLASS
}
}
?>