2016-10-06 15:57:01 +00:00
< ? php
2018-07-22 16:59:22 +00:00
2016-10-06 15:57:01 +00:00
/**
* Project :
* Contenido Content Management System
*
* Description :
* Contenido main file
*
* Requirements :
* @ con_php_req 5.0
*
*
* @ package Contenido Backend
* @ version 1.0 . 4
* @ author Olaf Niemann , Jan Lengowski
* @ copyright four for business AG < www . 4 fb . de >
* @ license http :// www . contenido . org / license / LIZENZ . txt
* @ link http :// www . 4 fb . de
* @ link http :// www . contenido . org
* @ since file available since contenido release <= 4.6
*
* { @ internal
* created 2003 - 01 - 20
* modified 2008 - 06 - 16 , Holger Librenz , Hotfix : added check for invalid calls
* modified 2008 - 06 - 25 , Timo Trautmann , Contenido Framework Constand added
* modified 2008 - 07 - 02 , Frederic Schneider , add security fix and include security_class
* modified 2010 - 05 - 20 , Murat Purc , standardized Contenido startup and security check invocations , see [ #CON-307]
* modified 2011 - 02 - 08 , Dominik Ziegler , removed old PHP compatibility stuff as contenido now requires at least PHP 5
*
2019-07-03 11:58:28 +00:00
* $Id $ :
2016-10-06 15:57:01 +00:00
* }}
*
*/
if ( ! defined ( " CON_FRAMEWORK " )) {
define ( " CON_FRAMEWORK " , true );
}
// Contenido startup process
include_once ( './includes/startup.php' );
$cfg [ " debug " ][ " backend_exectime " ][ " fullstart " ] = getmicrotime ();
2018-07-22 16:59:22 +00:00
cInclude ( " includes " , 'functions.api.php' );
cInclude ( " includes " , 'functions.forms.php' );
2016-10-06 15:57:01 +00:00
page_open ( array ( 'sess' => 'Contenido_Session' ,
2018-07-22 16:59:22 +00:00
'auth' => 'Contenido_Challenge_Crypt_Auth' ,
'perm' => 'Contenido_Perm' ));
2016-10-06 15:57:01 +00:00
2018-07-22 16:59:22 +00:00
i18nInit ( $cfg [ " path " ][ " contenido " ] . $cfg [ " path " ][ " locale " ], $belang );
2016-10-06 15:57:01 +00:00
/**
* Bugfix
* @ see http :// contenido . org / forum / viewtopic . php ? t = 18291
*
* added by H . Librenz ( 2007 - 12 - 07 )
*/
//includePluginConf();
require_once $cfg [ 'path' ][ 'contenido' ] . $cfg [ 'path' ][ 'includes' ] . 'functions.includePluginConf.php' ;
2018-07-22 16:59:22 +00:00
cInclude ( " includes " , 'cfg_language_de.inc.php' );
2016-10-06 15:57:01 +00:00
2018-07-22 16:59:22 +00:00
if ( $cfg [ " use_pseudocron " ] == true ) {
2016-10-06 15:57:01 +00:00
/* Include cronjob-Emulator, but only for frame 1 */
2018-07-22 16:59:22 +00:00
if ( $frame == 4 ) {
2016-10-06 15:57:01 +00:00
$sess -> freeze ();
$oldpwd = getcwd ();
2018-07-22 16:59:22 +00:00
chdir ( $cfg [ " path " ][ " contenido " ] . $cfg [ " path " ][ " cronjobs " ]);
2016-10-06 15:57:01 +00:00
cInclude ( " includes " , " pseudo-cron.inc.php " );
chdir ( $oldpwd );
2018-07-22 16:59:22 +00:00
if ( $bJobRunned == true ) {
2016-10-06 15:57:01 +00:00
// Some cronjobs might overwrite important system variables.
// We are thaw'ing the session again to re-register these variables.
$sess -> thaw ();
}
}
}
/* Remove all own marks , only for frame 1 and 4 if $_REQUEST [ 'appendparameters' ] == 'filebrowser'
2018-07-22 16:59:22 +00:00
filebrowser is used in tiny in this case also do not remove session marks */
if (( $frame == 1 || $frame == 4 ) && isset ( $_REQUEST [ 'appendparameters' ]) && $_REQUEST [ 'appendparameters' ] != 'filebrowser' ) {
$col = new InUseCollection ;
$col -> removeSessionMarks ( $sess -> id );
2016-10-06 15:57:01 +00:00
}
/* If the override flag is set, override a specific InUseItem */
2018-07-22 16:59:22 +00:00
if ( isset ( $overrideid ) && isset ( $overridetype )) {
$col = new InUseCollection ;
$col -> removeItemMarks ( $overridetype , $overrideid );
2016-10-06 15:57:01 +00:00
}
# Create Contenido classes
$oDb = new DB_ConLite ();
/* @var $db DB_ConLite */
$db = & $oDb ;
$notification = new Contenido_Notification ;
$classarea = new Area ();
$classlayout = new Layout ();
$classclient = new Client ();
$classuser = new User ();
$currentuser = new User ();
$currentuser -> loadUserByUserID ( $auth -> auth [ " uid " ]);
# change Client
2018-07-22 16:59:22 +00:00
if ( isset ( $changeclient ) && is_numeric ( $changeclient )) {
2016-10-06 15:57:01 +00:00
$client = $changeclient ;
unset ( $lang );
}
# Sprache wechseln
2018-07-22 16:59:22 +00:00
if ( isset ( $changelang ) && is_numeric ( $changelang )) {
unset ( $area_rights );
unset ( $item_rights );
2016-10-06 15:57:01 +00:00
$lang = $changelang ;
}
2018-07-22 16:59:22 +00:00
if ( ! is_numeric ( $client ) || ( ! $perm -> have_perm_client ( " client[ " . $client . " ] " ) && ! $perm -> have_perm_client ( " admin[ " . $client . " ] " ))) {
// use first client which is accessible
2016-10-06 15:57:01 +00:00
$sess -> register ( " client " );
2018-07-22 16:59:22 +00:00
$sql = " SELECT idclient FROM " . $cfg [ " tab " ][ " clients " ] . " ORDER BY idclient ASC " ;
2016-10-06 15:57:01 +00:00
$db -> query ( $sql );
2018-07-22 16:59:22 +00:00
while ( $db -> next_record ()) {
$mclient = $db -> f ( " idclient " );
if ( $perm -> have_perm_client ( " client[ " . $mclient . " ] " ) || $perm -> have_perm_client ( " admin[ " . $mclient . " ] " )) {
unset ( $lang );
$client = $mclient ;
break ;
}
2016-10-06 15:57:01 +00:00
}
} else {
2018-07-22 16:59:22 +00:00
$sess -> register ( " client " );
2016-10-06 15:57:01 +00:00
}
if ( ! is_numeric ( $lang ) || $lang == " " ) {
$sess -> register ( " lang " );
# search for the first language of this client
2018-07-22 16:59:22 +00:00
$sql = " SELECT * FROM " . $cfg [ " tab " ][ " lang " ] . " AS A, " . $cfg [ " tab " ][ " clients_lang " ] . " AS B WHERE A.idlang=B.idlang AND idclient=' " . Contenido_Security :: toInteger ( $client ) . " ' ORDER BY A.idlang ASC " ;
2016-10-06 15:57:01 +00:00
$db -> query ( $sql );
$db -> next_record ();
$lang = $db -> f ( " idlang " );
} else {
2018-07-22 16:59:22 +00:00
$sess -> register ( " lang " );
2016-10-06 15:57:01 +00:00
}
// send right encoding http header
sendEncodingHeader ( $db , $cfg , $lang );
$perm -> load_permissions ();
# Create Contenido classes
2018-07-22 16:59:22 +00:00
$xml = new XML_doc ;
$tpl = new Template ;
$backend = new Contenido_Backend ;
2016-10-06 15:57:01 +00:00
//$backend->debug=true;
# Register session variables
$sess -> register ( " sess_area " );
if ( isset ( $area )) {
$sess_area = $area ;
} else {
$area = ( isset ( $sess_area ) && $sess_area != " " ) ? $sess_area : 'login' ;
}
$sess -> register ( " cfgClient " );
$sess -> register ( " errsite_idcat " );
$sess -> register ( " errsite_idart " );
2018-07-22 16:59:22 +00:00
if ( ! isset ( $cfgClient ) || ! isset ( $cfgClient [ " set " ]) || $cfgClient [ " set " ] != " set " ) {
2016-10-06 15:57:01 +00:00
rereadClients ();
}
# Initialize Contenido_Backend.
# Load all actions from the DB
# and check if permission is
# granted.
2018-07-22 16:59:22 +00:00
if ( $cfg [ " debug " ][ " rendering " ] == true ) {
$oldmemusage = memory_get_usage ();
2016-10-06 15:57:01 +00:00
}
# Select frameset
$backend -> setFrame ( $frame );
# Select area
$backend -> select ( $area );
$cfg [ " debug " ][ " backend_exectime " ][ " start " ] = getmicrotime ();
# Include all required 'include' files.
# Can be an array of files, if more than
# one file is required.
if ( is_array ( $backend -> getFile ( 'inc' ))) {
foreach ( $backend -> getFile ( 'inc' ) as $filename ) {
2018-07-22 16:59:22 +00:00
include_once ( $cfg [ 'path' ][ 'contenido' ] . $filename );
2016-10-06 15:57:01 +00:00
}
}
# If $action is set -> User klicked some button/link
# get the appopriate code for this action and evaluate it.
2018-07-22 16:59:22 +00:00
if ( isset ( $action ) && $action != " " ) {
if ( ! isset ( $idart )) {
$idart = 0 ;
}
2016-10-06 15:57:01 +00:00
$backend -> log ( $idcat , $idart , $client , $lang , $action );
}
if ( isset ( $action )) {
if ( $backend -> getCode ( $action ) != '' ) {
if ( $backend -> debug == 1 ) {
2018-07-22 16:59:22 +00:00
echo '<pre style="font-family: verdana; font-size: 10px"><b>Executing:</b>' . " \n " ;
echo $backend -> getCode ( $action ) . " \n " ;
2016-10-06 15:57:01 +00:00
echo '</pre>' ;
}
eval ( $backend -> getCode ( $action ));
} else {
if ( $backend -> debug == 1 ) {
2018-07-22 16:59:22 +00:00
echo '<pre style="font-family: verdana; font-size: 10px"><b>Executing:</b>' . " \n " ;
2016-10-06 15:57:01 +00:00
echo " no code available in action \n " ;
echo '</pre>' ;
}
}
}
# Include the 'main' file for the selected area.
# Usually there is only one main file
2018-07-22 16:59:22 +00:00
if ( is_array ( $backend -> getFile ( 'main' ))) {
foreach ( $backend -> getFile ( 'main' ) as $id => $filename ) {
include_once ( $cfg [ 'path' ][ 'contenido' ] . $filename );
}
} elseif ( $frame == 3 ) {
include_once ( $cfg [ 'path' ][ 'contenido' ] . $cfg [ 'path' ][ 'includes' ] . " include.default_subnav.php " );
} else {
include_once ( $cfg [ 'path' ][ 'contenido' ] . $cfg [ 'path' ][ 'includes' ] . " include.blank.php " );
2016-10-06 15:57:01 +00:00
}
$cfg [ " debug " ][ " backend_exectime " ][ " end " ] = getmicrotime ();
2018-07-22 16:59:22 +00:00
if ( $cfg [ " debug " ][ " rendering " ] == true ) {
echo " Building this page (excluding contenido includes) took: " . ( $cfg [ " debug " ][ " backend_exectime " ][ " end " ] - $cfg [ " debug " ][ " backend_exectime " ][ " start " ]) . " seconds<br> " ;
echo " Building the complete page took: " . ( $cfg [ " debug " ][ " backend_exectime " ][ " end " ] - $cfg [ " debug " ][ " backend_exectime " ][ " fullstart " ]) . " seconds<br> " ;
2016-10-06 15:57:01 +00:00
2018-07-22 16:59:22 +00:00
echo " Include memory usage: " . human_readable_size ( memory_get_usage () - $oldmemusage ) . " <br> " ;
echo " Complete memory usage: " . human_readable_size ( memory_get_usage ()) . " <br> " ;
2016-10-06 15:57:01 +00:00
}
/**
* Start User Tracking ( who is online )
*
2018-07-22 16:59:22 +00:00
* */
2016-10-06 15:57:01 +00:00
$oActiveUser = new ActiveUsers ( $db , $cfg , $auth );
$oActiveUser -> startUsersTracking ();
/**
*
* End of the User Tracking
*/
$db -> disconnect ();
page_close ();
?>