Skip to content

Instantly share code, notes, and snippets.

View lukapaunovic's full-sized avatar
🎯
Focusing

Luka Paunović lukapaunovic

🎯
Focusing
  • Serbia
  • 00:09 (UTC +01:00)
View GitHub Profile
<?php
// If Woo thinks payment is not required (total = 0), recalculate and force needs_payment = true.
add_filter( 'woocommerce_order_needs_payment', function( $needs_payment, $order ) {
if ( $needs_payment || ! $order instanceof WC_Order ) {
return $needs_payment;
}
if ( 0 === count( $order->get_items( 'line_item' ) ) ) {
return $needs_payment;
}
<?php
// Checkout snapshot: billing/shipping, payment, IP, user agent, shipping lines.
add_action( 'woocommerce_checkout_create_order', function( WC_Order $order, $data ) {
$shipping_lines = array();
foreach ( $order->get_shipping_methods() as $item ) {
$shipping_lines[] = array(
'method_id' => $item->get_method_id(),
'instance_id' => $item->get_instance_id(),
'name' => $item->get_name(),
'total' => $item->get_total(),
#!/usr/bin/env bash
# kill_foreign_sessions.sh
# Kills session leader PIDs from `who -u` whose remote IP is not the allowed IP.
# DEFAULT: dry-run mode. Set DRY_RUN=0 to actually kill.
#
# Usage:
# DRY_RUN=1 sudo /usr/local/bin/kill_foreign_sessions.sh # just show what WOULD be killed
# DRY_RUN=0 sudo /usr/local/bin/kill_foreign_sessions.sh # perform kills
ALLOWED_IP="91.150.72.133"
<?php
/*
Plugin Name: Disable WP Rocket SaaS Deletion
Description: Prevent WP Rocket from deleting SaaS-generated assets.
Author: Luka
*/
# Remove Notices
add_filter( 'rocket_dismiss_notice', '__return_true' );
# Do not automatically delete RUCSS
<?php
/**
* Plugin Name: WP Rocket | Ignore Query Strings
* Description: Define query strings that should use the same set of cache.
* Plugin URI: https://github.com/wp-media/wp-rocket-helpers/cache/wp-rocket-cache-ignore-query-strings
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@lukapaunovic
lukapaunovic / gist:d8b072ec475e54da62c21204dcb8bbb0
Created October 28, 2025 09:05
Block Facebook Ads Idiotism
Ovo ide u server { } blok sajta:
if ($block_preview_ajax) { return 403; }
location = /wp-admin/admin-ajax.php {
if ($is_preview_bot) { return 403; }
proxy_pass https://79.101.60.115:8443;
}
location = /wp-content/plugins/translatepress-business/add-ons-pro/automatic-language-detection/includes/trp-ald-ajax.php {
if ($is_preview_bot) { return 403; }
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# Nginx log → IP agregacija → Team Cymru IP→ASN (bulk, netcat) → izveštaj
# - IPv4 i IPv6 podrška (posebne bulk sesije)
# - Brz join (AWK mapa) umesto grep u petlji
# - MIN_REQS filter za TOP IP ispis
# - Keš CSV sa flock zaključavanjem (+ opcioni age keš)
# - Retry + exponential backoff za bulk upite
<?php
/**
* WHMCS Hook - Sakrivanje Payment Gateway-a na osnovu valute
* Autor: Luka @ dcx.rs
* Ovaj hook sakriva:
* - PayPal PPCP (paypal_ppcpv) za RSD valutu
* - Bank Transfer (banktransfer) za USD valutu
*/
use WHMCS\Database\Capsule;
smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/exim4/virtual/helo_data}{$value}}
...
remote_smtp:
driver = smtp
interface = ${lookup{$sender_address_domain}lsearch{/etc/exim4/virtual/interfaces}{$value}}
helo_data = ${lookup{$sender_address_domain}lsearch*@{/etc/exim4/virtual/helo_domains}{$value}}
root@my-vps:/var/log/exim4# cat /etc/exim4/virtual/helo_domains
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDtYAMj6ZcTAsgLCgHz2TnAl0lbyq/iU3msaXJaT7PfSVQYX8qQZ5tmycumEvwkgHG0bKxF6tmjuNYkSN4jWQX8McPllneDHoEwlw7nyx9lv05PsL+qziG/4MR81lETowvBbvhXN82MnbmjlV7eGuM3eyDL5v5JGxKBsPtNHTsXXfy9h5CIBLQBFbRHX9glGV/gs3wSdiw/iRAsFJ+g4YQCfdzPURwYis8shmKHeotUirlLURa7Q6PctnkTJ3sTA52aKy/3zgPtFj29Ky58yOqN/v1KIy1iBbhEzIXk7RhFN6QDsGrirL2uwBgGIOgFjg2+D2Pa8JbNLQ8KazH9qomH luka@paunovic