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