国内流行的内容管理系统(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.

434 lines
15KB

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