<?
if (!defined("SKIN")) die("Hack attempt!<br />You can't access directly to this file".SKIN);
#let's delete this post!
$mid = trim($_POST[mid]);
$tid = trim($_POST[tid]);
function delete_forum_stats($posts,$topics='0') {
list($topic_stat,$post_stat)=file('data/stats.txt');
$topic_stat=rtrim($topic_stat)-$topics;
$post_stat=rtrim($post_stat)-$posts;
$fo=fopen('data/stats.txt',"w+");
fseek($fo,0);
fwrite($fo,"$topic_stat\n$post_stat");
fclose($fo);
}
$c = "data/$mid.txt";
if (is_file("$c")) {
list(,$author,,,,$text_m,,,,,$is_register)=file($c);
$author=aut_sub(rtrim($author)); #we always get /n after file()
if (($arraj[u]==(strtolower($author)) AND $is_register==1) OR ${arraj}[a]) { #let's check if he is allowed to delete
/*now let's party :)
we have tid and mid so let's roll
*/
if ($tid==$mid) { #this means we need to delete whole topic.
$topics = file("data/headers.txt");
$hd=fopen("data/headers.txt","w+");
flock($hd,LOCK_EX);
for ($i = 0;is_string($topics[$i]); $i++) {
list(,$ttid,,,,)=explode('<|>', rtrim($topics[$i]));
if($mid!=$ttid) { fwrite($hd,$topics[$i]); }
}
flock($hd,LOCK_UN);
fclose($hd);
$posts=file("data/$tid.data/replies.txt");
for ($i = 0;is_string($posts[$i]); $i++) {
$pid=rtrim($posts[$i]);
rename("data/$pid.txt","data/deleted.$pid.txt") or print("Could not rename file $pid.txt");
}
delete_forum_stats($i++,1);
header("Location: index.php");
}
else {
$topics=file("data/$tid.data/replies.txt");
$hd=fopen("data/$tid.data/replies.txt","w+"); #now we need to open data/$tid-replies.txt for writing.
flock($hd,LOCK_EX) OR print("Didn't lock file"); #delete print() after.
for ($i = 0;is_string($topics[$i]); $i++) {
$tfor=rtrim($topics[$i]);
if ($mid!=$tfor) { fwrite($hd,$topics[$i]); }
}
flock($hd,LOCK_UN);
fclose($hd);
rename("data/$mid.txt","data/$tid.data/deleted.$mid.txt");
delete_forum_stats(1);
admin_msg("Post deleted!");
}
}
else {
echo "hack attempt<br />";
}
}
else {
admin_msg("Somebody deleted $c");
}
$razlog = $_POST['reason1'];
$author_delete = "$author.php";
include "users/$author_delete";
$mail_s = "Your message is deleted!";
$mail_a = "$r_email";
$mail_b = "
We want to tell you that your message on our forums has been deleted.
Messages getting deleted if they are spam, off-topic, or contains bad words.
If this message is OK, maybe it is randomly deleted.
----message----
$text_m
----message----
Message is deleted by $b_user.
-----------------------
Reason why your message is deleted:
$razlog
-----------------------
Please, write your message again, but FIRST READ rules.
Thanks a Lot,
txtForum Team!";
$mail_h = "From: hide@address.com";
if (mail($mail_a, $mail_s, $mail_b, $mail_h)) {
$mail_sent = "ok";
}
?>