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' );
15 if ( !yourls_check_php_version() )
16 $error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'PHP' );
18 // Is YOURLS already installed ?
19 if ( yourls_is_installed() ) {
20 $error[] = yourls__( 'YOURLS already installed.' );
21 // check if .htaccess exists, recreate otherwise. No error checking.
22 if( !file_exists( YOURLS_ABSPATH.'/.htaccess' ) ) {
23 yourls_create_htaccess();
27 // Start install if possible and needed
28 if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {
29 // Create/update .htaccess file
30 if ( yourls_create_htaccess() ) {
31 $success[] = yourls__( 'File <tt>.htaccess</tt> successfully created/updated.' );
33 $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>.' );
37 $install = yourls_create_sql_tables();
38 if ( isset( $install['error'] ) )
39 $error = array_merge( $error, $install['error'] );
40 if ( isset( $install['success'] ) )
41 $success = array_merge( $success, $install['success'] );
46 yourls_html_head( 'install', yourls__( 'Install YOURLS' ) );
49 <form method="post" action="?"><?php // reset any QUERY parameters ?>
51 <img src="<?php yourls_site_url(); ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />
54 // Print errors, warnings and success messages
55 foreach ( array ('error', 'warning', 'success') as $info ) {
56 if ( count( $$info ) > 0 ) {
57 echo "<ul class='$info'>";
58 foreach( $$info as $msg ) {
59 echo '<li>'.$msg."</li>\n";
65 // Display install button or link to admin area if applicable
66 if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {
67 echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__( 'Install YOURLS') .'" class="button" /></p>';
69 if( count($error) == 0 )
70 echo '<p style="text-align: center;">» <a href="'.yourls_admin_url().'" title="' . yourls__( 'YOURLS Administration Page') . '">' . yourls__( 'YOURLS Administration Page') . '</a></p>';
75 <?php yourls_html_footer(); ?>