Skip to content

Instantly share code, notes, and snippets.

View Sinepel's full-sized avatar

Constantin Boulanger Sinepel

View GitHub Profile
@Sinepel
Sinepel / openssl_encrypt_decrypt.php
Created August 2, 2019 14:13 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@Sinepel
Sinepel / purge_cf.php
Created April 20, 2021 12:10 — forked from Greg-Boggs/purge_cf.php
PHP code to Purge Cloudflare Cache
<?php
// Replace EMAIL/API_KEY/ZONE_ID with your details.
// Zone ID is on the dashboard for the domain in the bottom right.
// Api keys are generated from the account settings. You must give cache purge permissions
// Place this script on your webserver and point a Github Webhook at it, and you'll clear
// the Cloudflare cache every time you do a push to GH.
try {
$head = [];
$head[] = 'Content-Type: application/json';
@Sinepel
Sinepel / function.php
Created November 22, 2021 20:34 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@Sinepel
Sinepel / HexSHA512.class.php
Created October 3, 2022 09:09 — forked from m-primo/HexSHA512.class.php
Hash & Verify - sha512 & hex.. php
final class HexSHA512 {
public static final function Hash($s) {
return (bin2hex(hash('sha512', $s.bin2hex($s), true)));
}
public static final function Verify($s, $h) {
return (HexSHA512::Hash($s) == $h);
}
}
$s = "hello there";
@Sinepel
Sinepel / tinygod-recover-roles.php
Created December 9, 2022 18:06 — forked from luistinygod/tinygod-recover-roles.php
WordPress Plugin: Restores all the default roles and caps in the WordPress
<?php
/**
* Recover or Reset the default WordPress user roles and caps
* Install it as a WordPress plugin, activate it and deativate. That's it.
*
* @wordpress-plugin
* Plugin Name: tinyGod Recover User Roles
* Plugin URI:
* Author: luistinygod
* Author URI: https://tinygod.pt
@Sinepel
Sinepel / functions.php
Created May 30, 2023 20:19 — forked from MwieMarin/functions.php
WordPress: Disable REST API User Enumeration
<?php
add_filter( 'rest_endpoints', function( $endpoints ){
if ( isset( $endpoints['/wp/v2/users'] ) ) {
unset( $endpoints['/wp/v2/users'] );
}
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
}
return $endpoints;
});