$r = dbq("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr))
$r = dbq("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr))
- $file = 'item-'.round(microtime(true) * 10000).".msg";
- $spool = get_spoolpath().'/'.$file;
- file_put_contents($spool, json_encode($arr));
- logger("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG);
+ // We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates
+ $file = 'item-'.round(microtime(true) * 10000).'-'.mt_rand().'.msg';
+
+ $spoolpath = get_spoolpath();
+ if ($spoolpath != "") {
+ $spool = $spoolpath.'/'.$file;
+ file_put_contents($spool, json_encode($arr));
+ logger("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG);
+ }
$r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
if ((dbm::is_result($r)) && (count($r) == 1)) {
$r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
if ((dbm::is_result($r)) && (count($r) == 1)) {
proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid'])
);
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid'])
);
- q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
- `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d",
+ q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
+ `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d",
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true;
logger('tgroup_check: mention found: ' . $mtch[2]);
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true;
logger('tgroup_check: mention found: ' . $mtch[2]);
assumes the update has been seen before and should be ignored.
*/
function edited_timestamp_is_newer($existing, $update) {
assumes the update has been seen before and should be ignored.
*/
function edited_timestamp_is_newer($existing, $update) {
- if (!x($existing,'edited') || !$existing['edited']) {
- return true;
- }
- if (!x($update,'edited') || !$update['edited']) {
- return false;
- }
- $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
- $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
- return (strcmp($existing_edited, $update_edited) < 0);
+ if (!x($existing,'edited') || !$existing['edited']) {
+ return true;
+ }
+ if (!x($update,'edited') || !$update['edited']) {
+ return false;
+ }
+
+ $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
+ $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
+ return (strcmp($existing_edited, $update_edited) < 0);