www.gusucode.com > 搜一次CMS电影程序 PHP 1.5源码程序 > admin/admin_pathip.php

    <?php
/*
**************************************************************************************************
*软件名称: 搜一次 Content Management System
*版本编号: PHPV1.0版
*官方服务器: http://www.syccms.com
* 软件著作: 无痕,暮寒,新手℡鼠标
*Copyright (C) 2009-2010 Soyici Inc. 搜一次网络事业部 版权所有
***************************************************************************************************
*/
include "../include/conn.php";
include "../include/function.php";
include "admin_version.php";
include "admin_loginstate.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link  href="images/style.css" rel="stylesheet" type="text/css" />
<title>服务器组</title>
<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath?>';</script>
<script src="js/jquery.js"></script>
<script language="javascript" src="js/alerts.js"></script>
<link type="text/css" href="images/alerts.css" rel="stylesheet" media="screen">
</head>
<script language="javascript">
 $(document).ready(function(){
	$("#ChkAll").click(function(){
		if($(this).attr("checked")==true){
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",true);									 
			})							
		}else{
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",false);									 
			})							
		}
	})	
	$("#addlink").click(function(){
		 $("#S_Name").css("border-color","#666 #ccc #ccc #666");
		 $("#sname").text("");
		 $("#SInPut").text("");
		 $("#S_Pic").text("");
		 $("#S_Url").css("border-color","#666 #ccc #ccc #666");
		 $("#SWebUrl").text("").css("color","red");
		 var S_Name=$("#S_Name").val();
		 var S_Url=$("#S_Url").val();
		 var S_Pic=$("#S_Pic").val();
		 var S_InPut=$("#S_InPut").val();
		 if (S_Name==""){
			 $("#S_Name").css("border","1px solid red");
			 $("#sname").text("请填写服务器名!").css("color","red");
			 return false;}
		 else if(S_Name.length > 50){
		 	 $("#S_Name").css("border","1px solid red");
			 $("#sname").text("服务器名不能超过50个字符!").css("color","red");
			 return false;}
		 else if(S_Url==""){
			 $("#S_Url").css("border","1px solid red");
			 $("#SWebUrl").text("请填写服务器链接!").css("color","red");
			 return false;}
		 else if(S_Url.length > 100){
		 	 $("#S_Url").css("border","1px solid red");
			 $("#SWebUrl").text("服务器链接不能超过100个字符!").css("color","red");
			 return false;} 
		 else if(S_Pic.length > 150){
			 $("#SPic").text("申请服务器地址不能超过100个字符!").css("color","red");	
			 return false;
			 }
		 else if(S_InPut.length > 100){
			 $("#SInPut").text("申请服务器地址不能超过100个字符!").css("color","red");
			 return false;
			 }
		 })
	
	$("#btn_editall").click(function(){
		var page=$("#page").val();							 
		jConfirm('确定要编辑选中的服务器组吗?', '操作提示', function(r) {
				if(r==true){
					document.Link.action='?action=editall'
					Link.submit();}
				});
	 })
		
	 $("#btn_delall").click(function(){
		var page=$("#page").val();							 
		jConfirm('确定要删除选中的服务器组吗?', '操作提示', function(r) {
				if(r==true){
					document.Link.action='?action=delall'
					Link.submit();}
				});
	 })
		
})

function del(id,page){
	jConfirm('确定要删除该服务器组吗?', '操作提示', function(r) {
		if(r==true){
			window.location='?action=del&S_ID='+id;
			}
				});
		
		}

</script>

