lainchan-webring

Code for the unofficial lainchan webring.
git clone git://git.concealed.world/lainchan-webring
Log | Files | Refs | README | LICENSE

commit 0e682eeca4d530f05957fae63d934a7f46550c83
parent dd19559b56f805fc17cf409058648687359db89e
Author: Nixx <nixx@firemail.cc>
Date:   Sun, 22 Aug 2021 16:17:53 +0100

General improvements

Diffstat:
DREADME | 26--------------------------
AREADME.md | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Mcheck-up | 39+++++++++++++++++++++++++--------------
Awebring.csv | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mwebring.php | 95++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Dwebring.txt | 74--------------------------------------------------------------------------
Dwebring_onion.txt | 13-------------
7 files changed, 234 insertions(+), 150 deletions(-)

diff --git a/README b/README @@ -1,26 +0,0 @@ -# CODE FOR THE LAINCHAN.ORG UNOFFICIAL WEBRING - -## Redirecting To Other Sites - -### URL Documentation: -- Use the clearnet webring with webring.php?route=clearnet -- Use the onion webring with webring.php?route=onion - -This could quite easily accomodate more networks, such as I2P, but -currently I don't see a strong enough need. - -Defaults: clearnet - -### File Documentation: - -- 'webring.php' is the script file itself -- 'webring.txt' holds all of the clearnet domains -- 'webring_onion.txt' holds all of the onion domains - -## Checking Site Status - -'check-up' creates the files 'sites_up.txt' and 'sites_up_onion.txt'. -These files contain a sorted list with two fields, first the domain, -then the site's status. If the site can't be reached upon running the -script, the status is incremented by 1. If the site can be reached, -the status is reset to 0. diff --git a/README.md b/README.md @@ -0,0 +1,50 @@ +# CODE FOR THE LAINCHAN.ORG UNOFFICIAL WEBRING + +## webring.php + +'webring.php' manages redirects to other websites in the webring. A webmaster's +'ID' identifies their position in the ring, allowing them to use 'next' and +'previous' links. The script should function identically, whether self-hosted +or linked to from another website. + +### Parameters + +#### Actions: defaults 'random' +* webring.php?action=next +* webring.php?action=previous +* webring.php?action=random + +#### Networks: defaults 'clearnet' +* webring.php?network=clearnet +* webring.php?network=onion + +#### ID: defaults to first list row +* webring.php?id=concealedworld +The ID can be found in 'webring.csv'. + +#### Banner: defaults false +* webring.php?banner=true +* webring.php?banner=false +Directs to banner image instead of website. + +### Examples: +* Go to a random website on clearnet: webring.php +* Go to the next website on clearnet: webring.php?id=concealedworld&action=next +* See the banner of a random onion site: + webring.php?id=concealedworld&network=onion + +## webring.csv + +'webring.csv' contains a list of all websites in the webring. The entries are +in the format {network, ID, URL, extension}. Banners are within +'../images/banners/' relative to the script directory, and are in the format +'{id}.{extension}'. + +## check-up + +'check-up' creates the file 'sites\_up.txt' in the directory given as an +argument - 'webring.csv' must be in this directory for the script to function. +The format of each entry in the file 'sites\_up.txt' is '{URL} {status}'. If it +is impossible to make a connection with a website, the script increments a +counter, indicating how many days (assuming you run daily) the website has been +down. When the site can be reached again, the counter is reset to 0. diff --git a/check-up b/check-up @@ -17,9 +17,10 @@ # # DEPENDS: coreutils, bash, torsocks +OUTPUT=${FILEPATH}sites_up.txt + createfile () { - cp "${1}" "${2}" - sed -i "s/$/ 0/" "${2}" + echo "${1}" >> "${2}" } doconnections () { @@ -37,13 +38,13 @@ doconnections () { while [ $COUNT -le $LENGTH ]; do DOMAIN=$(head -n $COUNT "${1}" | tail -n 1) # Find the domain in the output file - POSITION=$(grep -n "^${DOMAIN} " "${2}" | cut -d : -f 1) + POSITION=$(grep -n "^${DOMAIN} " "${OUTPUT}" | cut -d : -f 1) if [ -z $POSITION ]; then # If the domain is a new addition DOWNFOR=0 else # Get the current number of occurences it has been down - DOWNFOR=$(head -n $POSITION "${2}" | tail -n 1 | cut -d \ -f 2) + DOWNFOR=$(head -n $POSITION "${OUTPUT}" | tail -n 1 | cut -d \ -f 2) fi # If it doesn't connect, increment @@ -65,18 +66,28 @@ doconnections () { [ $# -ne 1 ] && echo "Path must be specified." && exit 1 FILEPATH="${1}" -CLEARDOMAINS=${FILEPATH}webring.txt -ONIONDOMAINS=${FILEPATH}webring_onion.txt -CLEAROUTPUT=${FILEPATH}sites_up.txt -ONIONOUTPUT=${FILEPATH}sites_up_onion.txt +CLEARDOMAINS=$(grep "^clearnet" "${FILEPATH}webring.csv" | cut -d , -f 3) +ONIONDOMAINS=$(grep "^onion" "${FILEPATH}webring.csv" | cut -d , -f 3) + +CLEARTMP=$(mktemp) +ONIONTMP=$(mktemp) +echo "${CLEARDOMAINS}" > "${CLEARTMP}" +echo "${ONIONDOMAINS}" > "${ONIONTMP}" # If either domain file does not exist, exit -[ ! -f "${CLEARDOMAINS}" ] && exit 2 -[ ! -f "${ONIONDOMAINS}" ] && exit 3 +[ -z "${CLEARTMP}" ] && exit 2 +[ -z "${ONIONTMP}" ] && exit 3 # If either output file does not exist, create it -[ ! -f "${CLEAROUTPUT}" ] && createfile "${CLEARDOMAINS}" "${CLEAROUTPUT}" -[ ! -f "${ONIONOUTPUT}" ] && createfile "${ONIONDOMAINS}" "${ONIONOUTPUT}" +[ -z "${OUTPUT}" ] && createfile "${CLEARTMP}" "${OUTPUT}" && createfile "${ONIONTMP}" "${OUTPUT}" && sed -i "s/$/ 0/" "${OUTPUT}" + +TMPO1=$(mktemp) +TMPO2=$(mktemp) +doconnections "${CLEARTMP}" "${TMPO1}" 0 +doconnections "${ONIONTMP}" "${TMPO2}" 1 + +rm "${CLEARTMP}" +rm "${ONIONTMP}" -doconnections "${CLEARDOMAINS}" "${CLEAROUTPUT}" 0 -doconnections "${ONIONDOMAINS}" "${ONIONOUTPUT}" 1 +cat "${TMPO1}" > "${OUTPUT}" +cat "${TMPO2}" >> "${OUTPUT}" diff --git a/webring.csv b/webring.csv @@ -0,0 +1,87 @@ +clearnet,yukinu,https://yukinu.com/,gif +clearnet,alienozi,http://alienozi.c1.biz/,gif +clearnet,kamel,https://kamel.surge.sh/,png +clearnet,jyushimatsu,https://jyushimatsu.web.fc2.com/,gif +clearnet,qorg11,https://qorg11.net/,png +clearnet,xerophyte,https://xerophyte.neocities.org/,gif +clearnet,nightt,https://nightt.neocities.org/,gif +clearnet,volta,https://volta.neocities.org/,png +clearnet,jakesthoughts,https://jakesthoughts.xyz/,gif +clearnet,jakesmail,https://jakes-mail.top/,gif +clearnet,concealedworld,https://concealed.world/,gif +clearnet,davidgebski,https://www.davidgebski.nl/,png +clearnet,getimiskon,https://getimiskon.neocities.org/,png +clearnet,0x4f,https://0x4f.org/,png +clearnet,mayvaneday-melia,https://mayvaneday.art/,png +clearnet,se7en,https://se7en-site.neocities.org/,png +clearnet,lich,https://dataswamp.org/~lich/,png +clearnet,chupacabra,https://radiocc.xyz/stream/,png +clearnet,uwcur,https://uwcur.neocities.org/,png +clearnet,saltorn,https://saltorn.neocities.org/,png +clearnet,nyomru,https://nyom.ru/,gif +clearnet,parnell,http://tilde.club/~parnell/,png +clearnet,deurist,https://deurist.neocities.org/,png +clearnet,saturnexplorers,https://www.tohya.net/,png +clearnet,kyubit,https://kyubit.neocities.org/,png +clearnet,grafovolaverunt,https://grafovolaverunt.xyz/,gif +clearnet,kill9,https://kill-9.xyz/,png +clearnet,computability,https://computability.neocities.org/,png +clearnet,lainch,https://arisu.ee/,png +clearnet,cumbia,https://cumbia.neocities.org/,png +clearnet,sftn,https://sftn.github.io/,png +clearnet,lilibyte,http://lilibyte.net/,gif +clearnet,wiredspace,https://wiredspace.de/,png +clearnet,strlst,https://strlst.myogaya.jp/,png +clearnet,user-index,https://user-index.xyz/,gif +clearnet,slime-net,https://skumsoft.ltd/slimenet/,png +clearnet,bendersteed,https://bendersteed.tech/,jpg +clearnet,hellchem,https://hellishchemicals.neocities.org/,png +clearnet,freetext,http://freetext.wz.cz/,png +clearnet,swissbay,https://theswissbay.ch/pdf/,jpg +clearnet,born2live,https://born2live.tk/,png +clearnet,jack,https://jack---91.neocities.org/,gif +clearnet,xenobyte,https://xenobyte.xyz/,jpg +clearnet,six10,https://www.six10.pw/,png +clearnet,techur,https://techur.live/,png +clearnet,flammableduck,https://flammableduck.xyz/,png +clearnet,goat,https://tildezero.xyz/~goat/,jpg +clearnet,purplevoid,https://purplevoid.neocities.org/,png +clearnet,unix-tirol,https://unix.tirol/,png +clearnet,coolio,https://coolio321.xyz/,gif +clearnet,funwithhakase,https://funwithhakase.pl/,gif +clearnet,extramundane,https://extramundane.xyz/,jpg +clearnet,omicron,https://omicronsetup.eu/,gif +clearnet,fonix,https://xn--fnixfogelfuchs-vpb.eu/,png +clearnet,workingsea,https://workingsea.neocities.org/,png +clearnet,lukescabin,https://lukescabin.neocities.org/,png +clearnet,protocol7,https://protocol7.xyz/,png +clearnet,tardzone,https://tard.zone/,gif +clearnet,beedge,https://beedge.neocities.org/,png +clearnet,thealchemist,https://thealchemist.website/,png +clearnet,0x1bi,https://0x1bi.net/,png +clearnet,deadendshrine,https://deadendshrine.online/,png +clearnet,digilord,https://digilord.neocities.org/,gif +clearnet,michii,http://michii.tk/,png +clearnet,karar,https://karar.neocities.org/,png +clearnet,erratas,https://erratas.neocities.org/,gif +clearnet,nosleep,https://nosleepforme.neocities.org/,png +clearnet,room4,https://room4.neocities.org/,jpg +clearnet,hen6003,https://hen6003.xyz/,png +clearnet,gapandfriends2,https://gapandfriends.neocities.org/,png +clearnet,tinfoilhat,https://tinfoil-hat.net/,png +clearnet,diskmagvp,https://diskmagvp.neocities.org/,png +clearnet,thecosmiclibrary,https://thecosmiclibrary.neocities.org/,jpg +clearnet,slushbin,https://slushbin.org/,png +onion,coarseenigma,http://cgjzkysxa4ru5rhrtr6rafckhexbisbtxwg2fg743cjumioysmirhdad.onion/,png +onion,ic3,http://ic3333h2g3p7ffv6ypscxfvgomi2oj7x45xkqzpay6txjl2nlg5qwcid.onion/,png +onion,qorg11,http://lainwir3s4y5r7mqm3kurzpljyf77vty2hrrfkps6wm4nnnqzest4lqd.onion/,png +onion,kill9,http://killnod2s77o3axkktdu52aqmmy4acisz2gicbhjm4xbvxa2zfftteyd.onion/,png +onion,concealedworld,http://kpzscgdqezpen5zpnc4gky5vx4r56thl5syq2x45j6hbjy5w7tjilwid.onion/,gif +onion,mayvaneday-melia,http://meynethaffeecapsvfphrcnfrx44w2nskgls2juwitibvqctk2plvhqd.onion/,png +onion,jakesthoughts,http://y5wnzw4e6i7srm2gqadlow5anhlaj5avdkzbwzbmrxwkygxdp7ffieqd.onion/,gif +onion,getimiskon,http://ebca2srjjopvpopuypgn34wdnbj4ohwm7e5dbw5m5srv3nxpxzrdd4qd.onion/,png +onion,swissbay,http://swissbaync5d7ykaz7dh7v4qjrb4gmen5aj3bogxrcgbb43ij34bjuyd.onion/pdf/,jpg +onion,surfingforever,http://osirianwgeyfnshykr5gfvompz7iocvlknjucmmroqzdd7w6sarq2mqd.onion/,png +onion,goat,http://lh22ochx45fpimdekzbx6mh5h5fzoxcp3gyw7qhbv43m3guep54gurad.onion/,jpg +onion,coolio,http://kushgveghtve2r2e64pysmeovtsy2uuee4ez5foqdl5gcdxfmcfyxjyd.onion/,gif +onion,kunstler,http://imxg7v2cvgzrbupbi6hjmoiv47pjzy3ci67spezcvsl6rr5gjkmx5gid.onion/fa%C3%A7ade/,png diff --git a/webring.php b/webring.php @@ -1,6 +1,6 @@ <?php -# Copyright (C) <2021> <nixx@firemail.cc> +# Copyright (C) <2021> <nixx@firemail.cc> & contributors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,31 +15,80 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -// Use separate files for clearnet and onion sites - this could be extended further to other networks -$route = isset($_GET['route']) ? strtolower($_GET['route']) : 'clearnet'; -$valid_route = array('clearnet', 'onion'); -if(!in_array($route, $valid_route)) die('ERROR(1): Invalid network \''.$route.'\'.'); - -// Use the appropriate file for the network -if($route == 'clearnet'){ - $file = 'webring.txt'; -}elseif($route == 'onion'){ - $file = 'webring_onion.txt'; -}else{ - die('ERROR(2): Something went wrong while reading the network \''.$route.'\'.'); +$valid_action = array('next', 'previous', 'random'); // Ring actions +$valid_network = array('clearnet', 'onion'); // Ring networks +$file = 'webring.csv'; // Sites list +$list = []; // Final array +$redirkey = 0; // Site to go to, 0 should be ringmaster + +// If sites file doesn't exist, die +if(!file_exists($file)) die('ERROR: Sites list \''.$file.'\' not found.'); + +// Open file, store data, close file +$handle = fopen($file, 'r'); +while ($row = fgetcsv($handle)){ + $list[] = $row; +} +fclose($handle); + +// Get number of sites +$length = count($list) - 1; + +// Check network +$network = isset($_GET['network']) ? strtolower($_GET['network']) : 'clearnet'; +if(!in_array($network, $valid_network)) die('ERROR: Invalid network \''.$network.'\'.'); + +// Remove irrelevant rows +$count = 0; +while($count < $length){ + if($list[$count][0] != $network){ + array_splice($list, $count, 1); + $length = count($list) - 1; + }else{ + $count++; + } } -// If file doesn't exist, die -if(!file_exists($file)) die('ERROR(3): File \''.$file.'\' not found.'); -// The 'file' function reads an array from a file, separated by newlines -$list = file($file); -// Find the length -$length = count($list); +// Check calling site then store index +$caller = isset($_GET['id']) ? strtolower($_GET['id']) : $list[0][1]; +if(!in_array($caller, array_column($list, 1))) die('ERROR: Invalid member ID \''.$caller.'\'.'); +$id = array_search($caller, array_column($list, 1)); -// Get a random position -$redirkey = rand(0, $length - 1); +// Store and check action +$action = isset($_GET['action']) ? strtolower($_GET['action']) : 'random'; +if(!in_array($action, $valid_action)) die('ERROR: Invalid action \''.$action.'\'.'); + +// Store and check banner mode +$banner = isset($_GET['banner']) ? $_GET['banner'] : 'false'; +if(!in_array($banner, array('true', 'false'))) die('ERROR: Invalid banner mode \''.$banner.'\'.'); + +// Perform requested action +if($action == 'next'){ // Get next site in list + $redirkey = $id + 1; + if($redirkey > $length){ // Fix overflow + $redirkey = 0; + } +}elseif($action == 'previous'){ // Get previous site + $redirkey = $id - 1; + if($redirkey < 0){ // Fix underflow + $redirkey = $length; + } +}elseif($action == 'random'){ // Get random site + $redirkey = rand(0, $length); + if($length + 1 > 1){ // Don't waste CPU + while($redirkey == $id){ // Don't visit caller + $redirkey = rand(0, $length); + } + } +} + +// Show banner +if($banner == 'true'){ + header('Location: ../images/banners/'.$list[$redirkey][1].'.'.$list[$redirkey][3]); + exit; +} -// Finally, do the redirect - presumes HTTP will redirect to HTTPS where applicable -header('Location: http://'.$list[$redirkey]); +// Finally, do the redirect +header('Location: '.$list[$redirkey][2]); ?> diff --git a/webring.txt b/webring.txt @@ -1,74 +0,0 @@ -yukinu.com -alienozi.c1.biz -kamel.surge.sh -jyushimatsu.web.fc2.com -qorg11.net -xerophyte.neocities.org -nightt.neocities.org -volta.neocities.org -jakesthoughts.xyz -jakes-mail.top -concealed.world -www.davidgebski.nl -getimiskon.neocities.org -0x4f.org -mayvaneday.art -se7en-site.neocities.org -dataswamp.org/~lich/ -radiocc.xyz -uwcur.neocities.org -saltorn.neocities.org -nyom.ru -tilde.club/~parnell/ -deurist.neocities.org -www.tohya.net -kyubit.neocities.org -grafovolaverunt.xyz -kill-9.xyz -computability.neocities.org -lainch.leibur.eu -cumbia.neocities.org -sftn.github.io -lilibyte.net -wiredspace.de -strlst.myogaya.jp -user-index.xyz -skumsoft.ltd/slimenet/ -bendersteed.tech -hellishchemicals.neocities.org -freetext.wz.cz -theswissbay.ch/pdf/ -born2live.tk -jack---91.neocities.org -xenobyte.xyz -www.six10.pw -techur.live -flammableduck.xyz -tildezero.xyz/~goat/ -purplevoid.neocities.org -unix.tirol -coolio321.xyz -funwithhakase.pl -extramundane.xyz -omicronsetup.eu -xn--fnixfogelfuchs-vpb.eu -workingsea.neocities.org -lukescabin.neocities.org -protocol7.xyz -tard.zone -beedge.neocities.org -thealchemist.website -0x1bi.net -deadendshrine.online -digilord.neocities.org -michii.tk -karar.neocities.org -erratas.neocities.org -nosleepforme.neocities.org -room4.neocities.org -hen6003.xyz -gapandfriends.neocities.org -tinfoil-hat.net -diskmagvp.neocities.org -thecosmiclibrary.neocities.org -slushbin.org diff --git a/webring_onion.txt b/webring_onion.txt @@ -1,13 +0,0 @@ -cgjzkysxa4ru5rhrtr6rafckhexbisbtxwg2fg743cjumioysmirhdad.onion -ic3333h2g3p7ffv6ypscxfvgomi2oj7x45xkqzpay6txjl2nlg5qwcid.onion -lainwir3s4y5r7mqm3kurzpljyf77vty2hrrfkps6wm4nnnqzest4lqd.onion -killnod2s77o3axkktdu52aqmmy4acisz2gicbhjm4xbvxa2zfftteyd.onion -kpzscgdqezpen5zpnc4gky5vx4r56thl5syq2x45j6hbjy5w7tjilwid.onion -meynethaffeecapsvfphrcnfrx44w2nskgls2juwitibvqctk2plvhqd.onion -y5wnzw4e6i7srm2gqadlow5anhlaj5avdkzbwzbmrxwkygxdp7ffieqd.onion -ebca2srjjopvpopuypgn34wdnbj4ohwm7e5dbw5m5srv3nxpxzrdd4qd.onion -swissbaync5d7ykaz7dh7v4qjrb4gmen5aj3bogxrcgbb43ij34bjuyd.onion/pdf/ -osirianwgeyfnshykr5gfvompz7iocvlknjucmmroqzdd7w6sarq2mqd.onion -lh22ochx45fpimdekzbx6mh5h5fzoxcp3gyw7qhbv43m3guep54gurad.onion -kushgveghtve2r2e64pysmeovtsy2uuee4ez5foqdl5gcdxfmcfyxjyd.onion -imxg7v2cvgzrbupbi6hjmoiv47pjzy3ci67spezcvsl6rr5gjkmx5gid.onion/fa%C3%A7ade/