ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

Functions
install.php File Reference

Go to the source code of this file.

## Functions
| install_step_1 ()
| handle_connection_error ($Silent)
| handle_step_2 ($Host, $Database, $Prefix, $User, $Password, $Silent=false)
| show_step_2_form ()
| install_step_2 ($Silent=false)
| handle_step_3 ($HttpHost, $Silent=false)
| install_step_3 ($HttpHost, $Silent=false)
| install_step_4 ()
| handle_installation_steps ()
| run_installation_wizard ()

## Function Documentation

handle_connection_error | ( |  | $Silent | ) |

Обработка ситуации, когда не удалось подключиться к базе данных.

Parameters

  $Silent | - Тихая обработка.

Author
  Додонов А.А. Function process connection errors.

Parameters

  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 54 of file install.php.

{
if( $Silent === false )
{
$CachedFS = get_package( 'cached_fs' );
$Page = $CachedFS->file_get_contents( "./install/res/templates/install_template_2.tpl" );
$Page = str_replace( '{error_message}' , 'An error occured while database connection' , $Page );
$Security = get_package( 'security' );
$PlaceHolders = array( '{host}' , '{database}' , '{prefix}' , '{user}' , '{password}' );
$Data = array(
$Security->get_gp( 'host' , 'string' , '' ) , $Security->get_gp( 'database' , 'string' , '' ) ,
$Security->get_gp( 'prefix' , 'string' , '' ) , $Security->get_gp( 'user' , 'string' , '' ) ,
$Security->get_gp( 'password' , 'string' , '' )
);
$Page = str_replace( $PlaceHolders , $Data , $Page );
print( $Page );
exit( 0 );
}
}

handle_installation_steps | ( |  | ) |

Шаги инсталлятора.

Parameters

  $HttpHost | - Хост.
  $Silent | - Тихая обработка.

Author
  Додонов А.А. Third step.

Parameters

  $HttpHost | - Host.
  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 307 of file install.php.

{
$Security = get_package( 'security' );
$Page = $Security->get_gp( 'page' , 'integer' , 1 );
switch( $Page )
{
case( 1 ):install_step_1();
case( 2 ):install_step_2( false );
case( 3 ):
install_step_3( $Security->get_gp( 'http_root' , 'string' , false ) , false );
break;
case( 4 ):install_step_4();
}
}

handle_step_2 | ( |  | $Host,
|  |  | $Database,
|  |  | $Prefix,
|  |  | $User,
|  |  | $Password,
|  |  | $Silent = `false`
| ) |  |

Функция обработки второго шага.

Parameters

  $Host | - Хост.
  $Database | - База данных.
  $Prefix | - Префикс таблиц.
  $User | - Пользователь.
  $Password | - Пароль.
  $Silent | - Тихая обработка.

Author
  Додонов А.А. Function process step 2.

Parameters

  $Host | - Host.
  $Database | - Database.
  $Prefix | - Tables'es prefix.
  $User | - User.
  $Password | - Password.
  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 111 of file install.php.

{
$DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$CachedFS = get_package( 'cached_fs' );
$CachedFS->file_put_contents(
"packages/_core_data/conf/cf_mysql_database" , "$Host#$User#$Password#$Database#$Prefix"
);
if( $DatabaseAlgorithms->try_connect() )
{
$DBScript = file_get_contents( './install/sql/data.sql' , 'cleaned' );
$DBScript = str_replace( '{prefix}' , $Prefix , $DBScript );
$DatabaseAlgorithms->execute_query_set( $DBScript );
if( $Silent === false )
{
header( 'Location: ./install.php?page=3' );
exit( 0 );
}
}
else
{
handle_connection_error( $Silent );
}
}

handle_step_3 | ( |  | $HttpHost,
|  |  | $Silent = `false`
| ) |  |

Функция обработки третьего шага.

Parameters

  $HttpHost | - Хост.
  $Silent | - Тихая обработка.

Author
  Додонов А.А. Function process step 3.

Parameters

  $HttpHost | - Host.
  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 210 of file install.php.

{
$HttpHost = rtrim( $HttpHost , '/\\' );
$HtAccess = file_get_contents( './install/res/templates/tpl.htaccess' );
$HtAccess = str_replace( '{http_host}' , $HttpHost , $HtAccess );
file_put_contents( '.htaccess' , $HtAccess );
file_put_contents(
'./packages/_core_data/conf/cf_settings' , "HTTP_HOST=$HttpHost\r\nGZIP_TRAFFIC=false"
);
if( $Silent === false )
{
header( 'Location: ./install.php?page=4' );
exit( 0 );
}
}

