Check that the response for URL does not create a session

@return array
434248
public function check()
    {
        $response = $this->client->get($this->getURL());
        $cookie = $this->getCookie($response);
        $fullURL = $this->getURL();

        if ($cookie) {
            return [
                EnvironmentCheck::ERROR,
                "Sessions are being set for {$fullURL} : Set-Cookie => " . $cookie,
            ];
        }
        return [
            EnvironmentCheck::OK,
            "Sessions are not being created for {$fullURL} 👍",
        ];
    }
1218946
public function notFound()
    {
        if (isset($this->request->path_array[1])) {
            switch ($this->request->path_array[1]) {
                case 'methods':
                    return $this->getMethods(true);
                    break;
            }
        }

        return null;
    }
663939
private function checkCookieAuth()
    {
        if (strlen(trim($this->getUsername())) == 0) {
            $this->objConnector->cleanupSession();
            $this->objConnector->refreshSession();
            return false;
        }
        return true;
    }
1097561
public function resetUrl()
    {
        $query = $this->request->getQuery();

        $searchParams = (array)$this->_View->get('_searchParams');
        $query = array_diff_key($query, $searchParams);

        $additionalBlacklist = (array)$this->getConfig('additionalBlacklist');
        foreach ($additionalBlacklist as $param) {
            unset($query[$param]);
        }

        return [
            '?' => $query,
        ];
    }
266591
protected function checkReferer()
    {
        if (!empty($_SERVER['HTTP_REFERER'])) {
            $url = parse_url($_SERVER['HTTP_REFERER']);

            $hostUrl = (array_key_exists('port', $url)) ? $url['host'].':'.$url['port'] : $url['host'];

            if ($hostUrl != $_SERVER['HTTP_HOST']) {
                session_destroy(); // destroy fake session
            }
        }
    }
682440
public function check()
    {
        $urls = $this->getURLs();

        $chs = [];
        foreach ($urls as $url) {
            $ch = curl_init();
            $chs[] = $ch;
            curl_setopt_array($ch, $this->getCurlOpts($url));
        }
        // Parallel execution for faster performance
        $mh = curl_multi_init();
        foreach ($chs as $ch) {
            curl_multi_add_handle($mh, $ch);
        }

        $active = null;
        // Execute the handles
        do {
            $mrc = curl_multi_exec($mh, $active);
            curl_multi_select($mh);
        } while ($active > 0);

        while ($active && $mrc == CURLM_OK) {
            if (curl_multi_select($mh) != -1) {
                do {
                    $mrc = curl_multi_exec($mh, $active);
                } while ($mrc == CURLM_CALL_MULTI_PERFORM);
            }
        }

        $hasError = false;
        $msgs = [];
        foreach ($chs as $ch) {
            $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            if (curl_errno($ch) || $code >= 400) {
                $hasError = true;
                $msgs[] = sprintf(
                    'Error retrieving "%s": %s (Code: %s)',
                    $url,
                    curl_error($ch),
                    $code
                );
            } else {
                $msgs[] = sprintf(
                    'Success retrieving "%s" (Code: %s)',
                    $url,
                    $code
                );
            }
        }

        // Close the handles
        foreach ($chs as $ch) {
            curl_multi_remove_handle($mh, $ch);
        }
        curl_multi_close($mh);

        if ($hasError) {
            return [EnvironmentCheck::ERROR, implode(', ', $msgs)];
        }

        return [EnvironmentCheck::OK, implode(', ', $msgs)];
    }
31157
protected function validateUrl()
    {
        $this->url->convertToHttps();
        return ($this->urlMatchesPattern(array_merge($this->postPatterns, $this->videoPatterns, $this->pagePatterns)));
    }
407083
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        $response = [];
        foreach ($bulletin->getFeedbacks() as $feedback) {
            $response[] = [
                'id' => $feedback->getId(),
                'updatedAt' => $feedback->getUpdatedAt() ? $feedback->getUpdatedAt()->getTimestamp() : null,
                'receiver' => [
                    'id' => $feedback->getReceiver()->getId(),
                    'username' => $feedback->getReceiver()->getUsername(),
                    'name' => $feedback->getReceiver()->getName()
                ],
                'checked' => $feedback->isChecked(),
                'remark' => $feedback->getRemark()
            ];
        }
        return response($response);
    }
313354
public static function check()
    {
        if (Session::exists(static::resource('session'))) {
            return true;
        } elseif (Cookie::existe(static::resource('cookie'))) {
            $token = Cookie::get(static::resource('cookie'));

            $result = Query::from(config('auth.table'))
                ->where('rememberToken', '=', $token)
                ->get();

            if (count($result) > 0) {
                return true;
            }

            return false;
        }

        return false;
    }
481089
protected function notFound()
    {
        $errmsg = sprintf('[%s][%s]method not found: %s:%s. handlers: %s', $this->request->getMethod(), UriHelper::getCurrentUrl(), get_class($this), $this->getLongName(), implode('|', $this->getHandleStack()));
        Ioc::logger('router')->error($errmsg);
        
        $handler = Ioc::get('notFoundHandler');
        return $handler($this->request, $this->response);
    }
