$data = $this->mongoCollection->findOne($this->buildCondition($condition), $fields); //$data = $this->convertFromMongoData($data); return $data; } public function findOneConvert($condition = [], $fields = []) { $data = $this->mongoCollection->findOne($this->buildCondition($condition), $fields); $data = $this->convertFromMongoData($data); return $data; } //mongodb里面取出来的数据,把日期类型的转换成字符串。 public function convertFromMongoData($data,$format = 1){ //$data = object_to_array($data); $dataformat = "";
} public function findOneConvert($condition = [], $fields = []) { $data = $this->mongoCollection->findOne($this->buildCondition($condition), $fields); $data = $this->convertFromMongoData($data); return $data; } //mongodb里面取出来的数据,把日期类型的转换成字符串。
protected function getCustomUrl($uri){ if(substr($uri,0,1) == "/"){ $uri = substr($uri,1); } $url_rewrite_coll = \Yii::$app->mongodb->getCollection('url_rewrite'); $one = $url_rewrite_coll->findOneConvert(['request_path' => $uri]); if($one['_id']){ $type = $one['type']; $type_data_id = $one['type_data_id']; Global $page_handle; if($type == 'product'){ $product_coll = \Yii::$app->mongodb->getCollection("catalog_product");
$arr = explode("#",$requestUri); $front_requestUri = $arr[0]; $dh_requestUri = $arr[1]; }else{ $front_requestUri = $requestUri; } if($custom_uri = $this->getCustomUrl($front_requestUri)){ if($wh_requestUri){ return $custom_uri."?".$wh_requestUri; }else if($dh_requestUri){ return $custom_uri."#".$dh_requestUri; }else{ return $custom_uri;
throw new InvalidConfigException('Unable to determine the request URI.'); } //echo $requestUri."<br/>" ;exit; //$requestUri = "system/account/manager"; //echo $this->getRewriteUri($requestUri);exit; $requestUri = $this->getRewriteUri($requestUri); $ip = Help::get_real_ip(); $myfile = fopen("logs/".$ip.".txt", "a+") or die("Unable to open file!"); fwrite($myfile, "#".session_id()."#".date('Y-m-d H:i:s')." "); fwrite($myfile, $requestUri."\n"); fclose($myfile);
* @return string the currently requested relative URL. Note that the URI returned is URL-encoded. * @throws InvalidConfigException if the URL cannot be determined due to unusual server configuration */ public function getUrl() { if ($this->_url === null) { $this->_url = $this->resolveRequestUri(); } return $this->_url; } /**
* @return string part of the request URL that is after the entry script and before the question mark. * Note, the returned path info is decoded. * @throws InvalidConfigException if the path info cannot be determined due to unexpected server configuration */ protected function resolvePathInfo() { $pathInfo = $this->getUrl(); if (($pos = strpos($pathInfo, '?')) !== false) { $pathInfo = substr($pathInfo, 0, $pos); } $pathInfo = urldecode($pathInfo);
* Note, the returned path info is already URL-decoded. * @throws InvalidConfigException if the path info cannot be determined due to unexpected server configuration */ public function getPathInfo() { if ($this->_pathInfo === null) { $this->_pathInfo = $this->resolvePathInfo(); } return $this->_pathInfo; } /**
* @return array|boolean the route and the associated parameters. The latter is always empty * if [[enablePrettyUrl]] is false. False is returned if the current request cannot be successfully parsed. */ public function parseRequest($request) { if ($this->enablePrettyUrl) { $pathInfo = $request->getPathInfo(); /* @var $rule UrlRule */ foreach ($this->rules as $rule) { if (($result = $rule->parseRequest($this, $request)) !== false) { return $result; } }
* Resolves the current request into a route and the associated parameters. * @return array the first element is the route, and the second is the associated parameters. * @throws HttpException if the request cannot be resolved. */ public function resolve() { $result = Yii::$app->getUrlManager()->parseRequest($this); if ($result !== false) { list ($route, $params) = $result; $_GET = array_merge($_GET, $params); return [$route, $_GET]; } else {
* @return Response the resulting response * @throws NotFoundHttpException if the requested route is invalid */ public function handleRequest($request) { if (empty($this->catchAll)) { list ($route, $params) = $request->resolve(); } else { $route = $this->catchAll[0]; $params = array_splice($this->catchAll, 1); } try { Yii::trace("Route requested: '$route'", __METHOD__);
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
//var_dump($config);exit; #这个用来保存cms-->page页面的信息,在request通过url rewrite匹配后,得到对应的,handle,然后保存到这个变量中, #/home/index/page 通过变量获取出来这个值。 $cms_page_content = ''; $application = new yii\web\Application($config); $application->run();
$_SERVER = [ 'USER' => 'www-data', 'HOME' => '/home/www-data', 'FCGI_ROLE' => 'RESPONDER', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_SOFTWARE' => 'nginx', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'CONTENT_TYPE' => '', 'CONTENT_LENGTH' => '', 'SCRIPT_FILENAME' => '/www/web/onfancy/frontend/web/index.php', 'SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/catalog/product_compare/add/product/53774/uenc/aHR0cDovL3d3dy5vbmZhbmN5LmVzOjgyL2NoZWFwLWRpc2NvdW50LWNsb3RoaW5nLXdvbWVuL3dvbWVucy1sZWF0aGVyLWphY2tldHMtd2hvbGVzYWxlLmh0bWw,/form_key/iwQQv1Qe9JtNE7UQ/', 'DOCUMENT_URI' => '/index.php', 'DOCUMENT_ROOT' => '/www/web/onfancy/frontend/web', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REMOTE_ADDR' => '44.201.64.238', 'REMOTE_PORT' => '39224', 'SERVER_ADDR' => '85.195.99.50', 'SERVER_PORT' => '443', 'SERVER_NAME' => 'onfancy.es', 'REDIRECT_STATUS' => '200', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'claudebot', 'HTTP_REFERER' => 'http://www.onfancy.es/catalog/product_compare/add/product/53774/uenc/aHR0cDovL3d3dy5vbmZhbmN5LmVzOjgyL2NoZWFwLWRpc2NvdW50LWNsb3RoaW5nLXdvbWVuL3dvbWVucy1sZWF0aGVyLWphY2tldHMtd2hvbGVzYWxlLmh0bWw,/form_key/iwQQv1Qe9JtNE7UQ/', 'HTTP_HOST' => 'www.onfancy.es', 'PHP_SELF' => '/index.php', 'REQUEST_TIME_FLOAT' => 1711677663.6153049, 'REQUEST_TIME' => 1711677663, ];