<body>
<?php
	class ui_server{
		
		public function editdata($Arr,$url){
					$name=$Arr[0];
					$lurl=$Arr[1];
					$order=$Arr[2];

			
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
			<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tb_style">
			<form name="form1" method="post" action="<?php echo $url?>" >
			  <tr>
				<td height="30" colspan="2" class="td_title">&nbsp;添加服务器组</td>
			</tr>
			  <tr>
				<td width="28%" height="30" align="right" class="td_border">服务器名称:</td>
				<td width="72%" class="td_border">&nbsp;
				  <input name="S_Name" type="text" id="S_Name" value="<?php echo $name?>" size="35" />
                    <font color="#FF0000">*</font>
                <label id="sname"></label>				</td>
		      </tr>
			  <tr>
			    <td height="30" align="right" class="td_border">服务器地址:</td>
			    <td class="td_border"> &nbsp;
			      <input name="S_Url" type="text" id="S_Url"  value="<?php echo $lurl?>" size="35" />
                  <font color="#FF0000">*</font>
                  <label id="SWebUrl"></label></td>
		      </tr>
			  <tr>
			    <td height="30" align="right" class="td_border">服务器排序:</td>
			    <td class="td_border"> &nbsp;
			      <input name="S_TheOrder" type="text" id="S_TheOrder" value="<?php echo $order?>" size="5" />
                  <font color="#FF0000">&nbsp;&nbsp;*按数字序列排序</font>
                  <label id="SWebUrl"></label></td>
		      </tr>
			  
			  
			  <tr>
				<td height="30" align="right" class="td_border">&nbsp;</td>
				<td height="30" class="td_border"> &nbsp;
				  <input type="submit" name="Submit" value="确定提交" class="rb1" id="addlink"/>
				  &nbsp;&nbsp; <input type="reset" name="Submit2" value="清除重置" class="rb1" /></td>
			  </tr>
			</form>  
</table>
		</div>
	</div>
</div>
<?php			
			}
		
		public function main(){
			global $db;
			$Arr=getpagerow("select * from s_pathip",20);//sql,每页显示条数
			$result=$db->query($Arr[2]);
			$pathnum=$db->num_rows($result);
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
					<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style" >
                      <form method="post" name="Link" action="">
                      <tr>
                        <td colspan="5" class="td_title" height="30">&nbsp;服务器组管理</td>
                      </tr>
                      <tr>
                        <td width="116" height="30" bgcolor="#FFFFFF" class="td_border">&nbsp;&nbsp;编号</td>
                        <td width="320" bgcolor="#FFFFFF" class="td_border">&nbsp; 服务器名称<font color="#FF0000">(*)</font></td>
                        <td width="436" bgcolor="#FFFFFF" class="td_border">&nbsp; 服务器地址<font color="#FF0000">(*)</font></td>
                        <td width="106" bgcolor="#FFFFFF" class="td_border">&nbsp; 排序</td>
                         <td width="207" align="center" bgcolor="#FFFFFF" class="td_border">操作</td>
                      </tr>
                       <?php
					   if($pathnum==0) echo "
							<tr>
                            	<td colspan=\"8\" class=\"td_border\" height=\"30\" align=center><b>暂无服务器组,请添加!</b></td>
                            </tr>";						   
                       if($result){
						   while ($row = $db ->fetch_array($result)){

					   ?>   
				<tr>
				  <td width="116" height="28" bgcolor="#FFFFFF" class="td_border">&nbsp;
			      <input type="checkbox" name="S_ID[]" id="S_ID" value="<?php echo $row["S_ID"]?>" class="checkbox"/><?php echo $row["S_ID"]?>、</td>
				  <td bgcolor="#FFFFFF" class="td_border">
			         &nbsp;
		          <input type="text" name="S_Name<?php echo $row["S_ID"]?>" value="<?php echo $row["S_Name"]?>" size="25" /></td>
				  <td bgcolor="#FFFFFF" class="td_border"> &nbsp;
			      <input type="text" name="S_Url<?php echo $row["S_ID"]?>" value="<?php echo $row["S_AddPath"]?>" size="35" /></td>
                  <td bgcolor="#FFFFFF" class="td_border"> &nbsp;
                    <input type="text" name="S_TheOrder<?php echo $row["S_ID"]?>" value="<?php echo $row["S_TheOrder"]?>"size="5"/></td>
					<td align="center" bgcolor="#FFFFFF" class="td_border"><a href="?action=editdata&S_ID=<?php echo $row['S_ID']?>">编辑</a>&nbsp;&nbsp; &nbsp;<a style="cursor:pointer;"  onclick="del(<?php echo $row['S_ID']?>)">删除</a></td>
	  </tr>
   <?php
                         							   
		 }
	 }
?> 
      <tr>
            <td height="30" colspan="5" align="left" bgcolor="#FFFFFF" class="td_border">&nbsp;
   <input type="hidden" name="page" id="page" value="<?php echo page?>"><input type="checkbox" name="ChkAll" id="ChkAll" ids="S_ID"  class="checkbox"/>
   全选&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
   &nbsp; <input type="button" id="btn_editall" value="修改服务器组" class="rb1"   />
   &nbsp;&nbsp;
  <input type="button" value="删除服务器组"  class="rb1" id="btn_delall" />
 &nbsp; <input type="button" value="添加服务器组"  class="rb1" id="btn_add" onclick="window.location='?action=add'" />
  </td></tr>
      </form>
      <tr><td height="30" colspan="8" align="right" class="td_border" style="font-size:12px; color:#033d61;">
        <?php echo $Arr[0];?></td></tr>
</table>
		</div>
	</div>
</div>
<?php			
				
			}
		}//end class

?>

