* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 1.4 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ ob_start(); define('PS_ADMIN_DIR', getcwd()); include(PS_ADMIN_DIR.'/../config/config.inc.php'); include(PS_ADMIN_DIR.'/functions.php'); if ((empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED')) { header('HTTP/1.1 301 Moved Permanently'); header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); exit(); } $errors = array(); $cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10)); if (!isset($cookie->id_lang)) $cookie->id_lang = Configuration::get('PS_LANG_DEFAULT'); $iso = strtolower(Language::getIsoById((int)($cookie->id_lang))); include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'); /* Cookie creation and redirection */ if (Tools::isSubmit('Submit')) { /* Check fields validity */ $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) $errors[] = Tools::displayError('E-mail is empty'); elseif (!Validate::isEmail($email)) $errors[] = Tools::displayError('Invalid e-mail address'); elseif (empty($passwd)) $errors[] = Tools::displayError('Password is blank'); elseif (!Validate::isPasswd($passwd)) $errors[] = Tools::displayError('Invalid password'); else { /* Seeking for employee */ $employee = new Employee(); $employee = $employee->getByemail($email, $passwd); if (!$employee) { $errors[] = Tools::displayError('Employee does not exist or password is incorrect.'); $cookie->logout(); } else { /* Creating cookie */ $cookie->id_employee = $employee->id; $cookie->email = $employee->email; $cookie->profile = $employee->id_profile; $cookie->passwd = $employee->passwd; $cookie->remote_addr = ip2long(Tools::getRemoteAddr()); $cookie->write(); /* Redirect to admin panel */ if (isset($_GET['redirect'])) $url = strval($_GET['redirect'].(isset($_GET['token']) ? ('&token='.$_GET['token']) : '')); else $url = 'index.php'; if (!Validate::isCleanHtml($url)) die(Tools::displayError()); echo '
'; exit ; } } } echo '