Skip to content

Instantly share code, notes, and snippets.

@Shagshag
Shagshag / replace_bad_encoding_rubbishes.sql
Created December 13, 2017 08:52
Replace bad encoding rubbishes like é by UTF-8 characters
UPDATE table SET field = REPLACE(field, CAST(_latin1'à' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'à');
UPDATE table SET field = REPLACE(field, CAST(_latin1'é' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'é');
UPDATE table SET field = REPLACE(field, CAST(_latin1'è' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'è');
UPDATE table SET field = REPLACE(field, CAST(_latin1'ê' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'ê');
UPDATE table SET field = REPLACE(field, CAST(_latin1'ù' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'ù');
UPDATE table SET field = REPLACE(field, CAST(_latin1'ç' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'ç');
UPDATE table SET field = REPLACE(field, CAST(_latin1'ë' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'ë');
UPDATE table SET field = REPLACE(field, CAST(_latin1'ô' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'ô');
UPDATE table SET field = REPLACE(field, CAST(_latin1'â' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin, 'â');
UPDATE table SET field = REPLACE(field, CAST(_latin1
@Shagshag
Shagshag / rotateFTP.sh
Created November 15, 2017 15:11
Delete files older than X days on FTP. use curlftpfs
#!/bin/bash
ftpuser="x"
ftppass="x"
ftpsite="x"
ndays=10
# https://stackoverflow.com/a/34676160/2530962
# the directory of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
<?php
class BackupDatabaseCronModuleFrontController extends ModuleFrontController
{
public function init()
{
$this->module->cron();
die();
}
}
<?php
/**
* Add Shipping Number module
*
* @category Prestashop
* @category Module
* @author Samdha <contact@samdha.net>
* @copyright Samdha
* @license commercial license see license.txt
*
<?php
/**
* Ajax entry
*
* @category Prestashop
* @category Module
* @author Samdha <contact@samdha.net>
* @copyright Samdha
* @license commercial license see license.txt
*/
@Shagshag
Shagshag / AdminController.php
Created July 7, 2016 08:32
backward_compatibility with currentIndex
<?php
/**
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@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'])
<?php
/**
* idem than base64_encode()
*/
function mybase64_encode($to_encode)
{
$base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
$encoded = '';
$padding = '';
<?php
$file_content = '<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to http://doc.prestashop.com/display/PS15/Overriding+default+behaviors
* #Overridingdefaultbehaviors-Overridingamodule%27sbehavior for more information.
<?php
header('Content-Type: application/json');
$id_product = (int)$_GET['id_product'];
if (!$id_product)
{
$result = array(
'status' => 'fail',
'data' => array(
'id_product' => 'id_product is required'