// łączenie i dzielenie tematow
} elseif(isset($_GET['step']) && $_GET['step'] == "split"){
if(isset($_POST['split_thread'])){
$toMove = ""; $i = 0; $firstPost = "";
foreach($_POST as $post=>$move){
if(!ereg("move_", $post) || !$move) continue;
$toMove .= ($i > 0 ? " OR " : "")."post_id='".str_replace('move_', '', $post)."'";
if(!$i) $firstPost = dbarray(dbquery("select * from ".DB_POSTS." where post_id='".str_replace('move_', '', $post)."'"));
$i++;
}
$subject = (isset($_POST['thread_subject']) ? addslash(stripinput($_POST['thread_subject'])) : "");
$forum = (isset($_POST['thread_forum']) && isNum($_POST['thread_forum']) ? $_POST['thread_forum'] : $_GET['forum_id']);
$result = dbquery("INSERT INTO ".DB_THREADS." (forum_id, thread_subject, thread_author, thread_views, thread_lastpost, thread_lastpostid, thread_lastuser, thread_postcount, thread_poll, thread_sticky, thread_locked)
VALUES('$forum', '$subject', '".$firstPost['post_author']."', '0', '".time()."', '0', '".$firstPost['post_author']."', '1', '0', '0', '0')");
$threadid = mysql_insert_id();
$result = dbquery("update ".DB_POSTS." set thread_id='$threadid', forum_id='$forum' where $toMove");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='$threadid' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='$threadid'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='$threadid'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='$forum' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='$forum'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_threadcount=forum_threadcount+1,
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='$forum'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='".$_GET['thread_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='".$_GET['thread_id']."'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$_GET['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$_GET['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_threadcount=forum_threadcount+1,
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$_GET['forum_id']."'");
opentable($locale['fb215']);
echo "
\n";
} else {
$possibleParents = "";
$c_res = dbquery("select * from ".$db_prefix."forums where forum_cat='0'");
while($c_data = dbarray($c_res)){
$possibleParents .= "\n";
}
opentable($locale['fb215']);
echo "\n";
}
closetable();
} elseif(isset($_GET['step']) && $_GET['step'] == "merge"){
if(isset($_POST['merge_thread'])){
$toMove = ""; $i = 0;
foreach($_POST as $post=>$move){
if(!ereg("move_", $post) || !$move) continue;
$toMove .= ($i > 0 ? " OR " : "")."post_id='".str_replace('move_', '', $post)."'";
$i++;
}
$merge_id = (isset($_POST['merge_id']) && isNum($_POST['merge_id']) ? $_POST['merge_id'] : 0);
$result = dbquery("select * from ".DB_THREADS." where thread_id='$merge_id'");
if(!dbrows($result)) redirect(FUSION_SELF."?step=merge&thread_id=".$_GET['thread_id']."&forum_id=".$_GET['forum_id']."&status=notfound");
$data = dbarray($result);
$threadid = $data['thread_id'];
$result = dbquery("update ".DB_POSTS." set thread_id='$threadid', forum_id='".$data['forum_id']."' where $toMove");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='$threadid' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='$threadid'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='$threadid'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$data['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$data['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$data['forum_id']."'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='".$_GET['thread_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='".$_GET['thread_id']."'");
if(!dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'")){
$result = dbquery("delete from ".DB_THREADS." where thread_id='".$_GET['thread_id']."'");
$result = dbquery("delete from ".DB_THREAD_NOTIFY." where thread_id='".$_GET['thread_id']."'");
$delete=true;
} else { $delete=false; }
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$_GET['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$_GET['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$_GET['forum_id']."'");
opentable($locale['fb225']);
echo "\n";
} else {
opentable($locale['fb225']);
if(isset($_GET['status']) && $_GET['status'] == "notfound") echo "".$locale['fb234']."
\n";
echo "\n";
}
closetable();
} else {
redirect("index.php");
}
//
require_once THEMES."templates/footer.php";
?>