]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/install.php
Fix install procedure. Damn it was broken :/
[Github/YOURLS.git] / admin / install.php
1 <?php\r
2 // Require Files\r
3 define( 'YOURLS_INSTALLING', true );\r
4 require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );\r
5 require_once( dirname(dirname(__FILE__)).'/includes/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_mod_rewrite() )\r
13         $error[] = 'Apache module <tt>mod_rewrite</tt> not found. Check this with your server admin.';\r
14 \r
15 if ( !yourls_check_database_version() )\r
16         $error[] = 'MySQL version is too old. Ask your server admin for an upgrade.';\r
17 \r
18 if ( !yourls_check_php_version() )\r
19         $error[] = 'PHP version is too old. Ask your server admin for an upgrade.';\r
20 \r
21 // Check additional stuff\r
22 if ( !yourls_check_curl() )\r
23         $warning[] = 'PHP extension <tt>cURL</tt> is not installed. This server won\'t be able to use the remote API';\r
24 \r
25 if ( !yourls_check_bcmath() )\r
26         $warning[] = 'PHP extension <tt>BC Math</tt> is not installed. Config setting <tt>YOURLS_URL_CONVERT</tt> forced to <tt>36</tt>';\r
27 \r
28 // Is YOURLS already installed ?\r
29 if ( yourls_is_installed() )\r
30         $error[] = 'YOURLS already installed.';\r
31 \r
32 // Start install if possible and needed\r
33 if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {\r
34         // Create/update .htaccess file\r
35         if ( yourls_create_htaccess() ) {\r
36                 $success[] = 'File <tt>.htaccess</tt> successfully created/updated.';\r
37         } else {\r
38                 $error[] = '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
39         }\r
40 \r
41         // Create SQL tables\r
42         $install = yourls_create_sql_tables();\r
43         if ( isset( $install['error'] ) )\r
44                 $error = array_merge( $error, $install['error'] );\r
45         if ( isset( $install['success'] ) )\r
46                 $success = array_merge( $success, $install['success'] );\r
47 }\r
48 \r
49 \r
50 // Start output\r
51 yourls_html_head( 'install' );\r
52 ?>\r
53 <div id="login">\r
54         <form method="post" action="?"><?php // reset any QUERY parameters ?>\r
55                 <p>\r
56                         <img src="<?php echo YOURLS_SITE; ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />\r
57                 </p>\r
58                 <?php\r
59                         // Print errors, warnings and success messages\r
60                         foreach ( array ('error', 'warning', 'success') as $info ) {\r
61                                 if ( count( $$info ) > 0 ) {\r
62                                         echo "<ul class='$info'>";\r
63                                         foreach( $$info as $msg ) {\r
64                                                 echo '<li>'.$msg."</li>\n";\r
65                                         }\r
66                                         echo '</ul>';\r
67                                 }\r
68                         }\r
69 \r
70                         // Display install button or link to admin area if applicable\r
71                         if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {\r
72                                 echo '<p>&nbsp;</p><p style="text-align: center;"><input type="submit" name="install" value="Install YOURLS" class="button" /></p>';\r
73                         } else {\r
74                                 if( count($error) == 0 )\r
75                                         echo '<p>&nbsp;</p><p style="text-align: center;">&raquo; <a href="'.YOURLS_SITE.'/admin/" title="YOURS Administration Page">YOURS Administration Page</a></p>';\r
76                         }\r
77                 ?>\r
78         </form>\r
79 </div>\r
80 <?php yourls_html_footer(); ?>\r