mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Added blocklist updating, main nav tweaks
Implemented Oliphant's unified tier 3 blocklist and the supplementary instance audit file that tracks how many times an instance has been blocked by a trusted sources member. Keeping the update function manual for now to make sure it works smooth, then well automate so it checks on it's on at regular intervals. NOTE: Lists used are located at the following urls: https://codeberg.org/oliphant/blocklists/src/branch/main/blocklists/_unified_tier3_blocklist.csv https://codeberg.org/oliphant/blocklists/src/branch/main/blocklists/other/domain_audit_file.csv Also simplified the main nav to just include a link to the den index when logged in
This commit is contained in:
@ -72,8 +72,8 @@ class FrontIndexController extends Controller
|
||||
public function listings(int $pageNum = 1)
|
||||
{
|
||||
$range = $pageNum * $this->limit - $this->limit;
|
||||
$active = Location::where("active", true)->get();
|
||||
$locations = Location::where("active", true)
|
||||
$active = Location::where("active", true)->where('block_count', '>', 2)->get();
|
||||
$locations = Location::where("active", true)->where('block_count', '>', 2)
|
||||
->limit($this->limit)->offset($range)->orderByDesc('id')->get();
|
||||
$pageCount = ceil(count($active) / $this->limit);
|
||||
|
||||
|
@ -6,10 +6,16 @@ use Illuminate\Http\Request;
|
||||
use App\Models\Location;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use League\Csv\Reader;
|
||||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
//
|
||||
//url to oli's unified tier 3 list
|
||||
private $three = 'https://codeberg.org/oliphant/blocklists/raw/branch/main/blocklists/_unified_tier3_blocklist.csv';
|
||||
|
||||
//url to oli's domain audit containin block counts per domain
|
||||
private $defed = 'https://codeberg.org/oliphant/blocklists/raw/branch/main/blocklists/other/domain_audit_file.csv';
|
||||
|
||||
public function addLocation(Request $request)
|
||||
{
|
||||
$fields = $request->validate([
|
||||
@ -47,4 +53,68 @@ class LocationController extends Controller
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLocations()
|
||||
{
|
||||
//$fresh = file($this->three);
|
||||
//$deny = Reader::createFromPath($fresh, "r");
|
||||
//$deny->setHeaderOffset(0);
|
||||
//$list = $deny->getRecords();
|
||||
//$recordCount = count($fresh);
|
||||
$duplicates = 0;
|
||||
$fresh = 0;
|
||||
$denycount = array_map('str_getcsv', file($this->defed));
|
||||
$denylist = array_map('str_getcsv', file($this->three));
|
||||
|
||||
foreach ($denylist as $item) {
|
||||
$blockCount = 0;
|
||||
//get block count for item
|
||||
foreach ($denycount as $line) {
|
||||
if ($line[0] == $item[0]) {
|
||||
$blockcount = $line[1];
|
||||
}
|
||||
}
|
||||
$location = Location::where("url", $item[0])->first();
|
||||
if ($location) {
|
||||
++$duplicates;
|
||||
//update block count for existing item
|
||||
$location->block_count = $blockcount;
|
||||
$location->save();
|
||||
} else {
|
||||
// make new entries for instances not present
|
||||
if ($item[0] != 'domain') {
|
||||
++$fresh;
|
||||
$new = Location::create([
|
||||
'uuid' => Uuid::uuid4(),
|
||||
'name' => $item[0],
|
||||
'url' => $item[0],
|
||||
'description' => 'no description',
|
||||
'active' => true,
|
||||
'rating' => $item[1],
|
||||
'added_by' => 1,
|
||||
'tags' => 'poor moderation, hate speech',
|
||||
'block_count' => $blockcount
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return back()->with('message', $duplicates . ' UPDATED - ' . $fresh . ' CREATED');
|
||||
|
||||
//$domain = $csv[1000][0];
|
||||
//$record = null;
|
||||
|
||||
/*
|
||||
foreach ($blockcount as $line) {
|
||||
if ($line[0] == $domain) {
|
||||
$record = $line;
|
||||
}
|
||||
}
|
||||
if ($record != null) {
|
||||
return back()->with('message', $domain . ' has ' . $record[1] . ' blocks.');
|
||||
} else {
|
||||
return back()->with('message', 'NO MATCHES');
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user