Skip to content

Instantly share code, notes, and snippets.

View acecconato's full-sized avatar
👨‍💻

Anthony Espasa acecconato

👨‍💻
View GitHub Profile
@acecconato
acecconato / delete_old_users.php
Last active January 25, 2023 10:26
Useful scripts for Prestashop owners
<?php
/**
* @author - Mobiloweb - Anthony Cecconato
* @version 1.0
* @cms Prestashop
* @ps_version 1.7+
*
* Delete old users, without orders (+12month by default) by getting the /yoururl/cron/delete_old_users.php?s_key=SECRET url
*/
@acecconato
acecconato / .htaccess
Last active April 27, 2023 09:55
.htaccess security rules
## Block base64 injections
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
@acecconato
acecconato / App\Entity\EntityMerger.php
Created December 6, 2019 10:52
EntityMerger for a simple Symfony 4 RESTful API. Created for handle PUT methods.
<?php
namespace App\Entity;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Id;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
@acecconato
acecconato / FileUploader.php
Last active October 10, 2020 21:30
Symfony + EasyAdmin: File upload system
/**
Due to best practices, we need to create a new service which is used by the ImageListener.
Its role is to upload files and generate an unique filename.
NOTA:
The default $uploadPath is autowired by argument binding inside services.yaml
but in this case, we override it with the $path argument of the upload method.
*/
<?php
@acecconato
acecconato / client.js
Created May 23, 2019 12:51
npm ftp + npm util-promisifyall: Read directory and subfolders recursively
/**
* Install dependencies with npm:
* npm i ftp
* npm i util-promisifyall
*/
const promisifyAll = require('util-promisifyall');
const Client = require('ftp');
/**
* CONFIGURE YOUR OWN FTP !