Created
June 21, 2011 11:55
-
-
Save pkdavies/1037701 to your computer and use it in GitHub Desktop.
Emergency Joomla password reset
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 | |
$mysql_host = "localhost"; | |
$mysql_user = ""; | |
$mysql_password = ""; | |
$mysql_db = ""; | |
$user = "admin"; | |
$pass = "qwerty"; | |
$pass_enc = md5($pass); | |
if (!$link = mysql_connect($mysql_host, $mysql_user, $mysql_password)) { | |
echo 'Could not connect to mysql server'; | |
exit; | |
} | |
if (!mysql_select_db($mysql_db, $link)) { | |
echo 'Could not select joomla database'; | |
exit; | |
} | |
$sql = 'SELECT * FROM jos_users'; | |
$result = mysql_query($sql, $link); | |
if (!$result) { | |
echo "DB Error, could not query the database\n"; | |
echo 'MySQL Error: ' . mysql_error(); | |
exit; | |
} | |
while ($row = mysql_fetch_assoc($result)) { | |
echo "<pre>"; | |
print_r($row); | |
echo "</pre><hr />"; | |
} | |
$sql = "SELECT * FROM jos_users WHERE username='".$user."'"; | |
$result2 = mysql_query($sql, $link); | |
if (!$result2) { | |
echo "DB Error, could not query the database\n"; | |
echo 'MySQL Error: ' . mysql_error(); | |
exit; | |
} | |
while ($row = mysql_fetch_assoc($result2)) { | |
$result3 = mysql_query("UPDATE jos_users SET password='".$pass_enc."' WHERE username='".$user."'"); | |
if (!$result3) { | |
echo "DB Error, could not query the database\n"; | |
echo 'MySQL Error: ' . mysql_error(); | |
exit; | |
} else { | |
echo $row['name']." password updated to: ".$pass." (".$pass_enc.")"; | |
} | |
} | |
mysql_free_result($result); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment