adv_interthread.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_interthread.php 24553 2011-09-26 03:21:13Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_interthread {
  12. var $version = '1.1';
  13. var $name = 'interthread_name';
  14. var $description = 'interthread_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('468x60', '658x60', '728x90', '760x90');
  18. function getsetting() {
  19. global $_G;
  20. $settings = array(
  21. 'fids' => array(
  22. 'title' => 'interthread_fids',
  23. 'type' => 'mselect',
  24. 'value' => array(),
  25. ),
  26. 'groups' => array(
  27. 'title' => 'interthread_groups',
  28. 'type' => 'mselect',
  29. 'value' => array(),
  30. ),
  31. 'pnumber' => array(
  32. 'title' => 'interthread_pnumber',
  33. 'type' => 'mselect',
  34. 'value' => array(),
  35. 'default' => array(0),
  36. ),
  37. );
  38. loadcache(array('forums', 'grouptype'));
  39. $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
  40. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  41. foreach($_G['cache']['forums'] as $fid => $forum) {
  42. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  43. }
  44. foreach($_G['cache']['grouptype']['first'] as $gid => $group) {
  45. $settings['groups']['value'][] = array($gid, $group['name']);
  46. if($group['secondlist']) {
  47. foreach($group['secondlist'] as $sgid) {
  48. $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 8).$_G['cache']['grouptype']['second'][$sgid]['name']);
  49. }
  50. }
  51. }
  52. for($i = 1;$i <= $_G['ppp'];$i++) {
  53. $settings['pnumber']['value'][$i] = array($i, '> #'.$i);
  54. }
  55. return $settings;
  56. }
  57. function setsetting(&$advnew, &$parameters) {
  58. global $_G;
  59. if(is_array($advnew['targets'])) {
  60. $advnew['targets'] = implode("\t", $advnew['targets']);
  61. }
  62. if(is_array($parameters['extra']['fids']) && in_array(0, $parameters['extra']['fids'])) {
  63. $parameters['extra']['fids'] = array();
  64. }
  65. if(is_array($parameters['extra']['groups']) && in_array(0, $parameters['extra']['groups'])) {
  66. $parameters['extra']['groups'] = array();
  67. }
  68. }
  69. function evalcode() {
  70. return array(
  71. 'check' => '
  72. $parameter[\'pnumber\'] = $parameter[\'pnumber\'] ? $parameter[\'pnumber\'] : array(1);
  73. if(!in_array($params[2] + 1, (array)$parameter[\'pnumber\'])
  74. || $_G[\'basescript\'] == \'forum\' && $parameter[\'fids\'] && !in_array($_G[\'fid\'], $parameter[\'fids\'])
  75. || $_G[\'basescript\'] == \'group\' && $parameter[\'groups\'] && !in_array($_G[\'grouptypeid\'], $parameter[\'groups\'])
  76. ) {
  77. $checked = false;
  78. }',
  79. 'create' => '$adcode = $codes[$adids[array_rand($adids)]];',
  80. );
  81. }
  82. }
  83. ?>