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