ultimix
startup.php File Reference

Go to the source code of this file.

Functions

 set_session ()
 main_setup ()
 start_script_settings ()
 start_php_script ()
 index_main ()
 cron_main ()
 common_error_message_processing ($Visualisation, $e)
 zip_exception ($ErrorMessage)
 handle_script_error ($Visualisation, $e)

Function Documentation

common_error_message_processing (   $Visualisation,
  $e 
)

Function processes execution errors.

Parameters
$Visualisation- Should the trace info be outputted.
$e- Exception object.
Returns
HTML content of the error message.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 243 of file startup.php.

{
try
{
$ErrorTemplate = file_get_contents( dirname( __FILE__ ).'/../../res/templates/exception.tpl' );
$DownloadLinkTemplate = file_get_contents( dirname( __FILE__ ).'/../../res/templates/download_link.tpl' );
$ErrorTemplate = str_replace( '{exception_message}' , $e->getMessage() , $ErrorTemplate );
if( $Visualisation )
{
print( str_replace( '{download}' , $DownloadLinkTemplate , $ErrorTemplate ) );
}
return( $ErrorTemplate );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
cron_main ( )

Function processes tasks.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 201 of file startup.php.

{
try
{
$Schedule = get_package( 'schedule' , 'last' , __FILE__ );
$Schedule->process_tasks();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
handle_script_error (   $Visualisation,
  $e 
)

Function processes execution errors.

Parameters
$Visualisation- Should the trace info be outputted.
$e- Exception object.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 319 of file startup.php.

{
try
{
global $DEBUG;
if( $DEBUG )
{
$ErrorTemplate = common_error_message_processing( $Visualisation , $e );
$Handle = fopen( dirname( __FILE__ ).'/../../log/exception.log' , 'at' );
fwrite( $Handle , $e->getMessage().'<hr width="90%">' );
fclose( $Handle );
$Handle = fopen( dirname( __FILE__ ).'/../../log/exception.last.html' , 'wt' );
fwrite( $Handle , str_replace( '{download}' , '' , $ErrorTemplate ) );
fclose( $Handle );
zip_exception( $ErrorTemplate );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
index_main ( )

Function generates page.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 166 of file startup.php.

{
try
{
$PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
if( isset( $_GET[ 'page_name' ] ) === false )
{
$_GET[ 'page_name' ] = 'index';
}
print( $PageComposer->get_page( $_GET[ 'page_name' ] ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
main_setup ( )

Function prepares script for the main processing.

Author
Dodonov A.A.

Definition at line 64 of file startup.php.

{
try
{
$Settings = get_package_object( 'settings::settings' , 'last::last' , __FILE__ );
$Settings->load_file( './cf_settings' );
$Settings->define(
'HTTP_HOST' ,
rtrim( 'http://'.$_SERVER[ 'SERVER_NAME' ].dirname( $_SERVER[ 'REQUEST_URI' ].'a' ) , '/\\' )
);
$Settings->define( 'SERVER_NAME' , $_SERVER[ 'SERVER_NAME' ] );
$Settings->define( 'DOMAIN' , $_SERVER[ 'HTTP_HOST' ] );
$Settings->set_setting( 'GZIP_TRAFFIC' , $Settings->get_setting( 'GZIP_TRAFFIC' , 'true' ) == 'true' );
$Settings->define( 'GZIP_TRAFFIC' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_session ( )

Function sets session parameters.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 33 of file startup.php.

{
try
{
$Settings = get_package( 'settings::package_settings' , 'last::last' , __FILE__ );
$SessionTimeout = $Settings->get_package_setting(
'core_data' , 'last' , 'cf_system' , 'session_timeout' , 600
);
ini_set( 'session.gc_maxlifetime' , $SessionTimeout );
ini_set( 'session.cookie_lifetime' , $SessionTimeout );
ini_set( 'session.save_path' , './packages/_core_data/data/session/' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
start_php_script ( )

Function starts page generation.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 131 of file startup.php.

{
try
{
// TODO function register_view(function|package->method)
// TODO function register_controller(function|package->method)
// TODO add markup demo
// TODO ... (add multylanguage demo script)
// TODO database support (add demo)
// TODO caching demo
$_GET[ 'page_name' ] = basename( $_SERVER[ 'SCRIPT_NAME' ] , ".php" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
start_script_settings ( )

Settings.

Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 100 of file startup.php.

{
try
{
global $StartGenerationTime;
$StartGenerationTime = microtime( true );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
zip_exception (   $ErrorMessage)

Function processes execution errors.

Parameters
$ErrorMessage- Error message.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 282 of file startup.php.

{
try
{
@unlink( dirname( __FILE__ ).'/../../log/exception.last.zip' );
$zip = new ZipArchive();
$zip->open( dirname( __FILE__ ).'/../../log/exception.last.zip' , ZIPARCHIVE::CREATE );
$zip->addFromString( 'exception.html' , str_replace( '{download}' , '' , $ErrorMessage ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}