Admin_topic.php 22.5 KB
Newer Older
huangxuan258's avatar
huangxuan258 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );

class Admin_topic extends ADMIN_Controller {

	function __construct() {
		parent::__construct ();
		$this->load->model ( "topic_model" );
		$this->load->model ( "topic_tag_model" );
		$this->load->model ( "category_model" );
	}

	function index($msg = '', $ty = '') {
		$catetree = $this->category_model->get_categrory_tree ( $this->category_model->get_list () );
		if ($_POST ['submit']) {
			$this->uri->rsegments [6] = 1;
		}
		@$page = max ( 1, intval ( $this->uri->rsegments [6] ) );

		$pagesize = $this->setting ['list_default'];
		$startindex = ($page - 1) * $pagesize;

		if ($this->uri->rsegments [3] != '' && $this->uri->rsegments [3] != '0') {
			$srchtitle = trim ( urldecode ( $this->uri->rsegments [3] ) );
		} else {
			$srchtitle = trim ( $this->input->post ( 'srchtitle' ) );
		}

		if ($this->uri->rsegments [4] != '' && $this->uri->rsegments [4] != '0') {
			$srchauthor = trim ( urldecode ( $this->uri->rsegments [4] ) );
		} else {
			$srchauthor = trim ( $this->input->post ( 'srchauthor' ) );
		}

		if ($this->uri->rsegments [5] != '' && $this->uri->rsegments [5] != '0') {
			$srchcategory = trim ( urldecode ( $this->uri->rsegments [5] ) );
		} else {
			$srchcategory = $this->input->post ( 'srchcategory' );
		}

		$topiclist = $this->topic_model->list_by_search ( addslashes($srchtitle), addslashes($srchauthor),addslashes( $srchcategory), $startindex, $pagesize );

		$rownum = $this->topic_model->rownum_by_search (  addslashes($srchtitle), addslashes($srchauthor),addslashes( $srchcategory) );
		if (! $srchtitle) {
			$srchtitle = 0;
		}
		if (! $srchauthor) {
			$srchauthor = 0;
		}
		if (! $srchcategory) {
			$srchcategory = 0;
		}
		$departstr = page ( $rownum, $pagesize, $page, "admin_topic/index/$srchtitle/$srchauthor/$srchcategory" );
		if (! $srchtitle) {
			$srchtitle = '';
		}
		if (! $srchauthor) {
			$srchauthor = '';
		}
		if (! $srchcategory) {
			$srchcategory = '';
		}
		$msg && $message = $msg;
		$ty && $type = $ty;

		
		include template ( "topiclist", 'admin' );
	}
	function shenhe($msg = '', $ty = '') {
		$catetree = $this->category_model->get_categrory_tree ( $this->category_model->get_list () );
		if ($_POST ['submit']) {
			$this->uri->rsegments [6] = 1;
		}
		@$page = max ( 1, intval ( $this->uri->rsegments [6] ) );
		
		$pagesize = $this->setting ['list_default'];
		$startindex = ($page - 1) * $pagesize;
		
		if ($this->uri->rsegments [3] != '' && $this->uri->rsegments [3] != '0') {
			$srchtitle = trim ( urldecode ( $this->uri->rsegments [3] ) );
		} else {
			$srchtitle = trim ( $this->input->post ( 'srchtitle' ) );
		}
		
		if ($this->uri->rsegments [4] != '' && $this->uri->rsegments [4] != '0') {
			$srchauthor = trim ( urldecode ( $this->uri->rsegments [4] ) );
		} else {
			$srchauthor = trim ( $this->input->post ( 'srchauthor' ) );
		}
		
		if ($this->uri->rsegments [5] != '' && $this->uri->rsegments [5] != '0') {
			$srchcategory = trim ( urldecode ( $this->uri->rsegments [5] ) );
		} else {
			$srchcategory = $this->input->post ( 'srchcategory' );
		}
		
		$topiclist = $this->topic_model->list_by_searchshenhe ( $srchtitle, $srchauthor, $srchcategory, $startindex, $pagesize );
		
		$rownum = $this->topic_model->rownum_by_searchshenhe ( $srchtitle, $srchauthor, $srchcategory );
		if (! $srchtitle) {
			$srchtitle = 0;
		}
		if (! $srchauthor) {
			$srchauthor = 0;
		}
		if (! $srchcategory) {
			$srchcategory = 0;
		}
		$departstr = page ( $rownum, $pagesize, $page, "admin_topic/shenhe/$srchtitle/$srchauthor/$srchcategory" );
		if (! $srchtitle) {
			$srchtitle = '';
		}
		if (! $srchauthor) {
			$srchauthor = '';
		}
		if (! $srchcategory) {
			$srchcategory = '';
		}
		$msg && $message = $msg;
		$ty && $type = $ty;
		
		include template ( "topicshenhelist", 'admin' );
	}
	function vertifycomments($msg = ''){
		$this->load->model ( "articlecomment_model" );
		$msg && $message = $msg;
		@$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) );
		$pagesize = 20;
		$startindex = ($page - 1) * $pagesize;
		$commentlist = $this->articlecomment_model->list_by_state ( 0, $startindex, $pagesize );
		$rownum = returnarraynum ( $this->db->query ( getwheresql ( 'articlecomment', ' `state`=0', $this->db->dbprefix ) )->row_array () );
		$departstr = page ( $rownum, $pagesize, $page, "admin_topic/vertifycomments" );
		include template ( "verifyarticlecomments", "admin" );
	}
	function add() {
		if (null !== $this->input->post ( 'submit' )) {
			$title = $this->input->post ( 'title' );
			$desrc = $this->input->post ( 'content' );
			$isphone = $this->input->post ( 'isphone' );
			$topic_tag = $this->input->post ( 'topic_tag' );
			$taglist = explode ( ",", $topic_tag );
			if ($isphone == 'on') {
				$isphone = 1;
			} else {
				$isphone = 0;
			}
			$acid = $this->input->post ( 'topicclass' );

			if ($acid == null)
				$acid = 1;
			$imgname = strtolower ( $_FILES ['image'] ['name'] );
			if ('' == $title || '' == $desrc) {
				$this->index ( '请完整填写专题相关参数!', 'errormsg' );
				exit ();
			}
			$type = substr ( strrchr ( $imgname, '.' ), 1 );
			if (! isimage ( $type )) {
				$this->index ( '当前图片图片格式不支持,目前仅支持jpg、gif、png格式!', 'errormsg' );
				exit ();
			}
			$upload_tmp_file = FCPATH . '/data/tmp/topic_' . random ( 6, 0 ) . '.' . $type;

			$filepath = '/data/attach/topic/topic' . random ( 6, 0 ) . '.' . $type;
			forcemkdir ( FCPATH . '/data/attach/topic' );
			if (move_uploaded_file ( $_FILES ['image'] ['tmp_name'], $upload_tmp_file )) {
				image_resize ( $upload_tmp_file, FCPATH . $filepath, 270, 220 );

				$this->topic_model->add ( $title, $desrc, $filepath, $isphone, '1', $acid );
				$this->index ( '添加成功!' );
			} else {
				$this->index ( '服务器忙,请稍后再试!' );
			}
		} else {
			include template ( "addtopic", 'admin' );
		}
	}
	/*百度推送*/

	function baidutui() {

		$urls = array ();
		$suffix = '?';
		if ($this->setting ['seo_on']) {
			$suffix = '';
		}
		$fix = $this->setting ['seo_suffix'];
		if (null !== $this->input->post ( 'tid' )) {
			//SITE_URL.$suffix."q-$item[id]$fix
			$tids = $this->input->post ( 'tid' );
			$q_size = count ( $tids );
			for($i = 0; $i < $q_size; $i ++) {
				array_push ( $urls, SITE_URL . $suffix . "article-" . $tids [$i] . $fix );
			}
		} else {
			$this->index ( '您还没选择推送文章!' );
		}
		if (trim ( $this->setting ['baidu_api'] ) != '' && $this->setting ['baidu_api'] != null) {

			$api = $this->setting ['baidu_api'];
			$result = baidusend ( $api, $urls );
			$this->index ( '文章推送成功!' );
		} else {
			$this->index ( '文章推送不成功,您还没设置百度推送的api地址,前往系统设置--seo设置里配置!' );
		}
	}
	/**
	 * 后台修改专题
	 */
	function edit() {
		if ($this->user ['uid'] == 0) {
			header ( "Location:" . url ( 'user/login' ) );
		}
		if (is_mobile ()) {
			$catetree = $this->category_model->get_categrory_tree ( 2 );
		}
		session_start ();
		$this->load->model ( "tag_model" );
		$this->load->model ( "topic_tag_model" );
		$tid = intval ( $this->uri->segment ( 3 ) ) > 0 ? intval ( $this->uri->segment ( 3 ) ) : intval ( $this->input->post ( 'id' ) );
		
		$topic = $this->topic_model->get ( intval ( $tid ) );
		
		
		// 判断当前用户是不是超级管理员
		$candone = false;
		if ($this->user ['grouptype'] == 1) {
			$candone = true;
		} else {
			// 判断当前用户是不是回答者本人
			
			if ($this->user ['uid'] == $topic ['authorid']) {
				$candone = true;
			}
		}
		
		if ($candone == false) {
			$this->message ( "非法操作,您的ip已被系统记录!", "STOP" );
		}
		if (null !== $this->input->post ( 'submit' )) {
			if ($this->user ['uid'] == 0 || $this->user ['uid'] == null) {
				$this->message ( '您还没有登录!', 'user/login' );
			}
			// $this->check_apikey();
			$tid = intval ( $this->input->post ( 'id' ) );
			$topic = $this->topic_model->get ( $tid );
			
			if ($topic ['authorid'] != $this->user ['uid'] && $candone == false) {
				$this->message ( '非法操作,你的ip已被记录' );
			}
			if (isset ( $this->setting ['register_on'] ) && $this->setting ['register_on'] == '1') {
				if ($this->user ['active'] != 1) {
					$viewhref = urlmap ( 'user/editemail', 1 );
					$this->message ( "必须激活邮箱才能修改文章!", $viewhref );
				}
			}
			$title = $this->input->post ( 'title' );
			$topic_price = intval ( $this->input->post ( 'topic_price' ) );
			if ($topic_price < 0) {
				$this->message ( '积分不能小于0!', "BACK" );
				
				exit ();
			}
			$topic_tag = $this->input->post ( 'topic_tag' );
			$taglist = explode ( ",", $topic_tag );
			$desrc = $_POST ['content']; // $this->input->post ( 'content' );
			$outimgurl = $this->input->post ( 'outimgurl' );
			$upimg = $this->input->post ( 'upimg' );
			$views = $this->input->post ( 'views' );
			$isphone = $this->input->post ( 'isphone' );
			if ($isphone == 'on') {
				$isphone = 1;
			} else {
				$isphone = 0;
			}
			$acid = $this->input->post ( 'topicclass' );
			if ($acid == null)
				$acid = 1;
				$imgname = strtolower ( $_FILES ['image'] ['name'] );
				if ('' == $title || '' == strip_tags ( $desrc )) {
					$this->message ( '请完整填写专题相关参数!', 'BACK' );
					exit ();
				}
				// print_r($tagarr);
				// exit();
				if ($imgname) {
					$type = substr ( strrchr ( $imgname, '.' ), 1 );
					if (! isimage ( $type )) {
						$this->message ( '当前图片图片格式不支持,目前仅支持jpg、gif、png格式!', 'errormsg' );
						exit ();
					}
					$filepath = '/data/attach/topic/topic' . random ( 6, 0 ) . '.' . $type;
					$upload_tmp_file = FCPATH . 'data/tmp/topic_' . random ( 6, 0 ) . '.' . $type;
					forcemkdir ( FCPATH . 'data/attach/topic' );
					if (move_uploaded_file ( $_FILES ['image'] ['tmp_name'], $upload_tmp_file )) {
						image_resize ( $upload_tmp_file, FCPATH . $filepath, 300, 240 );
						$filepath = SITE_URL . $filepath;
						$ispc = $topic ['ispc'];
						
						$this->topic_model->updatetopic ( $tid, $title, $desrc, $filepath, $isphone, $views, $acid, $ispc, $topic_price );
						$taglist && $this->tag_model->multi_addarticle ( array_unique ( $taglist ), $tid, $acid, $this->user ['uid'] );
						
						$state = 1;
						if ($this->setting ['publisharticlecheck']) {
							$state = intval ( $this->setting ['publisharticlecheck'] ) > 0 ? 0 : 1;
						}
						if ($state) {
307
							$this->message ( '文章修改成功!', "admin_topic/default");
huangxuan258's avatar
huangxuan258 已提交
308
						} else {
309
							$this->message ( "文章在审核中" , "admin_topic/default");
huangxuan258's avatar
huangxuan258 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
						}
					} else {
						$this->message ( '服务器忙,请稍后再试!' );
					}
				} else {
					if (trim ( $outimgurl ) == '') {
						$this->message ( '封面图不能为空!', "BACK" );
					}
					// if($outimgurl!=$upimg&&trim($upimg)!=''){
					$upimg = $outimgurl;
					$filepath = 'data/attach/topic/topic' . random ( 6, 0 ) . '.jpg';
					
					image_resize ( $outimgurl, FCPATH . $filepath, 300, 240 );
					
					$upimg = SITE_URL . $filepath;
					// }
					$ispc = $topic ['ispc'];
					$this->topic_model->updatetopic ( $tid, $title, $desrc, $upimg, $isphone, $views, $acid, $ispc, $topic_price );
					$taglist && $this->tag_model->multi_addarticle ( array_unique ( $taglist ), $tid, $acid, $this->user ['uid'] );
					$state = 1;
					if ($this->setting ['publisharticlecheck']&&$this->user['groupid']>=6) {
						$state = intval ( $this->setting ['publisharticlecheck'] ) > 0 ? 0 : 1;
					}
					if ($state) {
334
						$this->message ( '文章修改成功!' , "admin_topic/default");
huangxuan258's avatar
huangxuan258 已提交
335
					} else {
336
						$this->message ( "文章在审核中", "admin_topic/default" );
huangxuan258's avatar
huangxuan258 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
					}
				}
		} else {
			
			$topic ['tags'] = $this->tag_model->gettaglistbytypeid ( $topic ['id'], 'article' );
			$tagstr = '';
			foreach ( $topic ['tags'] as $tag ) {
				$tagstr .= $tag ['id'] . ",";
			}
			$topic ['topic_tag'] = trim ( $tagstr, ',' );
			
			$_SESSION ["userid"] = getRandChar ( 56 );
			$catmodel = $this->category_model->get ( $topic ['articleclassid'] );
			$categoryjs = $this->category_model->get_js ( 0, 2 );
			
			include template ( 'editxinzhi' , 'admin' );
		}
	}
	function view() {
		if (null !== $this->input->post ( 'submit' )) {
			
			$title = $this->input->post ( 'title' );
			$topic_tag = $this->input->post ( 'topic_tag' );
			$taglist = explode ( ",", $topic_tag );
			$desrc = $this->input->post ( 'content' );
			$tid = intval ( $this->input->post ( 'id' ) );
			$upimg = $this->input->post ( 'upimg' );
			$views = $this->input->post ( 'views' );
			$isphone = $this->input->post ( 'isphone' );
			$ispc = $this->input->post ( 'ispc' );
			if ($isphone == 'on') {
				$isphone = 1;
			} else {
				$isphone = 0;
			}
			if ($ispc == 'on') {
				$ispc = 1;
			} else {
				$ispc = 0;
			}
			$acid = $this->input->post ( 'topicclass' );
			
			if ($acid == null)
				$acid = 1;
				$imgname = strtolower ( $_FILES ['image'] ['name'] );
				if ('' == $title || '' == $desrc) {
					$this->index ( '请完整填写专题相关参数!', 'errormsg' );
					exit ();
				}
				$topic = $this->topic_model->get ( $tid );
				$filepath = $topic ['image'];
				if ($imgname) {
					$type = substr ( strrchr ( $imgname, '.' ), 1 );
					if (! isimage ( $type )) {
						$this->index ( '当前图片图片格式不支持,目前仅支持jpg、gif、png格式!', 'errormsg' );
						exit ();
					}
					$filepath = '/data/attach/topic/topic' . random ( 6, 0 ) . '.' . $type;
					$upload_tmp_file = FCPATH . '/data/tmp/topic_' . random ( 6, 0 ) . '.' . $type;
					forcemkdir ( FCPATH . '/data/attach/topic' );
					if (move_uploaded_file ( $_FILES ['image'] ['tmp_name'], $upload_tmp_file )) {
						image_resize ( $upload_tmp_file, FCPATH . $filepath, 270, 220 );
						$this->topic_model->updatetopic ( $tid, $title, $desrc, $filepath, $isphone, $views, $acid, $ispc, $topic ['price'] );
						$taglist && $this->topic_tag_model->multi_add ( array_unique ( $taglist ), $tid );
						$viewhref = urlmap ( 'admin_topic/index', 1 );
						$url = SITE_URL . $this->setting ['seo_prefix'] . $viewhref . $this->setting ['seo_suffix'];
						header ( "Location:$url" );
					} else {
						$this->index ( '服务器忙,请稍后再试!' );
					}
				} else {
					
					$this->topic_model->updatetopic ( $tid, $title, $desrc, $filepath, $isphone, $views, $acid, $ispc, $topic ['price'] );
					$taglist && $this->topic_tag_model->multi_add ( array_unique ( $taglist ), $tid );
					$this->index ( '专题修改成功!' );
					
				}
		} else {
			$topic = $this->topic_model->get ( intval ( $this->uri->segment ( 3 ) ) );
			
			$tagmodel = $this->topic_tag_model->get_by_aid ( $topic ['id'] );
			
			$topic ['topic_tag'] = implode ( ',', $tagmodel );
			
			$catmodel = $this->category_model->get ( $topic ['articleclassid'] );
			$categoryjs = $this->category_model->get_js ();
			include template ( "topicshenhe", 'admin' );
		}
	}
	//审核通过
	function vertify(){
		if (null !== $this->input->post ( 'tid' )) {
			$this->load->model ( "doing_model" );
			if(is_array($this->input->post ( 'tid' ))){
431
				$tids = implode ( ',', $this->input->post ( 'tid' ) );
huangxuan258's avatar
huangxuan258 已提交
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
				$this->topic_model->vertify ( $tids );
				
			    //审核通过插入动态
				foreach ($this->input->post ( 'tid' ) as $tid){
					$topic = $this->topic_model->get ( intval ( $tid ) );
					$this->doing_model->add ( $topic['authorid'],$topic['author'], 9, $tid, $topic['title'] );
					
				}
			}else{
				$this->topic_model->vertify ( $this->input->post ( 'tid' ) );
				//审核通过插入动态
				$topic = $this->topic_model->get ( intval (  $this->input->post ( 'tid' )  ) );
				$this->doing_model->add ( $topic['authorid'],$topic['author'], 9, $tid, $topic['title'] );
				
			}
			if (null !== $this->input->post ( 'viewtid' ))
			{
				$this->message ( '文章审核通过!' );
			}else{
				$this->message ( '文章审核通过!' );
			}
			
		}
	}
	//文章删除
	function remove() {
		if (null !== $this->input->post ( 'tid' )) {
			if(is_array($this->input->post ( 'tid' ))){
				$tids = implode ( ",", $this->input->post ( 'tid' ) );
				foreach ($this->input->post ( 'tid' ) as $tid){
					$topic = $this->topic_model->get ( $tid );
					$this->load->model ( 'topdata_model' );
					$this->topdata_model->remove ( $topic ['id'], 'topic' );
					$uid = $topic ['authorid'];
					$this->load->model ( "doing_model" );
					$this->doing_model->deletedoing ( $uid, 9, $topic ['id'] ); // 删除动态
					
					// 删除文章,扣减财富值
					$touser = $this->user_model->get_by_uid ( $uid );
					$koujiancredit1=intval($this->setting ['credit1_article']);
					if($touser['credit1']<$koujiancredit1){
						$koujiancredit1=$touser['credit1']>=0? $touser['credit1']:0;
					}
					
					$koujiancredit2=intval($this->setting ['credit2_article']);
					if($touser['credit2']<$koujiancredit2){
						$koujiancredit2=$touser['credit2']>=0? $touser['credit2']:0;
					}
					
					$this->credit ( $uid, -$koujiancredit1, -$koujiancredit2, 0, 'delarticle' );
					
				}
				$this->topic_model->remove ( $tids );
			}else{
				$topic = $this->topic_model->get (  $this->input->post ( 'tid' ) );
				$this->load->model ( 'topdata_model' );
				$this->topdata_model->remove ( $topic ['id'], 'topic' );
				$uid = $topic ['authorid'];
				$this->load->model ( "doing_model" );
				$this->doing_model->deletedoing ( $uid, 9, $topic ['id'] ); // 删除动态
		
				// 删除文章,扣减财富值
				$touser = $this->user_model->get_by_uid ( $uid );
				$koujiancredit1=intval($this->setting ['credit1_article']);
				if($touser['credit1']<$koujiancredit1){
					$koujiancredit1=$touser['credit1']>=0? $touser['credit1']:0;
				}
				
				$koujiancredit2=intval($this->setting ['credit2_article']);
				if($touser['credit2']<$koujiancredit2){
					$koujiancredit2=$touser['credit2']>=0? $touser['credit2']:0;
				}
				
				$this->credit ( $uid, -$koujiancredit1, -$koujiancredit2, 0, 'delarticle' );
				
				
				$this->topic_model->remove ( $this->input->post ( 'tid' ) );
			}
			if (null !== $this->input->post ( 'viewtid' )) 
			{
				$this->message ( '文章删除成功!' );
			}else{
				$this->message ( '文章删除成功!' );
			}
			
		}
	}
  
	
	//审核文章评论
	function verifycomment(){
		$this->load->model ( "articlecomment_model" );
		if (null !== $this->input->post ( 'aid' )) {
			if(is_array($this->input->post ( 'aid' ))){
				$aids = implode ( ",", $this->input->post ( 'aid' ) );
				$this->articlecomment_model->pass ( $aids );
			}else{
				$this->articlecomment_model->pass ( $this->input->post ( 'aid' ) );
			}
			
			$this->vertifycomments( '文章评论审核成功!' );
			exit ();
		}
	}
	//文章评论删除
	function deletecomment(){
		$this->load->model ( "articlecomment_model" );
		if (null !== $this->input->post ( 'aid' )) {
			if(is_array($this->input->post ( 'aid' ))){
				$aids = implode ( ",", $this->input->post ( 'aid' ) );
				$this->articlecomment_model->remove ( $aids );
			}else{
				$this->articlecomment_model->remove ( $this->input->post ( 'aid' ) );
			}
		
			$this->vertifycomments( '删除文章评论成功!' );
			exit ();
		}
	}
	/* 后台分类排序 */

	function reorder() {
		$orders = explode ( ",", $this->input->post ( 'order' ) );
		foreach ( $orders as $order => $tid ) {
			$this->topic_model->order_topic ( intval ( $tid ), $order );
		}
		$this->cache->remove ( 'topic' );
	}

	function ajaxgetselect() {
		echo $this->topic_model->get_select ();
		exit ();
	}

	function makeindex() {

		
		$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) );
		$pagesize = 1000;
		$startindex = ($page - 1) * $pagesize;
		ignore_user_abort ();
		set_time_limit ( 0 );
		$this->topic_model->makeindex ( $startindex, $pagesize );
		echo 'ok';
		exit ();
		
	}
	/**
	
	* 获取顶置内容列表
	
	* @date: 2018年11月9日 下午4:51:35
	
	* @author: 61703
	
	* @param: variable
	
	* @return:
	
	*/
	function topicdatalist(){
		$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) );
		$pagesize = $this->setting ['list_default'];
		$startindex = ($page - 1) * $pagesize;
		$this->load->model ( 'topdata_model' );
		$rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topdata', ' 1=1', $this->db->dbprefix ) )->row_array () );
		
		$topicdatalist = $this->topdata_model->get_list ( $startindex, $pagesize );
		$departstr = page ( $rownum, $pagesize, $page, "admin_topic/topicdatalist" );
		include template ( "topicdatalist", 'admin' );
	}
	/**
	
	* 取消顶置内容
	
	* @date: 2018年11月9日 下午6:10:30
	
	* @author: 61703
	
	* @param: variable
	
	* @return:
	
	*/
	function canceltopdata(){
		$this->load->model ( 'topdata_model' );
		if (null !== $this->input->post ( 'tid' )) {
			if(is_array($this->input->post ( 'tid' ))){
				$tids = implode ( ",", $this->input->post ( 'tid' ) );
				
				$this->topdata_model->remove_by_id ( $tids );
			}else{
			
				$this->topdata_model->remove ( $this->input->post ( 'tid' ) );
			}
			$this->message("取消顶置成功");
			
		}
	}
	/**
	
	* 重新排序
	
	* @date: 2018年11月9日 下午6:14:15
	
	* @author: 61703
	
	* @param: variable
	
	* @return:
	
	*/
	function reordertopdata(){
		$this->load->model ( 'topdata_model' );
		if (null !== $this->input->post ( 'tid' )) {
			$cids = implode ( ",", $this->input->post ( 'tid' ) );
		
			$orders=$this->input->post ( 'corder' );
			//var_dump($orders);exit();
			
			foreach ( $this->input->post ( 'tid' ) as $val ) {
				
				$orderval=$this->input->post ( 'corder'.$val );
				//echo $val.'--'.$orderval."<br>";
				$this->topdata_model->order_topdata ( intval ( $val ), intval($orderval) );
				
			}
		
	
			$this->message("更新排序成功");
		}
	}
	/**
	
	* 推荐文章管理
	
	* @date: 2018年11月9日 下午6:40:31
	
	* @author: 61703
	
	* @param: variable
	
	* @return:
	
	*/
	function topichotlist(){
		//get_hotlist
		@$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) );
		$pagesize = $this->setting ['list_default'];
		$startindex = ($page - 1) * $pagesize;
		$rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', ' ispc=1 and state=1 ', $this->db->dbprefix ) )->row_array () );
		
		
		$topiclist = $this->topic_model->get_hotlist ( 1, $startindex, $pagesize, 12 );
		$departstr = page ( $rownum, $pagesize, $page, "admin_topic/topichotlist" );
		include template ( "topichotlist", 'admin' );
	}
	/**
	
	* 取消热文推荐
	
	* @date: 2018年11月9日 下午6:47:26
	
	* @author: 61703
	
	* @param: variable
	
	* @return:
	
	*/
	function cancelhottopic(){
		$this->load->model ( 'topdata_model' );
		if (null !== $this->input->post ( 'tid' )) {
			foreach ( $this->input->post ( 'tid' ) as $val ) {
			
				$this->topic_model->updatetopichot ( $val, '0' );
			}
			$this->message("取消推荐成功");
			
		}
	}
}

?>