form.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,631 行 · 第 1/5 页

PHP
1,631
字号
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * HTML form utility functions * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt.  If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   HTML * @package    HTML_Form * @author     Stig Bakken <ssb@fast.no> * @author     Urs Gehrig <urs@circle.ch> * @author     Daniel Convissor <danielc@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License * @version    $Id: Form.php,v 1.21 2005/03/18 14:06:38 danielc Exp $ * @link       http://pear.php.net/package/HTML_Form */if (!defined('HTML_FORM_TEXT_SIZE')) {    /**     * Default value for the $size parameter of most methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     */    define('HTML_FORM_TEXT_SIZE', 20);}if (!defined('HTML_FORM_MAX_FILE_SIZE')) {    /**     * Default value for the $maxsize parameter of some methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     */    define('HTML_FORM_MAX_FILE_SIZE', 1048576); // 1 MB}if (!defined('HTML_FORM_PASSWD_SIZE')) {    /**     * Default value for the $maxsize parameter of some methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     */    define('HTML_FORM_PASSWD_SIZE', 8);}if (!defined('HTML_FORM_TEXTAREA_WT')) {    /**     * Default value for the $width parameter of some methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     */    define('HTML_FORM_TEXTAREA_WT', 40);}if (!defined('HTML_FORM_TEXTAREA_HT')) {    /**     * Default value for the $height parameter of some methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     */    define('HTML_FORM_TEXTAREA_HT', 5);}if (!defined('HTML_FORM_TH_ATTR')) {    /**     * Default value for the $thattr parameter of most methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     *     * @since Constant available since Release 1.1.0     */    define('HTML_FORM_TH_ATTR', 'align="right" valign="top"');}if (!defined('HTML_FORM_TD_ATTR')) {    /**     * Default value for the $tdattr parameter of most methods.     *     * You can set this in your scripts before including Form.php     * so you don't have to manually set the argument each time     * you call a method.     *     * @since Constant available since Release 1.1.0     */    define('HTML_FORM_TD_ATTR', '');}/** * HTML form utility functions * * @category   HTML * @package    HTML_Form * @author     Stig Bakken <ssb@fast.no> * @author     Urs Gehrig <urs@circle.ch> * @author     Daniel Convissor <danielc@php.net> * @copyright  1997-2004 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License * @version    Release: @package_version@ * @link       http://pear.php.net/package/HTML_Form */class HTML_Form{    // {{{ properties    /**     * ACTION attribute of <form> tag     * @var string     */    var $action;    /**     * METHOD attribute of <form> tag     * @var string     */    var $method;    /**     * NAME attribute of <form> tag     * @var string     */    var $name;    /**     * an array of entries for this form     * @var array     */    var $fields;    /**     * DB_storage object, if tied to one     */    var $storageObject;    /**     * TARGET attribute of <form> tag     * @var string     */    var $target;    /**     * ENCTYPE attribute of <form> tag     * @var string     */    var $enctype;    /**     * additional attributes for <form> tag     *     * @var string     * @since Property available since Release 1.1.0     */    var $attr;    // }}}    // {{{ constructor    /**     * Constructor     *     * @param string $action  the string naming file or URI to which the form     *                         should be submitted     * @param string $method  a string indicating the submission method     *                         ('get' or 'post')     * @param string $name    a string used in the <form>'s 'name' attribute     * @param string $target  a string used in the <form>'s 'target' attribute     * @param string $enctype a string indicating the submission's encoding     * @param string $attr    a string of additional attributes to be put     *                         in the element (example: 'id="foo"')     * @return void     *     * @access public     */    function HTML_Form($action, $method = 'get', $name = '', $target = '',                       $enctype = '', $attr = '')    {        $this->action  = $action;        $this->method  = $method;        $this->name    = $name;        $this->fields  = array();        $this->target  = $target;        $this->enctype = $enctype;        $this->attr    = $attr;    }    // ===========  ADD  ===========    // }}}    // {{{ addText()    /**     * Adds a text input to the list of fields to be processed by display()     *     * @param string $name      the string used in the 'name' attribute     * @param string $title     the string used as the label     * @param mixed  $default   a default value for the element     * @param int    $size      an integer used in the 'size' attribute     * @param int    $maxlength an integer used in the 'maxlength' attribute     * @param string $attr      a string of additional attributes to be put     *                           in the element (example: 'id="foo"')     * @param string $thattr    a string of additional attributes to be put     *                           in the <th> element (example: 'class="foo"')     * @param string $tdattr    a string of additional attributes to be put     *                           in the <td> element (example: 'class="foo"')     * @return void     *     * @access public     * @see HTML_Form::display(),     *      HTML_Form::displayText(), HTML_Form::displayTextRow(),     *      HTML_Form::returnText(), HTML_Form::returnTextRow()     */    function addText($name, $title, $default = null,                     $size = HTML_FORM_TEXT_SIZE, $maxlength = 0,                     $attr = '', $thattr = HTML_FORM_TH_ATTR,                     $tdattr = HTML_FORM_TD_ATTR)    {        $this->fields[] = array('text', $name, $title, $default, $size,                                $maxlength, $attr, $thattr, $tdattr);    }    // }}}    // {{{ addPassword()    /**     * Adds a combined password input and password confirmation input     * to the list of fields to be processed by display()     *     * @param string $name      the string used in the 'name' attribute     * @param string $title     the string used as the label     * @param mixed  $default   a default value for the element     * @param int    $size      an integer used in the 'size' attribute     * @param int    $maxlength an integer used in the 'maxlength' attribute     * @param string $attr      a string of additional attributes to be put     *                           in the element (example: 'id="foo"')     * @param string $thattr    a string of additional attributes to be put     *                           in the <th> element (example: 'class="foo"')     * @param string $tdattr    a string of additional attributes to be put     *                           in the <td> element (example: 'class="foo"')     * @return void     *     * @access public     * @see HTML_Form::addPasswordOne(), HTML_Form::display(),     *      HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),     *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow(),     *      HTML_Form::displayPasswordOneRow(),     *      HTML_Form::returnPasswordOneRow()     */    function addPassword($name, $title, $default = null,                         $size = HTML_FORM_PASSWD_SIZE,                         $maxlength = 0, $attr = '', $thattr = HTML_FORM_TH_ATTR,                         $tdattr = HTML_FORM_TD_ATTR)    {        $this->fields[] = array('password', $name, $title, $default, $size,                                $maxlength, $attr, $thattr, $tdattr);    }    // }}}    // {{{ addPasswordOne()    /**     * Adds a password input to the list of fields to be processed by display()     *     * @param string $name      the string used in the 'name' attribute     * @param string $title     the string used as the label     * @param mixed  $default   a default value for the element     * @param int    $size      an integer used in the 'size' attribute     * @param int    $maxlength an integer used in the 'maxlength' attribute     * @param string $attr      a string of additional attributes to be put     *                           in the element (example: 'id="foo"')     * @param string $thattr    a string of additional attributes to be put     *                           in the <th> element (example: 'class="foo"')     * @param string $tdattr    a string of additional attributes to be put     *                           in the <td> element (example: 'class="foo"')     * @return void     *     * @access public     * @see HTML_Form::addPassword(), HTML_Form::display(),     *      HTML_Form::displayPassword(), HTML_Form::displayPasswordRow(),     *      HTML_Form::returnPassword(), HTML_Form::returnPasswordRow(),     *      HTML_Form::displayPasswordOneRow(),     *      HTML_Form::returnPasswordOneRow()     */    function addPasswordOne($name, $title, $default = null,                            $size = HTML_FORM_PASSWD_SIZE,                            $maxlength = 0, $attr = '', $thattr = HTML_FORM_TH_ATTR,                            $tdattr = HTML_FORM_TD_ATTR)    {        $this->fields[] = array('passwordOne', $name, $title, $default, $size,                                $maxlength, $attr, $thattr, $tdattr);    }    // }}}    // {{{ addCheckbox()    /**     * Adds a checkbox input to the list of fields to be processed by display()     *     * @param string $name      the string used in the 'name' attribute     * @param string $title     the string used as the label     * @param bool   $default   a bool indicating if item should be checked     * @param string $attr      a string of additional attributes to be put     *                           in the element (example: 'id="foo"')     * @param string $thattr    a string of additional attributes to be put     *                           in the <th> element (example: 'class="foo"')     * @param string $tdattr    a string of additional attributes to be put

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?