| 1 |
|
|---|
| 2 |
WP AuthImage Plugin (v2.1.1) |
|---|
| 3 |
written by Keith McDuffee (2004-6-7) |
|---|
| 4 |
http://www.gudlyf.com |
|---|
| 5 |
gudlyf@realistek.com |
|---|
| 6 |
|
|---|
| 7 |
--- |
|---|
| 8 |
|
|---|
| 9 |
CHANGELOG: |
|---|
| 10 |
|
|---|
| 11 |
2.1.1 -- Forget the $sess_key_name variable -- that did nothing to spammers. |
|---|
| 12 |
Trying something else with this version by destroying the session |
|---|
| 13 |
after a confirmed code entry. I think spammers are reusing |
|---|
| 14 |
sessions before they timeout. |
|---|
| 15 |
2.1 -- Added support info. in README for Wordpress 1.5. |
|---|
| 16 |
Fixed other typos in README. |
|---|
| 17 |
Merged alt and regular versions -- no need for two. |
|---|
| 18 |
You should now edit the $sess_key_name variable in authimage.php. |
|---|
| 19 |
Read below. |
|---|
| 20 |
2.0.4 -- Fixed echo typo in this README file |
|---|
| 21 |
Added path for $plugins_dir for those who may not have it defined |
|---|
| 22 |
Added the case insinsitivity stuff to the -alt version of the script |
|---|
| 23 |
Fixed bounds in for loop for CreateAIAltText |
|---|
| 24 |
2.0.3 -- Fixed some code in the README regarding the <iframe> closing tag. |
|---|
| 25 |
Added full path for the authimage.php script in the README. |
|---|
| 26 |
Fixed version number on files. |
|---|
| 27 |
Added full path for font file (which must be in the plugins dir) |
|---|
| 28 |
2.0.2 -- Fixed this file's numbering -- sorry about that! |
|---|
| 29 |
Codes are now case-insensitive by default. You can turn this off |
|---|
| 30 |
by editing the authimage.php file. |
|---|
| 31 |
2.0.1a -- Added an alternate plugin called 'authimage-alt.php' that can be |
|---|
| 32 |
used instead of the original. This alternate version will test |
|---|
| 33 |
come of the form values before submitting to wp-comments-post.php |
|---|
| 34 |
using JavaScript. |
|---|
| 35 |
Useful for not clearing the entire form when hitting back button on |
|---|
| 36 |
the WP error message. Read instructions below for usage of this new |
|---|
| 37 |
alternate plugin. |
|---|
| 38 |
2.0.1 -- Some bug fixes. Need for a my-hacks.php file afterall. |
|---|
| 39 |
PLEASE READ ALL INSTRUCTIONS BELOW IF YOU ARE UPGRADING FROM |
|---|
| 40 |
ANY PREVIOUS RELEASE! |
|---|
| 41 |
2.0 -- Minimal hacks now -- no need for the 'my-hacks.php' file. |
|---|
| 42 |
Now works as a plugin, so it has to be enabeled now. |
|---|
| 43 |
Image path changed to plugin location. |
|---|
| 44 |
No more temp files -- code is now stored in session variables |
|---|
| 45 |
MANY thanks to Marus Welz (http://marcus.scrappad.com/) for making |
|---|
| 46 |
the session variable changes for me and suggesting making this more |
|---|
| 47 |
of a plugin. |
|---|
| 48 |
Images can now be easily all numeric or all uppercase alphanumaric. |
|---|
| 49 |
|
|---|
| 50 |
1.4.1 -- Added instructions for dumping the comment into the moderation |
|---|
| 51 |
pool rather than fail altogether. See instructions below for more |
|---|
| 52 |
details. |
|---|
| 53 |
1.4 -- Added cookie information with phonetic English translation |
|---|
| 54 |
of the code. This allows the failure page to give a hint to the |
|---|
| 55 |
poster as to what code they need to enter. Non-English users may |
|---|
| 56 |
want to edit the showAIAltText() function to their liking. |
|---|
| 57 |
Added header information so the image expires and doesn't get cached. |
|---|
| 58 |
Changed function names so we don't walk over anything else in the |
|---|
| 59 |
future. |
|---|
| 60 |
Now allows creation of code in phonetic English if image creation |
|---|
| 61 |
is not possible or wanted. |
|---|
| 62 |
1.3.3 -- Altered angle of the font and added better spacing so "q" and "p" |
|---|
| 63 |
won't get cut off. |
|---|
| 64 |
1.3.2 -- Changed font to "atomicclockradio" and adjusted image size for it. |
|---|
| 65 |
Added image size info to comment page code. |
|---|
| 66 |
1.3.1 -- Increased length of image slightly to stop font cutoff. |
|---|
| 67 |
Added crontab example at end of README. |
|---|
| 68 |
1.3 -- Added a chmod 666 for the created files so they can be deleted by |
|---|
| 69 |
a user other than the http process user. |
|---|
| 70 |
1.2 -- Changed font to "jewels" and altered image size. |
|---|
| 71 |
1.1 -- Zero-length the image file after it's displayed. |
|---|
| 72 |
1.0 -- Initial release. |
|---|
| 73 |
|
|---|
| 74 |
--- |
|---|
| 75 |
|
|---|
| 76 |
REQUIREMENTS: |
|---|
| 77 |
|
|---|
| 78 |
This hack assumes the following for your blog. Anything else is up to |
|---|
| 79 |
the user to hack for their own use. These are the only reqs that have been |
|---|
| 80 |
fully tested up to this point. |
|---|
| 81 |
|
|---|
| 82 |
- WordPress (http://wordpress.org/) version 1.2 or above (includes 1.5). |
|---|
| 83 |
- Apache 1.3 or above running on Linux. |
|---|
| 84 |
- PHP 4 or above. |
|---|
| 85 |
- GD library (http://www.boutell.com/gd/) and Freetype library |
|---|
| 86 |
(http://www.freetype.org/) for PHP. See http://us2.php.net/gd for more |
|---|
| 87 |
information. |
|---|
| 88 |
- Some sort of shell access to your web server. |
|---|
| 89 |
|
|---|
| 90 |
You can test your version of PHP for GD and Freetype with the following |
|---|
| 91 |
commands "from a shell": |
|---|
| 92 |
|
|---|
| 93 |
php -i | grep "GD Support" |
|---|
| 94 |
|
|---|
| 95 |
should return: |
|---|
| 96 |
|
|---|
| 97 |
<tr><td class="e">GD Support </td><td class="v">enabled </td></tr> |
|---|
| 98 |
|
|---|
| 99 |
and: |
|---|
| 100 |
|
|---|
| 101 |
php -i | grep "FreeType Support" |
|---|
| 102 |
|
|---|
| 103 |
should return: |
|---|
| 104 |
|
|---|
| 105 |
<tr><td class="e">FreeType Support </td><td class="v">enabled </td></tr> |
|---|
| 106 |
|
|---|
| 107 |
If you don't see both of those enabled, you can still use AuthImage, but |
|---|
| 108 |
you'll need to use it in text mode. Read below on how to do that |
|---|
| 109 |
|
|---|
| 110 |
--- |
|---|
| 111 |
|
|---|
| 112 |
INSTALLATION: |
|---|
| 113 |
|
|---|
| 114 |
Following the directions below with the included files should allow you to |
|---|
| 115 |
add authorization image checking for comments posted on your site. It displays |
|---|
| 116 |
an image with some random text that the commenter has to enter in order for |
|---|
| 117 |
their comment to go through. This should cut down on any bots out there from |
|---|
| 118 |
spamming your comments area and perhaps remove the need for comment moderation. |
|---|
| 119 |
|
|---|
| 120 |
NOTE: It's important to make the indicated changes to BOTH the regular AND the |
|---|
| 121 |
popup versions of the comment pages. If you don't do that, spammers may |
|---|
| 122 |
perhaps find a way to target the unedited version of the page. |
|---|
| 123 |
|
|---|
| 124 |
1. Put the files "authimage.php" and "automicclockradio.ttf" in your WP |
|---|
| 125 |
plugins directory. Keep reading past step 7 if you want to use the |
|---|
| 126 |
JavaScript form checking. |
|---|
| 127 |
|
|---|
| 128 |
2. FOR WORDPRESS VERSIONS < 1.5, look for this in 'wp-comments.php' AND 'wp-comments-popup.php'. FOR WORDPRESS VERSION 1.5, loog for this in your theme's 'comments.php' and/or 'comments-popup.php': |
|---|
| 129 |
|
|---|
| 130 |
<label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label> |
|---|
| 131 |
|
|---|
| 132 |
and add this after it if you want to display an image: |
|---|
| 133 |
|
|---|
| 134 |
<p> |
|---|
| 135 |
<input type="text" name="code" id="code" value="<?php echo ""; ?>" size="28" tabindex="4" /> |
|---|
| 136 |
<label for="code"><?php _e("Enter this code: "); ?></label> |
|---|
| 137 |
<img src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/authimage.php?type=image" width="155" height="50" alt="authimage" /> |
|---|
| 138 |
</p> |
|---|
| 139 |
|
|---|
| 140 |
-or- if you want to display phonetic-English text instead of an image: |
|---|
| 141 |
|
|---|
| 142 |
<input type="text" name="code" id="code" value="<?php echo ""; ?>" size="28" tabindex="4" /> |
|---|
| 143 |
<label for="code"><?php _e("Enter this code: "); ?></label> |
|---|
| 144 |
<iframe src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/authimage.php?type=text" width="155" height="50"></iframe> |
|---|
| 145 |
</p> |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
3. FOR WORDPRESS VERSIONS < 1.5: Look for this in 'wp-comments-post.php': |
|---|
| 149 |
|
|---|
| 150 |
if (strlen($url) < 7) |
|---|
| 151 |
$url = ''; |
|---|
| 152 |
|
|---|
| 153 |
and add this after it: |
|---|
| 154 |
|
|---|
| 155 |
// authimage -- Check for valid sized code |
|---|
| 156 |
$code = trim(strip_tags($_POST['code'])); |
|---|
| 157 |
if (strlen($code) < 6) |
|---|
| 158 |
$code = ''; |
|---|
| 159 |
|
|---|
| 160 |
FOR WORDPRESS VERSION 1.5: Look for this in 'wp-comments-post.php': |
|---|
| 161 |
|
|---|
| 162 |
$comment_content = $_POST['comment']; |
|---|
| 163 |
|
|---|
| 164 |
and add this after it: |
|---|
| 165 |
|
|---|
| 166 |
$comment_code = $_POST['code']; // AuthImage |
|---|
| 167 |
|
|---|
| 168 |
4. FOR WORDPRESS VERSIONS < 1.5: You have two options next, both require editing 'wp-comments-post.php': |
|---|
| 169 |
|
|---|
| 170 |
To allow comments to come into the moderation pool, look for the following |
|---|
| 171 |
lines in 'wp-comments-post.php': |
|---|
| 172 |
|
|---|
| 173 |
if(check_comment($author, $email, $url, $comment, $user_ip)) { |
|---|
| 174 |
$approved = 1; |
|---|
| 175 |
} else { |
|---|
| 176 |
$approved = 0; |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
and add this afterwards: |
|---|
| 180 |
|
|---|
| 181 |
// authimage -- Check if valid code. If not valid, send to moderation. |
|---|
| 182 |
if ( !checkAICode($code) ) |
|---|
| 183 |
$approved = 0; |
|---|
| 184 |
|
|---|
| 185 |
-or- if you want to dump the comment altogether and warn the commenter |
|---|
| 186 |
that an invalid code was entered, look for the following lines in |
|---|
| 187 |
'wp-comments-post.php': |
|---|
| 188 |
|
|---|
| 189 |
if ( '' == $comment ) |
|---|
| 190 |
die( __('Error: please type a comment.') ); |
|---|
| 191 |
|
|---|
| 192 |
and add this after it: |
|---|
| 193 |
|
|---|
| 194 |
if ( !checkAICode($code) ) |
|---|
| 195 |
die( __('Error: please enter the valid authorization code.') ); |
|---|
| 196 |
|
|---|
| 197 |
FOR WORDPRESS VERSION 1.5: |
|---|
| 198 |
|
|---|
| 199 |
Look for the following lines n 'wp-comments-post.php': |
|---|
| 200 |
|
|---|
| 201 |
if ( '' == $comment_content ) |
|---|
| 202 |
die( __('Error: please type a comment.') ); |
|---|
| 203 |
|
|---|
| 204 |
and add this after it: |
|---|
| 205 |
|
|---|
| 206 |
// AuthImage |
|---|
| 207 |
if ( !checkAICode($comment_code) ) |
|---|
| 208 |
die( __('Error: please enter the valid authorization code.') ); |
|---|
| 209 |
|
|---|
| 210 |
5. Make sure you've activated the AuthImage plugin. |
|---|
| 211 |
|
|---|
| 212 |
6. Make sure your 'my-hacks.php' file contains what is in 'authimage-hacks.php'. |
|---|
| 213 |
THIS IS STILL REQUIRED! |
|---|
| 214 |
|
|---|
| 215 |
7. Enable the 'my-hacks.php legacy support' from your WP options. If you are not |
|---|
| 216 |
interested in using the JavaScript form checking, you can stop here. |
|---|
| 217 |
|
|---|
| 218 |
-- |
|---|
| 219 |
|
|---|
| 220 |
8. FOR WORDPRESS VERSIONS < 1.5: Edit 'wp-comments.php' AND 'wp-comments-popup.php' |
|---|
| 221 |
and change the following line. FOR WORDPRESS VERSION 1.5, this line is in |
|---|
| 222 |
'comments.php' AND 'comments-popup.php' in your theme's directory: |
|---|
| 223 |
|
|---|
| 224 |
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" |
|---|
| 225 |
method="post" id="commentform"> |
|---|
| 226 |
|
|---|
| 227 |
to read: |
|---|
| 228 |
|
|---|
| 229 |
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" |
|---|
| 230 |
method="post" id="commentform" onSubmit="return testValues(this)"> |
|---|
| 231 |
|
|---|
| 232 |
9. If you want to validate the email address, edit the plugin and uncomment |
|---|
| 233 |
the code that checks for email. That's it! |
|---|