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

465 lines
16KB

  1. <?php
  2. /**
  3. * 管理后台首页主体
  4. *
  5. * @version $Id: index_body.php 1 11:06 2010年7月13日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require(dirname(__FILE__).'/config.php');
  12. require(DEDEINC.'/image.func.php');
  13. require(DEDEINC.'/dedetag.class.php');
  14. $defaultIcoFile = DEDEDATA.'/admin/quickmenu.txt';
  15. $myIcoFile = DEDEDATA.'/admin/quickmenu-'.$cuserLogin->getUserID().'.txt';
  16. if(!file_exists($myIcoFile)) $myIcoFile = $defaultIcoFile;
  17. //默认主页
  18. if(empty($dopost))
  19. {
  20. require(DEDEINC.'/inc/inc_fun_funAdmin.php');
  21. $verLockFile = DEDEDATA.'/admin/ver.txt';
  22. $fp = fopen($verLockFile,'r');
  23. $upTime = trim(fread($fp,64));
  24. fclose($fp);
  25. $oktime = substr($upTime,0,4).'-'.substr($upTime,4,2).'-'.substr($upTime,6,2);
  26. $offUrl = SpGetNewInfo();
  27. $dedecmsidc = DEDEDATA.'/admin/idc.txt';
  28. $fp = fopen($dedecmsidc,'r');
  29. $dedeIDC = fread($fp,filesize($dedecmsidc));
  30. fclose($fp);
  31. $myMoveFile = DEDEDATA.'/admin/move-'.$cuserLogin->getUserID().'.txt';
  32. if(file_exists($myMoveFile))
  33. {
  34. $fp = fopen($myMoveFile,'r');
  35. $movedata= fread($fp,filesize($myMoveFile));
  36. $movedata = unserialize($movedata);
  37. $column1 = array();
  38. $column2 = array();
  39. foreach ($movedata['items'] as $key => $value) {
  40. if($value['column'] == 'column1') $column1 = $column1 + array($key => $value['id']);
  41. else if($value['column'] == 'column2') $column2 = $column2 + array($key => $value['id']);
  42. }
  43. include DedeInclude('templets/index_body_move.htm');
  44. }else{
  45. include DedeInclude('templets/index_body.htm');
  46. }
  47. exit();
  48. }
  49. /*-----------------------
  50. 增加新项
  51. function _AddNew() { }
  52. -------------------------*/
  53. else if($dopost=='addnew')
  54. {
  55. if(empty($link) || empty($title))
  56. {
  57. ShowMsg("链接网址或标题不能为空!","-1");
  58. exit();
  59. }
  60. $fp = fopen($myIcoFile,'r');
  61. $oldct = trim(fread($fp, filesize($myIcoFile)));
  62. fclose($fp);
  63. $link = preg_replace("#['\"]#", '`', $link);
  64. $title = preg_replace("#['\"]#", '`', $title);
  65. $ico = preg_replace("#['\"]#", '`', $ico);
  66. $oldct .= "\r\n<menu:item ico=\"{$ico}\" link=\"{$link}\" title=\"{$title}\" />";
  67. $myIcoFileTrue = DEDEDATA.'/admin/quickmenu-'.$cuserLogin->getUserID().'.txt';
  68. $fp = fopen($myIcoFileTrue, 'w');
  69. fwrite($fp, $oldct);
  70. fclose($fp);
  71. ShowMsg("成功增加一个项目!","index_body.php?".time());
  72. exit();
  73. }
  74. /*---------------------------
  75. 保存修改的项
  76. function _EditSave() { }
  77. ----------------------------*/
  78. else if($dopost=='editsave')
  79. {
  80. $quickmenu = stripslashes($quickmenu);
  81. $myIcoFileTrue = DEDEDATA.'/admin/quickmenu-'.$cuserLogin->getUserID().'.txt';
  82. $fp = fopen($myIcoFileTrue,'w');
  83. fwrite($fp,$quickmenu);
  84. fclose($fp);
  85. ShowMsg("成功修改快捷操作项目!","index_body.php?".time());
  86. exit();
  87. }
  88. /*---------------------------
  89. 保存修改的项
  90. function _EditSave() { }
  91. ----------------------------*/
  92. else if($dopost=='movesave')
  93. {
  94. $movedata = str_replace('\\',"",$sortorder);
  95. $movedata = json_decode($movedata,TRUE);
  96. $movedata = serialize($movedata);
  97. $myIcoFileTrue = DEDEDATA.'/admin/move-'.$cuserLogin->getUserID().'.txt';
  98. $fp = fopen($myIcoFileTrue,'w');
  99. fwrite($fp,$movedata);
  100. fclose($fp);
  101. }
  102. /*-----------------------------
  103. 显示修改表单
  104. function _EditShow() { }
  105. -----------------------------*/
  106. else if($dopost=='editshow')
  107. {
  108. $fp = fopen($myIcoFile,'r');
  109. $oldct = trim(fread($fp,filesize($myIcoFile)));
  110. fclose($fp);
  111. ?>
  112. <form name='editform' action='index_body.php' method='post'>
  113. <input type='hidden' name='dopost' value='editsave' />
  114. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  115. <tr>
  116. <td height='28' background="images/tbg.gif">
  117. <div style='float:left'><b>修改快捷操作项</b></div>
  118. <div style='float:right;padding:3px 10px 0 0;'>
  119. <a href="javascript:CloseTab('editTab')"><img src="images/close.gif" width="12" height="12" border="0" /></a>
  120. </div>
  121. </td>
  122. </tr>
  123. <tr><td style="height:6px;font-size:1px;border-top:1px solid #8DA659">&nbsp;</td></tr>
  124. <tr>
  125. <td>
  126. 按原格式修改/增加XML项。
  127. </td>
  128. </tr>
  129. <tr>
  130. <td align='center'>
  131. <textarea name="quickmenu" rows="10" cols="50" style="width:94%;height:220px"><?php echo $oldct; ?></textarea>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td height="45" align="center">
  136. <input type="submit" name="Submit" value="保存项目" class="np coolbg" style="width:80px;cursor:pointer" />
  137. &nbsp;
  138. <input type="reset" name="reset" value="重设" class="np coolbg" style="width:50px;cursor:pointer" />
  139. </td>
  140. </tr>
  141. </table>
  142. </form>
  143. <?php
  144. exit();
  145. }
  146. /*---------------------------------
  147. 载入右边内容
  148. function _getRightSide() { }
  149. ---------------------------------*/
  150. else if($dopost=='getRightSide')
  151. {
  152. $query = " SELECT COUNT(*) AS dd FROM `#@__member` ";
  153. $row1 = $dsql->GetOne($query);
  154. $query = " SELECT COUNT(*) AS dd FROM `#@__feedback` ";
  155. $row2 = $dsql->GetOne($query);
  156. $chArrNames = array();
  157. $query = "SELECT id, typename FROM `#@__channeltype` ";
  158. $dsql->Execute('c', $query);
  159. while($row = $dsql->GetArray('c'))
  160. {
  161. $chArrNames[$row['id']] = $row['typename'];
  162. }
  163. $query = "SELECT COUNT(channel) AS dd, channel FROM `#@__arctiny` GROUP BY channel ";
  164. $allArc = 0;
  165. $chArr = array();
  166. $dsql->Execute('a', $query);
  167. while($row = $dsql->GetArray('a'))
  168. {
  169. $allArc += $row['dd'];
  170. $row['typename'] = $chArrNames[$row['channel']];
  171. $chArr[] = $row;
  172. }
  173. ?>
  174. <table width="100%" class="dboxtable">
  175. <tr>
  176. <td width='50%' class='nline' style="text-align:left"> 会员数: </td>
  177. <td class='nline' style="text-align:left"> <?php echo $row1['dd']; ?> </td>
  178. </tr>
  179. <tr>
  180. <td class='nline' style="text-align:left"> 文档数: </td>
  181. <td class='nline' style="text-align:left"> <?php echo $allArc; ?> </td>
  182. </tr>
  183. <?php
  184. foreach($chArr as $row)
  185. {
  186. ?>
  187. <tr>
  188. <td class='nline' style="text-align:left"> <?php echo $row['typename']; ?>: </td>
  189. <td class='nline' style="text-align:left"> <?php echo $row['dd']; ?>&nbsp; </td>
  190. </tr>
  191. <?php
  192. }
  193. ?>
  194. <tr>
  195. <td style="text-align:left"> 评论数: </td>
  196. <td style="text-align:left"> <?php echo $row2['dd']; ?> </td>
  197. </tr>
  198. </table>
  199. <?php
  200. exit();
  201. } else if ($dopost=='getRightSideNews')
  202. {
  203. $query = "SELECT arc.id, arc.arcrank, arc.title, arc.channel, ch.editcon FROM `#@__archives` arc
  204. LEFT JOIN `#@__channeltype` ch ON ch.id = arc.channel
  205. WHERE arc.arcrank<>-2 ORDER BY arc.id DESC LIMIT 0, 6 ";
  206. $arcArr = array();
  207. $dsql->Execute('m', $query);
  208. while($row = $dsql->GetArray('m'))
  209. {
  210. $arcArr[] = $row;
  211. }
  212. AjaxHead();
  213. ?>
  214. <table width="100%" class="dboxtable">
  215. <?php
  216. foreach($arcArr as $row)
  217. {
  218. if(trim($row['editcon'])=='') {
  219. $row['editcon'] = 'archives_edit.php';
  220. }
  221. $linkstr = "·<a href='{$row['editcon']}?aid={$row['id']}&channelid={$row['channel']}'>{$row['title']}</a>";
  222. if($row['arcrank']==-1) $linkstr .= "<font color='red'>(未审核)</font>";
  223. ?>
  224. <tr>
  225. <td class='nline'>
  226. <?php echo $linkstr; ?>
  227. </td>
  228. </tr>
  229. <?php
  230. }
  231. ?>
  232. </table>
  233. <?php
  234. exit;
  235. } else if ($dopost=='showauth')
  236. {
  237. include('templets/index_body_showauth.htm');
  238. exit;
  239. } else if ($dopost=='showad')
  240. {
  241. include('templets/index_body_showad.htm');
  242. exit;
  243. } else if($dopost=='setskin')
  244. {
  245. $cskin = empty($cskin)? 1 : $cskin;
  246. $skin = !in_array($cskin, array(1,2,3,4))? 1 : $cskin;
  247. $skinconfig = DEDEDATA.'/admin/skin.txt';
  248. PutFile($skinconfig, $skin);
  249. } elseif ( $dopost=='get_seo' )
  250. {
  251. if (!function_exists('fsocketopen') && !function_exists('curl_init')) {
  252. echo '没有支持的curl或fsocketopen组件';
  253. exit;
  254. }
  255. function dedeseo_http_send($url, $limit=0, $post='', $cookie='', $timeout=5)
  256. {
  257. $return = '';
  258. $matches = parse_url($url);
  259. $scheme = $matches['scheme'];
  260. $host = $matches['host'];
  261. $path = $matches['path'] ? $matches['path'].(@$matches['query'] ? '?'.$matches['query'] : '') : '/';
  262. $port = !empty($matches['port']) ? $matches['port'] : 80;
  263. if (function_exists('curl_init') && function_exists('curl_exec')) {
  264. $ch = curl_init();
  265. curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path);
  266. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  267. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  268. curl_setopt($ch, CURLOPT_USERAGENT, @$_SERVER['HTTP_USER_AGENT']);
  269. if ($post) {
  270. curl_setopt($ch, CURLOPT_POST, 1);
  271. $content = is_array($port) ? http_build_query($post) : $post;
  272. curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
  273. }
  274. if ($cookie) {
  275. curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  276. }
  277. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  278. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  279. $data = curl_exec($ch);
  280. $status = curl_getinfo($ch);
  281. $errno = curl_errno($ch);
  282. curl_close($ch);
  283. if ($errno || $status['http_code'] != 200) {
  284. return;
  285. } else {
  286. return !$limit ? $data : substr($data, 0, $limit);
  287. }
  288. }
  289. if ($post) {
  290. $content = is_array($port) ? http_build_query($post) : $post;
  291. $out = "POST $path HTTP/1.0\r\n";
  292. $header = "Accept: */*\r\n";
  293. $header .= "Accept-Language: zh-cn\r\n";
  294. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  295. $header .= "User-Agent: ".@$_SERVER['HTTP_USER_AGENT']."\r\n";
  296. $header .= "Host: $host:$port\r\n";
  297. $header .= 'Content-Length: '.strlen($content)."\r\n";
  298. $header .= "Connection: Close\r\n";
  299. $header .= "Cache-Control: no-cache\r\n";
  300. $header .= "Cookie: $cookie\r\n\r\n";
  301. $out .= $header.$content;
  302. } else {
  303. $out = "GET $path HTTP/1.0\r\n";
  304. $header = "Accept: */*\r\n";
  305. $header .= "Accept-Language: zh-cn\r\n";
  306. $header .= "User-Agent: ".@$_SERVER['HTTP_USER_AGENT']."\r\n";
  307. $header .= "Host: $host:$port\r\n";
  308. $header .= "Connection: Close\r\n";
  309. $header .= "Cookie: $cookie\r\n\r\n";
  310. $out .= $header;
  311. }
  312. $fpflag = 0;
  313. $fp = false;
  314. if (function_exists('fsocketopen')) {
  315. $fp = fsocketopen($host, $port, $errno, $errstr, $timeout);
  316. }
  317. if (!$fp) {
  318. $context = stream_context_create(array(
  319. 'http' => array(
  320. 'method' => $post ? 'POST' : 'GET',
  321. 'header' => $header,
  322. 'content' => $content,
  323. 'timeout' => $timeout,
  324. ),
  325. ));
  326. $fp = @fopen($scheme.'://'.$host.':'.$port.$path, 'b', false, $context);
  327. $fpflag = 1;
  328. }
  329. if (!$fp) {
  330. return '';
  331. } else {
  332. stream_set_blocking($fp, true);
  333. stream_set_timeout($fp, $timeout);
  334. @fwrite($fp, $out);
  335. $status = stream_get_meta_data($fp);
  336. if (!$status['timed_out']) {
  337. while (!feof($fp) && !$fpflag) {
  338. if (($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
  339. break;
  340. }
  341. }
  342. if ($limit) {
  343. $return = stream_get_contents($fp, $limit);
  344. } else {
  345. $return = stream_get_contents($fp);
  346. }
  347. }
  348. @fclose($fp);
  349. return $return;
  350. }
  351. }
  352. $seo_info = array();
  353. $seo_info = $dsql->GetOne("SELECT * FROM `#@__plus_seoinfo` ORDER BY id DESC");
  354. $now = time();
  355. if ( empty($seo_info) OR $now - $seo_info['create_time'] > 60*60*6 )
  356. {
  357. $site = str_replace(array("http://",'/'),'',$cfg_basehost);
  358. $url = "http://www.alexa.com/siteinfo/{$site}";
  359. $html = dedeseo_http_send($url);
  360. //var_dump($html);exit;
  361. if ( preg_match("#API at http://aws.amazon.com/awis -->(.*)</strong>#isU",$html,$matches) )
  362. {
  363. $seo_info['alexa_num'] = isset($matches[1])? trim($matches[1]) : 0;
  364. }
  365. $seo_info['alexa_num'] = empty($seo_info['alexa_num'])? 0 : $seo_info['alexa_num'];
  366. if ( preg_match("#Flag'><strong class=\"metrics-data align-vmiddle\">(.*)</strong>#isU",$html,$matches) )
  367. {
  368. $seo_info['alexa_area_num'] = isset($matches[1])? trim($matches[1]) : 0;
  369. }
  370. $seo_info['alexa_area_num'] = empty($seo_info['alexa_area_num'])? 0 : $seo_info['alexa_area_num'];
  371. $url = "http://www.baidu.com/s?wd=site:{$site}";
  372. $html = Html2Text(dedeseo_http_send($url));
  373. if ( preg_match("#结果数约([\d]+)个#",$html,$matches) )
  374. {
  375. $seo_info['baidu_count'] = isset($matches[1])? $matches[1] : 0;
  376. }
  377. if (empty($seo_info['baidu_count']) AND preg_match("#网站共有([\d, ]+)个#",$html,$matches) )
  378. {
  379. $seo_info['baidu_count'] = isset($matches[1])? trim($matches[1]) : 0;
  380. }
  381. $seo_info['baidu_count'] = empty($seo_info['baidu_count'])? 0 : $seo_info['baidu_count'];
  382. $url = "http://www.sogou.com/web?query=site:{$site}";
  383. $html = Html2Text(dedeseo_http_send($url));
  384. if ( preg_match("#结果数约([\d]+)个#",$html,$matches) )
  385. {
  386. $seo_info['sogou_count'] = isset($matches[1])? $matches[1] : 0;
  387. }
  388. if (empty($seo_info['sogou_count']) AND preg_match("#找到约([\d, ]+)条结果#",$html,$matches) )
  389. {
  390. $seo_info['sogou_count'] = isset($matches[1])? trim($matches[1]) : 0;
  391. }
  392. $seo_info['sogou_count'] = empty($seo_info['sogou_count'])? 0 : $seo_info['sogou_count'];
  393. $url = "http://www.haosou.com/s?q=site%3A{$site}";
  394. $html = Html2Text(dedeseo_http_send($url));
  395. if ( preg_match("#结果数约([\d]+)个#",$html,$matches) )
  396. {
  397. $seo_info['haosou360_count'] = isset($matches[1])? $matches[1] : 0;
  398. }
  399. if (empty($seo_info['haosou360_count']) AND preg_match("#结果约([\d, ]+)个#",$html,$matches) )
  400. {
  401. $seo_info['haosou360_count'] = isset($matches[1])? trim($matches[1]) : 0;
  402. }
  403. $seo_info['haosou360_count'] = empty($seo_info['haosou360_count'])? 0 : $seo_info['haosou360_count'];
  404. $in_query = "INSERT INTO `#@__plus_seoinfo` (`create_time`, `alexa_num`, `alexa_area_num`, `baidu_count`, `sogou_count`, `haosou360_count`) VALUES ({$now}, '{$seo_info['alexa_num']}', '{$seo_info['alexa_area_num']}', '{$seo_info['baidu_count']}', '{$seo_info['sogou_count']}', '{$seo_info['haosou360_count']}');";
  405. $dsql->ExecuteNoneQuery($in_query);
  406. }
  407. $inff=array(
  408. 'alexa_num'=>'Alexa全球排名',
  409. 'alexa_area_num'=>'Alexa地区排名',
  410. 'baidu_count'=>'百度收录',
  411. 'sogou_count'=>'搜狗收录',
  412. 'haosou360_count'=>'360收录',
  413. );
  414. ?>
  415. <table width="100%" class="dboxtable">
  416. <tbody>
  417. <?php
  418. foreach( $seo_info as $key => $value )
  419. {
  420. if ( $key=='id' OR $key=='create_time' ) continue;
  421. ?>
  422. <tr>
  423. <td width="50%" class="nline" style="text-align:left"> <?php
  424. echo $inff[$key];
  425. ?>
  426. : </td>
  427. <td class="nline" style="text-align:left"> <?php
  428. echo $value;
  429. ?>
  430. </td>
  431. </tr>
  432. <?php
  433. }
  434. ?>
  435. </tbody></table>
  436. <?php
  437. exit;
  438. }
  439. ?>