[Résolu]Warning: preg_replace_callback(): Requires argument 2

Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
#1
Citation :#~~~~~ DEBUT BLOC A NE PAS SUPPRIMER ~~~~~
#~ Version du CMS: 1.11.10
#~ Url du site :
#~ Hébergeur / Soft : EasyPHP
#~ Informations Système :
#~ ----------------------------------------------
#~ Cms Version: 1.11.11
#~ Installed Modules:
#~ CMSMailer: 5.2.2
#~ CMSPrinting: 1.0.5
#~ FileManager: 1.4.5
#~ MenuManager: 1.8.6
#~ MicroTiny: 1.2.7
#~ ModuleManager: 1.5.8
#~ News: 2.14.4
#~ Search: 1.7.11
#~ ThemeManager: 1.1.8
#~ Config Information:
#~ php_memory_limit:
#~ process_whole_template:
#~ max_upload_size: 2000000
#~ url_rewriting: none
#~ page_extension:
#~ query_var: page
#~ image_manipulation_prog: GD
#~ auto_alias_content: true
#~ locale:
#~ default_encoding: utf-8
#~ admin_encoding: utf-8
#~ set_names: true
#~ Php Information:
#~ phpversion: 5.5.8
#~ md5_function: On (Vrai)
#~ gd_version: 2
#~ tempnam_function: On (Vrai)
#~ magic_quotes_runtime: Off (Faux)
#~ E_STRICT: 2048
#~ E_DEPRECATED: 8192
#~ memory_limit: 128M
#~ max_execution_time: 30
#~ output_buffering: 4096
#~ safe_mode: Off (Faux)
#~ file_uploads: On (Vrai)
#~ post_max_size: 8M
#~ upload_max_filesize: 2M
#~ session_save_path: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\tmp (0777)
#~ session_use_cookies: On (Vrai)
#~ xml_function: On (Vrai)
#~ xmlreader_class: On (Vrai)
#~ Server Information:
#~ Server Api: apache2handler
#~ Server Db Type: MySQL (mysqli)
#~ Server Db Version: 5.6.15
#~ Server Db Grants: Trouvé un privilège "GRANT ALL" qui semble être adapté
#~ Server Time Diff: Aucune différence de date du système de fichiers trouvées
#~ ----------------------------------------------
#~~~~~ FIN BLOC A NE PAS SUPPRIMER ~~~~~



Bonjour à tous,

Attention ma version est 11.11.11 et 11.11.10

Je viens d'installer CMSMS en local sous EasyPHP.
Tout a bien l'air de fonctionner, sauf deux lignes d'erreurs se répétant plusieurs fois quand j'affiche Contenu>pages dans l'admin.

Code :
Warning: preg_replace_callback(): Requires argument 2, '_code2utf8(\1)', to be a valid callback in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\farwell\lib\html_entity_decode_utf8.php on line 38

Warning: preg_replace_callback(): Requires argument 2, '_code2utf8(\1)', to be a valid callback in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\farwell\lib\html_entity_decode_utf8.php on line 39

Comme demandé j'ai bien modifié le fichier "html_entity_decode_utf8.php" aux lignes 38 et 39.

Code :
#CMS - CMS Made Simple
#(c)2004-2010 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://www.cmsmadesimple.org
#
# Code copied from http://www.php.net/manual/en/function.html-entity-decode.php
#
#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; either version 2 of the License, or
#(at your option) any later version.
#
#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
#
#$Id: html_entity_decode_utf8.php 7396 2011-09-15 12:57:25Z rolf1 $

/**
* @package CMS
*/

