Editing Mediawiki/Anonymous IP Hash
From Bibliotheca Anonoma
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Here's the gist of my anon ID hack to MediaWiki. I can't really package it as an extension or anything because it involves hacking things that | Here's the gist of my anon ID hack to MediaWiki. I can't really package it as an extension or anything because it involves hacking things that | ||
apparently aren't supposed to be hacked, but it's not hard to do. - Halcy | apparently aren't supposed to be hacked, but it's not hard to do. - Halcy | ||
1. Add the following to your LocalSettings.php: | 1. Add the following to your LocalSettings.php: | ||
Line 20: | Line 8: | ||
// likely end up with useless crud after IDs expire | // likely end up with useless crud after IDs expire | ||
$wgDisableAnonTalk = true; | $wgDisableAnonTalk = true; | ||
function AnonUsername( | function AnonUsername() { | ||
$key = wfGetIP().'PUT RANDOM TEXT HERE'; | |||
# Alternatively, you can use this function to further anonymize, but it makes it harder to ban: dmY = new ID per day, WY = per week. | |||
#$key = wfGetIP().'PUT RANDOM TEXT HERE'.gmdate('dmY'); | |||
return 'ID:'.substr(crypt(md5($key), 'id'), 2, 8); | |||
} | } | ||
</pre> | </pre> | ||
{{Warning|Consider using something better than md5, such as sha1 for same performance, or bcrypt for reduced brute force.}} | |||
{{ | |||
{{ | {{Note|Obviously you'd change the "PUT RANDOM TEXT HERE" to some random text: this functions as the salt and reduces the risk of brute force attacks. Just bang on the keyboard for a bit, or if you want to be truly random, get an RNG or just roll some dice.}} | ||
2. In <code>includes/user/User.php</code>, (Mediawiki 1.27.1: getName() Line 2109) find the line that says: | 2. In <code>includes/user/User.php</code>, (Mediawiki 1.27.1: getName() Line 2109) find the line that says: | ||
Line 46: | Line 26: | ||
and change it to: | and change it to: | ||
$this->mName = AnonUsername( | $this->mName = AnonUsername(); | ||
3. In <code>includes/user/User.php</code>, (Mediawiki 1.27.1: getBlockedStatus() Line 1600) find the line that says: | 3. In <code>includes/user/User.php</code>, (Mediawiki 1.27.1: getBlockedStatus() Line 1600) find the line that says: | ||
Line 54: | Line 34: | ||
and change it to: | and change it to: | ||
: AnonUsername( | : AnonUsername(); | ||
You will need to repeat this mod whenever you update MediaWiki, since obviously an update replaces the system files. And of course the lines may vary, but have generally been similar. | You will need to repeat this mod whenever you update MediaWiki, since obviously an update replaces the system files. And of course the lines may vary, but have generally been similar. |