mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:47:36 -05:00 
			
		
		
		
	Merge pull request #4488 from turbo124/v5-develop
Add additional SystemHealth checks
This commit is contained in:
		
						commit
						666966c8bd
					
				@ -101,8 +101,6 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private function validException($exception) 
 | 
					    private function validException($exception) 
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        info("the exception is ");
 | 
					 | 
				
			||||||
        info($exception->getMessage());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(strpos($exception->getMessage(), 'file_put_contents') === TRUE)
 | 
					        if(strpos($exception->getMessage(), 'file_put_contents') === TRUE)
 | 
				
			||||||
            return FALSE;
 | 
					            return FALSE;
 | 
				
			||||||
@ -110,6 +108,10 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
        if(strpos($exception->getMessage(), 'Permission denied') === TRUE)
 | 
					        if(strpos($exception->getMessage(), 'Permission denied') === TRUE)
 | 
				
			||||||
            return FALSE;
 | 
					            return FALSE;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        if(strpos($exception->getMessage(), 'flock()') === TRUE)
 | 
				
			||||||
 | 
					            return FALSE;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return TRUE;
 | 
					        return TRUE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -132,7 +132,7 @@ class EmailController extends BaseController
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity_obj->service()->markSent()->save();
 | 
					        $entity_obj = $entity_obj->service()->markSent()->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity_obj->last_sent_date = now();
 | 
					        $entity_obj->last_sent_date = now();
 | 
				
			||||||
        $entity_obj->save();
 | 
					        $entity_obj->save();
 | 
				
			||||||
@ -172,8 +172,6 @@ class EmailController extends BaseController
 | 
				
			|||||||
            $this->entity_transformer = RecurringInvoiceTransformer::class;
 | 
					            $this->entity_transformer = RecurringInvoiceTransformer::class;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity_obj->service()->markSent()->save();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->itemResponse($entity_obj);
 | 
					        return $this->itemResponse($entity_obj);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -75,7 +75,7 @@ class ImportController extends Controller
 | 
				
			|||||||
        $hash = Str::random(32);
 | 
					        $hash = Str::random(32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //store the csv in cache with an expiry of 10 minutes
 | 
					        //store the csv in cache with an expiry of 10 minutes
 | 
				
			||||||
        Cache::put($hash, base64_encode(file_get_contents($request->file('file')->getPathname())), 10);
 | 
					        Cache::put($hash, base64_encode(file_get_contents($request->file('file')->getPathname())), 60);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //parse CSV
 | 
					        //parse CSV
 | 
				
			||||||
        $csv_array = $this->getCsvData(file_get_contents($request->file('file')->getPathname()));
 | 
					        $csv_array = $this->getCsvData(file_get_contents($request->file('file')->getPathname()));
 | 
				
			||||||
 | 
				
			|||||||
@ -20,11 +20,14 @@ use App\Models\InvoiceInvitation;
 | 
				
			|||||||
use App\Services\PdfMaker\Design;
 | 
					use App\Services\PdfMaker\Design;
 | 
				
			||||||
use App\Services\PdfMaker\PdfMaker;
 | 
					use App\Services\PdfMaker\PdfMaker;
 | 
				
			||||||
use App\Utils\HtmlEngine;
 | 
					use App\Utils\HtmlEngine;
 | 
				
			||||||
 | 
					use App\Utils\Ninja;
 | 
				
			||||||
use App\Utils\PhantomJS\Phantom;
 | 
					use App\Utils\PhantomJS\Phantom;
 | 
				
			||||||
use App\Utils\Traits\MakesHash;
 | 
					use App\Utils\Traits\MakesHash;
 | 
				
			||||||
use App\Utils\Traits\MakesInvoiceHtml;
 | 
					use App\Utils\Traits\MakesInvoiceHtml;
 | 
				
			||||||
use Illuminate\Support\Facades\DB;
 | 
					use Illuminate\Support\Facades\DB;
 | 
				
			||||||
use Illuminate\Support\Facades\Response;
 | 
					use Illuminate\Support\Facades\Response;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\App;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Lang;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PreviewController extends BaseController
 | 
					class PreviewController extends BaseController
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -96,15 +99,16 @@ class PreviewController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $entity_obj->load('client');
 | 
					            $entity_obj->load('client');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            App::setLocale($entity_obj->client->primary_contact()->preferredLocale());
 | 
				
			||||||
 | 
					            App::forgetInstance('translator');
 | 
				
			||||||
 | 
					            Lang::replace(Ninja::transformTranslations($entity_obj->client->getMergedSettings()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $html = new HtmlEngine($entity_obj->invitations()->first());
 | 
					            $html = new HtmlEngine($entity_obj->invitations()->first());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $design_namespace = 'App\Services\PdfMaker\Designs\\'.request()->design['name'];
 | 
					            $design_namespace = 'App\Services\PdfMaker\Designs\\'.request()->design['name'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $design_class = new $design_namespace();
 | 
					            $design_class = new $design_namespace();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // $designer = new Designer($entity_obj, $design_object, $entity_obj->client->getSetting('pdf_variables'), lcfirst($entity));
 | 
					 | 
				
			||||||
            // $html = $this->generateEntityHtml($designer, $entity_obj);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $state = [
 | 
					            $state = [
 | 
				
			||||||
                'template' => $design_class->elements([
 | 
					                'template' => $design_class->elements([
 | 
				
			||||||
                    'client' => $entity_obj->client,
 | 
					                    'client' => $entity_obj->client,
 | 
				
			||||||
@ -141,6 +145,10 @@ class PreviewController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private function blankEntity()
 | 
					    private function blankEntity()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
 | 
					        Lang::replace(Ninja::transformTranslations(auth()->user()->company()->settings));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DB::beginTransaction();
 | 
					        DB::beginTransaction();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client = Client::factory()->create([
 | 
					        $client = Client::factory()->create([
 | 
				
			||||||
 | 
				
			|||||||
@ -78,9 +78,27 @@ class SystemHealth
 | 
				
			|||||||
            'node_status' => self::checkNode(),
 | 
					            'node_status' => self::checkNode(),
 | 
				
			||||||
            'cache_enabled' => self::checkConfigCache(),
 | 
					            'cache_enabled' => self::checkConfigCache(),
 | 
				
			||||||
            'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
 | 
					            'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
 | 
				
			||||||
 | 
					            'exec' => (bool) self::checkExecWorks(),
 | 
				
			||||||
 | 
					            'open_basedir' => (bool) self::checkOpenBaseDir(),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static function checkOpenBaseDir()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if(strlen(ini_get('open_basedir') == 0))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static function checkExecWorks()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if(function_exists('exec')) 
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static function checkConfigCache()
 | 
					    public static function checkConfigCache()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (env('APP_URL')) {
 | 
					        if (env('APP_URL')) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user