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

📄 cmssys.php

📁 为我们学校开发的一个住房货币化补贴工作的专题网站
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    }
  
  function SetLink($Field,$LinkHref,$DistinctField)
    {
      //Set the links and the distinct fields for each field.
      $this->Field[$Field]=$LinkHref;
      $this->DistinctField[$Field]=$DistinctField;
    }	
  
  function Output()
    {
      $res=$this->db->query($this->sql);
      echo "<Form name='form1' method='post' action='$this->OperateHref'>";
      echo "<Table width=100%>";
      for($count=0;$list=$this->db->fetch_array($res);$count++)
	{
	  $FieldNum=0;
	  echo "<Tr>";
	  echo "<Td><input type='checkbox' name='select[]' value='".$list[$this->IdentifyField]."'></Td>";
	  foreach($list as $element => $value)
	    {
	      if($element==$this->IdentifyField)
		{
		  $IdentifyFieldValue=$value;
		  continue;
		}
	      if($element==$this->DistinctField[$elemment])continue;
	      $FieldNum++;
	      $Distinct="?".$this->DistinctField[$element]."=".$list[$this->DistinctField[$element]];
	      echo "<Td>";
	      if($this->Field[$element]!="")
		$value="<a href='".$this->Field[$element]."$Distinct'>$value</a>";
	      echo $value;
	      echo "</Td>";		
	    }
	  echo "<Td align=center>";
	  echo "<a href='$this->ModifyHref?$this->IdentifyField=$IdentifyFieldValue' target='_blank'>Modify</a>&nbsp;&nbsp;";
	  echo "<a href='$this->OperateHref?$this->IdentifyField=$IdentifyFieldValue&Operate=Delete' onclick=\"javascript:return confirm('Are you sure?')\">Delete</a>&nbsp;&nbsp;";
	  if(is_array($this->AdditionOperate))
	    foreach($this->AdditionOperate as $element => $value)
	      echo "<a href='".$this->AdditionOperate[$element]."?$this->IdentifyField=$IdentifyFieldValue&Operate=$element'>$element</a>&nbsp;&nbsp;";
	  echo "</Td>";
	  echo "</Tr>";
	}
      echo "<Tr>";
      echo "<Td align=center>";
      echo "<input type='checkbox' name='chkall' onclick=\"javascript:CheckAll('form1',this)\">ALL</Td>";
      echo "<Td colspan='$FieldNum' align=center>";
      echo "<input type='button' value='New' onclick=\"javascript:window.open('$this->NewHref')\">&nbsp;";
      echo "<input type='submit' value='Delete' onclick=\"javascript:return confirm('Are you sure?')\" name='Delete'>&nbsp;";
      if(is_array($this->OperateAll))
	foreach($this->OperateAll as $element => $value)
	  if($this->OperateAll[$element]==true)
	    echo "<input type='submit' value='$element' name='$element'>&nbsp;";
      echo "<input type='hidden' name='Flag' value=1>";
      echo "</Td></Tr>";
      echo "</Table>";
      echo "</Form>";
      if($this->SetPageFlag==true&&$this->TotalNum/$this->PageNumLimit>1)
	{
	  echo "<Table><Tr><Td>";
	  $this->PageControl();
	  echo "</Td></Tr></Table>";
	}
    }
  
  function DataInput($TableName,$Fields,$Values,$SourceField="aid",$UploadTable="upload")
    {
      $sql="insert into $TableName($Fields) values($Values)";
      $this->db->query($sql);
      $InsertID=$this->db->insert_id();
      $sql="update $UploadTable set $SourceField=$InsertID where $SourceField<=0";
      $this->db->query($sql);
      echo "<script language='javascript'>alert('Insert successfully!')</script>";
    }
  
  function DataModify($TableName,$Fields,$Values,$IdentifyField,$IdentifyFieldValue)
    {
      $FieldsPiece=explode(",",$Fields);
      $ValuesPiece=explode(",",$Values);
      for($count=0;$ValuesPiece[$count];$count++)
	$ComponentPiece[$count]=$FieldsPiece[$count]."=".$ValuesPiece[$count];
      $UpdateFields=str_replace($FieldsPiece,$ComponentPiece,$Fields);
      $sql="update $TableName set $UpdateFields where $IdentifyField='$IdentifyFieldValue'";
      $this->db->query($sql);
      echo "<script language='javascript'>window.location='".$_SERVER["PHP_SELF"]."?$IdentifyField=$IdentifyFieldValue'</script>";
    }
  
  function DataDelete($TableName,$BackHref,$IdentifyField="")
    {
      $IdentifyField=$IdentifyField?$IdentifyField:$this->IdentifyField;
      if(is_array($_POST["select"]))
	{
	  for($count=0;$IdentifyFieldValue=$_POST["select"][$count];$count++)
	    {
	      $sql="delete from $TableName where $IdentifyField='$IdentifyFieldValue'";
	      $this->db->query($sql);
	    }
	}
      else
	{
	  $IdentifyFieldValue=$_GET[$IdentifyField];
	  $sql="delete from $TableName where $IdentifyField='$IdentifyFieldValue'";
	  $this->db->query($sql);
	}
      echo "<script language='javascript'>window.location='$BackHref'</script>";
    }
  
  function DataOperate($sql,$BackHref,$IdentifyField="")
    {
      $IdentifyField=$IdentifyField?$IdentifyField:$this->IdentifyField;
      if(is_array($_POST["select"]))
	{
	  for($count=0;$IdentifyFieldValue=$_POST["select"][$count];$count++)
	    {
	      $sqltmp=$sql." where $IdentifyField='$IdentifyFieldValue'";
	      $this->db->query($sqltmp);
	    }
	}
      else
	{
	  $IdentifyFieldValue=$_GET[$IdentifyField];
	  $sql.=" where $IdentifyField='$IdentifyFieldValue'";
	  $this->db->query($sql);
	}
      echo "<script language='javascript'>window.location='$BackHref'</script>";
    }
  
  function GenerateUploadHref($TableName,$SourceField,$PathField,$SourceFieldValue="",$UploadPage="upload.php")
    {
      //In this function,the program should delete the useless
      //information about upload and the files with it first.
      
      $sql="select * from $TableName where $SourceField<=0";
      $res=$this->db->query($sql);
      if($this->db->num_rows($res)>0)
	{
	  while($list=$this->db->fetch_array($res))
	    unlink($list[$PathField]);
	  $sql="delete from $TableName where $SourceField<=0";
	  $this->db->query($sql);
	}
      
      if($SourceFieldValue=="")
	{
	  $RandomID=rand(-32768,-1);
	  echo "<a href='$UploadPage?$SourceField=$RandomID' target='_blank'>Upload</a><br>";
	  echo "<font color=#FF0000>Caution:After uploading,you should NOT refresh this page,or the file you uploaded may disappear!</font>";
	}
      else
	{
	  echo "<a href='$UploadPage?$SourceField=$SourceFieldValue' target='_blank'>Upload</a><br>";
	  echo "<font color=#FF0000>Caution:After uploading,you should NOT refresh this page,or the file you uploaded may disappear!</font>";
	}
    }
}

