search
HomeBackend DevelopmentPHP Tutorial求PHP网站靠山管理 管理员 权限控制 系统方案

求PHP网站后台管理 管理员 权限控制 系统方案
小弟现在做一个网站后台,包括文章上传模块,供下载的文件上传,用户留言模块等。
问题:后台管理员权限分配

说明:现在系统有一个超级管理员,具有所有权限。现在想实现:超级管理员可以添加一般管理员,并且可以控制一般管理员的权限。比如控制某个一般用户只能上传文章,而不能上传图片等等,这该如何实现?求个思路,有源码实例更好啦!

另外,系统可能新增加其他模块(比如新增一个 图片上传模块等等),在新增了后台模块后,如何方便的配置原有管理员账号关于新增模块的相关权限? 

可能说的不太清楚,有问题欢迎跟帖!

最高只能给100分,不知能不能加分了!


------解决方案--------------------
每个权限都需要加一个标记。

如:

发布贴子 1

添加管理员 2

图片上传 3

...........

如用户具备已上三个权限

存记数据库,是数组,(1;2;3)

用户只具备发布贴子权限 (2;)

具备发布贴子和图片上传权限 (2;3;)

...........

判断是否助有权限时,查找是否包含就行。。

不知我是明白??
------解决方案--------------------
建立一个模块表。如果对该模块有操作权利,为1.否则.0


 1 0 1 1.很灵活的使用
------解决方案--------------------
建立一个模块表,模快表里面有个admin_group_id,记录那些是管理员可以看到的,那些是用户的..那一目了然比如
用户模快 1,3 --1表示最高管理员,3表示用户
上传模块 1,2 --1表示最高管理员,2表示一般管理员
------解决方案--------------------
建立一个模块表,模快表里面有个admin_group_id,记录那些是管理员可以看到的,那些是用户的..那一目了然比如
用户模快 1,3 --1表示最高管理员,3表示用户
上传模块 1,2 --1表示最高管理员,2表示一般管理员
------解决方案--------------------
phpgacl
------解决方案--------------------

探讨
每个权限都需要加一个标记。

如:

发布贴子 1

添加管理员 2

图片上传 3

...........

如用户具备已上三个权限

存记数据库,是数组,(1;2;3)

用户只具备发布贴子权限 (2;)

具备发布贴子和图片上传权限 (2;3;)

...........

判断是否助有权限时,查找是否包含就行。。

不知我是明白??

------解决方案--------------------
上面的多是简单权限
复杂的看权限角色模型,网上搜一下
------解决方案--------------------
使用组很方便

组表:
组id/组名
1/组1
2/组2
…………

权限表:
权限id/权限名
1/权限1
2/权限2
3/权限3
…………

组 权限关联表:
组id/权限id
1/1
1/2
2/2
2/4
…………

随意搭配,组1可能就是你的超管,组2是普管,你新建个组3,搭配一下,就是普通用户。新建组4,可能就是受限用户
------解决方案--------------------
看看dedecms的权限管理吧 我就是模仿的那种 我觉得非常灵活
------解决方案--------------------
探讨
谢谢各位的意见.

还有个问题:如果系统新增加其他模块(比如新增一个 图片上传模块等等),在新增了后台模块后,如何方便的配置原有管理员账号关于新增模块的相关权限?

------解决方案--------------------
我前两天也在弄这个权限问题,

自己设计了几个表

在zend auth下面使用的,搂主可以参考一下

/*角色表
-- id
-- 用户名
-- 密码
-- 工作组 A,B,C...
*/
DROP TABLE IF EXISTS role_acl;
CREATE TABLE role_acl (
id int(11) NOT NULL auto_increment,
username varchar(30) NOT NULL,
password varchar(20) NOT NULL,
work_group char(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*工作组
-- id
-- 工作组 A,B,C...
-- 文字描述
*/
DROP TABLE IF EXISTS group_acl;
CREATE TABLE group_acl (
id int(11) NOT NULL auto_increment,
work_group char(1) NOT NULL,
group_desc varchar(60) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/* 角色 资源 动作 映射表
-- id
-- 工作组 A,B,C...
-- 资源代码
*/
DROP TABLE IF EXISTS mapped_acl;
CREATE TABLE mapped_acl (
id int(11) NOT NULL auto_increment,
work_group varchar(1) NOT NULL,
resource varchar(20) NOT NULL,
action varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.