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

418 lines
17KB

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