[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 init_customer_auth.php

Zen Cart 源代码 init_customer_auth.php




下载文件

文件名: init_customer_auth.php
文件类型: PHP文件
文件大小: 5.82 KiB
MD5: b37a479e5a67102431c85db44c02749b

init_customer_auth.php - 关闭高亮
  1. <?php
  2. /**
  3.  * customer authorisation based on DOWN_FOR_MAINTENANCE and CUSTOMERS_APPROVAL_AUTHORIZATION settings
  4.  * see {@link  http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details.
  5.  *
  6.  * @package initSystem
  7.  * @copyright Copyright 2003-2007 Zen Cart Development Team
  8.  * @copyright Portions Copyright 2003 osCommerce
  9.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  10.  * @version $Id: init_customer_auth.php 6992 2007-09-13 02:54:24Z ajeh $
  11.  */
  12. if (!defined('IS_ADMIN_FLAG')) {
  13.   die('Illegal Access');
  14. }
  15. $down_for_maint_flag = false;
  16. /**
  17.  * do not let people get to down for maintenance page if not turned on unless is admin in IP list
  18.  */
  19. if (DOWN_FOR_MAINTENANCE=='false' and $_GET['main_page'] == DOWN_FOR_MAINTENANCE_FILENAME && !strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])){
  20.   zen_redirect(zen_href_link(FILENAME_DEFAULT));
  21. }
  22. /**
  23.  * see if DFM mode type is defined (strict means all pages blocked, relaxed means logoff/privacy/etc pages are usable)
  24.  */
  25. if (!defined('DOWN_FOR_MAINTENANCE_TYPE')) define('DOWN_FOR_MAINTENANCE_TYPE', 'relaxed');
  26. /**
  27.  * check to see if site is DFM, and set a flag for use later
  28.  */
  29. if (DOWN_FOR_MAINTENANCE == 'true') {
  30.   if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])){
  31.     if ($_GET['main_page'] != DOWN_FOR_MAINTENANCE_FILENAME) $down_for_maint_flag = true;
  32.   }
  33. }
  34. /**
  35.  * recheck customer status for authorization
  36.  */
  37. if (CUSTOMERS_APPROVAL_AUTHORIZATION > 0 && ($_SESSION['customer_id'] != '' and $_SESSION['customers_authorization'] != '0')) {
  38.   $check_customer_query = "select customers_id, customers_authorization
  39.                             from " . TABLE_CUSTOMERS . "
  40.                             where customers_id = '" . $_SESSION['customer_id'] . "'";
  41.   $check_customer = $db->Execute($check_customer_query);
  42.   $_SESSION['customers_authorization'] = $check_customer->fields['customers_authorization'];
  43. }
  44. /**
  45.  * customer login status
  46.  * 0 = normal shopping
  47.  * 1 = Login to shop
  48.  * 2 = Can browse but no prices
  49.  *
  50.  * customer authorization status
  51.  * 0 = normal shopping
  52.  * 1 = customer authorization to shop
  53.  * 2 = customer authorization pending can browse but no prices
  54.  */
  55. switch (true) {
  56.   case ($down_for_maint_flag && DOWN_FOR_MAINTENANCE_TYPE == 'strict'):
  57.     // if DFM is in strict mode, then block access to all pages:
  58.     zen_redirect(zen_href_link(DOWN_FOR_MAINTENANCE_FILENAME));
  59.   break;
  60.  
  61.   case ((DOWN_FOR_MAINTENANCE == 'true') && !in_array($_GET['main_page'], array(FILENAME_LOGOFF, FILENAME_PRIVACY, FILENAME_CONTACT_US, FILENAME_CONDITIONS, FILENAME_SHIPPING))):
  62.     // on special pages, if DFM mode is "relaxed", allow access to these pages
  63.     if ($down_for_maint_flag && DOWN_FOR_MAINTENANCE_TYPE == 'relaxed') {
  64.       zen_redirect(zen_href_link(DOWN_FOR_MAINTENANCE_FILENAME));
  65.     }
  66.   break;
  67.  
  68.   case (in_array($_GET['main_page'], array(FILENAME_LOGOFF, FILENAME_PRIVACY, FILENAME_PASSWORD_FORGOTTEN, FILENAME_CONTACT_US, FILENAME_CONDITIONS, FILENAME_SHIPPING, FILENAME_UNSUBSCRIBE))):
  69.     // on special pages, allow customers to access regardless of store mode or cust auth mode
  70.   break;
  71.  
  72. /**
  73.  * check store status before authorizations
  74.  */
  75.   case (STORE_STATUS != 0):
  76.     break;
  77. /**
  78.  * if not down for maintenance check login status
  79.  */
  80.   case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
  81.   /**
  82.    * customer must be logged in to browse
  83.    */
  84.   if (!in_array($_GET['main_page'], array(FILENAME_LOGIN, FILENAME_CREATE_ACCOUNT))) {
  85.     if (!isset($_GET['set_session_login'])) {
  86.       $_GET['set_session_login'] = 'true';
  87.       $_SESSION['navigation']->set_snapshot();
  88.     }
  89.     zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  90.   }
  91.   break;
  92.   case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
  93.   /**
  94.    * customer may browse but no prices
  95.    */
  96.   break;
  97.   default:
  98.   /**
  99.    * proceed normally
  100.    */
  101.   break;
  102. }
  103.  
  104. switch (true) {
  105. /**
  106.  * check store status before authorizations
  107.  */
  108.   case (STORE_STATUS != 0):
  109.     break;
  110.   case (CUSTOMERS_APPROVAL_AUTHORIZATION == '1' and $_SESSION['customer_id'] == ''):
  111.   /**
  112.    * customer must be logged in to browse
  113.    */
  114. //  if (!in_array($_GET['main_page'], array(FILENAME_LOGIN, FILENAME_CREATE_ACCOUNT))) {
  115.   if (!in_array($_GET['main_page'], array(FILENAME_LOGIN, FILENAME_LOGOFF, FILENAME_CREATE_ACCOUNT, FILENAME_PASSWORD_FORGOTTEN, FILENAME_CONTACT_US, FILENAME_PRIVACY))) {
  116.     if (!isset($_GET['set_session_login'])) {
  117.       $_GET['set_session_login'] = 'true';
  118.       $_SESSION['navigation']->set_snapshot();
  119.     }
  120.     zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  121.   }
  122.   break;
  123.   case (CUSTOMERS_APPROVAL_AUTHORIZATION == '2' and $_SESSION['customer_id'] == ''):
  124.   /**
  125.    * customer may browse but no prices unless Authorized
  126.    */
  127.   /*
  128.   if (!in_array($_GET['main_page'], array(FILENAME_LOGIN, FILENAME_CREATE_ACCOUNT))) {
  129.    if (!isset($_GET['set_session_login'])) {
  130.     $_GET['set_session_login'] = 'true';
  131.     $_SESSION['navigation']->set_snapshot();
  132.    }
  133.   zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  134.   }
  135.   */
  136.   break;
  137.   case (CUSTOMERS_APPROVAL_AUTHORIZATION == '1' and $_SESSION['customers_authorization'] != '0'):
  138.   /**
  139.    * customer is pending approval
  140.    * customer must be logged in to browse
  141.    */
  142.   if (!in_array($_GET['main_page'], array(FILENAME_LOGIN, FILENAME_LOGOFF, FILENAME_CONTACT_US, FILENAME_PRIVACY))) {
  143.   if ($_GET['main_page'] != CUSTOMERS_AUTHORIZATION_FILENAME) {
  144.     zen_redirect(zen_href_link(CUSTOMERS_AUTHORIZATION_FILENAME));
  145.     }
  146.   }
  147.   break;
  148.   case (CUSTOMERS_APPROVAL_AUTHORIZATION == '2' and $_SESSION['customers_authorization'] != '0'):
  149.   /**
  150.    * customer may browse but no prices
  151.    */
  152.   break;
  153.   default:
  154.   /**
  155.    * proceed normally
  156.    */
  157.   break;
  158. }
  159. ?>