Created
July 18, 2012 23:06
-
-
Save jacquesbh/3139595 to your computer and use it in GitHub Desktop.
Script for change admin password
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 | |
declare(ticks = 1); | |
// Mage ! | |
require_once __DIR__ . '/../app/Mage.php'; | |
// Usage function :) | |
function usage() | |
{ | |
echo "Usage: php -f " . basename(__FILE__) . " <username>\n"; | |
exit(65); | |
} | |
// Check command line | |
if ($argc != 2) { | |
usage(); | |
} | |
// Init Magento | |
Mage::app('admin'); | |
// Init store (needed for save products for example) | |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
// We get the user | |
$user = Mage::getModel('admin/user')->load($argv[1], 'username'); | |
// User exists? | |
if (!$user->getId()) { | |
echo "Bad username.\n\n"; | |
usage(); | |
} | |
// We ask for the password | |
do { | |
$password = trim(readline('Wich password?')); | |
} while (!$password); | |
// We change the user password :) | |
$user->setNewPassword($password)->save(); | |
echo "User updated\n"; | |
exit(0); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment