Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Incluir en functions.php */
- function my_cforms_filter($params)
- {
- if (!function_exists('akismet_get_key') || !akismet_get_key()) {
- return $params;
- }
- /* $params es la variable global $_POST. */
- /* Modifica la llamada a my_cforms_akismet() si es necesario con los campos adecuados. */
- if (my_cforms_akismet($params['cf_field_1'], $params['cf_field_2'], $params['cf_field_3'], $params['cf_field_4'])) {
- /* Esto causa que la página no se termine de componer, pero no hay otra manera. */
- /* Agradéceselo a Oliver Seidel, autor del plugin. */
- exit('Spam detectado...');
- }
- return $params;
- }
- function my_cforms_ajax_filter($params)
- {
- if (!function_exists('akismet_get_key') || !akismet_get_key()) {
- return $params;
- }
- /* $params contiene los campos del formulario en el orden establecido durante su creación. */
- /* Modifica la llamada a my_cforms_akismet() si es necesario con los campos adecuados. */
- if (my_cforms_akismet($params['field_1'], $params['field_2'], $params['field_3'], $params['field_4'])) {
- header ('Content-Type: text/javascript');
- header ('X-Content-Type-Options: nosniff');
- header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
- header ('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
- header ('Cache-Control: no-cache, must-revalidate');
- header ('Pragma: no-cache');
- exit('+:var res = ' . (trim(sajax_get_js_repr('1*$#nSpam detectado...'))) . '; res;');
- }
- return $params;
- }
- function my_cforms_akismet($author, $email, $url, $content)
- {
- global $akismet_api_host, $akismet_api_port;
- $comment = array(
- 'blog' => get_option('home'),
- 'blog_lang' => get_locale(),
- 'blog_charset' => get_option('blog_charset'),
- 'user_ip' => $_SERVER['REMOTE_ADDR'],
- 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null,
- 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null,
- 'comment_type' => 'contact-form',
- 'comment_author' => $author,
- 'comment_author_email' => $email,
- 'comment_author_url' => $url,
- 'comment_content' => $content
- );
- $query_string = '';
- foreach ($comment as $key => $data) {
- $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
- }
- $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
- if ('true' == $response[1]) {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement