Skip to content

Instantly share code, notes, and snippets.

View beatwiz's full-sized avatar
🥶
#crunching

Gustavo Silva beatwiz

🥶
#crunching
View GitHub Profile
@beatwiz
beatwiz / wp-featured-image-upload-for-front-end.php
Created January 23, 2017 00:12 — forked from juyal-ahmed/wp-featured-image-upload-for-front-end.php
Upload featured image on custom post from WordPress front-end
@beatwiz
beatwiz / cleartrash.sh
Last active April 22, 2022 12:13
[bash] cPanel / WHM Cron bash script to delete all accounts > domains > users, trash / spam / junk emails with more than 30 days
#!/bin/bash
# All users from all domains from all accounts in /home
MAILDIRS=$(find /home/*/mail/ -type d)
# Only .Trash .Junk .Spam folders
INBOXFOLDERS=(.Trash .Junk .spam)
for basedir in $MAILDIRS; do
for ((i = 0; i < ${#INBOXFOLDERS[*]}; i++)); do
# Only cur and new folders
for dir in cur new; do
# Only if the full path to the folder exists
@beatwiz
beatwiz / functions.php
Last active March 22, 2018 16:11
[wordpress] Add login/logout link to wordpress menu based on user login status
<?php
// ADD LOGIN / LOGOUT FUNCTION TO MENU
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
ob_start();
wp_loginout('index.php');
$loginoutlink = ob_get_contents();
ob_end_clean();
$items .= '<li>'. $loginoutlink .'</li>'; return $items;
}
@beatwiz
beatwiz / functions.php
Last active March 22, 2018 16:09
[wordpress] Block all users except admin (and ajax requests) from dashboard / wp-login
<?php
//BLOCK USERS EXCEPT ADMIN FROM DASHBOARD / WP-LOGIN
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
@beatwiz
beatwiz / functions.php
Last active March 22, 2018 16:11
[wordpress] Disable wordpress top bar for all users except admin
<?php
//DISABLE TOP BAR FOR ALL USERS EXCEPT ADMIN
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
@beatwiz
beatwiz / as_list.txt
Created January 25, 2017 22:15
Lista de AS´s (Autonomous System)
# Lista de AS´s (Autonomous System)
# Gamas de IP servidores / ISP / networking nacionais
# Obtido em: http://www.zon.pt/Internet/Detalhe.aspx?detail=XzU29K
Allow from 193.64.0.0/24
Allow from 195.245.234.0/24
Allow from 194.140.238.0/24
Allow from 84.39.0.0/16
Allow from 195.95.236.0/23
Allow from 193.16.103.0/24
@beatwiz
beatwiz / badbots.conf
Created January 25, 2017 22:15
List of Badbots
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
<ifModule mod_rewrite.c>
# mod rewrite redirects
RewriteEngine On
# LIST1 provided by hackers
@beatwiz
beatwiz / checkhax.sh
Created January 25, 2017 22:17
Scan for hax0rs
egrep -R -l '$OOO0O0O00|r0nin|m0rtix|r57shell|c99shell|phpshell|void\.ru|phpremoteview|directmail|bash_history|\.ru/|brute *force|MultiViews|cwings|bitchx|eggdrop|guardservices|psyBNC|DALnet|CASPER|RFI|CRACK|casper|rfi|crack|scanner' /home/sites/*/web | grep .php | grep -v phpThumb | grep -v index.php | grep -v admin. | grep -v lang_ >> /root/scripts/hax.txt
@beatwiz
beatwiz / validip.sh
Created January 25, 2017 22:18
[shell] validate IP address
#! /bin/bash
# Test an IP address for validity:
# Usage:
# valid_ip IP_ADDRESS
# if [[ $? -eq 0 ]]; then echo good; else echo bad; fi
# OR
# if valid_ip IP_ADDRESS; then echo good; else echo bad; fi
#
function valid_ip()
{
@beatwiz
beatwiz / dfix.conf
Created January 25, 2017 22:19
le good old dfix conf
#
# DFIX Configuration File.
#
# Dovecot Process limits
#
# When the number of Dovecot processes exceeds the MAX value, dfix will stop dovecot until the number of processes
# drops beliw the MIN value.
MIN=10
MAX=50