We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27889
    • 415 Posts
    This topic is no more used, see The DebugTool support Topic



    I’m trying to make a link checker for my debug tool.

    //check links don't work :(
    $href='http://ww.gooredegle.fr';
    $file = @fopen ($href, 'r'); // @ used to skip warning
    if (!$file) {
      $is_link_ok="<span style=\"color:red;\">$href FAILS! </span>\n";
    } else { 
      $is_link_ok="$href: OK\n";fclose($file);
    }
    

    but when the link is wrong, MODx raise an error:
    [tt]« MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: fopen(): php_network_getaddresses: gethostbyname failed
    Error type/ Nr.: Warning - 2
    File: W:\www\modx\manager\includes\document.parser.class.inc.php(705) : eval()’d code
    Line: 86[/tt]

    Anyone as an idea ? Now I use socket.
      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
      • 18397
      • 3,250 Posts
      If I recall, fopen is normally used for files and not web sites. If your host does not have it blocked, you can try appending /index.php to the url to have it retrieve the file. The better function is file_get_contents().
        • 27889
        • 415 Posts
        fopen

        (PHP 3, PHP 4 >= 4.0.0)
        fopen -- Opens file or URL

        Thank for the info Mark, but now I use socket to check the url in an other php file because I try an Ajax way to achieve the check.
          MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
          MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
          • 27889
          • 415 Posts
          It seems to work well now, I post in the repository the full debugtool included the Links Checker.
            MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
            MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]