PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/adminstrator/init.php

http://marocmall.googlecode.com/
PHP | 84 lines | 47 code | 10 blank | 27 comment | 9 complexity | 9bbf2c10b90a6d3c4742ed8a43bf5a81 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: 7588 $
  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. ob_start();
  28. $timerStart = microtime(true);
  29. $currentFileName = array_reverse(explode("/", $_SERVER['SCRIPT_NAME']));
  30. $cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600));
  31. $cookie = new Cookie('psAdmin', substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($currentFileName['0'])), $cookieLifetime);
  32. if (isset($_GET['logout']))
  33. $cookie->logout();
  34. if (!$cookie->isLoggedBack())
  35. {
  36. $destination = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])) + 1);
  37. Tools::redirectAdmin('login.php'.(empty($destination) || ($destination == 'index.php?logout') ? '' : '?redirect='.$destination));
  38. }
  39. else
  40. {
  41. $link = new Link();
  42. $currentIndex = $_SERVER['SCRIPT_NAME'].(($tab = Tools::getValue('tab')) ? '?tab='.$tab : '');
  43. if ($back = Tools::getValue('back'))
  44. $currentIndex .= '&back='.urlencode($back);
  45. /* Server Params */
  46. $protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
  47. $protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
  48. define('_PS_BASE_URL_', Tools::getShopDomain(true));
  49. define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
  50. $employee = new Employee((int)$cookie->id_employee);
  51. $cookie->id_lang = (int)$employee->id_lang;
  52. $iso = strtolower(Language::getIsoById($cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT')));
  53. include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
  54. include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
  55. include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
  56. /* attribute id_lang is often needed, so we create a constant for performance reasons */
  57. define('_USER_ID_LANG_', (int)$cookie->id_lang);
  58. $path = dirname(__FILE__).'/themes/';
  59. if (empty($employee->bo_theme) OR !file_exists($path.$employee->bo_theme.'/admin.css'))
  60. {
  61. if (file_exists($path.'oldschool/admin.css'))
  62. $employee->bo_theme = 'oldschool';
  63. elseif (file_exists($path.'origins/admin.css'))
  64. $employee->bo_theme = 'origins';
  65. else
  66. foreach (scandir($path) as $theme)
  67. if ($theme[0] != '.' AND file_exists($path.$theme.'/admin.css'))
  68. {
  69. $employee->bo_theme = $theme;
  70. break;
  71. }
  72. $employee->update();
  73. }
  74. }