diff --git a/scripts/conf.py b/scripts/conf.py index e256729..9b79107 100644 --- a/scripts/conf.py +++ b/scripts/conf.py @@ -9,7 +9,6 @@ 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 845e187..b8c80a3 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -153,7 +153,7 @@ def main(): if 'Blacklisted' not in webpdf.columns: webpdf['Blacklisted'] = 'NO' - save_dataframe(webpdf, webpcsvfile) + webpdf.to_csv(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 68387d0..f3174a7 100644 --- a/scripts/logic/lantern_logic.py +++ b/scripts/logic/lantern_logic.py @@ -69,8 +69,6 @@ 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 4b4c05b..9cd3be5 100644 --- a/scripts/logic/options.py +++ b/scripts/logic/options.py @@ -15,8 +15,10 @@ 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') + + webring_df = utils.get_local_webring_participants() - webring_df = utils.get_local_webring_participants(conf.LOCAL_INSTANCE) + current_instance = utils.get_current_instance() utils.print_colors('[+] Reading local blacklist and sensitive words') local_blacklist_df = utils.get_local_blacklist() @@ -25,9 +27,13 @@ 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 = local_unverified_df[0:0] + local_verified_df = local_verified_df[0:0] + for participant in webring_df.itertuples(index=False, name='columns'): # Check if the participant is my instance - if conf.LOCAL_INSTANCE in participant: + if current_instance in participant: continue if participant.Blacklisted == 'YES': diff --git a/scripts/utils.py b/scripts/utils.py index f0d7f53..790be16 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -36,8 +36,7 @@ def get_current_instance(): return "" #Set the local dir on script run -conf.LOCAL_INSTANCE = get_current_instance() -conf.LOCAL_DIR = conf.PARTICIPANT_DIR + conf.LOCAL_INSTANCE + '/' +conf.LOCAL_DIR = conf.PARTICIPANT_DIR + get_current_instance() + '/' ###################### Validations ###################### @@ -306,26 +305,6 @@ 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) @@ -357,39 +336,6 @@ 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: - - 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) - - return df - def remove_duplications(df): """ Remove url and name duplications from the dataframe @@ -404,10 +350,9 @@ def remove_duplications(df): pd.DataFrame The dataframe after all duplications were removed """ - try: - df = df.drop_duplicates(subset='Name', keep='first') - df = df.drop_duplicates(subset='URL', keep='first') + df = df.drop_duplicates(subset='Name') + df = df.drop_duplicates(subset='URL') except Exception as err: print_colors('[-] Removing duplication failed',is_error=True) @@ -739,8 +684,10 @@ 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 conf.LOCAL_INSTANCE not in line] + return [line.strip() for line in file if current_instance not in line] except Exception as err: print_colors('[-] Couldn\'t read official webring participants file',is_error=True ) @@ -828,15 +775,10 @@ def get_local_verified_and_unverified(): return pd.DataFrame(), pd.DataFrame() -def get_local_webring_participants(current_instance): +def get_local_webring_participants(): """ Make sure the official participants are registered in the webring csv file - Parameters - ---------- - current_instance : str - The current local instance url - Returns ------- pd.DataFrame @@ -850,9 +792,7 @@ def get_local_webring_participants(current_instance): missing_participants = set(get_official_participants()) - set(webring_df['URL']) for participant in missing_participants: - if participant == current_instance: - continue - new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': '', 'Blacklisted': 'NO'}] + new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': ''}] webring_df = pd.concat([webring_df, pd.DataFrame(new_row)], ignore_index=True) save_dataframe(webring_df, conf.LOCAL_DIR + conf.WEBRING_CSV_FILE) diff --git a/www/header.php b/www/header.php index 2d95866..0073bf1 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]); } @@ -203,6 +203,8 @@ function DisplayCategories($instancename, $path) { ?> + +

Update Frequency: every 3 hours


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

"; -?> +?>

@@ -100,7 +99,6 @@ require("header.php"); ?>
-
Submit a new link
'],'', $_POST['link']); - // Clear user input + // Clear user input $link = htmlspecialchars($link); $name = htmlspecialchars($_POST['name']); $description = htmlspecialchars($_POST['description']); @@ -14,36 +12,33 @@ if (isset($_POST['submit'])){ $captcha = htmlspecialchars($_POST['captcha']); // Captcha Auth check if ($captcha != htmlspecialchars($_SESSION['secure'])){ - $submission_message = "Error: Captcha Failed"; - } else { + echo "Captcha Failed"; + }else{ if (empty($link) or empty($name) or empty($description)){ - $submission_message = "Error: All of the fields must not be empty"; - } else { + echo "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 = "Error: Don't exceed the limit"; - } else { + echo "Don't excede 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."); - } - - if ($submission_message === null) { // Only set success message if no error occurred - $submission_message = "Link Successfully Submitted"; - } - } + // Close the file after writing + fclose($file); + } else { + // Handle error opening the file + error_log("Error opening the file."); + } + echo "Link Successfully Submitted"; + } } } } @@ -73,7 +68,6 @@ if (isset($_POST['submit'])){
-

Character Limits

Link should be 354

@@ -96,7 +90,7 @@ if (isset($_POST['submit'])){
- +