/**
* A function to decode utf8 entities in a string
*
* @param string The input string
* @param boolean Should single quotes be converted
* @return string The converted string
*/
function cms_html_entity_decode_utf8( $string, $convert_single_quotes = false )
{
    static $trans_tbl;
    //replace numeric entities

/** Repère des lignes 38/39 --- cette ligne n'est pas dans le code, juste ici comme repère */

    $string = preg_replace_callback('~&#x0*([0-9a-f]+);~ei', '_code2utf8(\1)', $string);    
        $string = preg_replace_callback('~&#0*([0-9]+);~e', '_code2utf8(\1)', $string);


    //replace literal entities
    if (!isset($trans_tbl))
    {
        $trans_tbl=array();
        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
            $trans_tbl[$key] = utf8_encode($val);
    }
    $decode = strtr($string, $trans_tbl);
    if($convert_single_quotes) $decode = str_replace("'", "\'", $decode);

    return $decode;
}

/**
* Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv)
*
* @ignore
* @access private
* @param int The unicode value
* @return string UTF string
*/
function _code2utf8( $num )
{
    if($num < 0) return '';
    if($num < 128) return chr($num);

    //Removing / Replacing Windows Illegals Characters
    if($num < 160)
    {
        switch ($num)
        {
            case 128: $num=8364; break;
            case 129: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 130: $num=8218; break;
            case 131: $num=402;  break;
            case 132: $num=8222; break;
            case 133: $num=8230; break;
            case 134: $num=8224; break;
            case 135: $num=8225; break;
            case 136: $num=710;  break;
            case 137: $num=8240; break;
            case 138: $num=352;  break;
            case 139: $num=8249; break;
            case 140: $num=338;  break;
            case 141: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 142: $num=381;  break;
            case 143: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 144: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 145: $num=8216; break;
            case 146: $num=8217; break;
            case 147: $num=8220; break;
            case 148: $num=8221; break;
            case 149: $num=8226; break;
            case 150: $num=8211; break;
            case 151: $num=8212; break;
            case 152: $num=732;  break;
            case 153: $num=8482; break;
            case 154: $num=353;  break;
            case 155: $num=8250; break;
            case 156: $num=339;  break;
            case 157: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 158: $num=382;  break;
            case 159: $num=376;  break;
        }
    }

    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    return '';
}
?>

Sauvé le fichier, vider le cache, et même redémarré Easyphp. Mais rien ne change : toujours la même erreur.
Aussi je vois bien les infos dans Administration du site>Informations système, mais je ne sais pas ou aller les modifier.

J'espère me conformer à votre charte, c'est mon premier post et je suis débutant.
Merci de votre aide et bonne soirée à tous.
#1
Citation :#~~~~~ DEBUT BLOC A NE PAS SUPPRIMER ~~~~~
#~ Version du CMS: 1.11.10
#~ Url du site :
#~ Hébergeur / Soft : EasyPHP
#~ Informations Système :
#~ ----------------------------------------------
#~ Cms Version: 1.11.11
#~ Installed Modules:
#~ CMSMailer: 5.2.2
#~ CMSPrinting: 1.0.5
#~ FileManager: 1.4.5
#~ MenuManager: 1.8.6
#~ MicroTiny: 1.2.7
#~ ModuleManager: 1.5.8
#~ News: 2.14.4
#~ Search: 1.7.11
#~ ThemeManager: 1.1.8
#~ Config Information:
#~ php_memory_limit:
#~ process_whole_template:
#~ max_upload_size: 2000000
#~ url_rewriting: none
#~ page_extension:
#~ query_var: page
#~ image_manipulation_prog: GD
#~ auto_alias_content: true
#~ locale:
#~ default_encoding: utf-8
#~ admin_encoding: utf-8
#~ set_names: true
#~ Php Information:
#~ phpversion: 5.5.8
#~ md5_function: On (Vrai)
#~ gd_version: 2
#~ tempnam_function: On (Vrai)
#~ magic_quotes_runtime: Off (Faux)
#~ E_STRICT: 2048
#~ E_DEPRECATED: 8192
#~ memory_limit: 128M
#~ max_execution_time: 30
#~ output_buffering: 4096
#~ safe_mode: Off (Faux)
#~ file_uploads: On (Vrai)
#~ post_max_size: 8M
#~ upload_max_filesize: 2M
#~ session_save_path: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\tmp (0777)
#~ session_use_cookies: On (Vrai)
#~ xml_function: On (Vrai)
#~ xmlreader_class: On (Vrai)
#~ Server Information:
#~ Server Api: apache2handler
#~ Server Db Type: MySQL (mysqli)
#~ Server Db Version: 5.6.15
#~ Server Db Grants: Trouvé un privilège "GRANT ALL" qui semble être adapté
#~ Server Time Diff: Aucune différence de date du système de fichiers trouvées
#~ ----------------------------------------------
#~~~~~ FIN BLOC A NE PAS SUPPRIMER ~~~~~



