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