Skip to content

Instantly share code, notes, and snippets.

Avatar

Emanuele "ToX" Toscano ToX82

View GitHub Profile
@ToX82
ToX82 / obfuscator.php
Created May 8, 2020
Reversible ID obfuscator - without any libraries
View obfuscator.php
/**
* These two functions takes an integer (with some optional salt) and converts it to an alphanumeric string
* It's super easy to use, and it's useful if you want to "hide" the original ID - or at least make it not obvious
*
* WARNING: It's not a security tool! Actually, it's far from being secure. It's just an obfuscator
*
*
* Usage:
*
* $id = 53; // The data you want to encode
@ToX82
ToX82 / javascript-logger.php
Created May 3, 2020
A simple script that captures the browser's JavaScript errors and send them to a server
View javascript-logger.php
<?php
// Pt. 1) This is the server side part. We read the error (see pt. 2) and write it down using error_log
if (!empty($_POST)) {
$errorData = $_POST;
$error = " Error: " . $errorData['url'];
if ($errorData['error'] !== '') {
$error .= "<br><br>" . $errorData['error'];
}
if ($errorData['msg'] !== '') {
@ToX82
ToX82 / phpswitch.sh
Last active Jul 7, 2020
A simple script that helps you choose which PHP version should be active - apache version
View phpswitch.sh
#!/bin/bash
color_off='\033[0m' # Text Reset
color_green='\033[1;32m' # Green text
versions=(/usr/bin/php*)
mapfile -t versions < <(printf '%s\n' "${versions[@]}" | egrep '[0-9]+\.[0-9]+' | cut -c 13-)
counter=0
if [ $# -eq 0 ]; then
@ToX82
ToX82 / access_dump.sh
Created Apr 3, 2020
A quick script that converts a Ms Access database to sql insert files
View access_dump.sh
#!/bin/bash
if [ -z "$1" ]
then
echo "You need to specify the database file. Eg.: ./access_dump.sh my-database.mdb"
echo ""
echo "Please make sure that you have mdbtools installed on your system: 'sudo apt install mdbtools'"
exit 1
fi
DB="$1"
@ToX82
ToX82 / wordpress-installer.sh
Created Feb 13, 2018
Just one shell command to install wordpress and a few plugins
View wordpress-installer.sh
#!/bin/bash
# Please note that this script downloads the italian localization of wordpress.
# Please check on line 21 if this doesn't suit you.
if [ $# -eq 0 ]; then
echo "You didn't specify in which directory you want wordpress to be installed!"
exit 1
fi
cd $1
@ToX82
ToX82 / batch-wordpress-updater.sh
Created Feb 13, 2018
In a folder containing multiple wordpress installations, it cycles all of the websites and updates core, plugins and themes
View batch-wordpress-updater.sh
#!/bin/bash
echo "Updating wp-cli to its latest version..."
sudo wp cli update
echo ""
for d in */ ; do
user=$(stat -c '%U' $d)
echo ""
echo "Entering $d with user $user..."
@ToX82
ToX82 / pre-push
Last active May 14, 2017
pre-push GIT Hook - upload project to remote server through SSH, update Database
View pre-push
#!/bin/sh
##############
## CONFIGURATION
##############
# remote access
sshUser=""
sshPass=""