/admin/kernel/article.class.php
PHP | 904 lines | 812 code | 48 blank | 44 comment | 103 complexity | 355cd64e57018694769a35fec4d19859 MD5 | raw file
Possible License(s): AGPL-1.0
- <?php
- !defined('IN_NOVA') && exit('Access Denied!');
- class Article {
- public function start() {
- global $db,$cache,$request;
- $action = $request->get( 'p' );
- $id = $request->id;
- switch( $action ) {
- case 'add':
- $this->article_add();
- break;
- case 'edit':
- $this->article_add( 'edit' );
- break;
- case 'saveadd':
- // ??????
- $article_id = $this->add();
- if( $article_id == 0 ) {
- break;
- }
- //$article_type = $request->get( 'article_type', 'P' );
- if( $cache->config['arttype'] == '??' ){
- page_make( $article_id, $article_type );
- }
- $cache->refresh( 'count', TRUE );
- $cache->refresh( 'article_new', TRUE );
- $cache->refresh( 'article_list', TRUE );
- echo '<p class="warning">' . L('_ADD_ARTICLE_SUCCESS_') . '</p>';
- break;
- case 'saveedit':
- // ??????
- if( $this->edit( $id ) == 0 ) {
- break;
- }
- $article_type = $request->get('article_type','P');
- if( $cache->config['arttype'] == '??' ){
- page_make( $article_id, $article_type );
- }
- $cache->refresh( 'article_hot', TRUE );
- $cache->refresh( 'article_new', TRUE );
- $cache->refresh( 'article_list', TRUE );
- echo '<p class="warning">' . L('_EDIT_ARTICLE_SUCCESS_') . '</p>';
- break;
- case 'top':
- // ??????
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET istop = 1 WHERE id=$id" );
- // ????
- $cache->refresh( 'article_list', TRUE );
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'topcancel':
- // ????????
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET istop = 0 WHERE id=$id" );
- // ????
- $cache->refresh( 'article_list', TRUE );
- echo '<p class="warning">' . '????????' . '</p>';
- break;
- case 'reflash':
- // ??????
- /*page_make_html( $id );
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=$id" );*/
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'del':
- // ??????
- $category = $db->result( "SELECT category FROM `" . DB_PREFIX . "article` WHERE id=$id AND isdel = 0" );
- if( $category == '' ) {
- $theme->show_message( '??????' );
- break;
- }
- // ??????
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum - 1 WHERE cid=$category" );
- // ????????
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel = 1 WHERE articleid=$id" );
- // ??????
- $tags = $db->result( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE id=$id" );
- $tags = str_replace( '*}{*',',',$tags );
- $tags = str_replace( '*}','',$tags );
- $tags = str_replace( '{*','',$tags );
- $tags = split( ',' , $tags );
- foreach($tags as $tag){
- if( $tag != '' ){
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num-1 WHERE t_id=$tag" );
- }
- }
- // ????
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET isdel = 1 WHERE id=$id" );
- // ????
- $cache->article_new = NULL;
- $cache->article_hot = NULL;
- $cache->comment_new = NULL;
- $cache->category = NULL;
- $cache->count = NULL;
- $cache->tag = NULL;
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'addreply':
- // ??????
- $reply = htmlspecialchars( $request->get('commentreply','P') );
- $reply = str_replace( array("\r\n", "\n", "\r"), '<br />', $reply );
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET replyuser = '" . $_SESSION['user_name'] . "',reply = '$reply',replytime = " . PHP_TIME . " WHERE cid = $id" );
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'delreply':
- // ??????
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET replyuser = NULL WHERE cid = $id" );
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'delcomment':
- // ??????
- $aid = $db->result( "SELECT articleid FROM `" . DB_PREFIX . "comment` WHERE cid=$id AND isdel = 0" );
- if( $aid == '' ) {
- echo '<p class="error">' . '??????' . '</p>';
- break;
- }
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET comment=comment-1 WHERE id=$aid" );
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel=1 WHERE cid=$id" );
- $cache->article_hot = NULL;
- $cache->comment_new = NULL;
- $cache->guestbook_new = NULL;
- $cache->count = NULL;
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'censor':
- // ??????
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isshow = 1 WHERE cid = $id" );
- $cache->comment_new = NULL;
- $cache->guestbook_new = NULL;
- echo '<p class="warning">' . '??????' . '</p>';
- break;
- case 'MakearticlePage':
- $this->make_article_page();
- break;
- case 'datacheckexe':
- $this->data_check_exe();
- break;
- case 'tagdatacheckexe':
- $this->tag_data_check_exe();
- break;
- case 'batch':
- $this->batch();
- break;
- default:
- $this->show( $action );
- }
- }
- private function make_article_page() {
- global $db,$_CACHE;
- $_CACHE['count'][0]['online'] = cache_online();
- if( count( $_CACHE['category'] ) == 0 ) {
- show_admin_message( '??????', 'admin_article.php' );
- exit;
- }else{
- foreach( $_CACHE['category'] as $category ) {
- $file_path = XKLOG_ROOT . 'article/' . $category['alias'] . '/';
- if ( !is_dir( $file_path ) ) {
- @mkdir( $file_path, 0777 );
- }
- $article_arr = array();
- $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=" . $category['cid'] . " AND type='??' ORDER BY id DESC" );
- foreach( $article_arr as $article ) {
- page_make_html( $article['id'] );
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=" . $article['id'] );
- }
- }
- }
- show_admin_message( '???????????', 'admin_article.php' );
- exit;
- }
- private function data_check_exe() {
- global $db,$cache;
- $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article`" );
- if( count( $article_arr ) == 0 ) {
- $this->show( 'datacheck', '???????????', 'error' );
- return;
- }
- foreach( $article_arr as $article ) {
- $temp = $db->result( "SELECT COUNT(cid) FROM `" . DB_PREFIX . "comment` WHERE isdel=0 AND articleid=" . $article['id'] );
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET comment=" . $temp . " WHERE id=" . $article['id'] );
- }
- $cache->refresh( 'article_hot', TRUE );
- $this->show( 'datacheck', '????????????', 'warning' );
- }
- private function tag_data_check_exe() {
- global $db,$cache;
- $article_arr = $db->fetch_all( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE isdel=0" );
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=0" );
- $tag_arr = $db->fetch_all( "SELECT t_id,t_name FROM `" . DB_PREFIX . "tags`" );
- if( count( $article_arr ) == 0 ) {
- $this->show( 'datacheck', '???????????', 'error' );
- return;
- }
- foreach( $article_arr as $article ) {
- $article['tag'] = str_replace( '*}{*',',',$article['tag'] );
- $article['tag'] = substr( $article['tag'],2 );
- $article['tag'] = substr( $article['tag'],0,-2 );
- $article['tag'] = explode( ',' , $article['tag'] );
- foreach( $article['tag'] as $tag ) {
- foreach( $tag_arr as $tag_old ) {
- if( $tag == $tag_old['t_id'] ) {
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num+1 WHERE t_id=" . $tag_old['t_id'] );
- break;
- }
- }
- }
- }
- if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=1" ) != 0 ) {
- $this->show( 'datacheck', '??????????????????? 0 ????????????????', 'warning' );
- }else{
- $db->query( "DELETE FROM `" . DB_PREFIX . "tags` WHERE t_num=0" );
- $this->show( 'datacheck', '??????????', 'warning' );
- }
- $cache->refresh( 'tag', TRUE );
- }
- private function batch() {
- global $cache,$db;
- $control = getGP( 'Control','P' );
- $id_arr = array();
- $id_arr = getGP( 'id_arr','P','array' );
- $size = count( $id_arr );
- if( $size == 0 ) {
- echo '<p class="error">' . '?????????' . '</p>';
- return;
- }
- $sql = '';
- for( $i=0; $i<$size; $i ++ ){
- $sql .= 'id=' . $id_arr[$i] . ' OR ';
- }
- $sql = substr( $sql,0,-4 );
- if( $control == '??' ) {
- // ????
- $db->query( 'UPDATE `' . DB_PREFIX . 'article` SET isdel=1 WHERE (' . $sql . ')' );
- // ??????
- $tag_arr = $db->fetch_all( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE ( $sql )" );
- foreach( $tag_arr as $tags ) {
- $tags['tag'] = str_replace( '*}{*',',',$tags['tag'] );
- $tags['tag'] = str_replace( '*}','',$tags['tag'] );
- $tags['tag'] = str_replace( '{*','',$tags['tag'] );
- $tags['tag'] = split( ',' , $tags['tag'] );
- foreach($tags['tag'] as $tag){
- if( $tag != '' ){
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num=t_num-1 WHERE t_id=$tag" );
- }
- }
- }
- // ??????
- $id_arr = str_replace( 'id=','',$sql );
- $id_arr = split( ' OR ',$id_arr );
- $size = count( $id_arr );
- $sql = '';
- for( $i=0; $i<$size; $i ++ ){
- $sql .= 'articleid=' . $id_arr[$i] . ' OR ';
- }
- $sql = substr( $sql,0,-4 );
- $db->query( "UPDATE `" . DB_PREFIX . "comment` SET isdel = 1 WHERE ( $sql )" );
- // ????????
- foreach( $_CACHE['category'] as $category ) {
- $cid = $category['cid'];
- $article_num = $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=$cid" );
- if( $category['articlenum'] != $article_num ) {
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum=$article_num WHERE cid=$cid" );
- }
- }
- // ????
- cache_article_hot();
- cache_article_new();
- cache_comment_new();
- cache_category();
- cache_count();
- cache_tag();
- show_admin_message( '????????', 'admin_article.php?action=article' );
- }elseif( $control == '??' ) {
- $category = getGP( 'article_category','P','int' );
- $sql = 'UPDATE `' . DB_PREFIX . 'article` SET category=' . $category . ' WHERE (' . $sql . ')';
- $db->query( $sql );
- // ????????
- foreach( $_CACHE['category'] as $category ) {
- $cid = $category['cid'];
- $article_num = $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE isdel=0 AND category=$cid" );
- if( $category['articlenum'] != $article_num ) {
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum=$article_num WHERE cid=$cid" );
- }
- }
- // ????
- cache_article_hot();
- cache_article_new();
- cache_category();
- show_admin_message( '?????????????????????', 'admin_article.php?action=article' );
- }elseif( $control == '??' ) {
- $type = getGP( 'article_type','P' );
- $sql2 = "UPDATE `" . DB_PREFIX . "article` SET type='$type' WHERE ( $sql )";
- $db->query( $sql2 );
- // ???????????
- if( $type != '??' ) {
- $_CACHE['count'][0]['online'] = cache_online();
- foreach( $_CACHE['category'] as $category ) {
- $file_path = XKLOG_ROOT . 'article/' . $category['alias'] . '/';
- if ( !is_dir( $file_path ) ) {
- @mkdir( $file_path, 0777 );
- }
- $article_arr = array();
- $article_arr = $db->fetch_all( "SELECT id FROM `" . DB_PREFIX . "article` WHERE ( $sql )" );
- foreach( $article_arr as $article ) {
- page_make( $article['id'], $type );
- $db->query( "UPDATE `" . DB_PREFIX . "article` SET `update`=0 WHERE id=" . $article['id'] );
- }
- }
- }
- // ????
- cache_article_hot();
- cache_article_new();
- show_admin_message( '????????', 'admin_article.php?action=article' );
- }else{
- show_admin_message( '?????', 'admin_article.php' );
- }
- }
- // ??????
- private function add(){
- global $cache,$db,$request;
- $title = $request->get('article_title','P');
- $keywords = $request->get('article_keywords','P');
- $description = $request->get('article_description','P');
- $content = $request->get('article_content','P');
- $summary = $request->get('article_summary','P');
- $address = $request->get('article_alias','P');
- $type = $request->get('article_type','P');
- if( trim( $title ) == '' || trim( $content ) == '' ){
- echo '<p class="error">' . '??????????????' . '</p>';
- return 0;
- }
- if( strlen( $content ) > $cache->config['artmaxlength'] ){
- echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
- return 0;
- }
- if( strlen( $summary ) > $cache->config['artmaxlength'] ){
- echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
- return 0;
- }
- // ???????????
- // ?????????????????????? is_numeric ???????????
- if( $address != '' ) {
- if( is_numeric( $address ) ) {
- echo '<p class="error">' . '???????????????' . '</p>';
- return 0;
- }
- if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE address='$address'") ) {
- echo '<p class="error">' . '????????????' . '</p>';
- return 0;
- }
- $file_path = APP_CACHE . $address . '.html';
- @file_put_contents( $file_path, ' ' );
- if( file_exists( $file_path ) ) {
- unlink( $file_path );
- }else{
- echo '<p class="error">' . '???????????' . '</p>';
- return 0;
- }
- unset( $file_path );
- }
- // ????
- $category = $request->get('article_category','P');
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum + 1 WHERE cid = '$category'");
- $cache->refresh( 'category', TRUE );
- $type = $request->get('article_type','P');
- $trackback = $request->get('article_trackback','P');
- // ????
- $temp = explode( ',' , $request->get('article_tag','P') );
- $temp = array_unique( $temp );
- $tag = '';
- $find = false;
- foreach( $temp as $itag ){
- if( $itag != '' ){
- foreach( $cache->tag as $tag_id => $tag_arr ){
- if( $tag_arr['t_name'] == $itag ){
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num + 1 WHERE t_name = '$itag'");
- $tag .= '{*' . $tag_id . '*}';
- $find = true;
- break;
- }
- }
- if( $find == false ){
- $db->query( "INSERT INTO `" . DB_PREFIX . "tags` (`t_name`,`t_num`) VALUES ('$itag',1)" );
- $tag .= '{*' . $db->insert_id() . '*}';
- }else{
- $find = false;
- }
- }
- }
- $cache->refresh( 'tag', TRUE );
- if( !isset( $_SESSION['upfile'] ) ) $_SESSION['upfile'] = '';
- $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'] . "')" );
- unset($_SESSION['upfile']);
- return $db->insert_id();
- }
- // ??????
- private function edit( $article_id ){
- global $cache,$db,$request;
- $title = $request->get('article_title','P');
- $keywords = $request->get('article_keywords','P');
- $description = $request->get('article_description','P');
- $content = $request->get('article_content','P');
- $summary = $request->get('article_summary','P');
- $address = trim( $request->get('article_alias','P') );
- $type = $request->get('article_type','P');
- if( trim( $title ) == '' || trim( $content ) == '' ){
- echo '<p class="error">' . '??????????????' . '</p>';
- return 0;
- }
- if( strlen( $content ) > $cache->config['artmaxlength'] ){
- echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
- return 0;
- }
- if( strlen( $summary ) > $cache->config['artmaxlength'] ){
- echo '<p class="error">' . '??????????? ' . $cache->config['artmaxlength'] . ' ???' . '</p>';
- return 0;
- }
- // ????????
- if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE id={$article_id} AND isdel=0 AND type<3" ) == 0 ){
- echo '<p class="error">' . '?????????????' . '</p>';
- return 0;
- }
- if( $address != '' ) {
- // ???????????
- if( is_numeric( $address ) ) {
- echo '<p class="error">' . '???????????????' . '</p>';
- return 0;
- }
- if( $db->result( "SELECT COUNT(id) FROM `" . DB_PREFIX . "article` WHERE address='$address' AND id<>$article_id") ) {
- echo '<p class="error">' . '??????????' . '</p>';
- return 0;
- }
- $file_path = APP_CACHE . $address . '.html';
- @file_put_contents( $file_path, ' ' );
- if( file_exists( $file_path ) ) {
- unlink( $file_path );
- }else{
- echo '<p class="error">' . '???????????' . $file_path . '</p>';
- return 0;
- }
- unset( $file_path );
- }
- // ?????
- $category_old = $db->result( "SELECT category FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum - 1 WHERE cid = $category_old");
- // ?????
- $category = $request->get('article_category','P');
- $db->query( "UPDATE `" . DB_PREFIX . "category` SET articlenum = articlenum + 1 WHERE cid = $category");
- $cache->refresh( 'category', TRUE );
- $type = $request->get('article_type','P');
- $trackback = $request->get('article_trackback','P');
- // ?????
- $tags_old = $db->result( "SELECT tag FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
- $tags_old = str_replace( '*}{*',',',$tags_old);
- $tags_old = str_replace( '*}','',$tags_old);
- $tags_old = str_replace( '{*','',$tags_old);
- $tags_old = explode( ',' ,$tags_old );
- foreach( $tags_old as $i_tag ){
- if( $i_tag != '' ){
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num - 1 WHERE t_id = $i_tag" );
- }
- }
- // ?????
- $temp = explode( ',' , $request->get('article_tag','P') );
- $temp = array_unique( $temp );
- $tag = '';
- $find = false;
- $tag_list = $db->fetch_all( 'SELECT * FROM `' . DB_PREFIX . 'tags` ORDER BY t_id Asc' );
- foreach( $temp as $itag ){
- if( $itag != '' ){
- foreach( $tag_list as $tag_arr ){
- if( $tag_arr['t_name'] == $itag ){
- $db->query( "UPDATE `" . DB_PREFIX . "tags` SET t_num = t_num + 1 WHERE t_name = '$itag'");
- $tag .= '{*' . $tag_arr['t_id'] . '*}';
- $find = true;
- break;
- }
- }
- if( $find == false ){
- $db->query( "INSERT INTO `" . DB_PREFIX . "tags` (`t_name`,`t_num`) VALUES ('$itag',1)" );
- $tag .= '{*' . $db->insert_id() . '*}';
- }else{
- $find = false;
- }
- }
- }
- $cache->refresh( 'tag', TRUE );
- if( !isset( $_SESSION['upfile'] ) ) $_SESSION['upfile'] = '';
- $upfile = $db->result( "SELECT attachment FROM `" . DB_PREFIX . "article` WHERE id = $article_id" );
- $upfile .= $_SESSION['upfile'];
- $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}" );
- unset($_SESSION['upfile']);
- return $article_id;
- }
- private function show( $action ) {
- @header("content-type: text/html; charset=utf-8");
- ?>
- <div class="admin_panel">
- <?php
- switch( $action ) {
- case 'list':
- $this->article_list();
- break;
- case 'page':
- $this->page_control();
- break;
- case 'datacheck':
- $this->data_check();
- break;
- default:
- $this->main();
- }
- ?>
- </div>
- <?php
- }
- private function article_add( $action = '' ) {
- global $cache;
- if( $action == 'edit' ) {
- global $db,$request;
- $article = $db->fetch_one_array( 'SELECT * FROM `' . DB_PREFIX . 'article` WHERE id=' . $request->id );
- $article['trackback'] = '';//$db->result( 'SELECT tb_url FROM `' . DB_PREFIX . 'trackback` WHERE tb_type = 0 AND tb_article_id=' . $id );
- // ????
- $article['attachment'] = str_replace( '*}{*',',',$article['attachment']);
- $article['attachment'] = str_replace( '*}','',$article['attachment']);
- $article['attachment'] = str_replace( '{*','',$article['attachment']);
- $temp = array();
- $temp = split( ',' , $article['attachment'] );
- $article['attachment'] = '';
- $blog_path = str_replace( ' ','%20',APP_PATH );
- foreach($temp as $row){
- if( !is_numeric( $row ) ) continue;
- $file_info = $db->fetch_one_array( "SELECT ul_filetype,ul_filepath FROM `" . DB_PREFIX . "upload` WHERE ul_id=$row" );
- if ( stristr( $file_info['ul_filetype'],'image' ) ) {
- $ubb = '<img src=' . $blog_path . $file_info['ul_filepath'] . ' />';
- $ubb2 = '<img src=' . $blog_path . 'include/attachment.php?id=' . $row . ' />';
- } else {
- $ubb = '<span class=download><a href=' . $blog_path . $file_info['ul_filepath'] . ' target=_blank>??????</a></span>';
- $ubb2 = '<span class=download><a href=' . $blog_path . 'include/attachment.php?id=' . $row . ' target=_blank>??????</a></span>';
- }
- $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>';
- }
- $article['attachment'] = '<ol>' . $article['attachment'] . '</ol>';
- // ????
- $article['tag'] = str_replace( '*}{*',',',$article['tag']);
- $article['tag'] = str_replace( '*}','',$article['tag']);
- $article['tag'] = str_replace( '{*','',$article['tag']);
- $temp = array();
- $temp = split( ',' , $article['tag']);
- $article['tag'] = '';
- foreach($temp as $row){
- if( isset( $cache->tag[$row]['t_name'] ) ){
- $article['tag'] .= '{*' . $cache->tag[$row]['t_name'] . '*}';
- }
- }
- $article['tag'] = str_replace( '*}{*',',',$article['tag']);
- $article['tag'] = str_replace( '*}','',$article['tag']);
- $article['tag'] = str_replace( '{*','',$article['tag']);
- } else {
- $article = array();
- $temp = array('title','content','summary','category','tag','trackback','address','keywords','description');
- foreach ( $temp as $value ) {
- $article[$value] = '';
- }
- $article['trackback'] = '???????';
- }
- // $article['p'], $article['extra'] );
- ?>
- <style>
- .input_submit { border:1px solid #a3a3a3; background-color: #e7e7e7; padding: 5px; width: 100px; font-weight:bold; }
- .admin_content { margin:0px; padding:0px; margin-top:5px; }
- .admin_content .input_text { border: 1px solid #c8c8c8; padding: 5px; width: 235px; font-size: 14px; }
- .admin_title .tit_right { float: right; font-size: 12px; font-weight:normal; padding-top:2px; }
- .admin_content select { border:1px solid #c8c8c8; padding: 5px; width: 245px; font-size: 14px; }
- .admin_content .input_radio { margin:5px; }
- .admin_title { cursor:pointer; }
- </style>
- <script type="text/javascript">
- KE.init({
- id : 'article_content',
- resizeMode : 1,
- width : '668px',
- allowFileManager : true,
- newlineTag : 'p'
- });
- KE.init({
- id : 'article_summary',
- resizeMode : 1,
- width : '668px',
- allowFileManager : true,
- newlineTag : 'p'
- });
- var flag_content=false,flag_summary=false;
- </script>
- <form method="post" action="index.php?m=article&p=<?php if( $action == 'edit' ) { echo 'saveedit&id=' . $request->id; } else { echo 'saveadd'; }?>" id="ajax_form">
- <div style="float:left;width:680px;">
- <div class="admin_panel" onclick="if(!flag_content){flag_content=true;KE.create('article_content');KE.util.focus('article_content');}">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_content')">????<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_content">
- <textarea id="article_content" name="article_content" style="width:665px;height:400px;border:1px solid #c8c8c8;"><?php echo $article['content'] ?></textarea>
- </div>
- </div>
- </div>
- <div class="admin_panel" onclick="if(!flag_summary){flag_summary=true;KE.create('article_summary');KE.util.focus('article_content');}">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_summary')">????<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_summary" style="display:none;">
- <textarea id="article_summary" name="article_summary" style="width:665px;height:200px;border:1px solid #c8c8c8;"><?php echo $article['summary'] ?></textarea>
- </div>
- </div>
- </div>
- <?php if( $action == 'edit' ) { ?>
- <div class="admin_panel" onmouseover="if(!flag_summary){flag_summary=true;KE.create('article_summary');KE.util.focus('article_content');}">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_upfile')">????<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_upfile" style="text-align:left;">
- <?php echo $article['attachment'] ?>
- </div>
- </div>
- <script>
- function to_editor(id, html){
- KE.util.focus(id);
- KE.util.selection(id);
- KE.util.insertHtml(id, html);
- }
- </script>
- </div>
- <?php } ?>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_upload')">????<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_upload" style="display:none;">
- <iframe frameborder="0" src="../include/upload.php" width="600" height="110"></iframe>
- </div>
- </div>
- </div>
- </div>
- <div style="float:right;width:260px;">
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_submit')">??<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_submit" style="padding:10px;">
- <input type="submit" onclick="KE.util.setData('article_content');KE.util.setData('article_summary');" value=" ? ? " class="input_submit" />
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_title')">??<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_title">
- <input name="article_title" type="text" id="article_title" size="40" class="input_text" value="<?php echo $article['title'] ?>"/>
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_category')">??<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_category">
- <select name="article_category" id="article_category">
- <?php
- global $cache;
- foreach ( $cache->category as $value ) {
- if( $article['category'] == $value['cid'] ){
- echo '<option value="' . $value['cid'] . '" selected="selected">' . $value['name'] . '</option>';
- }else{
- echo '<option value="' . $value['cid'] . '">' . $value['name'] . '</option>';
- }
- }
- ?>
- </select>
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_tag')">??<div class="tit_right">???????,??</div></div>
- <div class="admin_content">
- <div id="div_article_tag">
- <input name="article_tag" type="text" id="article_tag" size="40" class="input_text" value="<?php echo $article['tag'] ?>" />
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_alias')">??<div class="tit_right">???????-??????</div></div>
- <div class="admin_content">
- <div id="div_article_alias" style="display:none;">
- <input name="article_alias" type="text" id="article_alias" size="40" class="input_text" value="<?php echo $article['address'] ?>"/>
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_meta')">??<div class="tit_right">??? SEO</div></div>
- <div class="admin_content">
- <div id="div_article_meta" style="display:none;">
- <p style="padding-bottom:5px;text-align:left;">????</p>
- <input name="article_keywords" type="text" id="article_keywords" size="40" class="input_text" value="<?php echo $article['keywords'] ?>" />
- <p style="padding-bottom:5px;padding-top:5px;text-align:left;">???</p>
- <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>
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_type')">??<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_type" style="display:none;">
- <input type="radio" value="??" name="article_type" checked="checked" class="input_radio" />??
- <input type="radio" value="??" name="article_type" class="input_radio" />??
- <input type="radio" value="??" name="article_type" class="input_radio" />??
- </div>
- </div>
- </div>
- <div class="admin_panel">
- <div class="admin_title" onclick="javascript:ShowHideDiv('div_article_trackback')">????<div class="tit_right"></div></div>
- <div class="admin_content">
- <div id="div_article_trackback" style="display:none;">
- <input name="article_trackback" type="text" id="article_trackback" size="40" class="input_text" value="<?php echo $article['trackback'] ?>" />
- </div>
- </div>
- </div>
- </div>
- <div class="fixed"></div>
- </form>
- <script>
- $(document).ready(function(){
- $('#ajax_form').ajaxForm(function(data){
- showMessage(data);
- $("#admin_loading").css('visibility','hidden');
- });
- });
- </script>
- <?php
- }
- private function article_list() {
- global $db,$cache,$request;
- $current_page = max( 1, $request->page );
- $max_per_page = 20;
- $offset = ($current_page - 1) * $max_per_page;
- $article_num = $cache->count['article_num'];
- $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";
- $article_array = $db->fetch_all( $sql );
- ?>
- <div class="admin_title"><?php echo L('_ARTICLE_LIST_'); ?></div>
- <div class="admin_content">
- <form name="smslist" action="admin_article.php?action=batch" method="post">
- <div style="padding:5px;margin:2px;">
- <table class="pickme" style="table-layout: fixed;word-wrap: break-word;" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#bbbbbb">
- <thead>
- <tr align="center" height="22" bgcolor="#ffffff">
- <td width="3%"><input type="checkbox" name="allbox" onclick="CheckAll();"><input type="checkbox" id="ckbox" style="display:none;" disabled></td>
- <td width="4%"><?php echo L('_NUM_'); ?></td>
- <td width="10%"><?php echo L('_AUTHOR_'); ?></td>
- <td width="32%"><?php echo L('_TITLE_'); ?></td>
- <td width="6%"><?php echo L('_TYPE_'); ?></td>
- <td width="14%"><?php echo L('_CATEGORY_'); ?></td>
- <td width="7%"><?php echo L('_READ_'); ?></td>
- <td width="7%"><?php echo L('_COMMENT_'); ?></td>
- <td width="11%"><?php echo L('_TIME_'); ?></td>
- <td width="6%"><?php echo L('_OPERATION_'); ?></td>
- </tr>
- </thead>
- <tbody>
- <?php
- $i = 1;
- foreach( $article_array as $value ) {
- ?>
- <tr align="center" height="20" bgcolor="#ffffff">
- <td ><input type="checkbox" id="ckbox" name="id_arr[]" value="<?php echo $value['id'] ?>" /></td>
- <td><?php echo ( $current_page - 1 ) * $max_per_page + $i ?></td>
- <td><?php echo $value['author'] ?></td>
- <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>
- <td>
- <?php
- if( $value['type'] == 0 ) {
- echo '??';
- } elseif( $value['type'] == 1 ) {
- echo '??';
- } elseif( $value['type'] == 3 ) {
- echo '??';
- } else {
- echo 'Unknown';
- }
- ?></td>
- <td><?php echo $cache->category[$value['category']]['name'] ?></td>
- <td><?php echo $value['read'] ?></td>
- <td><?php echo $value['comment'] ?></td>
- <td><?php echo date( 'Y-m-d', $value['time'] ) ?></td>
- <td>
- <span class="Control">
- <a href="#" onclick="ajax_load('<?php echo ADMIN_PATH ?>','article','edit',null,'<?php echo $value['id'] ?>');return false;"><?php echo L('_EDIT_'); ?></a>
- </span>
- </td>
- </tr>
- <?php
- $i ++;
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php echo Admin::get_navigator( $article_num, $max_per_page, $current_page, 'article', 'list' ); ?>
- <div align="center" style="margin-top:10px;">
- <?php echo L('_BATCH_ADMIN_'); ?>:
- <input type="radio" name="Control" value="??" checked="checked"/><?php echo L('_DELETE_'); ?>
- <input type="radio" name="Control" value="??" /><?php echo L('_MOVE_'); ?>
- <select name="article_category" id="article_category">
- <?php
- foreach ( $cache->category as $value ) {
- echo '<option value="' . $value['cid'] . '">' . $value['name'] . '</option>';
- }
- ?>
- </select>
- <input type="radio" name="Control" value="??" /><?php echo L('_CHANGE_'); ?>
- <select name="article_type" id="article_type">
- <option value="??">??</option>
- <option value="??">??</option>
- <option value="??">??</option>
- </select>
- <input type="submit" class="main_button" value=" <?php echo L('_TAKE_OPERATION_'); ?> " />
- </div>
- </form>
- <div class="main_button"></div>
- </div>
- <?php
- }
- private function page_control() {
- ?>
- <div class="admin_title"><?php echo L('_HTML_MANAGEMENT_'); ?></div>
- <div class="admin_content">
- <div style="padding:10px;">
- <a href="admin_article.php?action=MakearticlePage"><?php echo L('_REBUILD_HTML_'); ?></a>
- </div>
- </div>
- <?php
- }
- private function data_check() {
- ?>
- <div class="admin_title"><?php echo L('_DATA_CHECK_'); ?></div>
- <div class="admin_content">
- <div style="padding:10px;">
- <a href="index.php?m=article&p=datacheckexe"><?php echo L('_COMMENT_DATA_CHECK_'); ?></a><br />
- <a href="index.php?m=article&p=tagdatacheckexe"><?php echo L('_TAG_DATA_CHECK_'); ?></a>
- </div>
- </div>
- <?php
- }
- private function main() {
- ?>
- <div class="admin_title"><?php echo L('_CONTENT_MANAGEMENT_'); ?></div>
- <div class="admin_content">
- <div style="padding:10px;">
- <?php echo L('_UNDEFINED_ACTION_'); ?>
- </div>
- </div>
- <?php
- }
- }
- ?>