Example #1
0
        <tr><td>session</td><td>获取$_SESSION变量;建议使用session函数;此时第四个参数无任何意义</td></tr>
        <tr><td>cookie</td><td>获取$_COOKIE变量;建议使用cookie函数;此时第四个参数无任何意义</td></tr>
        <tr><td>server</td><td>获取$_SERVER变量;此时第四个参数无任何意义</td></tr>
        <tr><td>globals</td><td>获取$GLOBALS变量;此时第四个参数无任何意义</td></tr>
        <tr><td>data</td><td>获取其他类型的变量,需要第四个参数['额外数据源']配合</td></tr>
      </table>
        <p>“修饰符”可选为:<code>s、d、b、a、f</code>;表示获取的数据被强制转换的类型,s=>string[字符串]、d=>double[整形]、b=>boolean[布尔值]、a=>array[数组]、f=>float[浮点数];未设置该参数默认为s</p>
        <p>“默认值”表示需要获取的指定变量不存在时返回这个默认值,注意<code>变量不存在的含义</code>;假设获取get变量action,也就是说<code>$_GET['action']</code>不存在才会返回默认值;这里存在这种情况:<code>($_GET['action']==='')为true</code>;这就需要对“变量是否存在”的深入理解,直接给答案不解释,这种情况Input返回空字符串并不会返回设置的默认值。</p>
        <p>“过滤方法”参数,可以是数据处理或过滤的函数名字符串(自定义函数亦可,留意过滤函数方法体的合理性),多个函数使用逗号分隔函数名成字符串或用索引数组;也可以是一个正则表达式,使用正则来过滤数据(此时表达式分隔符必须是左划线[正划线];使用正则倘若匹配失败则不会返回原值,而是会返回设置的默认值或者null);同时也可以是int型常量或变量用于filter_var的第二个参数,并使用filter_var进行过滤。若传递的函数并不存在,此时将尝试将该参数理解成filter_var过滤方法的第二个参数(int型)并用filter_var函数对数据过滤。</p>
        <p>“额外数据源”可以使用Input处理该函数第一个参数中的“变量类型”所不支持的数据类型(主要指那些超全局变量);Input函数仅用于获取(并不进行数据设置),使用“额外数据源”参数则需要“变量类型”必须设置为data,继而“默认值”参数、“过滤方法”参数相互配合,用更少的代码完成更多的事情。该参数类型可以是数组也可以是字符串。</p>
        <p>注意:Input默认Sql注入的安全过滤需要针对特定业务场景,有需要进一步过滤请完善./Function/UsefullFunction.php中的<code>Input_filter函数</code>;该函数默认过滤掉纯粹的特定Sql语句中的关键词,若数据中包含这些Sql关键词是不会被过滤的!</p>
        <p>Input是一个很强大的函数,用法举例:</p>
        <ul class="sample_list">
          <li>获取所有get变量<code>Input('get.')</code>或<code>Input('get.','','trim,strip_tags')</code>;第一种写法相当于获取$_GET,第二种写法则对$_GET进行了过滤,并设置了默认值(当且仅当$_GET不存在时才会返回默认值;这里某种意义上来看设置默认值并没有什么意义,因为超全局数组在不手动unset的情况下isset均为true)</li>
          <li>获取get变量名为action的值并过滤:<code>Input('get.actoin','不存在get变量action','trim,strip_tags')</code>,输出结果:<code><?php 
