Community Forums

Open Cart Administrator Password Reset tool

Community created contributions & mods for OpenCart 1.x

Open Cart Administrator Password Reset tool

Postby JAY6390 » Mon Jun 07, 2010 7:39 pm

Want something similar in a vQmod? Check this thread out

After seeing a thread earlier asking how to reset their admin password I thought I'd create a little app that hopefully will be useful when people get stuck. It's taken from my Wordpress admin reset file I made a while back, with just a few tweaks to allow resetting OC passwords - It's actually taken me more time to write this post than to code it :D

Instructions for use
1. Either download the file here or copy the source code below and save it to a file called ocreset.php in your store's directory (The same one as the .htaccess/.htaccess.txt file)
2. Run the file through your browser by visiting your site's store address followed by ocreset.php, so for a localhost in a directory called shop it would be
Code: Select all
http://localhost/shop/ocreset.php
- for your domain in the root directory just use
Code: Select all
http://www.yoursite.com/ocreset.php

3. You should now see a screen with the following on it, and in the dropdown should be a list of your site administrators
Image
4. Select your administrator name you want to reset, type your password in the password field and click "Change Password"
5. If all went well a message should appear at the top of the screen with
Code: Select all
User `admin` updated successfully!
where admin is the name of the user you've just reset
6. Once you've reset your password MAKE SURE YOU DELETE THE OCRESET.PHP FILE from your server, to avoid anyone gaining unauthorised access to your store


For those interested, here's the source code with commenting. If anyone has any suggestions for improvement or bugs please let me know

Code: Select all
<?php
// Load config
include('config.php');

// Connect to database
mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die('ERROR CONNECTING TO SERVER');
mysql_select_db(DB_DATABASE) or die('ERROR SELECTING TABLE');

// Get list of active adminstrators
$query = "SELECT user_id, username FROM ".DB_PREFIX."user WHERE user_group_id = '1' AND status = '1'";
$result = mysql_query($query);
if(!
$result) {
    echo 'ERROR WITH QUERY: '.mysql_error().'<br />';
    die($query);
}
while(
$r = mysql_fetch_assoc($result)) {
    $users[$r['user_id']] = $r['username'];
}

// Form has been submitted
if(isset($_POST['ID'])) {
    // Clean up password field and make sure it has a value
    $pass = trim($_POST['password']);
    if($pass == '') {
        $info = 'ERROR: Password needed in order to reset';
    }else{
        // Update the table with the new information
        $query = sprintf("UPDATE ".DB_PREFIX."user SET password = '%s' WHERE user_id = '%s'", md5($pass), mysql_real_escape_string($_POST['ID']));
        $result = mysql_query($query);
        if(!$result) {
            $info = 'Could not update the database<br />'.mysql_error();
        }else{
            $info = 'User `'.$users[$_POST['ID']].'` updated successfully!';
        }
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Open Cart administrator password reset</title>
<style type="text/css">
<!--
body {font-family: Verdana, Arial, Helvetica, sans-serif; background: #438AB7; color: #ffffff; font-size: 10px;}
.lbl {display: block; text-align: center; width: 200px; font-weight: bold;}
.input {width: 200px;}
.info { border: 2px solid #2B5775; padding: 3px; font-size: 16px; font-weight: bold; text-align: center;}
-->
</style>
</head>

<body>
<?php
if(isset($info)) {
    echo "<div class=\"info\">$info</div>";
}
?>
<h1>Open Cart administrator password reset</h1>
<form id="frmReset" method="post" action="">
  <fieldset style="border: none;">
    <label for="ID" class="lbl">Administrator to reset: </label>
    <select name="ID" id="ID" class="input">
      <?php foreach($users as $id => $username): ?>
      <option value="<?php echo $id; ?>"><?php echo $username; ?></option>
      <?php endforeach; ?>
    </select>
    <label for="password" class="lbl">New password: </label>
    <input type="text" name="password" id="password" class="input" />
  <br />
  <br />
  <input class="lbl" type="submit" name="button" id="button" value="Change password"/>
  </fieldset>
</form>
</body>
</html>
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby cmebd » Tue Jun 08, 2010 12:56 am

%hanks for this - a brilliant "admin" helper........ ;)
A stupid question is the one you -don't- ask.........(Anon)

)C1.5.0.1 (IN devel)
OC V1.4.9.5
OC V1.4.9.2
OC V1.4.7
OC V1.3.4
User avatar
cmebd
 
Posts: 403
Joined: Thu Nov 12, 2009 10:17 pm
Location: Tasmania, Australia

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Tue Jun 08, 2010 5:06 am

No problem :)
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby Moggin » Tue Jun 08, 2010 12:20 pm

Many thanks JAY6390. Great app, which will solve something very high up on my worry list..
Cheers
Moggin
 
Posts: 1079
Joined: Tue May 04, 2010 3:56 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Tue Jun 08, 2010 2:10 pm

No problem. I will be adding more once 1.4.8 is released that will be useful for installing modules more easily (if everything goes to plan), and I have another idea or two up my sleeves yet :)
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby clairekw » Fri Jul 02, 2010 3:22 pm

