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

📄 cmssys.php

📁 为我们学校开发的一个住房货币化补贴工作的专题网站
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?
session_start();
//////////////////////////////////////////
//           Simple CMS system 
//  This file is named CMSSYS which is de-
//sign to generate simple and common CMS 
//system.
//  It has three mainly classes--one cont-
//rol the display of the front webpages;a-
//nother one creates the usual admin syst-
//em;And the last one is responsible for
//the uploading module.
//  Any classes or functions can be added,
//but I'd like you to send me a copy and
//you can add your own version information
//in the front of this file.
//
//
//                           Created by Q
//                            Dec-1-2006
//                              CQUPT
//                        Last Modify Date
//                           Dec-5-2006
//                         Modify Version
//                               1.0
//                         Last Test Date
//                           Dec-5-2006
//////////////////////////////////////////
include "mysql.php";
include "setpage.php";
include "function.js";
class FrontData
{
  var $sql;
  var $NumLimit;
  var $PageNumLimit;
  var $TotalNum;
  var $SetPageFlag=false;
  var $Field;
  var $TablePara;
  var $TdPara;
  var $PrefixString;
  var $PrefixImage;
  var $PageNum;
  var $db;
  var $pg;
  
  function FrontData($sql,$NumLimit=0)
    {
      $this->sql=$sql;
      $this->NumLimit=$NumLimit;
      $this->db=new mysql;
      $this->pg=new page;
    }
  
  function SetPrefixString($PrefixString)
    {
      $this->PrefixString=$PrefixString;
    }
  
  function SetPrefixImage($PrefixImage)
    {
      $this->PrefixImage=$PrefixImage;
    }
  
  function SetSQL($sql)
    {
      $this->sql=$sql;
    }
  
  function SetNumLimit($NumLimit)
    {
      $this->NumLimit=$NumLimit;
    }

  function SetLink($Field,$LinkHref,$DistinctField)
    {
      //Set the links and the distinct fields for each field.
      $this->Field[$Field]=$LinkHref;
      $this->DistinctField[$Field]=$DistinctField;
    }
  
  function SetTablePara($TablePara)
    {
      $this->TablePara=$TablePara;	
    }
  
  function SetTdPara($Field,$TdPara)
    {
      $this->TdPara[$Field]=$TdPara;
    }  
  
  function SetPageLimit($PageNumLimit,$PageNum=1)
    {
      
      //With Page class,this function collects the necessary information about pages.
      //The global varibles--SetPageFlag,TotalNum,sql,PageNumLimit have recorded
      //some PAGE information which the other functions may use.
      //SetPageFlag:A boolean varible which means whether this function has been invoked
      //PageNumLimit:The max number of records per page.
      //TotalNum:The total number of records.
      //sql:The SQL sentence.
      
      $PageNum=$PageNum>0?$PageNum:1;
      $this->SetPageFlag=true;
      $this->PageNumLimit=$PageNumLimit;
      if($this->SetPageFlag==true)
	$this->TotalNum=$this->db->num_rows($this->db->query($this->sql));
      $this->pg->SetValue($this->TotalNum,$this->PageNumLimit,$PageNum);
      $this->sql=$this->pg->limit($this->sql);
    }
  
  function PageControl()
    {

      //Echo the previous page.
      $this->pg->pre();
      echo "&nbsp;&nbsp;";

      //Echo the page number link.
      $this->pg->PageClick();
      echo "&nbsp;&nbsp;";

      //Echo the next page.
      $this->pg->next();
      echo "&nbsp;&nbsp;";

      //Echo the total number of pages.
      echo "Total ".$this->pg->GetMax()." Pages";
    }
  
