Last active
April 17, 2023 03:06
-
-
Save debloper/b0d96f5fcf4a186339d7acd3779a70d4 to your computer and use it in GitHub Desktop.
Update/reset mediawiki password for a user directly in SQLite DB without SUDO (NFSN/nearlyfreespeech.net edge case)
This file contains hidden or 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 | |
// Replace <DB> with actual DB name | |
$db = new PDO("sqlite:/path/to/<DB>.sqlite") or die("cannot open the database"); | |
// The WHERE clause excludes internal users; feel free to filter it any way you want | |
$query = $db->query("SELECT * FROM user WHERE user_email <> '';"); | |
// Get the column names; unfortunately this is the simplest way | |
$meta = ""; | |
for ($i=0; $i<=7; $i++) { $meta = $meta . "\n" . $query->getColumnMeta($i)["name"]; } | |
echo "<pre>".$meta."</pre>"; | |
// Format & list the query results | |
foreach($query as $row) { echo "<pre>".implode("\n", $row)."</pre>"; } | |
// Close DB connection | |
$db = null; | |
?> |
This file contains hidden or 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 | |
// Replace <DB> with actual DB name | |
$db = new PDO("sqlite:/path/to/<DB>.sqlite") or die("cannot open the database"); | |
// Replace <SET_KNOWN_HASH> & <USER_EMAIL> with actual values | |
$query = $db->query("UPDATE user SET user_password = '<SET_KNOWN_HASH>', user_newpassword = '', user_newpass_time = '' WHERE user_email = '<USER_EMAIL>';"); | |
// Close DB connection | |
$db = null; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment