Commit 7f0b0d08 authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge changes I8575a507,I9b7277d7,I5dd34049,I0ecb1970,I385b7d17,I5e36183b,Ief0446a1

* changes:
  Updating XML Feed Parser README.Mahara with changes and commit IDs
  Use XPath to find <link> elements (ignore atom:link) (bug #750815) (cherry picked from commit e662d5d9)
  Patching XML Feed Reader 1.0.4 - adding $suppressWarnings fix (bug #750815) (cherry picked from commit 48b8953c)
  Patch from 1.0.3 to 1.0.4 (Bug #750815)
  Upgrade Image_Canvas - 0.3.2 to 0.3.3 (bug #750815)
  Upgrade Archive_Tar - 1.3.3 to 1.3.7 (bug #750815)
  Upgrade PEAR.php - 1.9.0 to 1.9.2 (bug #750815)
parents c02816e4 c5172f50
......@@ -36,7 +36,7 @@
* @author Vincent Blavet <vincent@phpconcept.net>
* @copyright 1997-2008 The Authors
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Tar.php,v 1.43 2008/10/30 17:58:42 dufuz Exp $
* @version CVS: $Id: Tar.php 295988 2010-03-09 08:39:37Z mrook $
* @link http://pear.php.net/package/Archive_Tar
*/
......@@ -50,7 +50,7 @@ define ('ARCHIVE_TAR_END_BLOCK', pack("a512", ''));
* Creates a (compressed) Tar archive
*
* @author Vincent Blavet <vincent@phpconcept.net>
* @version $Revision: 1.43 $
* @version $Revision: 295988 $
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package Archive_Tar
*/
......@@ -86,6 +86,11 @@ class Archive_Tar extends PEAR
*/
var $_temp_tarname='';
/**
* @var string regular expression for ignoring files or directories
*/
var $_ignore_regexp='';
// {{{ constructor
/**
* Archive_Tar Class constructor. This flavour of the constructor only
......@@ -141,7 +146,7 @@ class Archive_Tar extends PEAR
$this->_compress = true;
$this->_compress_type = 'bz2';
} else {
die("Unsupported compression type '$p_compress'\n".
$this->_error("Unsupported compression type '$p_compress'\n".
"Supported types are 'gz' and 'bz2'.\n");
return false;
}
......@@ -157,7 +162,7 @@ class Archive_Tar extends PEAR
PEAR::loadExtension($extname);
}
if (!extension_loaded($extname)) {
die("The extension '$extname' couldn't be found.\n".
$this->_error("The extension '$extname' couldn't be found.\n".
"Please make sure your version of PHP was built ".
"with '$extname' support.\n");
return false;
......@@ -589,6 +594,36 @@ class Archive_Tar extends PEAR
}
// }}}
// {{{ setIgnoreRegexp()
/**
* This method sets the regular expression for ignoring files and directories
* at import, for example:
* $arch->setIgnoreRegexp("#CVS|\.svn#");
* @param string $regexp regular expression defining which files or directories to ignore
* @access public
*/
function setIgnoreRegexp($regexp)
{
$this->_ignore_regexp = $regexp;
}
// }}}
// {{{ setIgnoreList()
/**
* This method sets the regular expression for ignoring all files and directories
* matching the filenames in the array list at import, for example:
* $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool'));
* @param array $list a list of file or directory names to ignore
* @access public
*/
function setIgnoreList($list)
{
$regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list);
$regexp = '#/'.join('$|/', $list).'#';
$this->setIgnoreRegexp($regexp);
}
// }}}
// {{{ _error()
function _error($p_message)
{
......@@ -830,7 +865,7 @@ class Archive_Tar extends PEAR
for ($i=0; $i<$p_len; $i++)
$this->_readBlock();
} else if ($this->_compress_type == 'none')
@fseek($this->_file, ftell($this->_file)+($p_len*512));
@fseek($this->_file, $p_len*512, SEEK_CUR);
else
$this->_error('Unknown or missing compression type ('
.$this->_compress_type.')');
......@@ -882,6 +917,12 @@ class Archive_Tar extends PEAR
if ($v_filename == '')
continue;
// ----- ignore files and directories matching the ignore regular expression
if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/'.$v_filename)) {
$this->_warning("File '$v_filename' ignored");
continue;
}
if (!file_exists($v_filename)) {
$this->_warning("File '$v_filename' does not exist");
continue;
......@@ -1025,34 +1066,44 @@ class Archive_Tar extends PEAR
}
$v_info = lstat($p_filename);
$v_uid = sprintf("%6s ", DecOct($v_info[4]));
$v_gid = sprintf("%6s ", DecOct($v_info[5]));
$v_perms = sprintf("%6s ", DecOct($v_info['mode']));
$v_uid = sprintf("%07s", DecOct($v_info[4]));
$v_gid = sprintf("%07s", DecOct($v_info[5]));
$v_perms = sprintf("%07s", DecOct($v_info['mode'] & 000777));
$v_mtime = sprintf("%11s", DecOct($v_info['mode']));
$v_mtime = sprintf("%011s", DecOct($v_info['mtime']));
$v_linkname = '';
if (@is_link($p_filename)) {
$v_typeflag = '2';
$v_linkname = readlink($p_filename);
$v_size = sprintf("%11s ", DecOct(0));
$v_size = sprintf("%011s", DecOct(0));
} elseif (@is_dir($p_filename)) {
$v_typeflag = "5";
$v_size = sprintf("%11s ", DecOct(0));
$v_size = sprintf("%011s", DecOct(0));
} else {
$v_typeflag = '';
$v_typeflag = '0';
clearstatcache();
$v_size = sprintf("%11s ", DecOct($v_info['size']));
$v_size = sprintf("%011s", DecOct($v_info['size']));
}
$v_magic = '';
$v_magic = 'ustar ';
$v_version = '';
$v_uname = '';
$v_gname = '';
$v_version = ' ';
if (function_exists('posix_getpwuid'))
{
$userinfo = posix_getpwuid($v_info[4]);
$groupinfo = posix_getgrgid($v_info[5]);
$v_uname = $userinfo['name'];
$v_gname = $groupinfo['name'];
}
else
{
$v_uname = '';
$v_gname = '';
}
$v_devmajor = '';
......@@ -1060,7 +1111,7 @@ class Archive_Tar extends PEAR
$v_prefix = '';
$v_binary_data_first = pack("a100a8a8a8a12A12",
$v_binary_data_first = pack("a100a8a8a8a12a12",
$v_reduce_filename, $v_perms, $v_uid,
$v_gid, $v_size, $v_mtime);
$v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12",
......@@ -1084,7 +1135,7 @@ class Archive_Tar extends PEAR
$this->_writeBlock($v_binary_data_first, 148);
// ----- Write the calculated checksum
$v_checksum = sprintf("%6s ", DecOct($v_checksum));
$v_checksum = sprintf("%06s ", DecOct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
$this->_writeBlock($v_binary_data, 8);
......@@ -1107,27 +1158,37 @@ class Archive_Tar extends PEAR
}
if ($p_type == "5") {
$v_size = sprintf("%11s ", DecOct(0));
$v_size = sprintf("%011s", DecOct(0));
} else {
$v_size = sprintf("%11s ", DecOct($p_size));
$v_size = sprintf("%011s", DecOct($p_size));
}
$v_uid = sprintf("%6s ", DecOct($p_uid));
$v_gid = sprintf("%6s ", DecOct($p_gid));
$v_perms = sprintf("%6s ", DecOct($p_perms));
$v_uid = sprintf("%07s", DecOct($p_uid));
$v_gid = sprintf("%07s", DecOct($p_gid));
$v_perms = sprintf("%07s", DecOct($p_perms & 000777));
$v_mtime = sprintf("%11s", DecOct($p_mtime));
$v_linkname = '';
$v_magic = '';
$v_magic = 'ustar ';
$v_version = '';
$v_uname = '';
$v_gname = '';
$v_version = ' ';
if (function_exists('posix_getpwuid'))
{
$userinfo = posix_getpwuid($p_uid);
$groupinfo = posix_getgrgid($p_gid);
$v_uname = $userinfo['name'];
$v_gname = $groupinfo['name'];
}
else
{
$v_uname = '';
$v_gname = '';
}
$v_devmajor = '';
$v_devminor = '';
......@@ -1158,7 +1219,7 @@ class Archive_Tar extends PEAR
$this->_writeBlock($v_binary_data_first, 148);
// ----- Write the calculated checksum
$v_checksum = sprintf("%6s ", DecOct($v_checksum));
$v_checksum = sprintf("%06s ", DecOct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
$this->_writeBlock($v_binary_data, 8);
......@@ -1192,7 +1253,7 @@ class Archive_Tar extends PEAR
$v_prefix = '';
$v_binary_data_first = pack("a100a8a8a8a12A12",
$v_binary_data_first = pack("a100a8a8a8a12a12",
'././@LongLink', 0, 0, 0, $v_size, 0);
$v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12",
$v_typeflag, $v_linkname, $v_magic,
......@@ -1215,7 +1276,7 @@ class Archive_Tar extends PEAR
$this->_writeBlock($v_binary_data_first, 148);
// ----- Write the calculated checksum
$v_checksum = sprintf("%6s ", DecOct($v_checksum));
$v_checksum = sprintf("%06s ", DecOct($v_checksum));
$v_binary_data = pack("a8", $v_checksum);
$this->_writeBlock($v_binary_data, 8);
......@@ -1283,7 +1344,7 @@ class Archive_Tar extends PEAR
}
// ----- Extract the properties
$v_header['filename'] = trim($v_data['filename']);
$v_header['filename'] = $v_data['filename'];
if ($this->_maliciousFilename($v_header['filename'])) {
$this->_error('Malicious .tar detected, file "' . $v_header['filename'] .
'" will not install in desired directory tree');
......@@ -1343,7 +1404,7 @@ class Archive_Tar extends PEAR
}
if (($v_header['size'] % 512) != 0) {
$v_content = $this->_readBlock();
$v_filename .= $v_content;
$v_filename .= trim($v_content);
}
// ----- Read the next header
......
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php 287471 2009-08-18 23:12:01Z clockwerx $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
}
}
/**
* Convert any color-representation into an array of 4 ints (RGBA).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @param string How much each 'step' between the colors we should take.
* @return array Returns an array of all the colors, one element for each color.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php 291771 2009-12-06 17:38:31Z neufeind $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource &$img GD-resource
* @param mixed $color Any color representation supported by color2RGB()
*
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
}
}
/**
* Convert any color-representation into an array of 4 ints (RGBA).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed $color Any color representation supported by Image_Canvas_Color::color2RGB()
*
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color, '%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @param string $degrees How much each 'step' between the colors we should take.
*
* @return array Array of all the colors, one element for each color.
* @access public
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);