Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimír Smitka lynt-smitka

View GitHub Profile
View .htaccess examples
#Do not copy&paste whole file, find only interesting parts!
#HTTP authentification
AuthType Basic
AuthName "Log in"
AuthUserFile /path/to/.htpasswd
Require valid-user
#Security headers
View gist:252bbbd51006714ce0b3f4fe9892fd93
add_filter( 'wp_image_editors', 'lynt_wp_image_editors' );
function lynt_wp_image_editors( $editors ) {
//return array( 'WP_Image_Editor_GD' ); //only GD
//return array( 'WP_Image_Editor_Imagick' ); //only Imagick
}
@lynt-smitka
lynt-smitka / fbclid-nginx.conf
Last active Mar 30, 2021
Remove fbclid argument from the URL in Nginx
View fbclid-nginx.conf
http {
...
# redirect map in http block - remove fbclid argument from the end
map $request_uri $redirect_fbclid {
"~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1;
}
...
@lynt-smitka
lynt-smitka / fbclid.htaccess
Last active Mar 12, 2021
Remove fbclid argument from the URL in .htaccess
View fbclid.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*?)(&?fbclid=[a-zA-Z0-9_-]+)$
RewriteRule ^(.*)$ /$1?%1 [L,NE,R=301]
</IfModule>
@lynt-smitka
lynt-smitka / wp-config-part-1-show.php
Last active Mar 9, 2021
Display/Log WordPress errors
View wp-config-part-1-show.php
define( 'WP_DEBUG', true );
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );
@lynt-smitka
lynt-smitka / 1-common.txt
Last active Feb 25, 2021
Dir buster lists
View 1-common.txt
info.php
phpinfo.php
php_info.php
php-info.php
i.php
test.php
debug.php
admin.php
administrace.php
administration.php
@lynt-smitka
lynt-smitka / .htaccess
Last active Feb 17, 2021
Block hidden files except .well-known - Apache .htaccess + Nginx
View .htaccess
RewriteRule "(^|/)\.(?!well-known\/)" - [F]
View path.php
<?php
echo realpath(__FILE__);
@lynt-smitka
lynt-smitka / lynt-admin.php
Created Nov 18, 2020
WordPress - login as admin user
View lynt-admin.php
<?php
/**
* Plugin Name: Lynt Admin
* Author: Vladimir Smitka
* Author URI: https://lynt.cz/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) or die( 'nothing here' );
@lynt-smitka
lynt-smitka / remove_sensitiver_rest.php
Last active Nov 4, 2020
Remove sensitive user's data from the REST API response in WP
View remove_sensitiver_rest.php
//Remove sensitive data from REST API
function lynt_remove_sensitive_data_from_rest( $response ) {
if(!current_user_can('list_users')){
//get WP_REST_Response
$data = $response->get_data();
//unset sensitive fields
if(preg_replace('/[\W]+/', '',$data['name']) == preg_replace('/[\W]+/', '',$data['slug'])) $data['name']="Author";
unset($data['link']);