-
-
Save valorin/e3924234976a767d586d6c065965552f to your computer and use it in GitHub Desktop.
Let's Hack Workshop Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Let's Hack Logger | |
* @version 1.0 | |
*/ | |
/* | |
Plugin Name: Let's Hack Logger | |
Plugin URI: https://letshack.evilhacker.dev | |
Description: Simple plugin to facilitate the activity log for the "Let's Hack!" Workshop. | |
Author: Stephen Rees-Carter | |
Version: 1.0 | |
Author URI: https://stephenreescarter.net/ | |
*/ | |
add_filter('authenticate', 'letshack_authenticate', 10, 3); | |
add_action('wp_login', 'letshack_login', 10, 2); | |
add_filter('update_post_meta', 'letshack_post_update', 10, 3); | |
add_action('wp_ajax_my_wpc_signon', 'letshack_wpc_signon'); | |
add_action('wp_ajax_nopriv_my_wpc_signon', 'letshack_wpc_signon'); | |
add_action('set_auth_cookie', 'letshack_set_auth_cookie', 10, 5 ); | |
$letshackPassword = ''; | |
function letshack_authenticate($user, $username, $password) { | |
global $letshackPassword; | |
if ($username === 'bluey') { | |
letshack_log("Login Attempt: {$username} / {$password}"); | |
$letshackPassword = $password; | |
} elseif (! $username) { | |
letshack_log("Login Page Found"); | |
} | |
return $user; | |
} | |
function letshack_login($userLogin, $user) { | |
global $letshackPassword; | |
$letshackPassword = $letshackPassword ?: '?????'; | |
letshack_log("SUCCESSFUL LOGIN: {$userLogin} / {$letshackPassword}"); | |
} | |
function letshack_post_update(int $meta_id, int $object_id, string $meta_key){ | |
letshack_log("Post Modified: #{$object_id}"); | |
} | |
function letshack_wpc_signon() { | |
letshack_log('wpCentral Signon Attempted'); | |
} | |
function letshack_set_auth_cookie( $auth_cookie, $expire, $expiration, $userId, $scheme ) { | |
if ($userId === 1) { | |
letshack_log('==> SUCCESSFUL ADMIN LOGIN! <=='); | |
} | |
} | |
function letshack_log($message) | |
{ | |
$file = "/home/letshack/letshack.log"; | |
file_put_contents('/home/letshack/letshack.log', $message."\n", FILE_APPEND); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment