adv_intercat.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_intercat.php 26440 2011-12-13 06:28:38Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_intercat {
  12. var $version = '1.1';
  13. var $name = 'intercat_name';
  14. var $description = 'intercat_desc';
  15. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  16. var $targets = array('forum');
  17. var $imagesizes = array('468x60', '658x60', '728x90', '760x90', '950x90');
  18. function getsetting() {
  19. global $_G;
  20. $settings = array(
  21. 'fids' => array(
  22. 'title' => 'intercat_fids',
  23. 'type' => 'mselect',
  24. 'value' => array(),
  25. ),
  26. 'position' => array(
  27. 'title' => 'intercat_position',
  28. 'type' => 'mradio',
  29. 'value' => array(),
  30. 'default' => 0,
  31. ),
  32. );
  33. loadcache('forums');
  34. $settings['fids']['value'][] = array(0, '&nbsp;');
  35. $settings['fids']['value'][] = array(-1, 'intercat_position_fav');
  36. $settings['position']['value'][] = array(0, 'intercat_position_random');
  37. $settings['position']['value'][] = array(-1, 'intercat_position_fav');
  38. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  39. foreach($_G['cache']['forums'] as $fid => $forum) {
  40. if($forum['type'] == 'group') {
  41. $settings['fids']['value'][] = array($fid, $forum['name']);
  42. $settings['position']['value'][] = array($fid, $forum['name']);
  43. }
  44. }
  45. return $settings;
  46. }
  47. function setsetting(&$advnew, &$parameters) {
  48. global $_G;
  49. if(is_array($advnew['targets'])) {
  50. $advnew['targets'] = implode("\t", $advnew['targets']);
  51. }
  52. if(is_array($parameters['extra']['fids']) && in_array(0, $parameters['extra']['fids'])) {
  53. $parameters['extra']['fids'] = array();
  54. }
  55. }
  56. function evalcode() {
  57. return array(
  58. 'check' => '
  59. if(!(!$parameter[\'position\'] || $parameter[\'position\'] && $params[2] == $parameter[\'position\'] || $parameter[\'fids\'] && in_array($_GET[\'gid\'], $parameter[\'fids\']))) {
  60. $checked = false;
  61. }',
  62. 'create' => '$adcode = $codes[$adids[array_rand($adids)]];',
  63. );
  64. }
  65. }
  66. ?>