var_dump(Input('get.action', '不存在get变量action', 'trim,strip_tags'));
?>
</code>,你也可以在本url上加上<code>?action= 这是action变量&lt;p&gt;值&lt;/p&gt; </code>(注意html标签p和首尾空格会被过滤掉);这样返回的结果应该为:<code>这是action变量值</code>。(也就是传统方法中的<code>$_GET['actoin']</code>;只不过使用Input方法功能更强大,可以统一指定过滤方法也可以指定当action不存在时返回的默认值;节省很多业务逻辑代码)</li>
          <li>获取session值,<code>Input('session.uid',false)</code>若存在<code>$_SESSION['uid']</code>则返回<code>$_SESSION['uid']</code>,否则返回<code>false</code>;需要留意的是$_SESSION可能是多维(二维及其以上)数组,Input仅能获取到第一维中的数据(即一个数组),<strong>暂时并不能</strong>通过<code>Input('session.uid.name',false)</code>来获取<code>$_SESSION['uid']['name']</code>;此功能以后<strong>可能</strong>会支持。</li>
          <li>获取cookie值,<code>Input('cookie.uid',false)</code>若存在<code>$_COOKIE['uid']</code>则返回<code>$_COOKIE['uid']</code>,否则返回<code>false</code>;当然你也可以指定过滤方法。</li>
          <li>自动判断请求类型并获取指定变量名的值,<code>Input('request.id')</code>或<code>Input('id')</code>;如果当前请求类型是GET,那么等效于<code>$_GET['id']</code>,如果当前请求类型是POST或者PUT,那么相当于获取<code>$_POST['id']</code>或者PUT提交的数据中的id项数据。</li>
          <li><code>Input('server.REQUEST_METHOD')</code>获取<code>$_SERVER['REQUEST_METHOD']</code></li>
          <li>获取外部数据,<code>Input('data.file1','','',$_FILES)</code></li>
        </ul>
      <p>12、<code>session</code>函数用于统一设置、获取session</p>
      <p>13、<code>cookie</code>函数用于统一设置、获取cookie;函数原型<code>cookie('COOKIE名',['COOKIE值'],['COOKIE配置项'])</code>;注意此函数有默认配置项,可以按需定制(修改函数体开始的$config数组即可),亦可通过'COOKIE配置项'参数覆盖默认配置。</p>
      <p>'COOKIE名':用于获取或设置指定名称的COOKIE,若'COOKIE名'传入<code>null</code>则表示删除<strong>指定前缀的所有cookie</strong>,此时若cookie名前缀为空将不做任何处理即不删除任何cookie;作为php标准,当并未按需指定默认配置时可以通过'COOKIE配置项'参数传入cookie前缀,写法为:<code>cookie(null,null,array('prefix'=>'J_'))</code>;函数体也做了变通处理还可以这么写<code>cookie(null,'J_')</code>,此时第二个参数将被理解成要删除的cookie前缀。</p>
      <p>'COOKIE值':用于设置cookie的值,或当'COOKIE名'为<code>null</code>并且'COOKIE值'不为<code>null</code>,此时'COOKIE值'表示传入cookie前缀,以用于快速删除该cookie前缀的所有cookie。</p>
      <p>'COOKIE配置项'参数形式:</p>
      <p>'COOKIE配置项'允许三种类型变量参数:int、string(int)以及array,可以理解为两种,多数情况下允许传入数组;仅进行cooke设置时'COOKIE配置项'参数方可允许为数值型参数(无论是int还是int型的字符串);此时的数值表示为该设置的cookie设置一个过期时间,例如<code>cookie('J_cookie','required',3600)</code>,表示设置一个名为<code>J_cookie</code>,值为<code>required</code>,过期时间为<code>3600秒</code>的cookie。当'COOKIE配置项'为数组时,该关联数组的结构为:<code>array('prefix'=>string,'expire'=>int,'path'=>path string,domain'=>string,'httponly'=>boolean)</code>,其中索引不区分大小写,prefix为设置该cookie的前缀(设置前缀也可以通过默认值配置或者直接将'COOKIE名'设置为完整的cookie名称)、设置的cookie过期时间(默认浏览器关闭cookie失效)、以及cookie的作用目录(默认/)、作用域名(默认当前域名)、以及该cookie是否httponly;除prefix外,其余几个索引键与<code>setcookie(string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]])</code>函数对应;仅需留意的是expire索引键的值通过cookie函数仅需指定多少秒后过期即可,而无需再加上<code>time()</code>,比如使用setcookie函数设置一个1个小时后过期的cookie,expire参数为<code>time()+3600</code>,而使用cookie函数,expire仅需要传入<code>3600</code>即可。</p>
      <p>cookie是一个很强大的函数,用法举例:</p>
Example #2
0
 * ->class('someclass'),
 * for a placeholder: ->placeholder('Some text'). If the attribute doesn't
 * take a value just omit it, so : ->required()
 *
 * In addition to HTML attributes, each element takes meta-data such as the
 * submitted value. All meta-data is set in exactly the same way but is prefixed
 * with a single underscore. For example, you can set the form's show_submitted
 * flag with ->_show_submitted(true), or force an initial check on a specific
 * item in a radioset using ->_value('name') -- in this case you are setting up
 * the element to appear as if that value was already submitted to it.
 *
 * This is done to make form specification as terse and fluent as possible
 * -- yet still giving control where needed.
 *
 **/
$contact_form = Form('contact', './')->setRenderer($r)->onSuccess('MySuccessHandler')->novalidate()->add(Fieldset('About you...', 'about')->class('about')->add(Checkbox('control', '>Collect Personal Details', 'ok')->_ignore_parent_fields('disabled,readonly,required'))->add(Input('salutation', 'Title', 'Your title please')->autofocus()->datalist($salutations)->required())->add(Input('name', 'Your Name', 'Your name please')->autocomplete('off')->required()->validator('myNameValidator'))->add(Email('email', 'Your Email', 'Your email address')->required()->autocomplete('off'))->add(URL('url', 'Website', 'Your URL here (optional)'))->add(Hidden('secret', '123'))->add(Password('pass', 'Your Password', 'Enter a password of 10 characters or more')->required()->minlength(10, '10+ chars. please'))->add(Password('oth', 'Repeat Password', 'Enter password again')->required()->minlength(10, '10+ chars. please')->matches('pass', 'This must match what you typed in the "Your Password" field.'))->add(Tel('tel', 'Phone', 'A contact number please')->pattern('/^[\\s]*[\\+]?[0-9][-0-9]*[\\s-0-9]*[\\s]*$/', 'Enter a valid phone number. This can start with an international code like +44 if needed.'))->add(Input('human', 'Are you human?', 'No bots please')->pattern('/^yes|yep|yeah|sure am|indeed$/i', 'Some form of affirmation is needed.')->required())->add(YesNo('alive', 'Were you alive when you celebrated your last birthday?', 'Babies excluded.', 'Just yes or no please.')->required())->add(Integer('age', 'How old are you?')->value(5)->min(2)->max(10)))->add(Fieldset('Your message...')->add(TextArea('msg', 'Message', 'Your message to us')->required()->pattern('/^[^0-9]*$/', 'No numbers please!')->whitelist('great,good,fantastic,amazing')))->add(Fieldset('Legal stuff...')->add(Radios('agreement', '>Do you agree to our terms?', $conditions)->required('* Please select one of the options')->validator('myConditionValidator'))->add(Checkboxes('options', 'Additional Options...', $checkboxes)->required()->value('spam_me'))->add(MSelect('depts', 'Forward to which departments?', $departments)->required('Please choose at least one department')->value('complaints-2 , complaints-3 , sales-0')))->add(Submit('Send'))->process();
/** ==================== Custom formatters follow ====================
 *
 * These all override, or append to, some aspect of the renderer's output
 * and should allow you fine enough control over your form output not to
 * have to resort to hand-crafted HTML.
 *
 * They are all enabled by setting values on the renderer.
 * Thay are also totally option. In fact, the default output of the renderer
 * should be fine in most cases so you can probably delete all the code in
 * this part of the file.
 **/
/**
 * Controls the output that goes at the head of the form when there are any
 * invalid elements. Use this only if the renderer's default markup isn't
 * what you need.
Example #3
0
function YesNo($name, $label, $note = null, $msg = null)
{
    return Input($name, $label, $note)->pattern('/^yes|no$/i', $msg);
}
Example #4
0
function DisplayCategories($parentid = 0, $sublevelmarker = '')
{
    global $db, $config, $link, $dle_vb_conf;
    if ($parentid != 0) {
        $sublevelmarker .= '--';
    }
    $getcategories = $db->query("SELECT * FROM " . PREFIX . "_category WHERE parentid = '{$parentid}' ORDER BY posi ASC");
    while ($row = $db->get_row($getcategories)) {
        $link .= "<tr><td style=\"padding-right:3px;\">" . $sublevelmarker . "<a class=\"list\" href=\"{$config['http_home_url']}index.php?do=cat&category=" . $row['alt_name'] . "\" target=\"_blank\">" . stripslashes($row['name']) . "</a></td><td><input class=edit type=text style=\"text-align: center;\" name='save_con[vb_link_forumid][{$row['id']}]' value='{$dle_vb_conf['vb_link_forumid'][$row['id']]}' size=10></td></tr><tr><td background=\"engine/skins/images/mline.gif\" height=1 colspan=2></td></tr>";
        DisplayCategories($row['id'], $sublevelmarker);
    }
}
$link = "<table><tr><td>{$dle_vb_lang['category']}</td><td>{$dle_vb_lang['forums']}</td></tr>";
DisplayCategories();
$link .= "</table>";
$settings_array = array('block_last' => array(array("title" => $dle_vb_lang['allow_forum_block'], "descr" => $dle_vb_lang['allow_forum_block_desc'], "setting" => YesNo('vb_lastpost_onoff'), "regexp" => false), array("title" => $dle_vb_lang['count_post'], "descr" => $dle_vb_lang['count_post_desc'], "setting" => Input('vb_block_new_count_post'), "regexp" => '#^[0-9]+$#', "name" => 'vb_block_new_count_post'), array("title" => $dle_vb_lang['leght_name'], "descr" => $dle_vb_lang['leght_name_desc'], "setting" => Input('vb_block_new_leght_name'), "regexp" => '#^[0-9]*$#', "name" => 'vb_block_new_leght_name'), array("title" => $dle_vb_lang['cache_time'], "descr" => $dle_vb_lang['cache_time_desc'], "setting" => Input('vb_block_new_cache_time'), "regexp" => '#^[0-9]*$#', "name" => 'vb_block_new_cache_time'), array("title" => $dle_vb_lang['bad_forum_for_block'], "descr" => $dle_vb_lang['bad_forum_for_block_desc'], "setting" => Input('vb_block_new_badf'), "regexp" => '#^[0-9,]*$#', "name" => 'vb_block_new_badf'), array("title" => $dle_vb_lang['good_forum_for_block'], "descr" => $dle_vb_lang['good_forum_for_block_desc'], "setting" => Input('vb_block_new_goodf'), "regexp" => '#^[0-9,]*$#', "name" => 'vb_block_new_goodf')), 'block_birthday' => array(array("title" => $dle_vb_lang['allow_birthday_block'], "descr" => $dle_vb_lang['allow_birthday_block_desc'], "setting" => YesNo('vb_birthday_onoff'), "regexp" => false), array("title" => $dle_vb_lang['cache_time'], "descr" => $dle_vb_lang['cache_time_desc'], "setting" => Input('vb_block_birthday_cache_time'), "regexp" => '#^[0-9]*$#', "name" => 'vb_block_birthday_cache_time'), array("title" => $dle_vb_lang['count_birthday'], "descr" => $dle_vb_lang['count_birthday_desc'], "setting" => Input('count_birthday'), "regexp" => '#^[0-9]+$#', "name" => 'count_birthday'), array("title" => $dle_vb_lang['no_user_birthday'], "descr" => $dle_vb_lang['no_user_birthday_desc'], "setting" => Input('no_user_birthday', 35), "regexp" => false), array("title" => $dle_vb_lang['spacer'], "descr" => $dle_vb_lang['spacer_desc'], "setting" => Input('vb_block_birthday_spacer'), "regexp" => false), array("title" => $dle_vb_lang['birthday_block'], "descr" => $dle_vb_lang['birthday_block_desc'], "setting" => TextArea('birthday_block'), "regexp" => '#^.+$#si', "name" => 'birthday_block')), 'block_online' => array(array("title" => $dle_vb_lang['allow_online_block'], "descr" => $dle_vb_lang['allow_online_block_desc'], "setting" => YesNo('vb_online_onoff'), "regexp" => false), array("title" => $dle_vb_lang['cache_time'], "descr" => $dle_vb_lang['cache_time_desc'], "setting" => Input('vb_block_online_cache_time'), "regexp" => '#^[0-9]*$#', "name" => 'vb_block_online_cache_time'), array("title" => $dle_vb_lang['separator'], "descr" => $dle_vb_lang['separator_desc'], "setting" => Input('separator'), "regexp" => false), array("title" => $dle_vb_lang['vb_block_online_user_link_forum'], "descr" => $dle_vb_lang['vb_block_online_user_link_forum_desc'], "setting" => YesNo('vb_block_online_user_link_forum'), "regexp" => false)), 'links' => array(array("title" => $dle_vb_lang['goforum'], "descr" => $dle_vb_lang['goforum_desc'], "setting" => YesNo('vb_goforum'), "regexp" => false), array("title" => $dle_vb_lang['link_title'], "descr" => $dle_vb_lang['link_title_desc'], "setting" => makeDropDown(array("old" => $dle_vb_lang['old_title'], "title" => $dle_vb_lang['title']), "save_con[link_title]", "{$dle_vb_conf['link_title']}"), "regexp" => false), array("title" => $dle_vb_lang['link_text'], "descr" => $dle_vb_lang['link_text_desc'], "setting" => makeDropDown(array("full" => $dle_vb_lang['full_text'], "short" => $dle_vb_lang['short_text'], "old" => $dle_vb_lang['old_text']), "save_con[link_text]", "{$dle_vb_conf['link_text']}"), "regexp" => false), array("title" => $dle_vb_lang['vb_link_show_no_register'], "descr" => $dle_vb_lang['vb_link_show_no_register_desc'], "setting" => YesNo('vb_link_show_no_register'), "regexp" => false), array("title" => $dle_vb_lang['link_on_news'], "descr" => $dle_vb_lang['link_on_news_desc'], "setting" => YesNo('link_on_news'), "regexp" => false), array("title" => $dle_vb_lang['show_count'], "descr" => $dle_vb_lang['show_count_desc'], "setting" => YesNo('vb_link_show_count'), "regexp" => false), array("title" => $dle_vb_lang['show_count_full'], "descr" => $dle_vb_lang['show_count_full_desc'], "setting" => YesNo('vb_link_show_count_full'), "regexp" => false), array("title" => $dle_vb_lang['link_user'], "descr" => $dle_vb_lang['link_user_desc'], "setting" => makeDropDown(array("old" => $dle_vb_lang['old_user'], "author" => $dle_vb_lang['author'], "cur_user" => $dle_vb_lang['cur_user']), "save_con[link_user]", "{$dle_vb_conf['link_user']}"), "regexp" => false), array("title" => $dle_vb_lang['name_post_on_forum'], "descr" => $dle_vb_lang['name_post_on_forum_desc'], "setting" => TextArea('vb_link_name_post_on_forum'), "regexp" => false), array("title" => $dle_vb_lang['text_post_on_forum'], "descr" => $dle_vb_lang['text_post_on_forum_desc'], "setting" => TextArea('text_post_on_forum'), "regexp" => false), array("title" => $dle_vb_lang['link_on_forum'], "descr" => $dle_vb_lang['link_on_forum_desc'], "setting" => TextArea('vb_link_link_on_forum'), "regexp" => false), array("title" => $dle_vb_lang['postusername'], "descr" => $dle_vb_lang['postusername_desc'], "setting" => Input('postusername', 35), "regexp" => '#^.+$#i', "name" => 'postusername'), array("title" => $dle_vb_lang['postuserid'], "descr" => $dle_vb_lang['postuserid_desc'], "setting" => Input('postuserid'), "regexp" => '#^[0-9]+$#', "name" => 'postuserid'), array("title" => $dle_vb_lang['forumid'], "descr" => $dle_vb_lang['forumid_desc'], "setting" => $link, "regexp" => false)), 'settings' => array(array("title" => $dle_vb_lang['vb_content_charset'], "descr" => $dle_vb_lang['vb_content_charset_desc'], "setting" => Input('vb_content_charset'), "regexp" => false), array("title" => $dle_vb_lang['allow_module'], "descr" => $dle_vb_lang['allow_module_desc'], "setting" => YesNo('vb_onoff'), "regexp" => false), array("title" => $dle_vb_lang['allow_reg'], "descr" => $dle_vb_lang['allow_reg_desc'], "setting" => YesNo('vb_reg'), "regexp" => false), array("title" => $dle_vb_lang['allow_profile'], "descr" => $dle_vb_lang['allow_profile_desc'], "setting" => YesNo('vb_profile'), "regexp" => false), array("title" => $dle_vb_lang['allow_lostpass'], "descr" => $dle_vb_lang['allow_lostpass_desc'], "setting" => YesNo('vb_lost'), "regexp" => false), array("title" => $dle_vb_lang['allow_pm'], "descr" => $dle_vb_lang['allow_pm_desc'], "setting" => YesNo('vb_pm'), "regexp" => false), array("title" => $dle_vb_lang['allow_login'], "descr" => $dle_vb_lang['allow_login_desc'], "setting" => YesNo('vb_login'), "regexp" => false), array("title" => $dle_vb_lang['allow_logout'], "descr" => $dle_vb_lang['allow_logout_desc'], "setting" => YesNo('vb_logout'), "regexp" => false), array("title" => $dle_vb_lang['allow_admin'], "descr" => $dle_vb_lang['allow_admin_desc'], "setting" => YesNo('vb_admin'), "regexp" => false), array("title" => $dle_vb_lang['vb_login_create_account'], "descr" => $dle_vb_lang['vb_login_create_account_desc'], "setting" => YesNo('vb_login_create_account'), "regexp" => false), array("title" => $dle_vb_lang['vb_login_create_dle_account'], "descr" => $dle_vb_lang['vb_login_create_dle_account_desc'], "setting" => YesNo('vb_login_create_dle_account'), "regexp" => false)));
if (defined('INSTALL')) {
    return false;
}
require ENGINE_DIR . '/modules/dle_vs_vb.php';
class vBIntegration_admin extends vBIntegration
{
    public $vBfields = array();
    public $vBGroups = array();
    public function __construct(db &$db)
    {
        parent::__construct($db);
        $this->_db_connect();
        $this->_initvBField();
        $this->_initvBGroups();
        $this->_db_disconnect();
Example #5
0
 function old_formEntrada($action, $esModificar)
 {
     if ($esModificar) {
         $out = gas("titulo", _("Modificando local"));
     } else {
         $out = gas("titulo", _("Nuevo local"));
     }
     $out .= "<table><tr>\n\t\t  <td>Nombre comercial</td><td>" . Input("NombreComercial", $this->getNombre()) . "</td><tr>" . "<tr><td></td><td>" . Enviar(_("Guardar")) . "</td></tr>" . "</table>";
     $modo = "newsave";
     if ($esModificar) {
         $modo = "modsave";
         $extra = Hidden("id", $this->getId());
     }
     return "<form action='{$action}?modo={$modo}' method=post>{$out} {$extra}</form>";
 }
Example #6
0
 /**
  * Output version same thing should verify
  * if its a DataPacket before sending back
  *
  * @param $data -> [array | multidimensional array]
  */
 public static function Output($data)
 {
     return Input($data);
 }