include "func.inc.php";
include "./db/config_pm.dat";
$where = "> Private Msg > Send a PM";
include "header.php";
if(is_logged_in($user_env, $pass_env, $power_env, $id_env)) {
if ($s == 1) {
if(!isset($HTTP_POST_VARS["icon"])) {
$error = 1;
echo "Must be submitted through the form
";
}
if(chop($message) == "") {
$error = 1;
echo "You must provide a message
";
}
if($to == "" || $to == "0") {
$error = 1;
echo "Select a Username";
} else {
$f = fopen("./db/pms/".$to."_block.dat", "r");
@$old = fread($f, filesize("./db/pms/".$to."_block.dat"));
fclose($f);
$ids = explode(",", $old);
deleteWhiteIndex($ids);
$count = count($ids);
for($i=0;$i<$count;$i++) {
if($ids[$i] == $id_env) {
$error = 1;
echo "The User you are sending does not wish to recieve messages from you. (You are blocked)";
break;
}
}
}
if(!isset($error)) {
$to_info = get($to, "./db/users");
$message = format_field($message);
if($icon == "") {
$icon = "icon1.gif";
}
if(trim($subject) == "") {
$subject = "No Subject";
}
if(isset($del) && isset($r)) {
@edit($r, "", "./db/pms/".$id_env."_inbox", "yes");
}
$message = format_field($message);
add("$user_env<~>$id_env<~>$power_env<~>$subject<~>$message<~>$icon<~>".date("M d, Y g:i:s a"), "./db/pms/".$to."_inbox", "no");
add("$to_info[user_name]<~>$to<~>$subject<~>$message<~>$icon<~>".date("M d, Y g:i:s a"), "./db/pms/".$id_env."_outbox", "no");
echo "PM Successfully Sent!";
$idfile = file("./db/pms/".$id_env."_outbox.id");
$last_id = trim($idfile[0]);
if($last_id > $pm_max_outbox_msg) {
$delete_id = $last_id - $pm_max_outbox_msg;
for($i=$delete_id;$i=0;$i--) {
$check = get($i, "./db/".$id_env."_outbox");
if($check["id"] == $i) edit($i, "", "./db/pms/".$id_env."_outbox");
}
}
if($ref != "") redirect("$ref?section=$section&id=$r_id", "2");
else redirect("pmsystem.php", "2");
exit;
} else {
if($r != "") {
$r_id = $r;
}
$r_sbj = $subject;
$r_msg = $message;
}
}
if(isset($r_id) && is_numeric($r_id)) {
$upb["def"] = "./db/pms/inbox";
$reply = get($r_id, "./db/pms/".$id_env."_inbox");
$select = "";
if(!isset($r_sbj)) {
while(substr($reply[subject], 0, 3) == "RE: ") {
$reply[subject] = substr($reply[subject], 4);
}
$sbj = "RE: ".$reply[subject];
} else {
$sbj = $r_sbj;
}
$tpc = "