Пример #1
0
function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $smb = new samba();
    $dirs = $smb->LOAD_RECYCLES_BIN();
    while (list($DirUid, $none) = each($dirs)) {
        $trashes[$DirUid] = $DirUid;
    }
    $trashes[null] = "{all}";
    $html = "\n\t<center style='margin-bottom:10px'>\n\t<table style='width:70%' class=form>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{files}:</td>\n\t\t\t\t<td colspan=3>" . Field_text("search-file-trash", "*", "font-size:14px;padding:3px;", null, null, null, false, "SearchTrashFileCheck(event)") . "</td>\n\t\t\t\t<td width=1%>" . button("{search}", "SearchTrashFile()") . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{share}:</td>\n\t\t\t\t<td>" . Field_array_Hash($trashes, "sharename", $_GET["sharename"], "style:font-size:14px") . "</td>\n\t\t\t\t<td class=legend>{date}:</td>\n\t\t\t\t<td>" . Field_text("search-date-trash", "0000-00-00", "font-size:14px;padding:3px;width:90px", null, null, null, false, "SearchTrashFileCheck(event)") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n\t</center>\n\t<div id='trash-samba-list' style='width:100%;height:550px;overflow:auto'></div>\n\t<script>\n\tfunction SearchTrashFileCheck(e){\n\t\tif(checkEnter(e)){SearchTrashFile();}\n\t}\n\t\n\tfunction SearchTrashFile(){\n\t\tvar date=escape(document.getElementById('search-date-trash').value);\n\t\tvar sharename=escape(document.getElementById('sharename').value);\n\t\tvar searchfile=escape(document.getElementById('search-file-trash').value);\n\t\tLoadAjax('trash-samba-list','{$page}?search='+searchfile+'&date='+date+'&sharename='+sharename);\n\t\n\t}\n\t\n\tSearchTrashFile();\n\t\n\t</script>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Пример #2
