aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-01 10:01:56 +0000
committerMario <mario@mariovavti.com>2022-02-01 10:01:56 +0000
commiteb207898219937435f5735eb96fe32e5b2d489f0 (patch)
tree002da6491f1ed7f18d1b84a2a8155fd952aa7894 /include/text.php
parentc90862217ef29ee4f3d37d37a8fe6063aa68dbdf (diff)
downloadvolse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.tar.gz
volse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.tar.bz2
volse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.zip
allow zotfinger to recurse through all known hublocs if the one we got does not exist (404) or got removed (410). add functions for updating tables from array and deleting hublocs.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index b76175a06..3b6039c31 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3592,6 +3592,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]);
}