mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:24:42 -04:00
Check for large logo image files
This commit is contained in:
parent
0732f068ff
commit
1b099d09cc
@ -1,7 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Event;
|
|
||||||
use File;
|
use File;
|
||||||
use Image;
|
use Image;
|
||||||
use Input;
|
use Input;
|
||||||
@ -227,6 +226,17 @@ class AccountController extends BaseController
|
|||||||
|
|
||||||
private function showCompanyDetails()
|
private function showCompanyDetails()
|
||||||
{
|
{
|
||||||
|
// check that logo is less than the max file size
|
||||||
|
$account = Auth::user()->account;
|
||||||
|
if ($account->hasLogo()) {
|
||||||
|
$filename = $account->getLogoPath();
|
||||||
|
$bytes = File::size($filename);
|
||||||
|
if ($bytes > MAX_LOGO_FILE_SIZE * 1000) {
|
||||||
|
$bytes /= 1000;
|
||||||
|
Session::flash('warning', trans('texts.logo_too_large', ['size' => round($bytes) . 'KB']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
||||||
'countries' => Cache::get('countries'),
|
'countries' => Cache::get('countries'),
|
||||||
@ -842,7 +852,7 @@ class AccountController extends BaseController
|
|||||||
{
|
{
|
||||||
$rules = array(
|
$rules = array(
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'logo' => 'sometimes|max:200|mimes:jpeg,gif,png',
|
'logo' => 'sometimes|max:' . MAX_LOGO_FILE_SIZE . '|mimes:jpeg,gif,png',
|
||||||
);
|
);
|
||||||
|
|
||||||
$validator = Validator::make(Input::all(), $rules);
|
$validator = Validator::make(Input::all(), $rules);
|
||||||
@ -905,7 +915,7 @@ class AccountController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::fire(new UserSettingsChanged());
|
event(new UserSettingsChanged());
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_settings'));
|
Session::flash('message', trans('texts.updated_settings'));
|
||||||
return Redirect::to('settings/' . ACCOUNT_COMPANY_DETAILS);
|
return Redirect::to('settings/' . ACCOUNT_COMPANY_DETAILS);
|
||||||
@ -940,7 +950,7 @@ class AccountController extends BaseController
|
|||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
Event::fire(new UserSettingsChanged());
|
event(new UserSettingsChanged());
|
||||||
Session::flash('message', trans('texts.updated_settings'));
|
Session::flash('message', trans('texts.updated_settings'));
|
||||||
return Redirect::to('settings/' . ACCOUNT_USER_DETAILS);
|
return Redirect::to('settings/' . ACCOUNT_USER_DETAILS);
|
||||||
}
|
}
|
||||||
@ -957,7 +967,7 @@ class AccountController extends BaseController
|
|||||||
$account->military_time = Input::get('military_time') ? true : false;
|
$account->military_time = Input::get('military_time') ? true : false;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
Event::fire(new UserSettingsChanged());
|
event(new UserSettingsChanged());
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_settings'));
|
Session::flash('message', trans('texts.updated_settings'));
|
||||||
return Redirect::to('settings/' . ACCOUNT_LOCALIZATION);
|
return Redirect::to('settings/' . ACCOUNT_LOCALIZATION);
|
||||||
|
@ -334,6 +334,7 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('MAX_NUM_USERS', 20);
|
define('MAX_NUM_USERS', 20);
|
||||||
define('MAX_SUBDOMAIN_LENGTH', 30);
|
define('MAX_SUBDOMAIN_LENGTH', 30);
|
||||||
define('MAX_IFRAME_URL_LENGTH', 250);
|
define('MAX_IFRAME_URL_LENGTH', 250);
|
||||||
|
define('MAX_LOGO_FILE_SIZE', 200); // KB
|
||||||
define('DEFAULT_FONT_SIZE', 9);
|
define('DEFAULT_FONT_SIZE', 9);
|
||||||
define('DEFAULT_SEND_RECURRING_HOUR', 8);
|
define('DEFAULT_SEND_RECURRING_HOUR', 8);
|
||||||
|
|
||||||
|
@ -918,4 +918,5 @@ return array(
|
|||||||
'country' => 'Country',
|
'country' => 'Country',
|
||||||
'include' => 'Include',
|
'include' => 'Include',
|
||||||
|
|
||||||
|
'logo_too_large' => 'Your logo is :size, for better performance we suggest uploading an image file less than 200KB',
|
||||||
);
|
);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
->addClass('warn-on-exit')
|
->addClass('warn-on-exit')
|
||||||
->autocomplete('on')
|
->autocomplete('on')
|
||||||
->rules([
|
->rules([
|
||||||
'name' => 'required'
|
'name' => 'required'
|
||||||
]) !!}
|
]) !!}
|
||||||
|
|
||||||
{{ Former::populate($account) }}
|
{{ Former::populate($account) }}
|
||||||
@ -37,24 +37,29 @@
|
|||||||
<h3 class="panel-title">{!! trans('texts.details') !!}</h3>
|
<h3 class="panel-title">{!! trans('texts.details') !!}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body form-padding-right">
|
<div class="panel-body form-padding-right">
|
||||||
|
|
||||||
{!! Former::text('name') !!}
|
{!! Former::text('name') !!}
|
||||||
{!! Former::text('id_number') !!}
|
{!! Former::text('id_number') !!}
|
||||||
{!! Former::text('vat_number') !!}
|
{!! Former::text('vat_number') !!}
|
||||||
{!! Former::text('work_email') !!}
|
{!! Former::text('work_email') !!}
|
||||||
{!! Former::text('work_phone') !!}
|
{!! Former::text('work_phone') !!}
|
||||||
{!! Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) !!}
|
{!! Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) !!}
|
||||||
|
|
||||||
|
|
||||||
@if ($account->hasLogo())
|
@if ($account->hasLogo())
|
||||||
<center>
|
<div class="form-group">
|
||||||
{!! HTML::image($account->getLogoPath().'?no_cache='.time(), 'Logo', ['width' => 200]) !!}
|
<div class="col-lg-4 col-sm-4"></div>
|
||||||
<a href="#" onclick="deleteLogo()">{{ trans('texts.remove_logo') }}</a>
|
<div class="col-lg-8 col-sm-8">
|
||||||
</center><br/>
|
<a href="/{{ $account->getLogoPath().'?no_cache='.time() }}" target="_blank">
|
||||||
@endif
|
{!! HTML::image($account->getLogoPath().'?no_cache='.time(), 'Logo', ['width' => 200]) !!}
|
||||||
|
</a>
|
||||||
|
<a href="#" onclick="deleteLogo()">{{ trans('texts.remove_logo') }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
{!! Former::select('size_id')->addOption('','')->fromQuery($sizes, 'name', 'id') !!}
|
{!! Former::select('size_id')->addOption('','')->fromQuery($sizes, 'name', 'id') !!}
|
||||||
{!! Former::select('industry_id')->addOption('','')->fromQuery($industries, 'name', 'id') !!}
|
{!! Former::select('industry_id')->addOption('','')->fromQuery($industries, 'name', 'id') !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user