<?php
	$ui=new ui_server;
	$action=SafeRequest("action","get");
	switch ($action){
		case 'main':
			$ui->main();
			break;
		case 'editdata':
			editdata();
			break;
		case 'saveedit':
			saveedit();
			break;
		case 'add':
			add();
			break;
		case 'saveadd':
			saveadd();
			break;
		case 'del':
			del();
			break;
		case 'delall':
			delall();
			break;
		case 'editall':
			editall();
			break;
		case 'changeverify':
			changeverify();
			break;
		case 'changeindex':
			changeindex();
			break;
		default:
			$ui->main();
		}
	function changeindex(){
		global $db;
		$isindex=SafeRequest("isindex","get");
		$id=SafeRequest("id","get");
		if(!IsNum($isindex)) $isindex=0;
		if(!IsNum($id)) die("<script>jAlert('id传输错误?','操作提示',function(R){history.back();})</script>");
		$sql="update s_pathip set S_IsIndex=$isindex where S_ID=$id";
		if($db->query($sql)){
			die("<script>window.location='admin_pathip.php';</script>");
			}
		else{
			die("<script>jAlert('未知错误!','操作提示',function(R){history.back();})</script>");
			}			

		}		
		
	function changeverify(){
		global $db;
		$isverify=SafeRequest("isverify","get");
		$id=SafeRequest("id","get");
		if(!IsNum($isverify)) $isverify=0;
		if(!IsNum($id)) die("<script>jAlert('id传输错误?','操作提示',function(R){history.back();})</script>");
		$sql="update s_pathip set S_IsVerify=$isverify where S_ID=$id";
		if($db->query($sql)){
			die("<script>window.location='admin_pathip.php';</script>");
			}
		else{
			die("<script>jAlert('未知错误!','操作提示',function(R){history.back();})</script>");
			}			

		}
	function editall(){
		global $db;
		$S_ID=RequestBox("S_ID");
		if($S_ID=="0"){
			die("<script>jAlert('请选择要编辑的服务器组?','操作提示',function(R){history.back();})</script>");
			}
		else{
			$ID=explode(",",$S_ID);
			
			for($i=0;$i<count($ID);$i++){
				$S_Name=SafeRequest("S_Name".$ID[$i]."","post");
				$S_Url=SafeRequest("S_Url".$ID[$i]."","post");
				$S_Order=SafeRequest("S_TheOrder".$ID[$i]."","post");
			if(!IsNul($S_Name)){echo "<script>jAlert('服务器组名称不能为空!','操作提示',function(R){history.back();})</script>";}
			if(!IsNul($S_Url)){echo "<script>jAlert('服务器组地址不能为空!','操作提示',function(R){history.back();})</script>";}
				$sql="update s_pathip set S_Name='".$S_Name."',S_AddPath='".$S_Url."',S_TheOrder=".$S_Order." where S_ID=".$ID[$i]."";
				$db->query($sql);
				}
			die("<script>jAlert('恭喜!服务器组编辑完毕!','操作提示',function(R){window.location='admin_pathip.php';})</script>");
			}	
		}
		
	function add(){
		global $ui;
		$Arr=array("","","");
		$ui->editdata($Arr,"?action=saveadd");
		}
		
	function saveadd(){
		global $db;
		$S_Name=SafeRequest("S_Name","post");
		$S_Url=SafeRequest("S_Url","post");
		$sql="Insert s_pathip  (S_Name,S_AddPath,S_TheOrder,S_SystemID) values ('".$S_Name."','".$S_Url."',0,0)";
		//die($sql);
		$db->query($sql);
		echo "<script>window.location='admin_pathip.php';</script>";
		}


	function delall(){
		global $db;
		$S_ID=RequestBox("S_ID");
		$sql="delete from s_pathip where S_ID in ($S_ID)";
		//die($S_ID);
		if($S_ID=="0"){
			die("<script>jAlert('请选择要删除的服务器组?','操作提示',function(R){history.back();})</script>");
			}
		else{
			if($db->query($sql)){
				die("<script>jAlert('恭喜你!操作成功了!','成功提示',function(R){window.location='admin_pathip.php';})</script>");
				}
			}	
		}

	function del(){
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$sql="delete from s_pathip where S_ID='".$S_ID."'";
		//die($sql);
		if($db->query($sql)){
			echo "<script>window.location='admin_pathip.php';</script>";
			}
		}


	function saveedit(){
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$S_Name=SafeRequest("S_Name","post");
		$S_Url=SafeRequest("S_Url","post");
		$S_TheOrder=SafeRequest("S_TheOrder","post");
		if(!IsNum($S_TheOrder)) $S_TheOrder=0;
		$sql="update s_pathip set S_Name='".$S_Name."',S_AddPath='".$S_Url."',S_TheOrder=".$S_TheOrder." where S_ID=".$S_ID."";
		
		$db->query($sql);
		echo "<script>window.location='admin_pathip.php';</script>";
		}

	function editdata(){
		global $db;
		global $ui;
		$S_ID=SafeRequest("S_ID","get");
		if(IsNum($S_ID)){
			$sql="SELECT * FROM `s_pathip` Where S_ID='".$S_ID."'";
			$row=$db->Getrow($sql);
				if($row){
					$Arr=array($row['S_Name'],$row['S_AddPath'],$row['S_TheOrder']);
					}
				$ui->editdata($Arr,"?action=saveedit&S_ID=".$S_ID."");
			}
		}

	
?>
<?php include "admin_bottom.php"; ?>
</body>
</html>