THANK YOU!!!!!!!

YOU SAVED MY LIFE

I AM NOT TECHY BUT I COULD FOLLOW THE INSTRUCTIONS - OLISH YOUR HALO!!! ;) :D :)
clairekw
 
Posts: 15
Joined: Fri Jun 25, 2010 3:09 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Fri Jul 02, 2010 3:36 pm

haha no problem :)
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby qahar » Sat Jul 03, 2010 7:20 am

interesting stuff.. nice work..
My product: Opencart Blog Manager Free System Information OpenCart Shortcodes
OpencartNews - News, Tutorial n Tips - Common OpenCart Errors and How to Solve Them
Don't forget to add [SOLVED] to your Thread Title (first post), if your issue is solved.
User avatar
qahar
 
Posts: 1775
Joined: Tue Jun 29, 2010 9:24 am
Location: Indonesia

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Sat Jul 03, 2010 5:15 pm

No problem :) Glad it helped you!
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby JCO » Wed Nov 10, 2010 10:46 pm

Whooooooo! Thanks Jay ... I just used it!!!!!!!! ;D
User avatar
JCO
 
Posts: 22
Joined: Wed Nov 10, 2010 10:39 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Thu Nov 11, 2010 5:46 am

lol no problem
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby ilovekhym » Sun Nov 21, 2010 8:23 pm

Hello Guys,

I just created and submitted the script for this. You can check it here
http://www.opencart.com/index.php?route ... ion_id=879

I will upload a demo site for this later.
ilovekhym
 
Posts: 4
Joined: Sun Nov 21, 2010 7:57 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Sun Nov 21, 2010 9:28 pm

lol you didn't create a script fro this, you created a PAID module to allow people to reset their admin passwords from the admin login. big difference tbh
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby ilovekhym » Mon Nov 22, 2010 8:08 pm

@JAY6390 - Hello, Yes its paid and i decide to make it paid since its easy to use and is already attached to the admins interface and on the users database. you can visit the extension page and try it yourself. I already put a demo site and test account/email for that. anyway, thanks for the feedback. :)
ilovekhym
 
Posts: 4
Joined: Sun Nov 21, 2010 7:57 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Mon Nov 22, 2010 8:21 pm

It wasn't feedback, I was pointing out that you were spamming the forum. I'm well aware of the way the extension works and how, I just don't see how it's pertinent to this thread to be honest. Your extension is fine I'm sure, and should probably be part of the core
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby FxMan » Tue Nov 23, 2010 2:12 am

Very sweet tool Jay.
Thanks.
FxMan
 
Posts: 39
Joined: Thu May 14, 2009 6:18 pm

Re: Open Cart Administrator Password Reset tool

Postby JAY6390 » Tue Nov 23, 2010 6:29 am

No problem FxMan :)
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4892
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Open Cart Administrator Password Reset tool

Postby rebecca » Wed Nov 24, 2010 3:01 am

Thanks!! You're a star!
rebecca
 
Posts: 26
Joined: Thu Jul 15, 2010 8:54 am

Re: Open Cart Administrator Password Reset tool

Postby ilovekhym » Fri Dec 03, 2010 4:59 am

@jay - im not spamming the forum cause i only post only on the topics that is related on my extension.
ilovekhym
 
Posts: 4
Joined: Sun Nov 21, 2010 7:57 pm

Re: Open Cart Administrator Password Reset tool

Postby Meiershus » Tue Jan 18, 2011 2:55 pm

thank you so much. works perfectly:-) :banana:
User avatar
Meiershus
 
Posts: 5
Joined: Tue Jan 18, 2011 2:44 pm

Next

Return to Free Contributions

Who is online

Users browsing this forum: No registered users and 19 guests

Hosted by Arvixe Web Hosting