block_adv.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: block_adv.php 25525 2011-11-14 04:39:11Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('commonblock_html', 'class/block/html');
  12. class block_adv extends commonblock_html {
  13. function block_adv() {}
  14. function name() {
  15. return lang('blockclass', 'blockclass_html_script_adv');
  16. }
  17. function getsetting() {
  18. global $_G;
  19. $settings = array(
  20. 'adv' => array(
  21. 'title' => 'adv_adv',
  22. 'type' => 'mradio',
  23. 'value' => array(),
  24. ),
  25. 'title' => array(
  26. 'title' => 'adv_title',
  27. 'type' => 'text',
  28. )
  29. );
  30. foreach(C::t('common_advertisement_custom')->fetch_all_data() as $value) {
  31. $settings['adv']['value'][] = array($value['name'], $value['name']);
  32. }
  33. return $settings;
  34. }
  35. function getdata($style, $parameter) {
  36. $advid = 0;
  37. if(!empty($parameter['title'])) {
  38. $adv = C::t('common_advertisement_custom')->fetch_by_name($parameter['title']);
  39. if(empty($adv)) {
  40. $advid = C::t('common_advertisement_custom')->insert(array('name' => $parameter['title']), true);
  41. } else {
  42. $advid = $adv['id'];
  43. }
  44. } elseif(!empty($parameter['adv'])) {
  45. $adv = C::t('common_advertisement_custom')->fetch_by_name($parameter['adv']);
  46. $advid = intval($adv['id']);
  47. } else {
  48. $return = 'Empty Ads';
  49. }
  50. if($advid) {
  51. $flag = false;
  52. if(getglobal('inajax')) {
  53. $flag = true;
  54. setglobal('inajax', 0);
  55. }
  56. $return = adshow('custom_'.$advid);
  57. if($flag) setglobal('inajax', 1);
  58. }
  59. return array('html' => $return, 'data' => null);
  60. }
  61. }
  62. ?>