Beispiel #1
0
                }
            }
            $i++;
        }
        fclose($FileHandle);
        $SiteList = array_reverse($TempList);
    } else {
        //Log not found
        return false;
    }
    return true;
}
//Main---------------------------------------------------------------
//Start with GET variables
$StartPoint = Filter_Int('start', 1, PHP_INT_MAX - 2, 1);
$RowsPerPage = Filter_Int('c', 2, PHP_INT_MAX, 500);
if (!Load_Access_Log()) {
    die('Unable to open Lighttpd Access Log ' . $LogLightyAccess);
}
$ListSize = count($SiteList);
if ($StartPoint >= $ListSize) {
    $StartPoint = 1;
}
//Start point can't be greater than the list size
if ($RowsPerPage < $ListSize) {
    //Slice array if it's larger than RowsPerPage
    $SiteList = array_slice($SiteList, $StartPoint, $RowsPerPage);
}
//Draw Table Headers-------------------------------------------------
echo '<div class="sys-group">' . PHP_EOL;
echo '<table id="blocked-table">';
Beispiel #2
0
//View 3: Blocked only
$View = Filter_Int('v', 1, 4, 1);
$ExecTime = time();
//Time of execution
$StartTime = $ExecTime;
$StartStr = 'today';
if (isset($_GET['e'])) {
    $StartStr = $_GET['e'];
    if ($StartStr != 'today') {
        if (($StartTime = strtotime($StartStr)) === false) {
            $StartTime = $ExecTime;
            $StartStr = 'today';
        }
    }
}
$DateRange = Filter_Int('dr', 1, 366, 1);
if ($Config['bl_tld'] == 1) {
    load_tldblocklist();
}
//Load TLD Blocklist if being used
//Merge Users Config of Suppress List with CommonSitesList
if ($Config['Suppress'] == '') {
    $CommonSites = array_merge($COMMONSITESLIST);
} else {
    $CommonSites = array_merge($COMMONSITESLIST, explode(',', $Config['Suppress']));
}
unset($COMMONSITESLIST);
load_logfiles();
//Load either Today or Historic logs
$ListSize = count($sortedlog);
if ($StartPoint >= $ListSize) {
Beispiel #3
0
function UpdateCustomList($LongName, $ListName)
{
    //Works for either BlackList or WhiteList
    //1. Appropriate list should have already have been loaded into $List Array
    //2. Find out what value has been requested on GET &do=
    //2a. Add Site using site name, and comment to end of $List array
    //2b. Change whether Site is enabled or disabled using Row number of $List array
    //2c. Delete Site from $List array by using Row number
    //2d. Change whether Site is enabled or disabled using name
    //2e. Error and leave function if any other value is given
    //3. Open File for writing in /tmp/"listname".txt
    //4. Write $List array to File
    //5. Delete $List array from Memcache
    //6. Write $List array with changes from #2 to Memcache
    //7. Run ntrk-exec as Forked process
    //8. Onward process is to DisplayCustomList function
    global $DirTmp, $List, $Mem;
    $LowercaseLongName = strtolower($LongName);
    if (Filter_Str('do')) {
        switch ($_GET['do']) {
            case 'add':
                if (Filter_URL('site') && Filter_Str('comment')) {
                    $List[] = array($_GET['site'], $_GET['comment'], true);
                }
                break;
            case 'cng':
                //Shift by one to compensate Human readable to actual Array value
                $RowNum = Filter_Int('row', 1, count($List) + 1);
                if ($RowNum !== false && isset($_GET['status'])) {
                    $RowNum--;
                    $List[$RowNum][2] = Filter_Bool('status');
                }
                break;
            case 'del':
                //Shift by one to compensate Human readable to actual Array value
                $RowNum = Filter_Int('row', 1, count($List) + 1);
                if ($RowNum !== false) {
                    array_splice($List, $RowNum - 1, 1);
                    //Remove one line from List array
                }
                break;
            case 'update':
                echo '<pre>Updating Custom blocklists in background</pre>' . PHP_EOL;
                ExecAction('run-notrack', true, true);
                return null;
                break;
            default:
                echo 'Invalid request in UpdateCustomList' . PHP_EOL;
                return false;
        }
    } else {
        echo 'No request specified in UpdateCustomList' . PHP_EOL;
        return false;
    }
    //Open file /tmp/listname.txt for writing
    $FileHandle = fopen($DirTmp . $LowercaseLongName . '.txt', 'w');
    //Write Usage Instructions to top of File
    fwrite($FileHandle, "#Use this file to create your own custom " . $LongName . PHP_EOL);
    fwrite($FileHandle, '#Run notrack script (sudo notrack) after you make any changes to this file' . PHP_EOL);
    foreach ($List as $Line) {
        //Write List Array to File
        if ($Line[2] == true) {
            //Is site enabled?
            fwrite($FileHandle, $Line[0] . ' #' . $Line[1] . PHP_EOL);
        } else {
            //Site disabled, comment it out by preceding Line with #
            fwrite($FileHandle, '# ' . $Line[0] . ' #' . $Line[1] . PHP_EOL);
        }
    }
    fclose($FileHandle);
    //Close file
    $Mem->delete($ListName);
    $Mem->set($ListName, $List, 0, 60);
    ExecAction('copy-' . $LowercaseLongName, true, true);
    return null;
}