aboutsummaryrefslogtreecommitdiff
path: root/core/access.js
blob: 8fb3ad658dbf5c85cd93ebd1ce6f5d72e0bba544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');

module.exports = (filename) => {
    if (fs.existsSync(path.dirname(filename) + "/.htaccess")) {
        try {
            access = fs.readFileSync(path.dirname(filename) + "/.htaccess").toString();
            if (access.trim().includes("##net.minteckprojects.fns.electrode@DenyAccess##") || access.trim().includes("Deny from All")) {
                return false;
            } else {
                return true;
            }
        } catch (e) {
            console.log(chalk.gray(cluster.worker.id + " ") + chalk.yellow("warn:") + " unable to read htaccess from " + path.dirname(filename) + ": " + e.message);
            console.log(e.stack);
            return true;
        }
    } else {
        if (fs.existsSync(path.dirname(path.dirname(filename)) + "/.htaccess")) {
            try {
                access = fs.readFileSync(path.dirname(path.dirname(filename)) + "/.htaccess").toString();
                if (access.trim().includes("##net.minteckprojects.fns.electrode@DenyAccess##") || access.trim().includes("Deny from All")) {
                    return false;
                } else {
                    return true;
                }
            } catch (e) {
                console.log(chalk.gray(cluster.worker.id + " ") + chalk.yellow("warn:") + " unable to read htaccess from " + path.dirname(path.dirname(filename)) + ": " + e.message);
                console.log(e.stack);
                return true;
            }
        } else {
            if (fs.existsSync(path.dirname(path.dirname(path.dirname(filename))) + "/.htaccess")) {
                try {
                    access = fs.readFileSync(path.dirname(path.dirname(path.dirname(filename))) + "/.htaccess").toString();
                    if (access.trim().includes("##net.minteckprojects.fns.electrode@DenyAccess##") || access.trim().includes("Deny from All")) {
                        return false;
                    } else {
                        return true;
                    }
                } catch (e) {
                    console.log(chalk.gray(cluster.worker.id + " ") + chalk.yellow("warn:") + " unable to read htaccess from " + path.dirname(path.dirname(path.dirname(filename))) + ": " + e.message);
                    console.log(e.stack);
                    return true;
                }
            } else {
                return true;
            }
        }
    }
}