Yii1.1 实现简单restful 框架

2023-05-16

学习了下php的rest服务,将总结记录如下。采用Yii1.1版本,Yii2已经专门有restful专题(ps:暂时没有学习)


1.先用Yii创建项目

2.创建数据库(rest)和表(rest_user)及对应模型(user)[脚手架创建]

CREATE TABLE `rest_user` (
  `id` int AUTO_INCREMENT COMMENT '用户账号',
  `name` char(32) NOT NULL COMMENT '用户姓名',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


INSERT INTO `rest_user` VALUES 
('1','考勤'),
('2','hu'),
('3','wang'),
('4','fan'),
('5','yuan');


3.在protected/config/main.php中配置路由

'urlManager'=>array(
		    'urlFormat'=>'path',
		    'showScriptName'=>false,//为优化URL去掉index.php入口文件名字准备
		    'rules'=>array(
		        'user/<id:\d+>/<title:.*?>'=>'user/view',
		        'users/<tag:.*?>'=>'users/index',
		        // REST patterns
		        array('api/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),
		        array('api/view', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'GET'),
		        array('api/update', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'PUT'),
		        array('api/delete', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'),
		        array('api/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST'),
		        // Other controllers
		        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
		    ),
		),

4.建立相关控制器处理rest请求(ApiController.php)

<?php

class ApiController extends Controller
{
    // {{{ *** Members ***
    /**
     * Key which has to be in HTTP USERNAME and PASSWORD headers 
     */
    Const APPLICATION_ID = 'ASCCPE';

    private $format = 'json';
    // }}} 
    // {{{ filters
    /**
     * @return array action filters
     */
    public function filters()
    {
            return array();
    } // }}} 
    // {{{ *** Actions ***
    // {{{ actionIndex
    public function actionIndex()
    {
        echo CJSON::encode(array(1, 2, 3));
    } // }}} 
    // {{{ actionList
    public function actionList()
    {
        $this->_checkAuth();
        switch($_GET['model'])
        {
            case 'users': // {{{ 
                $models = User::model()->findAll();
                break; // }}} 
            default: // {{{ 
                $this->_sendResponse(501, sprintf('Error: Mode <b>list</b> is not implemented for model <b>%s</b>',$_GET['model']) );
                exit; // }}} 
        }
        if(is_null($models)) {
            $this->_sendResponse(200, sprintf('No items where found for model <b>%s</b>', $_GET['model']) );
        } else {
            $rows = array();
            foreach($models as $model)
                $rows[] = $model->attributes;

            $this->_sendResponse(200, CJSON::encode($rows));
        }
    } // }}} 
    // {{{ actionView
    /* Shows a single item
     * 
     * @access public
     * @return void
     */
    public function actionView()
    {
        //$this->_checkAuth();
        // Check if id was submitted via GET
        if(!isset($_GET['id']))
            $this->_sendResponse(500, 'Error: Parameter <b>id</b> is missing' );
        var_dump($_GET['id']);
        var_dump($_GET['model']);
        switch($_GET['model'])
        {
            // Find respective model    
            case 'users': // {{{ 
                $model = User::model()->findByPk($_GET['id']);
                break; // }}} 
            default: // {{{ 
                $this->_sendResponse(501, sprintf('Mode <b>view</b> is not implemented for model <b>%s</b>',$_GET['model']) );
                exit; // }}} 
        }
        if(is_null($model)) {
            $this->_sendResponse(404, 'No Item found with id '.$_GET['id']);
        } else {
            $this->_sendResponse(200, $this->_getObjectEncoded($_GET['model'], $model->attributes));
        }
    } // }}} 
    // {{{ actionCreate
    /**
     * Creates a new item
     * 
     * @access public
     * @return void
     */
    public function actionCreate()
    {
        //$this->_checkAuth();

        switch($_GET['model'])
        {
            // Get an instance of the respective model
            case 'users': // {{{ 
                $model = new User;                    
                break; // }}} 
            default: // {{{ 
                $this->_sendResponse(501, sprintf('Mode <b>create</b> is not implemented for model <b>%s</b>',$_GET['model']) );
                exit; // }}} 
        }
        // Try to assign POST values to attributes
        foreach($_POST as $var=>$value) {
            // Does the model have this attribute?
            if($model->hasAttribute($var)) {
                $model->$var = $value;
            } else {
                // No, raise an error
                $this->_sendResponse(500, sprintf('Parameter <b>%s</b> is not allowed for model <b>%s</b>', $var, $_GET['model']) );
            }
        }
        // Try to save the model
        if($model->save()) {
            // Saving was OK
            $this->_sendResponse(200, $this->_getObjectEncoded($_GET['model'], $model->attributes) );
        } else {
            // Errors occurred
            $msg = "<h1>Error</h1>";
            $msg .= sprintf("Couldn't create model <b>%s</b>", $_GET['model']);
            $msg .= "<ul>";
            foreach($model->errors as $attribute=>$attr_errors) {
                $msg .= "<li>Attribute: $attribute</li>";
                $msg .= "<ul>";
                foreach($attr_errors as $attr_error) {
                    $msg .= "<li>$attr_error</li>";
                }        
                $msg .= "</ul>";
            }
            $msg .= "</ul>";
            $this->_sendResponse(500, $msg );
        }

        var_dump($_REQUEST);
    } // }}}     
    // {{{ actionUpdate
    /**
     * Update a single iten
     * 
     * @access public
     * @return void
     */
    public function actionUpdate()
    {
       // $this->_checkAuth();

        // Get PUT parameters
        parse_str(file_get_contents('php://input'), $put_vars);

        switch($_GET['model'])
        {
            // Find respective model
            case 'users': // {{{ 
                $model = User::model()->findByPk($_GET['id']);                    
                break; // }}} 
            default: // {{{ 
                $this->_sendResponse(501, sprintf('Error: Mode <b>update</b> is not implemented for model <b>%s</b>',$_GET['model']) );
                exit; // }}} 
        }
        if(is_null($model))
            $this->_sendResponse(400, sprintf("Error: Didn't find any model <b>%s</b> with ID <b>%s</b>.",$_GET['model'], $_GET['id']) );
        
        // Try to assign PUT parameters to attributes
        foreach($put_vars as $var=>$value) {
            // Does model have this attribute?
            if($model->hasAttribute($var)) {
                $model->$var = $value;
            } else {
                // No, raise error
                $this->_sendResponse(500, sprintf('Parameter <b>%s</b> is not allowed for model <b>%s</b>', $var, $_GET['model']) );
            }
        }
        // Try to save the model
        if($model->save()) {
            $this->_sendResponse(200, sprintf('The model <b>%s</b> with id <b>%s</b> has been updated.', $_GET['model'], $_GET['id']) );
        } else {
            $msg = "<h1>Error</h1>";
            $msg .= sprintf("Couldn't update model <b>%s</b>", $_GET['model']);
            $msg .= "<ul>";
            foreach($model->errors as $attribute=>$attr_errors) {
                $msg .= "<li>Attribute: $attribute</li>";
                $msg .= "<ul>";
                foreach($attr_errors as $attr_error) {
                    $msg .= "<li>$attr_error</li>";
                }        
                $msg .= "</ul>";
            }
            $msg .= "</ul>";
            $this->_sendResponse(500, $msg );
        }
    } // }}} 
    // {{{ actionDelete
    /**
     * Deletes a single item
     * 
     * @access public
     * @return void
     */
    public function actionDelete()
    {
      //  $this->_checkAuth();

        switch($_GET['model'])
        {
            // Load the respective model
            case 'users': // {{{ 
                $model = User::model()->findByPk($_GET['id']);                    
                break; // }}} 
            default: // {{{ 
                $this->_sendResponse(501, sprintf('Error: Mode <b>delete</b> is not implemented for model <b>%s</b>',$_GET['model']) );
                exit; // }}} 
        }
        // Was a model found?
        if(is_null($model)) {
            // No, raise an error
            $this->_sendResponse(400, sprintf("Error: Didn't find any model <b>%s</b> with ID <b>%s</b>.",$_GET['model'], $_GET['id']) );
        }

        // Delete the model
        $num = $model->delete();
        if($num>0)
            $this->_sendResponse(200, sprintf("Model <b>%s</b> with ID <b>%s</b> has been deleted.",$_GET['model'], $_GET['id']) );
        else
            $this->_sendResponse(500, sprintf("Error: Couldn't delete model <b>%s</b> with ID <b>%s</b>.",$_GET['model'], $_GET['id']) );
    } // }}} 
    // }}} End Actions
    // {{{ Other Methods
    // {{{ _sendResponse
    /**
     * Sends the API response 
     * 
     * @param int $status 
     * @param string $body 
     * @param string $content_type 
     * @access private
     * @return void
     */
    private function _sendResponse($status = 200, $body = '', $content_type = 'text/html')
    {
        $status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_getStatusCodeMessage($status);
        // set the status
        header($status_header);
        // set the content type
        header('Content-type: ' . $content_type);

        // pages with body are easy
        if($body != '')
        {
            // send the body
            echo $body;
            exit;
        }
        // we need to create the body if none is passed
        else
        {
            // create some body messages
            $message = '';

            // this is purely optional, but makes the pages a little nicer to read
            // for your users.  Since you won't likely send a lot of different status codes,
            // this also shouldn't be too ponderous to maintain
            switch($status)
            {
                case 401:
                    $message = 'You must be authorized to view this page.';
                    break;
                case 404:
                    $message = 'The requested URL ' . $_SERVER['REQUEST_URI'] . ' was not found.';
                    break;
                case 500:
                    $message = 'The server encountered an error processing your request.';
                    break;
                case 501:
                    $message = 'The requested method is not implemented.';
                    break;
            }

            // servers don't always have a signature turned on (this is an apache directive "ServerSignature On")
            $signature = ($_SERVER['SERVER_SIGNATURE'] == '') ? $_SERVER['SERVER_SOFTWARE'] . ' Server at ' . $_SERVER['SERVER_NAME'] . ' Port ' . $_SERVER['SERVER_PORT'] : $_SERVER['SERVER_SIGNATURE'];

            // this should be templatized in a real-world solution
            $body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
                        <html>
                            <head>
                                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                                <title>' . $status . ' ' . $this->_getStatusCodeMessage($status) . '</title>
                            </head>
                            <body>
                                <h1>' . $this->_getStatusCodeMessage($status) . '</h1>
                                <p>' . $message . '</p>
                                <hr />
                                <address>' . $signature . '</address>
                            </body>
                        </html>';

            echo $body;
            exit;
        }
    } // }}}            
    // {{{ _getStatusCodeMessage
    /**
     * Gets the message for a status code
     * 
     * @param mixed $status 
     * @access private
     * @return string
     */
    private function _getStatusCodeMessage($status)
    {
        // these could be stored in a .ini file and loaded
        // via parse_ini_file()... however, this will suffice
        // for an example
        $codes = Array(
            100 => 'Continue',
            101 => 'Switching Protocols',
            200 => 'OK',
            201 => 'Created',
            202 => 'Accepted',
            203 => 'Non-Authoritative Information',
            204 => 'No Content',
            205 => 'Reset Content',
            206 => 'Partial Content',
            300 => 'Multiple Choices',
            301 => 'Moved Permanently',
            302 => 'Found',
            303 => 'See Other',
            304 => 'Not Modified',
            305 => 'Use Proxy',
            306 => '(Unused)',
            307 => 'Temporary Redirect',
            400 => 'Bad Request',
            401 => 'Unauthorized',
            402 => 'Payment Required',
            403 => 'Forbidden',
            404 => 'Not Found',
            405 => 'Method Not Allowed',
            406 => 'Not Acceptable',
            407 => 'Proxy Authentication Required',
            408 => 'Request Timeout',
            409 => 'Conflict',
            410 => 'Gone',
            411 => 'Length Required',
            412 => 'Precondition Failed',
            413 => 'Request Entity Too Large',
            414 => 'Request-URI Too Long',
            415 => 'Unsupported Media Type',
            416 => 'Requested Range Not Satisfiable',
            417 => 'Expectation Failed',
            500 => 'Internal Server Error',
            501 => 'Not Implemented',
            502 => 'Bad Gateway',
            503 => 'Service Unavailable',
            504 => 'Gateway Timeout',
            505 => 'HTTP Version Not Supported'
        );

        return (isset($codes[$status])) ? $codes[$status] : '';
    } // }}} 
    // {{{ _checkAuth
    /**
     * Checks if a request is authorized
     * 
     * @access private
     * @return void
     */
    private function _checkAuth()
    {
        // Check if we have the USERNAME and PASSWORD HTTP headers set?
        if(!(isset($_SERVER['HTTP_X_'.self::APPLICATION_ID.'_USERNAME']) and isset($_SERVER['HTTP_X_'.self::APPLICATION_ID.'_PASSWORD']))) {
            // Error: Unauthorized
            $this->_sendResponse(401);
        }
        $username = $_SERVER['HTTP_X_'.self::APPLICATION_ID.'_USERNAME'];
        $password = $_SERVER['HTTP_X_'.self::APPLICATION_ID.'_PASSWORD'];
        // Find the user
        $user=User::model()->find('LOWER(username)=?',array(strtolower($username)));
        if($user===null) {
            // Error: Unauthorized
            $this->_sendResponse(401, 'Error: User Name is invalid');
        } else if(!$user->validatePassword($password)) {
            // Error: Unauthorized
            $this->_sendResponse(401, 'Error: User Password is invalid');
        }
    } // }}} 
    // {{{ _getObjectEncoded
    /**
     * Returns the json or xml encoded array
     * 
     * @param mixed $model 
     * @param mixed $array Data to be encoded
     * @access private
     * @return void
     */
    private function _getObjectEncoded($model, $array)
    {
        if(isset($_GET['format']))
            $this->format = $_GET['format'];

        if($this->format=='json')
        {
            return CJSON::encode($array);
        }
        elseif($this->format=='xml')
        {
            $result = '<?xml version="1.0">';
            $result .= "\n<$model>\n";
            foreach($array as $key=>$value)
                $result .= "    <$key>".utf8_encode($value)."</$key>\n"; 
            $result .= '</'.$model.'>';
            return $result;
        }
        else
        {
            return;
        }
    } // }}} 
    // }}} End Other Methods
}

/* vim:set ai sw=4 sts=4 et fdm=marker fdc=4: */
?>

到此即生成简单的rest框架

下面的get请求id的效果




本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Yii1.1 实现简单restful 框架 的相关文章

  • 区块链DAPP开发 以太坊智能合约框架有哪些

    一 truffle xff08 JavaScript xff09 Truffle 是一个在以太坊进行 DApp 开发的世界级开发环境 测试框架 使用 Truffle 开发有一以下优点 xff1a 内置智能合约编译 xff0c 链接 xff0
  • 区块链DAPP开发 智能合约开发工具IDE有哪些

    Remix http remix ethereum org ChainIDE https chainide cn zh CN ChainIDE提供云端编译功能 xff0c 无需繁琐的安装设置 xff0c 加速开发迭代速度 ChainIDE提
  • NFT和数字藏品的区别

    来源 xff1a 德勤 Web3 0模式分析及中国应用创新探索
  • Pycharm 增加 run 控制台缓冲行数

    找到 pycharm 安装目录的 bin 目录下 idea properties 文件 xff0c 修改 idea cycle buffer 值 xff0c 原来默认为 1024
  • python 类的定义一定要注意静态变量

    class A 静态变量 a 61 12 def init self a 成员变量 self a 61 a 静态变量通过 类名 变量名 来访问 print A a 12 成员变量通过 对象 变量名 访问的 print A 0 a 0 cla
  • python open按行读取txt 去掉\n

    加 strip 39 n 39
  • OOQP安装指南

    文章目录 1 OOQP的github链接 xff1a 2 准备工作 xff1a 3 安装OOQP xff1a 4 简单使用 xff1a 1 OOQP的github链接 xff1a ompl的官网网址为 xff1a https github
  • 海康摄像头实时显示与字符叠加详解

    1 说明 文章详细叙述了海康摄像头的两种实时显示方法 基于SDK 解码显示和基于数据流回调显示 xff0c 并且讲述了这在两种显示方法下如何往画面添加字符和图像 xff0c 最后比较了这两种方法的优劣 文章全程给以详细的程序说明 xff0c
  • Proto3序列化协议

    Proto3序列化协议 简介 对于互联网应用来说 xff0c 客户端 客户端 客户端 服务端之间需要数据的交互 xff0c 其数据传输是二进制流的方式在互联网上传输 xff0c 因为需要一种手段将数据对象编码为一种可以在网络上传输的二进制流
  • 一文读懂数据库分库分表

    阅读此文你将了解 xff1a 什么是分库分表以及为什么分库分表如何分库分表分库分表常见几种方式以及优缺点如何选择分库分表的方式 数据库常见优化方案 对于后端程序员来说 xff0c 绕不开数据库的使用与方案选型 xff0c 那么随着业务规模的
  • 从操作系统漫谈GOLang GPM模型

    前言 本文从操作系统谈起 xff0c 简单介绍操作系统基本知识 xff0c 引出进程 线程调度的基本原理和基本模型 xff0c 然后从0到1设计Golang调度器 xff0c 通过方案的逐步演进升级 xff0c 可以了解到GPM模型设计理念
  • 卡尔曼滤波经典讲解,C++算法实现

    请移步跳转文章排版更加清晰 在学习卡尔曼滤波器之前 xff0c 首先看看为什么叫 卡尔曼 跟其他著名的理论 xff08 例如傅立叶变换 xff0c 泰勒级数等等 xff09 一样 xff0c 卡尔曼也是一个人的名字 xff0c 而跟他们不同
  • 解决linux不能安装g++问题

    问题描述 xff1a Ubuntu如何通过重新安装G 43 43 编译器 xff0c 修复不能安装使用g 43 43 的问题 我刚安装的Ubuntu 14 10的g 43 43 编译器不能使用 xff0c 用sudo apt get ins
  • MySQL系列之源码浅析

    源码才是王道 真正的高手从来不是临场发挥 xff0c 随机应变是外人看来的错觉 1 主函数sql mysqld cc中 xff0c 代码如下 xff1a span class hljs keyword int span main span
  • 卡尔曼算法精讲与C++实现

    在学习卡尔曼滤波器之前 xff0c 首先看看为什么叫 卡尔曼 跟其他著名的理论 xff08 例如傅立叶变换 xff0c 泰勒级数等等 xff09 一样 xff0c 卡尔曼也是一个人的名字 xff0c 而跟他们不同的是 xff0c 他是个现代
  • 腾讯后端面试经验

    终于等来腾讯的面试 4 3号 机试 机试包括选择 xff08 30多 xff09 简答 xff08 2题 xff09 编程 xff08 2 xff09 选择和简答编程分别一小时 xff0c 选择题考的比较广 xff0c 概率 Linux 操
  • Springboot整合摘要式(Digest)身份认证

    百度下来关于springboot整合摘要式省份认证的帖子基本都是说原理的 xff0c 很少有直接的demo xff0c 前些天找到了一个博主写的demo xff0c 但是我只是截图了忘记了博主的地址很抱歉了 下面直接上代码截图 xff1a
  • kalibr相机内参标定优化过程和原理

    在估计出内参之后 xff0c 会进行优化迭代操作 如果是多相机标定 xff0c 在完成内参标定的同时 xff0c 也会完成具有交叉视野相机外参的的标定 初始估计步骤也会进行多相机基线距离的估计 xff0c 用作后续的迭代优化 优化过程如下
  • Curl多线程并发任务实例函数

    function curl post3 url arrs flen for i 61 0 i lt flen i 43 43 foreach arrs i as k 61 gt v tmp str 61 k 34 61 34 v 34 am
  • Linux下原子操作(信号量 自旋锁)的实现原理和底层代码分析

    csdn越改版 xff0c 越丑 开始我们的主题 xff1a Linux下原子操作 xff08 信号量 自旋锁 xff09 的实现原理和底层代码分析 2017年8月27日12 47 02 1 何为原子操作 xff1f 原子操作是什么 xff

随机推荐

  • Linux下用c语言实现发送http请求

    前言 在linux下 xff0c 使用socket进行编程 xff0c 需要到服务器上进行获取数据 xff0c 服务器使用的php编程 xff0c 需要使用http的方式进行获取数据 代码 span class hljs preproces
  • VSCode 的C++编译

    0 参考文档 0 1 官方参考 由于C 43 43 在不同平台上编译使用的编译器不同 xff0c 所以我们先将官网针对不同平台的编译文档摘录出来 xff0c 以便大家参考 xff1a 0 0 1 Linux平台使用GCC 参考 xff1a
  • STM32在子函数中的局部变量数组利用DMA发送无法正确发送数据的问题

    现象 xff1a 在子函数中 xff0c 定义了一个局部变量sendbuf 8 61 1 2 3 4 5 6 7 8 xff0c 然后分别利用普通串口发送函数发送可以正常发送和利用DMA发送 xff0c 并利用串口调试助手查看 xff0c
  • 如何使用Qt插件在Qt中进行ROS开发

    一 前言 本文介绍一种Qt下进行ROS开发的完美方案 xff0c 使用的是ros industrial的Levi Armstrong在2015年12月开发的一个Qt插件ros qtc plugin xff0c 这个插件使得Qt 新建项目 和
  • MN316_OPEN(NBIOT)物联网模块环境搭建

    因为项目的需要 这里要使用NBIOT 踩了一些坑 这里总结一下 编译 官方给的SDK如下 按照说明 在该目录下直接运行如下指令 34 build bat dlvs h0 demo 34 即可成功编译 但是我编译的时候不成功 报错如下 最后发
  • 《学习STL》-1.STL简介

    引言 当你C 43 43 入门后 xff0c 学了些C 43 43 编程规则 xff0c 正如 C 43 43 Primer 里的内容 xff0c 你知道C 43 43 里面的基本数据类型 循环 判断 函数 类 模板等 这阶段你的确会编写一
  • linux查看大小端命令

    Byte Order Litter Endian 小端模式 xff0c 绝大部分机器都是小端模式
  • 星网宇达利用NTRIPClient连接千寻服务器获取差分定位数据

    硬件设备 xff1a 星网宇达XW GI5610 软件设备 xff1a QXNTRIPClient 连接方式 xff1a 星网宇达RTK RS232连接电脑串口 打开QXNTRIPClient xff0c 连接千寻服务器 接收下发RTK数据
  • Ubuntu20.04 安装 mNetAssist

    安装环境 xff1a Ubuntu20 04安装包 xff1a mNetAssist release amd64 deb 安装与运行 span class token function sudo span span class token
  • 使用 include-what-you-use 检测冗余头文件

    include what you use 可以很方便的检测未使用的头文件 xff0c 使用的时候绕了点路 xff0c google后解决 xff0c 记录一下 1 安装clang ubuntu下直接apt get 安装就行了 需要注意的是
  • C语言结构体对齐详解

    文章目录 一 C语言结构体对齐大小快速判断二 反汇编角度看结构体三 总结 一 C语言结构体对齐大小快速判断 在C语言中定义一个结构体 xff0c 里面具体占用多少个字节呢 xff0c 先举一个例子 xff0c 如下 xff1a span c
  • 飞控各传感器相关作用

    飞控主要包括主控处理器MCU xff08 main control unit 和惯性导航模块IMU xff08 Inertial Measurement Unit xff09 四轴则必须配备3轴陀螺仪 xff0c 是四轴飞行器的机械结构 动
  • C++ : C++基础 :从内存的角度看 char[]和char*

    char 和char 区别 1 xff1a 数据在内存中的存储2 xff1a char 和 char 分析3 xff1a char p2 和 char p1 3 1 修改指针所指向的地址 4 string转char 5 char 转stri
  • 基于 nonce 的用户身份验证协议

    一 xff1a 什么是nonce 维基百科 xff1a 安全工程中 xff0c Nonce 是一个在加密通信只能使用一次的数字 在认证协议中 xff0c 它往往是一个 随机或 伪随机数 xff0c 以避免 重放攻击 二 xff1a 举例说明
  • php从数据库读取菜单数据并树状显示

    数据库表结构 mcp node表 字段 node code node name node pcode node code为区域编码 node name为区域名称 node pcode为父区域编码 祖先父区域编码为0 预期效果 代码实现部分
  • 蓝牙BLE之CC2541 OAD升级[带看门狗OAD]

    说明和代码设置 本文有两篇文章参考 其中博主 34 甜甜的大香瓜 34 的文章是原始文章 详细介绍了ImageA的hexh和B的bin以及A的bin是怎么生成的和具体的操作方法 https blog csdn net feilusia ar
  • php 从数据库读取数据并生成树型可折叠菜单

    数据存储形式 折叠菜单显示 直接调用 php页面即可输出树状可折叠菜单 所用到的js 区域折叠函数 function ShowMenu MenuID if MenuID style display 61 61 34 none 34 Menu
  • 提权apache 为root权限

    include lt stdio h gt include lt stdlib h gt include lt string h gt include lt sys types h gt include lt unistd h gt int
  • PHP 生成 WSDL 文件工具类 SoapDiscovery.class.php

    lt pre name 61 34 code 34 class 61 34 php 34 gt lt php Copyright c 2005 Braulio Jos Solano Rojas All rights reserved Red
  • Yii1.1 实现简单restful 框架

    学习了下php的rest服务 xff0c 将总结记录如下 采用Yii1 1版本 xff0c Yii2已经专门有restful专题 xff08 ps 暂时没有学习 xff09 1 先用Yii创建项目 2 创建数据库 xff08 rest xf