/** * Validate widget input * * @access public * @return Mixed */ function validate($args, $options, $preview) { // don't bother validating for preview if ($preview) { return NULL; } extract($args); $output = ""; if (empty($args['recaptcha_response_field'])) { return __('Please complete the reCAPTCHA.', 'tdomf'); } if (!function_exists('recaptcha_check_answer')) { @(require_once TDOMF_RECAPTCHALIB_PATH); } $response = recaptcha_check_answer($options['privatekey'], $_SERVER['REMOTE_ADDR'], $args['recaptcha_challenge_field'], $args['recaptcha_response_field']); if (!$response->is_valid) { $form_data = tdomf_get_form_data($args['tdomf_form_id']); $form_data['recaptcha_error'] = $response->error; tdomf_save_form_data($args['tdomf_form_id'], $form_data); if ($response->error == 'incorrect-captcha-sol') { return __('That reCAPTCHA was incorrect.', 'tdomf'); } else { tdomf_log_message('reCAPTCHA error ' . $response->error . '. Please refer to <a href="http://recaptcha.net/apidocs/captcha/">reCaptcha docs</a> for more information', TDOMF_LOG_ERROR); return __('Invalid reCAPTCHA configuration.', 'tdomf'); } } return NULL; }
} } else { require_once $wp_load; } global $wpdb; $form_id = intval($_REQUEST['tdomf_form_id']); $form_tag = $form_id; $post_id = false; if (isset($_REQUEST['tdomf_post_id'])) { $post_id = intval($_REQUEST['tdomf_post_id']); $form_tag = $form_id . '_' . $post_id; } // loading text domain for language translation // load_plugin_textdomain('tdomf', PLUGINDIR . DIRECTORY_SEPARATOR . TDOMF_FOLDER); $form_data = tdomf_get_form_data($form_id); // @TODO: Don't change word when on preview: isset($_POST['tdomf_form1_preview']) ////////////////////////////////////////////////////// ////// User Defined Vars: ////////////////////////////////////////////////////// // try to avoid the 'free p*rn' method of CAPTCHA circumvention // see www.wikipedia.com/captcha for more info $site_tags[0] = __("To avoid spam, please do NOT enter the text if", 'tdomf'); $site_tags[1] = sprintf(__("this site is not %s", "tdomf"), get_bloginfo('url')); // or more simply: //$site_tags[0] = "for use only on puremango.co.uk"; // reword or add lines as you please // or if you don't want any text: //$site_tags = null; // where to write the above: // 0=top
/** * Validate widget input * * @access public * @return Mixed */ function validate($args, $options, $preview) { if ($preview) { return NULL; } extract($args); $form_data = tdomf_get_form_data($tdomf_form_id); $form_tag = $tdomf_form_id; if (TDOMF_Widget::isEditForm($mode, $tdomf_form_id)) { $form_tag = $tdomf_form_id . '_' . $tdomf_post_id; } // all freeCap words are lowercase. // font #4 looks uppercase, but trust me, it's not... if ($form_data['hash_func_' . $form_tag](strtolower($args["imagecaptcha_" . $form_tag])) == $form_data['freecap_word_hash_' . $form_tag]) { // reset freeCap session vars // cannot stress enough how important it is to do this // defeats re-use of known image with spoofed session id $form_data['freecap_attempts_' . $form_tag] = 0; $form_data['freecap_word_hash_' . $form_tag] = false; tdomf_save_form_data($tdomf_form_id, $form_data); } else { return __("You must enter the word in the image as you see it.", "tdomf"); } return NULL; }
function validate($args, $options, $preview, $postfix = '') { extract($args); $form_data = tdomf_get_form_data($tdomf_form_id); if ($options['min'] > 0 && !isset($form_data['uploadfiles_' . $tdomf_form_id . '_' . $postfix])) { if (!empty($options['title'])) { return sprintf(__("No files have been uploaded yet. You must upload a minimum of %d files for %s.", "tdomf"), $options['min'], $options['title']); } else { return sprintf(__("No files have been uploaded yet. You must upload a minimum of %d files.", "tdomf"), $options['min']); } } $theirfiles = $form_data['uploadfiles_' . $tdomf_form_id . '_' . $postfix]; $filecount = 0; for ($i = 0; $i < $options['max']; $i++) { if (!file_exists($theirfiles[$i]['path'])) { unset($theirfiles[$i]); } else { $filecount++; } } if ($filecount < $options['min']) { if (!empty($options['title'])) { return sprintf(__("You must upload a minimum of %d files for %s.", "tdomf"), $options['min'], $options['title']); } else { return sprintf(__("You must upload a minimum of %d files.", "tdomf"), $options['min']); } } return NULL; }
function tdomf_ajaxeditscripts_action() { global $post; $post_ID = 0; if (isset($post)) { $post_ID = $post->ID; } $active_form = false; $forms = array(); $form_ids = tdomf_get_form_ids(); foreach ($form_ids as $form_id) { if (tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id) && tdomf_get_option_form(TDOMF_OPTION_AJAX_EDIT, $form_id->form_id) && (is_page() || is_single())) { if (tdomf_check_permissions_form($form_id->form_id, $post_ID, false) == NULL) { $form_tag = $form_id->form_id . '_' . $post_ID; /* * I'm sure there are probably nicer ways of doing this and it may * not be practical to modify the post-tag like this, but it works */ $code = <<<EOT function tdomf_show_form{$form_tag}(){ var post = document.getElementById('post-{$post_ID}'); if(post != null) { var tag = '#post-{$post_ID}'; } else { var tag = '#tdomf_inline_edit-{$post_ID}'; } var msg = document.getElementById('tdomf_form{$form_tag}_message'); if(msg != null) { jQuery(tag).after( jQuery('#tdomf_form{$form_tag}_message') ).remove(); jQuery('#tdomf_form{$form_tag}_message').after( jQuery('#tdomf_form{$form_tag}') ); jQuery('#tdomf_form{$form_tag}_message').before("<div id='" + tag + "'>"); jQuery('#tdomf_form{$form_tag}').after("</div>"); jQuery('#tdomf_form{$form_tag}').css("display", "block"); } else { jQuery(tag).after( jQuery('#tdomf_form{$form_tag}') ).remove(); jQuery('#tdomf_form{$form_tag}').before("<div id='" + tag + "'>"); jQuery('#tdomf_form{$form_tag}').after("</div>"); jQuery('#tdomf_form{$form_tag}').css("display", "block"); } } EOT; /* * If form doesn't support AJAX, then we need to know if it is * active and then to trick the javascript to show it! */ if (!$active_form && !tdomf_get_option_form(TDOMF_OPTION_AJAX, $form_id->form_id)) { $form_data = tdomf_get_form_data($form_id->form_id); if (!empty($form_data)) { $active_form = true; $code .= "\njQuery(document).ready( function() { tdomf_show_form{$form_tag}(); } );\n"; } } $forms[] = array('name' => '#tdomf_form' . $form_tag, 'code' => $code); } } } if (!empty($forms)) { echo "<script type='text/javascript' src='" . get_bloginfo('wpurl') . "/wp-includes/js/jquery/jquery.js'></script>"; echo "<style>\n"; foreach ($forms as $form) { echo $form['name'] . "{ display: none; background-color: white; }\n"; } echo "</style>\n"; echo "<script type='text/javascript'>\n"; foreach ($forms as $form) { echo $form['code']; } echo "</script>\n"; } }