diff options
author | Mario <mario@mariovavti.com> | 2022-02-09 09:50:08 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-02-09 09:50:08 +0000 |
commit | 3d318542cb182673b5eeb635916da29267b843c9 (patch) | |
tree | 88e24a6176589c4d56598e25fe07bac653fd6ffc /include/text.php | |
parent | 5bdc713afed394db3193a3b55cd8446cf614fb26 (diff) | |
parent | 4a8c3cdc6109c5515824082f57bdb801b13ef9e0 (diff) | |
download | volse-hubzilla-3d318542cb182673b5eeb635916da29267b843c9.tar.gz volse-hubzilla-3d318542cb182673b5eeb635916da29267b843c9.tar.bz2 volse-hubzilla-3d318542cb182673b5eeb635916da29267b843c9.zip |
Merge branch 'dev'
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/include/text.php b/include/text.php index aea8790fc..29a2ab3b1 100644 --- a/include/text.php +++ b/include/text.php @@ -417,6 +417,9 @@ function xmlify($str) { //$buffer = ''; + if (!$str) + return EMPTY_STR; + if(is_array($str)) { // allow to fall through so we ge a PHP error, as the log statement will @@ -482,6 +485,9 @@ function unxmlify($s) { return $ret; */ + if (!$s) + return EMPTY_STR; + if(is_array($s)) { // allow to fall through so we ge a PHP error, as the log statement will @@ -840,7 +846,7 @@ function activity_match($haystack,$needle) { if($needle) { foreach($needle as $n) { - if(($haystack === $n) || (strtolower(basename($n)) === strtolower(basename($haystack)))) { + if(($haystack === $n) || (strtolower(basename((string)$n)) === strtolower(basename((string)$haystack)))) { return true; } } @@ -1492,6 +1498,10 @@ function day_translate($s) { * @return string */ function normalise_link($url) { + if (!$url) { + return EMPTY_STR; + } + $ret = str_replace(array('https:', '//www.'), array('http:', '//'), $url); return(rtrim($ret, '/')); @@ -3588,6 +3598,45 @@ function create_table_from_array($table, $arr, $binary_fields = []) { return $r; } + +function update_table_from_array($table, $arr, $where, $binary_fields = []) { + + if (! ($arr && $table)) { + return false; + } + + $columns = db_columns($table); + + $clean = []; + foreach ($arr as $k => $v) { + if (! in_array($k, $columns)) { + continue; + } + + $matches = false; + if (preg_match('/([^a-zA-Z0-9\-\_\.])/', $k, $matches)) { + return false; + } + if (in_array($k, $binary_fields)) { + $clean[$k] = dbescbin($v); + } else { + $clean[$k] = dbesc($v); + } + } + + $sql = "UPDATE " . TQUOT . $table . TQUOT . " SET "; + + foreach ($clean as $k => $v) { + $sql .= TQUOT . $k . TQUOT . ' = "' . $v . '",'; + } + + $sql = rtrim($sql,','); + + $r = dbq($sql . " WHERE " . $where); + + return $r; +} + function share_shield($m) { return str_replace($m[1],'!=+=+=!' . base64url_encode($m[1]) . '=+!=+!=',$m[0]); } |