adv_footerbanner.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_footerbanner.php 22514 2011-05-10 11:11:11Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_footerbanner {
  12. var $version = '1.0';
  13. var $name = 'footerbanner_name';
  14. var $description = 'footerbanner_desc';
  15. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  16. var $targets = array('portal', 'home', 'member', 'forum', 'group', 'search', 'userapp', 'plugin', 'custom');
  17. var $imagesizes = array('468x60', '658x60', '728x90', '760x90', '950x90', '950x130');
  18. function getsetting() {
  19. global $_G;
  20. $settings = array(
  21. 'fids' => array(
  22. 'title' => 'footerbanner_fids',
  23. 'type' => 'mselect',
  24. 'value' => array(),
  25. ),
  26. 'groups' => array(
  27. 'title' => 'footerbanner_groups',
  28. 'type' => 'mselect',
  29. 'value' => array(),
  30. ),
  31. 'category' => array(
  32. 'title' => 'footerbanner_category',
  33. 'type' => 'mselect',
  34. 'value' => array(),
  35. ),
  36. 'position' => array(
  37. 'title' => 'footerbanner_position',
  38. 'type' => 'mradio',
  39. 'value' => array(
  40. array(1, 'footerbanner_position_up'),
  41. array(2, 'footerbanner_position_middle'),
  42. array(3, 'footerbanner_position_down'),
  43. ),
  44. 'default' => 1,
  45. ),
  46. );
  47. loadcache(array('forums', 'grouptype'));
  48. $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
  49. $settings['fids']['value'][] = $settings['groups']['value'][] = array(-1, 'footerbanner_index');
  50. $settings['fids']['value'][] = array(-2, 'Archiver');
  51. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  52. foreach($_G['cache']['forums'] as $fid => $forum) {
  53. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  54. }
  55. foreach($_G['cache']['grouptype']['first'] as $gid => $group) {
  56. $settings['groups']['value'][] = array($gid, str_repeat('&nbsp;', 4).$group['name']);
  57. if($group['secondlist']) {
  58. foreach($group['secondlist'] as $sgid) {
  59. $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 8).$_G['cache']['grouptype']['second'][$sgid]['name']);
  60. }
  61. }
  62. }
  63. loadcache('portalcategory');
  64. $this->categoryvalue[] = array(-1, 'footerbanner_index');
  65. $this->getcategory(0);
  66. $settings['category']['value'] = $this->categoryvalue;
  67. return $settings;
  68. }
  69. function getcategory($upid) {
  70. global $_G;
  71. foreach($_G['cache']['portalcategory'] as $category) {
  72. if($category['upid'] == $upid) {
  73. $this->categoryvalue[] = array($category['catid'], str_repeat('&nbsp;', $category['level'] * 4).$category['catname']);
  74. $this->getcategory($category['catid']);
  75. }
  76. }
  77. }
  78. function setsetting(&$advnew, &$parameters) {
  79. global $_G;
  80. if(is_array($advnew['targets'])) {
  81. $advnew['targets'] = implode("\t", $advnew['targets']);
  82. }
  83. if(is_array($parameters['extra']['fids']) && in_array(0, $parameters['extra']['fids'])) {
  84. $parameters['extra']['fids'] = array();
  85. }
  86. if(is_array($parameters['extra']['groups']) && in_array(0, $parameters['extra']['groups'])) {
  87. $parameters['extra']['groups'] = array();
  88. }
  89. if(is_array($parameters['extra']['category']) && in_array(0, $parameters['extra']['category'])) {
  90. $parameters['extra']['category'] = array();
  91. }
  92. }
  93. function evalcode() {
  94. return array(
  95. 'check' => '
  96. if($params[2] != $parameter[\'position\']
  97. || $_G[\'basescript\'] == \'forum\' && $parameter[\'fids\'] && !(!defined(\'IN_ARCHIVER\') && (in_array($_G[\'fid\'], $parameter[\'fids\']) || CURMODULE == \'index\' && in_array(-1, $parameter[\'fids\'])) || defined(\'IN_ARCHIVER\') && in_array(-2, $parameter[\'fids\']))
  98. || $_G[\'basescript\'] == \'group\' && $parameter[\'groups\'] && !(in_array($_G[\'grouptypeid\'], $parameter[\'groups\']) || CURMODULE == \'index\' && in_array(-1, $parameter[\'groups\']))
  99. || $_G[\'basescript\'] == \'portal\' && $parameter[\'category\'] && !(!empty($_G[\'catid\']) && in_array($_G[\'catid\'], $parameter[\'category\']) || empty($_G[\'catid\']) && in_array(-1, $parameter[\'category\']))
  100. ) {
  101. $checked = false;
  102. }',
  103. 'create' => '$adcode = $codes[$adids[array_rand($adids)]];',
  104. );
  105. }
  106. }
  107. ?>