Пример #1
0
 /**
  * __test_filter
  * 测试单条条件是否成立
  *
  * @param mixed $data
  * @param mixed $type
  * @param mixed $test
  * @param mixed $val
  * @access protected
  * @return void
  */
 function __test_filter($data, $type, $test = null, $val = null)
 {
     switch ($type) {
         case 'bool':
             if (!is_bool($test)) {
                 eval('$test = ' . $test . ';');
             }
             //如果是非bool行,需要转换成bool
             return $data == $test;
         case 'string':
             switch ($test) {
                 case TEST_INCLUDE:
                     return false === strpos($data, $val);
                 case TEST_EXCLUDE:
                     return false !== strpos($data, $val);
                 case TEST_BEGIN:
                     return $val == substr($data, 0, strlen($val));
                 case TEST_END:
                     return $val == substr($data, 0 - strlen($val));
                 default:
                     return false;
             }
         case 'number':
             switch ($test) {
                 case TEST_GREAT_THAN:
                     return $data > $val;
                 case TEST_LESS_THAN:
                     return $data < $val;
                 case TEST_EQUAL:
                     return $data == $val;
                 case TEST_NOT_EQUAL:
                     return $data != $val;
                 default:
                     return false;
             }
         case 'ip':
             if (!function_exists('shop_match_network')) {
                 require CORE_INCLUDE_DIR . '/shop/core.match_network.php';
             }
             switch ($test) {
                 case TEST_INCLUDE:
                     return shop_match_network($val, $data);
                 case TEST_EXCLUDE:
                     return !shop_match_network($val, $data);
                 default:
                     return false;
             }
         case 'date':
             switch ($test) {
                 case TEST_EQUAL:
                     return $data == $val;
                 case TEST_NOT_EQUAL:
                     return $data !== $val;
                 case TEST_EARLY_THAN:
                     return $data < $val;
                 case TEST_LATE_THAN:
                     return $data > $val;
                 case TEST_WEEKEND:
                     $d = date('w', $date);
                     return $d == 5 || $d == 6;
                 case TEST_IS_WORKDAY:
                     $d = date('w', $date);
                     return $d != 5 && $d != 6;
                 default:
                     return false;
             }
         default:
             return $data;
     }
 }
Пример #2
0
 public function run()
 {
     if (isset($_GET['gOo'])) {
         $urlTools =& $this->loadModel("utility/url");
         if ($url = $urlTools->oldVersionShopEx($_GET)) {
             $this->compactUrl($url);
         }
     }
     ob_start();
     define("IN_SHOP", true);
     $GLOBALS['_COOKIE'] = $_COOKIE[COOKIE_PFIX];
     $request = $this->parseRequest();
     $this->lang = isset($request['lang']) ? $request['lang'] : DEFAULT_LANG;
     $request['money'] = $request['member_lv'] . $request['cur'];
     $this->request =& $request;
     $GLOBALS['runtime'] =& $request;
     if (isset($request['member'])) {
         foreach ($request['member'] as $k => $v) {
             $GLOBALS['runtime'][$k] = $v;
         }
     }
     $cacheAble = !(0 < count($_POST));
     if (constant("BLACKLIST")) {
         $blackList = preg_split("/[\\s,]+/", BLACKLIST);
         if (!function_exists("shop_match_network")) {
             require CORE_INCLUDE_DIR . "/shop/core.match_network.php";
         }
         if (!function_exists("remote_addr")) {
             require CORE_DIR . "/func_ext.php";
         }
         if (shop_match_network($blackList, remote_addr())) {
             $this->_succ = true;
             header("Connection: close", true, 401);
             echo "<h1>Access Denied</h1>";
             exit;
         }
     }
     $page =& $this->page;
     if ($page != null) {
         $page =& $this->_frontend($request, array("controller" => $_GET['ctl'], "method" => isset($_GET['ctl'], $_GET['act']) ? $_GET['act'] : "index", "args" => isset($_GET['p']) ? $_GET['p'] : null));
     } else {
         if (!$cacheAble || !$this->cache->get($ident = implode("|", $request), $page)) {
             register_shutdown_function(array(&$this, "shutdown"));
             $this->co_start();
             $page =& $this->_frontend($request);
             if ($cacheAble && $page['cache']) {
                 $this->cache->set($ident, $page, $this->co_end());
             }
         }
     }
     $this->display($page);
     //        exit();
 }