magic_detector.php 2.5 KB

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