Share the permissions of frame-based web systems, especially for large projects and two development projects, how to handle

Source: Internet
Author: User
Sharing of permission handling for frame-based web systems, especially for large projects and two development projects


Users table is the user table, you can store tens of thousands of users also do not matter, the following groupid is 1 is the administrator rights, 2 is the visitor rights



The model table stores the name of each method of the framework, and the following group is the set collection type, which represents which group has this permission

Nonsense not much to say, look at the example code

PHP Code
  
  Find ("User", "string", "user="). $user. "'");                        $group _tmp= $data ["GroupID"];         $this->show ($group _tmp);             Public function Show ($group _tmp) {$list = $this->find ("Model", "string", "func= ' Show '");                  $sql = "SELECT * from model where func= ' show ' and Find_in_set (". $group _tmp. ",". $list [' group ']. ");                 if (Mysql_num_rows (mysql_query ($sql))) {echo "permission passed";             Handle the following content}else{echo "no permission"; }} Public Function ShowAll ($group _tmp) {$list = $this->find ("Model", "string", "func= ' ShowAll '             ");                   $sql = "SELECT * from model where func= ' ShowAll ' and Find_in_set (". $group _tmp. ",". $list [' group ']. ");                 if (Mysql_num_rows (mysql_query ($sql))) {echo "permission passed";             Handle the following content}else{echo "no permission"; }}}?>




Welcome reference ...

------Solution--------------------
The model table needs to be given the model name, otherwise the different model's same name method cannot be distinguished
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.