#!/usr/bin/perl -Tw # # ntriples.pl - Redland N-Triples validator demo # # Copyright (C) 2002-2004, David Beckett http://www.dajobe.org/ # Copyright (C) 2000-2004, University of Bristol, UK http://www.bristol.ac.uk/ # # This package is Free Software and part of Redland http://librdf.org/ # # It is licensed under the following three licenses as alternatives: # 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version # 2. GNU General Public License (GPL) V2 or any newer version # 3. Apache License, V2.0 or any newer version # # You may not use this file except in compliance with at least one of # the above three licenses. # # See LICENSE.html or LICENSE.txt at the top of this package for the # complete terms and further detail along with the license texts for # the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. # # # # CHANGE THIS FOR YOUR CONFIGURATION $::ROOT_DIR='/somewhere'; use strict; # Helps with broken web requests (missing headers) $ENV{'Content-Length'}||=0; # Tainting, dontcha know $ENV{'PATH'}="/bin:/usr/bin:/usr/local/bin:$::ROOT_DIR/bin/"; delete $ENV{'BASH_ENV'}; # Standard perl modules use CGI; use LWP::Simple; use URI::URL; # Configuration my $tmp_dir="$::ROOT_DIR/tmp"; my $log_file="$::ROOT_DIR/logs/ntriples.log"; my $max_stream_size=200; my $max_error_size=100; my(@parameters)=qw(uri); # Redland perl modules use RDF::Redland; use RDF::Redland::RSS; ###################################################################### # Subroutines sub log_action ($$;$) { my($host, $message, $now)=@_; $now ||= time; return unless open (LOG, ">>$log_file"); my($sec,$min,$hour,$mday,$mon,$year)=gmtime $now; my $date=sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",1900+$year,$mon+1,$mday,$hour,$min,$sec); print LOG "$host $date $message\n"; close(LOG); } sub end_page($) { my $q=shift; print <<"EOT";
This was written using Redland and the RDF::Redland::Parser Perl interface to the Raptor N-Triples parser.
The source code of this demonstration is available in the Redland distribution as demos/ntriples.pl or from the Redland website
EOT print qq{