  function Output()
    {
      $res=$this->db->query($this->sql);
      echo "<Table $this->TablePara>";
      for($count=0;($list=$this->db->fetch_array($res))&&($count<$this->NumLimit||$this->NumLimit==0);$count++)
	{
	  echo "<Tr>";
	  echo "<Td>";

	  //Echo prefix string or image of the records.
	  if($this->PrefixString!="")
	    echo $this->PrefixString;
	  if($this->PrefixImage!="")
	    echo "<img src='".$this->PrefixImage."'>";
	  
	  echo "</Td>";

	  //Echo the records with detail information.
	  foreach($list as $element => $value)
	    {
	      $DistinctFieldFlag=0;
	      foreach($this->DistinctField as $DistinctElement => $DistinctFieldValue)
		if($element==$DistinctFieldValue)
		  {
		    $DistinctFieldFlag=1;
		    break;
		  }
	      if($DistinctFieldFlag==1)continue;
	      $Distinct="?".$this->DistinctField[$element]."=".$list[$this->DistinctField[$element]];
	      echo "<Td ".$this->TdPara[$element].">";
	      if($this->Field[$element]!="")
		$value="<a href='".$this->Field[$element]."$Distinct'>$value</a>";
	      
	      echo $value;
	      echo "</Td>";		
	    }
	  
	  echo "</Tr>";
	}
      echo "</Table>";

      //If the SetPageFlag is true,echo the page controller.
      if($this->SetPageFlag==true&&$this->TotalNum/$this->PageNumLimit>1)
	{
	  echo "<Table><Tr><Td>";
	  $this->PageControl();
	  echo "</Td></Tr></Table>";
	}
    }
}

class AdminData
{
  var $db;
  var $pg;
  var $PageNumLimit;
  var $TotalNum;
  var $SetPageFlag=false;
  var $Field;
  var $ModifyHref;
  var $OperateHref;
  var $NewHref;
  var $IdentifyField;
  var $AdditionOperate;
  var $sql;
  
  function AdminData($sql="select * from admin",$IdentifyField="id",$NewHref="new.php",$ModifyHref="modify.php",$OperateHref="operate.php")
    {
      $this->db=new mysql;
      $this->pg=new page;
      $this->sql=$sql;
      $this->IdentifyField=$IdentifyField;
      $this->ModifyHref=$ModifyHref;
      $this->OperateHref=$OperateHref;
      $this->NewHref=$NewHref;
    }
  
  function SetIdentifyField($IdentifyField)
    {
      $this->IdentifyField=$IdentifyField;
    }
  
  function SetModifyHref($ModifyHref)
    {
      $this->ModifyHref=$ModifyHref;
    }
  
  function SetOperateHref($OperateHref)
    {
      $this->OperateHref=$OperateHref;
    }

  function SetAdditionOperate($Operate,$Link,$OperateAll="false")
    {
      //Set the addition operation,such as ShowNews,HideNews
      $Link=$Link?$Link:$this->OperateHref;
      $this->AdditionOperate[$Operate]=$Link;
      $this->OperateAll[$Operate]=$OperateAll;
    }
  
  function SetSQL($sql)
    {
      $this->sql=$sql;
    }
  
  function SetPageLimit($PageNumLimit,$PageNum=1)
    {
      //With Page class,this function collects the necessary information about pages.
      //The global varibles--SetPageFlag,TotalNum,sql,PageNumLimit have recorded
      //some PAGE information which the other functions may use.
      //SetPageFlag:A boolean varible which means whether this function has been invoked
      //PageNumLimit:The max number of records per page.
      //TotalNum:The total number of records.
      //sql:The SQL sentence.
      
      $PageNum=$PageNum>0?$PageNum:1;
      $this->SetPageFlag=true;
      $this->PageNumLimit=$PageNumLimit;
      $this->TotalNum=$this->db->num_rows($this->db->query($sql));
      $this->pg->SetValue($this->TotalNum,$this->PageNumLimit,$PageNum);
      $this->sql=$this->pg->limit($this->sql);
    }
  
  function PageControl()
    {
      //Echo the previous page.
      $this->pg->pre();
      echo "&nbsp;&nbsp;";

      //Echo the page number link.
      $this->pg->PageClick();
      echo "&nbsp;&nbsp;";

      //Echo the next page.
      $this->pg->next();
      echo "&nbsp;&nbsp;";

      //Echo the total number of pages.
      echo "Total ".$this->pg->GetMax()." Pages";

⌨️ 快捷键说明

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