Zen Cart PHP Cross Reference Customer Relationship Management

Source: /admin/includes/application_top.php - 147 lines - 5924 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @package admin
   4   * @copyright Copyright 2003-2012 Zen Cart Development Team
   5   * @copyright Portions Copyright 2003 osCommerce
   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
   7   * @version GIT: $Id: Author: DrByte  Fri Jul 6 11:57:44 2012 -0400 Modified in v1.5.1 $
   8   */
   9  /**
  10   * File contains just application_top code
  11   *
  12   * Initializes common classes & methods. Controlled by an array which describes
  13   * the elements to be initialised and the order in which that happens.
  14   *
  15   * @package admin
  16   */
  17  /**
  18   * boolean if true the autoloader scripts will be parsed and their output shown. For debugging purposes only.
  19   */
  20  define('DEBUG_AUTOLOAD', false);
  21  /**
  22   * boolean used to see if we are in the admin script, obviously set to false here.
  23   * DO NOT REMOVE THE define BELOW. WILL BREAK ADMIN
  24   */
  25  define('IS_ADMIN_FLAG', true);
  26  /**
  27   * integer saves the time at which the script started.
  28   */
  29  // Start the clock for the page parse time log
  30  define('PAGE_PARSE_START_TIME', microtime());
  31  /**
  32   * set the level of error reporting
  33   *
  34   * Note STRICT_ERROR_REPORTING should never be set to true on a production site. <br />
  35   * It is mainly there to show php warnings during testing/bug fixing phases.<br />
  36   * note for strict error reporting we also turn on show_errors as this may be disabled<br />
  37   * in php.ini. Otherwise we respect the php.ini setting
  38   *
  39   */
  40  if (defined('STRICT_ERROR_REPORTING') && STRICT_ERROR_REPORTING == true) {
  41    @ini_set('display_errors', TRUE);
  42    error_reporting(version_compare(PHP_VERSION, 5.3, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE : version_compare(PHP_VERSION, 5.4, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT : E_ALL & ~E_NOTICE);
  43  } else {
  44    error_reporting(0);
  45  }
  46  /*
  47   * turn off magic-quotes support, for both runtime and sybase, as both will cause problems if enabled
  48   */
  49  if (version_compare(PHP_VERSION, 5.3, '<') && function_exists('set_magic_quotes_runtime')) set_magic_quotes_runtime(0);
  50  if (version_compare(PHP_VERSION, 5.4, '<') && @ini_get('magic_quotes_sybase') != 0) @ini_set('magic_quotes_sybase', 0);
  51  // set php_self in the local scope
  52  if (!isset($PHP_SELF)) $PHP_SELF = $_SERVER['PHP_SELF'];
  53  
  54  /**
  55   * Set the local configuration parameters - mainly for developers
  56   */
  57  if (file_exists('includes/local/configure.php')) {
  58    /**
  59     * load any local(user created) configure file.
  60     */
  61    include('includes/local/configure.php');
  62  }
  63  /**
  64   * check for and load application configuration parameters
  65   */
  66  if (file_exists('includes/configure.php')) {
  67    /**
  68     * load the main configure file.
  69     */
  70    include('includes/configure.php');
  71  }
  72  if (!defined('DIR_FS_CATALOG') || !is_dir(DIR_FS_CATALOG.'/includes/classes') || !defined('DB_TYPE') || DB_TYPE == '') {
  73    if (file_exists('../includes/templates/template_default/templates/tpl_zc_install_suggested_default.php')) {
  74      require ('../includes/templates/template_default/templates/tpl_zc_install_suggested_default.php');
  75      exit;
  76    } elseif (file_exists('../zc_install/index.php')) {
  77      echo 'ERROR: Admin configure.php not found. Suggest running install? <a href="../zc_install/index.php">Click here for installation</a>';
  78    } else {
  79      die('ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?');
  80    }
  81  }
  82  /**
  83   * ignore version-check if INI file setting has been set
  84   */
  85  if (file_exists(DIR_FS_ADMIN . 'includes/local/skip_version_check.ini')) {
  86    $lines = @file(DIR_FS_ADMIN . 'includes/local/skip_version_check.ini');
  87    if (is_array($lines)) {
  88      foreach($lines as $line) {
  89        if (substr($line,0,14)=='admin_configure_php_check=') $check_cfg=substr(trim(strtolower(str_replace('admin_configure_php_check=','',$line))),0,3);
  90      }
  91    }
  92  }
  93  /*
  94  // turned off for now
  95    if ($check_cfg != 'off') {
  96      // if the admin/includes/configure.php file doesn't contain admin-related content, throw error
  97      $zc_pagepath = str_replace(basename($PHP_SELF),'',__FILE__); //remove page name from full path of current page
  98      $zc_pagepath = str_replace(array('\\','\\\\'),'/',$zc_pagepath); // convert '\' marks to '/'
  99      $zc_pagepath = str_replace('//','/',$zc_pagepath); //convert doubles to single
 100      $zc_pagepath = str_replace(strrchr($zc_pagepath,'/'),'',$zc_pagepath); // remove trailing '/'
 101      $zc_adminpage = str_replace('\\','/',DIR_FS_ADMIN); //convert "\" to '/'
 102      $zc_adminpage = str_replace('//','/',$zc_adminpage); // remove doubles
 103      $zc_adminpage = str_replace(strrchr($zc_adminpage,'/'),'',$zc_adminpage); // remove trailing '/'
 104      if (!defined('DIR_WS_ADMIN') || $zc_pagepath != $zc_adminpage ) {
 105        echo ('ERROR: The admin/includes/configure.php file has invalid configuration. Please rebuild, or verify specified paths.');
 106        if (file_exists('../zc_install/index.php')) {
 107          echo '<br /><a href="../zc_install/index.php">Click here for installation</a>';
 108        }
 109        echo '<br /><br /><br /><br />['.$zc_pagepath.']&nbsp;&nbsp;&nbsp;&laquo;&raquo;&nbsp;&nbsp;&nbsp;[' .$zc_adminpage.']<br />';
 110      }
 111    }
 112  */
 113  /**
 114   * include the list of extra configure files
 115   */
 116  if ($za_dir = @dir(DIR_WS_INCLUDES . 'extra_configures')) {
 117    while ($zv_file = $za_dir->read()) {
 118      if (preg_match('~^[^\._].*\.php$~i', $zv_file) > 0) {
 119        /**
 120         * load any user/contribution specific configuration files.
 121         */
 122        include(DIR_WS_INCLUDES . 'extra_configures/' . $zv_file);
 123      }
 124    }
 125    $za_dir->close();
 126  }
 127  /**
 128   * init some vars
 129   */
 130  $template_dir = '';
 131  define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');
 132  /**
 133   * Prepare init-system
 134   */
 135  unset($loaderPrefix); // admin doesn't need this override
 136  $autoLoadConfig = array();
 137  if (isset($loaderPrefix)) {
 138   $loaderPrefix = preg_replace('/[^a-z_]/', '', $loaderPrefix);
 139  } else {
 140    $loaderPrefix = 'config';
 141  }
 142  $loader_file = $loaderPrefix . '.core.php';
 143  require ('includes/initsystem.php');
 144  /**
 145   * load the autoloader interpreter code.
 146   */
 147    require (DIR_FS_CATALOG . 'includes/autoload_func.php');

title

Description

title

Description

title

Description

title

title

Body