bloqhead
8/13/2014 - 3:58 PM

Generate SQL for new opencart admin user

Generate SQL for new opencart admin user

<?php

$prefix = 'oc_';
$new_password = 'whatever';
$new_username = 'admin';
$new_email = 'yours@example.com';

$salt = substr(md5(uniqid(rand(),true)), 0, 9);
$password = sha1($salt . sha1($salt . sha1($new_password)));

$sql = "DELETE FROM `{$prefix}user` WHERE `user_id` = '1';\n";
$sql .= "INSERT INTO `{$prefix}user` 
	SET `user_id` = '1', 
		`user_group_id` = '1', 
		`username` = '{$new_username}', 
		`salt` = '{$salt}', 
		`password` = '{$password}', 
		`status` = '1', 
		`email` = '{$new_email}', 
		`date_added` = NOW();";

echo $sql;