message
This commit is contained in:
252
system/forum/action/addpost.php
Normal file
252
system/forum/action/addpost.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
|
||||
|
||||
if (check_access($forum_config['post_captcha']))
|
||||
{
|
||||
if ($_REQUEST['sec_code'] !== $_SESSION['sec_code_session'] and isset($_SESSION['sec_code_session']))
|
||||
{
|
||||
$post_captcha = true;
|
||||
|
||||
$_SESSION['sec_code_session'] = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_captcha = false;
|
||||
}
|
||||
|
||||
include_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
$post_text = $parse->process($post_text);
|
||||
|
||||
$post_text = $db->safesql($parse->BB_Parse($post_text, FALSE));
|
||||
|
||||
$post_text = auto_wrap ($post_text);
|
||||
|
||||
if (strlen($post_text) > $forum_config['post_maxlen'])
|
||||
{
|
||||
$post_maxlen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_maxlen = false;
|
||||
}
|
||||
|
||||
$topic_title = $db->safesql(urldecode($topic_title));
|
||||
|
||||
if (!$is_logged)
|
||||
{
|
||||
$name = $db->safesql($parse->BB_Parse($parse->process($name), TRUE));
|
||||
|
||||
$mail = $db->safesql($parse->BB_Parse($parse->process($mail), TRUE));
|
||||
|
||||
$member_id['name'] = $name;
|
||||
|
||||
if ($name)
|
||||
{
|
||||
$db->query("SELECT name from " . USERPREFIX . "_users where LOWER(name) = '".strtolower($name)."'");
|
||||
|
||||
if (!$db->num_rows()){
|
||||
$name_ok = true;
|
||||
}else{
|
||||
$name_ok = false;
|
||||
$stop .= $f_lang['err_name'];
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
|
||||
if ($mail)
|
||||
{
|
||||
if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)){
|
||||
$mail_ok = true;
|
||||
}else{
|
||||
$mail_ok = false;
|
||||
$stop .= $f_lang['err_mail'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($name_ok and $mail_ok)
|
||||
{
|
||||
$add_post_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$add_post_ok = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$add_post_ok = true;
|
||||
}
|
||||
|
||||
$_TIME = time()+($config['date_adjust']*60);
|
||||
|
||||
$topic_date = date ("Y-m-d H:i:s", $_TIME);
|
||||
|
||||
$_IP = $db->safesql($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if ($post_text and $topic_id and $forum_id and $add_post_ok and !$post_captcha and !$post_maxlen)
|
||||
{
|
||||
$postcount = intval ($forums_array[$forum_id]['postcount']);
|
||||
|
||||
if ($forum_config['post_update'])
|
||||
{
|
||||
$row = $db->super_query("SELECT pid, topic_id, post_author, DATE_FORMAT(post_date,'%Y-%m-%d') as post_date, post_text, is_register, post_ip FROM " . PREFIX . "_forum_posts WHERE topic_id = '$topic_id' ORDER BY pid DESC LIMIT 0,1");
|
||||
|
||||
$post_id = $row['pid'];
|
||||
|
||||
if ($row['post_author'] == $member_id['name'] AND $row['is_register']) $update_post = true;
|
||||
elseif ($row['ip'] == $_IP AND !$row['is_register'] AND !$is_logged) $update_post = true;
|
||||
|
||||
if ($row['post_date'] != date("Y-m-d", $_TIME)) $update_post = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!$update_post){
|
||||
|
||||
$db->query("INSERT INTO " . PREFIX . "_forum_posts (topic_id, post_date, post_author, post_text, post_ip, is_register, e_mail, is_count) values ('$topic_id', '$topic_date', '$member_id[name]', '$post_text', '$_IP', '$is_logged', '$mail', '$postcount')");
|
||||
|
||||
$new_pid = $db->insert_id();
|
||||
|
||||
// update table //
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET post = post+1, last_date = '$topic_date', last_poster_name = '$member_id[name]', last_post_id = '$new_pid' WHERE tid = '$topic_id'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET posts = posts+1, f_last_tid = '$topic_id', f_last_title = '$topic_title', f_last_date = '$topic_date', f_last_poster_name = '$member_id[name]', last_post_id = '$new_pid' WHERE id = '$forum_id'");
|
||||
|
||||
if ($is_logged)
|
||||
{
|
||||
if ($postcount)
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_users SET forum_post = forum_post+1 WHERE name = '$member_id[name]'");
|
||||
}
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_views WHERE topic_id = '$topic_id' and user_id != '$member_id[user_id]'");
|
||||
}
|
||||
|
||||
if ($forum_config['set_sub_last_up'] and $is_parentid = $forums_array[$forum_id]['parentid'])
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET f_last_tid = '$topic_id', f_last_title = '$topic_title', f_last_date ='$topic_date', f_last_poster_name = '$member_id[name]' WHERE id ='$is_parentid'");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$stop_subscription = true;
|
||||
|
||||
$post_text = $db->safesql($row['post_text'] . "<br /><br />" . stripslashes($post_text));
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts set post_text = '{$post_text}' WHERE pid = '{$post_id}'");
|
||||
|
||||
$new_pid = $post_id;
|
||||
}
|
||||
|
||||
if ($post_id)
|
||||
{
|
||||
if (stristr ($post_text, "[attachment="))
|
||||
{
|
||||
$result = $db->query("SELECT * FROM " . PREFIX . "_forum_files
|
||||
WHERE topic_id = '$topic_id' and file_attach = '0'");
|
||||
|
||||
while ($att = $db->get_row($result))
|
||||
{
|
||||
if (stristr ($post_text, "[attachment=".$att['file_id']."]") OR stristr ($post_text, "[attachment=".$att['file_id'].":url]"))
|
||||
{
|
||||
$update_id[] = $att['file_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_id)
|
||||
{
|
||||
$update_list = implode(',', $update_id);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_files SET topic_id = '$topic_id', post_id = '$new_pid', file_attach = '1' WHERE file_id IN ({$update_list})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cache->clear ('forum_show_last');
|
||||
|
||||
$topic_location = $forum_url."/topic_{$topic_id}/{$page}#post-{$new_pid}";
|
||||
|
||||
if (!$ajax_adds)
|
||||
{
|
||||
header("Location: {$topic_location}");
|
||||
}
|
||||
|
||||
if ($forum_config['subscription'] AND !$stop_subscription)
|
||||
{
|
||||
$all_subscr = $db->query("SELECT name, email FROM ". PREFIX ."_forum_subscription AS t1 INNER JOIN ". PREFIX ."_users AS t2 ON t1.user_id = t2.user_id WHERE t1.topic_id = $topic_id and t1.user_id != '{$member_id['user_id']}'");
|
||||
|
||||
if ($db->num_rows($all_subscr))
|
||||
{
|
||||
include_once SYSTEM_DIR.'/classes/mail.class.php';
|
||||
|
||||
$mail = new dle_mail ($config);
|
||||
|
||||
$topic_link = $a_forum_url."showtopic={$topic_id}&lastpost=1#reply";
|
||||
|
||||
$topic_link_del = $config['http_home_url']."?do=forum&act=subscription&code=del&selected_id={$topic_id}";
|
||||
|
||||
$mail_tpl = $db->super_query("SELECT template FROM " . PREFIX . "_forum_email where name='subscription_text' LIMIT 0,1");
|
||||
|
||||
$mail_tpl['template'] = stripslashes($mail_tpl['template']);
|
||||
|
||||
while ($mail_row = $db->get_row($all_subscr))
|
||||
{
|
||||
$mail_result = str_replace("{%username_to%}", $mail_row['name'], $mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%username_from%}", $member_id['name'], $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%topic_name%}", $topic_title, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%topic_link%}", $topic_link, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%topic_link_del%}", $topic_link_del, $mail_result);
|
||||
|
||||
$mail_title = "Óâåäîìëåíèå îá îòâåòàõ íà ïîäïèñàííóþ òåìó";
|
||||
|
||||
$mail->send ($mail_row['email'], $mail_title, $mail_result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$cache->clear ('forum_show_last');
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!$add_post_ok)
|
||||
{
|
||||
forum_msg($f_lang['all_info'], $stop);
|
||||
|
||||
$add_post_error = $stop;
|
||||
}
|
||||
|
||||
elseif ($post_captcha)
|
||||
{
|
||||
forum_msg($f_lang['all_info'], $f_lang['captcha_stop']);
|
||||
|
||||
$add_post_error = $f_lang['ajax_stop_2'];
|
||||
}
|
||||
|
||||
elseif ($post_maxlen)
|
||||
{
|
||||
forum_msg($f_lang['all_info'], $f_lang['maxlen_stop']);
|
||||
|
||||
$add_post_error = $f_lang['ajax_stop_4'];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['all_info'], $f_lang['values_error']);
|
||||
|
||||
$add_post_error = $f_lang['ajax_stop_3'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
325
system/forum/action/addtopic.php
Normal file
325
system/forum/action/addtopic.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
|
||||
|
||||
$forum_id = intval($_REQUEST['forum_id']);
|
||||
$postcount = intval ($forums_array[$forum_id]['postcount']);
|
||||
$subscription = intval($_REQUEST['subscription']);
|
||||
|
||||
// Îòêðûòèå íîâîé òåìû ïðè ìèíèìóìå ñîîáùåíèé íà ôîðóìå ó þçåðà
|
||||
if ($member_id['forum_post'] >= $forum_config['min_post'] OR $member_id['user_group'] < 2){
|
||||
$access_topic = check_access($forums_array[$forum_id]['access_topic']);
|
||||
}else{
|
||||
$access_topic = false;
|
||||
forum_msg($f_lang['all_info'], "Äëÿ îòêðûòèÿ íîâîé òåìû íóæíî èìåòü ìèíèìóì ".$forum_config['min_post']." ïîëåçíûõ ñîîáùåíèé íà ôîðóìå");
|
||||
}
|
||||
//Îòêðûòèå íîâîé òåìû ïðè ìèíèìóìå ñîîáùåíèé íà ôîðóìå ó þçåðà.
|
||||
|
||||
if ($access_topic)
|
||||
{
|
||||
if (!$_REQUEST['subaction'])
|
||||
{
|
||||
$access_upload = check_access($forums_array[$forum_id]['access_upload']);
|
||||
|
||||
$upload_var = array('area' => "topic", 'forum_id' => $forum_id, 'topic_id' => get_salt(),);
|
||||
|
||||
$tpl->set('[not-wysywyg]', "");
|
||||
|
||||
$tpl->set('{wysiwyg}','');
|
||||
|
||||
$tpl->set('[/not-wysywyg]',"");
|
||||
|
||||
include_once SYSTEM_DIR.'/forum/sources/components/bbcode.php';
|
||||
|
||||
$topic_action_add = $a_forum_url."act=add_topic&subaction=1";
|
||||
|
||||
$tpl->load_template($tpl_dir.'addtopic.tpl');
|
||||
|
||||
$tpl->set('{bbcode}',$bb_code);
|
||||
$tpl->set('{topic_title}',"");
|
||||
$tpl->set('{topic_descr}',"");
|
||||
$tpl->set('{text}',"");
|
||||
|
||||
if ($is_logged)
|
||||
{
|
||||
$tpl->set_block("'\\[not-logged\\](.*?)\\[/not-logged\\]'si","");
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->set('[not-logged]','');
|
||||
$tpl->set('[/not-logged]','');
|
||||
}
|
||||
|
||||
if (check_access($forum_config['tools_poll']))
|
||||
{
|
||||
$tpl->set('[poll]','');
|
||||
$tpl->set('[/poll]','');
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->set_block("'\\[poll\\](.*?)\\[/poll\\]'si","");
|
||||
}
|
||||
|
||||
if (check_access($forum_config['topic_captcha']))
|
||||
{
|
||||
$tpl->set('[sec_code]',"");
|
||||
$tpl->set('[/sec_code]',"");
|
||||
|
||||
$path = parse_url($config['http_home_url']);
|
||||
$anti_bot = !defined('FORUM_SUB_DOMAIN') ? 'system/modules/' : '';
|
||||
|
||||
$tpl->set('{sec_code}',"<span id=\"dle-captcha\"><img src=\"".$path['path'].$anti_bot."antibot.php\" alt=\"${lang['sec_image']}\" border=\"0\"></span>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->set('{sec_code}',"");
|
||||
$tpl->set_block("'\\[sec_code\\](.*?)\\[/sec_code\\]'si","");
|
||||
}
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"forum-post-form\" id=\"forum-post-form\" action=\"{$topic_action_add}\">".$tpl->copy_template."
|
||||
<input type=\"hidden\" name=\"forum_id\" value=\"{$forum_id}\" />
|
||||
<input type=\"hidden\" name=\"add_tid\" value=\"{$upload_var['topic_id']}\" /></form>
|
||||
<div id=\"uploads-form\"></div>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (check_access($forum_config['topic_captcha']))
|
||||
{
|
||||
if ($_REQUEST['sec_code'] !== $_SESSION['sec_code_session'] and isset($_SESSION['sec_code_session']))
|
||||
{
|
||||
$topic_captcha = true;
|
||||
|
||||
$_SESSION['sec_code_session'] = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_captcha = false;
|
||||
}
|
||||
|
||||
if (!$topic_captcha){
|
||||
|
||||
require_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
if (!$is_logged)
|
||||
{
|
||||
$name = $db->safesql($parse->process(trim($_POST['name'])));
|
||||
$mail = $db->safesql($parse->process(trim($_POST['mail'])));
|
||||
|
||||
$member_id['name'] = $name;
|
||||
|
||||
$db->query("SELECT name from " . USERPREFIX . "_users where LOWER(name) = '".strtolower($name)."'");
|
||||
|
||||
if (!$db->num_rows() > 0)
|
||||
{
|
||||
$name_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$name_ok = false;
|
||||
}
|
||||
|
||||
$db->free();
|
||||
|
||||
if(preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail))
|
||||
{
|
||||
$mail_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail_ok = false;
|
||||
}
|
||||
|
||||
if ($name_ok and $mail_ok)
|
||||
{
|
||||
$access_add = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$access_add = false;
|
||||
|
||||
if (!$name_ok) $stop .= $f_lang['err_name'];
|
||||
|
||||
if (!$mail_ok) $stop .= $f_lang['err_mail'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$access_add = true;
|
||||
}
|
||||
|
||||
$topic_title = $db->safesql($parse->process($_POST['topic_title']));
|
||||
$topic_descr = $db->safesql($parse->process($_POST['topic_descr']));
|
||||
|
||||
$topic_text = $parse->process($_POST['post_text']);
|
||||
|
||||
$topic_text = $db->safesql($parse->BB_Parse($topic_text, FALSE));
|
||||
|
||||
$topic_text = auto_wrap ($topic_text);
|
||||
|
||||
if (strlen($topic_text) > $forum_config['post_maxlen'])
|
||||
{
|
||||
$post_maxlen = true;
|
||||
|
||||
$stop .= $f_lang['ajax_stop_4'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_maxlen = false;
|
||||
}
|
||||
|
||||
if ($topic_title and $topic_text and $access_add and !$post_maxlen)
|
||||
{
|
||||
$_IP = $db->safesql($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$vote_title = trim($db->safesql($parse->process($_POST['vote_title'])));
|
||||
$frage = trim($db->safesql($parse->process($_POST['frage'])));
|
||||
$vote_body = $db->safesql($parse->BB_Parse($parse->process($_POST['vote_body']), false));
|
||||
$poll_multiple = intval($_POST['poll_multiple']);
|
||||
|
||||
$_TIME = time()+($config['date_adjust']*60);
|
||||
$topic_date = date ("Y-m-d H:i:s", $_TIME);
|
||||
|
||||
if ($forum_config['meta_topic'])
|
||||
{
|
||||
$meta = forum_metatags($topic_title . ' ' . $topic_descr . ': ' . $topic_text);
|
||||
}
|
||||
else{ $meta = ""; }
|
||||
|
||||
$db->query("INSERT INTO " . PREFIX . "_forum_topics (forum_id, title, topic_descr, author_topic, start_date, last_date, last_poster_name, poll_title, frage, poll_body, multiple, meta_descr, meta_keywords) values ('$forum_id', '$topic_title', '$topic_descr', '$member_id[name]', '$topic_date', '$topic_date', '$member_id[name]', '$vote_title', '$frage', '$vote_body', '$poll_multiple', '$meta[description]', '$meta[keywords]')");
|
||||
|
||||
$topic_id = $db->insert_id();
|
||||
|
||||
$db->query("INSERT INTO " . PREFIX . "_forum_posts (topic_id, post_date, post_author, post_text, post_ip, is_register, e_mail, is_count) values ('$topic_id', '$topic_date', '$member_id[name]', '$topic_text', '$_IP', '$is_logged', '$mail', '$postcount')");
|
||||
|
||||
$new_pid = $db->insert_id();
|
||||
|
||||
set_first_post_id ($topic_id, $new_pid);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET topics = topics+1, f_last_tid = '$topic_id', f_last_title = '$topic_title', f_last_date ='$topic_date', f_last_poster_name = '$member_id[name]' WHERE id ='$forum_id'");
|
||||
|
||||
if ($forum_config['set_topic_post'] and $postcount and $is_logged)
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_users SET forum_post = forum_post+1 WHERE name = '$member_id[name]'");
|
||||
}
|
||||
|
||||
if ($forum_config['set_sub_last_up'] and $is_parentid = $forums_array[$forum_id]['parentid'])
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET f_last_tid = '$topic_id', f_last_title = '$topic_title', f_last_date = '$topic_date', f_last_poster_name = '$member_id[name]', last_post_id = '$new_pid' WHERE id = '$is_parentid'");
|
||||
}
|
||||
|
||||
if ($subscription and $is_logged)
|
||||
{
|
||||
$db->query("SELECT * FROM " . PREFIX . "_forum_subscription WHERE topic_id = '$topic_id' and user_id = '{$member_id['user_id']}'");
|
||||
|
||||
if (!$db->num_rows() and $topic_id)
|
||||
{
|
||||
$db->query("INSERT INTO " . PREFIX . "_forum_subscription (user_id, topic_id) values ('{$member_id['user_id']}', '$topic_id')");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['add_tid'])
|
||||
{
|
||||
if (stristr ($topic_text, "[attachment="))
|
||||
{
|
||||
$result = $db->query("SELECT * FROM " . PREFIX . "_forum_files
|
||||
WHERE topic_id = '{$_REQUEST['add_tid']}' and file_attach = '0'");
|
||||
|
||||
while ($att = $db->get_row($result))
|
||||
{
|
||||
if (stristr($topic_text, "[attachment={$att['file_id']}]") OR stristr($topic_text, "/forum/files/{$att['onserver']}"))
|
||||
{
|
||||
$update_id[] = $att['file_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_id)
|
||||
{
|
||||
$update_list = implode(',', $update_id);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_files SET topic_id = '$topic_id', post_id = '$new_pid', file_attach = '1' WHERE file_id IN ({$update_list})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($forum_config['topic_email'])
|
||||
{
|
||||
$topic_link = $config['http_home_url']."?do=forum&showtopic={$topic_id}";
|
||||
|
||||
include_once SYSTEM_DIR.'/classes/mail.class.php';
|
||||
|
||||
$mail = new dle_mail ($config);
|
||||
|
||||
$mail_tpl = $db->super_query("SELECT template FROM " . PREFIX . "_forum_email where name='new_topic' LIMIT 0,1");
|
||||
|
||||
$mail_tpl['template'] = stripslashes($mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%username%}", $member_id[name], $mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%date%}", $topic_date, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%title%}", $topic_title, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%link%}", $topic_link, $mail_result);
|
||||
|
||||
$mail->send ($config['admin_mail'], "DLE Forum - NEW TOPIC", $mail_result);
|
||||
}
|
||||
|
||||
if ($forum_config['mod_rewrite'])
|
||||
{
|
||||
$topic_location = $forum_url."/topic_".$topic_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_location = $forum_url."showtopic=".$topic_id;
|
||||
}
|
||||
|
||||
$cache->clear('forum_show_last');
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['topic_add_stop'], 'stop', "<br />".$stop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($topic_captcha)
|
||||
{
|
||||
forum_msg($f_lang['all_info'], $f_lang['captcha_stop']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$group_name = $user_group[$member_id['user_group']]['group_name'];
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['topic_add_ndeny'], 'user_group', $group_name);
|
||||
}
|
||||
|
||||
if ($forum_config['forum_bar'])
|
||||
{
|
||||
$bbr_fid = $forum_id;
|
||||
$bbr_fname = $forums_array[$forum_id]['name'];
|
||||
|
||||
$category_id = $forums_array[$forum_id]['main_id'];
|
||||
|
||||
$bbr_cid = $category_id;
|
||||
$bbr_name = $cats_array[$category_id]['cat_name'];
|
||||
|
||||
$bbr_app = $f_lang['app_newtopic'];
|
||||
}
|
||||
|
||||
?>
|
||||
158
system/forum/action/forum.php
Normal file
158
system/forum/action/forum.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
$code = !empty($_POST['code']) ? $_POST['code'] : $_GET['code'];
|
||||
|
||||
$fid = intval($_REQUEST['fid']);
|
||||
|
||||
switch ($code)
|
||||
{
|
||||
// ********************************************************************************
|
||||
// FORUM CALCULATOR
|
||||
// ********************************************************************************
|
||||
case "calc":
|
||||
|
||||
if (is_moderation($fid, 0, 0))
|
||||
{
|
||||
$posts_in_forum = '0';
|
||||
|
||||
$result_topics = $db->query("SELECT tid FROM " . PREFIX . "_forum_topics WHERE forum_id = '$fid'");
|
||||
|
||||
while ($row = $db->get_row($result_topics))
|
||||
{
|
||||
$forum_topic++;
|
||||
|
||||
$p_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_posts WHERE topic_id = '$row[tid]'");
|
||||
$posts_in_forum = ($posts_in_forum + $p_count['count']);
|
||||
}
|
||||
|
||||
if (!$forum_config['set_topic_post'])
|
||||
{
|
||||
$posts_in_forum = ($posts_in_forum - $forum_topic);
|
||||
}
|
||||
|
||||
if ($forum_config['topic_sort']) $sort_type = "last_date";
|
||||
else $sort_type = "tid";
|
||||
|
||||
$row1 = $db->super_query("SELECT * FROM ". PREFIX ."_forum_topics WHERE forum_id = '$fid' ORDER by $sort_type DESC");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET posts = '$posts_in_forum', topics = '$forum_topic', f_last_tid = '$row1[tid]', f_last_title = '$row1[title]', f_last_date ='$row1[last_date]', f_last_poster_name = '$row1[last_poster_name]' WHERE id = '$fid'");
|
||||
|
||||
header("Location: $_SERVER[HTTP_REFERER]");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
header("Location: $_SERVER[HTTP_REFERER]");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// USER
|
||||
// ********************************************************************************
|
||||
case "user":
|
||||
|
||||
$mname = $db->safesql($_REQUEST['mname']);
|
||||
|
||||
if ($mname)
|
||||
{
|
||||
$get_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_topics WHERE author_topic = '$mname' and hidden = 0");
|
||||
|
||||
$count_all = $get_count['count'];
|
||||
}
|
||||
|
||||
if ($count_all){
|
||||
|
||||
if ($cstart)
|
||||
{
|
||||
$cstart = $cstart - 1;
|
||||
$cstart = $cstart * $forum_config['topic_inpage'];
|
||||
}
|
||||
|
||||
if ($forum_config['topic_sort'])
|
||||
{
|
||||
$sort_type = "last_date";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$sort_type = "tid";
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// TOPIC VIEWS
|
||||
// ********************************************************************************
|
||||
if ($is_logged)
|
||||
{
|
||||
$row_views = $db->query("SELECT topic_id FROM " . PREFIX . "_forum_views WHERE user_id = '$member_id[user_id]' and time > '$topic_a_time'");
|
||||
|
||||
$topic_views = array();
|
||||
|
||||
while ($row = $db->get_row($row_views))
|
||||
{
|
||||
$topic_views[$row['topic_id']] = '1';
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$row_views = explode(",", $_COOKIE['dle_forum_views']);
|
||||
|
||||
foreach ($row_views as $value)
|
||||
{
|
||||
$topic_views[$value] = '1';
|
||||
}
|
||||
}
|
||||
|
||||
$config_inpage = $forum_config['topic_inpage'];
|
||||
|
||||
$result_topics = $db->query("SELECT * FROM " . PREFIX . "_forum_topics WHERE author_topic = '$mname' and hidden = 0 ORDER BY fixed, ".$sort_type." DESC LIMIT ".$cstart.",".$forum_config['topic_inpage']."");
|
||||
|
||||
require_once SYSTEM_DIR.'/forum/sources/showtopics.php';
|
||||
|
||||
$icat = $forum_url."act=getforum&code=user&mname={$mname}&cstart=";
|
||||
|
||||
require_once SYSTEM_DIR.'/forum/sources/components/navigation.php';
|
||||
|
||||
$tpl->load_template($tpl_dir.'forum.tpl');
|
||||
|
||||
$tpl->set('{forum}', $f_lang['app_user_topic'].': '.$mname);
|
||||
|
||||
$tpl->set('{subforums}','');
|
||||
|
||||
$tpl->set('{topics}', $tpl->result['topics']);
|
||||
|
||||
$tpl->set('{info}', $msg_info);
|
||||
|
||||
$tpl->set('{navigation}', $tpl->result['navigation']);
|
||||
|
||||
$tpl->set_block("'\\[options\\](.*?)\\[/options\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[rules\\](.*?)\\[/rules\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[new_topic\\](.*?)\\[/new_topic\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[selected\\](.*?)\\[/selected\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[fast-search\\](.*?)\\[/fast-search\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[moderation\\](.*?)\\[/moderation\\]'si","");
|
||||
|
||||
$tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si","");
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
|
||||
$tpl->clear();
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
|
||||
$bbr_app = $f_lang['app_user_topic'];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
520
system/forum/action/moderation.php
Normal file
520
system/forum/action/moderation.php
Normal file
@@ -0,0 +1,520 @@
|
||||
<?php
|
||||
/*
|
||||
=====================================================
|
||||
DLE Forum - by DLE Files Group
|
||||
-----------------------------------------------------
|
||||
http://dle-files.ru/
|
||||
-----------------------------------------------------
|
||||
File: moderation.php
|
||||
=====================================================
|
||||
Copyright (c) 2008,2010 DLE Files Group
|
||||
=====================================================
|
||||
*/
|
||||
|
||||
if(!defined('DATALIFEENGINE'))
|
||||
{
|
||||
die("Hacking attempt!");
|
||||
}
|
||||
$code = !empty($_POST['code']) ? $_POST['code'] : $_GET['code'];
|
||||
|
||||
$selectedtids = $_REQUEST['selected_id'];
|
||||
|
||||
$subaction = $_REQUEST['subaction'];
|
||||
|
||||
switch ($code)
|
||||
{
|
||||
// ********************************************************************************
|
||||
// OPEN TOPIC
|
||||
// ********************************************************************************
|
||||
case "01":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0) OR group_moderation($selectedtids, 'forum_topic_set'))
|
||||
{
|
||||
if (!moderator_value('open_topic', $forum_id, $m_member) AND !group_moderation($selectedtids, 'forum_topic_set')) die();
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET topic_status = '0' WHERE tid = '$topic_id'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '0' WHERE topic_id = '$topic_id' and hidden NOT IN (1,6)");
|
||||
}
|
||||
|
||||
header("Location: $_SERVER[HTTP_REFERER]");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
die("Hacking attempt!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// CLOSE TOPIC
|
||||
// ********************************************************************************
|
||||
case "02":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0) OR group_moderation($selectedtids, 'forum_topic_set'))
|
||||
{
|
||||
if (!moderator_value('close_topic', $forum_id, $m_member) AND !group_moderation($selectedtids, 'forum_topic_set')) die();
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET topic_status = '1' WHERE tid = '$topic_id'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '2' WHERE topic_id = '$topic_id' and hidden NOT IN (1,6)");
|
||||
}
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
die("Hacking attempt!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// DEL TOPIC
|
||||
// ********************************************************************************
|
||||
case "03":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0) OR group_moderation($selectedtids, 'forum_topic_del'))
|
||||
{
|
||||
if (!moderator_value('delete_topic', $forum_id, $m_member) AND !group_moderation($selectedtids, 'forum_topic_del')) die();
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$row_topic = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '$topic_id'");
|
||||
|
||||
$topic_id = $row_topic['tid'];
|
||||
|
||||
$forum_id = $row_topic['forum_id'];
|
||||
|
||||
$post_all = $row_topic['post'];
|
||||
|
||||
if (!$forum_config['set_topic_post'])
|
||||
{
|
||||
$post_all = ($post_all - 1);
|
||||
}
|
||||
|
||||
if ($topic_id)
|
||||
{
|
||||
// user converting //
|
||||
if ($forum_config['set_post_num_up'])
|
||||
{
|
||||
$query = $db->query("SELECT distinct post_author FROM " . PREFIX . "_forum_posts WHERE topic_id = '$topic_id'");
|
||||
|
||||
while ($row = $db->get_row($query))
|
||||
{
|
||||
if ($forum_config['set_topic_post'])
|
||||
{
|
||||
$topic = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_topics WHERE author_topic = '$row[post_author]'");
|
||||
|
||||
$topic_num = $topic['count'];
|
||||
}
|
||||
|
||||
$post = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_posts WHERE post_author = '$row[post_author]'");
|
||||
|
||||
$post_num = $post['count'];
|
||||
|
||||
$update = ($topic_num + $post_num);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_users SET forum_post = '$update' WHERE name ='$row[post_author]'");
|
||||
}
|
||||
}
|
||||
|
||||
// Óäàëåíèå âëîæåíèé âìåñòå ñ òåìîé
|
||||
|
||||
$result = $db->query("SELECT * FROM " . PREFIX . "_forum_files WHERE topic_id = '" . $topic_id . "'");
|
||||
|
||||
while ($row = $db->get_row($result)) {
|
||||
|
||||
if ($row['file_type'] == "file") {
|
||||
|
||||
unlink(UPLOAD_DIR."files/" . $row['onserver']);
|
||||
|
||||
} elseif ($row['file_type'] == "thumb") {
|
||||
|
||||
unlink(UPLOAD_DIR."thumbs/" . $row['onserver']);
|
||||
|
||||
unlink(UPLOAD_DIR."images/" . $row['onserver']);
|
||||
|
||||
} else {
|
||||
|
||||
unlink(UPLOAD_DIR."images/" . $row['onserver']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_files WHERE topic_id = '" . $topic_id . "'");
|
||||
|
||||
// êîíåö óäàëåíèÿ âëîæåíèé âìåñòå ñ òåìîé
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_posts WHERE topic_id = '$topic_id'");
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_topics WHERE `tid` = '$topic_id'");
|
||||
|
||||
$new_result = $db->super_query("SELECT * FROM ". PREFIX ."_forum_topics WHERE forum_id = '$forum_id' ORDER by start_date DESC");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET topics = topics-1, posts = posts-$post_all, f_last_tid = '$new_result[tid]', f_last_title = '$new_result[title]', f_last_date = '$new_result[last_date]', f_last_poster_name = '$new_result[last_poster_name]' WHERE id ='$forum_id'");
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_poll_log WHERE topic_id = '$topic_id'");
|
||||
|
||||
// del discuss id //
|
||||
$db->query("UPDATE " . PREFIX . "_post SET news_tid = '0' WHERE news_tid = '$topic_id'");
|
||||
|
||||
// del attachment //
|
||||
$db->query("SELECT * FROM " . PREFIX . "_forum_files WHERE topic_id = '$topic_id'"); // and file_attach='1'
|
||||
|
||||
while($row = $db->get_row())
|
||||
{
|
||||
if ($row['file_type'] == "image")
|
||||
{
|
||||
@unlink(UPLOAD_DIR."images/".$row['onserver']);
|
||||
}
|
||||
|
||||
elseif ($row['file_type'] == "thumb")
|
||||
{
|
||||
@unlink(UPLOAD_DIR."thumbs/".$row['onserver']);
|
||||
|
||||
@unlink(UPLOAD_DIR."images/".$row['onserver']);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
@unlink(UPLOAD_DIR."files/".$row['onserver']);
|
||||
}
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_files WHERE file_id = '$row[file_id]'");
|
||||
} // end - del attachment //
|
||||
}
|
||||
}
|
||||
|
||||
if ($forum_config['mod_rewrite'])
|
||||
{
|
||||
$forum_location = "{$forum_url}/forum_{$forum_id}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_location = "{$forum_url}showforum={$forum_id}";
|
||||
}
|
||||
|
||||
header("Location: {$forum_location}");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
die("Hacking attempt!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// EDIT TOPIC TITLE
|
||||
// ********************************************************************************
|
||||
case "04":
|
||||
|
||||
$selectedtids = intval($selectedtids);
|
||||
|
||||
if (!$subaction and is_moderation(0, $selectedtids, 0) OR !$subaction and group_moderation($selectedtids, 'forum_topic_edit'))
|
||||
{
|
||||
if (!moderator_value('edit_topic', $forum_id, $m_member) AND !group_moderation($selectedtids, 'forum_topic_edit')) die();
|
||||
|
||||
$row = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '{$selectedtids}'");
|
||||
|
||||
$topic_action_add = $a_forum_url."act=moderation&code=04&subaction=save&selected_id={$selectedtids}";
|
||||
|
||||
require_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter();
|
||||
|
||||
$parse->safe_mode = true;
|
||||
|
||||
$topic_title = $parse->decodeBBCodes($row['title'], false);
|
||||
$topic_descr = $parse->decodeBBCodes($row['topic_descr'], false);
|
||||
|
||||
$tpl->load_template($tpl_dir.'edittopic.tpl');
|
||||
|
||||
$tpl->set('{topic_title}', $topic_title);
|
||||
$tpl->set('{topic_descr}', $topic_descr);
|
||||
|
||||
if (check_access($forum_config['tools_poll']))
|
||||
{
|
||||
$tpl->set('[poll]','');
|
||||
$tpl->set('[/poll]','');
|
||||
|
||||
$tpl->set('{vote_title}', $parse->decodeBBCodes($row['poll_title'], false));
|
||||
$tpl->set('{frage}', $parse->decodeBBCodes($row['frage'], false));
|
||||
$tpl->set('{vote_body}', $parse->decodeBBCodes($row['poll_body'], false));
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->set_block("'\\[poll\\](.*?)\\[/poll\\]'si","");
|
||||
}
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"dle-comments-form\" id=\"dle-comments-form\" action=\"{$topic_action_add}\">".$tpl->copy_template."</form>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
if ($subaction == "save" and is_moderation(0, $selectedtids, 0) OR $subaction == "save" and group_moderation($selectedtids, 'forum_topic_edit'))
|
||||
{
|
||||
if (!moderator_value('edit_topic', $forum_id, $m_member) AND !group_moderation($selectedtids, 'forum_topic_edit')) die();
|
||||
|
||||
require_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse->safe_mode = true;
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
$topic_title = $db->safesql($parse->process($_POST['topic_title']));
|
||||
$topic_descr = $db->safesql($parse->process($_POST['topic_descr']));
|
||||
$vote_title = trim($db->safesql($parse->process($_POST['vote_title'])));
|
||||
$frage = trim($db->safesql($parse->process($_POST['frage'])));
|
||||
$vote_body = $db->safesql($parse->BB_Parse($parse->process($_POST['vote_body']), false));
|
||||
$poll_multiple = intval($_POST['poll_multiple']);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET title = '$topic_title', topic_descr = '$topic_descr', poll_title = '$vote_title', frage = '$frage', poll_body = '$vote_body', multiple = '$poll_multiple' WHERE tid = '$selectedtids'");
|
||||
|
||||
if ($forum_config['mod_rewrite'])
|
||||
{
|
||||
$topic_location = "{$forum_url}/topic_$selectedtids";
|
||||
} else
|
||||
{
|
||||
$topic_location = "{$forum_url}showtopic=$selectedtids";
|
||||
}
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
|
||||
$bbr_app = "Ðåäàêòèðîâàíèå òåìû";
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// MOVE TOPIC
|
||||
// ********************************************************************************
|
||||
case "05":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0))
|
||||
{
|
||||
if (!moderator_value('move_topic', $is_mod['forum_id'], $m_member)) die();
|
||||
|
||||
$move_fid = $_REQUEST['move_fid'];
|
||||
|
||||
if (!$subaction)
|
||||
{
|
||||
$topic_action_add = "{$a_forum_url}act=moderation&code=05&subaction=move&selected_id=$selectedtids";
|
||||
|
||||
$tpl->load_template($tpl_dir.'movetopic.tpl');
|
||||
|
||||
$tpl->set('{topic_title}', $topic_title);
|
||||
$tpl->set('{forum}', $is_forum_name);
|
||||
$tpl->set('{forum_list}', forum_list());
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" action=\"{$topic_action_add}\">".$tpl->copy_template."</form>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
if ($subaction == "move" and $selectedtids and $move_fid)
|
||||
{
|
||||
$tid = $selectedtids;
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
$new_post_count = 0;
|
||||
|
||||
$postcount = intval ($forums_array[$move_fid]['postcount']);
|
||||
|
||||
foreach ($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET forum_id = '$move_fid' WHERE tid = '$topic_id'");
|
||||
$tid_count++;
|
||||
|
||||
$post = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_posts WHERE topic_id = '$topic_id'");
|
||||
|
||||
$post_count = $post_count + $post['count'];
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET is_count = '$postcount' WHERE topic_id = '$topic_id'");
|
||||
}
|
||||
|
||||
$post_count = $post_count - $tid_count;
|
||||
|
||||
if ($forum_config['topic_sort']) $sort_type = "last_date";
|
||||
else $sort_type = "tid";
|
||||
|
||||
$row1 = $db->super_query("SELECT * FROM ". PREFIX ."_forum_topics WHERE forum_id = '{$is_mod['forum_id']}' ORDER by $sort_type DESC");
|
||||
|
||||
$row2 = $db->super_query("SELECT * FROM ". PREFIX ."_forum_topics WHERE forum_id = '$move_fid' ORDER by $sort_type DESC");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET posts = posts-$post_count, topics = topics-$tid_count, f_last_tid = '$row1[tid]', f_last_title = '$row1[title]', f_last_date ='$row1[last_date]', f_last_poster_name = '$row1[last_poster_name]' WHERE id = '{$is_mod['forum_id']}'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_forums SET posts = posts+$post_count, topics = topics+$tid_count, f_last_tid = '$row2[tid]', f_last_title = '$row2[title]', f_last_date ='$row2[last_date]', f_last_poster_name = '$row2[last_poster_name]' WHERE id = '$move_fid'");
|
||||
|
||||
if ($forum_config['mod_rewrite'])
|
||||
{
|
||||
$topic_location = "{$forum_url}/topic_$tid";
|
||||
|
||||
$forum_location = "{$forum_url}/forum_$move_fid";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_location = "{$forum_url}showtopic=$tid";
|
||||
|
||||
$forum_location = "{$forum_url}showforum=$move_fid";
|
||||
}
|
||||
|
||||
if ($tid_count > 1)
|
||||
{
|
||||
header("Location: $forum_location");
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
}
|
||||
|
||||
$bbr_app = "Ïåðåìåùåíèå òåìû";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// HIDDEN TOPIC
|
||||
// ********************************************************************************
|
||||
case "06":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0))
|
||||
{
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET hidden = '1' WHERE tid = '$topic_id'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '6' WHERE topic_id = '$topic_id' and hidden NOT IN (1,2)");
|
||||
}
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// NOT HIDDEN TOPIC
|
||||
// ********************************************************************************
|
||||
case "07":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0))
|
||||
{
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET hidden = '0' WHERE tid = '$topic_id'");
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '0' WHERE topic_id = '$topic_id' and hidden NOT IN (1,2)");
|
||||
}
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// FIXED TOPIC
|
||||
// ********************************************************************************
|
||||
case "08":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0))
|
||||
{
|
||||
if (!moderator_value('pin_topic', $forum_id, $m_member)) die();
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET fixed = '0' WHERE tid = '$topic_id'");
|
||||
}
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// NOT FIXED TOPIC
|
||||
// ********************************************************************************
|
||||
case "09":
|
||||
|
||||
if ($selectedtids and is_moderation(0, $selectedtids, 0))
|
||||
{
|
||||
if (!moderator_value('unpin_topic', $forum_id, $m_member)) die();
|
||||
|
||||
$selectedtids = explode(",",$selectedtids);
|
||||
|
||||
foreach($selectedtids as $topic_id)
|
||||
{
|
||||
$topic_id = intval($topic_id);
|
||||
if ( $topic_id == 0 ) continue;
|
||||
$db->query("UPDATE " . PREFIX . "_forum_topics SET fixed = '1' WHERE tid = '$topic_id'");
|
||||
}
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// CALC
|
||||
// ********************************************************************************
|
||||
case "10":
|
||||
|
||||
$topic_id = intval($_REQUEST['tid']);
|
||||
|
||||
if ($topic_id and is_moderation(0, $topic_id, 0))
|
||||
{
|
||||
calk_topic_del ($topic_id);
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// Default
|
||||
// ********************************************************************************
|
||||
default:
|
||||
|
||||
header("Location: {$_SERVER['HTTP_REFERER']}");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
515
system/forum/action/post.php
Normal file
515
system/forum/action/post.php
Normal file
@@ -0,0 +1,515 @@
|
||||
<?php
|
||||
if(!defined('DATALIFEENGINE'))
|
||||
{
|
||||
die("Hacking attempt!");
|
||||
}
|
||||
$code = !empty($_POST['code']) ? $_POST['code'] : $_GET['code'];
|
||||
|
||||
$subaction = $_REQUEST['subaction'];
|
||||
|
||||
$selected_id = $_REQUEST['selected_id'];
|
||||
|
||||
switch ($code)
|
||||
{
|
||||
// ********************************************************************************
|
||||
// ADD POST
|
||||
// ********************************************************************************
|
||||
case "add":
|
||||
|
||||
$forum_id = intval($_POST['forum_id']);
|
||||
|
||||
$topic_id = intval($_POST['topic_id']);
|
||||
|
||||
$page = intval($_REQUEST['page']);
|
||||
|
||||
$post_id = $db->safesql($_POST['post_id']);
|
||||
|
||||
$topic_title = $_POST['topic_ti'];
|
||||
|
||||
$post_text = $_POST['post_text'];
|
||||
|
||||
$name = $_POST['name'];
|
||||
$mail = $_POST['mail'];
|
||||
|
||||
$check_write = check_access($forums_array[$forum_id]['access_write']);
|
||||
|
||||
if ($check_write)
|
||||
{
|
||||
require_once SYSTEM_DIR.'/forum/action/addpost.php';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$group_name = $user_group[$member_id['user_group']]['group_name'];
|
||||
|
||||
forum_msg($f_lang['all_info'], $f_lang['topic_write'], 'user_group', $group_name);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// EDIT POST
|
||||
// ********************************************************************************
|
||||
case "02":
|
||||
|
||||
$pid = intval($_REQUEST['pid']);
|
||||
|
||||
$page = intval($_REQUEST['p']);
|
||||
|
||||
$post_n = intval($_REQUEST['pn']);
|
||||
|
||||
if ($pid)
|
||||
{
|
||||
if (is_moderation(0, 0, $pid, 'forum_post_edit'))
|
||||
{
|
||||
include_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
$row = $db->super_query("SELECT * FROM " . PREFIX . "_forum_posts WHERE `pid` = '$pid'");
|
||||
|
||||
$post_text = $parse->decodeBBCodes($row['post_text'], false);
|
||||
|
||||
$topic_id = $row['topic_id'];
|
||||
|
||||
$fid = $db->super_query("SELECT forum_id FROM " . PREFIX . "_forum_topics WHERE tid = '$topic_id'");
|
||||
|
||||
$forum_id = $fid['forum_id'];
|
||||
|
||||
$access_upload = check_access($forums_array[$forum_id]['access_upload']);
|
||||
|
||||
$upload_var = array('area'=>"post", 'forum_id'=>$forum_id, 'topic_id'=>$topic_id, 'post_id'=>$pid);
|
||||
|
||||
if ($row['pid'])
|
||||
{
|
||||
$edit_post_action = $a_forum_url."act=post&code=03&pid=$pid&topic_id=$topic_id&p=$page&pn=$post_n";
|
||||
|
||||
$tpl->load_template($tpl_dir.'addpost.tpl');
|
||||
|
||||
$tpl->set('{title}', $f_lang['app_post_edit']);
|
||||
|
||||
$tpl->set('[not-wysywyg]', "");
|
||||
|
||||
$tpl->set('{wysiwyg}','');
|
||||
|
||||
$tpl->set('[/not-wysywyg]',"");
|
||||
|
||||
include_once SYSTEM_DIR.'/forum/sources/components/bbcode.php';
|
||||
|
||||
if (!$is_logged)
|
||||
{
|
||||
$tpl->set('[not-logged]','');
|
||||
$tpl->set('[/not-logged]','');
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$tpl->set_block("'\\[not-logged\\](.*?)\\[/not-logged\\]'si","");
|
||||
}
|
||||
|
||||
$tpl->set_block("'\\[sec_code\\](.*?)\\[/sec_code\\]'si","");
|
||||
|
||||
$tpl->set('{bbcode}',$bb_code);
|
||||
$tpl->set('{text}',$post_text);
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"forum-post-form\" id=\"forum-post-form\" action=\"{$edit_post_action}\">".$tpl->copy_template."</form><div id=\"uploads-form\"></div>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// SAVE POST
|
||||
// ********************************************************************************
|
||||
case "03":
|
||||
|
||||
$pid = intval($_REQUEST['pid']);
|
||||
|
||||
$topic_id = intval($_REQUEST['topic_id']);
|
||||
|
||||
$page = intval($_REQUEST['p']);
|
||||
|
||||
$post_n = intval($_REQUEST['pn']);
|
||||
|
||||
if (is_moderation(0, 0, $pid, 'forum_post_edit'))
|
||||
{
|
||||
include_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
$post_text = $parse->process($_POST['post_text']);
|
||||
|
||||
$post_text = $db->safesql($parse->BB_Parse($post_text, FALSE));
|
||||
|
||||
$post_text = auto_wrap ($post_text);
|
||||
|
||||
if (strlen($post_text) > $forum_config['post_maxlen'])
|
||||
{
|
||||
$post_maxlen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_maxlen = false;
|
||||
}
|
||||
|
||||
if ($post_text and !$post_maxlen)
|
||||
{
|
||||
$_TIME = time()+($config['date_adjust']*60);
|
||||
|
||||
$edit_info = ", edit_user = '{$member_id[name]}', edit_time = '{$_TIME}'";
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET post_text = '$post_text' {$edit_info} WHERE pid = '$pid'");
|
||||
|
||||
check_attachment($pid, $post_text);
|
||||
|
||||
if ($forum_config['mod_rewrite'])
|
||||
{
|
||||
$topic_location = $forum_url."/topic_{$topic_id}/$page#post-$post_n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_location = $forum_url."showtopic=$topic_id&cstart=$page#post-$post_n";
|
||||
}
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ($post_maxlen)
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['maxlen_stop']);
|
||||
}
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['topic_add_stop'], 'stop', '');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// DEL POST
|
||||
// ********************************************************************************
|
||||
case "04":
|
||||
|
||||
if (is_moderation(0, 0, $selected_id, 'forum_post_del'))
|
||||
{
|
||||
$selected_id = explode(",", $selected_id);
|
||||
|
||||
foreach ($selected_id as $post_id)
|
||||
{
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_posts WHERE pid = '$post_id'");
|
||||
|
||||
// Óäàëåíèå âëîæåíèé âìåñòå ñ ñîîáùåíèåì
|
||||
|
||||
$result = $db->query("SELECT * FROM " . PREFIX . "_forum_files WHERE post_id = '" . $post_id . "'");
|
||||
|
||||
while ($row = $db->get_row($result)) {
|
||||
|
||||
if ($row['file_type'] == "file") {
|
||||
|
||||
unlink(UPLOAD_DIR."files/" . $row['onserver']);
|
||||
|
||||
} elseif ($row['file_type'] == "thumb") {
|
||||
|
||||
unlink(UPLOAD_DIR."thumbs/" . $row['onserver']);
|
||||
|
||||
unlink(UPLOAD_DIR."images/" . $row['onserver']);
|
||||
|
||||
} else {
|
||||
|
||||
unlink(UPLOAD_DIR."images/" . $row['onserver']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_files WHERE post_id = '" . $post_id . "'");
|
||||
|
||||
// êîíåö óäàëåíèÿ âëîæåíèé âìåñòå ñ òåìîé
|
||||
|
||||
$update_id[] = $post_id;
|
||||
|
||||
$del_count++;
|
||||
}
|
||||
|
||||
if ($update_id)
|
||||
{
|
||||
$update_list = implode(',', $update_id);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_files SET file_attach = '0' WHERE post_id IN ({$update_list})");
|
||||
}
|
||||
|
||||
if ($is_mod['topic_id'] and $del_count)
|
||||
{
|
||||
calk_topic_del ($is_mod['topic_id'], $del_count);
|
||||
}
|
||||
|
||||
if ($forum_config['mod_rewrite']) $topic_location = $forum_url."/topic_".$is_mod['topic_id'];
|
||||
|
||||
else $topic_location = $forum_url."showtopic=".$is_mod['topic_id'];
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
|
||||
else break;
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// UN HIDDEN POST
|
||||
// ********************************************************************************
|
||||
case "05":
|
||||
|
||||
if ($selected_id and is_moderation(0, 0, $selected_id))
|
||||
{
|
||||
$selected_id = explode(",", $selected_id);
|
||||
|
||||
foreach ($selected_id as $post_id)
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '0' WHERE pid = '$post_id'");
|
||||
}
|
||||
|
||||
header("Location: $_SERVER[HTTP_REFERER]");
|
||||
}
|
||||
|
||||
else break;
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// HIDDEN POST
|
||||
// ********************************************************************************
|
||||
case "06":
|
||||
|
||||
if ($selected_id and is_moderation(0, 0, $selected_id))
|
||||
{
|
||||
$selected_id = explode(",", $selected_id);
|
||||
|
||||
foreach ($selected_id as $post_id)
|
||||
{
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET hidden = '1' WHERE pid = '$post_id'");
|
||||
}
|
||||
|
||||
header("Location: $_SERVER[HTTP_REFERER]");
|
||||
}
|
||||
|
||||
else break;
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// Combining POST
|
||||
// ********************************************************************************
|
||||
case "07":
|
||||
|
||||
if ($selected_id and is_moderation(0, 0, $selected_id, 'combining_post'))
|
||||
{
|
||||
$pid_list = $db->safesql($selected_id);
|
||||
|
||||
$db->query("SELECT * FROM " . PREFIX . "_forum_posts WHERE pid IN ($pid_list)");
|
||||
|
||||
$join_posts_error = false;
|
||||
|
||||
$post_author = array();
|
||||
|
||||
$posts_text = array();
|
||||
|
||||
$selected_id = array();
|
||||
|
||||
$topic_id = 0;
|
||||
|
||||
while ($row = $db->get_row())
|
||||
{
|
||||
$count++;
|
||||
|
||||
$selected_id[] = $row['pid'];
|
||||
|
||||
if ($count == 1)
|
||||
{
|
||||
$topic_id = $row['topic_id'];
|
||||
}
|
||||
|
||||
if (!in_array($row['post_author'], $post_author))
|
||||
{
|
||||
$post_author[] = $row['post_author'];
|
||||
}
|
||||
|
||||
if ($row['topic_id'] !== $topic_id)
|
||||
{
|
||||
$join_posts_error = true;
|
||||
}
|
||||
|
||||
$posts_text[] = $row['post_text'];
|
||||
}
|
||||
|
||||
if ($count > 1 and !$join_posts_error)
|
||||
{
|
||||
$new_post = implode("<br /><br />", $posts_text);
|
||||
|
||||
$new_post = $db->safesql($new_post);
|
||||
|
||||
foreach ($selected_id as $key => $value_pid)
|
||||
{
|
||||
$pid_count++;
|
||||
|
||||
if ($pid_count == 1)
|
||||
{
|
||||
$edit_info = ", edit_user = '{$member_id[name]}', edit_time = '{$_TIME}'";
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET post_text = '$new_post' {$edit_info} WHERE pid = '$value_pid'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->query("DELETE FROM " . PREFIX . "_forum_posts WHERE pid = '$value_pid'");
|
||||
|
||||
$del_count++;
|
||||
}
|
||||
}
|
||||
|
||||
$del_count = $del_count + 1;
|
||||
|
||||
calk_topic_del ($topic_id, $del_count);
|
||||
|
||||
if ($forum_config['mod_rewrite']) $topic_location = $forum_url . "/topic_" . $topic_id;
|
||||
|
||||
else $topic_location = $forum_url . "showtopic=" . $topic_id;
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// Move POST
|
||||
// ********************************************************************************
|
||||
case "08":
|
||||
|
||||
$new_topic = $_REQUEST['new_topic'];
|
||||
|
||||
$new_topic_id = 0;
|
||||
|
||||
if (intval($new_topic) != 0)
|
||||
{
|
||||
$new_topic_id = intval ($new_topic);
|
||||
}
|
||||
else
|
||||
{
|
||||
preg_match_all("#topic_([0-9]{1,10})#", $new_topic, $matches);
|
||||
|
||||
$new_topic_id = intval ($matches[1][0]);
|
||||
|
||||
if (!$new_topic_id)
|
||||
{
|
||||
preg_match_all("#showtopic=([0-9]{1,10})#", $new_topic, $matches);
|
||||
|
||||
$new_topic_id = intval ($matches[1][0]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($selected_id and is_moderation(0, 0, $selected_id, 'move_post'))
|
||||
{
|
||||
if (!$subaction)
|
||||
{
|
||||
$action_moveposts = $a_forum_url."act=post&code=08&subaction=move&selected_id={$selected_id}";
|
||||
|
||||
$tpl->load_template($tpl_dir.'moveposts.tpl');
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" action=\"{$action_moveposts}\">".$tpl->copy_template."</form>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($new_topic_id)
|
||||
{
|
||||
$row = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = $new_topic_id");
|
||||
|
||||
$new_forum_id = $row['forum_id'];
|
||||
|
||||
if ($row['tid'])
|
||||
{
|
||||
// get info //
|
||||
$post_id = intval($selected_id);
|
||||
$row_post = $db->super_query("SELECT * FROM " . PREFIX . "_forum_posts WHERE pid = $post_id");
|
||||
$old_topic_id = $row_post['topic_id'];
|
||||
|
||||
$row2 = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = $old_topic_id");
|
||||
$old_forum_id = $row2['forum_id'];
|
||||
// - //
|
||||
|
||||
if ($old_topic_id == $new_topic_id)
|
||||
{
|
||||
die("error");
|
||||
}
|
||||
|
||||
$in_post_id = array();
|
||||
|
||||
$selected_id = explode(",", $selected_id);
|
||||
|
||||
foreach ($selected_id as $post_id)
|
||||
{
|
||||
$post_count++;
|
||||
|
||||
$in_post_id[] = $post_id;
|
||||
}
|
||||
|
||||
$post_id_list = implode(',', $in_post_id);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET topic_id = $new_topic_id WHERE pid IN ({$post_id_list})");
|
||||
|
||||
if ($old_forum_id == $new_forum_id)
|
||||
{
|
||||
unset ($post_count);
|
||||
}
|
||||
|
||||
calk_topic_del ($new_topic_id, $post_count, '+');
|
||||
|
||||
calk_topic_del ($old_topic_id, $post_count, '-');
|
||||
|
||||
if ($forum_config['mod_rewrite']) $topic_location = $forum_url . "/topic_" . $new_topic_id;
|
||||
|
||||
else $topic_location = $forum_url . "showtopic=" . $new_topic_id;
|
||||
|
||||
header("Location: $topic_location");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// ERROR
|
||||
// ********************************************************************************
|
||||
default:
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
352
system/forum/action/topic.php
Normal file
352
system/forum/action/topic.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
|
||||
|
||||
$code = !empty($_POST['code']) ? $_POST['code'] : $_GET['code'];
|
||||
|
||||
$subaction = $_REQUEST['subaction'];
|
||||
$tid = intval($_REQUEST['tid']);
|
||||
$pid = intval($_REQUEST['pid']);
|
||||
|
||||
switch ($code)
|
||||
{
|
||||
// ********************************************************************************
|
||||
// REPLY
|
||||
// ********************************************************************************
|
||||
case "reply":
|
||||
|
||||
$row_topic = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '$tid'");
|
||||
|
||||
$forum_id = $row_topic['forum_id'];
|
||||
|
||||
$topic_title = stripslashes($row_topic['title']);
|
||||
|
||||
$topic_title_last = urlencode($topic_title);
|
||||
|
||||
$check_moderator = check_moderator($forums_array[$forum_id]['access_mod'], $forums_array[$forum_id]['moderators']);
|
||||
|
||||
$check_write = check_access($forums_array[$forum_id]['access_write']);
|
||||
|
||||
$page_n = @ceil(($row_topic['post'] + 1) / $forum_config['post_inpage']);
|
||||
|
||||
if ($row_topic['topic_status'] and !$check_moderator)
|
||||
{
|
||||
$topic_status = false;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$topic_status = true;
|
||||
}
|
||||
|
||||
if ($check_write and $topic_status)
|
||||
{
|
||||
$access_upload = check_access($forums_array[$forum_id]['access_upload']);
|
||||
|
||||
$upload_var = array('area'=>"post", 'forum_id'=>$forum_id, 'topic_id'=>$tid, 'post_id'=>get_salt());
|
||||
|
||||
$tpl->load_template($tpl_dir.'addpost.tpl');
|
||||
|
||||
$tpl->set('{title}', $f_lang['app_reply']);
|
||||
|
||||
$tpl->set('[not-wysywyg]', "");
|
||||
|
||||
$tpl->set('{wysiwyg}','');
|
||||
|
||||
$tpl->set('[/not-wysywyg]',"");
|
||||
|
||||
include_once SYSTEM_DIR.'/forum/sources/components/bbcode.php';
|
||||
|
||||
if (!$is_logged)
|
||||
{
|
||||
$tpl->set('[not-logged]','');
|
||||
$tpl->set('[/not-logged]','');
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$tpl->set_block("'\\[not-logged\\](.*?)\\[/not-logged\\]'si","");
|
||||
}
|
||||
|
||||
if (check_access($forum_config['post_captcha']))
|
||||
{
|
||||
$tpl->set('[sec_code]',"");
|
||||
$tpl->set('[/sec_code]',"");
|
||||
|
||||
$path = parse_url($config['http_home_url']);
|
||||
$anti_bot = !defined('FORUM_SUB_DOMAIN') ? 'system/modules/' : '';
|
||||
|
||||
$tpl->set('{sec_code}',"<span id=\"dle-captcha\"><img src=\"".$path['path'].$anti_bot."antibot.php\" alt=\"${lang['sec_image']}\" border=\"0\"></span>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->set('{sec_code}',"");
|
||||
$tpl->set_block("'\\[sec_code\\](.*?)\\[/sec_code\\]'si","");
|
||||
}
|
||||
|
||||
$tpl->set('{bbcode}',$bb_code);
|
||||
$tpl->set('{text}',"");
|
||||
|
||||
$add_post_action = $a_forum_url."act=post&code=add&page={$page_n}";
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"forum-post-form\" id=\"forum-post-form\" action=\"{$add_post_action}\">".$tpl->copy_template."
|
||||
<input type=\"hidden\" name=\"topic_id\" id=\"topic_id\" value=\"{$tid}\" />
|
||||
<input type=\"hidden\" name=\"topic_ti\" id=\"topic_id\" value=\"{$topic_title_last}\" />
|
||||
<input type=\"hidden\" name=\"forum_id\" id=\"forum_id\" value=\"{$forum_id}\" />
|
||||
<input type=\"hidden\" name=\"post_id\" id=\"post_id\" value=\"{$upload_var['post_id']}\" /></form>
|
||||
<div id=\"uploads-form\"></div>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$group_name = $user_group[$member_id['user_group']]['group_name'];
|
||||
|
||||
forum_msg($f_lang['all_info'], $f_lang['topic_write'], 'user_group', $group_name);
|
||||
}
|
||||
|
||||
if ($forum_config['forum_bar'])
|
||||
{
|
||||
$bbr_fid = $forum_id;
|
||||
$bbr_fname = $forums_array[$forum_id]['name'];
|
||||
|
||||
$category_id = $forums_array[$forum_id]['main_id'];
|
||||
|
||||
$bbr_cid = $category_id;
|
||||
$bbr_name = $cats_array[$category_id]['cat_name'];
|
||||
|
||||
$bbr_tid = $tid;
|
||||
$bbr_tname = $topic_title;
|
||||
|
||||
$bbr_app = $f_lang['app_reply'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// FORWARD
|
||||
// ********************************************************************************
|
||||
case "forward":
|
||||
|
||||
if ($is_logged)
|
||||
{
|
||||
if (!$subaction)
|
||||
{
|
||||
$result = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '$tid'");
|
||||
|
||||
if ($result['tid'])
|
||||
{
|
||||
$topic_action_add = $a_forum_url."act=_topic&code=forward&subaction=send&tid={$tid}";
|
||||
|
||||
$tpl->load_template($tpl_dir.'send_frend.tpl');
|
||||
|
||||
$topic_link = $a_forum_url."showtopic={$tid}";
|
||||
|
||||
$tpl->set('{topic_title}', $result['title']);
|
||||
$tpl->set('{topic_link}', $topic_link);
|
||||
$tpl->set('{user_name}', $member_id['name']);
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"dle-comments-form\" id=\"dle-comments-form\" action=\"{$topic_action_add}\">".$tpl->copy_template."</form>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$frend_name = strip_tags(stripslashes($_REQUEST['frend_name']));
|
||||
$frend_mail = strip_tags(stripslashes($_REQUEST['frend_mail']));
|
||||
$frend_title = strip_tags(stripslashes($_REQUEST['frend_title']));
|
||||
$frend_text = strip_tags(stripslashes($_REQUEST['frend_text']));
|
||||
|
||||
if ($frend_name and $frend_mail and $frend_title and $frend_text)
|
||||
{
|
||||
$mail_tpl = $db->super_query("SELECT template FROM " . PREFIX . "_forum_email where name='frend_text' LIMIT 0,1");
|
||||
|
||||
$mail_tpl['template'] = stripslashes($mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%username_from%}", $member_id['name'], $mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%username_to%}", $frend_name, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%text%}", $frend_text, $mail_result);
|
||||
|
||||
include_once SYSTEM_DIR.'/classes/mail.class.php';
|
||||
|
||||
$mail = new dle_mail ($config);
|
||||
|
||||
$mail->send ($frend_mail, $frend_title, $mail_result);
|
||||
|
||||
$topic_link = $a_forum_url."showtopic={$tid}";
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['mail_send'], "link", $topic_link);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['values_error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$group_name = $user_group[$member_id['user_group']]['group_name'];
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['page_deny'], "user_group", $group_name);
|
||||
}
|
||||
|
||||
$bbr_app = $f_lang['title_forward'];
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// PRINT
|
||||
// ********************************************************************************
|
||||
case "print":
|
||||
|
||||
$row_topic = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '$tid'");
|
||||
|
||||
$forum_id = $row_topic['forum_id'];
|
||||
|
||||
$check_read = check_access($forums_array[$forum_id]['access_read']);
|
||||
|
||||
if ($check_read)
|
||||
{
|
||||
if ($row_topic['topic_descr'])
|
||||
{
|
||||
$row_topic['title'] = $row_topic['title'].', '.$row_topic['topic_descr'];
|
||||
}
|
||||
|
||||
$result_posts = $db->query("SELECT p.*, u.* FROM " . PREFIX . "_forum_posts AS p LEFT JOIN " . USERPREFIX . "_users AS u ON p.post_author=u.name WHERE p.topic_id = '$tid' and p.hidden = '0' ORDER by pid");
|
||||
|
||||
while ($row = $db->get_row($result_posts))
|
||||
{
|
||||
$row['post_date'] = strtotime($row['post_date']);
|
||||
|
||||
$tpl->load_template($tpl_dir.'print/post.tpl');
|
||||
|
||||
$tpl->set('{author}', $row['post_author']);
|
||||
|
||||
$tpl->set('{post-date}', show_date($row['post_date']));
|
||||
|
||||
$tpl->set('{text}', $row['post_text']);
|
||||
|
||||
if ($member_id['forum_post'] >= $forum_config['post_hide'])
|
||||
{
|
||||
$tpl->set_block("'\[hide\](.*?)\[/hide\]'si","\\1");
|
||||
}
|
||||
else
|
||||
{
|
||||
$hide_info = "Âíèìàíèå! Ó âàñ íåò ïðàâ, äëÿ ïðîñìîòðà ñêðûòîãî òåêñòà. Íåîáõîäèìî $forum_config[post_hide] ñîîáùåíèé.";
|
||||
|
||||
$tpl->set_block("'\\[hide\\](.*?)\\[/hide\\]'si","<div class=\"quote\">".$hide_info."</div>");
|
||||
}
|
||||
|
||||
$tpl->compile('posts');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
if (stristr ($tpl->result['posts'], "[attachment="))
|
||||
{
|
||||
require_once SYSTEM_DIR.'/forum/sources/components/attachment.php';
|
||||
}
|
||||
|
||||
$tpl->load_template($tpl_dir.'print/topic.tpl');
|
||||
|
||||
$tpl->set('{topic_link}', $a_forum_url."showtopic=".$row_topic['tid']);
|
||||
|
||||
$tpl->set('{topic_title}', $row_topic['title']);
|
||||
|
||||
$tpl->set('{post_list}', $tpl->result['posts']);
|
||||
|
||||
$tpl->compile('topic_print');
|
||||
$tpl->clear();
|
||||
|
||||
die ($tpl->result['topic_print']);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// ********************************************************************************
|
||||
// POST REPORT
|
||||
// ********************************************************************************
|
||||
case "report":
|
||||
|
||||
if ($is_logged AND !$forum_config['mod_report'])
|
||||
{
|
||||
if (!$subaction)
|
||||
{
|
||||
$report_action_add = $a_forum_url."act=_topic&code=report&subaction=add&tid={$tid}&pid={$pid}";
|
||||
|
||||
$tpl->load_template($tpl_dir.'report.tpl');
|
||||
|
||||
$tpl->copy_template = "<form method=\"post\" name=\"dle-comments-form\" id=\"dle-comments-form\" action=\"{$report_action_add}\">".$tpl->copy_template."</form>";
|
||||
|
||||
$tpl->compile('dle_forum');
|
||||
$tpl->clear();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$report = strip_tags(stripslashes($_REQUEST['report']));
|
||||
|
||||
if ($tid AND $pid AND $report)
|
||||
{
|
||||
$mail_tpl = $db->super_query("SELECT template FROM " . PREFIX . "_forum_email where name='report_text' LIMIT 0,1");
|
||||
|
||||
$mail_tpl['template'] = stripslashes($mail_tpl['template']);
|
||||
|
||||
$topic_link = $a_forum_url."showtopic={$tid}";
|
||||
|
||||
$mail_result = str_replace("{%username_from%}", $member_id['name'], $mail_tpl['template']);
|
||||
|
||||
$mail_result = str_replace("{%text%}", $report, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%topic_link%}", $topic_link, $mail_result);
|
||||
|
||||
$mail_result = str_replace("{%post_id%}", $pid, $mail_result);
|
||||
|
||||
include_once SYSTEM_DIR.'/classes/mail.class.php';
|
||||
|
||||
$mail = new dle_mail ($config);
|
||||
|
||||
$mail->send ($config['admin_mail'], "DLE Forum - REPORT", $mail_result);
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['report_send'], "link", $topic_link);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['values_error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user