help in bbcode code Correction

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help in bbcode code Correction

    pls i want some one to help me correct this code pls

    PHP Code:
      private static function highlight_url($var)
        {
            if (!
    function_exists('process_url')) {
                function 
    process_url($url)
                {
    function 
    page_title($url) {     $page = @file_get_contents($url);
    if (empty(
    $page)) return null;    $matches = array();
    if (
    preg_match('/<title>(.*?)<\/title>/'$page$matches))

    return 
    $matches[1];
    }
    else
    {
    return 
    null;
    }
    }

                    if (!isset(
    $url[3])) {
                        
    $tmp parse_url($url[1]);
                        if (
    'http://' $tmp['host'] == core::$system_set['homeurl'] || isset(core::$user_set['direct_url']) && core::$user_set['direct_url']) {
                            return 
    '<a href="' $url[1] . '">' $ptitle '</a>';
                        } else {
                            return 
    '<a href="' core::$system_set['homeurl'] . '/go.php?url=' base64_encode($url[1]) . '">' $ptitle '</a>';
                        }
                    } else {
                        
    $tmp parse_url($url[3]);
                        
    $url[3] = str_replace(':'':'$url[3]);
                        if (
    'http://' $tmp['host'] == core::$system_set['homeurl'] || isset(core::$user_set['direct_url']) && core::$user_set['direct_url']) {
                            return 
    '<a href="' $url[3] . '">' $url[3] . '</a>';
                        } else {
                            return 
    '<a href="' core::$system_set['homeurl'] . '/go.php?url=' base64_encode($url[3]) . '">' $url[3] . '</a>';
                        }
                    }
                }
            }
            return 
    preg_replace_callback('~\\[url=(https?://.+?)\\](.+?)\\[/url\\]|(https?://(www.)?[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:#]*)~''process_url'$var);
        } 
    Added after 6 minutes:

    i was try to get the title of links posted in my forum but it gave me error,
    pls ignore any rubbish i have done there
    Last edited by metulj; 20.04.12, 14:53. Reason: use [ php ] code tag [ / php ] for posting code

    #2
    your variables are all mis-matched names :/
    there is a lot of the code missing?
    ...
    this topic came up a few days ago and i think just_m3 solved it .... so probably better off using his code

    Comment


      #3
      pls, pls just help i am a newbie in php. What happened is this

      this was the original code
      PHP Code:
       private static function highlight_url($var)
          {
              if (!
      function_exists('process_url')) {
                  function 
      process_url($url)
                  {
                      if (!isset(
      $url[3])) {
                          
      $tmp parse_url($url[1]);
                          if (
      'http://' $tmp['host'] == core::$system_set['homeurl'] || isset(core::$user_set['direct_url']) && core::$user_set['direct_url']) {
                              return 
      '<a href="' $url[1] . '">' $url[2] . '</a>';
                          } else {
                              return 
      '<a href="' core::$system_set['homeurl'] . '/go.php?url=' base64_encode($url[1]) . '">' $url[2] . '</a>';
                          }
                      } else {
                          
      $tmp parse_url($url[3]);
                          
      $url[3] = str_replace(':'':'$url[3]);
                          if (
      'http://' $tmp['host'] == core::$system_set['homeurl'] || isset(core::$user_set['direct_url']) && core::$user_set['direct_url']) {
                              return 
      '<a href="' $url[3] . '">' $url[3] . '</a>';
                          } else {
                              return 
      '<a href="' core::$system_set['homeurl'] . '/go.php?url=' base64_encode($url[3]) . '">' $url[3] . '</a>';
                          }
                      }
                  }
              }
              return 
      preg_replace_callback('~\\[url=(https?://.+?)\\](.+?)\\[/url\\]|(https?://(www.)?[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:#]*)~''process_url'$var);
          } 
      Added after 3 minutes:

      what it does is just to highlight the url in the forum so what i wanted is for it to also fetch the title of the highlighted url thats why i tried to use that file_get_contents, pls help
      Last edited by bestman; 20.04.12, 16:18.

      Comment

      Working...
      X