home/theblueo/tv/wp-includes/SimplePie/Cache/File.php000060400000010510152100561600016435 0ustar00location = $location; $this->filename = $name; $this->extension = $type; $this->name = "$this->location/$this->filename.$this->extension"; } /** * Save data to the cache * * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property * @return bool Successfulness */ public function save($data) { if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) { if ($data instanceof SimplePie) { $data = $data->data; } $data = serialize($data); return (bool) file_put_contents($this->name, $data); } return false; } /** * Retrieve the data saved to the cache * * @return array Data for SimplePie::$data */ public function load() { if (file_exists($this->name) && is_readable($this->name)) { return unserialize(file_get_contents($this->name)); } return false; } /** * Retrieve the last modified time for the cache * * @return int Timestamp */ public function mtime() { if (file_exists($this->name)) { return filemtime($this->name); } return false; } /** * Set the last modified time to the current time * * @return bool Success status */ public function touch() { if (file_exists($this->name)) { return touch($this->name); } return false; } /** * Remove the cache * * @return bool Success status */ public function unlink() { if (file_exists($this->name)) { return unlink($this->name); } return false; } } home/theblueo/www/wp-content/plugins/loco-translate/src/fs/File.php000064400000031415152133014270021426 0ustar00setPath( $path ); } /** * Internally set path value and flag whether relative or absolute */ private function setPath( $path ){ $path = (string) $path; if( $fixed = self::abs($path) ){ $path = $fixed; $this->rel = false; } else { $this->rel = true; } if( $path !== $this->path ){ $this->path = $path; $this->info = null; } return $path; } /** * @return array */ public function isAbsolute(){ return ! $this->rel; } /** * @internal */ public function __clone(){ $this->cloneWriteContext( $this->w ); } /** * Copy write context with oursel * @return */ private function cloneWriteContext( Loco_fs_FileWriter $context = null ){ if( $context ){ $context = clone $context; $this->w = $context->setFile($this); } return $this; } /** * Get file system context for operations that *modify* the file system. * Read operations and operations that stat the file will always do so directly. * @return Loco_fs_FileWriter */ public function getWriteContext(){ if( ! $this->w ){ $this->w = new Loco_fs_FileWriter( $this ); } return $this->w; } /** * @internal */ private function pathinfo(){ return is_array($this->info) ? $this->info : ( $this->info = pathinfo($this->path) ); } /** * @return bool */ public function exists(){ return file_exists( $this->path ); } /** * @return bool */ public function writable(){ return $this->getWriteContext()->writable(); } /** * @return bool */ public function deletable(){ $parent = $this->getParent(); if( $parent && $parent->writable() ){ // sticky directory requires that either the file its parent is owned by effective user if( $parent->mode() & 01000 ){ $writer = $this->getWriteContext(); if( $writer->isDirect() && ( $uid = Loco_compat_PosixExtension::getuid() ) ){ return $uid === $this->uid() || $uid === $parent->uid(); } // else delete operation won't be done directly, so can't pre-empt sticky problems // TODO is it worth comparing FTP username etc.. for ownership? } // defaulting to "deletable" based on fact that parent is writable. return true; } return false; } /** * Get owner uid * @return int */ public function uid(){ return fileowner($this->path); } /** * Get group gid * @return int */ public function gid(){ return filegroup($this->path); } /** * Check if file can't be overwitten when existant, nor created when non-existant * This does not check permissions recursively as directory trees are not built implicitly * @return bool */ public function locked(){ if( $this->exists() ){ return ! $this->writable(); } if( $dir = $this->getParent() ){ return ! $dir->writable(); } return true; } /** * Check if full path can be built to non-existant file. * @return bool */ public function creatable(){ $file = $this; while( $file = $file->getParent() ){ if( $file->exists() ){ return $file->writable(); } } return false; } /** * @return string */ public function dirname(){ $info = $this->pathinfo(); return $info['dirname']; } /** * @return string */ public function basename(){ $info = $this->pathinfo(); return $info['basename']; } /** * @return string */ public function filename(){ $info = $this->pathinfo(); return $info['filename']; } /** * @return string */ public function extension(){ $info = $this->pathinfo(); return isset($info['extension']) ? $info['extension'] : ''; } /** * @return string */ public function getPath(){ return $this->path; } /** * @return int */ public function modified(){ return filemtime( $this->path ); } /** * @return int */ public function size(){ return filesize( $this->path ); } /** * @return int */ public function mode(){ if( is_link($this->path) ){ $stat = lstat( $this->path ); $mode = $stat[2]; } else { $mode = fileperms($this->path); } return $mode; } /** * Set file mode * @return Loco_fs_File */ public function chmod( $mode, $recursive = false ){ $this->getWriteContext()->chmod( $mode, $recursive ); return $this->clearStat(); } /** * Clear stat cache if any file data has changed * @return Loco_fs_File */ public function clearStat(){ $this->info = null; // PHP 5.3.0 Added optional clear_realpath_cache and filename parameters. if( version_compare( PHP_VERSION, '5.3.0', '>=' ) ){ clearstatcache( true, $this->path ); } // else no choice but to drop entire stat cache else { clearstatcache(); } return $this; } /** * @return string */ public function __toString(){ return $this->getPath(); } /** * Check if passed path is equal to ours * @param string * @return bool */ public function equal( $path ){ return $this->path === (string) $path; } /** * Normalize path for string comparison, resolves redundant dots and slashes. * @param string path to prefix * @return string */ public function normalize( $base = '' ){ if( $path = self::abs($base) ){ $base = $path; } if( $base !== $this->base ){ $path = $this->path; if( '' === $path ){ $this->setPath($base); } else { if( ! $this->rel || ! $base ){ $b = array(); } else { $b = self::explode( $base, array() ); } $b = self::explode( $path, $b ); $this->setPath( implode('/',$b) ); } $this->base = $base; } return $this->path; } /** * */ private static function explode( $path, array $b ){ $a = explode( '/', $path ); foreach( $a as $i => $s ){ if( '' === $s ){ if( 0 !== $i ){ continue; } } if( '.' === $s ){ continue; } if( '..' === $s ){ if( array_pop($b) ){ continue; } } $b[] = $s; } return $b; } /** * Get path relative to given location, unless path is already relative * @return string */ public function getRelativePath( $base ){ $path = $this->normalize(); if( $abspath = self::abs($path) ){ // base may needs require normalizing $file = new Loco_fs_File($base); $base = $file->normalize(); $length = strlen($base); // if we are below given base path, return ./relative if( substr($path,0,$length) === $base ){ ++$length; if( isset($path{$length}) ){ return substr( $path, $length ); } // else paths were idenitcal return ''; } // else attempt to find nearest common root $i = 0; $source = explode('/',$base); $target = explode('/',$path); while( isset($source[$i]) && isset($target[$i]) && $source[$i] === $target[$i] ){ $i++; } if( $i > 1 ){ $depth = count($source) - $i; $build = array_merge( array_fill( 0, $depth, '..' ), array_slice( $target, $i ) ); $path = implode( '/', $build ); } } // else return unmodified return $path; } /** * @return bool */ public function isDirectory(){ if( file_exists($this->path) ){ return is_dir($this->path); } return ! $this->extension(); } /** * Load contents of file into a string * @return string */ public function getContents(){ return file_get_contents( $this->path ); } /** * Check if path is under a theme directory * @return bool */ public function underThemeDirectory(){ return Loco_fs_Locations::getThemes()->check( $this->path ); } /** * Check if path is under a plugin directory * @return bool */ public function underPluginDirectory(){ return Loco_fs_Locations::getPlugins()->check( $this->path ); } /** * Check if path is under a global system directory * @return bool */ public function underGlobalDirectory(){ return Loco_fs_Locations::getGlobal()->check( $this->path ); } /** * @return Loco_fs_Directory */ public function getParent(){ $path = $this->dirname(); if( '.' !== $path && $this->path !== $path ){ $dir = new Loco_fs_Directory( $path ); $dir->cloneWriteContext( $this->w ); return $dir; } } /** * Copy this file for real * @throws Loco_error_Exception * @return Loco_fs_File new file */ public function copy( $dest ){ $copy = clone $this; $copy->path = $dest; $copy->clearStat(); $this->getWriteContext()->copy( $copy ); return $copy; } /** * Delete this file for real * @throws Loco_error_Exception * @return Loco_fs_File */ public function unlink(){ $recursive = $this->isDirectory(); $this->getWriteContext()->delete( $recursive ); return $this->clearStat(); } /** * Copy this object with an alternative file extension * @return Loco_fs_File */ public function cloneExtension( $ext ){ $snip = strlen( $this->extension() ); $file = clone $this; if( $snip ){ $file->path = substr_replace( $this->path, $ext, - $snip ); } else { $file->path .= '.'.$ext; } $file->info = null; return $file; } /** * Ensure full parent directory tree exists * @return Loco_fs_Directory */ public function createParent(){ if( $dir = $this->getParent() ){ if( ! $dir->exists() ){ $dir->mkdir(); } } return $dir; } /** * @return int bytes written to file */ public function putContents( $data ){ $this->getWriteContext()->putContents($data); $this->clearStat(); return $this->size(); } }home/theblueo/www/wp-includes/SimplePie/File.php000060400000022716152133240700015641 0ustar00encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); } $this->url = $url; $this->useragent = $useragent; if (preg_match('/^http(s)?:\/\//i', $url)) { if ($useragent === null) { $useragent = ini_get('user_agent'); $this->useragent = $useragent; } if (!is_array($headers)) { $headers = array(); } if (!$force_fsockopen && function_exists('curl_exec')) { $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; $fp = curl_init(); $headers2 = array(); foreach ($headers as $key => $value) { $headers2[] = "$key: $value"; } if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) { curl_setopt($fp, CURLOPT_ENCODING, ''); } curl_setopt($fp, CURLOPT_URL, $url); curl_setopt($fp, CURLOPT_HEADER, 1); curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($fp, CURLOPT_REFERER, $url); curl_setopt($fp, CURLOPT_USERAGENT, $useragent); curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) { curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); } $this->headers = curl_exec($fp); if (curl_errno($fp) === 23 || curl_errno($fp) === 61) { curl_setopt($fp, CURLOPT_ENCODING, 'none'); $this->headers = curl_exec($fp); } if (curl_errno($fp)) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); $this->success = false; } else { $info = curl_getinfo($fp); curl_close($fp); $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); $this->headers = array_pop($this->headers); $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) { $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { $this->redirects++; $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); } } } } else { $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; $url_parts = parse_url($url); $socket_host = $url_parts['host']; if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { $socket_host = "ssl://$url_parts[host]"; $url_parts['port'] = 443; } if (!isset($url_parts['port'])) { $url_parts['port'] = 80; } $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout); if (!$fp) { $this->error = 'fsockopen error: ' . $errstr; $this->success = false; } else { stream_set_timeout($fp, $timeout); if (isset($url_parts['path'])) { if (isset($url_parts['query'])) { $get = "$url_parts[path]?$url_parts[query]"; } else { $get = $url_parts['path']; } } else { $get = '/'; } $out = "GET $get HTTP/1.1\r\n"; $out .= "Host: $url_parts[host]\r\n"; $out .= "User-Agent: $useragent\r\n"; if (extension_loaded('zlib')) { $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; } if (isset($url_parts['user']) && isset($url_parts['pass'])) { $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; } foreach ($headers as $key => $value) { $out .= "$key: $value\r\n"; } $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); $info = stream_get_meta_data($fp); $this->headers = ''; while (!$info['eof'] && !$info['timed_out']) { $this->headers .= fread($fp, 1160); $info = stream_get_meta_data($fp); } if (!$info['timed_out']) { $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) { $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { $this->redirects++; $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); } if (isset($this->headers['content-encoding'])) { // Hey, we act dumb elsewhere, so let's do that here too switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) { case 'gzip': case 'x-gzip': $decoder = new SimplePie_gzdecode($this->body); if (!$decoder->parse()) { $this->error = 'Unable to decode HTTP "gzip" stream'; $this->success = false; } else { $this->body = $decoder->data; } break; case 'deflate': if (($decompressed = gzinflate($this->body)) !== false) { $this->body = $decompressed; } else if (($decompressed = gzuncompress($this->body)) !== false) { $this->body = $decompressed; } else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) { $this->body = $decompressed; } else { $this->error = 'Unable to decode HTTP "deflate" stream'; $this->success = false; } break; default: $this->error = 'Unknown content coding'; $this->success = false; } } } } else { $this->error = 'fsocket timed out'; $this->success = false; } fclose($fp); } } } else { $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; if (!$this->body = file_get_contents($url)) { $this->error = 'file_get_contents could not read the file'; $this->success = false; } } } }