Skip to content

Instantly share code, notes, and snippets.

@Shagshag
Shagshag / gist:5848915
Last active July 3, 2023 21:45
Unobfuscate this type of code : "eval(gzinflate(base64_decode(strrev('AYwtRlkyv8MKXlcyNj09QdFyO30S'))));"
<?php
$obfuscated = "eval(gzinflate(base64_decode(strrev('AYwtRlkyv8MKXlcyNj09QdFyO30S'))));";
$decoder = new unobfuscate($obfuscated);
echo $decoder->decode(); // echo 'Hello world';
class unobfuscate
{
@Shagshag
Shagshag / gist:5849065
Created June 24, 2013 10:08
Do the same than parse_str without max_input_vars limitation
<?php
/**
* do the same than parse_str without max_input_vars limitation
* @param $string array string to parse
* @return array query parsed
**/
function my_parse_str($string) {
$result = array();
// find the pairs "name=value"
@Shagshag
Shagshag / backup.sh
Created October 20, 2021 09:20
Backup files and databases to FTP with space and old backup management
#!/bin/bash
### Configuration ###
### MYSQL ###
MUSER="" # MySQL user, must can execute 'show databases'
MPASS="" # MySQL password
MHOST="" # MySQL host
### FTP ###
@Shagshag
Shagshag / convert-gls-trackid.php
Created September 15, 2021 10:24
Convert GLS track ID to GLS reference
<?php
// based on https://stackoverflow.com/questions/10471991/convertions-between-decimal-and-base-36#10472259
function convertReferenceToTrackID($number) {
$offset = 2721109907456;
$base = 36;
$in = (string) ($number + $offset);
$out = '';
@Shagshag
Shagshag / PageNotFoundController.php
Created December 15, 2020 18:08
Allow product image with ID > 9 999 999 in PrestaShop
<?php
class PageNotFoundController extends PageNotFoundControllerCore
{
public function initContent()
{
list($filename) = explode('?', substr($_SERVER['REQUEST_URI'], 6));
if (preg_match('/([0-9]+)(\-[_a-zA-Z0-9-]*)?\/.*\.jpg/', $filename, $matches)) {
$path = _PS_ROOT_DIR_.'/img/p/'.implode('/', str_split($matches[1], 1)).'/'.$matches[1].$matches[2].'.jpg';
if (file_exists($path)) {
@Shagshag
Shagshag / vue3_inputdate.js
Created November 24, 2020 08:58
input-date for vue3
// adapted from https://acdcjunior.github.io/how-bind-date-object-to-input-date-vue.js-v-model.html
{
props: ['modelValue'],
emits: ['update:modelValue'],
setup() {
const dateToYYYYMMDD = (d) => {
// alternative implementations in https://stackoverflow.com/q/23593052/1850609
try {
return d && new Date(d.getTime()-(d.getTimezoneOffset()*60*1000)).toISOString().split('T')[0];
} catch(e) {
@Shagshag
Shagshag / vue3_nl2br.js
Created November 24, 2020 08:45
nl2br for vue3
// Adapted from https://github.com/inouetakuya/vue-nl2br/
{
props: {
tag: {
type: String,
required: true,
},
text: {
type: String,
required: true,
@Shagshag
Shagshag / netinstall.php
Last active May 14, 2020 16:55
WordPress netinstall : This script download and unzip the latest version of WordPress
<?php
// This script download and unzip the latest version of WordPress
//
// Put this file in the folder where you want to install WordPress
// Visit it with your browser
// Follow the installation process
$path = dirname(__FILE__);
$local_file = $path.'/latest.zip';
$remote_file = 'https://wordpress.org/latest.zip';
@Shagshag
Shagshag / ps_logtoadmin.php
Last active November 18, 2018 21:21
This script allows to login to PrestaShop without password. Put it on the root of your shop by FTP then visit the URL http://yourshop/ps_logtoadmin.php
<?php
/**
* 1. Change the password below, it's encoded with m5d https://duckduckgo.com/?q=md5+toto
* 2. Put this file at the root of your shop
* 3. Visit the URL http://yourshop/ps_logtoadmin.php
**/
$auth_pass = "f71dbe52628a3f83a77ab494817525c6"; //toto
// display login screen
if (!isset($_POST['pass'])
@Shagshag
Shagshag / empty_folder.php
Created October 4, 2018 08:25
Delete all files and subfolders in the current folder
<?php
/**
* Delete all files and subfolders in the current folder
* I use it to start a new project
* Be careful : There is no confirmation, this script deletes everything it can, including itself
*/
// https://stackoverflow.com/a/17161106/2530962 php glob - scan in subfolders for a file
function rglob($pattern, $flags = 0) {
$files = (array) glob($pattern, $flags);