Resolved issue 0000712: PWG-ERROR-VERSION on remote synchronization
Merge branch-1_7 2211:2212 into BSF git-svn-id: http://piwigo.org/svn/trunk@2213 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
8b69393986
commit
158ab645e7
3 changed files with 83 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
|
@ -124,6 +124,7 @@ if (!defined('PHPWG_INSTALLED'))
|
|||
foreach( array(
|
||||
'array_intersect_key', //PHP 5 >= 5.1.0RC1
|
||||
'hash_hmac', //(hash) - enabled by default as of PHP 5.1.2
|
||||
'preg_last_error', // PHP 5 >= 5.2.0
|
||||
) as $func)
|
||||
{
|
||||
if (!function_exists($func))
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Revision$
|
||||
|
@ -65,7 +65,7 @@ function encodeAttribute( $attribute, $value )
|
|||
{
|
||||
return $attribute.'="'.htmlspecialchars($value, ENT_QUOTES).'" ';
|
||||
}
|
||||
|
||||
|
||||
// The function getChild returns the first child
|
||||
// exemple : getChild( "<table><tr>XXX</tr><tr>YYY</tr></table>", "tr" )
|
||||
// returns "<tr>XXX</tr>"
|
||||
|
@ -74,8 +74,19 @@ function getChild( $document, $node )
|
|||
$regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*';
|
||||
$regex.= '(\s*\/>|>.*<\/'.$node.'>)/U';
|
||||
|
||||
preg_match( $regex, $document, $out );
|
||||
return $out[0];
|
||||
if
|
||||
(
|
||||
preg_match( $regex, $document, $out )
|
||||
or
|
||||
preg_last_error() == PREG_NO_ERROR
|
||||
)
|
||||
{
|
||||
return $out[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
die('getChild: error ['.preg_last_error().'] with preg_match function');
|
||||
}
|
||||
}
|
||||
|
||||
// getChildren returns a list of the children identified by the $node
|
||||
|
@ -89,14 +100,31 @@ function getChildren( $document, $node )
|
|||
$regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*';
|
||||
$regex.= '(\s*\/>|>.*<\/'.$node.'>)/U';
|
||||
|
||||
preg_match_all( $regex, $document, $out );
|
||||
return $out[0];
|
||||
if
|
||||
(
|
||||
preg_match_all( $regex, $document, $out )
|
||||
or
|
||||
preg_last_error() == PREG_NO_ERROR
|
||||
)
|
||||
{
|
||||
return $out[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
die('getChild: error ['.preg_last_error().'] with preg_match_all function');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// get_CodeXML places the content of a text file in a PHP variable and
|
||||
// return it. If the file can't be opened, returns false.
|
||||
function getXmlCode( $filename )
|
||||
{
|
||||
if (function_exists('ini_set'))
|
||||
{
|
||||
// limit must be growed with php5 and "big" listing file
|
||||
ini_set("pcre.backtrack_limit", pow(2, 32));
|
||||
}
|
||||
|
||||
$file = fopen( $filename, 'r' );
|
||||
if ( !$file )
|
||||
{
|
||||
|
|
45
include/php_compat/preg_last_error.php
Normal file
45
include/php_compat/preg_last_error.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Revision$
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// http://www.php.net/manual/fr/function.preg-last-error.php
|
||||
// PHP 5 >= 5.2.0
|
||||
if (!defined('PREG_NO_ERROR'))
|
||||
define('PREG_NO_ERROR', 0);
|
||||
if (!defined('PREG_INTERNAL_ERROR'))
|
||||
define('PREG_INTERNAL_ERROR', 1);
|
||||
if (!defined('PREG_BACKTRACK_LIMIT_ERROR'))
|
||||
define('PREG_BACKTRACK_LIMIT_ERROR', 2);
|
||||
if (!defined('PREG_RECURSION_LIMIT_ERROR'))
|
||||
define('PREG_RECURSION_LIMIT_ERROR', 3);
|
||||
if (!defined('PREG_BAD_UTF8_ERROR'))
|
||||
define('PREG_BAD_UTF8_ERROR', 4);
|
||||
|
||||
function preg_last_error()
|
||||
{
|
||||
return PREG_NO_ERROR;
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue