function usesubmit() { global $_G; $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10; $friends = $uids = $fids = array(); $query = DB::query('SELECT fuid as uid, fusername as username FROM ' . DB::table('home_friend') . " WHERE uid='{$_G['uid']}' LIMIT 500"); while ($value = DB::fetch($query)) { $uids[] = intval($value['uid']); $friends[$value['uid']] = $value; } $count = count($uids); if (!$count) { showmessage('magicuse_has_no_valid_friend'); } elseif ($count == 1) { $fids = array($uids[0]); } else { $keys = array_rand($uids, min($num, $count)); $fids = array(); foreach ($keys as $key) { $fids[] = $uids[$key]; } } $users = array(); foreach ($fids as $uid) { $value = $friends[$uid]; $value['avatar'] = str_replace("'", "\\'", avatar($value['uid'], 'small')); $users[$uid] = $value; } $inserts = array(); if ($_POST['visitway'] == 'poke') { $note = ''; $icon = intval($_POST['visitpoke']); foreach ($fids as $fid) { $inserts[] = "('{$fid}', '{$_G['uid']}', '{$_G['username']}', '{$note}', '{$_G['timestamp']}', '{$icon}')"; } $repokeids = array(); $query = DB::query("SELECT * FROM " . DB::table('home_poke') . " WHERE uid IN (" . dimplode($fids) . ") AND fromuid = '{$_G['uid']}'"); while ($value = DB::fetch($query)) { $repokeids[] = $value['uid']; } DB::query('REPLACE INTO ' . DB::table('home_poke') . '(uid, fromuid, fromusername, note, dateline, iconid) VALUES ' . implode(',', $inserts)); $ids = array_diff($fids, $repokeids); if ($ids) { require_once libfile('function/spacecp'); $pokemsg = makepokeaction($icon); $pokenote = array('fromurl' => 'home.php?mod=space&uid=' . $_G['uid'], 'fromusername' => $_G['username'], 'fromuid' => $_G['uid'], 'from_id' => $_G['uid'], 'from_idtype' => 'pokequery', 'pokemsg' => $pokemsg); foreach ($ids as $puid) { notification_add($puid, 'poke', 'poke_request', $pokenote); } } } elseif ($_POST['visitway'] == 'comment') { $message = getstr($_POST['visitmsg'], 255, 1, 1); $ip = $_G['clientip']; $note_inserts = array(); foreach ($fids as $fid) { $actor = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">{$_G['username']}</a>"; $inserts[] = "('{$fid}', '{$fid}', 'uid', '{$_G['uid']}', '{$_G['username']}','{$ip}', '{$_G['timestamp']}', '{$message}')"; $note = lang('spacecp', 'magic_note_wall', array('actor' => $actor, 'url' => "home.php?mod=space&uid={$fid}&do=wall")); $note_inserts[] = "('{$fid}', 'comment', '1', '{$_G['uid']}', '{$_G['username']}', '{$note}', '{$_G['timestamp']}')"; } DB::query('INSERT INTO ' . DB::table('home_comment') . "(uid, id, idtype, authorid, author, ip, dateline, message) VALUES " . implode(",", $inserts)); //vot !!!!!!!!!!! -> notification_add DB::query('INSERT INTO ' . DB::table('home_notification') . "(uid, type, new, authorid, author, note, dateline) VALUES " . implode(",", $note_inserts)); DB::query('UPDATE ' . DB::table('common_member') . " SET newprompt = newprompt + 1 WHERE uid IN (" . dimplode($fids) . ")"); } else { foreach ($fids as $fid) { $inserts[] = "('{$fid}', '{$_G['uid']}', '{$_G['username']}', '{$_G['timestamp']}')"; } DB::query('REPLACE INTO ' . DB::table('home_visitor') . "(uid, vuid, vusername, dateline) VALUES " . implode(",", $inserts)); } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']); $op = 'show'; include template('home/magic_visit'); }
function usesubmit() { global $_G; $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10; $friends = $uids = $fids = array(); $query = C::t('home_friend')->fetch_all_by_uid($_G['uid'], 0, 500); foreach ($query as $value) { $value['username'] = $value['fusername']; $value['uid'] = $value['fuid']; $uids[] = intval($value['fuid']); $friends[$value['fuid']] = $value; } $count = count($uids); if (!$count) { showmessage('magicuse_has_no_valid_friend'); } elseif ($count == 1) { $fids = array($uids[0]); } else { $keys = array_rand($uids, min($num, $count)); $fids = array(); foreach ($keys as $key) { $fids[] = $uids[$key]; } } $users = array(); foreach ($fids as $uid) { $value = $friends[$uid]; $value['avatar'] = str_replace("'", "\\'", avatar($value['uid'], 'small')); $users[$uid] = $value; } $inserts = array(); if ($_POST['visitway'] == 'poke') { $note = ''; $icon = intval($_POST['visitpoke']); foreach ($fids as $fid) { $insertdata = array('uid' => $fid, 'fromuid' => $_G['uid'], 'fromusername' => $_G['username'], 'note' => $note, 'dateline' => $_G['timestamp'], 'iconid' => $icon); C::t('home_poke')->insert($insertdata, false, true); } $repokeids = array(); foreach (C::t('home_poke')->fetch_all_by_uid_fromuid($fids, $_G['uid']) as $value) { $repokeids[] = $value['uid']; } $ids = array_diff($fids, $repokeids); if ($ids) { require_once libfile('function/spacecp'); $pokemsg = makepokeaction($icon); $pokenote = array('fromurl' => 'home.php?mod=space&uid=' . $_G['uid'], 'fromusername' => $_G['username'], 'fromuid' => $_G['uid'], 'from_id' => $_G['uid'], 'from_idtype' => 'pokequery', 'pokemsg' => $pokemsg); foreach ($ids as $puid) { notification_add($puid, 'poke', 'poke_request', $pokenote); } } } elseif ($_POST['visitway'] == 'comment') { $message = getstr($_POST['visitmsg'], 255); $ip = $_G['clientip']; $note_inserts = array(); foreach ($fids as $fid) { $actor = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">{$_G['username']}</a>"; $inserts[] = array('uid' => $fid, 'id' => $fid, 'idtype' => uid, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'ip' => $ip, 'dateline' => $_G['timestamp'], 'message' => $message); $note = lang('spacecp', 'magic_note_wall', array('actor' => $actor, 'url' => "home.php?mod=space&uid={$fid}&do=wall")); $note_inserts[] = array('uid' => $fid, 'type' => 'comment', 'new' => 1, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'note' => $note, 'dateline' => $_G['timestamp']); } foreach ($inserts as $insert) { C::t('home_comment')->insert($insert); } foreach ($note_inserts as $note_insert) { C::t('home_notification')->insert($note_insert); } C::t('common_member')->increase($fids, array('newprompt' => 1)); } else { foreach ($fids as $fid) { C::t('home_visitor')->insert(array('uid' => $fid, 'vuid' => $_G['uid'], 'vusername' => $_G['username'], 'dateline' => $_G['timestamp']), false, true); } } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']); $op = 'show'; include template('home/magic_visit'); }
$notetext = getstr($_POST['note'], 150, 1, 1); $notetext = censor($notetext); $setarr = array('pokeuid' => $uid + $_G['uid'], 'uid' => $uid, 'fromuid' => $_G['uid'], 'note' => $notetext, 'dateline' => $_G['timestamp'], 'iconid' => intval($_POST['iconid'])); DB::insert('home_pokearchive', $setarr); $setarr = array('uid' => $uid, 'fromuid' => $_G['uid'], 'fromusername' => $_G['username'], 'note' => getstr($_POST['note'], 150, 1, 1), 'dateline' => $_G['timestamp'], 'iconid' => intval($_POST['iconid'])); DB::insert('home_poke', $setarr, 0, true); require_once libfile('function/friend'); friend_addnum($tospace['uid']); if ($op == 'reply') { DB::query("DELETE FROM " . DB::table('home_poke') . " WHERE uid='{$_G['uid']}' AND fromuid='{$uid}'"); DB::query("UPDATE " . DB::table('common_member') . " SET newprompt=newprompt-'1' WHERE uid='{$_G['uid']}'"); } updatecreditbyaction('poke', 0, array(), $uid); if ($setarr['iconid']) { require_once libfile('function/spacecp'); $pokemsg = makepokeaction($setarr['iconid']); } else { $pokemsg = lang('home/template', 'say_hi'); } if (!empty($setarr['note'])) { $pokemsg .= ', ' . lang('home/template', 'say') . ':' . $setarr['note']; } $note = array('fromurl' => 'home.php?mod=space&uid=' . $_G['uid'], 'fromusername' => $_G['username'], 'fromuid' => $_G['uid'], 'from_id' => $_G['uid'], 'from_idtype' => 'pokequery', 'pokemsg' => $pokemsg); notification_add($uid, 'poke', 'poke_request', $note); include_once libfile('function/stat'); updatestat('poke'); showmessage('poke_success', dreferer(), array('username' => $tospace['username'], 'uid' => $uid, 'from' => $_G['gp_from']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } } elseif ($op == 'ignore') { if (submitcheck('ignoresubmit')) { $where = empty($uid) ? '' : "AND fromuid='{$uid}'";