"Fossies" - the Fresh Open Source Software Archive

Member "mythreads/docs_info/linklint-gen.pl" (30 Jun 2006, 2330 Bytes) of package /linux/privat/mythreads-links_1.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "linklint-gen.pl" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.2.0_vs_1.2.1.

    1 #!/usr/bin/perl
    2 #
    3 # $Id: linklint-gen.pl,v 1.2 2006-06-30 21:13:25 ldrolez Exp $
    4 #
    5 # Small Perl script which will convert the list of links on your Mythreads site
    6 # to a 'Linklint' configuration file.
    7 # Do not forget to install websec.php3 somewhere on your site.
    8 #
    9 #  Copyright (C) 2006 Ludovic Drolez
   10 #
   11 #  This program is free software; you can redistribute it and/or modify
   12 #  it under the terms of the GNU General Public License as published by
   13 #  the Free Software Foundation; either version 2 of the License, or
   14 #  (at your option) any later version.
   15 # 
   16 #  This program is distributed in the hope that it will be useful,
   17 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
   18 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19 #  GNU General Public License for more details.
   20 # 
   21 #  You should have received a copy of the GNU General Public License
   22 #  along with this program; if not, write to the Free Software
   23 #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
   24 #
   25 
   26 use LWP::UserAgent;
   27 
   28 # URL were your websec.php3 has been installed
   29 # Don't forget the password !
   30 $url = "http://www.example.com/websec.php3?pass=something";
   31 # ignore URLs containing this (regexp)
   32 $ignore = "example.com";
   33 # Were to write the 'linklint' configuration file
   34 $outfile="./linklint"; 
   35 
   36 # You can change the default options for 
   37 # the generated websec config file below
   38 mkdir $outfile;
   39 open(OUT, ">$outfile/urls.in");
   40 
   41 $ua = new LWP::UserAgent;
   42 $ua->agent("websec/1.0");
   43 $ua->env_proxy;
   44 $req = new HTTP::Request('GET', $url);
   45 # Try up to 3 times to download URL
   46 for(1..3)
   47 {
   48     $resp = $ua->request($req);
   49     if ($resp->is_success) { last; }
   50 }
   51 # If URL is successfully downloaded
   52 if ($resp->is_success)
   53 {
   54     print "Received HTTP data\n";
   55 } else {
   56     exit;
   57 }
   58 
   59 $count=0;
   60 foreach $line (split /\n/,$resp->content) {
   61     if ($count) {
   62     $url = $line;
   63     if ($url =~ m/$ignore/) {
   64         # ignore
   65     } else {
   66         $prefix = lc($name);
   67         $prefix =~ s/ $//g;
   68         $prefix =~ s/[^a-z0-9]/_/g;
   69         $slash = ($url =~ tr/\///);
   70             if ($slash > 2) { $prefix = "#$prefix"; }
   71             else { $prefix = "/#$prefix"; }
   72             print OUT "$url$prefix\n";
   73     }
   74     $count=0;   
   75     } else {
   76     $name = $line;
   77     $count++;
   78     }
   79 }
   80 
   81 close(OUT);
   82 
   83 print "\nDone. Now run 'linklint -netset -doc $outfile @".$outfile."/urls.in'\n";