tp3.2登录退出

public function index(){
      if(IS_POST){
          $admin=D('Admin');
          if($admin->create($_POST,4)){
            //   dump($admin->create($_POST,4));
            //   die;
              if($admin->login()){
                  $this->success('登陆成功',U('Index/index'));
              }else{
                  $this->error('用户名或密码错误!');
              }
          }else{
              $this->error($admin->getError());
          }
          return ;
        }
        $this->display();
    }

这个是登录控制器里面的方法,用于接收登录界面传来的账号和密码,$admin->create($_POST,4)为什么用4呢,因为在管理员这个控制器里面时,有model模型,有添加数据,编辑数据,还有所有情况的附加条件,而登录这是第四种气矿防止进行自动验证,重点是login()这个方法的编写,转到admin这个模块里面

public function login(){
        $password = $this->password;
        // dump($this->username);
        // die;
        $data['username']=$this->username;
        $info = $this->where($data)->find();
        // dump($info);
        // die;
        if($info){
            if($info['password']==md5($password)){
                session('id',$info['id']);
                session('username',$info['username']);
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }

$this->password代表前台接受的密码,$this->username代表接受前台的账号,然后记录在data数组里面然后查询¥admin里面username=$this->username这一行的数据,

如果¥info这个数据不为空说明存在这个账号否则不存在返回false,如果摩玛等于加密之后的密码,name就把这个账号存在session数组里面

突出的话也很贱蛋清除session里面的值就行了

public function layout(){
        session(null);
        $this->redirect('Login/index');
    }


但是我只是想要收集DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND数据库的数据然后利用CLI完成配置收集,其他的东西可以不用,现在把我的配置收集函数进行完善 static APPL_ERRCODE _addressreservation_cli_collectGlobal(TPCONFIG_COLLECTFUN_INPUT_T *pInput) { DBG_ALZ("Starting DHCP configuration collection (revised structure)"); // 1. 首先检查POOL迭代器是否存在 if (pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL] == NULL) { DBG_ALZ("No DHCP pools found"); return ERR_NO_ERROR; } // 2. 遍历所有地址池 TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]) { DHCP_POOL_PARAM poolParam = {0}; char poolKey[256] = {0}; char *pStr = NULL; // 2.1 获取当前池的键名 char *pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]); if (!pKey) { DBG_ALZ("Skipping NULL pool key"); continue; } strncpy(poolKey, pKey, sizeof(poolKey)-1); // 2.2 解析池名 if (sscanf(poolKey, UC_DS_POOL_TBL_FMT, poolParam.name) != 1) { DBG_ALZ("Failed to parse pool key: %s", poolKey); continue; } // 2.3 输出池配置头 char outBuf[DHCPS_MAX_CLI_STR_LEN] = {0}; snprintf(outBuf, sizeof(outBuf), "ip dhcp server pool \"%s\"", poolParam.name); tpConfig_outputToSdsForCli(pInput->regionId, 0, outBuf, TPCONFIG_HEADSPACE_YES); // 2.4 处理池的基本配置(网络、租期等)- 省略简化 // 3. 处理当前池的静态绑定 if (pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND] != NULL) { DBG_ALZ("Processing manual binds for pool: %s", poolParam.name); // 3.1 重置手动绑定迭代器 tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]); // 3.2 遍历所有手动绑定条目 TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]) { char *bindKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]); if (!bindKey) { DBG_ALZ("Skipping NULL bind key"); continue; } // 3.3 解析绑定键名(格式:UC_DS_MANUAL_BIND_ENTRY:<poolname>|<ip>) char bindPoolName[DHCPS_POOLNAME_LEN] = {0}; UINT32 bindIp = 0; char parseKey[256] = {0}; strncpy(parseKey, bindKey, sizeof(parseKey)-1); if (dhcpPoolAboutKeyNameParse(parseKey, UC_DS_MANUAL_BIND_ENTRY_FMT, bindPoolName, &bindIp) != APPL_ERR_OK) { DBG_ALZ("Failed to parse bind key: %s", bindKey); continue; } // 3.4 检查是否属于当前池 if (strcmp(bindPoolName, poolParam.name) != 0) { DBG_ALZ("Bind not for current pool (%s != %s)", bindPoolName, poolParam.name); continue; } // 3.5 处理绑定条目 MANUAL_BINDING bind = {0}; strncpy(bind.poolName, bindPoolName, sizeof(bind.poolName)); bind.ip.s_addr = bindIp; // 3.6 获取绑定字段值 TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]) { if (tpConfig_IterGetNumI8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], (INT8*)&bind.bindType, bindKey, UC_DS_MANUAL_BIND_BINDTYPE) == PFM_ERR_C_OK) { DBG_ALZ("Bind type: %d", bind.bindType); } if (tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &pStr, bindKey, UC_DS_MANUAL_BIND_MAC) == PFM_ERR_C_OK) { strncpy(bind.macStr, pStr, sizeof(bind.macStr)-1); } if (tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &pStr, bindKey, UC_DS_MANUAL_BIND_CLIENT_ID_STR) == PFM_ERR_C_OK) { strncpy(bind.cidStr, pStr, sizeof(bind.cidStr)-1); } } // 3.7 生成CLI命令 char ipStr[IP_ADDRESS_LENGTH] = {0}; Ipv4Int2Str(bind.ip.s_addr, ipStr); memset(outBuf, 0, sizeof(outBuf)); if (bind.bindType == ETHERNET_BIND || bind.bindType == IEEE802_BIND) { snprintf(outBuf, sizeof(outBuf), "address %s hardware-address %s %s", ipStr, bind.macStr, (bind.bindType == ETHERNET_BIND) ? "ethernet" : "ieee802"); } else if (bind.bindType == CLIENT_ID_ASCII || bind.bindType == CLIENT_ID_HEX) { char escapedCid[256] = {0}; escape_string(bind.cidStr, escapedCid, sizeof(escapedCid)); snprintf(outBuf, sizeof(outBuf), "address %s client-identifier %s\"%s\"", ipStr, (bind.bindType == CLIENT_ID_ASCII) ? "ascii " : "", escapedCid); } // 3.8 输出绑定配置 if (outBuf[0] != &#39;\0&#39;) { tpConfig_outputToSdsForCli(pInput->regionId, 0, outBuf, TPCONFIG_HEADSPACE_YES); } } // 3.9 重置迭代器以备后续使用 tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]); } // 4. 处理其他池级配置(范围、DNS等)- 省略简化 // 5. 关闭当前池视图 tpConfig_outputToSdsForCli(pInput->regionId, 0, "exit", TPCONFIG_HEADSPACE_YES); } // 6. 重置POOL迭代器 tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]); return ERR_NO_ERROR; }
最新发布
11-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值