2012-02-08 23:14:28 +01:00
< ? php
2013-04-05 10:16:33 +02:00
session_start ();
2012-02-08 23:14:28 +01:00
require_once ( " config.php " );
require ( DIR_SYSTEM . " /startup.php " );
2013-08-02 16:33:14 +02:00
$session = new Session ();
Registry :: set ( " session " , $session );
2012-02-08 23:14:28 +01:00
$request = new Request ();
Registry :: set ( " request " , $request );
Registry :: set ( 'document' , new Document ());
2013-04-09 15:02:10 +02:00
$start = NULL ;
2012-02-08 23:14:28 +01:00
$loader = new Loader ();
Registry :: set ( 'load' , $loader );
$language = new Language ();
Registry :: set ( 'language' , $language );
2012-10-23 19:11:49 +02:00
if ( ENABLE_SYSLOG == 1 ) { openlog ( " piler-webui " , LOG_PID , LOG_MAIL ); }
2012-02-08 23:14:28 +01:00
/* check if user has authenticated himself. If not, we send him to login */
Registry :: set ( 'username' , getAuthenticatedUsername ());
Registry :: set ( 'admin_user' , isAdminUser ());
Registry :: set ( 'auditor_user' , isAuditorUser ());
Registry :: set ( 'readonly_admin' , isReadonlyAdmin ());
$db = new DB ( DB_DRIVER , DB_HOSTNAME , DB_USERNAME , DB_PASSWORD , DB_DATABASE , DB_PREFIX );
Registry :: set ( 'DB_DATABASE' , DB_DATABASE );
Registry :: set ( 'db' , $db );
Registry :: set ( 'DB_DRIVER' , DB_DRIVER );
$sphx = new DB ( SPHINX_DRIVER , SPHINX_HOSTNAME , " " , " " , SPHINX_DATABASE , " " );
Registry :: set ( 'sphx' , $sphx );
if ( MEMCACHED_ENABLED ) {
$memcache = new Memcache ();
foreach ( $memcached_servers as $m ){
$memcache -> addServer ( $m [ 0 ], $m [ 1 ]);
}
Registry :: set ( 'memcache' , $memcache );
}
Registry :: set ( 'counters' , $counters );
Registry :: set ( 'langs' , $langs );
2013-11-15 22:04:26 +01:00
Registry :: set ( 'paging' , $paging );
2012-02-08 23:14:28 +01:00
Registry :: set ( 'themes' , $themes );
2012-06-27 11:17:23 +02:00
Registry :: set ( 'letters' , $letters );
2013-07-23 22:44:34 +02:00
Registry :: set ( 'ldap_types' , array ( " AD " , " iredmail " , " lotus " , " zimbra " ));
2012-02-08 23:14:28 +01:00
Registry :: set ( 'health_smtp_servers' , $health_smtp_servers );
Registry :: set ( 'partitions_to_monitor' , $partitions_to_monitor );
2013-08-02 16:33:14 +02:00
Registry :: set ( 'actions' , $actions );
2013-08-23 13:02:51 +02:00
Registry :: set ( 'import_status' , $import_status );
2012-02-08 23:14:28 +01:00
2013-10-16 14:55:17 +02:00
if ( $session -> get ( " ga_block " ) == 1 && $request -> get [ 'route' ] != 'login/logout' ) {
$action = new Router ( 'login/ga' );
}
else if ( Registry :: get ( 'username' )) {
2012-02-08 23:14:28 +01:00
if ( isset ( $request -> get [ 'route' ])){
$action = new Router ( $request -> get [ 'route' ]);
}
else {
$action = new Router ( 'search/search' );
}
2013-07-24 22:14:05 +02:00
if ( ENABLE_SAAS == 1 ) {
2013-09-11 09:25:56 +02:00
$query = $db -> query ( " UPDATE " . TABLE_ONLINE . " SET last_activity=? WHERE username=? AND ipaddr=? " , array ( NOW , $session -> get ( 'email' ), $_SERVER [ 'REMOTE_ADDR' ]));
2013-07-24 22:14:05 +02:00
if ( $db -> countAffected () == 0 ) {
2013-09-11 09:25:56 +02:00
$query = $db -> query ( " INSERT INTO " . TABLE_ONLINE . " (username, ts, last_activity, ipaddr) VALUES(?,?,?,?) " , array ( $session -> get ( 'email' ), NOW , NOW , $_SERVER [ 'REMOTE_ADDR' ]));
2013-07-24 22:14:05 +02:00
}
}
2012-02-08 23:14:28 +01:00
}
else {
2013-04-22 22:06:56 +02:00
if ( ENABLE_GOOGLE_LOGIN == 1 && isset ( $request -> get [ 'route' ]) && $request -> get [ 'route' ] == 'login/google' ) {
2012-09-28 10:34:04 +02:00
$action = new Router ( 'login/google' );
2013-04-23 22:11:21 +02:00
}
else if ( ENABLE_SSO_LOGIN == 1 ) {
if ( isset ( $request -> get [ 'route' ]) && $request -> get [ 'route' ] == 'login/login' ) {
$action = new Router ( 'login/login' );
}
else {
header ( " Location: " . SITE_URL . 'sso.php' );
exit ;
}
2013-04-22 16:52:02 +02:00
}
else {
2012-09-28 10:34:04 +02:00
$action = new Router ( 'login/login' );
}
2012-02-08 23:14:28 +01:00
}
$controller = new Front ();
$controller -> dispatch ( $action , new Router ( 'common/not_found' ));
?>