magic_detector.php
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: magic_detector.php 27375 2012-01-19 04:47:27Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class magic_detector {
var $version = '1.0';
var $name = 'detector_name';
var $description = 'detector_desc';
var $price = '20';
var $weight = '20';
var $useevent = 0;
var $targetgroupperm = false;
var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
var $magic = array();
var $parameters = array();
function getsetting(&$magic) {
$settings = array(
'num' => array(
'title' => 'detector_num',
'type' => 'select',
'value' => array(
array('5', '5'),
array('10', '10'),
array('20', '20'),
),
'default' => '10'
),
);
return $settings;
}
function setsetting(&$magicnew, &$parameters) {
$magicnew['num'] = in_array($parameters['num'], array(5,10,20,50)) ? intval($parameters['num']) : '10';
}
function usesubmit() {
global $_G;
$list = $uids = array();
$num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10;
$limit = $num + 20;
$giftMagicID = C::t('common_magic')->fetch_by_identifier('gift');
$mid = $giftMagicID['available'] ? intval($giftMagicID['magicid']) : 0;
if($mid) {
foreach(C::t('common_magiclog')->fetch_all_by_magicid_action_uid($mid, 2, $_G['uid'], 0, $limit) as $value) {
$uids[] = intval($value['uid']);
}
}
if($uids) {
$counter = 0;
$members = C::t('common_member')->fetch_all($uids);
foreach(C::t('common_member_field_home')->fetch_all($uids) as $uid => $value) {
$value = array_merge($members[$uid], $value);
$info = !empty($value['magicgift']) ? unserialize($value['magicgift']) : array();
if(!empty($info['left']) && (empty($info['receiver']) || !in_array($_G['uid'], $info['receiver']))) {
$value['avatar'] = addcslashes(avatar($uid, 'small'), "'");
$list[$uid] = $value;
$counter++;
if($counter>=$num) {
break;
}
}
}
}
usemagic($this->magic['magicid'], $this->magic['num']);
updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']);
$op = 'show';
include template('home/magic_detector');
}
function show() {
global $_G;
$num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10;
magicshowtips(lang('magic/detector', 'detector_info', array('num'=>$num)));
}
}
?>