Beispiel #1
0
 /**
  * Checks to see whether or not the database has a migrations table
  * and a user, otherwise display the setup view.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v3.0]
  * @return View
  */
 public function getSetupIndex()
 {
     try {
         $conn = DB::select('select 2 + 2');
         $start_settings['db_conn'] = true;
         $start_settings['db_name'] = DB::connection()->getDatabaseName();
         $start_settings['db_error'] = null;
     } catch (\PDOException $e) {
         $start_settings['db_conn'] = false;
         $start_settings['db_name'] = config('database.connections.mysql.database');
         $start_settings['db_error'] = $e->getMessage();
     }
     $protocol = array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on" ? 'https://' : 'http://';
     $pageURL = $protocol;
     if ($_SERVER["SERVER_PORT"] != "80") {
         $main_page = $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
         $pageURL .= $main_page . $_SERVER["REQUEST_URI"];
     } else {
         $main_page = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
         $pageURL .= $main_page;
     }
     $start_settings['env_location'] = $pageURL . '../.env';
     if (config('app.url') . '/setup' != $pageURL) {
         $start_settings['url_valid'] = false;
     } else {
         $start_settings['url_valid'] = true;
     }
     $start_settings['url_config'] = config('app.url');
     $start_settings['real_url'] = $pageURL;
     $exposed_env = @file_get_contents($main_page . '/.env');
     if ($exposed_env) {
         $start_settings['env_exposed'] = true;
     } else {
         $start_settings['env_exposed'] = false;
     }
     if (\App::Environment('production') && config('app.debug') == true) {
         $start_settings['debug_exposed'] = true;
     } else {
         $start_settings['debug_exposed'] = false;
     }
     $environment = app()->environment();
     if ($environment != 'production') {
         $start_settings['env'] = $environment;
         $start_settings['prod'] = false;
     } else {
         $start_settings['env'] = $environment;
         $start_settings['prod'] = true;
     }
     if (function_exists('posix_getpwuid')) {
         // Probably Linux
         $owner = posix_getpwuid(fileowner($_SERVER["SCRIPT_FILENAME"]));
         $start_settings['owner'] = $owner['name'];
     } else {
         // Windows
         // TODO: Is there a way of knowing if a windows user has elevated permissions
         // This just gets the user name, which likely isn't 'root'
         // $start_settings['owner'] = getenv('USERNAME');
         $start_settings['owner'] = '';
     }
     if ($start_settings['owner'] === 'root' || $start_settings['owner'] === '0') {
         $start_settings['owner_is_admin'] = true;
     } else {
         $start_settings['owner_is_admin'] = false;
     }
     if (is_writable(storage_path()) && is_writable(storage_path() . '/framework') && is_writable(storage_path() . '/framework/cache') && is_writable(storage_path() . '/framework/sessions') && is_writable(storage_path() . '/framework/views') && is_writable(storage_path() . '/logs')) {
         $start_settings['writable'] = true;
     } else {
         $start_settings['writable'] = false;
     }
     $start_settings['gd'] = extension_loaded('gd');
     return View::make('setup/index')->with('step', 1)->with('start_settings', $start_settings)->with('section', 'Pre-Flight Check');
 }