/** * $this->_parse_mail_content(), $this->_save_mail_content の本体 * 第2引数でDB保存するか判定 * * @param array $matches * @param bool $do_update * @return string $value */ protected function parse($matches, $do_update = false) { $match = $matches[1]; $form_id = $this->Setting->get('post_id'); // MWF_Config::TRACKINGNUMBER のときはお問い合せ番号を参照する if ($match === MWF_Config::TRACKINGNUMBER) { if ($form_id) { $value = $this->Setting->get_tracking_number($form_id); } } else { $form_key = MWF_Functions::get_form_key_from_form_id($form_id); $value = $this->Data->get($match); $value = $this->apply_filters_mwform_custom_mail_tag($form_key, $value, $match); } // 値が null でも保存(チェッボックス未チェックで直送信でも保存させるため) // ただし、画像の場合はURLが保存されないように調整がはいるため除外が必要 if ($do_update) { if (!array_key_exists($match, $this->Mail->attachments)) { update_post_meta($this->insert_contact_data_id, $match, $value); } } return $value; }
/** * check * @param string $akismet_author * @param string $akismet_author_email * @param string $akismet_author_url * @param MW_WP_Form_Data $Data * @return bool */ public function check($akismet_author, $akismet_author_email, $akismet_author_url, $Data) { global $akismet_api_host, $akismet_api_port; if (!$this->is_enable()) { return false; } $doAkismet = false; $author = ''; if ($Data->get_post_value_by_key($akismet_author)) { $author = $Data->get_post_value_by_key($akismet_author); $doAkismet = true; } $author_email = ''; if ($Data->get_post_value_by_key($akismet_author_email)) { $author_email = $Data->get_post_value_by_key($akismet_author_email); $doAkismet = true; } $author_url = ''; if ($Data->get_post_value_by_key($akismet_author_url)) { $author_url = $Data->get_post_value_by_key($akismet_author_url); $doAkismet = true; } if ($doAkismet) { $content = ''; foreach ($Data->gets() as $key => $value) { $value = $Data->get($key); $content .= $value . "\n\n"; } $permalink = get_permalink(); $akismet = array(); $akismet['blog'] = home_url(); $akismet['blog_lang'] = get_locale(); $akismet['blog_charset'] = get_option('blog_charset'); $akismet['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']); $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $akismet['referrer'] = $_SERVER['HTTP_REFERER']; $akismet['comment_type'] = MWF_Config::NAME; if ($permalink) { $akismet['permalink'] = $permalink; } if ($author) { $akismet['comment_author'] = $author; } if ($author_email) { $akismet['comment_author_email'] = $author_email; } if ($author_url) { $akismet['comment_author_url'] = $author_url; } if ($content) { $akismet['comment_content'] = $content; } foreach ($_SERVER as $key => $value) { if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'))) { $akismet[$key] = $value; } } $query_string = http_build_query($akismet, null, '&'); if (is_callable(array('Akismet', 'http_post'))) { $response = Akismet::http_post($query_string, 'comment-check'); } else { $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); } $response = apply_filters('mwform_akismet_responce', $response); return $response[1] == 'true' ? true : false; } }
/** * @group get */ public function test_get_送信データが複数値項目かつ文字列でchildrenがあるときは一致しなければ空文字列() { $this->Data->sets(array('test' => array('data' => 'a,b', 'separator' => ','), '__children' => array('test' => array(json_encode(array('c' => 'ccc', 'e' => 'ddd', 'e' => 'eee')))))); $this->assertSame('', $this->Data->get('test')); }