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