⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 news_ac.php

📁 没用的东西? 国外php免费程序,相册 留言板 等
💻 PHP
字号:
<?php
global $action,$cate,$superName;

switch($cate){
	case "save":
		$currentID=p('id');
		$ONE["nTitle"]=p("newsTitle");
		$ONE["nKeywords"]=p("newsKeywords");
		$ONE["nDescription"]=p("newsDescription");
		$ONE["nContent"]=p("newsContent");
		$ONE["nShow"]=p("newsShow")?1:0;
		
		//if(!$ONE['nTitle']) $msg='News title can not be empty.';
		//if(!$ONE['nContent']) $msg='News content can not be empty.';
		
		if($currentID!=0){
			$sql="update news set nTitle='".$ONE['nTitle']."',nKeywords='".$ONE['nKeywords']."',nDescription='".$ONE['nDescription']."',nContent='".$ONE['nContent']."',nShow=".$ONE['nShow'].",nUpdated=".time()." where ID=$currentID";
			$title='News updated!';
			$msg[]='News updated successfully.';
			$msg[]='<a href="index.php?action=news">Back to view news</a>';
		}
		else{
			$sql="insert into news(nTitle,nKeywords,nDescription,nContent,nShow,nCreated) values('".$ONE['nTitle']."','".$ONE['nKeywords']."','".$ONE['nDescription']."','".$ONE['nContent']."',".$ONE['nShow'].",".time().")";
			$title='News added!';
			$msg[]='News added successfully.';
			$msg[]='<a href="index.php?action=news">Back to view news</a>';
		}
		
		if(isset($sql)){
			$this->db->query($sql,'U_B');
		}else{$title='Warning!';}
		
		
		$this->set('finalTitle',$title);
		$this->set('msg',$msg);
		$this->set('final','warning');
	break;
	case "add":
		$currentID=g('id');
		$title='Add New News';
		
		$ONE=array('ID'=>0,'nTitle'=>'','nKeywords'=>'','nDecription'=>'','nContent'=>create_html_editor('newsContent',450),'nShow'=>1);
		if($currentID){
			$title='Edit News';			
			if($result=$this->db->get_one('select * from news where id='.$currentID)){
				$ONE['ID']				=$currentID;
				$ONE['nTitle']			=$result['nTitle'];
				$ONE['nKeywords']		=$result['nKeywords'];
				$ONE['nDescription']	=$result['nDescription'];
				$ONE['nContent']		=create_html_editor('newsContent',450,$result['nContent']);
				$ONE['nShow']			=$result['nShow'];
			}
			else{
				$msg[]='News No. not found.';
				$msg[]='<a href="index.php?action=news">Back to view news</a>';
			}
		}
		
		if(isset($msg)){
			$this->set('finalTitle','Warning!');
			$this->set('msg',$msg);
			$this->set('final','warning');
		}
		else{
			$this->set('finalTitle',$title);
			$this->set('ONE',$ONE);
			$this->set('final','news_edit');
		}
	break;
	case "delete":
		$pid=g('id')?g('id'):(p('id')?join(p('id'),','):false);
		if($pid){
			$sql="delete from news where id in($pid)";
			$this->db->query($sql,'U_B');
			$msg[]='News deleted successfully.';
			$msg[]='<a href="index.php?action=news">Back to view news</a>';
			$this->set('finalTitle','News deleted!');
			$this->set('msg',$msg);
			$this->set('final','warning');
		}
		else{
			$msg[]='News deleted unsuccessfully';
			$msg[]='<a href="index.php?action=news">Back to view news</a>';
			$this->set('finalTitle','Warning!');
			$this->set('msg',$msg);
			$this->set('final','warning');
		}
	break;
	default:
		$page[]=20;
		if(g('page')){$page[]=intval(g('page'));}else{$page[]=1;}
		$sql = "select count(id) as amount from news"; 
		$result=$this->db->query($sql);
		$row=$this->db->fetch_array($result);
		$amount = $row['amount'];
		if($amount){
			if($amount % $page[0]){$page[]=(int)($amount/$page[0])+1;}else{$page[]=$amount/$page[0];}
			$page[]=$amount;
		}
		else{$page[]=0;$page[]=0;}
		
		$sql = "select id,ntitle,nShow,nCreated from news order by nCreated desc limit ".($page[1]-1)*$page[0].",".$page[0];
		$result=$this->db->query($sql);
		while($row=$this->db->fetch_array($result)){
			$id=$row['id'];
			$title=$row['ntitle'];
			$show=$row["nShow"]==1?'<font color="#990000">Yes</font>':'No';
			$nTime=date('M d,Y',$row['nCreated']);
			$nTime2=date('M d,Y h:i:s',$row['nCreated']);
			$news[]=array($id,$title,$show,$nTime,$nTime2);
		}
		if(isset($news)) $this->set('news',$news);
		$this->set('page',$page);
		$this->set('finalTitle','View News');
		$this->set('final','news');
	break;
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -