<?php require_once './bootstrap.php'; require_once '../core/form_validator.php'; $MODULE_ROOT = '.'; $QWP_FORM_VALIDATOR_RULE = 'test1'; $_POST['f'] = array('user' => '*****@*****.**', 'pwd' => '111111', 'pwd1' => '11112'); initialize_request(); assert(qwp_validate_form() !== true); $_POST['f'] = array('user' => 'aaabbb.com', 'pwd' => '111111', 'pwd1' => '111111', 'url' => 'http://www.qwp.com', 'd1' => '2015-09-01', 'd2' => '2015-09-01 18:20:11', 'age' => '21'); initialize_request(); assert(qwp_validate_form() !== true); $_POST['f'] = array('user' => '*****@*****.**', 'pwd' => '111111', 'pwd1' => '111111', 'url' => 'http://www.qwp.com/test.php', 'd1' => '2015-09-01', 'd2' => '2015-09-01 18:20:11', 'age' => '21', 'invalid' => '2'); initialize_request(); assert(qwp_validate_form() === true); assert(F('invalid') === null);
function qwp_initialize() { global $MODULE, $USER, $MODULE_ROOT, $MODULE_URI, $SUPER_MODULE_ROOT, $IS_SUB_MODULE; initialize_logger('qwp'); $USER = null; initialize_request(); if (!$MODULE) { $MODULE = DEFAULT_MODULE; } $MODULE_URI = $MODULE; $MODULE = explode('-', $MODULE); if (!qwp_is_module_name_valid()) { return false; } $MODULE_ROOT = join_paths(QWP_MODULE_ROOT, implode('/', $MODULE)); require_once QWP_MODULE_ROOT . '/bootstrap.php'; $SUPER_MODULE_ROOT = join_paths(QWP_MODULE_ROOT, $MODULE[0]); $IS_SUB_MODULE = $MODULE_ROOT != $SUPER_MODULE_ROOT; return qwp_custom_initialize_check(); }