<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MS-potilas &#187; wp-contact-form-iii</title>
	<atom:link href="http://hamppu.net/mspotilas/tag/wp-contact-form-iii/feed/" rel="self" type="application/rss+xml" />
	<link>http://hamppu.net/mspotilas</link>
	<description>Kannabiksen lääkekäyttäjä</description>
	<lastBuildDate>Mon, 27 May 2019 14:47:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Yhteydenottolomake</title>
		<link>http://hamppu.net/mspotilas/2009/06/23/yhteydenottolomake/</link>
		<comments>http://hamppu.net/mspotilas/2009/06/23/yhteydenottolomake/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 03:56:39 +0000</pubDate>
		<dc:creator>MS-potilas</dc:creator>
				<category><![CDATA[WordPressin räätälöinti]]></category>
		<category><![CDATA[2.8]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[lisäosa]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[versiopäivitys]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-contact-form-iii]]></category>
		<category><![CDATA[yhteydenottolomake]]></category>

		<guid isPermaLink="false">http://hamppu.net/mspotilas/?p=169</guid>
		<description><![CDATA[Valitsin blogini yhteydenottolomakkeeksi lisäosan WP Contact Form III. Siinä estetään yhteydenottolomakkeella roskapostitus yksin&#173;kertaisella kysymyksellä tyyliin &#8221;2+2 = ?&#8221;.
Kysymystä (ja odotettua vastausta) voi muuttaa lisäosan asetuksista, jolloin sen todennäköisyys, että joku jaksaisi viilata jotain roskapostitusskriptiä juuri sinun yhteydenottolomakkeellesi, muuttuu lähes olemattomaksi. Itse päätin kuitenkin tehdä kysymyksestä muuttuvan. Seuraavassa ohjeet, miten sen tein.
Avaa wp-contactform-iii.php (tai vanhemmissa lisäosan [...]]]></description>
			<content:encoded><![CDATA[<p>Valitsin blogini <a href="?page_id=5" title="Siirry blogin yhteydenottolomakkeelle">yhteydenottolomakkeeksi</a> lisäosan <a href="http://wordpress.org/extend/plugins/wp-contact-form-iii/" title="Siirry lisäosan sivulle">WP Contact Form III</a>. Siinä estetään yhteydenottolomakkeella roskapostitus yksin&shy;kertaisella kysymyksellä tyyliin &#8221;2+2 = ?&#8221;.</p>
<p>Kysymystä (ja odotettua vastausta) voi muuttaa lisäosan asetuksista, jolloin sen todennäköisyys, että joku jaksaisi viilata jotain roskapostitusskriptiä juuri sinun yhteydenottolomakkeellesi, muuttuu lähes olemattomaksi. Itse päätin kuitenkin tehdä kysymyksestä muuttuvan. Seuraavassa ohjeet, miten sen tein.</p>
<p>Avaa wp-contactform-iii.php (tai vanhemmissa lisäosan versioissa wp-contactform.php). Etsi funktio:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> wpcf_is_challenge<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #339933;">...</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$is_challenge</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Kommentoi tämä funktio ja lisää sen eteen kaksi funktiota niin, että lopputulos näyttää seuraavalta:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// mspotilas</span>
<span style="color: #000000; font-weight: bold;">function</span> wpcf_get_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>wpcf_session<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">17</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">9</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">16</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">9</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ^ <span style="color: #208080;">0x96</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>wpcf_session<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%d</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$random</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wpcf_session'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ^ <span style="color: #208080;">0x96</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$n1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$random</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$n2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$random</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%d</span> + <span style="color: #009933; font-weight: bold;">%d</span> =&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// mspotilas</span>
<span style="color: #000000; font-weight: bold;">function</span> wpcf_is_challenge<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wpcf_session'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ^ <span style="color: #208080;">0x96</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$n1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$random</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$n2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$random</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$n2</span> <span style="color: #339933;">==</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/* commented out mspotilas
function wpcf_is_challenge($input) {
	$is_challenge = false;
	$answer = get_option('wpcf_answer');
	$answer = htmlentities(stripslashes(attribute_escape($answer)));
	if($input == $answer) {
		$is_challenge = true;
	}
	return $is_challenge;
}
*/</span></pre></div></div>

<p>Funktio wpcf_get_question luo kysymyksen muotoa &#8221;x + y =&#8221;, joissa x ja y ovat numeroita välillä 1&ndash;9.</p>
<p>Etsi seuraavaksi rivi, joka alkaa:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$question</span> <span style="color: #339933;">=</span></pre></div></div>

<p>vaihda sen tilalle rivi:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$question</span> <span style="color: #339933;">=</span> wpcf_get_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//htmlentities(stripslashes(get_option('wpcf_question')));</span></pre></div></div>

<p>Etsi rivi:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hiddenfield&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wpcf_stage&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;process&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>(tai vanhemmassa versiossa:)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wpcf_stage&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;process&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>lisää perään rivi:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hiddenfield&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wpcf_session&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;' . <span style="color: #006699; font-weight: bold;">$_POST[wpcf_session]</span> . '&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>Ja sitten testaamaan. <img src='http://hamppu.net/mspotilas/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>WordPressin versio päivitetty 2.8:aan</h3>
<p>Päivitin viime viikonloppuna WordPressin ohjelmiston 10.6.2009 julkaistuun <a href="http://codex.wordpress.org/Version_2.8">versioon 2.8</a>. Samalla päivitin lisäosat uusimpiin versioihinsa. Käyttämäni <a href="http://wordpress.org/extend/plugins/simple-captcha/">Simple CAPTCHA</a>-lisäosa muuttui niin, että varmistuskuva näytetään nyt hieman eri paikassa kommentin&shy;syöttö&shy;lomakkeella. Muita lukijoille näkyviä muutoksia päivitykset eivät tuoneet mukanaan.</p>
<p>Huomasin samalla, että WP Contact Form III -lisäosan kehitys on lopetettu, mistä sain kipinän tämän merkinnän kirjoittamiseen.</p>
<p>Ohjelmistopäivityksen yhteydessä lisäsin hakukentälle pika&shy;valinta&shy;näppäimen <strong>i</strong>, eli useilla selaimilla hakukentän saa aktiiviseksi näppäinyhdistelmällä ALT+i.</p>
]]></content:encoded>
			<wfw:commentRss>http://hamppu.net/mspotilas/2009/06/23/yhteydenottolomake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
