opensmtpdadmin/users/vacation.php

78 lines
2.0 KiB
PHP
Raw Normal View History

2022-08-18 14:01:52 +02:00
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: vacation.php
//
// Template File: users_vacation.tpl
//
// Template Variables:
//
// tMessage
// tSubject
// tBody
//
// Form POST \ GET Variables:
//
// fSubject
// fBody
//
require("../variables.inc.php");
require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
$USERID_USERNAME = check_user_session();
$USERID_DOMAIN = substr(strrchr($USERID_USERNAME, "@"), 1);
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$result = db_query("SELECT * FROM vacation WHERE email='$USERID_USERNAME'");
if ($result['rows'] == 1) {
$row = db_array($result['result']);
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['UsersVacation_welcome_text'];
2022-08-18 14:01:52 +02:00
$template = "users_vacation-get.tpl";
} else {
$template = "users_vacation.tpl";
}
include("../templates/header.tpl");
include("../templates/users_menu.tpl");
include("../templates/$template");
include("../templates/footer.tpl");
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (isset($_POST['fSubject'])) $fSubject = escape_string($_POST['fSubject']);
if (isset($_POST['fBody'])) $fBody = escape_string($_POST['fBody']);
if (!empty($_POST['fBack'])) {
$result = db_query("DELETE FROM vacation WHERE email='$USERID_USERNAME'");
if ($result['rows'] != 1) {
$error = 1;
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['UsersVacation_result_error'];
2022-08-18 14:01:52 +02:00
} else {
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['UsersVacation_result_succes'];
2022-08-18 14:01:52 +02:00
}
}
if (!empty($_POST['fAway'])) {
$result = db_query("INSERT INTO vacation (email,subject,body,cache,domain,created,active) VALUES ('$USERID_USERNAME','$fSubject','$fBody','','$USERID_DOMAIN',NOW(),'1')");
if ($result['rows'] != 1) {
$error = 1;
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['UsersVacation_result_error'];
2022-08-18 14:01:52 +02:00
} else {
header("Location: main.php");
exit;
}
}
include("../templates/header.tpl");
include("../templates/users_menu.tpl");
include("../templates/users_vacation.tpl");
include("../templates/footer.tpl");
}
?>