国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0KB

  1. <?php if(!defined('DEDEINC')) exit('Request Error!');
  2. helper('mda');
  3. helper('cache');
  4. function lib_mda(&$ctag,&$refObj)
  5. {
  6. global $dsql, $envs, $cfg_soft_lang;
  7. //属性处理
  8. $type = empty($type)? 'code' : $type;
  9. $class = empty($class)? '_DEDECY' : $class;
  10. $version = MDA_VER;
  11. $attlist="uuid|,name|";
  12. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  13. extract($ctag->CAttribute->Items, EXTR_SKIP);
  14. if ( empty($uuid) AND empty($name) ) return '填写正确的uuid 或 name';
  15. $reval="";
  16. //if( !$dsql->IsTable("#@__plus_mda_setting") ) return '没安装<a href="'.MDA_APIHOST.'" target="_blank">德得广告模块</a>';
  17. $email = mda_get_setting('email');
  18. $channel_uuid = mda_get_setting('channel_uuid');
  19. $channel_secret = mda_get_setting('channel_secret');
  20. //if(empty($channel_uuid)) return '尚未绑定德得广告账号,请<a href="'.MDA_APIHOST.'/home/register" target="_blank">注册</a>并到系统后台绑定';
  21. $prefix = 'mda';
  22. $key = 'code'.md5($uuid.$name);
  23. $row = GetCache($prefix, $key);
  24. if(!is_array($row))
  25. {
  26. $ts = time();
  27. $paramsArr=array(
  28. 'channel_uuid'=>$channel_uuid,
  29. 'channel_secret'=>$channel_secret,
  30. 'ts'=>$ts,
  31. 'crc'=>md5($channel_uuid.$channel_secret.$ts),
  32. );
  33. if ( !empty($uuid) )
  34. {
  35. $paramsArr['place_uuid'] = $uuid;
  36. } else {
  37. $paramsArr['tag_name'] = urlencode($name);
  38. }
  39. $place = json_decode(mda_http_send(MDA_API_GET_PLACE,0,$paramsArr),TRUE);
  40. if (!isset($place['data']['place_code']) )
  41. {
  42. return '';
  43. }
  44. $row['reval'] = htmlspecialchars($place['data']['place_code']);
  45. SetCache($prefix, $key, $row, 60*60*12);
  46. }
  47. if($cfg_soft_lang != 'utf-8') $row = AutoCharset($row, 'utf-8', 'gb2312');
  48. $reval .= htmlspecialchars_decode($row['reval']);
  49. return $reval;
  50. }