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

📄 gcate_ac.php

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

$this->set('_GALLERY',$_GALLERY);
require_once("../app/files.php");
switch($cate){
	case "save":
		$currentID=p('id');
		$ONE["gName"]=p("cateName");
		$ONE["gDesc"]=p("cateDesc");
		
		//if(!$ONE['gName']) $msg='Category Name can not be empty.';
		
		require_once("../app/files.php");
		$pic = new uploadPic;
		
		if($currentID!=0){
			$sql="update gcate set gName='".$ONE['gName']."',gDesc='".$ONE['gDesc']."',gUpdated=".time();
			
			if($_FILES["pic1"]["name"] != ""){
				$pic->upfile("../".$_GALLERY[0]."/","pic1");
				$iPic = $pic->picname;
				$sqlD="select gImage from gcate where ID=$currentID";
				$imgD=$this->db->get_one($sqlD);
				if($imgD){
					delete_file("../".$_GALLERY[0]."/".$imgD['gImage']);
					delete_file("../".$_GALLERY[0]."/".$_GALLERY[1].$imgD['gImage']);
				}
				makethumb("../".$_GALLERY[0]."/$iPic","../".$_GALLERY[0]."/".$_GALLERY[1].$iPic,$_GALLERY[6],$_GALLERY[7]);
				$sql.=",gImage='$iPic'";
			}
			$sql.=" where ID=$currentID";
			
			$this->db->query($sql,'U_B');
			$title='Category updated!';
			$msg[]='Category updated successfully.';
			$msg[]='<a href="index.php?action=gcate">Back to view categories</a>';
		}
		else{
			$pic->upfile("../".$_GALLERY[0]."/","pic1");
			$iPic = $pic->picname;
			makethumb("../".$_GALLERY[0]."/$iPic","../".$_GALLERY[0]."/".$_GALLERY[1].$iPic,$_GALLERY[6],$_GALLERY[7]);					
			$sql="insert into gcate(gName,gDesc,gImage,gCreated) values('".$ONE['gName']."','".$ONE['gDesc']."','$iPic',".time().")";
			$this->db->query($sql,'U_B');
			
			$title='Category added!';
			$msg[]='Category added successfully.';
			$msg[]='<a href="index.php?action=gcate">Back to view categories</a>';
		}
		
		if(!isset($sql)){$title='Warning!';}
		
		
		$this->set('finalTitle',$title);
		$this->set('msg',$msg);
		$this->set('final','warning');
	break;
	case "add":
		$currentID=g('id');
		$title='Add New Category';
		
		$ONE=array('ID'=>0,'gName'=>'','gImage'=>'','gDesc'=>'');
		if($currentID){
			$title='Edit Category';			
			if($result=$this->db->get_one('select * from gcate where id='.$currentID)){
				$ONE['ID']				=$currentID;
				$ONE['gName']			=$result['gName'];
				$ONE['gImage']			=$result['gImage'];
				$ONE['gDesc']			=$result['gDesc'];
			}
			else{
				$msg[]='Category No. not found.';
				$msg[]='<a href="index.php?action=gcate">Back to view categories</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','gcate_edit');
		}
	break;
	case "delete":
		$pid=g('id')?g('id'):(p('id')?join(p('id'),','):false);
		if($pid){
			require_once("../app/files.php");
			$sql="select gImage from gcate where id in($pid)";
			$result=$this->db->query($sql);
			while($row=$this->db->fetch_array($result)){
				delete_file("../".$_GALLERY[0]."/".$row['gImage']);
				delete_file("../".$_GALLERY[0]."/".$_GALLERY[1].$row['gImage']);
			}
			$this->db->query("delete from gcate where id in($pid)",'U_B');
			
			$sql="select gImage from gallery where gCate in($pid)";
			$result=$this->db->query($sql);
			while($row=$this->db->fetch_array($result)){
				delete_file("../".$_GALLERY[0]."/".$row['gImage']);
				delete_file("../".$_GALLERY[0]."/".$_GALLERY[1].$row['gImage']);
			}
			$this->db->query("delete from gallery where gCate in($pid)",'U_B');
			
			$msg[]='Category deleted successfully.';
			$msg[]='<a href="index.php?action=gcate">Back to view categories</a>';
			$this->set('finalTitle','Category deleted!');
			$this->set('msg',$msg);
			$this->set('final','warning');
		}
		else{
			$msg[]='Category deleted unsuccessfully';
			$msg[]='<a href="index.php?action=gcate">Back to view categories</a>';
			$this->set('finalTitle','Warning!');
			$this->set('msg',$msg);
			$this->set('final','warning');
		}
	break;
	default:		
		$sql = "select id,gName,gImage,gCreated from gcate";
		$result=$this->db->query($sql);
		while($row=$this->db->fetch_array($result)){
			$id=$row['id'];
			$name=$row['gName'];
			$Times=date('Y-m-d h:i:s',$row['gCreated']);
			$gcate[]=array($id,$name,$Times);
		}
		if(isset($gcate)) $this->set('gcate',$gcate);
		$this->set('finalTitle','View Categories');
		$this->set('final','gcate');
	break;
}
?>

⌨️ 快捷键说明

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