Sunday, July 4, 2010

Prestashop: "Your firstname contains some invalid character"

"Your firstname contains some invalid character"
"Cannot do step 4 in installing Prestashop"
"No admin user created for prestashop"
"table employee empty or no records"

Yup... all this error occurred when i try to installed PrestaShop.. even tho i download the fresh installer of this CMS from their own website.. its really a big bug.. took me a whole day to resolve this..

This script make a new admin-account so you can access “back office”.

Remember to delete this script after you have used it. Just a emergncy-tool.
Upload it to your back-office folder..

Hope this can help anyone here..


<?php
// This script add a new admin-account
// Delete this script from server after
// you have used it.
// Warning Very Big security-risk!!
// Upload it to your secret Back Office folder.
// Best regards KIH999

define('PS_ADMIN_DIR', getcwd());
include(PS_ADMIN_DIR.'/../config/config.inc.php');
include(PS_ADMIN_DIR.'/functions.php');

?>
<form name="formdata" action="newadmin.php">
<p><h1>Make a new admin account</h1></p><br>
<p>Remember long password (min 8 char long)</p>
<input type="hidden" name="key" value="OK" />
<table>
<tr>
<td>FirstName:</td>
<td><input type="text" name="firstname" value="" size="30" /></td>
</tr>
<tr>
<td>LastName:</td>
<td><input type="text" name="lastname" value="" size="30" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" value="" size="30" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="password" value="" size="30" /></td>
</tr>
</table>
<input type="submit" value="Send" name="send" />
</form>
<?php

if ($_GET['key']=="OK") {

$delim =' , ';
$query = 'INSERT INTO '._DB_PREFIX_.'employee (id_employee, lastname, firstname, email, passwd, last_passwd_gen, active, id_profile) VALUES';
$query.= ' (NULL'; //ID_emp
$query.=$delim;
$query.= '"'.pSQL($_GET['lastname']).'"'; //Last
$query.=$delim;
$query.= '"'.pSQL($_GET['firstname']).'"'; //First
$query.=$delim;
$query.= '"'.pSQL($_GET['email']).'"'; //Email
$query.=$delim;
$query.= '"'.md5(pSQL(_COOKIE_KEY_.$_GET['password'])).'"'; //Password
$query.=$delim;
$query.= '"'.date('Y-m-d h:i:s', strtotime('-360 minutes')).'"'; //Last_pass_gen
$query.=$delim;
$query.=' 1, 1)'; //active,id_profile
$dbInstance = Db::getInstance();
if(!$dbInstance->Execute($query))
$error['infosInsertSQL'] = '11';
unset($dbInstance);
}
?>

Or just free download here: newadmin.php

No comments: