13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
14 */ |
14 */ |
15 |
15 |
16 // Our version number. This needs to be changed for any custom releases. |
16 // Our version number. This needs to be changed for any custom releases. |
17 $installer_version = array( |
17 $installer_version = array( |
18 'version' => '1.1.8', |
18 'version' => '1.1.8', |
19 'type' => 'beta' |
19 'type' => 'beta' |
20 // If type is set to "rc", "beta", or "alpha", optionally another version number can be issued with the key 'sub': |
20 // If type is set to "rc", "beta", or "alpha", optionally another version number can be issued with the key 'sub': |
21 // 'sub' => '3' will produce Enano 1.1.1a3 / Enano 1.1.1 alpha 3 |
21 // 'sub' => '3' will produce Enano 1.1.1a3 / Enano 1.1.1 alpha 3 |
22 ); |
22 ); |
23 |
23 |
24 function installer_enano_version($long = false) |
24 function installer_enano_version($long = false) |
25 { |
25 { |
26 global $installer_version; |
26 global $installer_version; |
27 static $keywords = array( |
27 static $keywords = array( |
28 'alpha' => 'a', |
28 'alpha' => 'a', |
29 'beta' => 'b', |
29 'beta' => 'b', |
30 'RC' => 'rc' |
30 'RC' => 'rc' |
31 ); |
31 ); |
32 $v = $installer_version['version']; |
32 $v = $installer_version['version']; |
33 if ( isset($installer_version['sub']) ) |
33 if ( isset($installer_version['sub']) ) |
34 { |
34 { |
35 $v .= ( !$long ) ? $keywords[$installer_version['type']] : " {$installer_version['type']} "; |
35 $v .= ( !$long ) ? $keywords[$installer_version['type']] : " {$installer_version['type']} "; |
36 $v .= $installer_version['sub']; |
36 $v .= $installer_version['sub']; |
37 } |
37 } |
38 return $v; |
38 return $v; |
39 } |
39 } |
40 |
40 |
41 // Determine Enano root directory |
41 // Determine Enano root directory |
42 |
42 |
43 if ( !defined('ENANO_ROOT') ) |
43 if ( !defined('ENANO_ROOT') ) |
44 { |
44 { |
45 $enano_root = dirname(dirname(dirname(__FILE__))); |
45 $enano_root = dirname(dirname(dirname(__FILE__))); |
46 if ( preg_match('#/repo$#', $enano_root) && file_exists("$enano_root/../.enanodev") ) |
46 if ( preg_match('#/repo$#', $enano_root) && file_exists("$enano_root/../.enanodev") ) |
47 { |
47 { |
48 $enano_root = preg_replace('#/repo$#', '', $enano_root); |
48 $enano_root = preg_replace('#/repo$#', '', $enano_root); |
49 } |
49 } |
50 |
50 |
51 define('ENANO_ROOT', $enano_root); |
51 define('ENANO_ROOT', $enano_root); |
52 } |
52 } |
53 |
53 |
54 chdir(ENANO_ROOT); |
54 chdir(ENANO_ROOT); |
55 |
55 |
56 // Determine our scriptPath |
56 // Determine our scriptPath |
57 if ( isset($_SERVER['REQUEST_URI']) && !defined('scriptPath') ) |
57 if ( isset($_SERVER['REQUEST_URI']) && !defined('scriptPath') ) |
58 { |
58 { |
59 // Use reverse-matching to determine where the REQUEST_URI overlaps the Enano root. |
59 // Use reverse-matching to determine where the REQUEST_URI overlaps the Enano root. |
60 $requri = $_SERVER['REQUEST_URI']; |
60 $requri = $_SERVER['REQUEST_URI']; |
61 if ( isset($_SERVER['PATH_INFO']) && !preg_match('/index\.php$/', $_SERVER['PATH_INFO']) ) |
61 if ( isset($_SERVER['PATH_INFO']) && !preg_match('/index\.php$/', $_SERVER['PATH_INFO']) ) |
62 { |
62 { |
63 $requri = preg_replace(';' . preg_quote($_SERVER['PATH_INFO']) . '$;', '', $requri); |
63 $requri = preg_replace(';' . preg_quote($_SERVER['PATH_INFO']) . '$;', '', $requri); |
64 } |
64 } |
65 if ( !preg_match('/\.php$/', $requri) ) |
65 if ( !preg_match('/\.php$/', $requri) ) |
66 { |
66 { |
67 // user requested http://foo/enano as opposed to http://foo/enano/index.php |
67 // user requested http://foo/enano as opposed to http://foo/enano/index.php |
68 $requri .= '/index.php'; |
68 $requri .= '/index.php'; |
69 } |
69 } |
70 $sp = dirname($_SERVER['REQUEST_URI']); |
70 $sp = dirname($_SERVER['REQUEST_URI']); |
71 if ( $sp == '/' || $sp == '\\' ) |
71 if ( $sp == '/' || $sp == '\\' ) |
72 { |
72 { |
73 $sp = ''; |
73 $sp = ''; |
74 } |
74 } |
75 $sp = preg_replace('#/install$#', '', $sp); |
75 $sp = preg_replace('#/install$#', '', $sp); |
76 define('scriptPath', $sp); |
76 define('scriptPath', $sp); |
77 } |
77 } |
78 |
78 |
79 // is Enano already installed? |
79 // is Enano already installed? |
80 @include(ENANO_ROOT . '/config.php'); |
80 @include(ENANO_ROOT . '/config.php'); |
81 if ( defined('ENANO_INSTALLED') && defined('ENANO_DANGEROUS') && !isset($_GET['debug_warn_php4']) ) |
81 if ( defined('ENANO_INSTALLED') && defined('ENANO_DANGEROUS') && !isset($_GET['debug_warn_php4']) ) |
82 { |
82 { |
83 $title = 'Installation locked'; |
83 $title = 'Installation locked'; |
84 require('includes/common.php'); |
84 require('includes/common.php'); |
85 $template->header(); |
85 $template->header(); |
86 echo '<p>The installer has detected that an installation of Enano already exists on your server. You MUST delete config.php if you wish to reinstall Enano.</p>'; |
86 echo '<p>The installer has detected that an installation of Enano already exists on your server. You MUST delete config.php if you wish to reinstall Enano.</p>'; |
87 $template->footer(); |
87 $template->footer(); |
88 exit(); |
88 exit(); |
89 } |
89 } |
90 |
90 |
91 if ( !function_exists('microtime_float') ) |
91 if ( !function_exists('microtime_float') ) |
92 { |
92 { |
93 function microtime_float() |
93 function microtime_float() |
94 { |
94 { |
95 list($usec, $sec) = explode(" ", microtime()); |
95 list($usec, $sec) = explode(" ", microtime()); |
96 return ((float)$usec + (float)$sec); |
96 return ((float)$usec + (float)$sec); |
97 } |
97 } |
98 } |
98 } |
99 |
99 |
100 define('IN_ENANO_INSTALL', 1); |
100 define('IN_ENANO_INSTALL', 1); |
101 |
101 |
102 require_once(ENANO_ROOT . '/install/includes/ui.php'); |
102 require_once(ENANO_ROOT . '/install/includes/ui.php'); |
107 require_once(ENANO_ROOT . '/includes/hmac.php'); |
107 require_once(ENANO_ROOT . '/includes/hmac.php'); |
108 |
108 |
109 // If we have at least PHP 5, load json2 |
109 // If we have at least PHP 5, load json2 |
110 if ( version_compare(PHP_VERSION, '5.0.0', '>=') ) |
110 if ( version_compare(PHP_VERSION, '5.0.0', '>=') ) |
111 { |
111 { |
112 require_once(ENANO_ROOT . '/includes/json2.php'); |
112 require_once(ENANO_ROOT . '/includes/json2.php'); |
113 } |
113 } |
114 |
114 |
115 strip_magic_quotes_gpc(); |
115 strip_magic_quotes_gpc(); |
116 |
116 |
117 // Build a list of available languages |
117 // Build a list of available languages |
118 $dir = @opendir( ENANO_ROOT . '/language' ); |
118 $dir = @opendir( ENANO_ROOT . '/language' ); |
119 if ( !$dir ) |
119 if ( !$dir ) |
120 die('CRITICAL: could not open language directory'); |
120 die('CRITICAL: could not open language directory'); |
121 |
121 |
122 $languages = array(); |
122 $languages = array(); |
123 // Use the old PHP4-compatible JSON decoder |
123 // Use the old PHP4-compatible JSON decoder |
124 $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
124 $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
125 |
125 |
126 while ( $dh = @readdir($dir) ) |
126 while ( $dh = @readdir($dir) ) |
127 { |
127 { |
128 if ( $dh == '.' || $dh == '..' ) |
128 if ( $dh == '.' || $dh == '..' ) |
129 continue; |
129 continue; |
130 if ( file_exists( ENANO_ROOT . "/language/$dh/meta.json" ) ) |
130 if ( file_exists( ENANO_ROOT . "/language/$dh/meta.json" ) ) |
131 { |
131 { |
132 // Found a language directory, determine metadata |
132 // Found a language directory, determine metadata |
133 $meta = @file_get_contents( ENANO_ROOT . "/language/$dh/meta.json" ); |
133 $meta = @file_get_contents( ENANO_ROOT . "/language/$dh/meta.json" ); |
134 if ( empty($meta) ) |
134 if ( empty($meta) ) |
135 // Could not read metadata file, continue silently |
135 // Could not read metadata file, continue silently |
136 continue; |
136 continue; |
137 $meta = $json->decode($meta); |
137 $meta = $json->decode($meta); |
138 if ( isset($meta['lang_name_english']) && isset($meta['lang_name_native']) && isset($meta['lang_code']) ) |
138 if ( isset($meta['lang_name_english']) && isset($meta['lang_name_native']) && isset($meta['lang_code']) ) |
139 { |
139 { |
140 $languages[$meta['lang_code']] = array( |
140 $languages[$meta['lang_code']] = array( |
141 'name' => $meta['lang_name_native'], |
141 'name' => $meta['lang_name_native'], |
142 'name_eng' => $meta['lang_name_english'], |
142 'name_eng' => $meta['lang_name_english'], |
143 'dir' => $dh |
143 'dir' => $dh |
144 ); |
144 ); |
145 } |
145 } |
146 } |
146 } |
147 } |
147 } |
148 |
148 |
149 if ( count($languages) < 1 ) |
149 if ( count($languages) < 1 ) |
150 { |
150 { |
151 die('The Enano installer couldn\'t find any languages in the language/ folder. Enano needs at least one language in this folder to load and install properly.'); |
151 die('The Enano installer couldn\'t find any languages in the language/ folder. Enano needs at least one language in this folder to load and install properly.'); |
152 } |
152 } |
153 |
153 |
154 // List of available DB drivers |
154 // List of available DB drivers |
155 $supported_drivers = array('mysql', 'postgresql'); |
155 $supported_drivers = array('mysql', 'postgresql'); |
156 |
156 |
157 // Divert to CLI loader if running from CLI |
157 // Divert to CLI loader if running from CLI |
158 if ( isset($argc) && isset($argv) ) |
158 if ( isset($argc) && isset($argv) ) |
159 { |
159 { |
160 if ( is_int($argc) && is_array($argv) && !isset($_SERVER['REQUEST_URI']) ) |
160 if ( is_int($argc) && is_array($argv) && !isset($_SERVER['REQUEST_URI']) ) |
161 { |
161 { |
162 define('ENANO_CLI', ''); |
162 define('ENANO_CLI', ''); |
163 } |
163 } |
164 } |
164 } |
165 |
165 |
166 ?> |
166 ?> |