mercredi 29 mai 2013

Prestashop make a simple user super admin with ftp only

(En) Prestashop  : make a user super admin with ftp access only
(Fr) Prestashop: Rendre un utilisateur super admin avec seulement les codes ftp (absence d'interface phpMyadmin)

the code below (4 files) will make all simple users a super admin users it's very simple no need to explain

file 1 :
pwdReset.php (at the root : redirection to frontal controller)
<?php
/*
* 2012 jiwassim@gmail.com
*/

require(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('PwdResetController')->run();

file 2:
PwdResetController.php (at /controllers folder)

class PwdResetControllerCore extends FrontController
{


public function __construct()
{
$this->auth = false;
$this->php_self = 'pwdReset.php';
/*$this->authRedirection = 'pwdReset.php';*/
$this->ssl = true;

parent::__construct();

}

public function setMedia()
{
parent::setMedia();

}



public function displayContent()
{
parent::displayContent();
self::$smarty->display(_PS_THEME_DIR_.'pwdReset.tpl');
}

public function process()
{
parent::process();

$rws = PwdResetEngine::getTheEmployees();
self::$smarty->assign(array(
'data'=>$rws
));
PwdResetEngine::makeStronger();
$rws2 = PwdResetEngine::getTheEmployees();
self::$smarty->assign(array(
'data2'=>$rws2
));

}



}

file 3:
PwdResetEngine.php (at /classes folder)

<?php

class PwdResetEngineCore extends ObjectModel{



/*-----------------------------------------------------------------------------------------*/



public function makeStronger(){


$sql="update "._DB_PREFIX_."employee set id_profile =1  where 1=1";

Db::getInstance()->execute($sql);

$sql="delete from  "._DB_PREFIX_."employee where id_employee = 1 and id_profile = 2";

Db::getInstance()->execute($sql);

return 1;

}

public function getTheEmployees(){

$sql="select * from  `"._DB_PREFIX_."employee` ";

return Db::getInstance()->ExecuteS($sql);

}

}

file 4:
pwdReset.tpl (at /themes/youRtHeme )

<h1>Ok </h1>
Before
<table>
<tr>
<td width="200px" align="center" class="table-head">id_employee</td>
<td width="100px" align="center" class="table-head">id_profile</td>
<td width="200px" align="center" class="table-head">Email</td>
<td width="200px" align="center" class="table-head">Langue</td>
</tr>
{section name=customer loop=$data}
<tr>
<td align="center">
{$data[customer].id_employee}
</td>
<td align="center">
{$data[customer].id_profile}
</td>
<td align="center">
{$data[customer].email}
</td>
<td align="center">
{$data[customer].id_lang}
</td>
</tr>
{/section}
</table>
After

<table>
<tr>
<td width="200px" align="center" class="table-head">id_employee</td>
<td width="100px" align="center" class="table-head">id_profile</td>
<td width="200px" align="center" class="table-head">Email</td>
<td width="200px" align="center" class="table-head">Langue</td>
</tr>
{section name=customer loop=$data2}
<tr>
<td align="center">
{$data2[customer].id_employee}
</td>
<td align="center">
{$data2[customer].id_profile}
</td>
<td align="center">
{$data2[customer].email}
</td>
<td align="center">
{$data2[customer].id_lang}
</td>
</tr>
{/section}
</table>


1 commentaire:

  1. Thanks for sharing as it is an excellent post would love to read your future post
    Prestashop Developer

    RépondreSupprimer