PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/admin800/password.php

http://marocmall.googlecode.com/
PHP | 116 lines | 82 code | 9 blank | 25 comment | 7 complexity | 0a56c4ad79a2e0142a261918c3e1a2f0 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. * 2007-2011 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@prestashop.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. * @author PrestaShop SA <contact@prestashop.com>
  22. * @copyright 2007-2011 PrestaShop SA
  23. * @version Release: $Revision: 7086 $
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. * International Registered Trademark & Property of PrestaShop SA
  26. */
  27. define('PS_ADMIN_DIR', getcwd());
  28. include(PS_ADMIN_DIR.'/../config/config.inc.php');
  29. include(PS_ADMIN_DIR.'/functions.php');
  30. $cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10));
  31. $errors = array();
  32. $id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
  33. $iso = strtolower(Language::getIsoById((int)$id_lang));
  34. include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
  35. if (isset($_POST['Submit']))
  36. {
  37. $errors = array();
  38. if (empty($_POST['email']))
  39. $errors[] = Tools::displayError('E-mail is empty');
  40. elseif (!Validate::isEmail($_POST['email']))
  41. $errors[] = Tools::displayError('Invalid e-mail address');
  42. else
  43. {
  44. $employee = new Employee();
  45. if (!$employee->getByemail($_POST['email']) OR !$employee)
  46. $errors[] = Tools::displayError('This account does not exist');
  47. else
  48. {
  49. if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0 )
  50. $errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)');
  51. else
  52. {
  53. $pwd = Tools::passwdGen();
  54. $employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd));
  55. $employee->last_passwd_gen = date('Y-m-d H:i:s', time());
  56. $result = $employee->update();
  57. if (!$result)
  58. $errors[] = Tools::displayError('An error occurred during your password change.');
  59. else
  60. {
  61. Mail::Send((int)$id_lang, 'password', Mail::l('Your new admin password'), array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd), $employee->email, $employee->firstname.' '.$employee->lastname);
  62. $confirmation = 'ok';
  63. }
  64. }
  65. }
  66. }
  67. }
  68. echo '
  69. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  70. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$iso.'" lang="'.$iso.'">
  71. <head>
  72. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  73. <link type="text/css" rel="stylesheet" href="../css/login.css" />
  74. <title>PrestaShop&trade; - '.translate('Administration panel').'</title>
  75. </head>
  76. <body><div id="container">';
  77. if (sizeof($errors))
  78. {
  79. echo '<div id="error">
  80. <h3>'.translate('There is 1 error').'</h3>
  81. <ol>';
  82. foreach ($errors AS $error)
  83. echo '<li>'.$error.'</li>';
  84. echo '</ol>
  85. </div>';
  86. }
  87. echo '
  88. <div id="login">
  89. <h1>'.Configuration::get('PS_SHOP_NAME').'</h1>
  90. <form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post">
  91. <div class="page-title center">'.translate('Forgot your password?').'</div><br />';
  92. if (isset($confirmation))
  93. echo ' <br />
  94. <div style="font-weight: bold;">'.translate('Your password has been e-mailed to you').'.</div>
  95. <div style="margin: 2em 0 0 0; text-align: right;"><a href="login.php?email='.Tools::safeOutput(Tools::getValue('email')).'">> '.translate('back to login home').'</a></div>';
  96. else
  97. echo ' <span style="font-weight: bold;">'.translate('Please, enter your e-mail address').' </span>
  98. '.translate('(the one you wrote during your registration) in order to receive your access codes by e-mail').'.<br />
  99. <input type="text" name="email" class="input" />
  100. <div>
  101. <div id="submit"><input type="submit" name="Submit" value="'.translate('Send').'" class="button" /></div>
  102. <div id="lost">&nbsp;</div>
  103. </div>
  104. </form>
  105. </div>
  106. <h2><a href="http://www.prestashop.com">&copy; Copyright by PrestaShop. all rights reserved.</a></h2>
  107. </div></body></html>';