aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php10
-rw-r--r--include/text.php21
2 files changed, 11 insertions, 20 deletions
diff --git a/include/items.php b/include/items.php
index 24f1be84f..3d707a492 100755
--- a/include/items.php
+++ b/include/items.php
@@ -393,7 +393,11 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
if(! array_key_exists('mimetype',$arr))
$arr['mimetype'] = 'text/bbcode';
- $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id());
+
+ if(! $arr['mid']) {
+ $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id());
+ }
+ $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']);
$arr['parent_mid'] = ((x($arr,'parent_mid')) ? $arr['parent_mid'] : $arr['mid']);
$arr['thr_parent'] = ((x($arr,'thr_parent')) ? $arr['thr_parent'] : $arr['mid']);
@@ -635,6 +639,7 @@ function get_item_elements($x,$allow_code = false) {
if(mb_strlen($arr['title']) > 255)
$arr['title'] = mb_substr($arr['title'],0,255);
+ $arr['uuid'] = (($x['uuid']) ? htmlspecialchars($x['uuid'], ENT_COMPAT,'UTF-8',false) : '');
$arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : '');
$arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : '');
$arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
@@ -1070,6 +1075,7 @@ function encode_item($item,$mirror = false) {
$x['item_blocked'] = $item['item_blocked'];
}
+ $x['uuid'] = $item['uuid'];
$x['message_id'] = $item['mid'];
$x['message_top'] = $item['parent_mid'];
$x['message_parent'] = $item['thr_parent'];
@@ -1648,6 +1654,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
$arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : '');
$arr['route'] = ((x($arr,'route')) ? trim($arr['route']) : '');
+ $arr['uuid'] = ((x($arr,'uuid')) ? trim($arr['uuid']) : '');
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
$arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
$arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
@@ -2183,6 +2190,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) {
$arr['route'] = ((array_key_exists('route',$arr)) ? trim($arr['route']) : $orig[0]['route']);
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']);
+ $arr['uuid'] = ((x($arr,'uuid')) ? notags(trim($arr['uuid'])) : $orig[0]['uuid']);
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']);
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']);
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']);
diff --git a/include/text.php b/include/text.php
index 3d351f7dc..d3130023c 100644
--- a/include/text.php
+++ b/include/text.php
@@ -574,18 +574,9 @@ function alt_pager($i, $more = '', $less = '') {
* @return string a unique id
*/
function item_message_id() {
- do {
- $dups = false;
- $hash = random_string();
- $mid = $hash . '@' . App::get_hostname();
- $r = q("SELECT id FROM item WHERE mid = '%s' LIMIT 1",
- dbesc($mid));
- if($r)
- $dups = true;
- } while($dups == true);
+ return new_uuid();
- return $mid;
}
/**
@@ -596,17 +587,9 @@ function item_message_id() {
* @return string a uniqe hash
*/
function photo_new_resource() {
- do {
- $found = false;
- $resource = hash('md5', uniqid(mt_rand(), true));
- $r = q("SELECT id FROM photo WHERE resource_id = '%s' LIMIT 1",
- dbesc($resource));
- if($r)
- $found = true;
- } while($found === true);
+ return new_uuid();
- return $resource;
}
/**