function send($uId, $recipientIds, $appId, $notification) { $result = array(); foreach($recipientIds as $recipientId) { $val = intval($recipientId); $result[$val] = notification_add($val, $appId, $notification, 1); $number = $GLOBALS['db']->result_first('SELECT count(*) FROM '.$GLOBALS['tablepre'].'mynotice WHERE uid=\''.$val.'\' AND new=\'1\''); updateprompt('mynotice', $val, $number); } return new APIResponse($result); }
function send($uId, $recipientIds, $appId, $requestName, $myml, $type) { $now = time(); $result = array(); $type = ($type == 'request') ? 1 : 0; $fields = array( 'typename' => $requestName, 'appid' => $appId, 'type' => $type, 'fromuid' => $uId, 'dateline' => $now ); foreach($recipientIds as $key => $val) { $hash = crc32($appId.$val.$now.rand(0, 1000)); $hash = sprintf('%u', $hash); $fields['touid'] = intval($val); $fields['hash'] = $hash; $fields['myml'] = str_replace('{{MyReqHash}}', $hash, $myml); $result[] = inserttable('myinvite', $fields, 1); $number = $GLOBALS['db']->result_first('SELECT count(*) FROM '.$GLOBALS['tablepre'].'myinvite WHERE touid=\''.$fields['touid'].'\''); updateprompt('myinvite', $fields['touid'], $number); } return new APIResponse($result); }
} updateprompt('myinvite', $discuz_uid, 0); $multi = multi($count, $tpp, $page, "userapp.php?script=notice&action=invite"); } else { $page = isset($page) ? max(1, intval($page)) : 1; $start_limit = ($page - 1) * $tpp; $noticeids = array(); $count = $db->result_first("SELECT count(*) FROM {$tablepre}mynotice WHERE uid='$discuz_uid'"); $query = $db->query("SELECT * FROM {$tablepre}mynotice WHERE uid='$discuz_uid' ORDER BY dateline DESC LIMIT $start_limit,$tpp"); while($value = $db->fetch_array($query)) { $value['dateline'] = dgmdate("$dateformat $timeformat", $value['dateline'] + $timeoffset * 3600); $list[] = $value; $noticeids[] = $value['id']; } if($noticeids) { $db->query("UPDATE {$tablepre}mynotice SET new='0' WHERE id IN (".implodeids($noticeids).")"); updateprompt('mynotice', $discuz_uid, 0); } $multi = multi($count, $tpp, $page, "userapp.php?script=notice"); } include template('manyou_notice'); ?>
if($actorcount > 5) { include_once language('misc'); $actor .= eval('return " '.$language['notice_actor'].'";'); } else { $actor .= ' '; } $find[] = '{actor}'; $replace[] = $actor; } $row['message'] = str_replace($find, $replace, $row['message']); $pmlist[] = $row; } if($newexists) { $db->query("UPDATE {$tablepre}promptmsgs SET new='0' WHERE uid='$discuz_uid' AND new='1'", 'UNBUFFERED'); } $multipage = multi($count, $ppp, $page, 'notice.php'.($filter ? '?filter='.$filter : '')); if(!$filter) { foreach($prompts as $promptkey => $promptdata) { if($promptdata['new']) { updateprompt($promptkey, $discuz_uid, 0); } } } elseif($prompts[$filter]['new']) { updateprompt($filter, $discuz_uid, 0); } include template('notice'); ?>
function task_newfunction_autoapply() { global $db, $tablepre, $discuz_uid; $query = $db->query("SELECT * FROM {$tablepre}tasks WHERE newbietask='2' AND available='2'"); $tprompt = FALSE; while ($t = $db->fetch_array($query)) { $t['newbie'] = 1; if (!$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='{$discuz_uid}' AND taskid='{$t['taskid']}'")) { task_apply($t); $tprompt = TRUE; } } $tprompt && updateprompt('task', $discuz_uid, $db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='{$discuz_uid}' AND status='0'")); }
function sendnotice($toid, $message, $type, $extraid = 0, $actor = array(), $uselang = 1) { if (!$toid || $message === '') { return; } extract($GLOBALS, EXTR_SKIP); if ($uselang) { include language('notice'); if (isset($language[$message])) { eval("\$message = addslashes(\"" . $language[$message] . "\");"); } } $typeid = $prompts[$type]['id']; if (!$typeid) { return; } $toids = explode(',', $toid); foreach ($toids as $toid) { $keysadd = $valuesadd = $statnewnotice = ''; if ($extraid && $actor) { $promptmsg = $db->fetch_first("SELECT actor FROM {$tablepre}promptmsgs WHERE uid='{$toid}' AND typeid='{$typeid}' AND extraid='{$extraid}' LIMIT 1"); if ($promptmsg) { list($actorcount, $actors) = explode("\t", $promptmsg['actor']); $actorarray = array_unique(explode(',', $actors)); if (!in_array($actor['user'], $actorarray)) { array_unshift($actorarray, $actor['user']); $actors = implode(',', array_slice($actorarray, 0, $actor['maxusers'])); $actorcount++; } $statnewnotice = 1; $db->query("UPDATE {$tablepre}promptmsgs SET actor='" . addslashes($actorcount . "\t" . $actors) . "', dateline='{$timestamp}', new='1' WHERE uid='{$toid}' AND typeid='{$typeid}' AND extraid='{$extraid}'"); } else { $statnewnotice = 1; $db->query("INSERT INTO {$tablepre}promptmsgs (typeid, uid, new, dateline, message, extraid, actor) VALUES ('{$typeid}', '{$toid}', '1', '{$timestamp}', '{$message}', '{$extraid}', '" . addslashes("1\t" . $actor['user']) . "')"); } } else { $statnewnotice = 1; $db->query("INSERT INTO {$tablepre}promptmsgs (typeid, uid, new, dateline, message) VALUES ('{$typeid}', '{$toid}', '1', '{$timestamp}', '{$message}')"); } if ($statnewnotice) { write_statlog('', 'action=counttype&typeid=' . $typeid, '', '', 'notice.php'); } $count = $db->result_first("SELECT count(*) FROM {$tablepre}promptmsgs WHERE uid='{$toid}' AND typeid='{$typeid}' AND new='1'"); updateprompt($type, $toid, $count); } }
$pm['msgfromurl'] = $pm['fromappid'] && $ucapp[$pm['fromappid']]['viewprourl'] ? sprintf($ucapp[$pm['fromappid']]['viewprourl'], $pm['msgfromid']) : 'space.php?uid='.$pm['msgfromid']; $pm['daterange'] = 5; if($pm['dateline'] >= $today) { $pm['daterange'] = 1; } elseif($pm['dateline'] >= $today - 86400) { $pm['daterange'] = 2; } elseif($pm['dateline'] >= $today - 172800) { $pm['daterange'] = 3; } $pm['date'] = gmdate($dateformat, $pm['dateline'] + $timeoffset * 3600); $pm['time'] = gmdate($timeformat, $pm['dateline'] + $timeoffset * 3600); $pmlist[] = $pm; } if($prompts['pm']['new']) { updateprompt('pm', $discuz_uid, 0); } } elseif($action == 'view') { $daterange = empty($daterange) ? 1 : $daterange; if(isset($uid)) { $ucdata = uc_pm_view($discuz_uid, '', $uid, $daterange); $msgfromurl = $pm['fromappid'] && $ucapp[$pm['fromappid']]['viewprourl'] ? sprintf($ucapp[$pm['fromappid']]['viewprourl'], $uid) : 'space.php?uid='.$uid; list(,$user) = uc_get_user($uid, 1); } elseif(!empty($pmid)) { $ucdata = uc_pm_view($discuz_uid, $pmid, 0, $daterange); $msgfromurl = ''; } $pmlist = array();
} elseif($action == 'giveup' && $id && !empty($formhash)) { if($formhash != FORMHASH) { showmessage('undefined_action', NULL, 'HALTED'); } elseif(!$task = $db->fetch_first("SELECT t.taskid, mt.status FROM {$tablepre}tasks t LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='$discuz_uid' WHERE t.taskid='$id' AND t.available='2' AND t.newbietask!='1'")) { showmessage('task_nonexistence', NULL, 'HALTED'); } elseif($task['status'] != '0') { showmessage('undefined_action'); } $db->query("DELETE FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}tasks SET applicants=applicants-1 WHERE taskid='$id'", 'UNBUFFERED'); if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND status='0'")) { updateprompt('task', $discuz_uid, 0); } showmessage('task_giveup', "task.php?item=view&id=$id"); } elseif($action == 'parter' && $id) { $query = $db->query("SELECT * FROM {$tablepre}mytasks WHERE taskid='$id' ORDER BY dateline DESC LIMIT 0, 8"); while($parter = $db->fetch_array($query)) { $parter['avatar'] = discuz_uc_avatar($parter['uid'], 'small'); $csc = explode("\t", $parter['csc']); $parter['csc'] = floatval($csc[0]); $parterlist[] = $parter; } include template('task_parter');