ok well here it goes... please note im mediocore in php and sql...
Files i changed:
dbinput.php
theme.php
first add the SQL table to cpg_comments that the commenters URL will be written too... i called mine "msg_url" (see image).
edit dbinput.php
add "$msg_url = trim($_POST['msg_url']);" into the //comment update section here:
check_comment($_POST['msg_body']);
check_comment($_POST['msg_author']);
$msg_body = addslashes(trim($_POST['msg_body']));
$msg_author = addslashes(trim($_POST['msg_author']));
$msg_url = trim($_POST['msg_url']);
$msg_id = (int)$_POST['msg_id'];
and into the //comment section here:
check_comment($_POST['msg_body']);
check_comment($_POST['msg_author']);
$msg_author = addslashes(trim($_POST['msg_author']));
$msg_body = addslashes(trim($_POST['msg_body']));
$msg_url = trim($_POST['msg_url']);
$pid = (int)$_POST['pid'];
Then add msg_url into the query under
"// Anonymous users, we need to use META refresh to save the cookie" here (its important you place the "msg_url" text in the proper spot in the list or it will show in the wrong table:
$insert = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_url, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '{$CONFIG['comments_anon_pfx']}$msg_author', '$msg_body', '$msg_url', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
and again insert msg_url under the
// Registered users, we can use Location to redirect section here (again placement is important):
$insert = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_url, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
Now we're done editing the dpinput.php file.
next open theme.php and insert the following (if you already have it just edit it)
the $template_image_comments is for displaying the new db information. i created a new function and token called {MSG_URL} that can be placed anywhere in the display_comments section. heres how i did it.
// HTML template for the display of comments
$template_image_comments = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="tableh2_compact" nowrap="nowrap">
<b>{MSG_AUTHOR}</b> - <a href="http://{MSG_URL}">{MSG_URL}</a><a name="comment{MSG_ID}"></a>
<!-- BEGIN ipinfo -->
({IP})
<!-- END ipinfo -->
</td>
<td class="tableh2_compact" align="right" width="100%">
<!-- BEGIN report_comment_button -->
<a href="report_file.php?pid={PID}&msg_id={MSG_ID}&what=comment" title="{REPORT_COMMENT_TITLE}"><img src="images/report.gif" width="16" height="16" border="0" align="middle" alt="{REPORT_COMMENT_TITLE}" /></a>
<!-- END report_comment_button -->
<!-- BEGIN buttons -->
<a href="javascript:;" onclick="blocking('cbody{MSG_ID}','', 'block'); blocking('cedit{MSG_ID}','', 'block'); return false;" title="{EDIT_TITLE}"><img src="images/edit.gif" border="0" align="middle" /></a>
<a href="delete.php?msg_id={MSG_ID}&what=comment" onclick="return confirm('{CONFIRM_DELETE}');"><img src="images/delete.gif" border="0" align="middle" /></a>
<!-- END buttons -->
</td>
<td class="tableh2_compact" align="right" nowrap="nowrap">
<span class="comment_date">[{MSG_DATE}]</span>
</td></tr>
</table>
</td>
</tr>
<tr>
<td class="tableb_compact">
<div id="cbody{MSG_ID}" style="display:block">
{MSG_BODY}
</div>
<div id="cedit{MSG_ID}" style="display:none">
<!-- BEGIN edit_box_smilies -->
<table width="100%" cellpadding="0" cellspacing="0">
<form name="f{MSG_ID}" method="POST" action="db_input.php">
<input type="hidden" name="event" value="comment_update" />
<input type="hidden" name="msg_id" value="{MSG_ID}" />
<tr>
<td>
<input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
</td><td>
</tr>
<tr>
<td width="80%">
<textarea cols="40" rows="2" class="textinput" name="msg_body" onselect="storeCaret_f{MSG_ID}(this);" onclick="storeCaret_f{MSG_ID}(this);" onkeyup="storeCaret_f{MSG_ID}(this);" style="width: 100%;">{MSG_BODY_RAW}</textarea>
</td>
<td class="tableb_compact">
</td>
<td>
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</form>
</tr>
<tr>
<td colspan="3"><img src="images/spacer.gif" width="1" height="2" /><br /></td>
</tr>
</table>
{SMILIES}
<!-- END edit_box_smilies -->
<!-- BEGIN edit_box_no_smilies -->
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<form name="f{MSG_ID}" method="POST" action="db_input.php">
<input type="hidden" name="event" value="comment_update" />
<input type="hidden" name="msg_id" value="{MSG_ID}" />
<td>
<input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
</td>
</tr>
<tr>
<td width="100%">
<textarea cols="40" rows="2" class="textinput" name="msg_body" style="width: 100%;">{MSG_BODY_RAW}</textarea>
</td>
<td class="tableb_compact">
</td>
<td>
<input type="submit" class="comment_button" name="submit" value="{OK}" />
</td>
</form>
</tr>
<tr>
<td colspan="3"><img src="images/spacer.gif" width="1" height="2" /><br /></td>
</tr>
</table>
<!-- END edit_box_no_smilies -->
</div>
</td>
</tr>
</table>
EOT;
Next we need the function that created the {MSG_URL} token... its located in the
"function theme_html_comments($pid)" section. add this to your theme.php file if you dont already have it.
// Displays comments for a specific picture
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, msg_url, 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'],
'{MSG_URL}' => $row['msg_url'],
'{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 {
if (isset($USER['name'])) {
$user_name = strtr($USER['name'], $HTML_SUBST);
} else {
$user_name = $lang_display_comments['your_name'];
}
}
$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'],
'{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;
}
EOT;
Next we need the text input form where the user can enter his/her website. i added this to the "add comments" section of the theme.php file. add this if you dont already have it.
// HTML template for the form to add comments
$template_add_your_comment = <<<EOT
<form method="post" name="post" action="db_input2.php">
<!-- Start flushing the previous data memory-->
<?php
$msg_author = "";
$msg_body ="";
$toxic = "";
?>
<!-- end flushing the previous data memory -->
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable"
bgcolor="#FFFFFF">
<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" colspan="4" align="left">
<input type="text" class="textinput" name="msg_author" size="20"
maxlength="30" value="{USER_NAME}" />
</td>
<!-- END user_name_input -->
<tr>
<td class="tableb_compact">
http://
</td>
<td class="tableb_compact">
<input type="text" class="textinput" name="msg_url" size="20"
maxlength="70" value="" />
</td>
<!-- 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">
</td>
</tr>
</table>
</td>
</tr>
<!-- BEGIN smilies -->
<tr>
<td width="100%" class="tableb_compact">
{SMILIES}
</td>
</tr>
<!-- END smilies -->
</table>
</form>
EOT;
And that should be it.
again... im a newbie to php/sql stuff, so there might be some errors... use at your own risk it works for me on my custom theme. Also, i havent written the code to EDIT the url after a person posts... it shouldnt be too hard but i dont really need that function. if someone else wants to improve on this that'd be great!
also, if anyone can tell me another way of doing this without editing the DBinput file that would also be great.
Live demo at:
www.dillonpic.com