161 $sp = dirname($_SERVER['REQUEST_URI']); |
161 $sp = dirname($_SERVER['REQUEST_URI']); |
162 if($sp == '/' || $sp == '\\') $sp = ''; |
162 if($sp == '/' || $sp == '\\') $sp = ''; |
163 define('scriptPath', $sp); |
163 define('scriptPath', $sp); |
164 define('contentPath', "$sp/index.php?title="); |
164 define('contentPath', "$sp/index.php?title="); |
165 } |
165 } |
166 $loc = scriptPath . '/install.php'; |
166 $loc = scriptPath . '/install/index.php'; |
167 define('IN_ENANO_INSTALL', 1); |
167 define('IN_ENANO_INSTALL', 1); |
168 $GLOBALS['lang'] = new Language('eng'); |
168 $GLOBALS['lang'] = new Language('eng'); |
169 global $lang; |
169 global $lang; |
170 $lang->load_file('./language/english/enano.json'); |
170 $lang->load_file('./language/english/core.json'); |
171 $lang->load_file('./language/english/install.json'); |
171 $lang->load_file('./language/english/install.json'); |
172 // header("Location: $loc"); |
172 // header("Location: $loc"); |
173 redirect($loc, 'Enano not installed', 'We can\'t seem to find an Enano installation (valid config file). You will be transferred to the installation wizard momentarily...', 3); |
173 redirect($loc, 'Enano not installed', 'We can\'t seem to find an Enano installation (valid config file). You will be transferred to the installation wizard momentarily...', 0); |
174 exit; |
174 exit; |
175 } |
175 } |
176 } |
176 } |
177 |
177 |
178 $this->_conn = @mysql_connect($dbhost, $dbuser, $dbpasswd); |
178 $this->_conn = @mysql_connect($dbhost, $dbuser, $dbpasswd); |
179 unset($dbuser); |
179 unset($dbuser); |
180 unset($dbpasswd); // Security |
180 unset($dbpasswd); // Security |
181 |
181 |
182 if ( !$this->_conn ) |
182 if ( !$this->_conn && !$manual_credentials ) |
183 { |
183 { |
184 grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to MySQL.<br />'.mysql_error().'</p>'); |
184 grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to MySQL.<br />'.mysql_error().'</p>'); |
|
185 } |
|
186 else if ( !$this->_conn && $manual_credentials ) |
|
187 { |
|
188 return false; |
185 } |
189 } |
186 |
190 |
187 // Reset some variables |
191 // Reset some variables |
188 $this->query_backtrace = array(); |
192 $this->query_backtrace = array(); |
189 $this->query_times = array(); |
193 $this->query_times = array(); |
863 $t = "{'mode':'error','error':'An error occurred during database query.\nQuery was:\n $q\n\nError returned by PostgreSQL: $e'}"; |
860 $t = "{'mode':'error','error':'An error occurred during database query.\nQuery was:\n $q\n\nError returned by PostgreSQL: $e'}"; |
864 die($t); |
861 die($t); |
865 } |
862 } |
866 |
863 |
867 function get_error($t = '') { |
864 function get_error($t = '') { |
868 header('HTTP/1.1 500 Internal Server Error'); |
865 @header('HTTP/1.1 500 Internal Server Error'); |
869 $bt = $this->sql_backtrace(); |
866 $bt = $this->sql_backtrace(); |
870 $e = htmlspecialchars(pg_last_error()); |
867 $e = htmlspecialchars(pg_last_error()); |
871 if($e=='') $e='<none>'; |
868 if($e=='') $e='<none>'; |
872 global $email; |
869 global $email; |
873 $email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) ? ', at <' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '>' : ''; |
870 $email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) ? ', at <' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '>' : ''; |
931 } |
928 } |
932 $this->_conn = @pg_connect("host=$dbhost port=5432 dbname=$dbname user=$dbuser password=$dbpasswd"); |
929 $this->_conn = @pg_connect("host=$dbhost port=5432 dbname=$dbname user=$dbuser password=$dbpasswd"); |
933 unset($dbuser); |
930 unset($dbuser); |
934 unset($dbpasswd); // Security |
931 unset($dbpasswd); // Security |
935 |
932 |
936 if ( !$this->_conn ) |
933 if ( !$this->_conn && !$manual_credentials ) |
937 { |
934 { |
938 grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to PostgreSQL.<br />'.pg_last_error().'</p>'); |
935 grinding_halt('Enano is having a problem', '<p>Error: couldn\'t connect to PostgreSQL.<br />'.pg_last_error().'</p>'); |
|
936 } |
|
937 else if ( !$this->_conn && $manual_credentials ) |
|
938 { |
|
939 return false; |
939 } |
940 } |
940 |
941 |
941 // Reset some variables |
942 // Reset some variables |
942 $this->query_backtrace = array(); |
943 $this->query_backtrace = array(); |
943 $this->query_times = array(); |
944 $this->query_times = array(); |