// Store the unescaped version
$unescaped = $arr;
- dbesc_array($arr);
+ dbm::esc_array($arr, true);
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
$r = dbq("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr))
- . "`) VALUES ('"
- . implode("', '", array_values($arr))
- . "')");
+ . "`) VALUES ("
+ . implode(", ", array_values($arr))
+ . ")");
// And restore it
$arr = $unescaped;
}
// Now we store the data in the spool directory
- $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);
+ }
return 0;
}
$r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
if ((dbm::is_result($r)) && (count($r) == 1)) {
- if ($notify)
+ if ($notify) {
call_hooks('post_local_end', $r[0]);
- else
+ } else {
call_hooks('post_remote_end', $r[0]);
- } else
+ }
+ } else {
logger('item_store: new item not found in DB, id ' . $current_post);
+ }
}
if ($arr['parent-uri'] === $arr['uri']) {
check_item_notification($current_post, $uid);
- if ($notify)
+ if ($notify) {
proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
+ }
return $current_post;
}
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid'])
);
- if (! count($c)) {
+ if (! dbm::is_result($c)) {
return;
}
function tgroup_check($uid,$item) {
- $a = get_app();
-
$mention = false;
// check that the message originated elsewhere and is a top-level post