From 975ab6c2a0a0acd91d843b8c845a7ddaa6434fa4 Mon Sep 17 00:00:00 2001 From: lnprieto Date: Mon, 3 Dec 2018 11:42:34 +0100 Subject: [PATCH 01/10] php 7.2 compatibility --- lodel/scripts/checkxml.php | 6 ++++-- lodel/scripts/dao/class.entities_persons.php | 2 +- .../dao/class.entitytypes_entitytypes.php | 2 +- lodel/scripts/filterfunc.php | 3 ++- lodel/scripts/imapfunc.php | 2 +- lodel/scripts/lodelparser.php | 14 ++++++++++---- lodel/scripts/logic.php | 4 +++- lodel/scripts/logic/class.data.php | 2 +- lodel/scripts/logic/class.entities_index.php | 8 +++++--- lodel/scripts/logic/class.translations.php | 2 +- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/defines.lib.php | 4 ++-- lodel/scripts/pma/defines_php.lib.php | 17 ++++------------- lodel/scripts/pma/mysql_wrappers.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 4 ++-- lodel/scripts/servooclient.php | 4 ++-- lodel/scripts/servoofunc.php | 2 +- lodel/scripts/textfunc.php | 8 ++++---- lodel/scripts/view.php | 1 + lodel/src/lodel/edition/oochargement.php | 6 +++--- 21 files changed, 54 insertions(+), 49 deletions(-) diff --git a/lodel/scripts/checkxml.php b/lodel/scripts/checkxml.php index 03300f333..83710ff11 100644 --- a/lodel/scripts/checkxml.php +++ b/lodel/scripts/checkxml.php @@ -50,7 +50,8 @@ function checkstring(&$text, $error = 0) return; } else { echo ""; - echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS['line']++)+2).' '; } , htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); echo "
\n"; echo sprintf("

XML error: %s ligne %d

", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)); echo "L'erreur se situe avant la zone rouge. Elle peut etre due a une erreur bien au dessus la ligne donne par le parser
"; @@ -71,7 +72,8 @@ function checkstring(&$text, $error = 0) */ function characterHandlerCHECK($parser, $data) { - echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS[line]++)+2).' '; }, $data); } diff --git a/lodel/scripts/dao/class.entities_persons.php b/lodel/scripts/dao/class.entities_persons.php index be86646b5..ad6453f84 100644 --- a/lodel/scripts/dao/class.entities_persons.php +++ b/lodel/scripts/dao/class.entities_persons.php @@ -32,7 +32,7 @@ class entities_personsVO { class entities_personsDAO extends DAO { - function entities_personsDAO() + function __construct() { parent::__construct("entities_persons", false); $this->rights = array(); diff --git a/lodel/scripts/dao/class.entitytypes_entitytypes.php b/lodel/scripts/dao/class.entitytypes_entitytypes.php index bf1d57687..41d43c280 100644 --- a/lodel/scripts/dao/class.entitytypes_entitytypes.php +++ b/lodel/scripts/dao/class.entitytypes_entitytypes.php @@ -27,7 +27,7 @@ class entitytypes_entitytypesVO class entitytypes_entitytypesDAO extends DAO { - function entitytypes_entitytypesDAO() + function __construct() { parent::__construct("entitytypes_entitytypes", false); $this->rights = array(); diff --git a/lodel/scripts/filterfunc.php b/lodel/scripts/filterfunc.php index 1483c5dc9..5cdd6329a 100644 --- a/lodel/scripts/filterfunc.php +++ b/lodel/scripts/filterfunc.php @@ -43,7 +43,8 @@ function makefilterfunc() $arg = $result2[2]; // argument if any // process the variable. The processing is simple here. Need more ? Sould be associated with parser variable processing. - $arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + //$arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + $arg = preg_replace_callback("/\[\#([A-Z][A-Z_0-9]*)\]/", function ($test) { return "$"."context[".strtolower($test[1])."]";} , $arg); if ($arg) { $arg = ','. $arg; diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 21fc1efd3..265ebd83d 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - while (list ($j) = each($struct->parts)) { + foreach ($struct->parts as list($j)) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } diff --git a/lodel/scripts/lodelparser.php b/lodel/scripts/lodelparser.php index f80dfc47e..ae3ed9e5a 100644 --- a/lodel/scripts/lodelparser.php +++ b/lodel/scripts/lodelparser.php @@ -560,12 +560,18 @@ protected function parse_after(& $text) tpl}"; if(!isset(\$GLOBALS['langcache'][\$context['sitelang']])) { \$GLOBALS['langcache'][\$context['sitelang']] = array(); } -if (!(\$langcontents = cache_get(\$langfile))) { - \$GLOBALS['langcache'][\$context['sitelang']] += generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); +\$langcontents = cache_get(\$langfile); + +if (\$langcontents === false) { + \$cachelang = generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); + if (!is_array(\$cachelang)) { + \$cachelang = array(\$cachelang); + } + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$cachelang); } else { - \$GLOBALS['langcache'][\$context['sitelang']] += \$langcontents; + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$langcontents); } -unset(\$langfile, \$langcontents); +unset(\$langfile, \$langcontents, \$cachelang); ?> {$text} PHP; diff --git a/lodel/scripts/logic.php b/lodel/scripts/logic.php index fff2ab1d2..d7ab09f83 100644 --- a/lodel/scripts/logic.php +++ b/lodel/scripts/logic.php @@ -504,7 +504,9 @@ protected function _makeMask(&$context, &$error) $mask = $context['mask']['user']; if(isset($context['mask_regexp'])) { // disable eval options for more security - $mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); + $mask = $context['mask']['user'] = preg_replace_callback("/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/s", + function ($text){return($text[1].$text[2].$text[1].str_replace('e','',"$text[4]"));},$mask); + //$mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); if(FALSE === @preg_match($mask, 'just a test for user regexp')) { $error['mask'] = 'mask: '.getlodeltextcontents('mask_bad_regexp', 'common'); return; diff --git a/lodel/scripts/logic/class.data.php b/lodel/scripts/logic/class.data.php index ff58c3404..3b40c426e 100644 --- a/lodel/scripts/logic/class.data.php +++ b/lodel/scripts/logic/class.data.php @@ -1920,7 +1920,7 @@ private function _updateTypes($datas, &$error='') { } $field = $db->GetRow("SELECT * FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); unset($field['id']); - array_walk($field, create_function('&$f', '$f = addcslashes($f, "\'");')); + array_walk($field, function(&$f) { $f = addcslashes($f, "\'");}); $db->execute("INSERT INTO `{$table}` ({$typesFields}) VALUES ('{$id}','".join("','", $field)."')") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $fieldName = $db->getOne("SELECT type FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $db->execute("INSERT INTO `$tablefieldsTable`(name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask) (SELECT name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask FROM `{$tablefieldsTable}__oldME` WHERE name = '{$fieldName}');\n") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 15e820112..5cee7d25e 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -184,8 +184,10 @@ protected function _indexField ($id, $fieldValue, $fieldName, $fieldWeight, $dao */ protected function _decode_html_entities($text) { - $text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation - $text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation + $text= preg_replace_callback('/&#(\d+);/m',function ($str) { return utf8_encode(chr($str[1])); },$text); #decimal notation + $text= preg_replace_callback('/&#x([a-f0-9]+);/mi',function ($str) { return utf8_encode(chr(hexdec('0x'.$str[1]))); },$text); #hex notation + //$text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation + //$text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation return $text; } @@ -216,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - while (list (, $token) = each ($tokens)) { + foreach ($tokens as list(, $token)) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! diff --git a/lodel/scripts/logic/class.translations.php b/lodel/scripts/logic/class.translations.php index b659bc14d..6a330f20d 100644 --- a/lodel/scripts/logic/class.translations.php +++ b/lodel/scripts/logic/class.translations.php @@ -352,7 +352,7 @@ protected function _saveRelatedTables($vo,&$context) #if (in_array($lang,$langs)) continue; // the text already exists in the correct lang #echo $row['name']," "; - $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysql_escape_string($row['contents'])."','-1','".$context['lang']."')"; + $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysqli_escape_string($row['contents'])."','-1','".$context['lang']."')"; $count++; $result->MoveNext(); } diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 98d082cb9..3fbd1b01d 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - while(list($key, $val) = each($a_name)) { + foreach ($a_name as list($key, $val)) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/defines.lib.php b/lodel/scripts/pma/defines.lib.php index b8b705f9a..b30a521aa 100644 --- a/lodel/scripts/pma/defines.lib.php +++ b/lodel/scripts/pma/defines.lib.php @@ -58,8 +58,8 @@ // php 4.1+ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { - $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; + } else if (!empty($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } diff --git a/lodel/scripts/pma/defines_php.lib.php b/lodel/scripts/pma/defines_php.lib.php index 997f41408..4bafdb7d7 100644 --- a/lodel/scripts/pma/defines_php.lib.php +++ b/lodel/scripts/pma/defines_php.lib.php @@ -42,16 +42,7 @@ // MySQL client API if (!defined('PMA_MYSQL_CLIENT_API')) { - if (function_exists('mysql_get_client_info') || function_exists('mysqli_get_client_info')) { - if('mysql' == DBDRIVER) - $client_api = mysql_get_client_info(); - else - $client_api = mysqli_get_client_info(); - } else { - // for compatibility with php <= 4.0.5 - // expect the worst! - $client_api = '3.21.0'; - } + $client_api = mysqli_get_client_info(); $client_api = explode('.', $client_api); define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2]))); unset($client_api); @@ -80,8 +71,8 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('Thread Safety[[:space:]]*enabled', $a)) { - if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { + if (preg_match('Thread Safety[[:space:]]*enabled', $a)) { + if (preg_match('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; } else { $GLOBALS['PMA_dl_allowed'] = FALSE; @@ -134,7 +125,7 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { + if (preg_match('GD Version[[:space:]]*\(.*\)', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else { diff --git a/lodel/scripts/pma/mysql_wrappers.lib.php b/lodel/scripts/pma/mysql_wrappers.lib.php index 977576b6d..f5163138e 100644 --- a/lodel/scripts/pma/mysql_wrappers.lib.php +++ b/lodel/scripts/pma/mysql_wrappers.lib.php @@ -73,7 +73,7 @@ function PMA_mysql_fetch_array($result, $type = FALSE) { if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]); } else { /* Meta information available -> check type of field and convert it according to the type */ - if ($meta->blob || eregi('BINARY', $meta->type)) { + if ($meta->blob || preg_match('BINARY/i', $meta->type)) { if (isset($data[$i])) $ret[$i] = $data[$i]; if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name]; } else { diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 4c0746eaa..0e1fe56de 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - while(list($comment_field, $comment) = each($comments_map)) { + foreach ($comments_map as list($comment_field, $comment)) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - while(list($mime_field, $mime) = each($mime_map)) { + foreach ($mime_map as list($mime_field, $mime)) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - while(list($rel_field, $rel) = each($res_rel)) { + foreach ($res_rel as list($rel_field, $rel)) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - while (list($x, $columns) = @each($index)) { + foreach ($index as list($x, $columns)) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index 2214cb268..b4f678e76 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - while (list($key, $col) = each($cfg['SQP']['fmtColor'])) { + foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { @@ -1993,7 +1993,7 @@ function PMA_SQP_buildCssData() function PMA_SQP_formatNone($arr) { $formatted_sql = htmlspecialchars($arr['raw']); - $formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); + $formatted_sql = preg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); return $formatted_sql; } // end of the "PMA_SQP_formatNone()" function diff --git a/lodel/scripts/servooclient.php b/lodel/scripts/servooclient.php index 105d91e8c..c85a10284 100644 --- a/lodel/scripts/servooclient.php +++ b/lodel/scripts/servooclient.php @@ -64,7 +64,7 @@ class ServOO_Client { * @param string $url Location of the ServOO server. */ - function ServOO_Client($url) { + function __construct($url) { $this->_soapclient = new soapclientmime($url); $err = $this->_soapclient->getError(); @@ -576,7 +576,7 @@ function _convertToXML_Pre_Extract_CB($p_event, &$p_header) class servooattachment { var $cid; - function servooattachment($cid) { + function __construct($cid) { $this->cid=$cid; } diff --git a/lodel/scripts/servoofunc.php b/lodel/scripts/servoofunc.php index 53eecc89f..9261a1dee 100644 --- a/lodel/scripts/servoofunc.php +++ b/lodel/scripts/servoofunc.php @@ -12,7 +12,7 @@ class ServOO extends ServOO_Client { private $options; // username / passwd / url public $status; // true ou false - function ServOO($other = "") { + function __construct($other = "") { if(!empty($other)) { if(FALSE === $this->SelectOtherServer($other)) { $this->status = FALSE; diff --git a/lodel/scripts/textfunc.php b/lodel/scripts/textfunc.php index add60a824..eb40db652 100644 --- a/lodel/scripts/textfunc.php +++ b/lodel/scripts/textfunc.php @@ -214,10 +214,10 @@ function spip($letexte) { $puce = ""; // Harmoniser les retours chariot - $letexte = ereg_replace("\r\n?", "\n", $letexte); + $letexte = preg_replace("\r\n?", "\n", $letexte); // Corriger HTML - $letexte = eregi_replace("", "\n\n\n", $letexte); + $letexte = preg_replace("/i", "\n\n\n", $letexte); // // Raccourcis liens @@ -225,14 +225,14 @@ function spip($letexte) $regexp = "\[([^][]*)->([^]]*)\]"; $texte_a_voir = $letexte; $texte_vu = ''; - while (ereg($regexp, $texte_a_voir, $regs)) { + while (preg($regexp, $texte_a_voir, $regs)) { $lien_texte = $regs[1]; $lien_url = trim($regs[2]); $compt_liens ++; $lien_interne = false; $insert = "".$lien_texte.""; - $zetexte = split($regexp, $texte_a_voir, 2); + $zetexte = preg_split($regexp, $texte_a_voir, 2); $texte_vu .= $zetexte[0].$insert; $texte_a_voir = $zetexte[1]; } diff --git a/lodel/scripts/view.php b/lodel/scripts/view.php index 39e6c5afe..fe750525d 100644 --- a/lodel/scripts/view.php +++ b/lodel/scripts/view.php @@ -519,6 +519,7 @@ private function _eval($contents, &$context) } ob_start(); + //var_dump($contents); eval("?>" . $contents); $contents = ob_get_clean(); } diff --git a/lodel/src/lodel/edition/oochargement.php b/lodel/src/lodel/edition/oochargement.php index 1334ae271..0ea99e442 100644 --- a/lodel/src/lodel/edition/oochargement.php +++ b/lodel/src/lodel/edition/oochargement.php @@ -158,7 +158,7 @@ function printErrors($errors, $exit = true, $isFrame = true) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) { $var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -256,7 +256,7 @@ function removefilesfromimport($rep) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -417,7 +417,7 @@ function removefilesfromimport($rep) if(empty($context['multiple']) && C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } From 0b92b9e6276d71eda7224333bf2899e6a2ca71b3 Mon Sep 17 00:00:00 2001 From: lnprieto Date: Mon, 3 Dec 2018 11:42:34 +0100 Subject: [PATCH 02/10] php 7.2 compatibility --- lodel/scripts/checkxml.php | 6 ++++-- lodel/scripts/filterfunc.php | 3 ++- lodel/scripts/imapfunc.php | 2 +- lodel/scripts/lodelparser.php | 14 ++++++++++---- lodel/scripts/logic.php | 4 +++- lodel/scripts/logic/class.data.php | 2 +- lodel/scripts/logic/class.entities_index.php | 8 +++++--- lodel/scripts/logic/class.translations.php | 2 +- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/defines.lib.php | 4 ++-- lodel/scripts/pma/defines_php.lib.php | 17 ++++------------- lodel/scripts/pma/mysql_wrappers.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 4 ++-- lodel/scripts/servooclient.php | 4 ++-- lodel/scripts/servoofunc.php | 2 +- lodel/scripts/textfunc.php | 8 ++++---- lodel/scripts/view.php | 1 + lodel/src/lodel/edition/oochargement.php | 6 +++--- 19 files changed, 52 insertions(+), 47 deletions(-) diff --git a/lodel/scripts/checkxml.php b/lodel/scripts/checkxml.php index 03300f333..83710ff11 100644 --- a/lodel/scripts/checkxml.php +++ b/lodel/scripts/checkxml.php @@ -50,7 +50,8 @@ function checkstring(&$text, $error = 0) return; } else { echo ""; - echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS['line']++)+2).' '; } , htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); echo "
\n"; echo sprintf("

XML error: %s ligne %d

", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)); echo "L'erreur se situe avant la zone rouge. Elle peut etre due a une erreur bien au dessus la ligne donne par le parser
"; @@ -71,7 +72,8 @@ function checkstring(&$text, $error = 0) */ function characterHandlerCHECK($parser, $data) { - echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS[line]++)+2).' '; }, $data); } diff --git a/lodel/scripts/filterfunc.php b/lodel/scripts/filterfunc.php index 1483c5dc9..5cdd6329a 100644 --- a/lodel/scripts/filterfunc.php +++ b/lodel/scripts/filterfunc.php @@ -43,7 +43,8 @@ function makefilterfunc() $arg = $result2[2]; // argument if any // process the variable. The processing is simple here. Need more ? Sould be associated with parser variable processing. - $arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + //$arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + $arg = preg_replace_callback("/\[\#([A-Z][A-Z_0-9]*)\]/", function ($test) { return "$"."context[".strtolower($test[1])."]";} , $arg); if ($arg) { $arg = ','. $arg; diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 21fc1efd3..265ebd83d 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - while (list ($j) = each($struct->parts)) { + foreach ($struct->parts as list($j)) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } diff --git a/lodel/scripts/lodelparser.php b/lodel/scripts/lodelparser.php index f80dfc47e..ae3ed9e5a 100644 --- a/lodel/scripts/lodelparser.php +++ b/lodel/scripts/lodelparser.php @@ -560,12 +560,18 @@ protected function parse_after(& $text) tpl}"; if(!isset(\$GLOBALS['langcache'][\$context['sitelang']])) { \$GLOBALS['langcache'][\$context['sitelang']] = array(); } -if (!(\$langcontents = cache_get(\$langfile))) { - \$GLOBALS['langcache'][\$context['sitelang']] += generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); +\$langcontents = cache_get(\$langfile); + +if (\$langcontents === false) { + \$cachelang = generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); + if (!is_array(\$cachelang)) { + \$cachelang = array(\$cachelang); + } + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$cachelang); } else { - \$GLOBALS['langcache'][\$context['sitelang']] += \$langcontents; + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$langcontents); } -unset(\$langfile, \$langcontents); +unset(\$langfile, \$langcontents, \$cachelang); ?> {$text} PHP; diff --git a/lodel/scripts/logic.php b/lodel/scripts/logic.php index fff2ab1d2..d7ab09f83 100644 --- a/lodel/scripts/logic.php +++ b/lodel/scripts/logic.php @@ -504,7 +504,9 @@ protected function _makeMask(&$context, &$error) $mask = $context['mask']['user']; if(isset($context['mask_regexp'])) { // disable eval options for more security - $mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); + $mask = $context['mask']['user'] = preg_replace_callback("/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/s", + function ($text){return($text[1].$text[2].$text[1].str_replace('e','',"$text[4]"));},$mask); + //$mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); if(FALSE === @preg_match($mask, 'just a test for user regexp')) { $error['mask'] = 'mask: '.getlodeltextcontents('mask_bad_regexp', 'common'); return; diff --git a/lodel/scripts/logic/class.data.php b/lodel/scripts/logic/class.data.php index ff58c3404..3b40c426e 100644 --- a/lodel/scripts/logic/class.data.php +++ b/lodel/scripts/logic/class.data.php @@ -1920,7 +1920,7 @@ private function _updateTypes($datas, &$error='') { } $field = $db->GetRow("SELECT * FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); unset($field['id']); - array_walk($field, create_function('&$f', '$f = addcslashes($f, "\'");')); + array_walk($field, function(&$f) { $f = addcslashes($f, "\'");}); $db->execute("INSERT INTO `{$table}` ({$typesFields}) VALUES ('{$id}','".join("','", $field)."')") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $fieldName = $db->getOne("SELECT type FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $db->execute("INSERT INTO `$tablefieldsTable`(name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask) (SELECT name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask FROM `{$tablefieldsTable}__oldME` WHERE name = '{$fieldName}');\n") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 15e820112..5cee7d25e 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -184,8 +184,10 @@ protected function _indexField ($id, $fieldValue, $fieldName, $fieldWeight, $dao */ protected function _decode_html_entities($text) { - $text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation - $text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation + $text= preg_replace_callback('/&#(\d+);/m',function ($str) { return utf8_encode(chr($str[1])); },$text); #decimal notation + $text= preg_replace_callback('/&#x([a-f0-9]+);/mi',function ($str) { return utf8_encode(chr(hexdec('0x'.$str[1]))); },$text); #hex notation + //$text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation + //$text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation return $text; } @@ -216,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - while (list (, $token) = each ($tokens)) { + foreach ($tokens as list(, $token)) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! diff --git a/lodel/scripts/logic/class.translations.php b/lodel/scripts/logic/class.translations.php index b659bc14d..6a330f20d 100644 --- a/lodel/scripts/logic/class.translations.php +++ b/lodel/scripts/logic/class.translations.php @@ -352,7 +352,7 @@ protected function _saveRelatedTables($vo,&$context) #if (in_array($lang,$langs)) continue; // the text already exists in the correct lang #echo $row['name']," "; - $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysql_escape_string($row['contents'])."','-1','".$context['lang']."')"; + $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysqli_escape_string($row['contents'])."','-1','".$context['lang']."')"; $count++; $result->MoveNext(); } diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 98d082cb9..3fbd1b01d 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - while(list($key, $val) = each($a_name)) { + foreach ($a_name as list($key, $val)) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/defines.lib.php b/lodel/scripts/pma/defines.lib.php index b8b705f9a..b30a521aa 100644 --- a/lodel/scripts/pma/defines.lib.php +++ b/lodel/scripts/pma/defines.lib.php @@ -58,8 +58,8 @@ // php 4.1+ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { - $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; + } else if (!empty($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } diff --git a/lodel/scripts/pma/defines_php.lib.php b/lodel/scripts/pma/defines_php.lib.php index 997f41408..4bafdb7d7 100644 --- a/lodel/scripts/pma/defines_php.lib.php +++ b/lodel/scripts/pma/defines_php.lib.php @@ -42,16 +42,7 @@ // MySQL client API if (!defined('PMA_MYSQL_CLIENT_API')) { - if (function_exists('mysql_get_client_info') || function_exists('mysqli_get_client_info')) { - if('mysql' == DBDRIVER) - $client_api = mysql_get_client_info(); - else - $client_api = mysqli_get_client_info(); - } else { - // for compatibility with php <= 4.0.5 - // expect the worst! - $client_api = '3.21.0'; - } + $client_api = mysqli_get_client_info(); $client_api = explode('.', $client_api); define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2]))); unset($client_api); @@ -80,8 +71,8 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('Thread Safety[[:space:]]*enabled', $a)) { - if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { + if (preg_match('Thread Safety[[:space:]]*enabled', $a)) { + if (preg_match('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; } else { $GLOBALS['PMA_dl_allowed'] = FALSE; @@ -134,7 +125,7 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { + if (preg_match('GD Version[[:space:]]*\(.*\)', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else { diff --git a/lodel/scripts/pma/mysql_wrappers.lib.php b/lodel/scripts/pma/mysql_wrappers.lib.php index 977576b6d..f5163138e 100644 --- a/lodel/scripts/pma/mysql_wrappers.lib.php +++ b/lodel/scripts/pma/mysql_wrappers.lib.php @@ -73,7 +73,7 @@ function PMA_mysql_fetch_array($result, $type = FALSE) { if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]); } else { /* Meta information available -> check type of field and convert it according to the type */ - if ($meta->blob || eregi('BINARY', $meta->type)) { + if ($meta->blob || preg_match('BINARY/i', $meta->type)) { if (isset($data[$i])) $ret[$i] = $data[$i]; if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name]; } else { diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 4c0746eaa..0e1fe56de 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - while(list($comment_field, $comment) = each($comments_map)) { + foreach ($comments_map as list($comment_field, $comment)) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - while(list($mime_field, $mime) = each($mime_map)) { + foreach ($mime_map as list($mime_field, $mime)) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - while(list($rel_field, $rel) = each($res_rel)) { + foreach ($res_rel as list($rel_field, $rel)) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - while (list($x, $columns) = @each($index)) { + foreach ($index as list($x, $columns)) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index 2214cb268..b4f678e76 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - while (list($key, $col) = each($cfg['SQP']['fmtColor'])) { + foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { @@ -1993,7 +1993,7 @@ function PMA_SQP_buildCssData() function PMA_SQP_formatNone($arr) { $formatted_sql = htmlspecialchars($arr['raw']); - $formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); + $formatted_sql = preg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); return $formatted_sql; } // end of the "PMA_SQP_formatNone()" function diff --git a/lodel/scripts/servooclient.php b/lodel/scripts/servooclient.php index 105d91e8c..c85a10284 100644 --- a/lodel/scripts/servooclient.php +++ b/lodel/scripts/servooclient.php @@ -64,7 +64,7 @@ class ServOO_Client { * @param string $url Location of the ServOO server. */ - function ServOO_Client($url) { + function __construct($url) { $this->_soapclient = new soapclientmime($url); $err = $this->_soapclient->getError(); @@ -576,7 +576,7 @@ function _convertToXML_Pre_Extract_CB($p_event, &$p_header) class servooattachment { var $cid; - function servooattachment($cid) { + function __construct($cid) { $this->cid=$cid; } diff --git a/lodel/scripts/servoofunc.php b/lodel/scripts/servoofunc.php index 53eecc89f..9261a1dee 100644 --- a/lodel/scripts/servoofunc.php +++ b/lodel/scripts/servoofunc.php @@ -12,7 +12,7 @@ class ServOO extends ServOO_Client { private $options; // username / passwd / url public $status; // true ou false - function ServOO($other = "") { + function __construct($other = "") { if(!empty($other)) { if(FALSE === $this->SelectOtherServer($other)) { $this->status = FALSE; diff --git a/lodel/scripts/textfunc.php b/lodel/scripts/textfunc.php index 86756ea4a..fe28efde5 100644 --- a/lodel/scripts/textfunc.php +++ b/lodel/scripts/textfunc.php @@ -214,10 +214,10 @@ function spip($letexte) { $puce = ""; // Harmoniser les retours chariot - $letexte = ereg_replace("\r\n?", "\n", $letexte); + $letexte = preg_replace("\r\n?", "\n", $letexte); // Corriger HTML - $letexte = eregi_replace("", "\n\n\n", $letexte); + $letexte = preg_replace("/i", "\n\n\n", $letexte); // // Raccourcis liens @@ -225,14 +225,14 @@ function spip($letexte) $regexp = "\[([^][]*)->([^]]*)\]"; $texte_a_voir = $letexte; $texte_vu = ''; - while (ereg($regexp, $texte_a_voir, $regs)) { + while (preg($regexp, $texte_a_voir, $regs)) { $lien_texte = $regs[1]; $lien_url = trim($regs[2]); $compt_liens ++; $lien_interne = false; $insert = "".$lien_texte.""; - $zetexte = split($regexp, $texte_a_voir, 2); + $zetexte = preg_split($regexp, $texte_a_voir, 2); $texte_vu .= $zetexte[0].$insert; $texte_a_voir = $zetexte[1]; } diff --git a/lodel/scripts/view.php b/lodel/scripts/view.php index 39e6c5afe..fe750525d 100644 --- a/lodel/scripts/view.php +++ b/lodel/scripts/view.php @@ -519,6 +519,7 @@ private function _eval($contents, &$context) } ob_start(); + //var_dump($contents); eval("?>" . $contents); $contents = ob_get_clean(); } diff --git a/lodel/src/lodel/edition/oochargement.php b/lodel/src/lodel/edition/oochargement.php index 51a9a093b..60db835e1 100644 --- a/lodel/src/lodel/edition/oochargement.php +++ b/lodel/src/lodel/edition/oochargement.php @@ -159,7 +159,7 @@ function printErrors($errors, $exit = true, $isFrame = true) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) { $var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -257,7 +257,7 @@ function removefilesfromimport($rep) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -418,7 +418,7 @@ function removefilesfromimport($rep) if(empty($context['multiple']) && C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } From 0dec762a08f37382545d3b52f56fd1210182ed95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Prieto?= Date: Mon, 29 Apr 2019 15:14:44 +0200 Subject: [PATCH 03/10] =?UTF-8?q?R=C3=A9=C3=A9criture=20foreach=20rempla?= =?UTF-8?q?=C3=A7ant=20each?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lodel/scripts/imapfunc.php | 4 ++-- lodel/scripts/logic/class.entities_index.php | 4 ++-- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 265ebd83d..ac9196b40 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - foreach ($struct->parts as list($j)) { + foreach ($struct->parts as $j) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } @@ -118,4 +118,4 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") } return $nbattachment; } -?> \ No newline at end of file +?> diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 5cee7d25e..74d08c4ac 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -218,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - foreach ($tokens as list(, $token)) { + foreach ($tokens as $token) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! @@ -304,4 +304,4 @@ protected function _indexEntitiesRelations ($id, $nature, $daoIndex) } }//end of class -?> \ No newline at end of file +?> diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 3fbd1b01d..4d851ce34 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - foreach ($a_name as list($key, $val)) { + foreach ($a_name as $key => $val) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 0e1fe56de..0dcb6ab92 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - foreach ($comments_map as list($comment_field, $comment)) { + foreach ($comments_map as $comment_field => $comment) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - foreach ($mime_map as list($mime_field, $mime)) { + foreach ($mime_map as $mime_field => $mime) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - foreach ($res_rel as list($rel_field, $rel)) { + foreach ($res_rel as $rel_field => $rel) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - foreach ($index as list($x, $columns)) { + foreach ($index as $x => $columns) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index b4f678e76..0b2673756 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { + foreach ($cfg['SQP']['fmtColor'] as $key => $col) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { From 134319c96b84decd6a7f2d10831b4202f481954c Mon Sep 17 00:00:00 2001 From: lnprieto Date: Fri, 24 May 2019 09:35:17 +0200 Subject: [PATCH 04/10] Remove useless self-assignment --- lodel/scripts/loops.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lodel/scripts/loops.php b/lodel/scripts/loops.php index 447f64b23..980fc81c2 100644 --- a/lodel/scripts/loops.php +++ b/lodel/scripts/loops.php @@ -494,7 +494,6 @@ function _constructPages(& $context, $funcname, $arguments) */ function plageDeRecherche($numPageCourante, $nbPagesTotal) { - $nbPagesTotal = $nbPagesTotal; $numPageCourante = $numPageCourante +1; $precision = 4; $res = array (); From 258f0c9725962e57697d3d31a0715396036d84aa Mon Sep 17 00:00:00 2001 From: lnprieto Date: Mon, 3 Dec 2018 11:42:34 +0100 Subject: [PATCH 05/10] php 7.2 compatibility --- lodel/scripts/checkxml.php | 6 ++++-- lodel/scripts/filterfunc.php | 3 ++- lodel/scripts/imapfunc.php | 2 +- lodel/scripts/lodelparser.php | 14 ++++++++++---- lodel/scripts/logic.php | 4 +++- lodel/scripts/logic/class.data.php | 2 +- lodel/scripts/logic/class.entities_index.php | 8 +++++--- lodel/scripts/logic/class.translations.php | 2 +- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/defines.lib.php | 4 ++-- lodel/scripts/pma/defines_php.lib.php | 17 ++++------------- lodel/scripts/pma/mysql_wrappers.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 4 ++-- lodel/scripts/servooclient.php | 4 ++-- lodel/scripts/servoofunc.php | 2 +- lodel/scripts/textfunc.php | 8 ++++---- lodel/scripts/view.php | 1 + lodel/src/lodel/edition/oochargement.php | 6 +++--- 19 files changed, 52 insertions(+), 47 deletions(-) diff --git a/lodel/scripts/checkxml.php b/lodel/scripts/checkxml.php index 03300f333..83710ff11 100644 --- a/lodel/scripts/checkxml.php +++ b/lodel/scripts/checkxml.php @@ -50,7 +50,8 @@ function checkstring(&$text, $error = 0) return; } else { echo ""; - echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS['line']++)+2).' '; } , htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); echo "
\n"; echo sprintf("

XML error: %s ligne %d

", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)); echo "L'erreur se situe avant la zone rouge. Elle peut etre due a une erreur bien au dessus la ligne donne par le parser
"; @@ -71,7 +72,8 @@ function checkstring(&$text, $error = 0) */ function characterHandlerCHECK($parser, $data) { - echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + //echo preg_replace("/\n/se", "'
'.((\$GLOBALS[line]++)+2).' '", $data); + echo preg_replace_callback("/\n/s", function ($str) { return '
'.(($GLOBALS[line]++)+2).' '; }, $data); } diff --git a/lodel/scripts/filterfunc.php b/lodel/scripts/filterfunc.php index 1483c5dc9..5cdd6329a 100644 --- a/lodel/scripts/filterfunc.php +++ b/lodel/scripts/filterfunc.php @@ -43,7 +43,8 @@ function makefilterfunc() $arg = $result2[2]; // argument if any // process the variable. The processing is simple here. Need more ? Sould be associated with parser variable processing. - $arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + //$arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + $arg = preg_replace_callback("/\[\#([A-Z][A-Z_0-9]*)\]/", function ($test) { return "$"."context[".strtolower($test[1])."]";} , $arg); if ($arg) { $arg = ','. $arg; diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 21fc1efd3..265ebd83d 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - while (list ($j) = each($struct->parts)) { + foreach ($struct->parts as list($j)) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } diff --git a/lodel/scripts/lodelparser.php b/lodel/scripts/lodelparser.php index f80dfc47e..ae3ed9e5a 100644 --- a/lodel/scripts/lodelparser.php +++ b/lodel/scripts/lodelparser.php @@ -560,12 +560,18 @@ protected function parse_after(& $text) tpl}"; if(!isset(\$GLOBALS['langcache'][\$context['sitelang']])) { \$GLOBALS['langcache'][\$context['sitelang']] = array(); } -if (!(\$langcontents = cache_get(\$langfile))) { - \$GLOBALS['langcache'][\$context['sitelang']] += generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); +\$langcontents = cache_get(\$langfile); + +if (\$langcontents === false) { + \$cachelang = generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); + if (!is_array(\$cachelang)) { + \$cachelang = array(\$cachelang); + } + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$cachelang); } else { - \$GLOBALS['langcache'][\$context['sitelang']] += \$langcontents; + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$langcontents); } -unset(\$langfile, \$langcontents); +unset(\$langfile, \$langcontents, \$cachelang); ?> {$text} PHP; diff --git a/lodel/scripts/logic.php b/lodel/scripts/logic.php index fff2ab1d2..d7ab09f83 100644 --- a/lodel/scripts/logic.php +++ b/lodel/scripts/logic.php @@ -504,7 +504,9 @@ protected function _makeMask(&$context, &$error) $mask = $context['mask']['user']; if(isset($context['mask_regexp'])) { // disable eval options for more security - $mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); + $mask = $context['mask']['user'] = preg_replace_callback("/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/s", + function ($text){return($text[1].$text[2].$text[1].str_replace('e','',"$text[4]"));},$mask); + //$mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); if(FALSE === @preg_match($mask, 'just a test for user regexp')) { $error['mask'] = 'mask: '.getlodeltextcontents('mask_bad_regexp', 'common'); return; diff --git a/lodel/scripts/logic/class.data.php b/lodel/scripts/logic/class.data.php index ff58c3404..3b40c426e 100644 --- a/lodel/scripts/logic/class.data.php +++ b/lodel/scripts/logic/class.data.php @@ -1920,7 +1920,7 @@ private function _updateTypes($datas, &$error='') { } $field = $db->GetRow("SELECT * FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); unset($field['id']); - array_walk($field, create_function('&$f', '$f = addcslashes($f, "\'");')); + array_walk($field, function(&$f) { $f = addcslashes($f, "\'");}); $db->execute("INSERT INTO `{$table}` ({$typesFields}) VALUES ('{$id}','".join("','", $field)."')") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $fieldName = $db->getOne("SELECT type FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $db->execute("INSERT INTO `$tablefieldsTable`(name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask) (SELECT name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask FROM `{$tablefieldsTable}__oldME` WHERE name = '{$fieldName}');\n") or trigger_error("SQL ERROR :
".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 15e820112..5cee7d25e 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -184,8 +184,10 @@ protected function _indexField ($id, $fieldValue, $fieldName, $fieldWeight, $dao */ protected function _decode_html_entities($text) { - $text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation - $text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation + $text= preg_replace_callback('/&#(\d+);/m',function ($str) { return utf8_encode(chr($str[1])); },$text); #decimal notation + $text= preg_replace_callback('/&#x([a-f0-9]+);/mi',function ($str) { return utf8_encode(chr(hexdec('0x'.$str[1]))); },$text); #hex notation + //$text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation + //$text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation return $text; } @@ -216,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - while (list (, $token) = each ($tokens)) { + foreach ($tokens as list(, $token)) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! diff --git a/lodel/scripts/logic/class.translations.php b/lodel/scripts/logic/class.translations.php index b659bc14d..6a330f20d 100644 --- a/lodel/scripts/logic/class.translations.php +++ b/lodel/scripts/logic/class.translations.php @@ -352,7 +352,7 @@ protected function _saveRelatedTables($vo,&$context) #if (in_array($lang,$langs)) continue; // the text already exists in the correct lang #echo $row['name']," "; - $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysql_escape_string($row['contents'])."','-1','".$context['lang']."')"; + $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysqli_escape_string($row['contents'])."','-1','".$context['lang']."')"; $count++; $result->MoveNext(); } diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 98d082cb9..3fbd1b01d 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - while(list($key, $val) = each($a_name)) { + foreach ($a_name as list($key, $val)) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/defines.lib.php b/lodel/scripts/pma/defines.lib.php index b8b705f9a..b30a521aa 100644 --- a/lodel/scripts/pma/defines.lib.php +++ b/lodel/scripts/pma/defines.lib.php @@ -58,8 +58,8 @@ // php 4.1+ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { - $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; + } else if (!empty($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } diff --git a/lodel/scripts/pma/defines_php.lib.php b/lodel/scripts/pma/defines_php.lib.php index 997f41408..4bafdb7d7 100644 --- a/lodel/scripts/pma/defines_php.lib.php +++ b/lodel/scripts/pma/defines_php.lib.php @@ -42,16 +42,7 @@ // MySQL client API if (!defined('PMA_MYSQL_CLIENT_API')) { - if (function_exists('mysql_get_client_info') || function_exists('mysqli_get_client_info')) { - if('mysql' == DBDRIVER) - $client_api = mysql_get_client_info(); - else - $client_api = mysqli_get_client_info(); - } else { - // for compatibility with php <= 4.0.5 - // expect the worst! - $client_api = '3.21.0'; - } + $client_api = mysqli_get_client_info(); $client_api = explode('.', $client_api); define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2]))); unset($client_api); @@ -80,8 +71,8 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('Thread Safety[[:space:]]*enabled', $a)) { - if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { + if (preg_match('Thread Safety[[:space:]]*enabled', $a)) { + if (preg_match('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; } else { $GLOBALS['PMA_dl_allowed'] = FALSE; @@ -134,7 +125,7 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { + if (preg_match('GD Version[[:space:]]*\(.*\)', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else { diff --git a/lodel/scripts/pma/mysql_wrappers.lib.php b/lodel/scripts/pma/mysql_wrappers.lib.php index 977576b6d..f5163138e 100644 --- a/lodel/scripts/pma/mysql_wrappers.lib.php +++ b/lodel/scripts/pma/mysql_wrappers.lib.php @@ -73,7 +73,7 @@ function PMA_mysql_fetch_array($result, $type = FALSE) { if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]); } else { /* Meta information available -> check type of field and convert it according to the type */ - if ($meta->blob || eregi('BINARY', $meta->type)) { + if ($meta->blob || preg_match('BINARY/i', $meta->type)) { if (isset($data[$i])) $ret[$i] = $data[$i]; if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name]; } else { diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 4c0746eaa..0e1fe56de 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - while(list($comment_field, $comment) = each($comments_map)) { + foreach ($comments_map as list($comment_field, $comment)) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - while(list($mime_field, $mime) = each($mime_map)) { + foreach ($mime_map as list($mime_field, $mime)) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - while(list($rel_field, $rel) = each($res_rel)) { + foreach ($res_rel as list($rel_field, $rel)) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - while (list($x, $columns) = @each($index)) { + foreach ($index as list($x, $columns)) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index 2214cb268..b4f678e76 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - while (list($key, $col) = each($cfg['SQP']['fmtColor'])) { + foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { @@ -1993,7 +1993,7 @@ function PMA_SQP_buildCssData() function PMA_SQP_formatNone($arr) { $formatted_sql = htmlspecialchars($arr['raw']); - $formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); + $formatted_sql = preg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); return $formatted_sql; } // end of the "PMA_SQP_formatNone()" function diff --git a/lodel/scripts/servooclient.php b/lodel/scripts/servooclient.php index 105d91e8c..c85a10284 100644 --- a/lodel/scripts/servooclient.php +++ b/lodel/scripts/servooclient.php @@ -64,7 +64,7 @@ class ServOO_Client { * @param string $url Location of the ServOO server. */ - function ServOO_Client($url) { + function __construct($url) { $this->_soapclient = new soapclientmime($url); $err = $this->_soapclient->getError(); @@ -576,7 +576,7 @@ function _convertToXML_Pre_Extract_CB($p_event, &$p_header) class servooattachment { var $cid; - function servooattachment($cid) { + function __construct($cid) { $this->cid=$cid; } diff --git a/lodel/scripts/servoofunc.php b/lodel/scripts/servoofunc.php index 53eecc89f..9261a1dee 100644 --- a/lodel/scripts/servoofunc.php +++ b/lodel/scripts/servoofunc.php @@ -12,7 +12,7 @@ class ServOO extends ServOO_Client { private $options; // username / passwd / url public $status; // true ou false - function ServOO($other = "") { + function __construct($other = "") { if(!empty($other)) { if(FALSE === $this->SelectOtherServer($other)) { $this->status = FALSE; diff --git a/lodel/scripts/textfunc.php b/lodel/scripts/textfunc.php index 86756ea4a..fe28efde5 100644 --- a/lodel/scripts/textfunc.php +++ b/lodel/scripts/textfunc.php @@ -214,10 +214,10 @@ function spip($letexte) { $puce = ""; // Harmoniser les retours chariot - $letexte = ereg_replace("\r\n?", "\n", $letexte); + $letexte = preg_replace("\r\n?", "\n", $letexte); // Corriger HTML - $letexte = eregi_replace("", "\n\n\n", $letexte); + $letexte = preg_replace("/i", "\n\n\n", $letexte); // // Raccourcis liens @@ -225,14 +225,14 @@ function spip($letexte) $regexp = "\[([^][]*)->([^]]*)\]"; $texte_a_voir = $letexte; $texte_vu = ''; - while (ereg($regexp, $texte_a_voir, $regs)) { + while (preg($regexp, $texte_a_voir, $regs)) { $lien_texte = $regs[1]; $lien_url = trim($regs[2]); $compt_liens ++; $lien_interne = false; $insert = "".$lien_texte.""; - $zetexte = split($regexp, $texte_a_voir, 2); + $zetexte = preg_split($regexp, $texte_a_voir, 2); $texte_vu .= $zetexte[0].$insert; $texte_a_voir = $zetexte[1]; } diff --git a/lodel/scripts/view.php b/lodel/scripts/view.php index 39e6c5afe..fe750525d 100644 --- a/lodel/scripts/view.php +++ b/lodel/scripts/view.php @@ -519,6 +519,7 @@ private function _eval($contents, &$context) } ob_start(); + //var_dump($contents); eval("?>" . $contents); $contents = ob_get_clean(); } diff --git a/lodel/src/lodel/edition/oochargement.php b/lodel/src/lodel/edition/oochargement.php index 51a9a093b..60db835e1 100644 --- a/lodel/src/lodel/edition/oochargement.php +++ b/lodel/src/lodel/edition/oochargement.php @@ -159,7 +159,7 @@ function printErrors($errors, $exit = true, $isFrame = true) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) { $var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -257,7 +257,7 @@ function removefilesfromimport($rep) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } @@ -418,7 +418,7 @@ function removefilesfromimport($rep) if(empty($context['multiple']) && C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
'. print_r($contents, 1) . '
'; die(); } From 242dfa0a48685cf1dd15abf93d807797fc16621b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Prieto?= Date: Mon, 29 Apr 2019 15:14:44 +0200 Subject: [PATCH 06/10] =?UTF-8?q?R=C3=A9=C3=A9criture=20foreach=20rempla?= =?UTF-8?q?=C3=A7ant=20each?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lodel/scripts/imapfunc.php | 4 ++-- lodel/scripts/logic/class.entities_index.php | 4 ++-- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 265ebd83d..ac9196b40 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - foreach ($struct->parts as list($j)) { + foreach ($struct->parts as $j) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } @@ -118,4 +118,4 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") } return $nbattachment; } -?> \ No newline at end of file +?> diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 5cee7d25e..74d08c4ac 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -218,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - foreach ($tokens as list(, $token)) { + foreach ($tokens as $token) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! @@ -304,4 +304,4 @@ protected function _indexEntitiesRelations ($id, $nature, $daoIndex) } }//end of class -?> \ No newline at end of file +?> diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 3fbd1b01d..4d851ce34 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - foreach ($a_name as list($key, $val)) { + foreach ($a_name as $key => $val) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 0e1fe56de..0dcb6ab92 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - foreach ($comments_map as list($comment_field, $comment)) { + foreach ($comments_map as $comment_field => $comment) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - foreach ($mime_map as list($mime_field, $mime)) { + foreach ($mime_map as $mime_field => $mime) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - foreach ($res_rel as list($rel_field, $rel)) { + foreach ($res_rel as $rel_field => $rel) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - foreach ($index as list($x, $columns)) { + foreach ($index as $x => $columns) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index b4f678e76..0b2673756 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { + foreach ($cfg['SQP']['fmtColor'] as $key => $col) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { From e3463714a9d69d00177654906f6eb59d72bcfe2a Mon Sep 17 00:00:00 2001 From: lnprieto Date: Fri, 8 Nov 2019 09:19:00 +0100 Subject: [PATCH 07/10] Change
to
--- lodel/src/lodel/edition/tpl/unpublish_confirm.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lodel/src/lodel/edition/tpl/unpublish_confirm.html b/lodel/src/lodel/edition/tpl/unpublish_confirm.html index de9bef8f0..e7e0ef6be 100644 --- a/lodel/src/lodel/edition/tpl/unpublish_confirm.html +++ b/lodel/src/lodel/edition/tpl/unpublish_confirm.html @@ -19,7 +19,7 @@ -[@EDITION.FOLLOWING_ENTITIES_ARE_PROTECTED_CONFIRM_UNPUBLISIHING]:
+[@EDITION.FOLLOWING_ENTITIES_ARE_PROTECTED_CONFIRM_UNPUBLISIHING]:

    @@ -38,4 +38,4 @@ - \ No newline at end of file + From d16e2f4d4e4a76ad896d4b8b91b5c51bb9b6d15c Mon Sep 17 00:00:00 2001 From: lnprieto Date: Mon, 3 Dec 2018 11:42:34 +0100 Subject: [PATCH 08/10] php 7.2 compatibility --- lodel/scripts/checkxml.php | 6 ++++-- lodel/scripts/filterfunc.php | 3 ++- lodel/scripts/imapfunc.php | 2 +- lodel/scripts/lodelparser.php | 14 ++++++++++---- lodel/scripts/logic.php | 4 +++- lodel/scripts/logic/class.data.php | 2 +- lodel/scripts/logic/class.entities_index.php | 8 +++++--- lodel/scripts/logic/class.translations.php | 2 +- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/defines.lib.php | 4 ++-- lodel/scripts/pma/defines_php.lib.php | 17 ++++------------- lodel/scripts/pma/mysql_wrappers.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 4 ++-- lodel/scripts/servooclient.php | 4 ++-- lodel/scripts/servoofunc.php | 2 +- lodel/scripts/textfunc.php | 8 ++++---- lodel/scripts/view.php | 1 + lodel/src/lodel/edition/oochargement.php | 6 +++--- 19 files changed, 52 insertions(+), 47 deletions(-) diff --git a/lodel/scripts/checkxml.php b/lodel/scripts/checkxml.php index 03300f333..83710ff11 100644 --- a/lodel/scripts/checkxml.php +++ b/lodel/scripts/checkxml.php @@ -50,7 +50,8 @@ function checkstring(&$text, $error = 0) return; } else { echo ""; - echo preg_replace("/\n/se", "'
    '.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + //echo preg_replace("/\n/se", "'
    '.((\$GLOBALS['line']++)+2).' '", htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); + echo preg_replace_callback("/\n/s", function ($str) { return '
    '.(($GLOBALS['line']++)+2).' '; } , htmlspecialchars(substr($text, xml_get_current_byte_index($xml_parser) - 2))); echo "
    \n"; echo sprintf("

    XML error: %s ligne %d

    ", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)); echo "L'erreur se situe avant la zone rouge. Elle peut etre due a une erreur bien au dessus la ligne donne par le parser
    "; @@ -71,7 +72,8 @@ function checkstring(&$text, $error = 0) */ function characterHandlerCHECK($parser, $data) { - echo preg_replace("/\n/se", "'
    '.((\$GLOBALS[line]++)+2).' '", $data); + //echo preg_replace("/\n/se", "'
    '.((\$GLOBALS[line]++)+2).' '", $data); + echo preg_replace_callback("/\n/s", function ($str) { return '
    '.(($GLOBALS[line]++)+2).' '; }, $data); } diff --git a/lodel/scripts/filterfunc.php b/lodel/scripts/filterfunc.php index 1483c5dc9..5cdd6329a 100644 --- a/lodel/scripts/filterfunc.php +++ b/lodel/scripts/filterfunc.php @@ -43,7 +43,8 @@ function makefilterfunc() $arg = $result2[2]; // argument if any // process the variable. The processing is simple here. Need more ? Sould be associated with parser variable processing. - $arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + //$arg = preg_replace("/\[\#([A-Z][A-Z_0-9]*)\]/e", ' "$"."context[".strtolower("\\1")."]" ', $arg); + $arg = preg_replace_callback("/\[\#([A-Z][A-Z_0-9]*)\]/", function ($test) { return "$"."context[".strtolower($test[1])."]";} , $arg); if ($arg) { $arg = ','. $arg; diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 21fc1efd3..265ebd83d 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - while (list ($j) = each($struct->parts)) { + foreach ($struct->parts as list($j)) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } diff --git a/lodel/scripts/lodelparser.php b/lodel/scripts/lodelparser.php index f80dfc47e..ae3ed9e5a 100644 --- a/lodel/scripts/lodelparser.php +++ b/lodel/scripts/lodelparser.php @@ -560,12 +560,18 @@ protected function parse_after(& $text) tpl}"; if(!isset(\$GLOBALS['langcache'][\$context['sitelang']])) { \$GLOBALS['langcache'][\$context['sitelang']] = array(); } -if (!(\$langcontents = cache_get(\$langfile))) { - \$GLOBALS['langcache'][\$context['sitelang']] += generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); +\$langcontents = cache_get(\$langfile); + +if (\$langcontents === false) { + \$cachelang = generateLangCache(\$context['sitelang'], \$langfile, array({$tt})); + if (!is_array(\$cachelang)) { + \$cachelang = array(\$cachelang); + } + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$cachelang); } else { - \$GLOBALS['langcache'][\$context['sitelang']] += \$langcontents; + array_merge(\$GLOBALS['langcache'][\$context['sitelang']], \$langcontents); } -unset(\$langfile, \$langcontents); +unset(\$langfile, \$langcontents, \$cachelang); ?> {$text} PHP; diff --git a/lodel/scripts/logic.php b/lodel/scripts/logic.php index fff2ab1d2..d7ab09f83 100644 --- a/lodel/scripts/logic.php +++ b/lodel/scripts/logic.php @@ -504,7 +504,9 @@ protected function _makeMask(&$context, &$error) $mask = $context['mask']['user']; if(isset($context['mask_regexp'])) { // disable eval options for more security - $mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); + $mask = $context['mask']['user'] = preg_replace_callback("/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/s", + function ($text){return($text[1].$text[2].$text[1].str_replace('e','',"$text[4]"));},$mask); + //$mask = $context['mask']['user'] = preg_replace('/^(.)(.*)(\\1)([msieDASuUXxJ]*)?$/e', "'\\1'.\\2.'\\1'.str_replace('e', '', \"\\4\")", $mask); if(FALSE === @preg_match($mask, 'just a test for user regexp')) { $error['mask'] = 'mask: '.getlodeltextcontents('mask_bad_regexp', 'common'); return; diff --git a/lodel/scripts/logic/class.data.php b/lodel/scripts/logic/class.data.php index ff58c3404..3b40c426e 100644 --- a/lodel/scripts/logic/class.data.php +++ b/lodel/scripts/logic/class.data.php @@ -1920,7 +1920,7 @@ private function _updateTypes($datas, &$error='') { } $field = $db->GetRow("SELECT * FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
    ".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); unset($field['id']); - array_walk($field, create_function('&$f', '$f = addcslashes($f, "\'");')); + array_walk($field, function(&$f) { $f = addcslashes($f, "\'");}); $db->execute("INSERT INTO `{$table}` ({$typesFields}) VALUES ('{$id}','".join("','", $field)."')") or trigger_error("SQL ERROR :
    ".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $fieldName = $db->getOne("SELECT type FROM `{$table}__oldME` WHERE id = '{$val}'") or trigger_error("SQL ERROR :
    ".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); $db->execute("INSERT INTO `$tablefieldsTable`(name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask) (SELECT name, idgroup, class, title, altertitle, style, type, g_name, cond, defaultvalue, processing, allowedtags, gui_user_complexity, filtering, edition, editionparams, weight, comment, status, rank, upd, mask FROM `{$tablefieldsTable}__oldME` WHERE name = '{$fieldName}');\n") or trigger_error("SQL ERROR :
    ".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR); diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 15e820112..5cee7d25e 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -184,8 +184,10 @@ protected function _indexField ($id, $fieldValue, $fieldName, $fieldWeight, $dao */ protected function _decode_html_entities($text) { - $text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation - $text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation + $text= preg_replace_callback('/&#(\d+);/m',function ($str) { return utf8_encode(chr($str[1])); },$text); #decimal notation + $text= preg_replace_callback('/&#x([a-f0-9]+);/mi',function ($str) { return utf8_encode(chr(hexdec('0x'.$str[1]))); },$text); #hex notation + //$text= preg_replace('/&#(\d+);/me',utf8_encode("chr(\\1)"),$text); #decimal notation + //$text= preg_replace('/&#x([a-f0-9]+);/mei',utf8_encode("chr(0x\\1)"),$text); #hex notation return $text; } @@ -216,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - while (list (, $token) = each ($tokens)) { + foreach ($tokens as list(, $token)) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! diff --git a/lodel/scripts/logic/class.translations.php b/lodel/scripts/logic/class.translations.php index b659bc14d..6a330f20d 100644 --- a/lodel/scripts/logic/class.translations.php +++ b/lodel/scripts/logic/class.translations.php @@ -352,7 +352,7 @@ protected function _saveRelatedTables($vo,&$context) #if (in_array($lang,$langs)) continue; // the text already exists in the correct lang #echo $row['name']," "; - $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysql_escape_string($row['contents'])."','-1','".$context['lang']."')"; + $inserts[]="('".$row['name']."','".$row['textgroup']."','".mysqli_escape_string($row['contents'])."','-1','".$context['lang']."')"; $count++; $result->MoveNext(); } diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 98d082cb9..3fbd1b01d 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - while(list($key, $val) = each($a_name)) { + foreach ($a_name as list($key, $val)) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/defines.lib.php b/lodel/scripts/pma/defines.lib.php index b8b705f9a..b30a521aa 100644 --- a/lodel/scripts/pma/defines.lib.php +++ b/lodel/scripts/pma/defines.lib.php @@ -58,8 +58,8 @@ // php 4.1+ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { - $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; + } else if (!empty($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } diff --git a/lodel/scripts/pma/defines_php.lib.php b/lodel/scripts/pma/defines_php.lib.php index 997f41408..4bafdb7d7 100644 --- a/lodel/scripts/pma/defines_php.lib.php +++ b/lodel/scripts/pma/defines_php.lib.php @@ -42,16 +42,7 @@ // MySQL client API if (!defined('PMA_MYSQL_CLIENT_API')) { - if (function_exists('mysql_get_client_info') || function_exists('mysqli_get_client_info')) { - if('mysql' == DBDRIVER) - $client_api = mysql_get_client_info(); - else - $client_api = mysqli_get_client_info(); - } else { - // for compatibility with php <= 4.0.5 - // expect the worst! - $client_api = '3.21.0'; - } + $client_api = mysqli_get_client_info(); $client_api = explode('.', $client_api); define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2]))); unset($client_api); @@ -80,8 +71,8 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('Thread Safety[[:space:]]*enabled', $a)) { - if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { + if (preg_match('Thread Safety[[:space:]]*enabled', $a)) { + if (preg_match('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; } else { $GLOBALS['PMA_dl_allowed'] = FALSE; @@ -134,7 +125,7 @@ function PMA_dl($module) { $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { + if (preg_match('GD Version[[:space:]]*\(.*\)', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else { diff --git a/lodel/scripts/pma/mysql_wrappers.lib.php b/lodel/scripts/pma/mysql_wrappers.lib.php index 977576b6d..f5163138e 100644 --- a/lodel/scripts/pma/mysql_wrappers.lib.php +++ b/lodel/scripts/pma/mysql_wrappers.lib.php @@ -73,7 +73,7 @@ function PMA_mysql_fetch_array($result, $type = FALSE) { if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]); } else { /* Meta information available -> check type of field and convert it according to the type */ - if ($meta->blob || eregi('BINARY', $meta->type)) { + if ($meta->blob || preg_match('BINARY/i', $meta->type)) { if (isset($data[$i])) $ret[$i] = $data[$i]; if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name]; } else { diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 4c0746eaa..0e1fe56de 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - while(list($comment_field, $comment) = each($comments_map)) { + foreach ($comments_map as list($comment_field, $comment)) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - while(list($mime_field, $mime) = each($mime_map)) { + foreach ($mime_map as list($mime_field, $mime)) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - while(list($rel_field, $rel) = each($res_rel)) { + foreach ($res_rel as list($rel_field, $rel)) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - while (list($x, $columns) = @each($index)) { + foreach ($index as list($x, $columns)) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index 2214cb268..b4f678e76 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - while (list($key, $col) = each($cfg['SQP']['fmtColor'])) { + foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { @@ -1993,7 +1993,7 @@ function PMA_SQP_buildCssData() function PMA_SQP_formatNone($arr) { $formatted_sql = htmlspecialchars($arr['raw']); - $formatted_sql = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); + $formatted_sql = preg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $formatted_sql); return $formatted_sql; } // end of the "PMA_SQP_formatNone()" function diff --git a/lodel/scripts/servooclient.php b/lodel/scripts/servooclient.php index 105d91e8c..c85a10284 100644 --- a/lodel/scripts/servooclient.php +++ b/lodel/scripts/servooclient.php @@ -64,7 +64,7 @@ class ServOO_Client { * @param string $url Location of the ServOO server. */ - function ServOO_Client($url) { + function __construct($url) { $this->_soapclient = new soapclientmime($url); $err = $this->_soapclient->getError(); @@ -576,7 +576,7 @@ function _convertToXML_Pre_Extract_CB($p_event, &$p_header) class servooattachment { var $cid; - function servooattachment($cid) { + function __construct($cid) { $this->cid=$cid; } diff --git a/lodel/scripts/servoofunc.php b/lodel/scripts/servoofunc.php index 53eecc89f..9261a1dee 100644 --- a/lodel/scripts/servoofunc.php +++ b/lodel/scripts/servoofunc.php @@ -12,7 +12,7 @@ class ServOO extends ServOO_Client { private $options; // username / passwd / url public $status; // true ou false - function ServOO($other = "") { + function __construct($other = "") { if(!empty($other)) { if(FALSE === $this->SelectOtherServer($other)) { $this->status = FALSE; diff --git a/lodel/scripts/textfunc.php b/lodel/scripts/textfunc.php index 86756ea4a..fe28efde5 100644 --- a/lodel/scripts/textfunc.php +++ b/lodel/scripts/textfunc.php @@ -214,10 +214,10 @@ function spip($letexte) { $puce = ""; // Harmoniser les retours chariot - $letexte = ereg_replace("\r\n?", "\n", $letexte); + $letexte = preg_replace("\r\n?", "\n", $letexte); // Corriger HTML - $letexte = eregi_replace("", "\n\n\n", $letexte); + $letexte = preg_replace("/i", "\n\n\n", $letexte); // // Raccourcis liens @@ -225,14 +225,14 @@ function spip($letexte) $regexp = "\[([^][]*)->([^]]*)\]"; $texte_a_voir = $letexte; $texte_vu = ''; - while (ereg($regexp, $texte_a_voir, $regs)) { + while (preg($regexp, $texte_a_voir, $regs)) { $lien_texte = $regs[1]; $lien_url = trim($regs[2]); $compt_liens ++; $lien_interne = false; $insert = "".$lien_texte.""; - $zetexte = split($regexp, $texte_a_voir, 2); + $zetexte = preg_split($regexp, $texte_a_voir, 2); $texte_vu .= $zetexte[0].$insert; $texte_a_voir = $zetexte[1]; } diff --git a/lodel/scripts/view.php b/lodel/scripts/view.php index 7bc327b24..b3077b911 100644 --- a/lodel/scripts/view.php +++ b/lodel/scripts/view.php @@ -519,6 +519,7 @@ private function _eval($contents, &$context) } ob_start(); + //var_dump($contents); eval("?>" . $contents); $contents = ob_get_clean(); } diff --git a/lodel/src/lodel/edition/oochargement.php b/lodel/src/lodel/edition/oochargement.php index 51a9a093b..60db835e1 100644 --- a/lodel/src/lodel/edition/oochargement.php +++ b/lodel/src/lodel/edition/oochargement.php @@ -159,7 +159,7 @@ function printErrors($errors, $exit = true, $isFrame = true) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) { $var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
    '. print_r($contents, 1) . '
    '; die(); } @@ -257,7 +257,7 @@ function removefilesfromimport($rep) if(C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
    '. print_r($contents, 1) . '
    '; die(); } @@ -418,7 +418,7 @@ function removefilesfromimport($rep) if(empty($context['multiple']) && C::get('sortie') && C::get('adminlodel', 'lodeluser')) { - array_walk_recursive($contents, create_function('&$var', '$var = htmlentities($var, ENT_COMPAT, "UTF-8");')); + array_walk_recursive($contents, function(&$var) {$var = htmlentities($var, ENT_COMPAT, "UTF-8");}); echo '
    '. print_r($contents, 1) . '
    '; die(); } From 62763533f817b2b07e177fdfe2eef74b7b95b242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Prieto?= Date: Mon, 29 Apr 2019 15:14:44 +0200 Subject: [PATCH 09/10] =?UTF-8?q?R=C3=A9=C3=A9criture=20foreach=20rempla?= =?UTF-8?q?=C3=A7ant=20each?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lodel/scripts/imapfunc.php | 4 ++-- lodel/scripts/logic/class.entities_index.php | 4 ++-- lodel/scripts/pma/common.lib.php | 2 +- lodel/scripts/pma/sql-modified.php | 8 ++++---- lodel/scripts/pma/sqlparser.lib.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lodel/scripts/imapfunc.php b/lodel/scripts/imapfunc.php index 265ebd83d..ac9196b40 100644 --- a/lodel/scripts/imapfunc.php +++ b/lodel/scripts/imapfunc.php @@ -70,7 +70,7 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") if ($pno) { $pno .= "."; } - foreach ($struct->parts as list($j)) { + foreach ($struct->parts as $j) { $nbattachment += extractattachments($mbox, $mnum, $extre, $struct->parts[$j], $pno.$partno); $partno ++; } @@ -118,4 +118,4 @@ function extractattachments($mbox, $mnum, $extre, $struct = 0, $pno = "") } return $nbattachment; } -?> \ No newline at end of file +?> diff --git a/lodel/scripts/logic/class.entities_index.php b/lodel/scripts/logic/class.entities_index.php index 5cee7d25e..74d08c4ac 100644 --- a/lodel/scripts/logic/class.entities_index.php +++ b/lodel/scripts/logic/class.entities_index.php @@ -218,7 +218,7 @@ protected function _cleanAndcountTokens ($string, $regs=0) { $tokens = $this->_splitInTokens($string,$regs); $indexs = array();//Array of each word weight for this field - foreach ($tokens as list(, $token)) { + foreach ($tokens as $token) { //particular case : two letter acronym or initials if (preg_match ("/([A-Z][0-9A-Z]{1,2})/", $token) || strlen ($token) > 3) { //little hack because oe ligature is not supported in ISO-latin!! @@ -304,4 +304,4 @@ protected function _indexEntitiesRelations ($id, $nature, $daoIndex) } }//end of class -?> \ No newline at end of file +?> diff --git a/lodel/scripts/pma/common.lib.php b/lodel/scripts/pma/common.lib.php index 3fbd1b01d..4d851ce34 100644 --- a/lodel/scripts/pma/common.lib.php +++ b/lodel/scripts/pma/common.lib.php @@ -32,7 +32,7 @@ function PMA_backquote($a_name, $do_it = TRUE) if (is_array($a_name)) { $result = array(); reset($a_name); - foreach ($a_name as list($key, $val)) { + foreach ($a_name as $key => $val) { $result[$key] = '`' . $val . '`'; } return $result; diff --git a/lodel/scripts/pma/sql-modified.php b/lodel/scripts/pma/sql-modified.php index 0e1fe56de..0dcb6ab92 100644 --- a/lodel/scripts/pma/sql-modified.php +++ b/lodel/scripts/pma/sql-modified.php @@ -269,7 +269,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($comments_map) && count($comments_map) > 0) { $schema_create .= $crlf . $crlf . '/* COMMENTS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($comments_map); - foreach ($comments_map as list($comment_field, $comment)) { + foreach ($comments_map as $comment_field => $comment) { $schema_create .= ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -279,7 +279,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if (isset($mime_map) && count($mime_map) > 0) { $schema_create .= $crlf . $crlf . '/* MIME TYPES FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($mime_map); - foreach ($mime_map as list($mime_field, $mime)) { + foreach ($mime_map as $mime_field => $mime) { $schema_create .= ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -289,7 +289,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ if ($have_rel) { $schema_create .= $crlf . $crlf . '/* RELATIONS FOR TABLE ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf; @reset($res_rel); - foreach ($res_rel as list($rel_field, $rel)) { + foreach ($res_rel as $rel_field => $rel) { $schema_create .= ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes) . ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf; // omitting html_format is intentional. No use for htmlchars in the dump. } @@ -352,7 +352,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation = false, $ } // end while $result->Close(); - foreach ($index as list($x, $columns)) { + foreach ($index as $x => $columns) { $schema_create .= ',' . $crlf; if ($x == 'PRIMARY') { $schema_create .= ' PRIMARY KEY ('; diff --git a/lodel/scripts/pma/sqlparser.lib.php b/lodel/scripts/pma/sqlparser.lib.php index b4f678e76..0b2673756 100644 --- a/lodel/scripts/pma/sqlparser.lib.php +++ b/lodel/scripts/pma/sqlparser.lib.php @@ -1970,7 +1970,7 @@ function PMA_SQP_buildCssData() global $cfg; $css_string = ''; - foreach ($cfg['SQP']['fmtColor'] as list($key, $col)) { + foreach ($cfg['SQP']['fmtColor'] as $key => $col) { $css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col); } for ($i = 0; $i < 8; $i++) { From 6d036ae8930bb0c2aef1392625e9b41714ce8528 Mon Sep 17 00:00:00 2001 From: lnprieto Date: Fri, 8 Nov 2019 09:19:00 +0100 Subject: [PATCH 10/10] Change
    to
    --- lodel/src/lodel/edition/tpl/unpublish_confirm.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lodel/src/lodel/edition/tpl/unpublish_confirm.html b/lodel/src/lodel/edition/tpl/unpublish_confirm.html index de9bef8f0..e7e0ef6be 100644 --- a/lodel/src/lodel/edition/tpl/unpublish_confirm.html +++ b/lodel/src/lodel/edition/tpl/unpublish_confirm.html @@ -19,7 +19,7 @@ -[@EDITION.FOLLOWING_ENTITIES_ARE_PROTECTED_CONFIRM_UNPUBLISIHING]:
    +[@EDITION.FOLLOWING_ENTITIES_ARE_PROTECTED_CONFIRM_UNPUBLISIHING]:

      @@ -38,4 +38,4 @@ - \ No newline at end of file +