Thanks Sumale.nin for your response and also for the MOD, but my changes/requirement is little bit different and I am currently doing the changes for myself.. I will update my website with this changes in this week only..
. but I must say thank you, because I got the idea of auto closing popup window from your comment_popup.php .
After implementing the changes.. I will post the codes here.. for experts reviews..
Thank you.. !!
Updates...
I am almost done with my changes.. but I don't think, the same changes will be required by any other webmasters.. so I am not posting all the code changes..
Here is how my comments.php file looks like...
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: commnets.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.6 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = 'comment_live';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
if (!$image_id) {
redirect($url);
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_id = $image_id AND i.image_active = 1 AND c.cat_id = i.cat_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
redirect($url);
}
//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error = 0;
if ($action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
$id = intval($HTTP_POST_VARS[URL_ID]);
$sql = "SELECT cat_id, image_allow_comments
FROM ".IMAGES_TABLE."
WHERE image_id = $id";
$row = $site_db->query_firstrow($sql);
if ($row['image_allow_comments'] == 0 || !check_permission("auth_postcomment", $row['cat_id']) || !$row) {
$msg = $lang['comments_deactivated'];
}
else {
$user_name = un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
$comment_headline = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
$comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";
// Flood Check
$sql = "SELECT comment_ip, comment_date
FROM ".COMMENTS_TABLE."
WHERE image_id = $id
ORDER BY comment_date DESC
LIMIT 1";
$spam_row = $site_db->query_firstrow($sql);
$spamtime = $spam_row['comment_date'] + 180;
if ($session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN) {
$msg .= (($msg != "") ? "<br />" : "").$lang['spamming'];
$error = 1;
}
$user_name_field = get_user_table_field("", "user_name");
if (!empty($user_name_field)) {
if ($site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("", "user_id")." <> '".$user_info['user_id']."'")) {
$msg .= (($msg != "") ? "<br />" : "").$lang['username_exists'];
$error = 1;
}
}
if ($user_name == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['name_required'];
$error = 1;
}
// if ($comment_headline == "") {
// $msg .= (($msg != "") ? "<br />" : "").$lang['headline_required'];
// $error = 1;
// }
if ($comment_text == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
if ($captcha_enable_comments && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
if (!$error) {
$sql = "INSERT INTO ".COMMENTS_TABLE."
(image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
VALUES
($id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
$site_db->query($sql);
$commentid = $site_db->get_insert_id();
update_comment_count($id, $user_info['user_id']);
$msg = "<script type=\"text/javascript\">
window.setTimeout('self.close()', 10);
</script>\n";
echo $msg;
} elseif ($error) {
echo '<div style="padding: 10px">' . $msg . '</div>';
}
}
unset($row);
unset($spam_row);
}
if ($image_allow_comments == 0) {
//-----------------------------------------------------
//--- BBCode & Form -----------------------------------
//-----------------------------------------------------
$allow_posting = check_permission("auth_postcomment", $cat_id);
$bbcode = "";
if ($config['bb_comments'] == 1 && $allow_posting) {
$site_template->register_vars(array(
"lang_bbcode" => $lang['bbcode'],
"lang_tag_prompt" => $lang['tag_prompt'],
"lang_link_text_prompt" => $lang['link_text_prompt'],
"lang_link_url_prompt" => $lang['link_url_prompt'],
"lang_link_email_prompt" => $lang['link_email_prompt'],
"lang_list_type_prompt" => $lang['list_type_prompt'],
"lang_list_item_prompt" => $lang['list_item_prompt']
));
$bbcode = $site_template->parse_template("bbcode");
}
if (!$allow_posting) {
$comment_form_live = "";
}
else {
$user_name = (isset($HTTP_POST_VARS['user_name']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['user_name'])), 2) : (($user_info['user_level'] != GUEST) ? format_text($user_info['user_name'], 2) : "");
$comment_headline = (isset($HTTP_POST_VARS['comment_headline']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_headline'])), 2) : "";
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";
$site_template->register_vars(array(
"bbcode" => $bbcode,
"user_name" => $user_name,
"comment_headline" => $comment_headline,
"comment_text" => $comment_text,
"url_form" => $site_sess->url(ROOT_PATH."comments.php?image_id=$image_id"),
"image_id" => $image_id,
"lang_post_comment" => $lang['post_comment'],
"lang_name" => $lang['name'],
"lang_headline" => $lang['headline'],
"lang_comment" => $lang['comment'],
"lang_captcha" => $lang['captcha'],
"lang_captcha_desc" => $lang['captcha_desc'],
"captcha_comments" => (bool)$captcha_enable_comments
));
$comment_form_live = $site_template->parse_template("comment_form_live");
}
$site_template->register_vars("comment_form_live", $comment_form_live);
unset($comment_form_live);
$site_template->print_template($site_template->parse_template($main_template));
} // end if allow_comments
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"msg" => $msg,
"clickstream" => $clickstream,
"lang_category" => $lang['category'],
"lang_added_by" => $lang['added_by'],
"lang_description" => $lang['description'],
"lang_keywords" => $lang['keywords'],
"lang_date" => $lang['date'],
"lang_hits" => $lang['hits'],
"lang_downloads" => $lang['downloads'],
"lang_rating" => $lang['rating'],
"lang_votes" => $lang['votes'],
"lang_author" => $lang['author'],
"lang_comment" => $lang['comment'],
"lang_prev_image" => $lang['prev_image'],
"lang_next_image" => $lang['next_image'],
"lang_file_size" => $lang['file_size']
));
//$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
Could any php/4image guru review this code and let me know the unwanted parts, so that I can remove it from here...
If anyone wants a demo of this changes .. they can visit any images which is under wallpaper section and try to download any size image.. ( not original version.. Its under development..
)
Thank you.