} return $handler($request, $options)->then( function (ResponseInterface $response) use ($request, $handler) { $code = $response->getStatusCode(); if ($code < 400) { return $response; } throw $code > 499 ? new ServerException("Server error: $code", $request, $response) : new ClientException("Client error: $code", $request, $response); } ); }; }; } /** * Middleware that pushes history data to an ArrayAccess container. *
if ($promise->getState() !== self::PENDING) { return; } try { if (isset($handler[$index])) { $promise->resolve($handler[$index]($value)); } elseif ($index === 1) { // Forward resolution values as-is. $promise->resolve($value); } else { // Forward rejections down the chain. $promise->reject($value);
// it in the task queue using the correct ID. if (!method_exists($value, 'then')) { $id = $state === self::FULFILLED ? 1 : 2; // It's a success, so resolve the handlers in the queue. queue()->add(static function () use ($id, $value, $handlers) { foreach ($handlers as $handler) { self::callHandler($id, $value, $handler); } }); } elseif ($value instanceof Promise && $value->getState() === self::PENDING ) { // We can just merge our handlers onto the next promise.
/** * Execute all of the pending task in the queue. */ public function run() { while ($task = array_shift($this->queue)) { $task(); } } /** * The task queue will be run and exhausted by default when the process * exits IFF the exit is not the result of a PHP E_ERROR error.
); } } } // Step through the task queue which may add additional requests. P\queue()->run(); if ($this->active && curl_multi_select($this->_mh, $this->selectTimeout) === -1 ) { // Perform a usleep if a select returns -1. // See: https://bugs.php.net/bug.php?id=61141
while ($this->handles || !$queue->isEmpty()) { // If there are no transfers, then sleep for the next delay if (!$this->active && $this->delays) { usleep($this->timeToNext()); } $this->tick(); } } private function addRequest(array $entry) { $easy = $entry['easy'];
private function invokeWaitFn() { try { $wfn = $this->waitFn; $this->waitFn = null; $wfn(true); } catch (\Exception $reason) { if ($this->state === self::PENDING) { // The promise has not been resolved yet, so reject the promise // with the exception. $this->reject($reason); } else {
private function waitIfPending() { if ($this->state !== self::PENDING) { return; } elseif ($this->waitFn) { $this->invokeWaitFn(); } elseif ($this->waitList) { $this->invokeWaitList(); } else { // If there's not wait function, then reject the promise. $this->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait '
{ $waitList = $this->waitList; $this->waitList = null; foreach ($waitList as $result) { descend: $result->waitIfPending(); if ($result->result instanceof Promise) { $result = $result->result; goto descend; } } }
{ if ($this->state !== self::PENDING) { return; } elseif ($this->waitFn) { $this->invokeWaitFn(); } elseif ($this->waitList) { $this->invokeWaitList(); } else { // If there's not wait function, then reject the promise. $this->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait ' . 'function when constructing the promise to be able to ' . 'wait on a promise.');
{ return $this->then(null, $onRejected); } public function wait($unwrap = true) { $this->waitIfPending(); if (!$unwrap) { return null; } if ($this->result instanceof PromiseInterface) {
return $this->transfer($request, $options); } public function request($method, $uri = null, array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->requestAsync($method, $uri, $options)->wait(); } public function getConfig($option = null) { return $option === null ? $this->config
public $ogimage = ''; public $ogvideo = ''; private function getData($url, &$title, &$description, &$date, &$article) { $client = new Client(); $res = $client->request('GET', $url); $body = $res->getBody(); $document = \phpQuery::newDocumentHTML($body); $title = $document->find(".b-content h1"); $description = $document->find(".b-content .b-content__synopsis"); $date = $document->find(".b-content .b-content__date"); $article = $document->find(".b-content .b-content__text");
{ $this->layout = 'horoscopes-one-menu'; $this->ogtitle = 'Женский гороскоп на неделю'; $this->ogdescription = 'Женский гороскоп на неделю'; $this->ogimage = '/web/images/logo.png'; $this->getData('http://horoscopes.rambler.ru/women/', $title, $description, $date, $article); return $this->render('women', ['title' => $title, 'description' => $description, 'date' => $date, 'article' => $article]); } public function actionTravel() {
$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();
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();
$_SERVER = [ 'REDIRECT_REDIRECT_MEF_PROXY_ADDR' => '127.0.0.1', 'REDIRECT_REDIRECT_UNIQUE_ID' => 'ZgV9lH8AAAEACEoC8O0AAAA1', 'REDIRECT_REDIRECT_SCRIPT_URL' => '/horoscopes/women', 'REDIRECT_REDIRECT_SCRIPT_URI' => 'http://mir29.ru/horoscopes/women', 'REDIRECT_REDIRECT_HTTP_CGI_AUTHORIZATION' => '', 'REDIRECT_REDIRECT_STATUS' => '200', 'REDIRECT_MEF_PROXY_ADDR' => '127.0.0.1', 'REDIRECT_UNIQUE_ID' => 'ZgV9lH8AAAEACEoC8O0AAAA1', 'REDIRECT_SCRIPT_URL' => '/horoscopes/women', 'REDIRECT_SCRIPT_URI' => 'http://mir29.ru/horoscopes/women', 'REDIRECT_HTTP_CGI_AUTHORIZATION' => '', 'REDIRECT_STATUS' => '200', 'MEF_PROXY_ADDR' => '127.0.0.1', 'UNIQUE_ID' => 'ZgV9lH8AAAEACEoC8O0AAAA1', 'SCRIPT_URL' => '/horoscopes/women', 'SCRIPT_URI' => 'http://mir29.ru/horoscopes/women', 'HTTP_CGI_AUTHORIZATION' => '', 'HTTP_X_FORWARDED_FOR' => '18.206.12.31', 'HTTP_X_FORWARDED_PORT' => '80', 'HTTP_X_FORWARDED_PROTO' => 'http', 'HTTP_X_SECURITY' => 'on', 'HTTP_HOST' => 'mir29.ru', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'claudebot', 'PATH' => '/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin', 'SERVER_SIGNATURE' => 'Apache/2.2.29 (Gentoo) mod_dp/0.99.7 PHP/5.6.40 Server at mir29.ru Port 80 ', 'SERVER_SOFTWARE' => 'Apache/2.2.29 (Gentoo) mod_dp/0.99.7 PHP/5.6.40', 'SERVER_NAME' => 'mir29.ru', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '18.206.12.31', 'DOCUMENT_ROOT' => '/home/l/luckyjearu/mir29.ru/public_html', 'SERVER_ADMIN' => 'support@sweb.ru', 'SCRIPT_FILENAME' => '/home/l/luckyjearu/mir29.ru/public_html/web/index.php', 'REMOTE_PORT' => '49892', 'REDIRECT_URL' => '/web/horoscopes/women', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/horoscopes/women', 'SCRIPT_NAME' => '/web/index.php', 'PHP_SELF' => '/web/index.php', 'REQUEST_TIME_FLOAT' => 1711635860.0009999, 'REQUEST_TIME' => 1711635860, ];