[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/admin/ -> upgrade.php (source)

   1  <?php
   2  define( 'YOURLS_ADMIN', true );
   3  define( 'YOURLS_UPGRADING', true );
   4  require_once( dirname( __DIR__ ).'/includes/load-yourls.php' );
   5  yourls_maybe_require_auth();
   6  
   7  yourls_html_head( 'upgrade', yourls__( 'Upgrade YOURLS' ) );
   8  yourls_html_logo();
   9  yourls_html_menu();
  10  ?>
  11          <h2><?php yourls_e( 'Upgrade YOURLS' ); ?></h2>
  12  <?php
  13  
  14  // Check if upgrade is needed
  15  if ( !yourls_upgrade_is_needed() ) {
  16      echo '<p>' . yourls_s( 'Upgrade not required. Go <a href="%s">back to play</a>!', yourls_admin_url('index.php') ) . '</p>';
  17  
  18  
  19  } else {
  20      /*
  21      step 1: create new tables and populate them, update old tables structure,
  22      step 2: convert each row of outdated tables if needed
  23      step 3: - if applicable finish updating outdated tables (indexes etc)
  24              - update version & db_version in options, this is all done!
  25      */
  26  
  27      // From what are we upgrading?
  28      if ( isset( $_GET['oldver'] ) && isset( $_GET['oldsql'] ) ) {
  29          $oldver = yourls_sanitize_version($_GET['oldver']);
  30          $oldsql = intval($_GET['oldsql']);
  31      } else {
  32          list( $oldver, $oldsql ) = yourls_get_current_version_from_sql();
  33      }
  34  
  35      // To what are we upgrading ?
  36      $newver = YOURLS_VERSION;
  37      $newsql = YOURLS_DB_VERSION;
  38  
  39      // Verbose & ugly details
  40      yourls_debug_mode(true);
  41  
  42      // Let's go
  43      $step = ( isset( $_GET['step'] ) ? intval( $_GET['step'] ) : 0 );
  44      switch( $step ) {
  45  
  46          default:
  47          case 0:
  48              ?>
  49              <p><?php yourls_e( 'Your current installation needs to be upgraded.' ); ?></p>
  50              <p><?php yourls_e( 'Please, pretty please, it is recommended that you <strong>backup</strong> your database<br/>(you should do this regularly anyway)' ); ?></p>
  51              <p><?php yourls_e( "Nothing awful <em>should</em> happen, but this doesn't mean it <em>won't</em> happen, right? ;)" ); ?></p>
  52              <p><?php yourls_e( "On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix." ); ?></p>
  53              <p><?php yourls_e( 'If everything goes too fast and you cannot read, <span class="success">good for you</span>, let it go :)' ); ?></p>
  54              <p><?php yourls_e( 'Once you are ready, press "Upgrade" !' ); ?></p>
  55              <?php
  56              echo "
  57              <form action='upgrade.php?' method='get'>
  58              <input type='hidden' name='step' value='1' />
  59              <input type='hidden' name='oldver' value='$oldver' />
  60              <input type='hidden' name='newver' value='$newver' />
  61              <input type='hidden' name='oldsql' value='$oldsql' />
  62              <input type='hidden' name='newsql' value='$newsql' />
  63              <input type='submit' class='primary' value='" . yourls_esc_attr__( 'Upgrade' ) . "' />
  64              </form>";
  65  
  66              break;
  67  
  68          case 1:
  69          case 2:
  70              $upgrade = yourls_upgrade( $step, $oldver, $newver, $oldsql, $newsql );
  71              break;
  72  
  73          case 3:
  74              $upgrade = yourls_upgrade( 3, $oldver, $newver, $oldsql, $newsql );
  75              echo '<p>' . yourls__( 'Your installation is now up to date ! ' ) . '</p>';
  76              echo '<p>' . yourls_s( 'Go back to <a href="%s">the admin interface</a>', yourls_admin_url('index.php') ) . '</p>';
  77      }
  78  
  79  }
  80  
  81  ?>
  82  
  83  <?php yourls_html_footer(); ?>


Generated: Wed Sep 18 05:10:18 2024 Cross-referenced by PHPXref 0.7.1