Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created July 18, 2012 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacquesbh/3139595 to your computer and use it in GitHub Desktop.
Save jacquesbh/3139595 to your computer and use it in GitHub Desktop.
Script for change admin password
<?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