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

455 lines
16KB

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