1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-18 23:42:25 +02:00

cronjob thru url #1956

This commit is contained in:
Hillel Coren 2018-03-23 17:43:33 +03:00
parent 9720e66675
commit e76c6265d7
2 changed files with 29 additions and 0 deletions

View File

@ -439,4 +439,29 @@ class AppController extends BaseController
echo $invoice->getPDFString();
exit;
}
public function runCommand()
{
if (Utils::isNinjaProd()) {
abort(400, 'Not allowed');
}
$command = request()->command;
$options = request()->options ?: [];
$secret = env('CRON_SECRET');
if (! $secret) {
exit('Set a value for CRON_SECRET in the .env file');
} elseif (! hash_equals($secret, request()->secret ?: '')) {
exit('Invalid secret');
}
if (! $command || ! in_array($command, ['send-invoices', 'send-reminders', 'update-key'])) {
exit('Invalid command: Valid options are send-invoices, send-reminders or update-key');
}
Artisan::call('ninja:' . $command, $options);
return response(nl2br(Artisan::output()));
}
}

View File

@ -109,6 +109,10 @@ Route::group(['middleware' => ['lookup:contact']], function () {
Route::get('/proposal/image/{account_key}/{document_key}/{filename?}', 'ClientPortalProposalController@getProposalImage');
});
if (Utils::isSelfHost()) {
Route::get('/run_command', 'AppController@runCommand');
}
if (Utils::isReseller()) {
Route::post('/reseller_stats', 'AppController@stats');
}