Bonjour à tous,

Attention ma version est 11.11.11 et 11.11.10

Je viens d'installer CMSMS en local sous EasyPHP.
Tout a bien l'air de fonctionner, sauf deux lignes d'erreurs se répétant plusieurs fois quand j'affiche Contenu>pages dans l'admin.

Code :
Warning: preg_replace_callback(): Requires argument 2, '_code2utf8(\1)', to be a valid callback in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\farwell\lib\html_entity_decode_utf8.php on line 38

Warning: preg_replace_callback(): Requires argument 2, '_code2utf8(\1)', to be a valid callback in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\farwell\lib\html_entity_decode_utf8.php on line 39

Comme demandé j'ai bien modifié le fichier "html_entity_decode_utf8.php" aux lignes 38 et 39.

Code :
#CMS - CMS Made Simple
#(c)2004-2010 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://www.cmsmadesimple.org
#
# Code copied from http://www.php.net/manual/en/function.html-entity-decode.php
#
#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; either version 2 of the License, or
#(at your option) any later version.
#
#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
#
#$Id: html_entity_decode_utf8.php 7396 2011-09-15 12:57:25Z rolf1 $

/**
* @package CMS
*/

/**
* A function to decode utf8 entities in a string
*
* @param string The input string
* @param boolean Should single quotes be converted
* @return string The converted string
*/
function cms_html_entity_decode_utf8( $string, $convert_single_quotes = false )
{
    static $trans_tbl;
    //replace numeric entities

/** Repère des lignes 38/39 --- cette ligne n'est pas dans le code, juste ici comme repère */

    $string = preg_replace_callback('~&#x0*([0-9a-f]+);~ei', '_code2utf8(\1)', $string);    
        $string = preg_replace_callback('~&#0*([0-9]+);~e', '_code2utf8(\1)', $string);


    //replace literal entities
    if (!isset($trans_tbl))
    {
        $trans_tbl=array();
        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
            $trans_tbl[$key] = utf8_encode($val);
    }
    $decode = strtr($string, $trans_tbl);
    if($convert_single_quotes) $decode = str_replace("'", "\'", $decode);

    return $decode;
}

/**
* Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv)
*
* @ignore
* @access private
* @param int The unicode value
* @return string UTF string
*/
function _code2utf8( $num )
{
    if($num < 0) return '';
    if($num < 128) return chr($num);

    //Removing / Replacing Windows Illegals Characters
    if($num < 160)
    {
        switch ($num)
        {
            case 128: $num=8364; break;
            case 129: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 130: $num=8218; break;
            case 131: $num=402;  break;
            case 132: $num=8222; break;
            case 133: $num=8230; break;
            case 134: $num=8224; break;
            case 135: $num=8225; break;
            case 136: $num=710;  break;
            case 137: $num=8240; break;
            case 138: $num=352;  break;
            case 139: $num=8249; break;
            case 140: $num=338;  break;
            case 141: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 142: $num=381;  break;
            case 143: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 144: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 145: $num=8216; break;
            case 146: $num=8217; break;
            case 147: $num=8220; break;
            case 148: $num=8221; break;
            case 149: $num=8226; break;
            case 150: $num=8211; break;
            case 151: $num=8212; break;
            case 152: $num=732;  break;
            case 153: $num=8482; break;
            case 154: $num=353;  break;
            case 155: $num=8250; break;
            case 156: $num=339;  break;
            case 157: $num=160;  break; //(Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
            case 158: $num=382;  break;
            case 159: $num=376;  break;
        }
    }

    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    return '';
}
?>

