aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-10-06 20:30:49 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-10-06 20:30:49 -0700
commitc76da2e77d55ab6632e90c60e3a6ba0b2ffdd167 (patch)
tree540c860f0a5ad0ae4e6318bdb17b4d03851ff5f7 /include/text.php
parent95d6d2644f25b208ce087ed48578be580973745e (diff)
downloadvolse-hubzilla-c76da2e77d55ab6632e90c60e3a6ba0b2ffdd167.tar.gz
volse-hubzilla-c76da2e77d55ab6632e90c60e3a6ba0b2ffdd167.tar.bz2
volse-hubzilla-c76da2e77d55ab6632e90c60e3a6ba0b2ffdd167.zip
functions to update urls in items when doing migrations
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index b1af62fc5..205736502 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2564,3 +2564,47 @@ function str_rot47($str) {
'!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
'PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO');
}
+
+
+function string_replace($old,$new,&$s) {
+
+ $x = str_replace($old,$new,$s);
+ $replaced = false;
+ if($x !== $s) {
+ $replaced = true;
+ }
+ $s = $x;
+ return $replaced;
+}
+
+
+function json_url_replace($old,$new,&$s) {
+
+ $old = str_replace('/','\\/',$old);
+ $new = str_replace('/','\\/',$new);
+
+ $x = str_replace($old,$new,$s);
+ $replaced = false;
+ if($x !== $s) {
+ $replaced = true;
+ }
+ $s = $x;
+ return $replaced;
+}
+
+
+function item_url_replace($channel,&$item,$old,$new) {
+
+ if($item['attach'])
+ json_url_replace($old,$new,$item['attach']);
+ if($item['object'])
+ json_url_replace($old,$new,$item['object']);
+ if($item['target'])
+ json_url_replace($old,$new,$item['target']);
+
+ if(string_replace($old,$new,$item['body'])) {
+ $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
+ $item['item_verified'] = 1;
+ }
+
+} \ No newline at end of file