Home Backend Development PHP Tutorial PHPCMS does not display the left menu corresponding to the unauthorized column_PHP tutorial

PHPCMS does not display the left menu corresponding to the unauthorized column_PHP tutorial

Jul 13, 2016 am 10:34 AM
phpcms menu

PHPCMS can set permissions for certain roles. For example, some columns are inaccessible to certain roles. However, the left menu will still display the column name, which is not necessary for editors. Even if you can’t access it, why is the column name still displayed? After looking at the PHPCMS code, I simply implemented the small function of hiding the menu.

It can be easily analyzed from the background page that the left menu is generated using Ajax:

$.ajax(
{	
	type:'get', 
	url:'?mod=phpcms&file=menu&action=get_menu_list&menuid='+id, 
	cache:cache_refresh,
	dataType:'json', 
	success:function(json)
	{
		……
	}
}
Copy after login

The requested address is http://www.bkjia.com/admin.php?mod=phpcms&file=menu&action=get_menu_list&menuid=4

In the URL parameters, file refers to the requested controller file, here menu refers to the file admin/menu.inc.php, and action refers to the method. We find the get_menu_list method under menu.inc.php:

case 'get_menu_list':
	$data = $m->get_child($menuid);
	$data = str_charset(CHARSET, 'utf-8', $data);
	$max = array_slice($data, -1);
	$data['max'] = $max[0]['menuid'];
	$data = json_encode($data);
	if(PHP_OS < 5.0) header('Content-type: text/html; charset=utf-8');
	echo $data;
	break;
Copy after login

Change it to:

case 'get_menu_list':
	$data = $m->get_child($menuid);
	
	foreach($data as $k=>$val)
	{
		if( !empty($data[$k]['keyid']) && substr( $data[$k]['keyid'], 0, 5 ) == 'catid' )
		{
			if( $data[$k]['keyid'] == 'catid_0' )
			{
				continue;
			}
			$catid = str_replace("catid_", "", $data[$k]['keyid']);
			
			// 管理权限
			$allow_manage = $priv_role->check('catid', $catid, 'manage');
			
			if(!$allow_manage)
			{
				unset($data[$k]);
			}
		}
	}
	
	$data = str_charset(CHARSET, 'utf-8', $data);
	$max = array_slice($data, -1);
	$data['max'] = $max[0]['menuid'];
	$data = json_encode($data);
	if(PHP_OS < 5.0) header('Content-type: text/html; charset=utf-8');
	echo $data;
	break;
Copy after login

The code is speculative, but the general idea is this.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/752363.htmlTechArticlePHPCMS can set permissions for certain roles. For example, certain columns are inaccessible to certain roles. However, the left menu will still display the column name, which is unnecessary for editors...
Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Windows 11: The easy way to import and export start layouts Windows 11: The easy way to import and export start layouts Aug 22, 2023 am 10:13 AM

In Windows 11, the Start menu has been redesigned and features a simplified set of apps arranged in a grid of pages, unlike its predecessor, which had folders, apps, and apps on the Start menu. Group. You can customize the Start menu layout and import and export it to other Windows devices to personalize it to your liking. In this guide, we’ll discuss step-by-step instructions for importing Start Layout to customize the default layout on Windows 11. What is Import-StartLayout in Windows 11? Import Start Layout is a cmdlet used in Windows 10 and earlier versions to import customizations for the Start menu into

How to Default 'Show More Options' in Windows 11's Right-Click Menu How to Default 'Show More Options' in Windows 11's Right-Click Menu Jul 10, 2023 pm 12:33 PM

One of the most annoying changes that we users never want is the inclusion of "Show more options" in the right-click context menu. However, you can remove it and get back the classic context menu in Windows 11. No more multiple clicks and looking for these ZIP shortcuts in context menus. Follow this guide to return to a full-blown right-click context menu on Windows 11. Fix 1 – Manually adjust the CLSID This is the only manual method on our list. You will adjust specific keys or values ​​in Registry Editor to resolve this issue. NOTE – Registry edits like this are very safe and will work without any issues. Therefore, you should create a registry backup before trying this on your system. Step 1 – Try it

How to edit messages on iPhone How to edit messages on iPhone Dec 18, 2023 pm 02:13 PM

The native Messages app on iPhone lets you easily edit sent texts. This way, you can correct your mistakes, punctuation, and even autocorrect wrong phrases/words that may have been applied to your text. In this article, we will learn how to edit messages on iPhone. How to Edit Messages on iPhone Required: iPhone running iOS16 or later. You can only edit iMessage text on the Messages app, and then only within 15 minutes of sending the original text. Non-iMessage text is not supported, so they cannot be retrieved or edited. Launch the Messages app on your iPhone. In Messages, select the conversation from which you want to edit the message

Implementation steps of implementing menu navigation bar with shadow effect using pure CSS Implementation steps of implementing menu navigation bar with shadow effect using pure CSS Oct 16, 2023 am 08:27 AM

The steps to implement a menu navigation bar with shadow effect using pure CSS require specific code examples. In web design, the menu navigation bar is a very common element. By adding a shadow effect to the menu navigation bar, you can not only increase its aesthetics, but also improve the user experience. In this article, we will use pure CSS to implement a menu navigation bar with a shadow effect, and provide specific code examples for reference. The implementation steps are as follows: Create HTML structure First, we need to create a basic HTML structure to accommodate the menu navigation bar. by

How to disable the Show more options menu in Windows 11 How to disable the Show more options menu in Windows 11 Apr 13, 2023 pm 08:10 PM

More and more people are experiencing the new and improved Microsoft operating system, but it seems that some of them still prefer the old-school design. There's no doubt that the new context menu brings impressive consistency to Windows 11. If we consider Windows 10, the fact that each application has its own context menu element creates serious confusion for some people. From the Windows 11 transparent taskbar to the rounded corners, this operating system is a masterpiece. In this matter, users across the globe are interested to know how to quickly disable Windows 11 Show More Options menu. The process is pretty simple, so if you're in the same boat, make sure you check it out completely

How to remove the 'Open in Windows Terminal' option from the right-click context menu in Windows 11 How to remove the 'Open in Windows Terminal' option from the right-click context menu in Windows 11 Apr 13, 2023 pm 06:28 PM

By default, the Windows 11 right-click context menu has an option called Open in Windows Terminal. This is a very useful feature that allows users to open Windows Terminal at a specific location. For example, if you right-click on a folder and select the "Open in Windows Terminal" option, Windows Terminal will launch and set that specific location as its current working directory. Although this is an awesome feature, not everyone finds a use for this feature. Some users may simply not want this option in their right-click context menu and want to remove it to tidy up their right-click context menu.

What framework is phpcms? What framework is phpcms? Apr 20, 2024 pm 10:51 PM

PHP CMS is a PHP-based open source content management system for managing website content. Its features include ease of use, powerful functionality, scalability, high security, and free open source. It can save time, improve website quality, enhance collaboration and reduce development costs, and is widely used in various websites such as news websites, blogs, corporate websites, e-commerce websites and community forums.

How to jump to the details page in phpcms How to jump to the details page in phpcms Jul 27, 2023 pm 05:23 PM

How to jump to the details page in phpcms: 1. Use the header function to generate a jump link; 2. Loop through the content list; 3. Get the title and details page link of the content; 4. Generate a jump link.

See all articles