From 7c144fec1d93ad7c95e1d508d842a40f02efc31c Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Mon, 9 Jun 2025 07:30:42 +0100 Subject: [PATCH 01/11] issue 83: submission status is centered in the middle on submission --- www/header.php | 2 +- www/index.php | 6 +++--- www/style.css | 7 +++++++ www/submit.php | 17 ++++++++++++----- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/www/header.php b/www/header.php index 0073bf1..a6a949c 100644 --- a/www/header.php +++ b/www/header.php @@ -204,7 +204,7 @@ function DisplayCategories($instancename, $path) { - +
Submit a link

Update Frequency: every 3 hours


diff --git a/www/index.php b/www/index.php index f147029..85dcbc4 100644 --- a/www/index.php +++ b/www/index.php @@ -23,6 +23,7 @@
CSV LINES: " . $lines_uv . " " . $lines_v . "

"; - ?> +

@@ -99,7 +100,6 @@ require("header.php"); ?>
-
Submit a new link
'],'', $_POST['link']); - // Clear user input + // Clear user input + $success_message = null; + $error_message = null; $link = htmlspecialchars($link); $name = htmlspecialchars($_POST['name']); $description = htmlspecialchars($_POST['description']); @@ -12,13 +14,13 @@ if (isset($_POST['submit'])){ $captcha = htmlspecialchars($_POST['captcha']); // Captcha Auth check if ($captcha != htmlspecialchars($_SESSION['secure'])){ - echo "Captcha Failed"; + $error_message = "Captcha Failed"; }else{ if (empty($link) or empty($name) or empty($description)){ - echo "All of the fields must not be empty"; + $error_message = "All of the fields must not be empty"; }else{ if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ - echo "Don't excede the limit"; + $error_message = "Don't excede the limit"; }else{ // Open the file once before the loop @@ -37,7 +39,7 @@ if (isset($_POST['submit'])){ // Handle error opening the file error_log("Error opening the file."); } - echo "Link Successfully Submitted"; + $success_message = "Link Successfully Submitted"; } } } @@ -68,6 +70,11 @@ if (isset($_POST['submit'])){
+ +

+ +

+

Character Limits

Link should be 354

From b43da2d2df584f78af9e23a37e80eac66cf6a5aa Mon Sep 17 00:00:00 2001 From: doctor_dev Date: Mon, 9 Jun 2025 17:30:30 +0000 Subject: [PATCH 02/11] fixed the index saving to the webring participants --- scripts/lantern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lantern.py b/scripts/lantern.py index b8c80a3..cbcad6a 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -153,7 +153,7 @@ def main(): if 'Blacklisted' not in webpdf.columns: webpdf['Blacklisted'] = 'NO' - webpdf.to_csv(webpcsvfile) + webpdf.to_csv(webpcsvfile, index=False) ##### CHECK IF ARGUMENTS ARE PASSED TO ENTER PROMPT-LESS MODE ##### if len(sys.argv) == 2 and sys.argv[1] == "4": From 50f6a637cd1d73ee8430d8541f04dc6a098470f2 Mon Sep 17 00:00:00 2001 From: doctor_dev Date: Tue, 10 Jun 2025 06:22:26 +0000 Subject: [PATCH 03/11] fixed option 4 removing local instance rows --- scripts/logic/options.py | 8 ++++---- scripts/utils.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/scripts/logic/options.py b/scripts/logic/options.py index 9cd3be5..fe8cc47 100644 --- a/scripts/logic/options.py +++ b/scripts/logic/options.py @@ -16,10 +16,10 @@ def run_option_4(): utils.print_colors('[+] Syncing official webrings to local webrings') - webring_df = utils.get_local_webring_participants() - current_instance = utils.get_current_instance() + webring_df = utils.get_local_webring_participants(current_instance) + utils.print_colors('[+] Reading local blacklist and sensitive words') local_blacklist_df = utils.get_local_blacklist() local_sensitive_df = utils.get_local_sensitive() @@ -28,8 +28,8 @@ def run_option_4(): local_verified_df, local_unverified_df = utils.get_local_verified_and_unverified() #Remove all rows - local_unverified_df = local_unverified_df[0:0] - local_verified_df = local_verified_df[0:0] + local_unverified_df = utils.renew_csv(local_unverified_df, current_instance) + local_verified_df = utils.renew_csv(local_verified_df, current_instance) for participant in webring_df.itertuples(index=False, name='columns'): # Check if the participant is my instance diff --git a/scripts/utils.py b/scripts/utils.py index 790be16..497ed19 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -305,6 +305,26 @@ def is_row_valid(row): ###################### General ###################### +def renew_csv(df, participant_url): + """ + Removes all rows that are not generated by the local instance + + Parameters + ---------- + df : pd.DataFrame + Dataframe we want to renew + participant_url : str + the instance url + + Returns: + -------- + pd.DataFrame + The renewed dataframe + """ + + return df[df['Instance'] == participant_url] + + def merge_verification_df(receiving_df, merging_df): """ Merges 2 dataframes of type verified or unverified (do not merge duplications by name or url) @@ -775,10 +795,15 @@ def get_local_verified_and_unverified(): return pd.DataFrame(), pd.DataFrame() -def get_local_webring_participants(): +def get_local_webring_participants(current_instance): """ Make sure the official participants are registered in the webring csv file + Parameters + ---------- + current_instance : str + The current local instance url + Returns ------- pd.DataFrame @@ -792,7 +817,9 @@ def get_local_webring_participants(): missing_participants = set(get_official_participants()) - set(webring_df['URL']) for participant in missing_participants: - new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': ''}] + if participant == current_instance: + continue + new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': '', 'Blacklisted': 'NO'}] webring_df = pd.concat([webring_df, pd.DataFrame(new_row)], ignore_index=True) save_dataframe(webring_df, conf.LOCAL_DIR + conf.WEBRING_CSV_FILE) From bfd1c6ca7cae683fc4342005a3e604fd133b449d Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Tue, 10 Jun 2025 10:34:40 +0200 Subject: [PATCH 04/11] Update www/index.php Place "Submit Link" where it was originally --- www/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/index.php b/www/index.php index 85dcbc4..9e67613 100644 --- a/www/index.php +++ b/www/index.php @@ -101,6 +101,8 @@ require("header.php"); ?>
+
Submit a new link
+ From 124421ed896de072af0a86dabbe1cf7df7aefab5 Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Tue, 10 Jun 2025 10:35:56 +0200 Subject: [PATCH 05/11] Update www/header.php Removing "Submit Link" --- www/header.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/www/header.php b/www/header.php index a6a949c..a168414 100644 --- a/www/header.php +++ b/www/header.php @@ -203,8 +203,6 @@ function DisplayCategories($instancename, $path) { ?> - -
Submit a link

Update Frequency: every 3 hours


From 19fa5fefcd8946120cffa5d488335403ae34aef0 Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Tue, 10 Jun 2025 10:38:15 +0200 Subject: [PATCH 06/11] Update www/submit.php --- www/submit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/submit.php b/www/submit.php index 5471283..1f9f196 100644 --- a/www/submit.php +++ b/www/submit.php @@ -20,7 +20,7 @@ if (isset($_POST['submit'])){ $error_message = "All of the fields must not be empty"; }else{ if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ - $error_message = "Don't excede the limit"; + $error_message = "Don't exceed the limit"; }else{ // Open the file once before the loop From 3cb5af0f361ad57615c1fe384d9ca567d1c4462c Mon Sep 17 00:00:00 2001 From: Gasp Date: Tue, 10 Jun 2025 18:22:41 +0100 Subject: [PATCH 07/11] submit message status --- www/submit.php | 55 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/www/submit.php b/www/submit.php index 1f9f196..dd2668e 100644 --- a/www/submit.php +++ b/www/submit.php @@ -1,11 +1,11 @@ '],'', $_POST['link']); // Clear user input - $success_message = null; - $error_message = null; $link = htmlspecialchars($link); $name = htmlspecialchars($_POST['name']); $description = htmlspecialchars($_POST['description']); @@ -14,33 +14,36 @@ if (isset($_POST['submit'])){ $captcha = htmlspecialchars($_POST['captcha']); // Captcha Auth check if ($captcha != htmlspecialchars($_SESSION['secure'])){ - $error_message = "Captcha Failed"; - }else{ + $submission_message = "

Captcha Failed

"; + } else { if (empty($link) or empty($name) or empty($description)){ - $error_message = "All of the fields must not be empty"; - }else{ + $submission_message = "

All of the fields must not be empty

"; + } else { if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ - $error_message = "Don't exceed the limit"; - }else{ + $submission_message = "

Don't exceed the limit

"; + } else { - // Open the file once before the loop - $file = fopen("../submissions/submission.csv", "a"); + // Open the file once before the loop + $file = fopen("../submissions/submission.csv", "a"); - if ($file !== false) { - // Create an array with the inputs to write as a single row - $row = [$link, $name,$description,$category,$sensitive]; + if ($file !== false) { + // Create an array with the inputs to write as a single row + $row = [$link, $name,$description,$category,$sensitive]; - // Write the row to the CSV file - fputcsv($file, $row, ',', '"'); + // Write the row to the CSV file + fputcsv($file, $row, ',', '"'); - // Close the file after writing - fclose($file); - } else { - // Handle error opening the file - error_log("Error opening the file."); - } - $success_message = "Link Successfully Submitted"; - } + // Close the file after writing + fclose($file); + } else { + // Handle error opening the file + error_log("Error opening the file."); + } + + if ($submission_message === null) { // Only set success message if no error occurred + $submission_message = "

Link Successfully Submitted

"; + } + } } } } @@ -70,11 +73,7 @@ if (isset($_POST['submit'])){
- -

- -

- +

Character Limits

Link should be 354

From d78ed2bc86b582e8394c3865f7b010f337e37abf Mon Sep 17 00:00:00 2001 From: doctor_dev Date: Tue, 10 Jun 2025 22:07:56 +0000 Subject: [PATCH 08/11] fiex 4 and 10, sorting csv's now and making sure the origin of duplication is always local instance if compared --- scripts/conf.py | 1 + scripts/lantern.py | 2 +- scripts/logic/lantern_logic.py | 2 ++ scripts/logic/options.py | 10 ++------ scripts/utils.py | 43 +++++++++++++++++++++++++++++----- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/scripts/conf.py b/scripts/conf.py index 9b79107..e256729 100644 --- a/scripts/conf.py +++ b/scripts/conf.py @@ -9,6 +9,7 @@ OFFICIAL_PARTICIPANTS_FILE = STATIC_PATH + '.official_participants' WEBRING_CSV_FILE = 'webring-participants.csv' LOCAL_DIR = '' # Assign on script startup +LOCAL_INSTANCE = '' # Assign on script startup PROXIES = { 'http': 'socks5h://127.0.0.1:9050', diff --git a/scripts/lantern.py b/scripts/lantern.py index cbcad6a..845e187 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -153,7 +153,7 @@ def main(): if 'Blacklisted' not in webpdf.columns: webpdf['Blacklisted'] = 'NO' - webpdf.to_csv(webpcsvfile, index=False) + save_dataframe(webpdf, webpcsvfile) ##### CHECK IF ARGUMENTS ARE PASSED TO ENTER PROMPT-LESS MODE ##### if len(sys.argv) == 2 and sys.argv[1] == "4": diff --git a/scripts/logic/lantern_logic.py b/scripts/logic/lantern_logic.py index f3174a7..68387d0 100644 --- a/scripts/logic/lantern_logic.py +++ b/scripts/logic/lantern_logic.py @@ -69,6 +69,8 @@ def clean_csv(df, blacklist): try: if not df.empty: + df = utils.sort_instances(df, 'Instance', conf.LOCAL_INSTANCE) + df = utils.remove_duplications(df) df = df[~df.apply(lambda row: any(word in str(value) for word in blacklist for value in row), axis=1)] diff --git a/scripts/logic/options.py b/scripts/logic/options.py index fe8cc47..4b4c05b 100644 --- a/scripts/logic/options.py +++ b/scripts/logic/options.py @@ -15,10 +15,8 @@ def run_option_4(): utils.print_colors("4) Synchronize new links from new or existing webring participants, into your local csv files") utils.print_colors('[+] Syncing official webrings to local webrings') - - current_instance = utils.get_current_instance() - webring_df = utils.get_local_webring_participants(current_instance) + webring_df = utils.get_local_webring_participants(conf.LOCAL_INSTANCE) utils.print_colors('[+] Reading local blacklist and sensitive words') local_blacklist_df = utils.get_local_blacklist() @@ -27,13 +25,9 @@ def run_option_4(): utils.print_colors('[+] Reading local verified and unverified') local_verified_df, local_unverified_df = utils.get_local_verified_and_unverified() - #Remove all rows - local_unverified_df = utils.renew_csv(local_unverified_df, current_instance) - local_verified_df = utils.renew_csv(local_verified_df, current_instance) - for participant in webring_df.itertuples(index=False, name='columns'): # Check if the participant is my instance - if current_instance in participant: + if conf.LOCAL_INSTANCE in participant: continue if participant.Blacklisted == 'YES': diff --git a/scripts/utils.py b/scripts/utils.py index 497ed19..15edffc 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -36,7 +36,8 @@ def get_current_instance(): return "" #Set the local dir on script run -conf.LOCAL_DIR = conf.PARTICIPANT_DIR + get_current_instance() + '/' +conf.LOCAL_INSTANCE = get_current_instance() +conf.LOCAL_DIR = conf.PARTICIPANT_DIR + conf.LOCAL_INSTANCE + '/' ###################### Validations ###################### @@ -356,6 +357,37 @@ def merge_verification_df(receiving_df, merging_df): except Exception as err: return receiving_df +def sort_instances(df, sort_by, preferred=None): + """ + Sorts dataframe + + Parameters + ---------- + df : pd.DataFrame + The dataframe to sort + sort_by : str + The column to sort by + preferred(optional) : str + the preferred value is if i want the column to be sorted with a preferred value at the start of the dataframe + + Returns + ------- + pd.DataFrame + The sorted dataframe + """ + + try: + df = df.sort_values(by=sort_by) + + if preferred: + df['priority'] = (df[sort_by] == preferred).astype(int) + df = df.sort_values(by=['priority', sort_by], ascending=[False, True]).drop(columns='priority') + + except Exception as err: + print_colors('[-] Sorting failed',is_error=True) + + return df + def remove_duplications(df): """ Remove url and name duplications from the dataframe @@ -370,9 +402,10 @@ def remove_duplications(df): pd.DataFrame The dataframe after all duplications were removed """ + try: - df = df.drop_duplicates(subset='Name') - df = df.drop_duplicates(subset='URL') + df = df.drop_duplicates(subset='Name', keep='first') + df = df.drop_duplicates(subset='URL', keep='first') except Exception as err: print_colors('[-] Removing duplication failed',is_error=True) @@ -704,10 +737,8 @@ def get_official_participants(): """ try: - current_instance = get_current_instance() - with open(conf.OFFICIAL_PARTICIPANTS_FILE, 'r') as file: - return [line.strip() for line in file if current_instance not in line] + return [line.strip() for line in file if conf.LOCAL_INSTANCE not in line] except Exception as err: print_colors('[-] Couldn\'t read official webring participants file',is_error=True ) From 2d12280dc9ea0fc5dbf88a88179972d39769c277 Mon Sep 17 00:00:00 2001 From: doctor_dev Date: Tue, 10 Jun 2025 22:21:08 +0000 Subject: [PATCH 09/11] MOved the general sort to be incase no preferred value --- scripts/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/utils.py b/scripts/utils.py index 15edffc..f0d7f53 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -377,12 +377,14 @@ def sort_instances(df, sort_by, preferred=None): """ try: - df = df.sort_values(by=sort_by) if preferred: df['priority'] = (df[sort_by] == preferred).astype(int) df = df.sort_values(by=['priority', sort_by], ascending=[False, True]).drop(columns='priority') + else: + df = df.sort_values(by=sort_by) + except Exception as err: print_colors('[-] Sorting failed',is_error=True) From 0cf996661162d925970f80e1548e48376e572e59 Mon Sep 17 00:00:00 2001 From: SovereigntyIsNotFreedom Date: Wed, 11 Jun 2025 08:57:58 +0100 Subject: [PATCH 10/11] submit message status --- www/submit.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/www/submit.php b/www/submit.php index dd2668e..6eb35a5 100644 --- a/www/submit.php +++ b/www/submit.php @@ -1,7 +1,7 @@ '],'', $_POST['link']); @@ -14,13 +14,13 @@ if (isset($_POST['submit'])){ $captcha = htmlspecialchars($_POST['captcha']); // Captcha Auth check if ($captcha != htmlspecialchars($_SESSION['secure'])){ - $submission_message = "

Captcha Failed

"; + $submission_message = "Error: Captcha Failed"; } else { if (empty($link) or empty($name) or empty($description)){ - $submission_message = "

All of the fields must not be empty

"; + $submission_message = "Error: All of the fields must not be empty"; } else { if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ - $submission_message = "

Don't exceed the limit

"; + $submission_message = "Error: Don't exceed the limit"; } else { // Open the file once before the loop @@ -41,7 +41,7 @@ if (isset($_POST['submit'])){ } if ($submission_message === null) { // Only set success message if no error occurred - $submission_message = "

Link Successfully Submitted

"; + $submission_message = "Link Successfully Submitted"; } } } @@ -73,7 +73,7 @@ if (isset($_POST['submit'])){
- +

Character Limits

Link should be 354

@@ -96,7 +96,7 @@ if (isset($_POST['submit'])){
- +
From 7059e5066038f30262aec1e63ce600daff1531a7 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 15 Jun 2025 14:54:51 +0200 Subject: [PATCH 11/11] make categories show sensitive links by default --- www/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/header.php b/www/header.php index a168414..2d95866 100644 --- a/www/header.php +++ b/www/header.php @@ -181,7 +181,7 @@ function DisplayCategories($instancename, $path) { if (strtolower($oldcatname) != strtolower($data[1])){ - echo '' . ''. $data[1] . ' '; + echo '' . ''. $data[1] . ' '; $oldcatname = strtolower($data[1]); }