$len = filesize(substr($fileUrl,1)); $contentId = Yii::$app->request->get('id', ''); $contentId = number_format($contentId); $fileName = Yii::$app->request->get('fileName', ''); $fileUrl='http://'.$_SERVER['HTTP_HOST'].$fileUrl; $model = new Content(); $data = $model->getClass(['fields' => 'giveup', 'where' => "c.id=$contentId"])[0]; $count = $data['giveup']+1; ContentExtend::updateAll(['value' => $count], "contentId=$contentId and code='99c2265aa8cd374b779c95ccbdb5ac2a'"); $file = fopen($fileUrl, "r"); if (!$file) { echo "文件找不到"; } else { header("Content-type: application/octet-stream"); header("Accept-Ranges: bytes"); header("Content-Disposition: attachment; filename=" . $fileName); header('Content-Type: application/"'.$ext.'"'); //防止乱码 header("Content-Length: ".$len); ob_clean();
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); Yii::$app->controller = $oldController; return $result; } else { $id = $this->getUniqueId(); throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
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();
// // default: // break; //} error_reporting(E_ALL); (new yii\web\Application($config))->run();
$_GET = [ 'fileUrl' => '1', 'id' => '536', 'fileName' => '1', ]; $_SERVER = [ 'REDIRECT_UNIQUE_ID' => 'ZgWxtMeEExgslDS7bGXpkgAAACI', 'REDIRECT_HTTPS' => 'on', 'REDIRECT_SSL_TLS_SNI' => 'bbs.thinkwithu.com', 'REDIRECT_STATUS' => '200', 'UNIQUE_ID' => 'ZgWxtMeEExgslDS7bGXpkgAAACI', 'HTTPS' => 'on', 'SSL_TLS_SNI' => 'bbs.thinkwithu.com', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'claudebot', 'HTTP_HOST' => 'bbs.thinkwithu.com', 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin', 'SERVER_SIGNATURE' => '', 'SERVER_SOFTWARE' => 'Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.6.40', 'SERVER_NAME' => 'bbs.thinkwithu.com', 'SERVER_ADDR' => '172.18.175.120', 'SERVER_PORT' => '443', 'REMOTE_ADDR' => '18.232.169.110', 'DOCUMENT_ROOT' => '/var/www/html/thinku-bbs/web', 'REQUEST_SCHEME' => 'https', 'CONTEXT_PREFIX' => '', 'CONTEXT_DOCUMENT_ROOT' => '/var/www/html/thinku-bbs/web', 'SERVER_ADMIN' => 'root@localhost', 'SCRIPT_FILENAME' => '/var/www/html/thinku-bbs/web/index.php', 'REMOTE_PORT' => '44564', 'REDIRECT_QUERY_STRING' => 'fileUrl=1&&id=536&&fileName=1', 'REDIRECT_URL' => '/cn/article/download', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'fileUrl=1&&id=536&&fileName=1', 'REQUEST_URI' => '/cn/article/download?fileUrl=1&&id=536&&fileName=1', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'REQUEST_TIME_FLOAT' => 1711649204.5799999, 'REQUEST_TIME' => 1711649204, ]; $_SESSION = [ '__flash' => [], ];