Skip to content

Instantly share code, notes, and snippets.

View ToX82's full-sized avatar

Emanuele "ToX" Toscano ToX82

View GitHub Profile
@ToX82
ToX82 / phpswitch.sh
Last active July 7, 2020 01:11
A simple script that helps you choose which PHP version should be active - apache version
#!/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 / obfuscator.php
Created May 8, 2020 13:41
Reversible ID obfuscator - without any libraries
/**
* 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 11:03
A simple script that captures the browser's JavaScript errors and send them to a server
<?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 / access_dump.sh
Created April 3, 2020 13:30
A quick script that converts a Ms Access database to sql insert files
#!/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 February 13, 2018 09:56
Just one shell command to install wordpress and a few plugins
#!/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 February 13, 2018 09:49
In a folder containing multiple wordpress installations, it cycles all of the websites and updates core, plugins and themes
#!/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 00:31
pre-push GIT Hook - upload project to remote server through SSH, update Database
#!/bin/sh
##############
## CONFIGURATION
##############
# remote access
sshUser=""
sshPass=""