[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/admin/ -> install.php (source)

   1  <?php
   2  define( 'YOURLS_ADMIN', true );
   3  define( 'YOURLS_INSTALLING', true );
   4  require_once( dirname( __DIR__ ).'/includes/load-yourls.php' );
   5  
   6  $error   = array();
   7  $warning = array();
   8  $success = array();
   9  
  10  // Check pre-requisites
  11  if ( !yourls_check_PDO() ) {
  12      $error[] = yourls__( 'PHP extension for PDO not found' );
  13      yourls_debug_log( 'PHP PDO extension not found' );
  14  }
  15  
  16  if ( !yourls_check_database_version() ) {
  17      $error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'MySQL' );
  18      yourls_debug_log( 'MySQL version: ' . yourls_get_database_version() );
  19  }
  20  
  21  if ( !yourls_check_php_version() ) {
  22      $error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'PHP' );
  23      yourls_debug_log( 'PHP version: ' . PHP_VERSION );
  24  }
  25  
  26  // Is YOURLS already installed ?
  27  if ( yourls_is_installed() ) {
  28      $error[] = yourls__( 'YOURLS already installed.' );
  29      // check if .htaccess exists, recreate otherwise. No error checking.
  30      if( !file_exists( YOURLS_ABSPATH.'/.htaccess' ) ) {
  31          yourls_create_htaccess();
  32      }
  33  }
  34  
  35  // Start install if possible and needed
  36  if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {
  37      // Create/update .htaccess file
  38      if ( yourls_create_htaccess() ) {
  39          $success[] = yourls__( 'File <tt>.htaccess</tt> successfully created/updated.' );
  40      } else {
  41          $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>.' );
  42      }
  43  
  44      // Create SQL tables
  45      $install = yourls_create_sql_tables();
  46      if ( isset( $install['error'] ) )
  47          $error = array_merge( $error, $install['error'] );
  48      if ( isset( $install['success'] ) )
  49          $success = array_merge( $success, $install['success'] );
  50  }
  51  
  52  
  53  // Start output
  54  yourls_html_head( 'install', yourls__( 'Install YOURLS' ) );
  55  ?>
  56  <div id="login">
  57      <form method="post" action="?"><?php // reset any QUERY parameters ?>
  58          <p>
  59              <img src="<?php yourls_site_url(); ?>/images/yourls-logo.svg" id="yourls-logo" alt="YOURLS" title="YOURLS" />
  60          </p>
  61          <?php
  62              // Print errors, warnings and success messages
  63              foreach ( array ('error', 'warning', 'success') as $info ) {
  64                  if ( count( $$info ) > 0 ) {
  65                      echo "<ul class='$info'>";
  66                      foreach( $$info as $msg ) {
  67                          echo '<li>'.$msg."</li>\n";
  68                      }
  69                      echo '</ul>';
  70                  }
  71              }
  72  
  73              // Display install button or link to admin area if applicable
  74              if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {
  75                  echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__( 'Install YOURLS') .'" class="button" /></p>';
  76              } else {
  77                  if( count($error) == 0 )
  78                      echo '<p style="text-align: center;">&raquo; <a href="'.yourls_admin_url().'" title="' . yourls__( 'YOURLS Administration Page') . '">' . yourls__( 'YOURLS Administration Page') . '</a></p>';
  79              }
  80          ?>
  81      </form>
  82  </div>
  83  <?php yourls_html_footer(); ?>


Generated: Tue Sep 27 05:10:01 2022 Cross-referenced by PHPXref 0.7.1