Example #1
0
     if (!$data['msgfromid'] || !$data['msgtoid'] || $data['msgfromid'] == $data['msgtoid']) {
         continue;
     }
     $plid = $founderid = 0;
     $data['msgfrom'] = addslashes($data['msgfrom']);
     $data['subject'] = addslashes($data['subject']);
     $data['message'] = addslashes($data['message']);
     $relationship = relationship($data['msgfromid'], $data['msgtoid']);
     $querythread = $db->query("SELECT plid, authorid FROM " . UC_DBTABLEPRE . "pm_lists WHERE min_max='{$relationship}'");
     if ($thread = $db->fetch_array($querythread)) {
         $plid = $thread['plid'];
         $founderid = $thread['authorid'];
     }
     if (!$plid) {
         $db->query("INSERT INTO " . UC_DBTABLEPRE . "pm_lists(authorid, pmtype, subject, members, min_max, dateline) VALUES('{$data['msgfromid']}', 1, '', 2, '{$relationship}', '{$data['dateline']}')");
         $plid = $db->insert_id();
         $db->query("INSERT INTO " . UC_DBTABLEPRE . "pm_members(plid, uid, isnew, lastupdate) VALUES('{$plid}', '{$data['msgfromid']}', 0, 0)");
         $db->query("INSERT INTO " . UC_DBTABLEPRE . "pm_members(plid, uid, isnew, lastupdate) VALUES('{$plid}', '{$data['msgtoid']}', 0, 0)");
     }
     $db->query("INSERT INTO " . UC_DBTABLEPRE . "pm_indexes(plid) VALUES('{$plid}')");
     $pmid = $db->insert_id();
     if ($founderid == $data['msgfromid']) {
         $delstatus = $data['delstatus'];
     } else {
         $delstatus = $data['delstatus'] == 1 ? 2 : ($data['delstatus'] == 2 ? 1 : 0);
     }
     $db->query("INSERT INTO " . UC_DBTABLEPRE . getposttablename($plid) . "(pmid, plid, authorid, message, delstatus, dateline) VALUES('{$pmid}', '{$plid}', '{$data['msgfromid']}', '" . $data['message'] . "', '{$delstatus}', '{$data['dateline']}')");
 }
 if ($next > 0) {
     $end = $next;
     echo "Short message data has been processed: {$start} / {$total} ...";