*

RWozney

  • **
  • 6 posts
Help with URL blocking code.
« on: June 02, 2024, 12:45:13 AM »
I am trying to place this code into my classified ad website to block
certain URL's

import re

# List of URLs to block
blocked_urls = [
    "example.com",
    "blockeddomain.com",
    # Add more URLs here as needed
]

# Function to check if a URL is blocked
def is_url_blocked(url):
    for blocked_url in blocked_urls:
        if re.search(blocked_url, url):
            return True
    return False

# Example usage
def post_advertisement(ad_text, ad_url):
    if is_url_blocked(ad_url):
        print("Sorry, the URL you are trying to post is not allowed.")
    else:
        # Post the advertisement
        print("Advertisement posted successfully!")

# Test
post_advertisement("Check out this website: example.com", "example.com")
post_advertisement("Great deals here: myclassifieds.com", "myclassifieds.com")

Does anyone know which file I need to olace it in?

I have 2 different sites and using  fino and  bitfinder with
osclass 8.2.1 version back office.

Robert

*

MB Themes

Re: Help with URL blocking code.
« Reply #1 on: June 04, 2024, 02:36:57 PM »
Python code will not work in PHP script.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots