public function write($key, $value, $forceDb = false)
 {
     if ($forceDb) {
         return $this->writeToDb($key, $value);
     }
     if (!isUsingLocalStorage()) {
         // should probably throw exception here. just leave it as false for now.
         return false;
     }
     list($namespace, $group, $item) = $this->config->parseKey($key);
     $path = base_path("userdata/.env.php");
     $content = '';
     if (file_exists($path)) {
         $content = file_get_contents($path);
     }
     $array = eval('?>' . $content);
     // convert . to _ since some configs don't like . in env vars
     $key = str_replace('.', '_', $key);
     $array[$key] = $value;
     $string = "<?php\n\nreturn " . var_export($array, true) . ";";
     file_put_contents($path, $string);
     //put the value into the environment at run time
     $_ENV[$key] = $value;
     //reload the configuration with the changes to the environment
     \Config::reload($group, $namespace);
 }
示例#2
0
 public function store()
 {
     $data = Input::all();
     Input::flash();
     // Preliminary checks
     if (!($this->checkVersion()->getData()->status && $this->checkExtension('mcrypt')->getData()->status && $this->checkExtension('intl')->getData()->status && $this->checkPermissions()->getData()->status)) {
         Session::flash('error', 'There was a problem. Make sure all of the server checks are showing green to continue.');
         return Redirect::action('InstallController@index');
     }
     // General checks
     if (isUsingLocalStorage()) {
         if (!$data['services']['phaxio']['public']) {
             Session::flash('error', 'Your Phaxio api keys are required. Please get them from <a href="http://www.phaxio.com/apiSettings" target="_blank">your account</a> to continue.');
             return Redirect::action('InstallController@index')->withErrors(['services.phaxio.public' => 'Your public and secret key are required.']);
         }
         if (!$data['services']['phaxio']['secret']) {
             Session::flash('error', 'Your Phaxio api keys are required. Please get them from <a href="http://www.phaxio.com/apiSettings" target="_blank">your account</a> to continue.');
             return Redirect::action('InstallController@index')->withErrors(['services.phaxio.secret' => 'Your public and secret key are required.']);
         }
         if (!$data['app']['url']) {
             Session::flash('error', 'The Site URL is required.');
             return Redirect::action('InstallController@index')->withErrors(['app.url' => 'The Site URL is required']);
         }
         $dbresult = $this->checkDBCredentials($data)->getData();
         if ($dbresult->message) {
             Session::flash('error', 'Your database credentials are incorrect:<br>' . $dbresult->message);
             return Redirect::action('InstallController@index');
         }
         // reformat data
         $db['database'] = $data['database'];
         $db = array_dot($db);
         // write our DB config
         foreach ($db as $key => $value) {
             if (!$value) {
                 continue;
             }
             $this->settings->write($key, $value);
         }
     }
     // Run our migrations
     $artisan = base_path('artisan');
     exec("php {$artisan} migrate --package=cartalyst/sentry --force");
     exec("php {$artisan} migrate --force");
     // Create our superuser
     $data['admin']['permissions']['superuser'] = 1;
     $data['admin']['activate'] = true;
     $result = $this->registerForm->save($data['admin']);
     // Did the user get created? If not return with error
     if (!$result['success']) {
         Session::flash('error', trans('install.generalerror'));
         return Redirect::action('InstallController@index')->withErrors($this->registerForm->errors());
     }
     // Write our settings to the .env file
     if (isUsingLocalStorage()) {
         // write our other settings
         $this->settings->write('app.key', Str::random(32));
         $this->settings->write('app.url', $data['app']['url']);
         $this->settings->write('services.phaxio.public', $data['services']['phaxio']['public']);
         $this->settings->write('services.phaxio.secret', $data['services']['phaxio']['secret']);
         // sensible mail settings
         $this->settings->write('mail.driver', 'sendmail');
         $this->settings->write('mail.from.address', 'admin@' . parse_url($data['app']['url'])['host']);
         // use site name or admin's first/last name
         $from = $data['name'] ?: $data['admin']['first_name'] . ' ' . $data['admin']['last_name'];
         $this->settings->write('mail.from.name', $from);
     }
     // Write these settings to the database
     $this->settings->write('faxbox.name', $data['name'], true);
     $this->settings->write('faxbox.installed', 1, true);
     // installed=true is a workaround to make the success message display. Since we
     // effectively change the app.key during install, laravel will make a
     // new session for the user. But it's currently writing to the old
     // session, so we can't use Session::flash() here.
     // For people using ENV vars this isn't an issue but we'll do it this
     // way all the same to keep it consistent.
     return Redirect::route('login', ['installed' => 'true']);
 }
示例#3
0
|--------------------------------------------------------------------------
| Detect The Application Environment
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name for the host that matches a
| given environment, then we will automatically detect it for you.
|
*/
$env = $app->detectEnvironment(array());
//allow environment variables to override environment detection
if (isset($_ENV['ENVIRONMENT'])) {
    $env = $_ENV['ENVIRONMENT'];
}
//see if we have an env file to load
if (isUsingLocalStorage() && file_exists($app['path.base'] . '/userdata/.env.php')) {
    // We have to use eval since include will cache the file and cause redirects to have stale data
    $envVars = eval('?>' . file_get_contents($app['path.base'] . '/userdata/.env.php'));
    foreach ($envVars as $key => $val) {
        $_ENV[$key] = $val;
    }
}
/*
|--------------------------------------------------------------------------
| Load The Application
|--------------------------------------------------------------------------
|
| Here we will load this Illuminate application. We will keep this in a
| separate location so we can isolate the creation of an application
| from the actual running of the application with a given request.
|