Sauvé le fichier, vider le cache, et même redémarré Easyphp. Mais rien ne change : toujours la même erreur.
Aussi je vois bien les infos dans Administration du site>Informations système, mais je ne sais pas ou aller les modifier.

J'espère me conformer à votre charte, c'est mon premier post et je suis débutant.
Merci de votre aide et bonne soirée à tous.
#2
tu es en PHp 5.5.8 et :
preg_replace(): The /e modifier is deprecated, (depuis 5.5.0 : Le modificateur /e est obsolète)

il faut remplacer les lignes d'origine /lib/html_entity_decode_utf8.php
$string = preg_replace('~&#x0*([0-9a-f]+);~ei', '_code2utf8(hexdec("\\1"))', $string);
$string = preg_replace('~&#0*([0-9]+);~e', '_code2utf8(\\1)', $string);
Par les ligne suivantes
$string = preg_replace('~&#x0*([0-9a-f]+);~i', '_code2utf8(hexdec("\\1"))', $string);
$string = preg_replace('~&#0*([0-9]+);~', '_code2utf8(\\1)', $string);
pour le moment en simplifiant Wink

il faut aussi modifier
/lib/html_entity_decode_php4.php en ligne 306 et 307

je vais signaler le problème

Sinon
modif à faire (A tester...)
/lib/html_entity_decode_utf8.php
Code :
    //replace numeric entities
    /*
    $string = preg_replace('~&#x0*([0-9a-f]+);~ei', '_code2utf8(hexdec("\\1"))', $string);
    $string = preg_replace('~&#0*([0-9]+);~e', '_code2utf8(\\1)', $string);
    */
    $string = preg_replace_callback('~&#x([0-9a-f]+);~i',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $string);
    $string = preg_replace_callback('~&#([0-9]+);~',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $string);
/lib/html_entity_decode_php4.php
Code :
    /*
    $return_text = strtr($text_to_convert, $htmlentities_table);
    $return_text = preg_replace('~&#x([0-9a-f]+);~ei', 'code_to_utf8(hexdec("\\1"))', $return_text);
    $return_text = preg_replace('~&#([0-9]+);~e', 'code_to_utf8("\\1")', $return_text);
    return $return_text;
    */
    $return_text = strtr($text_to_convert, $htmlentities_table);
    $return_text = preg_replace_callback('~&#x([0-9a-f]+);~i',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $return_text);
    $return_text = preg_replace_callback('~&#([0-9]+);~',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $return_text);
    return $return_text;
J-C Etiemble v 2.2.xx
#2
tu es en PHp 5.5.8 et :
preg_replace(): The /e modifier is deprecated, (depuis 5.5.0 : Le modificateur /e est obsolète)

il faut remplacer les lignes d'origine /lib/html_entity_decode_utf8.php
$string = preg_replace('~&#x0*([0-9a-f]+);~ei', '_code2utf8(hexdec("\\1"))', $string);
$string = preg_replace('~&#0*([0-9]+);~e', '_code2utf8(\\1)', $string);
Par les ligne suivantes
$string = preg_replace('~&#x0*([0-9a-f]+);~i', '_code2utf8(hexdec("\\1"))', $string);
$string = preg_replace('~&#0*([0-9]+);~', '_code2utf8(\\1)', $string);
pour le moment en simplifiant Wink

il faut aussi modifier
/lib/html_entity_decode_php4.php en ligne 306 et 307

je vais signaler le problème

Sinon
modif à faire (A tester...)
/lib/html_entity_decode_utf8.php
Code :
    //replace numeric entities
    /*
    $string = preg_replace('~&#x0*([0-9a-f]+);~ei', '_code2utf8(hexdec("\\1"))', $string);
    $string = preg_replace('~&#0*([0-9]+);~e', '_code2utf8(\\1)', $string);
    */
    $string = preg_replace_callback('~&#x([0-9a-f]+);~i',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $string);
    $string = preg_replace_callback('~&#([0-9]+);~',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $string);