class Upload
{
  var $FileLimit;
  var $Path="upload/";
  var $FileNameMethod="UNIX";
  var $TableAndField;
  var $IdentifyField;
  var $SourceField;
  var $SourceFieldValue;
  var $db;
  
  function Upload($SourceFieldValue,$FileLimit,$TableAndField,$SourceField="aid",$IdentifyField="id")
    {
      $this->SourceFieldValue=$SourceFieldValue;
      $this->FileLimit=$FileLimit;
      $this->TableAndField=$TableAndField;
      $this->IdentifyField=$IdentifyField;
      $this->SourceField=$SourceField;
      $this->db=new mysql;
    }
  
  function SetPath($Path)
    {
      $this->Path=$Path;
    }
  
  function SetFileNameMethod($FileNameMethod)
    {
      $this->FileNameMethod=$FileNameMethod;
    }
  
  function Output($sql,$FileNameField="filename")
    {
      if($this->SourceFileValue<0)$sql.=" where $this->SourceField<=0";
      else $sql.=" where $this->SourceField=$this->SourceFieldValue";
      $res=$this->db->query($sql);
      echo "<Form method='post' enctype='multipart/form-data' name='form1'>";
      echo "<Table>";
      echo "<Tr><Td>";
      echo "<input type='File' name='File'>";
      echo "<input type='submit' value='Paste' name='Paste' onclick=\"return CheckUploadFile('$this->FileLimit',document.form1.File)\">";
      echo "</Td></Tr>";
      echo "<Tr><Td>";
      echo "<select name='select' size='10'>";
      if($this->db->num_rows($res)==0)
	echo "<option value='0'>---No Items---</option>";
      else
	while($list=$this->db->fetch_array($res))
	  echo "<option value='".$list[$this->IdentifyField]."'>$list[$FileNameField]</option>";
      echo "</Td></Tr>";
      echo "<Tr><Td>";
      echo "<input type='submit' name='Delete' value='Delete' onclick=\"return confirm('Are you sure?')\">";
      echo "<input type='button' name='Finish' value='Finish' onclick='self.close()'>";
      echo "</Td></Tr>";
      echo "</Table>";
      echo "</Form>";
    }
  
  function GenerateFileName()
    {
      switch($this->FileNameMethod)
	{
	case "UNIX":return date("U");

	case "DATETIME":return date("Ymdhis");
	  //This method hasn't tested.
	}
    }
  
  function UploadFile()
    {
      
      //According to the file name and the path to upload,
      //the program can automatically generate a new file
      //name and move it to the upload directory.
      
      $UploadDir = $this->Path."$this->FileLimit/";
      
      //Check whether the directory is exist.
      //If NOT create such a directory for upload files.
      if(!is_dir($UploadDir))mkdir($UploadDir);
      
      //With RegExp,the program rename,the function GenerateFileName(),
      //the file which is uploaded.
      if(preg_match('/([^\.]+)\.(...)$/i',$_FILES["File"]["name"],$match))
	$FileExtend=$match[2];
      $UploadFile = $UploadDir.$this->GenerateFileName().".".$FileExtend;
      
      move_uploaded_file($_FILES['File']['tmp_name'], $UploadFile);
      
      //After uploading the file to the server,
      //the program must insert the information
      //to the database on the server.
      
      $sql="insert into $this->TableAndField values('$UploadFile','".$_FILES[File][name]."','$this->SourceFieldValue')";
      $this->db->query($sql);
      echo "<script language='javascript'>window.location='".$_SERVER["PHP_SELF"]."?$this->SourceField=$this->SourceFieldValue'</script>";
    }
  
  function DeleteFile($TableName,$PathField,$IdentifyFieldValue)
    {
      $sql="select * from $TableName where $this->IdentifyField='$IdentifyFieldValue'";
      $res=$this->db->query($sql);
      while($list=$this->db->fetch_array($res))
	unlink($list[$PathField]);
      $sql="delete from $TableName where $this->IdentifyField='$IdentifyFieldValue'";
      $this->db->query($sql);
      echo "<script language='javascript'>window.location='".$_SERVER["PHP_SELF"]."?$this->SourceField=$this->SourceFieldValue'</script>";
    }
}
?>

⌨️ 快捷键说明

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