Curly brace syntax for accessing array elements and string offsets will be deprecated as of PHP 7.4 - changed to square brackets. See also https://wiki.php.net/rfc/deprecate_curly_braces_array_access

This commit is contained in:
azett 2019-11-18 16:56:57 +01:00
parent 76dbaa342b
commit b6f32d1f4f
3 changed files with 99 additions and 101 deletions

View File

@ -1,52 +1,50 @@
<?php <?php
function config_read($fullpath) { function config_read($fullpath) {
if ($fullpath{0}!='/') if ($fullpath [0] != '/')
trigger_error('config_read: syntax error. Path must begin with a /'); trigger_error('config_read: syntax error. Path must begin with a /');
$last_slash = strrpos($fullpath, '/'); $last_slash = strrpos($fullpath, '/');
$option = substr($fullpath, $last_slash + 1); $option = substr($fullpath, $last_slash + 1);
$path = substr($fullpath, 1, $last_slash); $path = substr($fullpath, 1, $last_slash);
$file = str_replace('/', '.', $path) . 'conf.php'; $file = str_replace('/', '.', $path) . 'conf.php';
$f = CONFIG_DIR . $file; $f = CONFIG_DIR . $file;
if (file_exists($f)) { if (file_exists($f)) {
include($f); include ($f);
}
$arr = explode('/', $fullpath);
/* todo finire */
}
// a cosmetic wrapper around an include :D
// plus, loads the defaults if CONFIG_FILE is not found
function config_load($conffile=CONFIG_FILE) {
if ( !file_exists($conffile) && ($conffile==CONFIG_FILE) )
$conffile = CONFIG_DEFAULT;
include $conffile;
// todo CHANGE
//$fp_config['general'] = array_change_key_case($blog_confi);
return $fp_config;
} }
$arr = explode('/', $fullpath);
// $conf_arr can have a variable number of args /* todo finire */
// they are the same of system_save(), as this is in fact }
// a wrapper to that ;)
// so: // a cosmetic wrapper around an include :D
// $conf_arr[ 'myvariable' ] = $myvariable; // plus, loads the defaults if CONFIG_FILE is not found
function config_save($conf_arr=null, $conffile=CONFIG_FILE) { function config_load($conffile = CONFIG_FILE) {
if ($conf_arr==null) { if (!file_exists($conffile) && ($conffile == CONFIG_FILE))
global $fp_config; $conffile = CONFIG_DEFAULT;
$conf_arr=$fp_config;
} include $conffile;
$arr = array('fp_config' => $conf_arr); // todo CHANGE
return system_save($conffile, $arr); // $fp_config['general'] = array_change_key_case($blog_confi);
return $fp_config;
}
// $conf_arr can have a variable number of args
// they are the same of system_save(), as this is in fact
// a wrapper to that ;)
// so:
// $conf_arr[ 'myvariable' ] = $myvariable;
function config_save($conf_arr = null, $conffile = CONFIG_FILE) {
if ($conf_arr == null) {
global $fp_config;
$conf_arr = $fp_config;
} }
$arr = array(
'fp_config' => $conf_arr
);
return system_save($conffile, $arr);
}
?> ?>

View File

@ -276,7 +276,7 @@ function utils_microtime() {
function utils_countdashes($string, &$rest) { function utils_countdashes($string, &$rest) {
trim($string); trim($string);
$i = 0; $i = 0;
while ($string {$i} == '-') { while ($string [$i] == '-') {
$i++; $i++;
} }
if ($i) if ($i)

View File

@ -8,15 +8,15 @@ function wptexturize($text) {
$skip = 0; // loop stuff $skip = 0; // loop stuff
for($i = 0; $i < $stop; $i++) { for($i = 0; $i < $stop; $i++) {
$curl = $textarr [$i]; $curl = $textarr [$i];
if (isset($curl {0}) && '<' != $curl {0} && $skip == 0) { // If it's not a tag if (isset($curl [0]) && '<' != $curl [0] && $skip == 0) { // If it's not a tag
$curl = str_replace('---', '&#8212;', $curl); $curl = str_replace('---', '&#8212;', $curl);
$curl = str_replace(' -- ', ' &#8212; ', $curl); $curl = str_replace(' -- ', ' &#8212; ', $curl);
$curl = str_replace('--', '&#8211;', $curl); $curl = str_replace('--', '&#8211;', $curl);
$curl = str_replace('xn&#8211;', 'xn--', $curl); $curl = str_replace('xn&#8211;', 'xn--', $curl);
$curl = str_replace('...', '&#8230;', $curl); $curl = str_replace('...', '&#8230;', $curl);
$curl = str_replace('``', '&#8220;', $curl); $curl = str_replace('``', '&#8220;', $curl);
// This is a hack, look at this more later. It works pretty well though. // This is a hack, look at this more later. It works pretty well though.
$cockney = array( $cockney = array(
"'tain't", "'tain't",
@ -43,25 +43,25 @@ function wptexturize($text) {
"&#8217;cause" "&#8217;cause"
); );
$curl = str_replace($cockney, $cockneyreplace, $curl); $curl = str_replace($cockney, $cockneyreplace, $curl);
$curl = preg_replace("/'s/", '&#8217;s', $curl); $curl = preg_replace("/'s/", '&#8217;s', $curl);
$curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl); $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
$curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl); $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
// $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl); // $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
$curl = preg_replace('/(\s|\A)("|&quot;)(?!\s)/', '$1&#8220;$3', $curl); $curl = preg_replace('/(\s|\A)("|&quot;)(?!\s)/', '$1&#8220;$3', $curl);
$curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl); $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
$curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl); $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
// $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl); // $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
$curl = preg_replace('/(\s|\A)("|&quot;)(?!\s)/', '$1&#8220;$3', $curl); $curl = preg_replace('/(\s|\A)("|&quot;)(?!\s)/', '$1&#8220;$3', $curl);
$curl = preg_replace('/("|&quot;)(\s|\S|\Z)/', '&#8221;$2', $curl); $curl = preg_replace('/("|&quot;)(\s|\S|\Z)/', '&#8221;$2', $curl);
$curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl); $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
$curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl); $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
$curl = str_replace("''", '&#8221;', $curl); $curl = str_replace("''", '&#8221;', $curl);
$curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl); $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
} elseif (strstr($curl, '</') || strstr($curl, '/>')) { } elseif (strstr($curl, '</') || strstr($curl, '/>')) {
if ($skip > 0) if ($skip > 0)
@ -70,7 +70,7 @@ function wptexturize($text) {
// strstr is fast // strstr is fast
$skip++; $skip++;
} else { } else {
if (isset($curl {0}) && $curl {0} == "<" && $skip > 0) if (isset($curl [0]) && $curl [0] == "<" && $skip > 0)
$skip++; $skip++;
} }
$curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $curl); $curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&#038;$1', $curl);
@ -84,7 +84,7 @@ function clean_pre($matches) {
$text = $matches [1] . $matches [2] . "</pre>"; $text = $matches [1] . $matches [2] . "</pre>";
else else
$text = $matches; $text = $matches;
/* NWM: a bit hackish? where are the slashes for double quotes added? */ /* NWM: a bit hackish? where are the slashes for double quotes added? */
$text = str_replace('\"', '"', $text); $text = str_replace('\"', '"', $text);
$text = str_replace('<br />', '', $text); $text = str_replace('<br />', '', $text);
@ -150,7 +150,7 @@ function wpautop($pee, $br = 1) {
if (strpos($pee, '<pre') !== false) if (strpos($pee, '<pre') !== false)
$pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee); $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee);
$pee = preg_replace("|\n</p>$|", '</p>', $pee); $pee = preg_replace("|\n</p>$|", '</p>', $pee);
return $pee; return $pee;
} }
@ -208,7 +208,7 @@ function wp_specialchars($text, $quotes = 0) {
$text = str_replace('"', '&quot;', $text); $text = str_replace('"', '&quot;', $text);
$text = str_replace("'", '&#039;', $text); $text = str_replace("'", '&#039;', $text);
} }
return $text; return $text;
} }
@ -216,32 +216,32 @@ function utf8_uri_encode($utf8_string) {
$unicode = ''; $unicode = '';
$values = array(); $values = array();
$num_octets = 1; $num_octets = 1;
for($i = 0; $i < strlen($utf8_string); $i++) { for($i = 0; $i < strlen($utf8_string); $i++) {
$value = ord($utf8_string [$i]); $value = ord($utf8_string [$i]);
if ($value < 128) { if ($value < 128) {
$unicode .= chr($value); $unicode .= chr($value);
} else { } else {
if (count($values) == 0) if (count($values) == 0)
$num_octets = ($value < 224) ? 2 : 3; $num_octets = ($value < 224) ? 2 : 3;
$values [] = $value; $values [] = $value;
if (count($values) == $num_octets) { if (count($values) == $num_octets) {
if ($num_octets == 3) { if ($num_octets == 3) {
$unicode .= '%' . dechex($values [0]) . '%' . dechex($values [1]) . '%' . dechex($values [2]); $unicode .= '%' . dechex($values [0]) . '%' . dechex($values [1]) . '%' . dechex($values [2]);
} else { } else {
$unicode .= '%' . dechex($values [0]) . '%' . dechex($values [1]); $unicode .= '%' . dechex($values [0]) . '%' . dechex($values [1]);
} }
$values = array(); $values = array();
$num_octets = 1; $num_octets = 1;
} }
} }
} }
return $unicode; return $unicode;
} }
@ -436,14 +436,14 @@ function remove_accents($string) {
// Euro Sign // Euro Sign
chr(226) . chr(130) . chr(172) => 'E' chr(226) . chr(130) . chr(172) => 'E'
); );
$string = strtr($string, $chars); $string = strtr($string, $chars);
} else { } else {
// Assume ISO-8859-1 if not UTF-8 // Assume ISO-8859-1 if not UTF-8
$chars ['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255); $chars ['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255);
$chars ['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $chars ['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
$string = strtr($string, $chars ['in'], $chars ['out']); $string = strtr($string, $chars ['in'], $chars ['out']);
$double_chars ['in'] = array( $double_chars ['in'] = array(
chr(140), chr(140),
@ -469,32 +469,32 @@ function remove_accents($string) {
); );
$string = str_replace($double_chars ['in'], $double_chars ['out'], $string); $string = str_replace($double_chars ['in'], $double_chars ['out'], $string);
} }
return $string; return $string;
} }
function sanitize_title($title, $fallback_title = '') { function sanitize_title($title, $fallback_title = '') {
$title = strip_tags($title); $title = strip_tags($title);
$title = apply_filters('sanitize_title', $title); $title = apply_filters('sanitize_title', $title);
if (empty($title)) { if (empty($title)) {
$title = $fallback_title; $title = $fallback_title;
} }
return $title; return $title;
} }
function sanitize_title_with_dashes($title) { function sanitize_title_with_dashes($title) {
$title = strip_tags($title); $title = strip_tags($title);
if (seems_utf8($title)) { if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) { if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8'); $title = mb_strtolower($title, 'UTF-8');
} }
$title = utf8_uri_encode($title); $title = utf8_uri_encode($title);
} }
// Preserve escaped octets. // Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet. // Remove percent signs that are not part of an octet.
@ -503,26 +503,26 @@ function sanitize_title_with_dashes($title) {
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
// and finally: Kill octets // and finally: Kill octets
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $title); $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $title);
// remove accents // remove accents
$title = remove_accents($title); $title = remove_accents($title);
// title is in lower case always // title is in lower case always
$title = strtolower($title); $title = strtolower($title);
// kill entities // kill entities
$title = preg_replace('/&.+?;/', '', $title); $title = preg_replace('/&.+?;/', '', $title);
// kill special chars // kill special chars
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
// replace spaces by dash // replace spaces by dash
$title = preg_replace('/\s+/', '-', $title); $title = preg_replace('/\s+/', '-', $title);
// Kill multiple dashes // Kill multiple dashes
$title = preg_replace('|-+|', '-', $title); $title = preg_replace('|-+|', '-', $title);
// kill dashes at beginning and end of string // kill dashes at beginning and end of string
$title = trim($title, '-'); $title = trim($title, '-');
return $title; return $title;
} }
@ -562,31 +562,31 @@ function convert_chars($content, $flag = 'obsolete') {
'&#158;' => '', '&#158;' => '',
'&#159;' => '&#376;' '&#159;' => '&#376;'
); );
// Remove metadata tags // Remove metadata tags
$content = preg_replace('/<title>(.+?)<\/title>/', '', $content); $content = preg_replace('/<title>(.+?)<\/title>/', '', $content);
$content = preg_replace('/<category>(.+?)<\/category>/', '', $content); $content = preg_replace('/<category>(.+?)<\/category>/', '', $content);
// Converts lone & characters into &#38; (a.k.a. &amp;) // Converts lone & characters into &#38; (a.k.a. &amp;)
$content = preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $content); $content = preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $content);
// Fix Word pasting // Fix Word pasting
$content = strtr($content, $wp_htmltranswinuni); $content = strtr($content, $wp_htmltranswinuni);
// Just a little XHTML help // Just a little XHTML help
$content = str_replace('<br>', '<br />', $content); $content = str_replace('<br>', '<br />', $content);
$content = str_replace('<hr>', '<hr />', $content); $content = str_replace('<hr>', '<hr />', $content);
return $content; return $content;
} }
function funky_javascript_fix($text) { function funky_javascript_fix($text) {
// Fixes for browsers' javascript bugs // Fixes for browsers' javascript bugs
global $is_macIE, $is_winIE; global $is_macIE, $is_winIE;
if ($is_winIE || $is_macIE) if ($is_winIE || $is_macIE)
$text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text); $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text);
return $text; return $text;
} }
@ -610,7 +610,7 @@ function funky_javascript_fix($text) {
* 1.0 First Version * 1.0 First Version
*/ */
function balanceTags($text, $is_comment = 0) { function balanceTags($text, $is_comment = 0) {
/* /*
* if (get_settings('use_balanceTags') == 0) { * if (get_settings('use_balanceTags') == 0) {
* return $text; * return $text;
@ -620,18 +620,18 @@ function balanceTags($text, $is_comment = 0) {
$stacksize = 0; $stacksize = 0;
$tagqueue = ''; $tagqueue = '';
$newtext = ''; $newtext = '';
// WP bug fix for comments - in case you REALLY meant to type '< !--' // WP bug fix for comments - in case you REALLY meant to type '< !--'
$text = str_replace('< !--', '< !--', $text); $text = str_replace('< !--', '< !--', $text);
// WP bug fix for LOVE <3 (and other situations with '<' before a number) // WP bug fix for LOVE <3 (and other situations with '<' before a number)
$text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text); $text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text);
while (preg_match("/<(\/?\w*)\s*([^>]*)>/", $text, $regex)) { while (preg_match("/<(\/?\w*)\s*([^>]*)>/", $text, $regex)) {
$newtext .= $tagqueue; $newtext .= $tagqueue;
$i = strpos($text, $regex [0]); $i = strpos($text, $regex [0]);
$l = strlen($regex [0]); $l = strlen($regex [0]);
// clear the shifter // clear the shifter
$tagqueue = ''; $tagqueue = '';
// Pop or Push // Pop or Push
@ -662,9 +662,9 @@ function balanceTags($text, $is_comment = 0) {
} }
} else { // Begin Tag } else { // Begin Tag
$tag = strtolower($regex [1]); $tag = strtolower($regex [1]);
// Tag Cleaning // Tag Cleaning
// If self-closing or '', don't do anything. // If self-closing or '', don't do anything.
if ((substr($regex [2], -1) == '/') || ($tag == '')) { if ((substr($regex [2], -1) == '/') || ($tag == '')) {
} // ElseIf it's a known single-entity tag but it doesn't close itself, do so } // ElseIf it's a known single-entity tag but it doesn't close itself, do so
@ -678,7 +678,7 @@ function balanceTags($text, $is_comment = 0) {
} }
$stacksize = array_push($tagstack, $tag); $stacksize = array_push($tagstack, $tag);
} }
// Attributes // Attributes
$attributes = $regex [2]; $attributes = $regex [2];
if ($attributes) { if ($attributes) {
@ -694,22 +694,22 @@ function balanceTags($text, $is_comment = 0) {
$newtext .= substr($text, 0, $i) . $tag; $newtext .= substr($text, 0, $i) . $tag;
$text = substr($text, $i + $l); $text = substr($text, $i + $l);
} }
// Clear Tag Queue // Clear Tag Queue
$newtext .= $tagqueue; $newtext .= $tagqueue;
// Add Remaining text // Add Remaining text
$newtext .= $text; $newtext .= $text;
// Empty Stack // Empty Stack
while ($x = array_pop($tagstack)) { while ($x = array_pop($tagstack)) {
$newtext .= '</' . $x . '>'; // Add remaining tags to close $newtext .= '</' . $x . '>'; // Add remaining tags to close
} }
// WP fix for the bug with HTML comments // WP fix for the bug with HTML comments
$newtext = str_replace("< !--", "<!--", $newtext); $newtext = str_replace("< !--", "<!--", $newtext);
$newtext = str_replace("< !--", "< !--", $newtext); $newtext = str_replace("< !--", "< !--", $newtext);
return $newtext; return $newtext;
} }
@ -1203,7 +1203,7 @@ function ent2ncr($text) {
'&hearts;' => '&#9829;', '&hearts;' => '&#9829;',
'&diams;' => '&#9830;' '&diams;' => '&#9830;'
); );
foreach ($to_ncr as $entity => $ncr) { foreach ($to_ncr as $entity => $ncr) {
$text = str_replace($entity, $ncr, $text); $text = str_replace($entity, $ncr, $text);
} }