0
function shared_folders_list()
{
    $tpl = new templates();
    $samba = new samba();
    $folders = $samba->main_folders;
    if (!is_array($folders)) {
        json_error_show("No shared folders", 1);
    }
    $dustbins = $samba->LOAD_RECYCLES_BIN();
    $search = string_to_flexregex();
    $q2 = new mysql();
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $banned = $tpl->_ENGINE_parse_body("{banned_files}");
    $c = 0;
    while (list($FOLDER, $ligne) = each($folders)) {
        if (trim($FOLDER) == null) {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#i", $FOLDER)) {
                continue;
            }
        }
        $FOLDER_url = urlencode($FOLDER);
        $md = md5($FOLDER);
        $propertiesjs = "FolderProp('{$FOLDER_url}')";
        $c++;
        $delete = imgsimple('dustbin-48.png', null, "FolderDelete('{$FOLDER}')");
        if ($samba->main_array[$FOLDER]["path"] == "/home/netlogon") {
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($samba->main_array[$FOLDER]["path"] == "/home/export/profile") {
            $properties = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "homes") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "printers") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "print\$") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "netlogon") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if (trim($FOLDER == "profiles.V2")) {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "profile") {
            $properties = null;
            $delete = "&nbsp;";
            $propertiesjs = null;
        }
        if ($FOLDER == "profiles") {
            $properties = null;
            $delete = "&nbsp;";
            $propertiesjs = null;
        }
        $icon = "folder-granted-properties-48.png";
        if ($propertiesjs == null) {
            $icon = "folder-granted-properties-48-grey.png";
        }
        if (strpos($samba->main_array[$FOLDER]["root preexec"], "exec.samba.php --usb-mount") > 0) {
            $icon = "usb-share-48.png";
        }
        if (strpos("   " . $samba->main_array[$FOLDER]["path"], "/automounts/") > 0) {
            $icon = "usb-share-48.png";
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $trash = "&nbsp;";
        if ($dustbins[$FOLDER]) {
            $trash = imgsimple("trash-48.png", null, "Loadjs('samba.recycle.php?sharename={$FOLDER}')");
        }
        $FOLDER = trim($FOLDER);
        $href = "<a href=\"javascript:blur()\" OnClick=\"javascript:{$propertiesjs}\" style='font-size:16px;text-decoration:underline;font-weight:bold'>";
        // *******************************************************
        $fBanned = array();
        $banned_explain = null;
        $md5 = md5(trim($samba->main_array[$FOLDER]["path"]));
        $sql = "SELECT `files` FROM samba_veto_files WHERE md5path='{$md5}'";
        $results2 = $q2->QUERY_SQL($sql, "artica_backup");
        while ($ligne2 = mysql_fetch_assoc($results2)) {
            $pattern = trim($ligne2["files"]);
            if ($pattern == null) {
                continue;
            }
            if (isset($alredy[$pattern])) {
                continue;
            }
            $fBanned[] = $pattern;
        }
        if (count($fBanned) > 0) {
            $banned_explain = "<div style='font-size:10px'>{$banned}: " . @implode(", ", $fBanned) . "</div>";
        }
        // *******************************************************
        $data['rows'][] = array('id' => $md, 'cell' => array(imgsimple($icon, null, $propertiesjs), "<div style='padding-top:10px'>{$href}{$FOLDER}</a></span>", $trash, "<div style='padding-top:10px'><strong>\n\t\t\t\t<code style='font-size:16px'>{$samba->main_array[$FOLDER]["path"]}</a></code>\n\t\t\t\t</strong>\n\t\t\t\t{$banned_explain}\n\t\t\t</div>", $delete));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
Пример #3
0
function recycles()
{
    $smb = new samba();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        $unix->send_email_events("Virtual trashs: Instance PID {$pid} already running, task is canceled", "A maintenance task pid {$pid} is already running... This task pid " . getmypid() . " is aborted", "samba");
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $recycles = $smb->LOAD_RECYCLES_BIN();
    if (count($recycles) == 0) {
        return;
    }
    $unix = new unix();
    while (list($directory, $none) = each($recycles)) {
        $ShareName = $directory;
        $path = $smb->main_array[$directory]["path"] . '/.RecycleBin$';
        if ($path == null) {
            continue;
        }
        echo "recycles:: Parsing {$directory} -> {$path}\n ";
        if (!is_dir($path)) {
            continue;
        }
        $finalDirectories = $unix->dirdir($path);
        while (list($DirUid, $none) = each($finalDirectories)) {
            $uid = basename($DirUid);
            echo "recycles:: Parsing recycles for {$uid} -> {$DirUid}\n ";
            Recycles_inject($DirUid, $uid, $ShareName);
        }
    }
    //DirRecursiveFiles
}
Пример #4
0
function shared_folders_list()
{
    $tpl = new templates();
    $samba = new samba();
    $folders = $samba->main_folders;
    if (!is_array($folders)) {
        $html = $tpl->_ENGINE_parse_body(button("{add_a_shared_folder}", "Loadjs('SambaBrowse.php')"));
    }
    $html = "\n\t\n\t\n\t\n\t<input type='hidden' id='del_folder_name' value='{del_folder_name}'>\n\t\n<table cellspacing='0' cellpadding='0' border='0' class='tableView'>\n<thead class='thead'>\n\t<tr>\n\t<th width=1%>&nbsp;</th>\n\t<th>{name}</th>\n\t<th width=1%>{trash}</th>\n\t<th>{path}</th>\n\t<th>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>\t\n";
    if (!is_array($folders)) {
        $html = $html . "</tbody></table>";
        echo $tpl->_ENGINE_parse_body($html);
        return;
    }
    $dustbins = $samba->LOAD_RECYCLES_BIN();
    while (list($FOLDER, $ligne) = each($folders)) {
        $FOLDER_url = urlencode($FOLDER);
        $propertiesjs = "FolderProp('{$FOLDER_url}')";
        $delete = imgtootltip('delete-32.png', '{delete}', "FolderDelete('{$FOLDER}')");
        if ($samba->main_array[$FOLDER]["path"] == "/home/netlogon") {
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($samba->main_array[$FOLDER]["path"] == "/home/export/profile") {
            $properties = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "homes") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "printers") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "print\$") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "netlogon") {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if (trim($FOLDER == "profiles.V2")) {
            $properties = null;
            $propertiesjs = null;
            $delete = "&nbsp;";
        }
        if ($FOLDER == "profile") {
            $properties = null;
            $delete = "&nbsp;";
            $propertiesjs = null;
        }
        if ($FOLDER == "profiles") {
            $properties = null;
            $delete = "&nbsp;";
            $propertiesjs = null;
        }
        $icon = "folder-granted-properties-48.png";
        if ($propertiesjs == null) {
            $icon = "folder-granted-properties-48-grey.png";
        }
        if (strpos($samba->main_array[$FOLDER]["root preexec"], "exec.samba.php --usb-mount") > 0) {
            $icon = "usb-share-48.png";
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $trash = "&nbsp;";
        if ($dustbins[$FOLDER]) {
            $trash = imgtootltip("trash-48.png", "{recycle}", "Loadjs('samba.recycle.php?sharename={$FOLDER}')");
        }
        $html = $html . "\n\t<tr class={$classtr}>\n\t<td width=1%>" . imgtootltip("{$icon}", "{edit}", $propertiesjs) . "</td>\n\t<td><strong style='font-size:13px'><code style='font-size:13px'>{$FOLDER}</a></code></td>\n\t<td width=1% align='center'><strong style='font-size:13px'><code style='font-size:13px'>{$trash}</a></code></td>\n\t<td><strong ><code style='font-size:13px'>{$samba->main_array[$FOLDER]["path"]}</a></code></td>\n\t<td width=1%>{$delete}</td>\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $html = "<div style='width:99%;'>{$html}</div>\n\t<script>\n\t\tLoadjs('js/samba.js');\n\t</script>\n\t\n\t\n\t";
    return $tpl->_ENGINE_parse_body($html);
}