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
https://forums.phpfreaks.com/topic/255909-last-thing-in-checking-url-function/
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  >:(

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.