dongwu3747 2010-03-30 20:48
浏览 33
已采纳

保持管理页面管理数据库是否危险?

Hey guys I have an admin page that checks if you are admin before submitting any queries, and contains a header to the index page if you are not admin, but I am worried about protecting the page. I am concerned someone may be able to destroy my database with it. Does anyone have any recommendation into protecting a page like this, if not, should I just manually admin my database through phpmyadmin and delete the page all together?

Example

function isAdmin(){
      return ($this->userlevel == ADMIN_LEVEL ||
              $this->username  == ADMIN_NAME);
   }

 if(!$session->isAdmin()){
         header("Location: ../index.php");
         return;
      }

The admin value is stored in the database and represents ADMIN_LEVEL

  • 写回答

2条回答 默认 最新

  • dst8922 2010-03-30 20:53
    关注

    It's rather common for websites to have an administrators section, but you do have to make sure, on every page, before anything is inserted, removed, etc. that the user is an admin, something you are doing.

    However, having a page that lets you enter explicit SQL statements and executes them probably isn't a good idea. You could too easily enter something wrong, and it does leave a MUCH larger security hole, should something go wrong. Larger as in, easier to access system admin-level commands, depending on the setup.

    Not to mention the ease of messing something up yourself.

    Direct SQL queries is why you have phpMyAdmin. Admin sections are normally intended to be a GUI frontend of your data, just as the website for regular users is, but with a greater range of abilities. Such things as being able to list all users, edit a user's data through a controlled form, then updating or deleting them with a button.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题