<?
###############################################################################
# Copyright (C) 2000 Derek Leung
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# You may modify your copy or copies of this Program or any portion of it,
# but you must cause the modified files to carry prominent notices stating
# that you changed the files and the date of any change. And you are required
# to keep a copy of this License along with this Program.
#
# You are not required to accept this License, since you have not signed it.
# However, nothing else grants you permission to modify or distribute this
# Program or its derivative works. These actions are prohibited by law if
# you do not accept this License. Therefore, by modifying or distributing
# this Program (or any work based on this Program), you indicate your
# acceptance of this License to do so, and all its terms and conditions
# for copying, distributing or modifying this Program or works based on it.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# See the GNU General Public License for more details.
# http://www.opensource.org/licenses/gpl-license.html
###############################################################################
// cronjob to add or delete forwarder from vpopmail dir.
require("config.php");
$dirName = $config[data_path];
$d = opendir ($dirName);
while($entry = readdir($d)) {
if ($entry != "." && $entry != ".." && $entry != "") {
if (Is_Dir($dirName."/".$entry)) {
// ignore sub dir
} else {
$str = explode(".",$entry);
if ($str[0] == "") {
// add the forwarder
$str2 = "." . $str[1];
$src = $config[data_path] . "/" . $str2;
$dest = $config[qmail_path] . "/" . $str2;
$src2 = $config[data_path] . "/" . $entry;
copy ($src,$dest);
chown($dest,"vpopmail");
chmod($dest,0600);
unlink($src2);
}
if ($str[0] == "rm") {
// remove the forwarder
$str2 = "." . $str[1];
$src = $config[qmail_path] . "/" . $str2;
$src2 = $config[data_path] . "/" . $entry;
unlink ($src);
unlink($src2);
}
}
}
}
closedir($d);
?>