PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/kernel/article.class.php

http://xklog.googlecode.com/
PHP | 904 lines | 812 code | 48 blank | 44 comment | 103 complexity | 355cd64e57018694769a35fec4d19859 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. !defined('IN_NOVA') && exit('Access Denied!');
  3. class Article {
  4. public function start() {
  5. global $db,$cache,$request;
  6. $action = $request->get( 'p' );
  7. $id = $request->id;
  8. switch( $action ) {
  9. case 'add':
  10. $this->article_add();
  11. break;
  12. case 'edit':
  13. $this->article_add( 'edit' );
  14. break;
  15. case 'saveadd':
  16. // ??????
  17. $article_id = $this->add();
  18. if( $article_id == 0 ) {
  19. break;
  20. }
  21. //$article_type = $request->get( 'article_type', 'P' );
  22. if( $cache->config['arttype'] == '??' ){
  23. page_make( $article_id, $article_type );
  24. }
  25. $cache->refresh( 'count', TRUE );
  26. $cache->refresh( 'article_new', TRUE );
  27. $cache->refresh( 'article_list', TRUE );
  28. echo '<p class="warning">' . L('_ADD_ARTICLE_SUCCESS_') . '</p>';
  29. break;
  30. case 'saveedit':
  31. // ??????
  32. if( $this->edit( $id ) == 0 ) {
  33. break;
  34. }
  35. $article_type = $request->get('article_type','P');
  36. if( $cache->config['arttype'] == '??' ){
  37. page_make( $article_id, $article_type );
  38. }
  39. $cache->refresh( 'article_hot', TRUE );
  40. $cache->refresh( 'article_new', TRUE );
  41. $cache->refresh( 'article_list', TRUE );
  42. echo '<p class="warning">' . L('_EDIT_ARTICLE_SUCCESS_') . '</p>';
  43. break;
  44. case 'top':
  45. // ??????
  46. $db->query( "UPDATE `" . DB_PREFIX . "article` SET istop = 1 WHERE id=$id" );
  47. // ????
  48. $cache->refresh( 'article_list', TRUE );
  49. echo '<p class="warning">' . '??????' . '</p>';
  50. break;
  51. case 'topcancel':
  52. // ????????
  53. $db->query( "UPDATE `" . DB_PREFIX . "article` SET istop = 0 WHERE id=$id" );
  54. // ????
  55. $cache->refresh( 'article_list', TRUE );
  56. echo '<p class="warning">' . '????????' . '</p>';
  57. break;
  58. case 'reflash':
  59. // ??????
  60. /*page_make_html( $id );
  61. $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=$id" );*/
  62. echo '<p class="warning">' . '??????' . '</p>';
  63. break;
  64. case 'del':
  65. // ??????
  66. $category = $db->result( "SELECT category FROM `" . DB_PREFIX . "article` WHERE id=$id AND isdel = 0" );
  67. if( $category == '' ) {
  68. $theme->show_message( '??????' );
  69. break;
  70. }
  71. // ??????
  72. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum - 1 WHERE cid=$category" );
  73. // ????????
  74. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel = 1 WHERE articleid=$id" );
  75. // ??????
  76. $tags = $db->result( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE id=$id" );
  77. $tags = str_replace( '*}{*',',',$tags );
  78. $tags = str_replace( '*}','',$tags );
  79. $tags = str_replace( '{*','',$tags );
  80. $tags = split( ',' , $tags );
  81. foreach($tags as $tag){
  82. if( $tag != '' ){
  83. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num-1 WHERE t_id=$tag" );
  84. }
  85. }
  86. // ????
  87. $db->query( "UPDATE `" . DB_PREFIX . "article` SET isdel = 1 WHERE id=$id" );
  88. // ????
  89. $cache->article_new = NULL;
  90. $cache->article_hot = NULL;
  91. $cache->comment_new = NULL;
  92. $cache->category = NULL;
  93. $cache->count = NULL;
  94. $cache->tag = NULL;
  95. echo '<p class="warning">' . '??????' . '</p>';
  96. break;
  97. case 'addreply':
  98. // ??????
  99. $reply = htmlspecialchars( $request->get('commentreply','P') );
  100. $reply = str_replace( array("\r\n", "\n", "\r"), '<br />', $reply );
  101. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET replyuser = '" . $_SESSION['user_name'] . "',reply = '$reply',replytime = " . PHP_TIME . " WHERE cid = $id" );
  102. echo '<p class="warning">' . '??????' . '</p>';
  103. break;
  104. case 'delreply':
  105. // ??????
  106. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET replyuser = NULL WHERE cid = $id" );
  107. echo '<p class="warning">' . '??????' . '</p>';
  108. break;
  109. case 'delcomment':
  110. // ??????
  111. $aid = $db->result( "SELECT articleid FROM `" . DB_PREFIX . "comment` WHERE cid=$id AND isdel = 0" );
  112. if( $aid == '' ) {
  113. echo '<p class="error">' . '??????' . '</p>';
  114. break;
  115. }
  116. $db->query( "UPDATE `" . DB_PREFIX . "article` SET comment=comment-1 WHERE id=$aid" );
  117. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel=1 WHERE cid=$id" );
  118. $cache->article_hot = NULL;
  119. $cache->comment_new = NULL;
  120. $cache->guestbook_new = NULL;
  121. $cache->count = NULL;
  122. echo '<p class="warning">' . '??????' . '</p>';
  123. break;
  124. case 'censor':
  125. // ??????
  126. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isshow = 1 WHERE cid = $id" );
  127. $cache->comment_new = NULL;
  128. $cache->guestbook_new = NULL;
  129. echo '<p class="warning">' . '??????' . '</p>';
  130. break;
  131. case 'MakearticlePage':
  132. $this->make_article_page();
  133. break;
  134. case 'datacheckexe':
  135. $this->data_check_exe();
  136. break;
  137. case 'tagdatacheckexe':
  138. $this->tag_data_check_exe();
  139. break;
  140. case 'batch':
  141. $this->batch();
  142. break;
  143. default:
  144. $this->show( $action );
  145. }
  146. }
  147. private function make_article_page() {
  148. global $db,$_CACHE;
  149. $_CACHE['count'][0]['online'] = cache_online();
  150. if( count( $_CACHE['category'] ) == 0 ) {
  151. show_admin_message( '??????', 'admin_article.php' );
  152. exit;
  153. }else{
  154. foreach( $_CACHE['category'] as $category ) {
  155. $file_path = XKLOG_ROOT . 'article/' . $category['alias'] . '/';
  156. if ( !is_dir( $file_path ) ) {
  157. @mkdir( $file_path, 0777 );
  158. }
  159. $article_arr = array();
  160. $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=" . $category['cid'] . " AND type='??' ORDER BY id DESC" );
  161. foreach( $article_arr as $article ) {
  162. page_make_html( $article['id'] );
  163. $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=" . $article['id'] );
  164. }
  165. }
  166. }
  167. show_admin_message( '???????????', 'admin_article.php' );
  168. exit;
  169. }
  170. private function data_check_exe() {
  171. global $db,$cache;
  172. $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article`" );
  173. if( count( $article_arr ) == 0 ) {
  174. $this->show( 'datacheck', '???????????', 'error' );
  175. return;
  176. }
  177. foreach( $article_arr as $article ) {
  178. $temp = $db->result( "SELECT COUNT(cid) FROM `" . DB_PREFIX . "comment` WHERE isdel=0 AND articleid=" . $article['id'] );
  179. $db->query( "UPDATE `" . DB_PREFIX . "article` SET comment=" . $temp . " WHERE id=" . $article['id'] );
  180. }
  181. $cache->refresh( 'article_hot', TRUE );
  182. $this->show( 'datacheck', '????????????', 'warning' );
  183. }
  184. private function tag_data_check_exe() {
  185. global $db,$cache;
  186. $article_arr = $db->fetch_all( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE isdel=0" );
  187. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=0" );
  188. $tag_arr = $db->fetch_all( "SELECT t_id,t_name FROM `" . DB_PREFIX . "tags`" );
  189. if( count( $article_arr ) == 0 ) {
  190. $this->show( 'datacheck', '???????????', 'error' );
  191. return;
  192. }
  193. foreach( $article_arr as $article ) {
  194. $article['tag'] = str_replace( '*}{*',',',$article['tag'] );
  195. $article['tag'] = substr( $article['tag'],2 );
  196. $article['tag'] = substr( $article['tag'],0,-2 );
  197. $article['tag'] = explode( ',' , $article['tag'] );
  198. foreach( $article['tag'] as $tag ) {
  199. foreach( $tag_arr as $tag_old ) {
  200. if( $tag == $tag_old['t_id'] ) {
  201. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num+1 WHERE t_id=" . $tag_old['t_id'] );
  202. break;
  203. }
  204. }
  205. }
  206. }
  207. if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=1" ) != 0 ) {
  208. $this->show( 'datacheck', '??????????????????? 0 ????????????????', 'warning' );
  209. }else{
  210. $db->query( "DELETE FROM `" . DB_PREFIX . "tags` WHERE t_num=0" );
  211. $this->show( 'datacheck', '??????????', 'warning' );
  212. }
  213. $cache->refresh( 'tag', TRUE );
  214. }
  215. private function batch() {
  216. global $cache,$db;
  217. $control = getGP( 'Control','P' );
  218. $id_arr = array();
  219. $id_arr = getGP( 'id_arr','P','array' );
  220. $size = count( $id_arr );
  221. if( $size == 0 ) {
  222. echo '<p class="error">' . '?????????' . '</p>';
  223. return;
  224. }
  225. $sql = '';
  226. for( $i=0; $i<$size; $i ++ ){
  227. $sql .= 'id=' . $id_arr[$i] . ' OR ';
  228. }
  229. $sql = substr( $sql,0,-4 );
  230. if( $control == '??' ) {
  231. // ????
  232. $db->query( 'UPDATE `' . DB_PREFIX . 'article` SET isdel=1 WHERE (' . $sql . ')' );
  233. // ??????
  234. $tag_arr = $db->fetch_all( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE ( $sql )" );
  235. foreach( $tag_arr as $tags ) {
  236. $tags['tag'] = str_replace( '*}{*',',',$tags['tag'] );
  237. $tags['tag'] = str_replace( '*}','',$tags['tag'] );
  238. $tags['tag'] = str_replace( '{*','',$tags['tag'] );
  239. $tags['tag'] = split( ',' , $tags['tag'] );
  240. foreach($tags['tag'] as $tag){
  241. if( $tag != '' ){
  242. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num-1 WHERE t_id=$tag" );
  243. }
  244. }
  245. }
  246. // ??????
  247. $id_arr = str_replace( 'id=','',$sql );
  248. $id_arr = split( ' OR ',$id_arr );
  249. $size = count( $id_arr );
  250. $sql = '';
  251. for( $i=0; $i<$size; $i ++ ){
  252. $sql .= 'articleid=' . $id_arr[$i] . ' OR ';
  253. }
  254. $sql = substr( $sql,0,-4 );
  255. $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel = 1 WHERE ( $sql )" );
  256. // ????????
  257. foreach( $_CACHE['category'] as $category ) {
  258. $cid = $category['cid'];
  259. $article_num = $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=$cid" );
  260. if( $category['articlenum'] != $article_num ) {
  261. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum=$article_num WHERE cid=$cid" );
  262. }
  263. }
  264. // ????
  265. cache_article_hot();
  266. cache_article_new();
  267. cache_comment_new();
  268. cache_category();
  269. cache_count();
  270. cache_tag();
  271. show_admin_message( '????????', 'admin_article.php?action=article' );
  272. }elseif( $control == '??' ) {
  273. $category = getGP( 'article_category','P','int' );
  274. $sql = 'UPDATE `' . DB_PREFIX . 'article` SET category=' . $category . ' WHERE (' . $sql . ')';
  275. $db->query( $sql );
  276. // ????????
  277. foreach( $_CACHE['category'] as $category ) {
  278. $cid = $category['cid'];
  279. $article_num = $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=$cid" );
  280. if( $category['articlenum'] != $article_num ) {
  281. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum=$article_num WHERE cid=$cid" );
  282. }
  283. }
  284. // ????
  285. cache_article_hot();
  286. cache_article_new();
  287. cache_category();
  288. show_admin_message( '?????????????????????', 'admin_article.php?action=article' );
  289. }elseif( $control == '??' ) {
  290. $type = getGP( 'article_type','P' );
  291. $sql2 = "UPDATE `" . DB_PREFIX . "article` SET type='$type' WHERE ( $sql )";
  292. $db->query( $sql2 );
  293. // ???????????
  294. if( $type != '??' ) {
  295. $_CACHE['count'][0]['online'] = cache_online();
  296. foreach( $_CACHE['category'] as $category ) {
  297. $file_path = XKLOG_ROOT . 'article/' . $category['alias'] . '/';
  298. if ( !is_dir( $file_path ) ) {
  299. @mkdir( $file_path, 0777 );
  300. }
  301. $article_arr = array();
  302. $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article` WHERE ( $sql )" );
  303. foreach( $article_arr as $article ) {
  304. page_make( $article['id'], $type );
  305. $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=" . $article['id'] );
  306. }
  307. }
  308. }
  309. // ????
  310. cache_article_hot();
  311. cache_article_new();
  312. show_admin_message( '????????', 'admin_article.php?action=article' );
  313. }else{
  314. show_admin_message( '?????', 'admin_article.php' );
  315. }
  316. }
  317. // ??????
  318. private function add(){
  319. global $cache,$db,$request;
  320. $title = $request->get('article_title','P');
  321. $keywords = $request->get('article_keywords','P');
  322. $description = $request->get('article_description','P');
  323. $content = $request->get('article_content','P');
  324. $summary = $request->get('article_summary','P');
  325. $address = $request->get('article_alias','P');
  326. $type = $request->get('article_type','P');
  327. if( trim( $title ) == '' || trim( $content ) == '' ){
  328. echo '<p class="error">' . '??????????????' . '</p>';
  329. return 0;
  330. }
  331. if( strlen( $content ) > $cache->config['artmaxlength'] ){
  332. echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
  333. return 0;
  334. }
  335. if( strlen( $summary ) > $cache->config['artmaxlength'] ){
  336. echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
  337. return 0;
  338. }
  339. // ???????????
  340. // ?????????????????????? is_numeric ???????????
  341. if( $address != '' ) {
  342. if( is_numeric( $address ) ) {
  343. echo '<p class="error">' . '???????????????' . '</p>';
  344. return 0;
  345. }
  346. if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE address='$address'") ) {
  347. echo '<p class="error">' . '????????????' . '</p>';
  348. return 0;
  349. }
  350. $file_path = APP_CACHE . $address . '.html';
  351. @file_put_contents( $file_path, ' ' );
  352. if( file_exists( $file_path ) ) {
  353. unlink( $file_path );
  354. }else{
  355. echo '<p class="error">' . '???????????' . '</p>';
  356. return 0;
  357. }
  358. unset( $file_path );
  359. }
  360. // ????
  361. $category = $request->get('article_category','P');
  362. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum + 1 WHERE cid = '$category'");
  363. $cache->refresh( 'category', TRUE );
  364. $type = $request->get('article_type','P');
  365. $trackback = $request->get('article_trackback','P');
  366. // ????
  367. $temp = explode( ',' , $request->get('article_tag','P') );
  368. $temp = array_unique( $temp );
  369. $tag = '';
  370. $find = false;
  371. foreach( $temp as $itag ){
  372. if( $itag != '' ){
  373. foreach( $cache->tag as $tag_id => $tag_arr ){
  374. if( $tag_arr['t_name'] == $itag ){
  375. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num + 1 WHERE t_name = '$itag'");
  376. $tag .= '{*' . $tag_id . '*}';
  377. $find = true;
  378. break;
  379. }
  380. }
  381. if( $find == false ){
  382. $db->query( "INSERT INTO `" . DB_PREFIX . "tags` (`t_name`,`t_num`) VALUES ('$itag',1)" );
  383. $tag .= '{*' . $db->insert_id() . '*}';
  384. }else{
  385. $find = false;
  386. }
  387. }
  388. }
  389. $cache->refresh( 'tag', TRUE );
  390. if( !isset( $_SESSION['upfile'] ) ) $_SESSION['upfile'] = '';
  391. $db->query( "INSERT INTO `" . DB_PREFIX . "article` (`title`,`keywords`,`description`,`time`,`author`,`category`,`tag`,`summary`,`content`,`read`,`comment`,`address`,`type`,`attachment`) VALUES ('$title', '$keywords', '$description', '" . PHP_TIME . "', '" . $request->get( APP_PREFIX . 'username', 'C' ) . "', $category, '$tag', '$summary', '$content',0,0,'$address','$type','" . $_SESSION['upfile'] . "')" );
  392. unset($_SESSION['upfile']);
  393. return $db->insert_id();
  394. }
  395. // ??????
  396. private function edit( $article_id ){
  397. global $cache,$db,$request;
  398. $title = $request->get('article_title','P');
  399. $keywords = $request->get('article_keywords','P');
  400. $description = $request->get('article_description','P');
  401. $content = $request->get('article_content','P');
  402. $summary = $request->get('article_summary','P');
  403. $address = trim( $request->get('article_alias','P') );
  404. $type = $request->get('article_type','P');
  405. if( trim( $title ) == '' || trim( $content ) == '' ){
  406. echo '<p class="error">' . '??????????????' . '</p>';
  407. return 0;
  408. }
  409. if( strlen( $content ) > $cache->config['artmaxlength'] ){
  410. echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
  411. return 0;
  412. }
  413. if( strlen( $summary ) > $cache->config['artmaxlength'] ){
  414. echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
  415. return 0;
  416. }
  417. // ????????
  418. if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE id={$article_id} AND isdel=0 AND type<3" ) == 0 ){
  419. echo '<p class="error">' . '?????????????' . '</p>';
  420. return 0;
  421. }
  422. if( $address != '' ) {
  423. // ???????????
  424. if( is_numeric( $address ) ) {
  425. echo '<p class="error">' . '???????????????' . '</p>';
  426. return 0;
  427. }
  428. if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE address='$address' AND id<>$article_id") ) {
  429. echo '<p class="error">' . '??????????' . '</p>';
  430. return 0;
  431. }
  432. $file_path = APP_CACHE . $address . '.html';
  433. @file_put_contents( $file_path, ' ' );
  434. if( file_exists( $file_path ) ) {
  435. unlink( $file_path );
  436. }else{
  437. echo '<p class="error">' . '???????????' . $file_path . '</p>';
  438. return 0;
  439. }
  440. unset( $file_path );
  441. }
  442. // ?????
  443. $category_old = $db->result( "SELECT category FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
  444. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum - 1 WHERE cid = $category_old");
  445. // ?????
  446. $category = $request->get('article_category','P');
  447. $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum + 1 WHERE cid = $category");
  448. $cache->refresh( 'category', TRUE );
  449. $type = $request->get('article_type','P');
  450. $trackback = $request->get('article_trackback','P');
  451. // ?????
  452. $tags_old = $db->result( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
  453. $tags_old = str_replace( '*}{*',',',$tags_old);
  454. $tags_old = str_replace( '*}','',$tags_old);
  455. $tags_old = str_replace( '{*','',$tags_old);
  456. $tags_old = explode( ',' ,$tags_old );
  457. foreach( $tags_old as $i_tag ){
  458. if( $i_tag != '' ){
  459. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num - 1 WHERE t_id = $i_tag" );
  460. }
  461. }
  462. // ?????
  463. $temp = explode( ',' , $request->get('article_tag','P') );
  464. $temp = array_unique( $temp );
  465. $tag = '';
  466. $find = false;
  467. $tag_list = $db->fetch_all( 'SELECT * FROM `' . DB_PREFIX . 'tags` ORDER BY t_id Asc' );
  468. foreach( $temp as $itag ){
  469. if( $itag != '' ){
  470. foreach( $tag_list as $tag_arr ){
  471. if( $tag_arr['t_name'] == $itag ){
  472. $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num + 1 WHERE t_name = '$itag'");
  473. $tag .= '{*' . $tag_arr['t_id'] . '*}';
  474. $find = true;
  475. break;
  476. }
  477. }
  478. if( $find == false ){
  479. $db->query( "INSERT INTO `" . DB_PREFIX . "tags` (`t_name`,`t_num`) VALUES ('$itag',1)" );
  480. $tag .= '{*' . $db->insert_id() . '*}';
  481. }else{
  482. $find = false;
  483. }
  484. }
  485. }
  486. $cache->refresh( 'tag', TRUE );
  487. if( !isset( $_SESSION['upfile'] ) ) $_SESSION['upfile'] = '';
  488. $upfile = $db->result( "SELECT attachment FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
  489. $upfile .= $_SESSION['upfile'];
  490. $db->query( "UPDATE `" . DB_PREFIX . "article` SET title='{$title}' ,keywords='{$keywords}' ,description='{$description}' ,category={$category} ,tag='{$tag}' ,summary='{$summary}' ,content='{$content}' ,address='{$address}' ,type='{$type}' ,attachment='{$upfile}' WHERE id={$article_id}" );
  491. unset($_SESSION['upfile']);
  492. return $article_id;
  493. }
  494. private function show( $action ) {
  495. @header("content-type: text/html; charset=utf-8");
  496. ?>
  497. <div class="admin_panel">
  498. <?php
  499. switch( $action ) {
  500. case 'list':
  501. $this->article_list();
  502. break;
  503. case 'page':
  504. $this->page_control();
  505. break;
  506. case 'datacheck':
  507. $this->data_check();
  508. break;
  509. default:
  510. $this->main();
  511. }
  512. ?>
  513. </div>
  514. <?php
  515. }
  516. private function article_add( $action = '' ) {
  517. global $cache;
  518. if( $action == 'edit' ) {
  519. global $db,$request;
  520. $article = $db->fetch_one_array( 'SELECT * FROM `' . DB_PREFIX . 'article` WHERE id=' . $request->id );
  521. $article['trackback'] = '';//$db->result( 'SELECT tb_url FROM `' . DB_PREFIX . 'trackback` WHERE tb_type = 0 AND tb_article_id=' . $id );
  522. // ????
  523. $article['attachment'] = str_replace( '*}{*',',',$article['attachment']);
  524. $article['attachment'] = str_replace( '*}','',$article['attachment']);
  525. $article['attachment'] = str_replace( '{*','',$article['attachment']);
  526. $temp = array();
  527. $temp = split( ',' , $article['attachment'] );
  528. $article['attachment'] = '';
  529. $blog_path = str_replace( ' ','%20',APP_PATH );
  530. foreach($temp as $row){
  531. if( !is_numeric( $row ) ) continue;
  532. $file_info = $db->fetch_one_array( "SELECT ul_filetype,ul_filepath FROM `" . DB_PREFIX . "upload` WHERE ul_id=$row" );
  533. if ( stristr( $file_info['ul_filetype'],'image' ) ) {
  534. $ubb = '<img src=' . $blog_path . $file_info['ul_filepath'] . ' />';
  535. $ubb2 = '<img src=' . $blog_path . 'include/attachment.php?id=' . $row . ' />';
  536. } else {
  537. $ubb = '<span class=download><a href=' . $blog_path . $file_info['ul_filepath'] . ' target=_blank>??????</a></span>';
  538. $ubb2 = '<span class=download><a href=' . $blog_path . 'include/attachment.php?id=' . $row . ' target=_blank>??????</a></span>';
  539. }
  540. $article['attachment'] .= '<li><a href="javascript:;" onclick="to_editor(\''.$ubb2.'\')" title="??????">[?????]</a> <a href="#" onclick="to_editor(\''.$ubb.'\')" title="??????">[????]</a> ' . $file_info['ul_filepath'] . '</li>';
  541. }
  542. $article['attachment'] = '<ol>' . $article['attachment'] . '</ol>';
  543. // ????
  544. $article['tag'] = str_replace( '*}{*',',',$article['tag']);
  545. $article['tag'] = str_replace( '*}','',$article['tag']);
  546. $article['tag'] = str_replace( '{*','',$article['tag']);
  547. $temp = array();
  548. $temp = split( ',' , $article['tag']);
  549. $article['tag'] = '';
  550. foreach($temp as $row){
  551. if( isset( $cache->tag[$row]['t_name'] ) ){
  552. $article['tag'] .= '{*' . $cache->tag[$row]['t_name'] . '*}';
  553. }
  554. }
  555. $article['tag'] = str_replace( '*}{*',',',$article['tag']);
  556. $article['tag'] = str_replace( '*}','',$article['tag']);
  557. $article['tag'] = str_replace( '{*','',$article['tag']);
  558. } else {
  559. $article = array();
  560. $temp = array('title','content','summary','category','tag','trackback','address','keywords','description');
  561. foreach ( $temp as $value ) {
  562. $article[$value] = '';
  563. }
  564. $article['trackback'] = '???????';
  565. }
  566. // $article['p'], $article['extra'] );
  567. ?>
  568. <style>
  569. .input_submit { border:1px solid #a3a3a3; background-color: #e7e7e7; padding: 5px; width: 100px; font-weight:bold; }
  570. .admin_content { margin:0px; padding:0px; margin-top:5px; }
  571. .admin_content .input_text { border: 1px solid #c8c8c8; padding: 5px; width: 235px; font-size: 14px; }
  572. .admin_title .tit_right { float: right; font-size: 12px; font-weight:normal; padding-top:2px; }
  573. .admin_content select { border:1px solid #c8c8c8; padding: 5px; width: 245px; font-size: 14px; }
  574. .admin_content .input_radio { margin:5px; }
  575. .admin_title { cursor:pointer; }
  576. </style>
  577. <script type="text/javascript">
  578. KE.init({
  579. id : 'article_content',
  580. resizeMode : 1,
  581. width : '668px',
  582. allowFileManager : true,
  583. newlineTag : 'p'
  584. });
  585. KE.init({
  586. id : 'article_summary',
  587. resizeMode : 1,
  588. width : '668px',
  589. allowFileManager : true,
  590. newlineTag : 'p'
  591. });
  592. var flag_content=false,flag_summary=false;
  593. </script>
  594. <form method="post" action="index.php?m=article&p=<?php if( $action == 'edit' ) { echo 'saveedit&id=' . $request->id; } else { echo 'saveadd'; }?>" id="ajax_form">
  595. <div style="float:left;width:680px;">
  596. <div class="admin_panel" onclick="if(!flag_content){flag_content=true;KE.create('article_content');KE.util.focus('article_content');}">
  597. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_content')">????<div class="tit_right"></div></div>
  598. <div class="admin_content">
  599. <div id="div_article_content">
  600. <textarea id="article_content" name="article_content" style="width:665px;height:400px;border:1px solid #c8c8c8;"><?php echo $article['content'] ?></textarea>
  601. </div>
  602. </div>
  603. </div>
  604. <div class="admin_panel" onclick="if(!flag_summary){flag_summary=true;KE.create('article_summary');KE.util.focus('article_content');}">
  605. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_summary')">????<div class="tit_right"></div></div>
  606. <div class="admin_content">
  607. <div id="div_article_summary" style="display:none;">
  608. <textarea id="article_summary" name="article_summary" style="width:665px;height:200px;border:1px solid #c8c8c8;"><?php echo $article['summary'] ?></textarea>
  609. </div>
  610. </div>
  611. </div>
  612. <?php if( $action == 'edit' ) { ?>
  613. <div class="admin_panel" onmouseover="if(!flag_summary){flag_summary=true;KE.create('article_summary');KE.util.focus('article_content');}">
  614. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_upfile')">????<div class="tit_right"></div></div>
  615. <div class="admin_content">
  616. <div id="div_article_upfile" style="text-align:left;">
  617. <?php echo $article['attachment'] ?>
  618. </div>
  619. </div>
  620. <script>
  621. function to_editor(id, html){
  622. KE.util.focus(id);
  623. KE.util.selection(id);
  624. KE.util.insertHtml(id, html);
  625. }
  626. </script>
  627. </div>
  628. <?php } ?>
  629. <div class="admin_panel">
  630. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_upload')">????<div class="tit_right"></div></div>
  631. <div class="admin_content">
  632. <div id="div_article_upload" style="display:none;">
  633. <iframe frameborder="0" src="../include/upload.php" width="600" height="110"></iframe>
  634. </div>
  635. </div>
  636. </div>
  637. </div>
  638. <div style="float:right;width:260px;">
  639. <div class="admin_panel">
  640. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_submit')">??<div class="tit_right"></div></div>
  641. <div class="admin_content">
  642. <div id="div_article_submit" style="padding:10px;">
  643. <input type="submit" onclick="KE.util.setData('article_content');KE.util.setData('article_summary');" value=" ? ? " class="input_submit" />
  644. </div>
  645. </div>
  646. </div>
  647. <div class="admin_panel">
  648. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_title')">??<div class="tit_right"></div></div>
  649. <div class="admin_content">
  650. <div id="div_article_title">
  651. <input name="article_title" type="text" id="article_title" size="40" class="input_text" value="<?php echo $article['title'] ?>"/>
  652. </div>
  653. </div>
  654. </div>
  655. <div class="admin_panel">
  656. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_category')">??<div class="tit_right"></div></div>
  657. <div class="admin_content">
  658. <div id="div_article_category">
  659. <select name="article_category" id="article_category">
  660. <?php
  661. global $cache;
  662. foreach ( $cache->category as $value ) {
  663. if( $article['category'] == $value['cid'] ){
  664. echo '<option value="' . $value['cid'] . '" selected="selected">' . $value['name'] . '</option>';
  665. }else{
  666. echo '<option value="' . $value['cid'] . '">' . $value['name'] . '</option>';
  667. }
  668. }
  669. ?>
  670. </select>
  671. </div>
  672. </div>
  673. </div>
  674. <div class="admin_panel">
  675. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_tag')">??<div class="tit_right">???????“,”??</div></div>
  676. <div class="admin_content">
  677. <div id="div_article_tag">
  678. <input name="article_tag" type="text" id="article_tag" size="40" class="input_text" value="<?php echo $article['tag'] ?>" />
  679. </div>
  680. </div>
  681. </div>
  682. <div class="admin_panel">
  683. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_alias')">??<div class="tit_right">???????“-”??????</div></div>
  684. <div class="admin_content">
  685. <div id="div_article_alias" style="display:none;">
  686. <input name="article_alias" type="text" id="article_alias" size="40" class="input_text" value="<?php echo $article['address'] ?>"/>
  687. </div>
  688. </div>
  689. </div>
  690. <div class="admin_panel">
  691. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_meta')">??<div class="tit_right">??? SEO</div></div>
  692. <div class="admin_content">
  693. <div id="div_article_meta" style="display:none;">
  694. <p style="padding-bottom:5px;text-align:left;">????</p>
  695. <input name="article_keywords" type="text" id="article_keywords" size="40" class="input_text" value="<?php echo $article['keywords'] ?>" />
  696. <p style="padding-bottom:5px;padding-top:5px;text-align:left;">???</p>
  697. <textarea name="article_description" type="text" id="article_description" style="padding:5px;width:235px;height:100px;font-size: 14px;border:1px solid #c8c8c8;"><?php echo $article['description'] ?></textarea>
  698. </div>
  699. </div>
  700. </div>
  701. <div class="admin_panel">
  702. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_type')">??<div class="tit_right"></div></div>
  703. <div class="admin_content">
  704. <div id="div_article_type" style="display:none;">
  705. <input type="radio" value="??" name="article_type" checked="checked" class="input_radio" />??&nbsp;&nbsp;
  706. <input type="radio" value="??" name="article_type" class="input_radio" />??&nbsp;&nbsp;
  707. <input type="radio" value="??" name="article_type" class="input_radio" />??
  708. </div>
  709. </div>
  710. </div>
  711. <div class="admin_panel">
  712. <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_trackback')">????<div class="tit_right"></div></div>
  713. <div class="admin_content">
  714. <div id="div_article_trackback" style="display:none;">
  715. <input name="article_trackback" type="text" id="article_trackback" size="40" class="input_text" value="<?php echo $article['trackback'] ?>" />
  716. </div>
  717. </div>
  718. </div>
  719. </div>
  720. <div class="fixed"></div>
  721. </form>
  722. <script>
  723. $(document).ready(function(){
  724. $('#ajax_form').ajaxForm(function(data){
  725. showMessage(data);
  726. $("#admin_loading").css('visibility','hidden');
  727. });
  728. });
  729. </script>
  730. <?php
  731. }
  732. private function article_list() {
  733. global $db,$cache,$request;
  734. $current_page = max( 1, $request->page );
  735. $max_per_page = 20;
  736. $offset = ($current_page - 1) * $max_per_page;
  737. $article_num = $cache->count['article_num'];
  738. $sql = "SELECT id,author,title,time,istop,isdel,category,`read`,comment,`type` FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND `type`<3 ORDER BY istop DESC, id DESC LIMIT $offset, $max_per_page";
  739. $article_array = $db->fetch_all( $sql );
  740. ?>
  741. <div class="admin_title"><?php echo L('_ARTICLE_LIST_'); ?></div>
  742. <div class="admin_content">
  743. <form name="smslist" action="admin_article.php?action=batch" method="post">
  744. <div style="padding:5px;margin:2px;">
  745. <table class="pickme" style="table-layout: fixed;word-wrap: break-word;" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#bbbbbb">
  746. <thead>
  747. <tr align="center" height="22" bgcolor="#ffffff">
  748. <td width="3%"><input type="checkbox" name="allbox" onclick="CheckAll();"><input type="checkbox" id="ckbox" style="display:none;" disabled></td>
  749. <td width="4%"><?php echo L('_NUM_'); ?></td>
  750. <td width="10%"><?php echo L('_AUTHOR_'); ?></td>
  751. <td width="32%"><?php echo L('_TITLE_'); ?></td>
  752. <td width="6%"><?php echo L('_TYPE_'); ?></td>
  753. <td width="14%"><?php echo L('_CATEGORY_'); ?></td>
  754. <td width="7%"><?php echo L('_READ_'); ?></td>
  755. <td width="7%"><?php echo L('_COMMENT_'); ?></td>
  756. <td width="11%"><?php echo L('_TIME_'); ?></td>
  757. <td width="6%"><?php echo L('_OPERATION_'); ?></td>
  758. </tr>
  759. </thead>
  760. <tbody>
  761. <?php
  762. $i = 1;
  763. foreach( $article_array as $value ) {
  764. ?>
  765. <tr align="center" height="20" bgcolor="#ffffff">
  766. <td ><input type="checkbox" id="ckbox" name="id_arr[]" value="<?php echo $value['id'] ?>" /></td>
  767. <td><?php echo ( $current_page - 1 ) * $max_per_page + $i ?></td>
  768. <td><?php echo $value['author'] ?></td>
  769. <td style="text-align:left;padding-left:3px;"><?php if( $value['istop'] ) { echo '<span class="top_article">[??]</span>' . cut_str( $value['title'],40 ); }else{ echo cut_str( $value['title'],40 ); } ?></td>
  770. <td>
  771. <?php
  772. if( $value['type'] == 0 ) {
  773. echo '??';
  774. } elseif( $value['type'] == 1 ) {
  775. echo '??';
  776. } elseif( $value['type'] == 3 ) {
  777. echo '??';
  778. } else {
  779. echo 'Unknown';
  780. }
  781. ?></td>
  782. <td><?php echo $cache->category[$value['category']]['name'] ?></td>
  783. <td><?php echo $value['read'] ?></td>
  784. <td><?php echo $value['comment'] ?></td>
  785. <td><?php echo date( 'Y-m-d', $value['time'] ) ?></td>
  786. <td>
  787. <span class="Control">
  788. <a href="#" onclick="ajax_load('<?php echo ADMIN_PATH ?>','article','edit',null,'<?php echo $value['id'] ?>');return false;"><?php echo L('_EDIT_'); ?></a>
  789. </span>
  790. </td>
  791. </tr>
  792. <?php
  793. $i ++;
  794. }
  795. ?>
  796. </tbody>
  797. </table>
  798. </div>
  799. <?php echo Admin::get_navigator( $article_num, $max_per_page, $current_page, 'article', 'list' ); ?>
  800. <div align="center" style="margin-top:10px;">
  801. <?php echo L('_BATCH_ADMIN_'); ?>:
  802. <input type="radio" name="Control" value="??" checked="checked"/><?php echo L('_DELETE_'); ?>
  803. <input type="radio" name="Control" value="??" /><?php echo L('_MOVE_'); ?>
  804. <select name="article_category" id="article_category">
  805. <?php
  806. foreach ( $cache->category as $value ) {
  807. echo '<option value="' . $value['cid'] . '">' . $value['name'] . '</option>';
  808. }
  809. ?>
  810. </select>
  811. <input type="radio" name="Control" value="??" /><?php echo L('_CHANGE_'); ?>
  812. <select name="article_type" id="article_type">
  813. <option value="??">??</option>
  814. <option value="??">??</option>
  815. <option value="??">??</option>
  816. </select>
  817. <input type="submit" class="main_button" value=" <?php echo L('_TAKE_OPERATION_'); ?> " />
  818. </div>
  819. </form>
  820. <div class="main_button"></div>
  821. </div>
  822. <?php
  823. }
  824. private function page_control() {
  825. ?>
  826. <div class="admin_title"><?php echo L('_HTML_MANAGEMENT_'); ?></div>
  827. <div class="admin_content">
  828. <div style="padding:10px;">
  829. <a href="admin_article.php?action=MakearticlePage"><?php echo L('_REBUILD_HTML_'); ?></a>
  830. </div>
  831. </div>
  832. <?php
  833. }
  834. private function data_check() {
  835. ?>
  836. <div class="admin_title"><?php echo L('_DATA_CHECK_'); ?></div>
  837. <div class="admin_content">
  838. <div style="padding:10px;">
  839. <a href="index.php?m=article&p=datacheckexe"><?php echo L('_COMMENT_DATA_CHECK_'); ?></a><br />
  840. <a href="index.php?m=article&p=tagdatacheckexe"><?php echo L('_TAG_DATA_CHECK_'); ?></a>
  841. </div>
  842. </div>
  843. <?php
  844. }
  845. private function main() {
  846. ?>
  847. <div class="admin_title"><?php echo L('_CONTENT_MANAGEMENT_'); ?></div>
  848. <div class="admin_content">
  849. <div style="padding:10px;">
  850. <?php echo L('_UNDEFINED_ACTION_'); ?>
  851. </div>
  852. </div>
  853. <?php
  854. }
  855. }
  856. ?>