X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FCookie.php;h=a67b919f47b280312a8e6715445730745c856212;hp=0fe944443f0ae39cff51b3a45704cf83bf40315d;hb=7065200b036d4bbf0c46f4b236d761a79b57215e;hpb=07707b85aa84d31e758cebc25ece20c35829293c diff --git a/includes/libs/Cookie.php b/includes/libs/Cookie.php index 0fe944443f..a67b919f47 100644 --- a/includes/libs/Cookie.php +++ b/includes/libs/Cookie.php @@ -206,86 +206,3 @@ class Cookie { return $this->isSessionKey || $this->expires > time(); } } - -class CookieJar { - private $cookie = array(); - - /** - * Set a cookie in the cookie jar. Make sure only one cookie per-name exists. - * @see Cookie::set() - * @param string $name - * @param string $value - * @param array $attr - */ - public function setCookie( $name, $value, $attr ) { - /* cookies: case insensitive, so this should work. - * We'll still send the cookies back in the same case we got them, though. - */ - $index = strtoupper( $name ); - - if ( isset( $this->cookie[$index] ) ) { - $this->cookie[$index]->set( $value, $attr ); - } else { - $this->cookie[$index] = new Cookie( $name, $value, $attr ); - } - } - - /** - * @see Cookie::serializeToHttpRequest - * @param string $path - * @param string $domain - * @return string - */ - public function serializeToHttpRequest( $path, $domain ) { - $cookies = array(); - - foreach ( $this->cookie as $c ) { - $serialized = $c->serializeToHttpRequest( $path, $domain ); - - if ( $serialized ) { - $cookies[] = $serialized; - } - } - - return implode( '; ', $cookies ); - } - - /** - * Parse the content of an Set-Cookie HTTP Response header. - * - * @param string $cookie - * @param string $domain Cookie's domain - * @return null - */ - public function parseCookieResponseHeader( $cookie, $domain ) { - $len = strlen( 'Set-Cookie:' ); - - if ( substr_compare( 'Set-Cookie:', $cookie, 0, $len, true ) === 0 ) { - $cookie = substr( $cookie, $len ); - } - - $bit = array_map( 'trim', explode( ';', $cookie ) ); - - if ( count( $bit ) >= 1 ) { - list( $name, $value ) = explode( '=', array_shift( $bit ), 2 ); - $attr = array(); - - foreach ( $bit as $piece ) { - $parts = explode( '=', $piece ); - if ( count( $parts ) > 1 ) { - $attr[strtolower( $parts[0] )] = $parts[1]; - } else { - $attr[strtolower( $parts[0] )] = true; - } - } - - if ( !isset( $attr['domain'] ) ) { - $attr['domain'] = $domain; - } elseif ( !Cookie::validateCookieDomain( $attr['domain'], $domain ) ) { - return null; - } - - $this->setCookie( $name, $value, $attr ); - } - } -}