Jump to content

last thing in checking url function


wadie

Recommended Posts

I'm trying to create a function which checks if a url has been posted before,and if it has then an error is given.

 

This is what I have so far in /includes/functions_posting.php

 

      function http_file_exists($url)
        {
          $f = @fopen($url,"r");
          if($f)
          {
            fclose($f);
          return true;
          }
        return false;
        } 

 

And this is what I have in posting.php

 

 

    if ($submit || $preview || $refresh)
        {
         $post_data['your_url'] = "http://www.google.com"; //remove the equals and url value if using in real post
          $your_url = $post_data['your_url'];
          $your_url_exists = (isset($your_url)) ? true : false;
          $your_url = preg_replace(array('#&\#46;#','#&\#58;#','/\[(.*?)\]/'), array('.',':',''), $your_url);
    
          if ($your_url_exists && http_file_exists($your_url) == true)
          {
            trigger_error('exists!');
          }
          else if ($your_url_exists && http_file_exists($your_url) == false)
          {
            trigger_error('doesnt exist..');
          }

 

It works fine,but I still don't know how to do one last thing.

 

if the url doesn't exist,I want it to continue posting. else,trigger the error message that url exists.

 

I think I'm close,but not sure where to go now  :confused:

Link to comment
Share on other sites

It's not working that way.

 

There's even another problem which is it doesn't matter what's the full URL. it's enough to assign http://www. to the variable

$post_data['your_url']

and then it will always show that the url exists no matter what's the url I'm trying to post.

 

I'd really appreciate it and even willing to pay if someone can make it fully work cause it's getting on my nerve now  >:(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.