protected function execute(InputInterface $input, OutputInterface $output) { $rc = 0; $default_environment = \Config::getEnvironment(); $environment = $input->getOption('environment') ?: $default_environment; $file_system = new Filesystem(); $file_loader = new FileLoader($file_system); if ($input->getOption('generated-overrides')) { $file_saver = new FileSaver($file_system, $environment == $default_environment ? null : $environment); } else { $file_saver = new DirectFileSaver($file_system, $environment == $default_environment ? null : $environment); } $this->repository = new Repository($file_loader, $file_saver, $environment); try { $item = $input->getArgument('item'); switch ($input->getArgument('operation')) { case self::OPERATION_GET: $output->writeln($this->serialize($this->repository->get($item))); break; case self::OPERATION_SET: $value = $input->getArgument('value'); if (!isset($value)) { throw new Exception('Missing new configuration value'); } $this->repository->save($item, $this->unserialize($value)); break; default: throw new Exception('Invalid operation specified. Allowed operations: ' . implode(', ', $this->getAllowedOperations())); } } catch (Exception $x) { $output->writeln('<error>' . $x->getMessage() . '</error>'); $rc = 1; } return $rc; }
public function fire() { $options = $this->option(); $this->seed_path = storage_path('seeder'); Asset::setFromSeed(true); // ------------------------------------- if (is_true($options['reset'])) { if (Config::getEnvironment() == 'production') { $really = $this->confirm('This is the *** PRODUCTION *** server are you sure!? [yes|no]'); if (!$really) { $this->info("**** Exiting ****"); exit; } } if (!File::exists($this->seed_path)) { File::makeDirectory($this->seed_path); $n = 50; for ($i = 1; $i <= $n; $i++) { $gender_types = ['men', 'women']; foreach ($gender_types as $gender) { $user_photo_url = "http://api.randomuser.me/portraits/{$gender}/{$i}.jpg"; File::put($this->seed_path . "/{$gender}_{$i}.jpg", file_get_contents($user_photo_url)); } $this->info("Cache user seed image - {$i}"); } } if ($this->confirm('Do you really want to delete the tables? [yes|no]')) { // first delete all assets if (Schema::hasTable('assets')) { foreach (Asset::all() as $asset) { $asset->delete(); } } $name = $this->call('migrate'); $name = $this->call('migrate:reset'); File::deleteDirectory(public_path('assets/content/users')); $this->info('--- Halp has been reset ---'); } Auth::logout(); $this->setupDatabases(); return; } // ------------------------------------- if (is_true($options['setup'])) { $this->setupDatabases(); } // ------------------------------------- if ($options['seed'] == 'all') { $this->seed(); } if ($options['seed'] == 'users') { $this->seedUsers(); } if ($options['seed'] == 'tasks') { $this->seedTasks(); } if ($options['seed'] == 'projects') { $this->seedProjects(); } }
public static function getClient() { $creds = GoogleSessionController::getCreds(); $client = new Google_Client(); $env = Config::getEnvironment(); if ($env == 'local' && $creds->oauth_local_path) { $client->setAuthConfigFile($creds->oauth_local_path); } else { if ($creds->oauth_remote_path) { $client->setAuthConfigFile($creds->oauth_remote_path); } else { $client->setApplicationName($creds->app_name); $client->setClientId($creds->client_id); $client->setClientSecret($creds->client_secret); } } $client->setRedirectUri(GoogleSessionController::getRedirectURI()); $hd = Config::get('config.google.hd'); if ($hd) { $client->setHostedDomain($hd); } $client->setAccessType('offline'); $client->addScope("https://www.googleapis.com/auth/userinfo.profile"); $client->addScope("https://www.googleapis.com/auth/userinfo.email"); $client->setScopes($creds->scopes); return $client; }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('tasks', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->integer('project_id'); $table->integer('creator_id'); $table->string('duration'); $table->boolean('does_not_expire')->default(false); $table->integer('claimed_id')->nullable()->default(NULL); $table->timestamp('claimed_at')->nullable()->default(NULL); $table->timestamp('task_date')->nullable()->default(NULL); $table->text('details')->nullable()->default(NULL); $table->softDeletes(); $table->timestamps(); }); if (Config::getEnvironment() == 'local') { } }
private static function environmentTests() { $tests = array(); // PHP version $test['label'] = 'PHP'; $test['value'] = PHP_VERSION; $test['pass'] = version_compare(PHP_VERSION, '5.2.0', '>'); $test['info'] = version_compare(PHP_VERSION, '5.3.0', '<') ? 'PHP >= 5.3 recommanded' : null; $tests[] = $test; // Configuration $test['label'] = 'Configuration environment (APP_ENV)'; $test['value'] = Config::getEnvironment(); $test['pass'] = true; $test['info'] = null; $tests[] = $test; // Dirs $test['label'] = 'Project Directory (APP_DIR)'; $test['value'] = APP_DIR; $test['pass'] = true; $test['info'] = null; $tests[] = $test; $t = is_writable(CACHE_DIR) && is_writable(CACHE_DIR . DS . 'templates_c') && is_writable(CACHE_DIR . DS . 'html'); $test['label'] = 'Cache Directory (CACHE_DIR)'; $test['value'] = CACHE_DIR; $test['pass'] = $t; $test['info'] = !$t ? 'Cache directory or one of his subdir is not writeable' : null; $tests[] = $test; $t = is_writable(LOGS_DIR); $test['label'] = 'Logs Directory (LOGS_DIR)'; $test['value'] = LOGS_DIR; $test['pass'] = $t; $test['info'] = !$t ? 'Logs directory is not writeable' : null; $tests[] = $test; // required extensions $exts = array('GD', 'mbstring', 'PDO'); foreach ($exts as $ext) { $t = extension_loaded($ext); $test['label'] = $ext; $test['value'] = $t ? 'Pass' : 'Fail'; $test['pass'] = $t; $test['info'] = !$t ? $ext . ' extension is not loaded' : null; $tests[] = $test; } // required extensions $exts = array('APC', 'mcrypt'); foreach ($exts as $ext) { $t = extension_loaded($ext); $test['label'] = $ext . ' enabled'; $test['value'] = $t ? 'Pass' : 'Recommanded'; $test['pass'] = $t; $test['info'] = !$t ? $ext . ' extension is recommanded' : null; $tests[] = $test; } $t = extension_loaded('memcache') || extension_loaded('memcached'); $test['label'] = 'memcache(d) enabled'; $test['value'] = $t ? 'Pass' : 'Recommanded'; $test['pass'] = $t; $test['info'] = !$t ? 'memcached extension is recommanded' : null; $tests[] = $test; return $tests; }
// $q->whereRaw("IFNULL(`task_date`, `created_at`) > '$today'"); // $q->whereRaw(DB::raw(" // IFNULL(`task_date`, `created_at`) > // (CASE WHEN `task_date` IS NULL THEN DATE_ADD(CURDATE(), INTERVAL $n_days DAY) ELSE CURRENT_DATE END)")); //$q->select('tasks.*', DB::raw("IFNULL(`task_date`, `created_at`) > (CASE WHEN `task_date` IS NULL THEN DATE_ADD(CURDATE(), INTERVAL $n_days DAY) ELSE CURRENT_DATE END) AS is_expired")); $q->withTrashed(); // return $q->toSql(); return $q->get(); return $r; }); // ------------------------------------------------------------------------ Route::get('php', function () { phpinfo(); }); Route::get('env', function () { return [$_SERVER, Config::getEnvironment()]; }); // notifications // ------------------------------------------------------------------------ Route::group(array('prefix' => 'notifications'), function () { // send a notification Route::any('send/{id}', ['uses' => 'NotificationsController@send']); }); // site login // ------------------------------------------------------------------------ Route::post('site-login', ['uses' => 'PageController@ChecksiteLogin']); // ------------------------------------------------------------------------ Route::group(array('before' => ['auth']), function () { Route::get('unsubscribe', ['uses' => 'UsersController@unsubscribe']); Route::get('/', ['uses' => 'TasksController@index']); // leaderboard
}); Route::post('generator/{character}/reset', 'SaveController@resetCurrentChanges'); Route::group(['before' => 'storyteller'], function () { Route::post('generator/{character}/options/save', 'SaveController@saveStorytellerOptions'); }); }); }); Route::get('login', function () { return View::make('login'); }); Route::post('login', ['uses' => 'HomeController@doLogin']); Route::get('logout', ['uses' => 'HomeController@doLogout']); Route::post('createAccount', ['uses' => 'HomeController@createAccount']); Route::get('rulebook', 'HomeController@buildRulebook'); Route::get('character/verify/{character}/{version?}', function (Character $character, $version = -1) { if ($version == -1) { $version = $character->approved_version; } return Response::json($character->verify($version, true)); }); Route::controller('password', 'RemindersController'); App::missing(function ($exception) { return Response::view('errors/404', [], 404); }); App::error(function ($error, $code) { if ($code != 500 || Config::getEnvironment() == 'production') { if (!Auth::user() || !Auth::user()->isStoryteller()) { return Response::view('errors.' . $code, [], $code); } } });
| | Here you may handle any errors that occur in your application, including | logging them or displaying custom views for specific errors. You may | even register several error handlers to handle different types of | exceptions. If nothing is returned, the default error view is | shown, which includes a detailed stack trace during debug. | | When an error occurs, all the emails in the developers_to_email array | are sent an email containing the error data. | */ //Change this, future developer aka Rebecca. $developers_to_email = ["*****@*****.**"]; App::error(function (Exception $exception, $code) use($developers_to_email) { Log::error($exception); if (Config::getEnvironment() == 'production') { if (!Auth::user() || !Auth::user()->isStoryteller()) { $data = array('exception' => $exception); foreach ($developers_to_email as $d) { Mail::send('emails.error', $data, function ($message) use($d) { $message->to($d)->subject("[Bug Report] Carpe Noctem Error"); }); } Log::info('Error Emails sent to ' . Helpers::nl_join($developers_to_email)); return App::abort(500); } } }); /* |-------------------------------------------------------------------------- | Maintenance Mode Handler