PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/admin800/init.php

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