国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mda_main.php 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <?php
  2. /**
  3. * 附件添加
  4. *
  5. * @version $Id: mda_main.php 2 15:25 2018-6-2 tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__).'/config.php');
  12. require_once(DEDEINC."/oxwindow.class.php");
  13. helper('mda');
  14. $install_sqls = array(
  15. "CREATE TABLE IF NOT EXISTS `#@__plus_mda_setting` (
  16. `skey` varchar(255) NOT NULL DEFAULT '',
  17. `svalue` text NOT NULL,
  18. `stime` int(10) NOT NULL,
  19. PRIMARY KEY (`skey`)
  20. ) TYPE=MyISAM;",
  21. "INSERT INTO `#@__plus_mda_setting` (`skey`, `svalue`, `stime`) VALUES
  22. ('version', '0.0.1', 0),
  23. ('channel_uuid', '0', 0),
  24. ('channel_secret', '0', 0),
  25. ('email', '0', 0);",
  26. );
  27. $update_sqls = array(
  28. );
  29. /*--------------------------------
  30. function __install(){ }
  31. -------------------------------*/
  32. if (! $dsql->IsTable('#@__plus_mda_setting') )
  33. {
  34. $mysql_version = $dsql->GetVersion(TRUE);
  35. foreach( $install_sqls as $install_sql )
  36. {
  37. $sql = preg_replace("#ENGINE=MyISAM#i", 'TYPE=MyISAM', $install_sql);
  38. $sql41tmp = 'ENGINE=MyISAM DEFAULT CHARSET='.$cfg_db_language;
  39. if($mysql_version >= 4.1)
  40. {
  41. $sql = preg_replace("#TYPE=MyISAM#i", $sql41tmp, $sql);
  42. }
  43. $dsql->ExecuteNoneQuery($sql);
  44. }
  45. }
  46. /*--------------------------------
  47. function __update(){ }
  48. -------------------------------*/
  49. $version=mda_get_setting('version');
  50. if (empty($version)) $version = '0.0.1';
  51. if (version_compare($version, MDA_VER, '<')) {
  52. $mysql_version = $dsql->GetVersion(TRUE);
  53. foreach ($update_sqls as $ver => $sqls) {
  54. if (version_compare($ver, $version,'<')) {
  55. continue;
  56. }
  57. foreach ($sqls as $sql) {
  58. $sql = preg_replace("#ENGINE=MyISAM#i", 'TYPE=MyISAM', $sql);
  59. $sql41tmp = 'ENGINE=MyISAM DEFAULT CHARSET='.$cfg_db_language;
  60. if($mysql_version >= 4.1)
  61. {
  62. $sql = preg_replace("#TYPE=MyISAM#i", $sql41tmp, $sql);
  63. }
  64. $dsql->ExecuteNoneQuery($sql);
  65. }
  66. mda_set_setting('version', $ver);
  67. $version=mda_get_setting('version');
  68. }
  69. }
  70. if(empty($dopost)) $dopost = '';
  71. /*--------------------------------
  72. function __link(){ }
  73. -------------------------------*/
  74. if($dopost == 'place' OR $dopost == 'report' OR $dopost == 'account' OR $dopost == 'setting')
  75. {
  76. if ( !mda_islogin() )
  77. {
  78. ShowMsg("您尚未登录德得广告,请先登录后继续使用……!",'?dopost=login');
  79. exit();
  80. }
  81. mda_check_islogin();
  82. if($dopost=='place')
  83. {
  84. $channel_uuid = mda_get_setting('channel_uuid');
  85. $manage_url = MDA_APIHOST."/place?from=dedecms&uuid={$channel_uuid}";
  86. $ptitle = '广告管理';
  87. } elseif ($dopost=='report')
  88. {
  89. $manage_url = MDA_APIHOST."/report";
  90. $ptitle = '报表管理';
  91. } elseif ($dopost=='account')
  92. {
  93. $manage_url = MDA_APIHOST."/account";
  94. $ptitle = '结算中心';
  95. } elseif ($dopost=='setting')
  96. {
  97. $manage_url = MDA_APIHOST."/setting";
  98. $ptitle = '德得设置';
  99. }
  100. echo <<<EOT
  101. <html>
  102. <head>
  103. <meta http-equiv="Content-Type" content="text/html; charset={$cfg_soft_lang}">
  104. <title>{$ptitle}</title>
  105. <link rel="stylesheet" type="text/css" href="css/base.css">
  106. </head>
  107. <body background='images/allbg.gif' leftmargin="8" topmargin='8'>
  108. <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DFF9AA" height="100%">
  109. <tr>
  110. <td height="28" style="border:1px solid #DADADA" background='images/wbg.gif'>
  111. <div style="float:left">&nbsp;<b>◇<a href="?">德得广告</a> 》{$ptitle}</b></div>
  112. <div style="float:right;margin-right:20px;">您好:{$_SESSION['mda_email']} {$account_str}</div>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td width="100%" height="100%" valign="top" bgcolor='#ffffff' style="padding-top:5px"><table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#DADADA' height="100%">
  117. <tr bgcolor='#DADADA'>
  118. <td colspan='2' background='images/wbg.gif' height='26'><font color='#666600'><b>{$ptitle}</b></font></td>
  119. </tr>
  120. {$addstr}
  121. <tr bgcolor='#FFFFFF'>
  122. <td colspan='2' height='100%'><iframe src="{$manage_url}" {$addstyle} width="100%" height="100%" style="border:none" onload="if(this.postMessage){this.postMessage('ok')}"></iframe></td>
  123. </tr>
  124. <tr>
  125. <td bgcolor='#F5F5F5'>&nbsp;</td>
  126. </tr>
  127. </table></td>
  128. </tr>
  129. </table>
  130. <p align="center"> <br>
  131. <br>
  132. </p>
  133. </body>
  134. </html>
  135. EOT;
  136. }
  137. /*--------------------------------
  138. function __clearcache(){ }
  139. -------------------------------*/
  140. else if($dopost == 'clearcache'){
  141. if (!is_dir(DEDEDATA . "/cache/mda/") OR RmRecurse(DEDEDATA . "/cache/mda/") )
  142. {
  143. ShowMsg("成功清除缓存信息",-1);
  144. exit();
  145. } else {
  146. ShowMsg("清除缓存失败,请尝试手工删除".DEDEDATA."/cache/mda/", 'javascript:;');
  147. exit();
  148. }
  149. }
  150. /*--------------------------------
  151. function __bind_user(){ }
  152. -------------------------------*/
  153. else if($dopost == 'bind_user')
  154. {
  155. $email = isset($email)? $email : '';
  156. $pwd = isset($pwd)? $pwd : '';
  157. $domain = isset($domain)? $domain : '';
  158. $channel_name = isset($channel_name)? $channel_name : '';
  159. if ( !$email OR !$pwd OR !$domain OR !$channel_name)
  160. {
  161. ShowMsg("填写正确的账号信息!",-1);
  162. exit();
  163. }
  164. if($cfg_soft_lang=='gb2312') $channel_name = gb2utf8($channel_name);
  165. $paramsArr=array(
  166. 'email'=>$email,
  167. 'password'=>$pwd,
  168. 'domain'=>$domain,
  169. 'channel_name'=>$channel_name,
  170. );
  171. $rs = json_decode(mda_http_send(MDA_API_BIND_USER,0,$paramsArr),TRUE);
  172. if ( !$rs )
  173. {
  174. ShowMsg("请求API错误,请重试!",-1);
  175. exit();
  176. }
  177. if ( $rs['code'] != 0 )
  178. {
  179. ShowMsg("请求失败,错误代码[code:{$rs['code']}],消息[{$rs['msg']}]",-1);
  180. exit();
  181. }
  182. $channel_uuid = $rs['data']['channel_uuid'];
  183. $channel_secret = $rs['data']['channel_secret'];
  184. mda_set_setting('email', $email);
  185. mda_set_setting('channel_uuid', $channel_uuid);
  186. mda_set_setting('channel_secret', $channel_secret);
  187. $login_url = "?dopost=login";
  188. echo <<<EOT
  189. <iframe src="{$login_url}" scrolling="no" width="0" height="0" style="border:none"></iframe>
  190. EOT;
  191. ShowMsg("绑定成功,下面自动登录德得广告平台", "?dopost=login");
  192. exit();
  193. }
  194. /*--------------------------------
  195. function __login(){ }
  196. -------------------------------*/
  197. else if($dopost == 'login')
  198. {
  199. $email = mda_get_setting('email');
  200. $channel_uuid = mda_get_setting('channel_uuid');
  201. $channel_secret = mda_get_setting('channel_secret');
  202. $ts = time();
  203. $paramsArr=array(
  204. 'channel_uuid'=>$channel_uuid,
  205. 'channel_secret'=>$channel_secret,
  206. 'email'=>$email,
  207. 'ts'=>$ts,
  208. 'crc'=>md5($channel_uuid.$channel_secret.$ts),
  209. );
  210. $jquery_file = MDA_JQUERY;
  211. $api_login = MDA_API_LOGIN;
  212. $params = json_encode($paramsArr);
  213. $rs = json_decode(mda_http_send(MDA_API_LOGIN,0,$paramsArr),TRUE);
  214. if ( isset($rs['code']) AND $rs['code'] == 0 ) {
  215. $_SESSION['mda_email']=$email;
  216. } else {
  217. unset($_SESSION['mda_email']);
  218. header('Location:?logout=1');
  219. exit();
  220. }
  221. echo <<<EOT
  222. <script type="text/javascript" src="{$jquery_file}"></script>
  223. <script type="text/javascript">
  224. (function($){
  225. $.ajax({
  226. url: "{$api_login}",
  227. dataType : 'jsonp',
  228. jsonpCallback:"callfunc",
  229. data: $params,
  230. success: function( response ) {
  231. if(response.code == 0){
  232. window.location.href='?dopost=main&nomsg=yes&forward={$dopost}';
  233. console.log(response);
  234. }
  235. }
  236. });
  237. })(jQuery);
  238. </script>
  239. EOT;
  240. exit;
  241. }
  242. /*--------------------------------
  243. function __main(){ }
  244. -------------------------------*/
  245. else if($dopost == 'main'){
  246. $mda_version = MDA_VER;
  247. $channel_uuid = mda_get_setting('channel_uuid');
  248. $channel_secret = mda_get_setting('channel_secret');
  249. $msg = <<<EOT
  250. <form name='myform' method='POST' action='?'>
  251. <input type='hidden' name='dopost' value='set_secret'>
  252. <table width="98%" border="0" cellspacing="1" cellpadding="1">
  253. <tbody>
  254. <tr>
  255. <td width="16%" height="30">登录用户:</td>
  256. <td width="84%" style="text-align:left;">{$_SESSION['email']} {$account_str} <!--<a href='?dopost=logout' style='color:blue'>[退出]</a>--></td>
  257. </tr>
  258. <tr>
  259. <td width="16%" height="30">德得模块版本:</td>
  260. <td width="84%" style="text-align:left;">v{$mda_version} </td>
  261. </tr>
  262. <tr>
  263. <td width="16%" height="30">Channel UUID:</td>
  264. <td width="84%" style="text-align:left;"><input class="input-xlarge" type="text" value="{$channel_uuid}" disabled="disabled/" style="width:260px"> </td>
  265. </tr>
  266. <tr>
  267. <td width="16%" height="30">Channel Secret:</td>
  268. <td width="84%" style="text-align:left;">
  269. <input name="channel_secret" class="input-xlarge" type="text" value="{$channel_secret}" style="width:260px">
  270. <input type="submit" value="修改">
  271. </td>
  272. </tr>
  273. <tr>
  274. <td height="30" colspan="2">您已成功登录德得广告!您可以进行以下操作:</td>
  275. </tr>
  276. <tr>
  277. <td height="30" colspan="2">
  278. <a href='?dopost=place' style='color:blue'>[广告管理]</a>
  279. <a href='?dopost=report' style='color:blue'>[查看报表]</a>
  280. <a href='?dopost=account' style='color:blue'>[结算中心]</a>
  281. <a href='?dopost=setting' style='color:blue'>[德得设置]</a>
  282. <a href='?dopost=clearcache' style='color:blue'>[清空缓存]</a>
  283. </td>
  284. </tr>
  285. <tr>
  286. <td height="30" colspan="2">
  287. <hr>
  288. 使用说明:<br>
  289. 在广告管理中创建对应广告位,获取广告位标签,置入模板相应位置即可。
  290. <hr>
  291. 功能说明:<br>
  292. <b>[广告管理]</b>管理站点相应的广告位;<br>
  293. <b>[查看报表]</b>获取广告位相应的统计情况;<br>
  294. <b>[结算中心]</b>查看收益统计;<br>
  295. <b>[德得设置]</b>德得广告平台账号信息配置;<br>
  296. <b>[清空缓存]</b>清空广告标签缓存,如果更改登录账号建议清空缓存再生成;<br>
  297. <hr>
  298. </td>
  299. </tr>
  300. <tr>
  301. <td height="30" colspan="2" style="color:#999"><strong>德得广告</strong>是一个简单友好的广告平台,深度融合织梦系统,帮助您获取更多收益。</td>
  302. </tr>
  303. </tbody>
  304. </table>
  305. </form>
  306. {$login_str}
  307. {$change_isv_id}
  308. EOT;
  309. $wintitle = '德得广告管理';
  310. $wecome_info = '德得广告模块 》';
  311. $win = new OxWindow();
  312. $win->AddTitle($wintitle);
  313. $win->AddMsgItem($msg);
  314. $winform = $win->GetWindow('hand', '&nbsp;', false);
  315. $win->Display();
  316. exit;
  317. } else if($dopost == 'set_secret') {
  318. $email = mda_get_setting('email');
  319. $channel_uuid = mda_get_setting('channel_uuid');
  320. $ts = time();
  321. $paramsArr=array(
  322. 'channel_uuid'=>$channel_uuid,
  323. 'channel_secret'=>$channel_secret,
  324. 'email'=>$email,
  325. 'ts'=>$ts,
  326. 'crc'=>md5($channel_uuid.$channel_secret.$ts),
  327. );
  328. $rs = json_decode(mda_http_send(MDA_API_LOGIN,0,$paramsArr),TRUE);
  329. if ( !$rs )
  330. {
  331. ShowMsg("请求API错误,请重试!",-1);
  332. exit();
  333. }
  334. if ( $rs['code'] != 0 )
  335. {
  336. ShowMsg("请求失败,错误代码[code:{$rs['code']}],消息[{$rs['msg']}]",'?dopost=main');
  337. exit();
  338. }
  339. if ($rs['code'] == 0){
  340. ShowMsg("Channel Secret 修改成功……!",'?dopost=main');
  341. mda_set_setting('channel_secret', $channel_secret);
  342. }
  343. }
  344. // ------------------------------------------------------------------------
  345. /*--------------------------------
  346. function __index(){ }
  347. -------------------------------*/
  348. else {
  349. if ( mda_get_setting('email') AND mda_get_setting('channel_uuid') AND mda_get_setting('channel_secret') AND empty($logout))
  350. {
  351. header('Location:?dopost=login');
  352. exit;
  353. }
  354. $mda_reg_url = MDA_REG_URL;
  355. $mda_forget_pwd_url = MDA_FORGOT_PASSWORD_URL;
  356. $domain = !empty($_SERVER['HTTP_HOST'])? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
  357. $mda_update_url = MDA_APIHOST."/help/dedecms_module_download";
  358. echo <<<EOT
  359. <html>
  360. <head>
  361. <meta http-equiv="Content-Type" content="text/html; charset={$cfg_soft_lang}">
  362. <title>德得广告</title>
  363. <link rel="stylesheet" type="text/css" href="{$cfg_static_dir}/img/base.css">
  364. </head>
  365. <body background='{$cfg_static_dir}/img/allbg.gif' leftmargin="8" topmargin='8'>
  366. <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DFF9AA">
  367. <tr>
  368. <td height="28" style="border:1px solid #DADADA" background='{$cfg_static_dir}/img/wbg.gif'>&nbsp;<b><a href="?">德得广告 </a> &gt;&gt; 配置德得广告</b></td>
  369. </tr>
  370. <tr>
  371. <td width="100%" height="80" style="padding-top:5px" bgcolor='#ffffff'>
  372. <form name='myform' method='POST' action='?'>
  373. <input type='hidden' name='dopost' value='bind_user'>
  374. <table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#DADADA'>
  375. <tr bgcolor='#DADADA'>
  376. <td colspan='2' background='{$cfg_static_dir}/img/wbg.gif' height='26'><font color='#666600'><b>德得广告</b></font></td>
  377. </tr>
  378. <tr bgcolor='#FFFFFF'>
  379. <td colspan='2' height='100'>
  380. <table width="98%" border="0" cellspacing="1" cellpadding="1">
  381. <tbody>
  382. <tr>
  383. <td colspan="2" id="isvsContent">
  384. <table width="98%" border="0" cellspacing="1" cellpadding="1">
  385. <tbody>
  386. <tr>
  387. <td width="16%" height="30">邮箱:</td>
  388. <td width="84%" style="text-align:left;"><input name="email" type="email" id="email" size="16" style="width:200px" value="" />
  389. <a target="_blank" href="$mda_reg_url" style="color:blue">免费注册</a> ,获取专业广告服务</td>
  390. </tr>
  391. <tr>
  392. <td height="30">密码:</td>
  393. <td style="text-align:left;"><input name="pwd" type="password" id="pwd" size="16" style="width:200px">
  394. <a target="_blank" href="$mda_forget_pwd_url" style="color:blue">忘记密码</a> &nbsp; </td>
  395. </tr>
  396. <tr>
  397. <td width="16%" height="30">站点域名:</td>
  398. <td width="84%" style="text-align:left;"><input name="domain" type="text" id="domain" size="16" style="width:200px" value="{$domain}" />
  399. </td>
  400. </tr>
  401. <tr>
  402. <td width="16%" height="30">名称:</td>
  403. <td width="84%" style="text-align:left;"><input name="channel_name" type="text" id="channel_name" size="16" style="width:200px" value="{$cfg_webname}" />
  404. </td>
  405. </tr>
  406. <tr>
  407. <td height="30">模块版本:</td>
  408. <td style="text-align:left;">{$version}
  409. <a target="_blank" href="$mda_update_url" style="color:blue">下载新版模块</a> &nbsp; </td>
  410. </tr>
  411. </tbody>
  412. </table>
  413. </td>
  414. </tr>
  415. </tbody>
  416. </table>
  417. </td>
  418. </tr>
  419. <tr>
  420. <td colspan='2' bgcolor='#F9FCEF'><table width='270' border='0' cellpadding='0' cellspacing='0'>
  421. <tr align='center' height='28'>
  422. <td width='90'><input name='imageField1' type='image' class='np' src='{$cfg_plus_dir}/img/button_ok.gif' width='60' height='22' border='0' /></td>
  423. <td width='90'></td>
  424. <td></td>
  425. </tr>
  426. </table></td>
  427. </tr>
  428. </table>
  429. </form>
  430. </td>
  431. </tr>
  432. </table>
  433. <p align="center"> <br>
  434. <br>
  435. </p>
  436. </body>
  437. </html>
  438. EOT;
  439. }