Example #1
0
function sendout($filename)
{
    $q = new mysql_mimedefang_builder();
    $sql = "SELECT `filesize`,`filedata` FROM `storage` WHERE `filename`='{$filename}'";
    include_once dirname(__FILE__) . "/ressources/mimestypes.inc";
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    $content_type = "application/octet-stream";
    if (isset($GLOBALS["MIME_CONTENT_TYPES_ARRAY"][$ext])) {
        $content_type = $GLOBALS["MIME_CONTENT_TYPES_ARRAY"][$ext];
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    $fsize = $ligne["filesize"];
    header('Content-type: ' . $content_type);
    header('Content-Transfer-Encoding: binary');
    header("Content-Disposition: attachment; filename=\"{$filename}\"");
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    // Date dans le passé
    header("Content-Length: " . $fsize);
    ob_clean();
    flush();
    echo $ligne["filedata"];
}
Example #2
0
function status()
{
    $t = $_GET["t"];
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $page = CurrentPageName();
    $ini->loadString(base64_decode($sock->getFrameWork('mimedefang.php?status=yes')));
    $APP_MIMEDEFANG = DAEMON_STATUS_ROUND("APP_MIMEDEFANG", $ini, null);
    $APP_MIMEDEFANGX = DAEMON_STATUS_ROUND("APP_MIMEDEFANGX", $ini, null);
    $Param = unserialize(base64_decode($sock->GET_INFO("MimeDefangServiceOptions")));
    if (!is_numeric($Param["MX_TMPFS"])) {
        $Param["MX_TMPFS"] = 0;
    }
    $tpl = new templates();
    if ($Param["MX_TMPFS"] > 5) {
        $array = unserialize(base64_decode($sock->getFrameWork("mimedefang.php?getramtmpfs=yes")));
        if (!is_numeric($array["PURC"])) {
            $array["PURC"] = 0;
        }
        if (!isset($array["SIZE"])) {
            $array["SIZE"] = "0M";
        }
        $tmpfs[] = "\n\t\t<tr>\n\t\t\t<td colspan=2 style='font-size:16px' align='left'>tmpfs:</td>\n\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valing='middle'>" . pourcentage($array["PURC"]) . "</td>\n\t\t\t\t<td style='font-size:14px'>{$array["PURC"]}%/{$array["SIZE"]}</td>\n\t\t\t</tr>\n\n\t\t\t";
    }
    $q = new mysql_mimedefang_builder();
    $attachments_storage = $q->COUNT_ROWS("storage");
    if ($attachments_storage > 0) {
        $sql = "SELECT SUM(filesize) as tcount FROM `storage`";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $size = FormatBytes($ligne["tcount"] / 1024);
        $tmpfs[] = "\n\t<tr>\n\t\t<td colspan=2>\n\t\t<hr>\n\t<table>\n\t\t<tr>\n\t\t\t<td style='font-size:16px' align='left'>{attachments_storage}:</td>\n\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('mimedefang.filehosting.table.php');\"\n\t\t\t\tstyle='font-size:16px;text-decoration:underline'>{$attachments_storage} {items} ({$size})</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t</tr>\n\t\n\n\t\t\t";
    }
    if (count($tmpfs) > 0) {
        $tmpfs_builded = "<table style='width:30%;margin-top:15px' class=form>" . @implode("\n", $tmpfs) . "</table>";
    }
    $html = "<table style='width:99%' class=form>\n\t<tr>\n\t<td>{$APP_MIMEDEFANG}{$APP_MIMEDEFANGX}\n\t\t<center style='margin-top:10px;margin-bottom:10px;width:95%' class=form>\n\t\t<table style='width:70%'>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td width=10% align='center;'>" . imgtootltip("32-stop.png", "{stop}", "Loadjs('{$page}?service-cmds=stop')") . "</td>\n\t\t\t<td width=10% align='center'>" . imgtootltip("restart-32.png", "{stop} & {start}", "Loadjs('{$page}?service-cmds=restart')") . "</td>\n\t\t\t<td width=10% align='center'>" . imgtootltip("32-run.png", "{start}", "Loadjs('{$page}?service-cmds=start')") . "</td>\n\t\t</tr>\n\t\t</tbody>\n\t\t</table>\n\t\t</center>\t\n\t\n\t</td>\n\t</tr>\n\t</table>\n\t<center>\n\t\t{$tmpfs_builded}\n\t</center>\n\t<div style='text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('status-{$t}','{$page}?status=yes&t={$t}');") . "</div>";
    echo $tpl->_ENGINE_parse_body($html);
}
function delete_item()
{
    $q = new mysql_mimedefang_builder();
    $q->QUERY_SQL("DELETE FROM storage WHERE filename='{$_POST["filename"]}'", "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
}
function CleanDatabase()
{
    $sock = new sockets();
    $unix = new unix();
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($unix->file_time_min($pidtime) < 120) {
        return;
    }
    $MimeDefangFileMaxDaysStore = $sock->GET_INFO("MimeDefangFileMaxDaysStore");
    if (!is_numeric($MimeDefangFileMaxDaysStore)) {
        $MimeDefangFileMaxDaysStore = 5;
    }
    if ($MimeDefangFileMaxDaysStore == 0) {
        return;
    }
    $q = new mysql_mimedefang_builder();
    $filesStart = $q->COUNT_ROWS("storage");
    if ($filesStart == 0) {
        return;
    }
    $sql = "DELETE FROM storage WHERE filetime<DATE_SUB(NOW(),INTERVAL {$MimeDefangFileMaxDaysStore} DAY)";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        system_admin_events("Fatal: {$q->mysql_error}.", __FUNCTION__, __FILE__, __LINE__, "postfix");
        return;
    }
    $filesEND = $q->COUNT_ROWS("storage");
    $diff = $filesStart - $filesEND;
    if ($diff > 0) {
        system_admin_events("Success cleaned {$diff} files from attachments storage.", __FUNCTION__, __FILE__, __LINE__, "postfix");
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
}