install_step_1 | ( |  | ) |

Первый шаг.

Author
  Додонов А.А. First step.
  Dodonov A.A.

Definition at line 32 of file install.php.

{
$CachedFS = get_package( 'cached_fs' );
$Page = $CachedFS->file_get_contents( "./install/res/templates/install_template_1.tpl" );
print( $Page );
exit( 0 );
}

install_step_2 | ( |  | $Silent = `false` | ) |

Второй шаг.

Parameters

  $Silent | - Тихая обработка.

Author
  Додонов А.А. Second step.

Parameters

  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 174 of file install.php.

{
$Security = get_package( 'security' );
if( $Security->get_gp( 'setup_db' ) )
{
handle_step_2(
$Security->get_gp( 'host' , 'string' , '' ) , $Security->get_gp( 'database' , 'string' , '' ) ,
$Security->get_gp( 'prefix' , 'string' , '' ) , $Security->get_gp( 'user' , 'string' , '' ) ,
$Security->get_gp( 'password' , 'string' , '' ) , $Silent
);
}
else
{
show_step_2_form();
}
}

install_step_3 | ( |  | $HttpHost,
|  |  | $Silent = `false`
| ) |  |

Третий шаг.

Parameters

  $HttpHost | - Хост.
  $Silent | - Тихая обработка.

Author
  Додонов А.А. Third step.

Parameters

  $HttpHost | - Host.
  $Silent | - Silent processing.

Author
  Dodonov A.A.

Definition at line 246 of file install.php.

{
$CachedFS = get_package( 'cached_fs' );
$Security = get_package( 'security' );
if( $HttpHost === false )
{
if( $Silent === false )
{
$Page = $CachedFS->file_get_contents( "./install/res/templates/install_template_3.tpl" );
$Page = str_replace(
'{http_root}' ,
rtrim( 'http://'.$_SERVER[ 'SERVER_NAME' ].dirname( $_SERVER[ 'REQUEST_URI' ] ) , '/\\' ) ,
$Page
);
print( $Page );
exit( 0 );
}
}
else
{
handle_step_3( $HttpHost , $Silent );
}
}

install_step_4 | ( |  | ) |

Четвёртый шаг.

Author
  Додонов А.А. Forth step.
  Dodonov A.A.

Definition at line 281 of file install.php.

{
$CachedFS = get_package( 'cached_fs' );
$Page = $CachedFS->file_get_contents( "./install/res/templates/install_template_4.tpl" );
print( $Page );
exit( 0 );
}

run_installation_wizard | ( |  | ) |

Отображение визарда установки.

Author
  Додонов А.А. Function runs installation wizard.
  Dodonov A.A.

Definition at line 336 of file install.php.

{
try
{
if( isset( $_GET[ 'auto_install' ] ) === true )
{
$DBS = file_get_contents( './install/conf/cf_db_settings' );
$DBS = explode( '#' , $DBS );
install_step_2( $DBS[ 0 ] , $DBS[ 1 ] , $DBS[ 2 ] , $DBS[ 3 ] , $DBS[ 4 ] , true );
$HttpHost = rtrim( 'http://'.$_SERVER[ 'SERVER_NAME' ].dirname( $_SERVER[ 'REQUEST_URI' ] ) , '/\\' );
install_step_3( $HttpHost , true );
}
else
{
handle_installation_steps();
}
}
catch( Exception $e )
{
handle_script_error( true , $e );
}
}

show_step_2_form | ( |  | ) |

Показать форму для второго шага.

Author
  Додонов А.А. Show form for the second step.
  Dodonov A.A.

Definition at line 146 of file install.php.

{
$CachedFS = get_package( 'cached_fs' );
$Page = $CachedFS->file_get_contents( "./install/res/templates/install_template_2.tpl" );
$Needles = array( '{host}' , '{user}' , '{password}' , '{database}' , '{prefix}' , '{error_message}' );
$Config = $CachedFS->file_get_contents( "packages/_core_data/conf/cf_mysql_database" );
$Replacements = array_merge( explode( '#' , $Config ) , array( '' ) );
print( str_replace( $Needles , $Replacements , $Page ) );
exit( 0 );
}