/lib/html_entity_decode_php4.php
Code :
    /*
    $return_text = strtr($text_to_convert, $htmlentities_table);
    $return_text = preg_replace('~&#x([0-9a-f]+);~ei', 'code_to_utf8(hexdec("\\1"))', $return_text);
    $return_text = preg_replace('~&#([0-9]+);~e', 'code_to_utf8("\\1")', $return_text);
    return $return_text;
    */
    $return_text = strtr($text_to_convert, $htmlentities_table);
    $return_text = preg_replace_callback('~&#x([0-9a-f]+);~i',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $return_text);
    $return_text = preg_replace_callback('~&#([0-9]+);~',
                         function($matches) {
                           __code_to_utf8($matches[1]);
                         }, $return_text);
    return $return_text;
J-C Etiemble v 2.2.xx
#3
Un tout grand merci. C'est LA solution. J'admire votre connaissance du sujet.
Je clôture. Bonne journée et à bientôt.
ps: Comment indiquer [resolu] dans le titre ? Je ne trouve pas comment modifier.
#3
Un tout grand merci. C'est LA solution. J'admire votre connaissance du sujet.
Je clôture. Bonne journée et à bientôt.
ps: Comment indiquer [resolu] dans le titre ? Je ne trouve pas comment modifier.
#4
j'ai eu le cas hier soir Wink sur un PHP 5.5.x

>ps: Comment indiquer [resolu] dans le titre ? Je ne trouve pas comment modifier.

c'est écrit en haut de la page "ATTENTION" :/
Ajoutez [Résolu] au début du titre de votre 1er message lorsqu'une solution a été trouvée.
J-C Etiemble v 2.2.xx
#4
j'ai eu le cas hier soir Wink sur un PHP 5.5.x

>ps: Comment indiquer [resolu] dans le titre ? Je ne trouve pas comment modifier.

c'est écrit en haut de la page "ATTENTION" :/
Ajoutez [Résolu] au début du titre de votre 1er message lorsqu'une solution a été trouvée.
J-C Etiemble v 2.2.xx
#5
Houla! Ça sent la 1.11.12 :mad:
{SEO}
Inscrivez-vous à notre Newsletter sur le site (colonne de droite, en bas).
Vous appréciez CMSMS et l'aide qui vous est fournie ici, aidez-nous en participant au projet.
Formation CMS Made Simple | Création de site CMS Made Simple.

C'est en se plantant qu'on devient cultivé.
J'ai un string dans l'Array (Paris Hilton)
#5
Houla! Ça sent la 1.11.12 :mad:
{SEO}
Inscrivez-vous à notre Newsletter sur le site (colonne de droite, en bas).
Vous appréciez CMSMS et l'aide qui vous est fournie ici, aidez-nous en participant au projet.
Formation CMS Made Simple | Création de site CMS Made Simple.

C'est en se plantant qu'on devient cultivé.
J'ai un string dans l'Array (Paris Hilton)
#6
Quand j'édite mon message je me positionne dans le titre, mais impossible d'y ajouter [Résolu].
Comment faire ???

Merci.
#6
Quand j'édite mon message je me positionne dans le titre, mais impossible d'y ajouter [Résolu].
Comment faire ???

Merci.
#7
Citation :Quand j'édite mon message je me positionne dans le titre, mais impossible d'y ajouter [Résolu].
Comment faire ???
alors explication c'est ton titre qui est trop long il faut donc en supprimer un partie
si tu mets comme titre [Résolu] Warning: preg_replace_callback()... ce ser Ok
J-C Etiemble v 2.2.xx
#7
Citation :Quand j'édite mon message je me positionne dans le titre, mais impossible d'y ajouter [Résolu].
Comment faire ???
alors explication c'est ton titre qui est trop long il faut donc en supprimer un partie
si tu mets comme titre [Résolu] Warning: preg_replace_callback()... ce ser Ok
J-C Etiemble v 2.2.xx
#8
Merci, voilà c'est fait. Bonne journée à tous.
#8
Merci, voilà c'est fait. Bonne journée à tous.


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)