Current File : //safe-wp/wp-includes/class-wp-http-encoding.php
<?php
/**
* HTTP API: WP_Http_Encoding class
*
* @package WordPress
* @subpackage HTTP
* @since 4.4.0
*/
/**
* Core class used to implement deflate and gzip transfer encoding support for HTTP requests.
*
* Includes RFC 1950, RFC 1951, and RFC 1952.
*
* @since 2.8.0
*/
#[AllowDynamicProperties]
class WP_Http_Encoding {
/**
* Compress raw string using the deflate format.
*
* Supports the RFC 1951 standard.
*
* @since 2.8.0
*
* @param string $raw String to compress.
* @param int $level Optional. Compression level, 9 is highest. Default 9.
* @param string $supports Optional, not used. When implemented it will choose
* the right compression based on what the server supports.
* @return string|false Compressed string on success, false on failure.
*/
public static function compress( $raw, $level = 9, $supports = null ) {
return gzdeflate( $raw, $level );
}
/**
* Decompression of deflated string.
*
* Will attempt to decompress using the RFC 1950 standard, and if that fails
* then the RFC 1951 standard deflate will be attempted. Finally, the RFC
* 1952 standard gzip decode will be attempted. If all fail, then the
* original compressed string will be returned.
*
* @since 2.8.0
*
* @param string $compressed String to decompress.
* @param int $length The optional length of the compressed data.
* @return string|false Decompressed string on success, false on failure.
*/
public static function decompress( $compressed, $length = null ) {
if ( empty( $compressed ) ) {
return $compressed;
}
$decompressed = @gzinflate( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
$decompressed = self::compatible_gzinflate( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
$decompressed = @gzuncompress( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
if ( function_exists( 'gzdecode' ) ) {
$decompressed = @gzdecode( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
}
return $compressed;
}
/**
* Decompression of deflated string while staying compatible with the majority of servers.
*
* Certain Servers will return deflated data with headers which PHP's gzinflate()
* function cannot handle out of the box. The following function has been created from
* various snippets on the gzinflate() PHP documentation.
*
* Warning: Magic numbers within. Due to the potential different formats that the compressed
* data may be returned in, some "magic offsets" are needed to ensure proper decompression
* takes place. For a simple pragmatic way to determine the magic offset in use, see:
* https://core.trac.wordpress.org/ticket/18273
*
* @since 2.8.1
*
* @link https://core.trac.wordpress.org/ticket/18273
* @link https://www.php.net/manual/en/function.gzinflate.php#70875
* @link https://www.php.net/manual/en/function.gzinflate.php#77336
*
* @param string $gz_data String to decompress.
* @return string|false Decompressed string on success, false on failure.
*/
public static function compatible_gzinflate( $gz_data ) {
// Compressed data might contain a full header, if so strip it for gzinflate().
if ( str_starts_with( $gz_data, "\x1f\x8b\x08" ) ) {
$i = 10;
$flg = ord( substr( $gz_data, 3, 1 ) );
if ( $flg > 0 ) {
if ( $flg & 4 ) {
list($xlen) = unpack( 'v', substr( $gz_data, $i, 2 ) );
$i = $i + 2 + $xlen;
}
if ( $flg & 8 ) {
$i = strpos( $gz_data, "\0", $i ) + 1;
}
if ( $flg & 16 ) {
$i = strpos( $gz_data, "\0", $i ) + 1;
}
if ( $flg & 2 ) {
$i = $i + 2;
}
}
$decompressed = @gzinflate( substr( $gz_data, $i, -8 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
}
// Compressed data from java.util.zip.Deflater amongst others.
$decompressed = @gzinflate( substr( $gz_data, 2 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
return false;
}
/**
* What encoding types to accept and their priority values.
*
* @since 2.8.0
*
* @param string $url
* @param array $args
* @return string Types of encoding to accept.
*/
public static function accept_encoding( $url, $args ) {
$type = array();
$compression_enabled = self::is_available();
if ( ! $args['decompress'] ) { // Decompression specifically disabled.
$compression_enabled = false;
} elseif ( $args['stream'] ) { // Disable when streaming to file.
$compression_enabled = false;
} elseif ( isset( $args['limit_response_size'] ) ) { // If only partial content is being requested, we won't be able to decompress it.
$compression_enabled = false;
}
if ( $compression_enabled ) {
if ( function_exists( 'gzinflate' ) ) {
$type[] = 'deflate;q=1.0';
}
if ( function_exists( 'gzuncompress' ) ) {
$type[] = 'compress;q=0.5';
}
if ( function_exists( 'gzdecode' ) ) {
$type[] = 'gzip;q=0.5';
}
}
/**
* Filters the allowed encoding types.
*
* @since 3.6.0
*
* @param string[] $type Array of what encoding types to accept and their priority values.
* @param string $url URL of the HTTP request.
* @param array $args HTTP request arguments.
*/
$type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args );
return implode( ', ', $type );
}
/**
* What encoding the content used when it was compressed to send in the headers.
*
* @since 2.8.0
*
* @return string Content-Encoding string to send in the header.
*/
public static function content_encoding() {
return 'deflate';
}
/**
* Whether the content be decoded based on the headers.
*
* @since 2.8.0
*
* @param array|string $headers All of the available headers.
* @return bool
*/
public static function should_decode( $headers ) {
if ( is_array( $headers ) ) {
if ( array_key_exists( 'content-encoding', $headers ) && ! empty( $headers['content-encoding'] ) ) {
return true;
}
} elseif ( is_string( $headers ) ) {
return ( stripos( $headers, 'content-encoding:' ) !== false );
}
return false;
}
/**
* Whether decompression and compression are supported by the PHP version.
*
* Each function is tested instead of checking for the zlib extension, to
* ensure that the functions all exist in the PHP version and aren't
* disabled.
*
* @since 2.8.0
*
* @return bool
*/
public static function is_available() {
return ( function_exists( 'gzuncompress' ) || function_exists( 'gzdeflate' ) || function_exists( 'gzinflate' ) );
}
}
Zerion Mini Shell 1.0
Home - Professional Genealogists and Historians - LineagesSkip to content
Our talented staff of professional researchers can help you, whether you have hit a roadblock in your research or simply lack the time or training to tackle it yourself. Plus, our rates are 40% lower than many of our competitors! Check out our sample projects and then pick the research package that best fits your needs!
ENSLAVED PEOPLE & ENSLAVERS
Identifying the men and women who owned your ancestors during slavery requires finely honed skills and years of experience. Our expertise comes from having traced hundreds of African-American family trees. Choose the research package that best fits your needs, and we will start tracing your ancestors back to the slave period and look for their owners.
Genealogy Research that's Insightful, Thorough & Personal
Our staff of amazinggenealogistsand family historians cannot wait to start documenting your ancestry. They will work with you to plan and achieve your research goals.
We will need your help in bringing your ancestors back to life by supplying items not available in public records or online, such as photos, passages from diaries, family stories, unsolved mysteries, and other interesting details.
The end result will be a fun trip down several memory lanes, and you will want to share it with family and friends.
“When Alex Haley prodded me to have my ancestry traced, I reached out to Johni Cerny and she has been my genealogist for 34 years—tracing my African-American roots and the ancestry of many of my close friends. She eternally reminds all of us how we got to this planet. Johni also keeps my soul eternally smiling and nobody does it better!”
Quincy D. Jones
“Thank you, thank you, thank you…for the amazing work you did to identify my biological father. The DNA results were gibberish until you explained it in layman’s terms for me and then used it to find him. Now it is time for you to trace his ancestry. I can’t wait to see the results of that adventure!”
Janet Williamson
“Wow, the research package arrived a few days ago and I can hardly put it down. The report and all those wonderful documents tell an interesting story about my mother’s Graupman ancestors. We will treasure this forever! Let me know what else you can do to trace the Graupman line in German records.”
K. Meyer
“My sister always felt like the odd person out in our family. DNA testing confirmed we were half-siblings. In her late 60s, we didn’t hold out much hope for identifying her biological father. With over 1,000 matches, we turned to Lineages’ staff expert for help. A few months and a lot of hard work, they solved the mystery. Lineages gave my sister the gift of a lifetime. Thank you, Lineages!”
How Your Family Tree Could Make You a Citizen Somewhere in many American family trees is a name followed by a Canadian birthplace: a fishing village in Nova Scotia, a farm township in Ontario, a parish along the St. Lawrence River. Maybe it belongs to a great-grandmother who crossed into Michigan as a young woman…
Imagine sitting down with a photograph of a document that has stumped your family for three generations. It is a baptismal register from a village church, the ink faded to a whisper, the words looping across the page in a script that seems indecipherable. Previously, you could hire a specialist, spend months teaching yourself the…
What an immigrant’s disappearance taught me about the limits of records, the value of living relatives, and why some answers only exist in family memory. The ancestor in this story happened to be Swedish; the story itself is one that almost every immigrant family carries. Öckerö parish husförhörslängd AIIa:5 (1916–1938), Image 1490, Page 140 —…
For half a century, Price Genealogy has done more than just look at census records and birth certificates; we’ve listened to the echoes of the past to tell the stories that define your present As we celebrate our golden anniversary, we look back at five decades of unmatched expertise, and more importantly, look forward to…
Description: French soldier in service uniform Date: 1914 Library of Congress, public domain. If you have recent French ancestors, there’s a good chance they appear in one of the most useful record sets you may not be using: the Registres de Matricule, or Military Conscription Registers. Starting in the late 19th century, every young man…
Insights from 50 Years of Professional Genealogy Your ancestors are from a country outside of the United States – now what? If your ancestors are from European countries such as the United Kingdom, Scandinavia, Germany, France, Switzerland, Spain, Italy, or even Latin American countries such as Mexico and Brazil, you may be able to find…
What better way to honor the 250th birthday of the United States of America than by discovering and recognizing your family’s contributions to the foundation of the United States. Lineage societies offer an interesting opportunity to recognize those past contributions and to participate in activities today that will give our descendants reason to celebrate in…
For fifty years, Price Genealogy has had the privilege of walking alongside families as they uncover their roots. While our company name appears on every report, it’s our researchers who bring each story to life. Behind every carefully crafted report, every breakthrough discovery, and every long-awaited answer is a dedicated researcher who truly cares about…
The journey of a master genealogist often begins not in a grand archive, but in the quiet corners of a family home. For Richard Price, that journey began in 1962. Like many young teenagers, Richard was naturally curious, but the discovery of an old file drawer of family memorabilia in his grandfather’s garage, transformed a…
Understanding Pedigree Collapse A typical family tree looks like this, with you at the bottom and spreading out vertically as your ancestors multiply, from 2 parents, to 4 grandparents, 8 great grandparents, 16 great grandparents, and so on. But probably at some point for all of us a portion of our tree resembles more of…