Skip to content

Instantly share code, notes, and snippets.

@tuckbloor
tuckbloor / upload.php
Created May 12, 2023 07:28
laravel upload a file and protect against phar attack
if ($request->hasFile('file')) {
$file = $request->file('file');
$filePath = $file->store('uploads');
$signature = file_get_contents('phar://' . storage_path('app/' . $filePath) . '/.signature');
if ($signature !== 'GBMB') {
// Invalid PHAR file
Storage::delete($filePath);
// Handle error
@tuckbloor
tuckbloor / upload.php
Created May 12, 2023 07:21
php file upload protect against phat
if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) {
// Handle upload error
}
$filePath = $_FILES['file']['tmp_name'];
$signature = file_get_contents('phar://' . $filePath . '/.signature');
if ($signature !== 'GBMB') {
// Invalid PHAR file
}
ini_set('default_socket_timeout', 600);
ini_set('soap.wsdl_cache_enabled',0);//prevent 504 bad getway when conecting to soap
ini_set('soap.wsdl_cache_ttl',0);
/etc/nginx/nginx.conf
inside http
@tuckbloor
tuckbloor / .babelrc
Created July 9, 2022 20:28
laravel 8 with vue3 inertia and jest
{
"presets": [
"@babel/preset-env"
]
}
<template>
<input v-model="county" @input="filterCounty()">
<ul>
<li v-for="result in results" :key="result">
{{ result.replace(/(?:^|\s)\S/g, function(letter) { return letter.toUpperCase() }) }}
</li>
</ul>
@tuckbloor
tuckbloor / php_excel-to-php_office.txt
Last active November 18, 2021 23:17
php excel to php office
src https://stackoverflow.com/questions/48122220/phpspreadsheet-where-is-phpexcel-worksheet-drawing
use PhpOffice\PhpSpreadsheet\Spreadsheet as spreadsheet; // instead PHPExcel
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xlsx; // Instead PHPExcel_Writer_Excel2007
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing as drawing; // Instead PHPExcel_Worksheet_Drawing
use PhpOffice\PhpSpreadsheet\Style\Alignment as alignment; // Instead PHPExcel_Style_Alignment
use PhpOffice\PhpSpreadsheet\Style\Fill as fill; // Instead PHPExcel_Style_Fill
use PhpOffice\PhpSpreadsheet\Style\Color as color_; //Instead PHPExcel_Style_Color
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup as pagesetup; // Instead PHPExcel_Worksheet_PageSetup
use PhpOffice\PhpSpreadsheet\IOFactory as io_factory; // Instead PHPExcel_IOFactory
<?php
namespace {{ namespace }};
use Illuminate\Foundation\Http\FormRequest;
// run php artisan stub:publish first
class {{ class }} extends FormRequest
{
/**
* @param null $keys
@tuckbloor
tuckbloor / gist:b1bf480046e61cb39c9cbbfccd6686c7
Last active December 2, 2020 09:36
laradock windows mssql error run in docker cli php-fpm restart nginx after
sed -i -E 's/(CipherString\s*=\s*DEFAULT@SECLEVEL=)2/\11/' /etc/ssl/openssl.cnf
RewriteEngine on
RewriteCond "%{HTTP_REFERER}" "!http://localhost" [NC]
RewriteRule \.(pdf|xls|xlsx|jpeg|jpg|png|msg|numbers|doc|docx|csv|zip|tar)$ - [F]
#change localhost to mydomain.co.uk change pdf|xls|xlsx to what ever you require
public function claimLinePrice()
{
$quote_number = \Session::get('project_quote_number');
return \DB::select("SELECT quote_builder_line_price_id, quote_builder_line_price_description, quote_builder_line_price_description2, quote_builder_line_price_description3,
quote_builder_line_price_description4, quote_builder_line_price_description5, quote_builder_line_price_description6,
quote_builder_line_price_description7,
quote_builder_line_price_description8, quote_builder_line_price_description9, quote_builder_line_price_description10,
quote_builder_line_price,quote_builder_line_price2,quote_builder_line_price3,quote_builder_line_price4,quote_builder_line_price5,quote_builder_line_price6,
quote_builder_line_price7,quote_builder_line_price8,quote_builder_line_price9,quote_builder_line_price10,