
ecard image verification mod for Coppermine Photo Gallery, version 1.4.9 (also tested with 1.4.8)
works with the classic theme. have not tried it with other themes, but it should work.
by wirewolf,http://academyphotos.net
see working mod at http://academyphotos.net/photogallery/displayimage-425-Ships'-Compass-Binnacle.html , just hit the E-Card link

Note: you will notice that I have mod-rewrite on my site. this mod will work with the standard 1.4.9 files.

files to edit - 2:
ecard.php
lang/english.php // you will have to add your own translations for other languages

new file to add - 1:
randomimage.php // generates the random image code. I'm not sure who the author is of this file.
there are numerous files out there called randomimage.php. I got this from a friend and it came with no identifying
information.

all edited lines are commented with - // image verify mod
and every line in the randomimage.php file has a comment so you can clearly understand what it is doing
the only lines in this file you should edit are the ones for the image text color and for the image background color
go to http://web.forret.com/tools/color.asp for color conversions

as always with any editing to existing files, BACKUP!! before applying the changes

step 1:
upload randomimage.php into the root folder of your gallery (same place where the ecard.php file is located)

step 2:
edit lang/english.php

find - around line 1066 in the File ecard.php section:

'preview_button' => 'Preview', //cpg1.4

replace with:

'preview_button' => 'Preview Ecard Before Sending', //cpg1.4 image verify mod

find - around line 1068 in the File ecard.php section:

'preview_view_ecard' => 'This will be the alternate link to the ecard once it gets generated. It won\'t work for previews.', //cpg1.4

add after:

// image verify mod
'error_image' => 'Please enter a valid image verification code!<br />Maybe you\'re having trouble seeing the image code clearly.<br />Hit the \'Reset Image and Preview Ecard Again\'',
'reset_image_button' => 'Reset Image and Preview Ecard Again',
'image_info' => 'Before hitting the \'Send ecard\' button, please enter this image verification code:',
'image_button' => 'This is to prevent automated entry from search robots. Letters must be in upper case.<br /><br />If you have trouble reading the image, just hit this button >>',
'server_info' => 'Please hit the \'Send ecard\' button only once to allow the server time to send your ecard',
// image verify mod

end edit lang/english.php
upload edited lang/english.php file


step 3:
edit ecard.php

find - around line 54 (approx.):

$sender_email_warning = '';
$recipient_email_warning = '';

add after:

$error_image = ''; // image verify mod

find - around line 79 (approx.):

// Create and send the e-card

add after:
// image verify mod

session_start();

$number = $_POST['confirmcode'];

if (empty($number) || md5($number) != $_SESSION['image_random_value']);{
   $error_image = '<br /><font size="2" color="red">' . $lang_ecard_php['error_image'] . '</font><br />';
}

// image verify mod

find - around line 80 (approx.):

if (count($_POST) > 0 && $valid_sender_email && $valid_recipient_email) {

replace with:

// image verify mod
if (count($_POST) > 0 && $valid_sender_email && $valid_recipient_email && md5($number) == $_SESSION['image_random_value']) { 

find - around line 280 (approx.):

echo generate_smilies();
echo <<<EOT
                </td>
        </tr>
        <tr>
                <td colspan="3" align="center" class="tablef">
                        <input type="submit" class="button" name="preview" title="{$lang_ecard_php['preview_button']}" value="{$lang_ecard_php['preview_button']}" />
                                                                                                &nbsp;&nbsp;
                        <input type="submit" class="button" name="submit" title="{$lang_ecard_php['submit_button']}" value="{$lang_ecard_php['submit_button']}" />
                        </form>
                </td>
        </tr>
EOT;

endtable();
pagefooter();
ob_end_flush();

replace with (Note - the choice of <span class="footer"> is optional.
if you want regular size text, just eliminate the <span class="footer"> and </span> tags):

// image verify mod

echo generate_smilies();
echo <<<EOT
               </td>
        </tr>
        <tr>
                <td colspan="3" align="center" class="tablef">
                <input type="submit" class="button" name="preview" title="{$lang_ecard_php['preview_button']}" value="{$lang_ecard_php['preview_button']}" />
EOT;
if (count($_POST) > 0 && $valid_sender_email && $valid_recipient_email) {
echo <<<EOT
              <div align="center" valign="middle">
                <span class="footer">{$lang_ecard_php['image_info']}&nbsp;</span>
                  <input type="text" name="confirmcode" size="6" class="textinput">&nbsp;<img src="randomimage.php"><br />
                  <span class="footer">{$lang_ecard_php['image_button']}</span>&nbsp;
                  <input type="submit" class="button" name="preview" title="{$lang_ecard_php['reset_image_button']}" value="{$lang_ecard_php['reset_image_button']}" />
                  <br /><br /><span class="footer">{$lang_ecard_php['server_info']}</span>&nbsp;
                  <input type="submit" class="button" name="submit" title="{$lang_ecard_php['submit_button']}" value="{$lang_ecard_php['submit_button']}" /><br />$error_image<br />						
               </div>
EOT;
}
echo <<<EOT
                     </form>
              </td>
        </tr>
EOT;

endtable();
pagefooter();
ob_end_flush();

// end image verify mod

end edit ecard.php
upload edited ecard.php file

end of ecard image verification mod

=================================

that's it! try it out!
send an ecard to a friend or have them send one to you!
hopefully this will stop the spammers from cluttering up your site with garbage.

wirewolf, John

=================================
optional image background code:

added a alternate randomimage_alt.php file. see file for edit details.
!!! don't edit this file except for line 20 !!!
choose 2 for a multi colored background or 3 for a cross hatched background 

step 1:
upload the two included images, background2.png and background3.png to the same folder where the randomimage.php file is located

step2:
rename randomimage_alt.php to randomimage.php and upload to replace the original randomimage.php file
(be sure to save the original in case you want to go back to it)
