I think there is some confusion in adding this mod for the average user which does not know PHP or how it is coded.
So I'm going to post a clear how to:
I will do this in steps for everyone.
1) Check to make sure your host has GD Support with FreeType Support. If not then this will not work for you. You can check this by making a php page with phpinfo(); in it and uploading it to your site. Under gd you will see the above if it is installed on their server.
2) Now upload captcha.php and fonts directory in your coppermine root directory and then upload captcha.class.php in include directory.
3) Open lang/english.php
Find:
'non_exist_comment' => 'The selected comment does not exist', //cpg1.4
Just under that add:
'captcha_error' => 'The confirmation code didn\'t matched',
Find:
'report_comment_title' => 'Report this comment to the administrator', //cpg1.4
Just under that add:
'confirm' => 'Confirmation',
Save and close.
4) This is where is gets some what confusing.
We now want to open themes/yourtheme/theme.php (for an example we will do eyeball).
Now we want to also open themes/sample/theme.php
In themes/sample/theme.php Find & Copy:
function theme_html_comments($pid)
{
global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
global $template_image_comments, $template_add_your_comment, $lang_display_comments;
$html = '';
//report to moderator buttons
if (!(($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS))) {
template_extract_block($template_image_comments, 'report_comment_button');
}
if (!$CONFIG['enable_smilies']) {
$tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
template_extract_block($template_image_comments, 'edit_box_smilies');
template_extract_block($template_add_your_comment, 'input_box_smilies');
} else {
$tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
template_extract_block($template_image_comments, 'edit_box_no_smilies');
template_extract_block($template_add_your_comment, 'input_box_no_smilies');
}
$tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
$tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');
if ($CONFIG['comments_sort_descending'] == 1) {
$comment_sort_order = 'DESC';
} else {
$comment_sort_order = 'ASC';
}
$result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid' ORDER BY msg_id $comment_sort_order");
while ($row = mysql_fetch_array($result)) {
$user_can_edit = (GALLERY_ADMIN_MODE) || (USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS) || (!USER_ID && USER_CAN_POST_COMMENTS && ($USER['ID'] == $row['author_md5_id']));
$comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
$comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
$comment_ipinfo = ($row['msg_raw_ip'] && GALLERY_ADMIN_MODE)?$tmpl_comments_ipinfo : '';
if ($CONFIG['enable_smilies']) {
$comment_body = process_smilies(make_clickable($row['msg_body']));
$smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
} else {
$comment_body = make_clickable($row['msg_body']);
$smilies = '';
}
$ip = $row['msg_hdr_ip'];
if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
$ip .= ' [' . $row['msg_raw_ip'] . ']';
}
$params = array('{EDIT}' => &$comment_edit_box,
'{BUTTONS}' => &$comment_buttons,
'{IPINFO}' => &$comment_ipinfo
);
$template = template_eval($template_image_comments, $params);
$params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
'{MSG_ID}' => $row['msg_id'],
'{PID}' => $row['pid'],
'{EDIT_TITLE}' => &$lang_display_comments['edit_title'],
'{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'],
'{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt),
'{MSG_BODY}' => bb_decode($comment_body),
'{MSG_BODY_RAW}' => $row['msg_body'],
'{OK}' => &$lang_display_comments['OK'],
'{SMILIES}' => $smilies,
'{IP}' => $ip,
'{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'],
'{WIDTH}' => $CONFIG['picture_table_width']
);
$html .= template_eval($template, $params);
}
if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
if (USER_ID) {
$user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
$user_name = '';
} else {
$user_name = isset($USER['name']) ? '"' . strtr($USER['name'], $HTML_SUBST) . '"' : $lang_display_comments['your_name'] . '" onclick="javascript:this.value=\'\';';
}
$params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'],
// Modified Name and comment field
'{NAME}' => $lang_display_comments['name'],
'{COMMENT}' => $lang_display_comments['comment'],
'{CONFIRM}' => $lang_display_comments['confirm'],
'{PIC_ID}' => $pid,
'{USER_NAME}' => $user_name,
'{MAX_COM_LENGTH}' => $CONFIG['max_com_size'],
'{OK}' => $lang_display_comments['OK'],
'{SMILIES}' => '',
'{WIDTH}' => $CONFIG['picture_table_width'],
);
if ($CONFIG['enable_smilies']){
$params['{SMILIES}'] = generate_smilies();
} else {
template_extract_block($template_add_your_comment, 'smilies');
}
$html .= template_eval($template_add_your_comment, $params);
}
return $html;
}
Now we want to paste that copy in your theme (again in this case the eyeball theme) just above the PHP close ?>.
Now that is done go back to themes/sample/theme.php then
Find & Copy:
$template_add_your_comment = <<<EOT
<form method="post" name="post" action="db_input.php">
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td width="100%" class="tableh2_compact"><b>{ADD_YOUR_COMMENT}</b></td>
</tr>
<tr>
<td colspan="1">
<table width="100%" cellpadding="0" cellspacing="0">
<!-- BEGIN user_name_input -->
<tr>
<td class="tableb_compact">
{NAME}
</td>
<td class="tableb_compact">
<input type="text" class="textinput" name="msg_author" size="10" maxlength="20" value="{USER_NAME}" />
</td>
<!-- END user_name_input -->
<!-- BEGIN input_box_smilies -->
<td class="tableb_compact">
{COMMENT}
</td>
<td width="100%" class="tableb_compact">
<input type="text" class="textinput" id="message" name="msg_body" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
</td>
<!-- END input_box_smilies -->
<!-- BEGIN input_box_no_smilies -->
<td class="tableb_compact">
{COMMENT}
</td>
<td width="100%" class="tableb_compact">
<input type="text" class="textinput" id="message" name="msg_body" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
</td>
<!-- END input_box_no_smilies -->
<td class="tableb_compact">
<input type="hidden" name="event" value="comment" />
<input type="hidden" name="pid" value="{PIC_ID}" />
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</tr>
</table>
</td>
</tr>
<!-- BEGIN smilies -->
<tr>
<td width="100%" class="tableb_compact">
{SMILIES}
</td>
</tr>
<!-- END smilies -->
</table>
</form>
EOT;
Now we want to paste that copy in your theme (again in this case the eyeball theme) just above the PHP close ?> again.
5) Now we want to search your theme file (again in this caes eyeball) for:
<!-- END input_box_no_smilies -->
<td class="tableb_compact">
<input type="hidden" name="event" value="comment" />
<input type="hidden" name="pid" value="{PIC_ID}" />
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td></tr>
Just after that add:
<tr>
<td class="tableb_compact" colspan="2">
{CONFIRM}
</td>
<td class="tableb_compact" colspan="2">
<input type="text" name="confirmCode" size="5" class="textinput"> <img src="captcha.php" align="middle">
</td>
</tr>
Save and close.
6) Open db_input.php
Find:
case 'comment':
if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
Just after that add:
require("include/captcha.class.php");
if (!PhpCaptcha::Validate($_POST['confirmCode'])) {
cpg_die(ERROR, "Confirmation code didn't matched", __FILE__, __LINE__);
}
Save and Close.
Thats it..... You're done.....
I hope this helps out some people having problems. I also hope this is not looked at as a double post to Abbas Ali first post, I just thought it would help some with how to add it to their theme as his post was not clear on that part.
Thanks for the great mod and the time it took!
Jake