??php /* * frontend.php * Created on 2008-07-13 * * Autor: Mariusz Kropiwnicki * Email: gsl@data.pl */ $RUNTIME = microtime(true); require_once("config.php"); require_once("cms/db.php"); require_once("cms/lib/rxd_image.php"); require_once("cms/lib/smarty/Smarty.class.php"); require_once("cms/lib/smarty_translation_engine.php"); require_once("cms/lib/cms_autoloader.php"); require_once("cms/lib/cms_debug.php"); spl_autoload_register('rxd_frontend_autoloader'); // Enable cms exception handling, adds stack traces and error source. // set_exception_handler(array('cms', 'exception_handler')); // Enable cms error handling, converts all PHP errors to exceptions. // set_error_handler(array('cms', 'error_handler')); // Enable the cms shutdown handler, which catches E_FATAL errors. // register_shutdown_function(array('cms', 'shutdown_handler')); $SEP = "/"; header('Content-Type: text/html; charset=utf-8'); $translate = array(); $db = new DBConn; if ( !$db ) die( "Line __LINE__ error: ". $db->error() ); $img = new rxd_image; $img->ImageCachePath = $PATH; /* * REWRITE THIS!!! */ // logowanie if ( array_key_exists('token', $_REQUEST) and strlen(trim($_REQUEST['token'])) > 0 ) { $token = addslashes($_REQUEST['token']); $select = new DBSelect; $select->SetDBConn($db); $sql = "select * from klienci where token='${token}'"; $select->SQLSelect($sql); if ($select->NumRes() > 0 ) { $user = $select->GetNextRecord(); $typklienta=intval($user['grupa']); } else $token = ''; } /* * /REWRITE THIS!!! */ // redirect $url = 'http'; if ( array_key_exists('HTTPS', $_SERVER) ) if ( $_SERVER['HTTPS'] == 'on' ) $url .= 's'; $url .= '://'; if ( $_SERVER['SERVER_PORT'] != '80' ) $url .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; else $url .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if ( $_SERVER['QUERY_STRING'] > ' ' ) $url .= '?'.$_SERVER['QUERY_STRING']; $sql = "select * from redirect where publish=1 and nazwa='" . htmlentities($url) . "'"; $res = $db->Query($sql); if ( is_array($res) ) { header("Location: " . $res['url'] ); exit; } /* * Wybieramy moduł do uruchomienia */ $page = new page; $page->set_db($db); if ( $page->is_in_cache() ) { $page->cache(); if ( isset($DISPLAYRUNTIME) and $DISPLAYRUNTIME == 1 ) echo "\n
Run: " . (microtime(true) - $RUNTIME ); exit; } $module = $page->get_request('m', 'stronaglowna'); $mod = load_module($module); if ( $mod->is_fullpage() == 1 ) { $mod->get(); exit; } $page->add_module('html', $mod->get()); $page->display(); if ( isset($DISPLAYRUNTIME) and $DISPLAYRUNTIME == 1 ) echo "\n
Run: " . (microtime(true) - $RUNTIME ); exit; /* * ------------------------------------------------------------------------ */ function load_module ( $module ) { global $db; global $PATH; /* * Wybieramy moduł do uruchomienia */ $modobj = null; $moddir = dirname(__FILE__) . "/modules/"; $load = $moddir . "mod_default/"; $d = dir($moddir); while (false !== ($entry = $d->read())) { if ( $entry != '..' and $entry != '.' and $entry != '.svn' and $entry != '.cvs' and $entry == "mod_" . $module) $load = $moddir . $entry . "/"; } $d->close(); /* * Sprawdzam czy są moduły uzytkownika */ $moddir = $PATH . "/modules/"; if ( is_dir($moddir) ) { $d = dir($moddir); while (false !== ($entry = $d->read())) { if ( $entry != '..' and $entry != '.' and $entry != '.svn' and $entry != '.cvs' and $entry == "mod_" . $module) $load = $moddir . $entry . "/module.php"; if ( $entry != '..' and $entry != '.' and $entry != '.svn' and $entry != '.cvs' and $entry == "mod_" . $module . '.php') $load = $moddir . $entry; } $d->close(); } require_once ( $load ); if ( $modobj ) $modobj->set_db($db); return $modobj; } ?>