707612
protected function validate()
    {
        // Are needed session variables set ?
        if (!isset($_SESSION['s3ss10nCr3at3d']) || !isset($_SESSION['n3k0t'])) {
            return false;
        }

        // Check if session token match ?
        if ($this->matchUserAgent) {
            if ($_SESSION['n3k0t'] !== hash_hmac($this->hashAlgo, $_SERVER['HTTP_USER_AGENT'] . $_SESSION['s3ss10nCr3at3d'], $this->hashKey)) {
                return false;
            }
        } elseif ($_SESSION['n3k0t'] !== hash_hmac($this->hashAlgo, $_SESSION['s3ss10nCr3at3d'], $this->hashKey)) {
            return false;
        }

        // Is session expired ?
        if ((time() > ($_SESSION['s3ss10nCr3at3d']) + $this->expiration)) {
            return false;
        }

        // Everything is fine return true
        return true;
    }
286349
public function checkRegistryRequestsAnswers()
    {
        if (! $this->db instanceof \Zend_Db_Adapter_Abstract) {
            return false;
        }

        $select = $this->db->select();
        $select->from(['nw'=> 'gems__tokens'], [
            'gtrp_id_token_new' => 'gto_id_token',
            'gtrp_created' => 'gto_created',
            'gtrp_created_by' => 'gto_created_by',
            ])->joinInner(
                    ['pr' => 'gems__tokens'],
                    "nw.gto_id_respondent_track = pr.gto_id_respondent_track AND
                     nw.gto_id_round            = pr.gto_id_round AND
                     nw.gto_round_order         = pr.gto_round_order AND
                     nw.gto_created             > pr.gto_created
                     ",
                    ['gtrp_id_token_old' => 'gto_id_token',]
                    )
                ->where('nw.gto_id_token NOT IN (SELECT gtrp_id_token_new FROM gems__token_replacements)')
                ->order('nw.gto_id_token')
                ->order('pr.gto_created');

        $this->_stmt = $this->db->query($select);

        return parent::checkRegistryRequestsAnswers();
    }
814845
public function isAjax()
    {
        if (isset($this->_isAjax)) {
            return $this->_isAjax;
        }
        return $this->_isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
    }
1281963
protected function notFoundResponse()
    {
        $content = ['error' => "Resource not found."];

        return (request()->ajax() || request()->wantsJson())
            ? new JsonResponse($content, 404)
            : new Response($content, 404);
    }
1250553
protected function _passive()
	{
		$match = array();
		$parts = array();
		$errno = null;
		$err = null;

		// Make sure we have a connection to the server
		if (!is_resource($this->conn))
		{
			Log::add(__METHOD__ . ': Not connected to the control port.', Log::WARNING, 'jerror');

			return false;
		}

		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
		@ fwrite($this->conn, "PASV\r\n");

		// Wait for a response from the server, but timeout after the set time limit
		$endTime = time() + $this->timeout;
		$this->response = '';

		do
		{
			$this->response .= fgets($this->conn, 4096);
		}

		while (!preg_match("/^([0-9]{3})(-(.*" . CRLF . ")+\\1)? [^" . CRLF . "]+" . CRLF . "$/", $this->response, $parts) && time() < $endTime);

		// Catch a timeout or bad response
		if (!isset($parts[1]))
		{
			Log::add(
				sprintf(
					'%1$s: Timeout or unrecognised response while waiting for a response from the server. Server response: %2$s',
					__METHOD__, $this->response
				),
				Log::WARNING, 'jerror');

			return false;
		}

		// Separate the code from the message
		$this->_responseCode = $parts[1];
		$this->_responseMsg = $parts[0];

		// If it's not 227, we weren't given an IP and port, which means it failed.
		if ($this->_responseCode != '227')
		{
			Log::add(
				sprintf('%1$s: Unable to obtain IP and port for data transfer. Server response: %2$s', __METHOD__, $this->_responseMsg),
				Log::WARNING, 'jerror'
			);

			return false;
		}

		// Snatch the IP and port information, or die horribly trying...
		if (preg_match('~\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))\)~', $this->_responseMsg, $match) == 0)
		{
			Log::add(sprintf('%1$s: IP and port for data transfer not valid. Server response: %2$s', __METHOD__, $this->_responseMsg), Log::WARNING, 'jerror');

			return false;
		}

		// This is pretty simple - store it for later use ;).
		$this->pasv = array('ip' => $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4], 'port' => $match[5] * 256 + $match[6]);

		// Connect, assuming we've got a connection.
		$this->dataconn = @fsockopen($this->pasv['ip'], $this->pasv['port'], $errno, $err, $this->timeout);

		if (!$this->dataconn)
		{
			Log::add(
				sprintf(
					'%1$s: Could not connect to host %2$s on port %3$s. Socket error number: %4$s and error message: %5$s',
					__METHOD__,
					$this->pasv['ip'],
					$this->pasv['port'],
					$errno,
					$err
				),
				Log::WARNING,
				'jerror'
			);

			return false;
		}

		// Set the timeout for this connection
		socket_set_timeout($this->conn, $this->timeout, 0);

		return true;
	}
497949
public function checkRegistryRequestsAnswers()
    {
        // Make sure \Gems_User_User gets userLoader variable.
        $extras['userLoader'] = $this;

        // Make sure that this code keeps working when _initSession
        // is removed from GemsEscort
        if (! $this->session instanceof \Zend_Session_Namespace) {
            $this->session = new \Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.session');

            $idleTimeout = $this->project->getSessionTimeout();

            $this->session->setExpirationSeconds($idleTimeout);

            $extras['session'] = $this->session;
        }

        $this->addRegistryContainer($extras);
    }
815083
public function inAction()
    {
        $id = $this
            ->request
            ->query
            ->get('id');

        $ids = explode(',', $this
            ->request
            ->query
            ->get('ids'));

        $result = $this
                ->locationProvider
                ->in($id, $ids);

        return $this->createResponseObject(function () use ($result) {
            return ['result' => $result];
        });
    }