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

📄 popedominformation.class.php

📁 简单的权限管理系统
💻 PHP
字号:
<?php


	/*
	 * @(#)PopedomInformation.class.php 1.0 05/05/17
	 *
	 * Copyright 2005 Garfield.Huang
	 */


	/**
	* <b>权限信息处理程序</b><br>
	* @author	Garfield.Huang
	* @version	1.0 05/05/17
	* @since   	PHP 5.0.3
	*/
	
	
	class PopedomInformation {
	
	/**
	* 传入的数据库句柄
	*/
	var $db;
	
	/**
	* 得到的结果集
	*/
	var $resultSet;
	
	
	/**
	* 增加权限类别
	* @return	boolean	操作成功返回true
	*/
		
	function append ()
	{
		
			$sqlL = "insert into popedom_info (";
			$sqlR = "values (";
						
			//权限名称
			$sqlL .= "popedomname,";
			$sqlR .= "'" . trim( $_POST["popedomname"] ) . "',";
			
			
			//权限代码
			$sqlL .= "popedomcode)";
			$sqlR .= "'" . $this->getNewPopedomCode() . "')";

			
			$this->db->query( $sqlL . $sqlR );

			return true;
			
	}
	
	
	/**
	* 修改权限类别
	* @return	boolean	操作成功返回true
	*/
	
	function edit ()
	{
		
			$sql = "update popedom_info set ";
			
			//权限名称
			$sql .= "popedomname='". trim( $_POST["popedomname"] ) ."'";
			$sql .= " where popedomcode = '" . trim( $_POST["popedomcode"] ) . "'";
			
			$this->db->query( $sql );
			
			return true;
			
	}
	
	
	/**
	* 删除权限类别
	* @return	boolean	操作成功返回true
	*/
	
	function del()
	{
		$sql = "delete from popedom_info where popedomcode='" . $_POST["popedomcode"] . "'";
		$this->db->query( $sql );
			
		return true;
			
	}
	
	
	/**
	* 得到当前数据库中的一个新的权限编码
	* @return	string	新的权限编码
	*/
	
	function getNewPopedomCode ()
	{
		if( "homology" != $_POST["level"] )
		{
			$level = "__";
		}
		
		$sql = "select max(popedomcode) as popedomcode from popedom_info where popedomcode like '";
		$sql .= $_POST["popedomcode"] . $level . "'";
		
		$this->db->query( $sql );
		$this->db->next_record();
		
		//当前是新层
		if( empty( $this->db->Record["popedomcode"] ) )
		{
			if( empty( $_POST["popedomcode"] ) )
			{
				return "10";
			}
			else{
				return $_POST["popedomcode"] . "00";
			}
		}
		
		$l_code = substr( $this->db->Record["popedomcode"], 0, strlen( $this->db->Record["popedomcode"] ) - 2 );
		$r_code = substr( $this->db->Record["popedomcode"], strlen( $this->db->Record["popedomcode"] ) - 2, 2 );
		
		if( 99 == intval( $r_code ) )
		{
			return "0";
		}
		
		$r_code = strval( intval( $r_code ) + 1 );
		
		if( strlen( $r_code ) < 2 )
		{
			$r_code = "0" . $r_code;
		}
		
		return $l_code . $r_code;
		
	}
	
	
	/**
	* 得到权限组菜单列表
	* @return	string	权限组菜单
	*/
	
	function getPopedomSelectList ()
	{
		$sql = "select * from popedom_info order by popedomcode asc";
		$this->db->query( $sql );
		
		$sl;
		while( $this->db->next_record() )
		{
			$sl .= "<option value=\"" . $this->db->Record["popedomcode"] . "\">";
			$sl .= $this->getIndent ( $this->db->Record["popedomcode"] );
			$sl .= $this->db->Record["popedomname"] . "</option>\n";
		}
		
		return $sl;
		
	}
	
	
	/**
	* 得到缩进长度
	* @return	string	缩进长度的空格
	*/
	
	function getIndent ( $popedomcode )
	{
		$s;
		$i = ( strlen( $popedomcode ) - 2 ) / 2;
			for( $j = 0; $j < $i; $j++ ){
				$s .= "&nbsp;&nbsp;";
			}
		return $s . "├-";
		
	}
	
	
	/**
	* 获取一个结果集
	* @param	$table_name	表名
	* @param	$flag_name	字段名
	* @param	$flag_value	字段值
	* @return	boolean		操作成功返回true
	*/
	
	function setResultSet( $table_name, $flag_name, $flag_value )
	{
		$sql = "select * from ". $table_name ." where ". $flag_name ." = '" . $flag_value . "'";

		$this->db->query( $sql );
		$this->db->next_record();
		$this->resultSet = $this->db->Record;
		
		return true;
	}
	
	
	/**
	* 获取当前结果集中某一字段的值
	* @param	$flag_name	字段名
	* @return	string		字段值
	*/
	
	function getResultSetValue ( $field_name )
	{
		return $this->resultSet[$field_name];
	}
	
	
	/**
	* 设置数据库句柄
	* @return	boolean	操作成功返回true
	*/
	
	function setDB ( $DB )
	{
		$this->db = $DB;
		
		return true;
	}
}

?>

⌨️ 快捷键说明

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