'Joomla/' . JVERSION); $context = stream_context_create(array( 'http' => $httpopts )); $ih = @fopen($url, 'r', false, $context); } else { // PHP 4 way (actually, it's just a fallback) if ( function_exists('ini_set') ) { ini_set('user_agent', 'Joomla/' . JVERSION); } $ih = @fopen($url, 'r'); } // If fopen() fails, abort if ( !is_resource($ih) ) { return $result; } // Try to download $bytes = 0; $result = true; $return = ''; while (!feof($ih) && $result) { $contents = fread($ih, 4096); if ($contents === false) { @fclose($ih); $result = false; return $result; } else { $bytes += strlen($contents); if (is_resource($fp)) { $result = @fwrite($fp, $contents); } else { $return .= $contents; unset($contents); } } } @fclose($ih); if (is_resource($fp)) { return $result; } elseif ( $result === true ) { return $return; } else { return $result; } } /** * Detect and return available download "adapters" (not really adapters, as * we don't follow the Adapter pattern, yet) * * @return array * * @since 2.5.4 */ private static function getAdapters() { // Detect available adapters $adapters = array(); if (self::hasCURL()) { $adapters[] = 'curl'; } if (self::hasFOPEN()) { $adapters[] = 'fopen'; } return $adapters; } /** * Change the permissions of a file, optionally using FTP * * @param string $path Absolute path to file * @param int $mode Permissions, e.g. 0755 * * @return boolean True on success * * @since 2.5.4 */ private static function chmod($path, $mode) { if (is_string($mode)) { $mode = octdec($mode); if ( ($mode < 0600) || ($mode > 0777) ) { $mode = 0755; } } $ftpOptions = JClientHelper::getCredentials('ftp'); // Check to make sure the path valid and clean $path = JPath::clean($path); if ($ftpOptions['enabled'] == 1) { // Connect the FTP client $ftp = JClientFtp::getInstance( $ftpOptions['host'], $ftpOptions['port'], null, $ftpOptions['user'], $ftpOptions['pass'] ); } if (@chmod($path, $mode)) { $ret = true; } elseif ($ftpOptions['enabled'] == 1) { // Translate path and delete $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); // FTP connector throws an error $ret = $ftp->chmod($path, $mode); } else { return false; } return $ret; } }