2 define( 'YOURLS_ADMIN', true );
3 define( 'YOURLS_INSTALLING', true );
4 require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );
5 require_once( YOURLS_INC.'/functions-install.php' );
11 // Check pre-requisites
12 if ( !yourls_check_database_version() ) {
13 $error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'MySQL' );
14 yourls_debug_log( 'MySQL version: ' . yourls_get_database_version() );
17 if ( !yourls_check_php_version() ) {
18 $error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'PHP' );
19 yourls_debug_log( 'PHP version: ' . phpversion() );
22 // Is YOURLS already installed ?
23 if ( yourls_is_installed() ) {
24 $error[] = yourls__( 'YOURLS already installed.' );
25 // check if .htaccess exists, recreate otherwise. No error checking.
26 if( !file_exists( YOURLS_ABSPATH.'/.htaccess' ) ) {
27 yourls_create_htaccess();
31 // Start install if possible and needed
32 if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {
33 // Create/update .htaccess file
34 if ( yourls_create_htaccess() ) {
35 $success[] = yourls__( 'File <tt>.htaccess</tt> successfully created/updated.' );
37 $warning[] = yourls__( 'Could not write file <tt>.htaccess</tt> in YOURLS root directory. You will have to do it manually. See <a href="http://yourls.org/htaccess">how</a>.' );
41 $install = yourls_create_sql_tables();
42 if ( isset( $install['error'] ) )
43 $error = array_merge( $error, $install['error'] );
44 if ( isset( $install['success'] ) )
45 $success = array_merge( $success, $install['success'] );
50 yourls_html_head( 'install', yourls__( 'Install YOURLS' ) );
53 <form method="post" action="?"><?php // reset any QUERY parameters ?>
55 <img src="<?php yourls_site_url(); ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />
58 // Print errors, warnings and success messages
59 foreach ( array ('error', 'warning', 'success') as $info ) {
60 if ( count( $$info ) > 0 ) {
61 echo "<ul class='$info'>";
62 foreach( $$info as $msg ) {
63 echo '<li>'.$msg."</li>\n";
69 // Display install button or link to admin area if applicable
70 if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {
71 echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__( 'Install YOURLS') .'" class="button" /></p>';
73 if( count($error) == 0 )
74 echo '<p style="text-align: center;">» <a href="'.yourls_admin_url().'" title="' . yourls__( 'YOURLS Administration Page') . '">' . yourls__( 'YOURLS Administration Page') . '</a></p>';
79 <?php yourls_html_footer(); ?>