本文整理汇总了PHP中wpcf7_canonicalize函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_canonicalize函数的具体用法?PHP wpcf7_canonicalize怎么用?PHP wpcf7_canonicalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_canonicalize函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf7_captcha_validation_filter
function wpcf7_captcha_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$type = $tag->type;
$name = $tag->name;
$captchac = '_wpcf7_captcha_challenge_' . $name;
$prefix = isset($_POST[$captchac]) ? (string) $_POST[$captchac] : '';
$response = isset($_POST[$name]) ? (string) $_POST[$name] : '';
$response = wpcf7_canonicalize($response);
if (0 == strlen($prefix) || !wpcf7_check_captcha($prefix, $response)) {
$result->invalidate($tag, wpcf7_get_message('captcha_not_match'));
}
if (0 != strlen($prefix)) {
wpcf7_remove_captcha($prefix);
}
return $result;
}
开发者ID:dracudakid,项目名称:WP_TrungTamTinHoc,代码行数:17,代码来源:really-simple-captcha.php
示例2: wpcf7_quiz_ajax_refill
function wpcf7_quiz_ajax_refill($items)
{
if (!is_array($items)) {
return $items;
}
$fes = wpcf7_scan_shortcode(array('type' => 'quiz'));
if (empty($fes)) {
return $items;
}
$refill = array();
foreach ($fes as $fe) {
$name = $fe['name'];
$pipes = $fe['pipes'];
if (empty($name)) {
continue;
}
if (is_a($pipes, 'WPCF7_Pipes') && !$pipes->zero()) {
$pipe = $pipes->random_pipe();
$question = $pipe->before;
$answer = $pipe->after;
} else {
// default quiz
$question = '1+1=?';
$answer = '2';
}
$answer = wpcf7_canonicalize($answer);
$refill[$name] = array($question, wp_hash($answer, 'wpcf7_quiz'));
}
if (!empty($refill)) {
$items['quiz'] = $refill;
}
return $items;
}
开发者ID:sydneyDAD,项目名称:cardguys.com,代码行数:33,代码来源:quiz.php
示例3: wpcf7_file_validation_filter
function wpcf7_file_validation_filter($result, $tag)
{
$tag = new WPCF7_Shortcode($tag);
$name = $tag->name;
$id = $tag->get_id_option();
$file = isset($_FILES[$name]) ? $_FILES[$name] : null;
if ($file['error'] && UPLOAD_ERR_NO_FILE != $file['error']) {
$result->invalidate($tag, wpcf7_get_message('upload_failed_php_error'));
return $result;
}
if (empty($file['tmp_name']) && $tag->is_required()) {
$result->invalidate($tag, wpcf7_get_message('invalid_required'));
return $result;
}
if (!is_uploaded_file($file['tmp_name'])) {
return $result;
}
$allowed_file_types = array();
if ($file_types_a = $tag->get_option('filetypes')) {
foreach ($file_types_a as $file_types) {
$file_types = explode('|', $file_types);
foreach ($file_types as $file_type) {
$file_type = trim($file_type, '.');
$file_type = str_replace(array('.', '+', '*', '?'), array('\\.', '\\+', '\\*', '\\?'), $file_type);
$allowed_file_types[] = $file_type;
}
}
}
$allowed_file_types = array_unique($allowed_file_types);
$file_type_pattern = implode('|', $allowed_file_types);
$allowed_size = 1048576;
// default size 1 MB
if ($file_size_a = $tag->get_option('limit')) {
$limit_pattern = '/^([1-9][0-9]*)([kKmM]?[bB])?$/';
foreach ($file_size_a as $file_size) {
if (preg_match($limit_pattern, $file_size, $matches)) {
$allowed_size = (int) $matches[1];
if (!empty($matches[2])) {
$kbmb = strtolower($matches[2]);
if ('kb' == $kbmb) {
$allowed_size *= 1024;
} elseif ('mb' == $kbmb) {
$allowed_size *= 1024 * 1024;
}
}
break;
}
}
}
/* File type validation */
// Default file-type restriction
if ('' == $file_type_pattern) {
$file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
}
$file_type_pattern = trim($file_type_pattern, '|');
$file_type_pattern = '(' . $file_type_pattern . ')';
$file_type_pattern = '/\\.' . $file_type_pattern . '$/i';
if (!preg_match($file_type_pattern, $file['name'])) {
$result->invalidate($tag, wpcf7_get_message('upload_file_type_invalid'));
return $result;
}
/* File size validation */
if ($file['size'] > $allowed_size) {
$result->invalidate($tag, wpcf7_get_message('upload_file_too_large'));
return $result;
}
wpcf7_init_uploads();
// Confirm upload dir
$uploads_dir = wpcf7_upload_tmp_dir();
$uploads_dir = wpcf7_maybe_add_random_dir($uploads_dir);
$filename = $file['name'];
$filename = wpcf7_canonicalize($filename);
$filename = sanitize_file_name($filename);
$filename = wpcf7_antiscript_file_name($filename);
$filename = wp_unique_filename($uploads_dir, $filename);
$new_file = trailingslashit($uploads_dir) . $filename;
if (false === @move_uploaded_file($file['tmp_name'], $new_file)) {
$result->invalidate($tag, wpcf7_get_message('upload_failed'));
return $result;
}
// Make sure the uploaded file is only readable for the owner process
@chmod($new_file, 0400);
if ($submission = WPCF7_Submission::get_instance()) {
$submission->add_uploaded_file($name, $new_file);
}
return $result;
}
开发者ID:flasomm,项目名称:Montkailash,代码行数:87,代码来源:file.php
示例4: cf7bs_quiz_shortcode_handler
function cf7bs_quiz_shortcode_handler($tag)
{
$tag = new WPCF7_Shortcode($tag);
if (empty($tag->name)) {
return '';
}
$status = 'default';
$validation_error = wpcf7_get_validation_error($tag->name);
$class = wpcf7_form_controls_class($tag->type);
if ($validation_error) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
// size is not used since Bootstrap input fields always scale 100%
//$atts['size'] = $tag->get_size_option( '40' );
$pipes = $tag->pipes;
if (is_a($pipes, 'WPCF7_Pipes') && !$pipes->zero()) {
$pipe = $pipes->random_pipe();
$question = $pipe->before;
$answer = $pipe->after;
} else {
// default quiz
$question = '1+1=?';
$answer = '2';
}
$answer = wpcf7_canonicalize($answer);
$field = new CF7BS_Form_Field(cf7bs_apply_field_args_filter(array('name' => $tag->name, 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'type' => 'text', 'value' => '', 'placeholder' => '', 'label' => $tag->content, 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'status' => $status, 'maxlength' => $tag->get_maxlength_option(), 'tabindex' => $tag->get_option('tabindex', 'int', true), 'wrapper_class' => $tag->name), $tag->basetype, $tag->name));
$html = $field->display(false);
$hidden_html = sprintf('<input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%2$s">', $tag->name, wp_hash($answer, 'wpcf7_quiz'));
return str_replace('<input', '<p class="wpcf7-quiz-label">' . esc_html($question) . '</p>' . $hidden_html . '<input', $html);
}
开发者ID:accionclima1,项目名称:accionclima,代码行数:31,代码来源:quiz.php
注:本文中的wpcf7_canonicalize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论