Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:18:23+00:00 2026-05-28T05:18:23+00:00

I have a phpBB forum on my localhost for learning purposes..now I’m trying to

  • 0

I have a phpBB forum on my localhost for learning purposes..now I’m trying to do this using PHP :

When a link gets posted,a script checks if the exact link exists and if it does then the process of posting the message doesn’t continue.
EDIT: This is what I have in includes/message_parser.php

function url_exists($url) {
$handle = @fopen($url, "r");
if ($handle === false){
return false;
fclose($handle);}
else{
return true;
fclose($handle);}}

And this is what I have in posting.php

$your_url = "http://www.somewhere.com/index.php";

$your_url = preg_replace(array('#&\#46;#','#&\#58;#','/\[(.*?)\]/'), array('.',':',''), $your_url);

if (url_exists($your_url))
{
echo 'yeah, its reachable';
}
else
{
echo 'what da hell..';
}

It works. I can see it echoing what da hell when I post a link that exists,but the problem is that the post gets posted. what I want now is,if the link exists,then don’t allow the post to be posted.

2ND EDIT:

if($submit){
    $URL = "http://www.fileserve.com/file/rP59FZ2";
    preg_replace(array('#&\#46;#','#&\#58;#','/\[(.*?)\]/'), array('.',':',''), $url);
if(url_exists($url)) {
    echo "Link exists!";
}

That’s what I did to prevent submitting the topic when the url exists. not working :\

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:18:24+00:00Added an answer on May 28, 2026 at 5:18 am

    Checking if link return status code 200 (dunno about 30x)

    Using cURL:

    function url_exists($url) {
        $ch = @curl_init($url);
        @curl_setopt($ch, CURLOPT_HEADER, TRUE);
        @curl_setopt($ch, CURLOPT_NOBODY, TRUE);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
        @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $status = array();
        preg_match('/HTTP\/.* ([0-9]+) .*/', @curl_exec($ch) , $status);
         return ($status[1] == 200);
    }
    // now call the function
    $myUrl = "http://www.somewhere.com";
    if(url_exists($myUrl)) {
        echo "Link exists!";
    } else {
        echo "Link does not exist :(";
    }
    

    Without cURL:

    function url_exists($url) {
        $h = get_headers($url);
        $status = array();
        preg_match('/HTTP\/.* ([0-9]+) .*/', $h[0] , $status);
        return ($status[1] == 200);
    }
    // now call the function
    $myUrl = "http://www.somewhere.com";
    if(url_exists($myUrl)) {
        echo "Link exists!";
    } else {
        echo "Link does not exist :(";
    }
    

    You can play around with it 🙂

    UPDATE

    To the updated question.

    I don’t know exactly how phpBB works or where you’re trying to catch it, but some suggestions to stop the posting might be to check for the link using javascript/jQuery and then disable the submit button alerting/printing a statement as to why the post wasn’t posted.

    I’m not that into regex and such, but you would check the post if it contains any link you where looking for, and then “block” the submit of the form.

    Something along the lines of:

    $('#myform').submit(function(event){
        // disable the submit button so the user doesn't spam it
        $('#myform input[type=submit]', this).attr('disabled', 'disabled');
    
        // check with regex for the links
        // if it's found return true else return false to variable preventSubmit
        if(preventSubmit) {
            // prevent the form from being submitted
            event.preventDefault();
            // notify the user
            alert("You cannot post that link!");
            return false;
        }
    
    });
    

    as extra security, you could disable the submit by default, and only enable it once the javascript has loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a forum using phpBB. Now i would like to do something like
I have limited knowledge of php and mysql, I am trying to learn it
I am building a forum from scratch in PHP. I have used the most
I have this replace regex (it's taken from the phpbb source code). $match =
I'm painfully new to PHP, and was trying to set up phpBB on my
Ok, please look at my problem: http://phone7forum.com/viewforum.php?f=2 http://phone7forum.com/viewtopic.php?f=2&t=4 I've been editing a phpBB forum
I have a web application that requires Blog Forum Chat support etc Now my
For a personal project, I need to build a forum using PHP and MySQL.
I have an asp.net mvc application, phpBB forum and asp.net webservice that I want
Our forum is based on phpbb3 and for sometime we have been using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.