mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:35:30 +00:00
functions to update urls in items when doing migrations
This commit is contained in:
parent
95d6d2644f
commit
c76da2e77d
1 changed files with 44 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue