adv_threadlist.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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: adv_threadlist.php 29052 2012-03-23 09:07:40Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_threadlist {
  12. var $version = '1.0';
  13. var $name = 'threadlist_name';
  14. var $description = 'threadlist_desc';
  15. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  16. var $targets = array('forum', 'group');
  17. var $imagesizes = array('120x60', '468x40', '468x60');
  18. function getsetting() {
  19. global $_G;
  20. $settings = array(
  21. 'fids' => array(
  22. 'title' => 'threadlist_fids',
  23. 'type' => 'mselect',
  24. 'value' => array(),
  25. ),
  26. 'groups' => array(
  27. 'title' => 'threadlist_groups',
  28. 'type' => 'mselect',
  29. 'value' => array(),
  30. ),
  31. 'pos' => array(
  32. 'title' => 'threadlist_pos',
  33. 'type' => 'text',
  34. 'value' => '',
  35. ),
  36. 'mode' => array(
  37. 'title' => 'threadlist_mode',
  38. 'type' => 'mradio',
  39. 'value' => array(
  40. array(0, 'threadlist_mode_0'),
  41. array(1, 'threadlist_mode_1'),
  42. ),
  43. ),
  44. 'tid' => array(
  45. 'title' => 'threadlist_tid',
  46. 'type' => 'text',
  47. 'value' => '',
  48. ),
  49. 'threadurl' => array(
  50. 'title' => 'threadlist_threadurl',
  51. 'type' => 'text',
  52. 'value' => '',
  53. ),
  54. );
  55. loadcache(array('forums', 'grouptype'));
  56. $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
  57. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  58. foreach($_G['cache']['forums'] as $fid => $forum) {
  59. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  60. }
  61. foreach($_G['cache']['grouptype']['first'] as $gid => $group) {
  62. $settings['groups']['value'][] = array($gid, $group['name']);
  63. if($group['secondlist']) {
  64. foreach($group['secondlist'] as $sgid) {
  65. $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 4).$_G['cache']['grouptype']['second'][$sgid]['name']);
  66. }
  67. }
  68. }
  69. return $settings;
  70. }
  71. function setsetting(&$advnew, &$parameters) {
  72. global $_G;
  73. if(is_array($advnew['targets'])) {
  74. $advnew['targets'] = implode("\t", $advnew['targets']);
  75. }
  76. if(is_array($parameters['extra']['fids']) && in_array(0, $parameters['extra']['fids'])) {
  77. $parameters['extra']['fids'] = array();
  78. }
  79. if(is_array($parameters['extra']['groups']) && in_array(0, $parameters['extra']['groups'])) {
  80. $parameters['extra']['groups'] = array();
  81. }
  82. $parameters['extra']['pos'] = $parameters['pos'];
  83. $parameters['extra']['tid'] = $parameters['tid'];
  84. $parameters['extra']['threadurl'] = $parameters['threadurl'];
  85. }
  86. function evalcode() {
  87. return array(
  88. 'check' => '
  89. if($GLOBALS[\'page\'] != 1 || !empty($_GET[\'filter\'])
  90. || $_G[\'basescript\'] == \'forum\' && $parameter[\'fids\'] && !in_array($_G[\'fid\'], $parameter[\'fids\'])
  91. || $_G[\'basescript\'] == \'group\' && $parameter[\'groups\'] && !in_array($_G[\'grouptypeid\'], $parameter[\'groups\'])
  92. ) {
  93. $checked = false;
  94. } else {
  95. if(empty($_G[\'adv_vtp_count\'])) {
  96. for($i = 1;$i <= $_G[\'forum_threadnum\'];$i++) {
  97. if(empty($parameter[\'pos\'])) {
  98. $_G[\'adv_vtp\'][0][$i][] = $adid;
  99. } elseif($parameter[\'pos\'] == $i) {
  100. $_G[\'adv_vtp\'][1][$i][] = $adid;
  101. }
  102. }
  103. $_G[\'adv_vtp_showed\'] = $_G[\'adv_vtp_thread\'] = array();
  104. }
  105. if($parameter[\'mode\'] && $parameter[\'tid\']) {
  106. $_G[\'adv_vtp_tids\'][] = $parameter[\'tid\'];
  107. }
  108. }',
  109. 'create' => '
  110. $_G[\'adv_vtp_count\']++;
  111. if($_G[\'adv_vtp_count\'] == 1 && !empty($_G[\'adv_vtp_tids\'])) {
  112. foreach(C::t(\'forum_thread\')->fetch_all_by_tid($_G[\'adv_vtp_tids\']) as $row) {
  113. $_G[\'adv_vtp_thread\'][$row[\'tid\']] = $row;
  114. }
  115. }
  116. $vt = $_G[\'adv_vtp_thread\'];
  117. $adi = !empty($_G[\'adv_vtp\'][1][$_G[\'adv_vtp_count\']]) ? 1 : 0;
  118. $adary = array_diff($_G[\'adv_vtp\'][$adi][$_G[\'adv_vtp_count\']], $_G[\'adv_vtp_showed\']);
  119. $adid = $adary[array_rand($adary)];
  120. $_G[\'adv_vtp_showed\'][] = $adid;
  121. $vttid = $parameters[$adid][\'tid\'];
  122. $notag = true;
  123. $adcode = $adid ? (!$parameters[$adid][\'mode\'] ? \'<tbody><tr><td colspan=\'.($_G[\'forum\'][\'ismoderator\'] && !$_GET[\'archiveid\'] ? 6 : 5).\'>\'.$codes[$adid].\'</td></tr></tbody>\'
  124. : \'<tr><td class="icn"><a href="forum.php?mod=viewthread&tid=\'.$vt[$vttid][\'tid\'].\'" target="_blank"><img src="\'.$_G[\'style\'][\'imgdir\'].\'/folder_new.gif" /></a></td>\'.
  125. ($_G[\'forum\'][\'ismoderator\'] && !$_GET[\'archiveid\'] ? \'<td class="o"></td>\' : \'\').
  126. \'<td class="new"><a href="\'.($parameters[$adid][\'threadurl\'] ? $parameters[$adid][\'threadurl\'] : \'forum.php?mod=viewthread&tid=\'.$vt[$vttid][\'tid\']).\'" class="xst">\'.$codes[$adid].\'</a></td>\'.
  127. \'<td class="by"><cite><a href="home.php?mod=space&uid=\'.$vt[$vttid][\'authorid\'].\'">\'.$vt[$vttid][\'author\'].\'</a></cite><em>\'.dgmdate($vt[$vttid][\'dateline\'], \'d\').\'</em></td>\'.
  128. \'<td class="num"><a href="forum.php?mod=viewthread&tid=\'.$vt[$vttid][\'tid\'].\'" class="xi2">\'.$vt[$vttid][\'replies\'].\'</a><em>\'.$vt[$vttid][\'views\'].\'</em></td>\'.
  129. \'<td class="by"><cite><a href="forum.php?mod=viewthread&tid=\'.$vt[$vttid][\'tid\'].\'">\'.$vt[$vttid][\'lastposter\'].\'</a></cite>\'.
  130. \'<em><a href="forum.php?mod=redirect&tid=\'.$vt[$vttid][\'tid\'].\'&goto=lastpost#lastpost">\'.dgmdate($vt[$vttid][\'lastpost\'], \'u\').\'</a></em></td>\'.
  131. \'</tr>\') : \'\';',
  132. );
  133. }
  134. }
  135. ?>