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