# $Id$ # Captive project DriverSurvey page Perl template. # Copyright (C) 2005 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; exactly version 2 of June 1991 is required # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package project::captive::DriverSurvey; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; our $CVS_ID=q$Id$; use strict; use warnings; use My::Web; use Apache2::Cookie; require Time::Piece::ISO; use Carp qw(confess cluck); our $HTML_TEST_QUERY_STRING="captive-static-1.1.6-0.i386.rpm"; # It will not return the new cookie if you set one! sub cookie(;$) { my($val)=@_; my $trash; # For {"headers_in"} stability. $trash=$W->{"headers_in"}{"Cookie"}; $trash=$W->{"headers_in"}{"Cookie2"}; my $jar=Apache2::Cookie::Jar->new($W->{"r"}); my $name=__PACKAGE__; if (defined $val) { my $cookie=Apache2::Cookie->new($W->{"r"}, "name" =>$name, "value" =>$val, "expires"=>"+3M", "domain" =>$W->{"web_hostname"}, # No __PACKAGE__ as it needs to be retrieved also from: /project/captive/Index.pm "path" =>"/project/captive/", "secure" =>0, # Do not: # Prevent: Can't bake2 a Netscape cookie # "version"=>1, # as RFCed "Cookie2" somehow does not work and even nobody uses it. ); # Do not: $cookie->bake2($W->{"r"}); # as RFCed "Cookie2" somehow does not work and even nobody uses it. $cookie->bake($W->{"r"}); } # Somehow it may croak on error parsing the cookie headers or whatever. return eval { $jar->cookies($name) }; } my $COLS=50; sub nameval($) { my($name)=@_; my $val=$W->{"args"}{$name}; return 'name="'.$name.'"'.(!defined $val ? "" : ' value="'.escapeHTML($val).'"'); } sub textarea($$;$) { my($name,$rows,$attr)=@_; return <<"HERE"; HERE } sub radio($$;$) { my($name,$value,$attr)=@_; return <<"HERE"; {"args"}{$name}||"") ne $value ? '' : ' checked="checked"' ]}@{[ !$attr ? '' : ' '.$attr ]} /> HERE } sub store() { my $data=""; $data.=<<"HERE"; stamp: @{[ Time::Piece::ISO::gmtime()."+00:00" ]} HERE for my $key (qw( User-Agent Referer _remote_ip X-Forwarded-For )) { next if !defined (my $val=$W->{"headers_in"}{$key}); $data.=<<"HERE" headers_in::$key=$val HERE } $data.="\n"; for my $key (sort keys(%{$W->{"args"}})) { next if $key eq "file"; next if $key eq "submit"; my $val=$W->{"args"}{$key}; next if !defined $val; next if $val eq ""; $data.=<<"HERE"; $key: $val HERE } $data.=("-" x 78)."\n\n"; my $filename=">>".path_abs_disk("./DriverSurvey.out"); local *F; open F,$filename or confess "open \"$filename\": $!"; print F $data or confess "write \"$filename\": $!"; close F or confess "close \"$filename\": $!"; } sub submit() { return "Please check the appropriate leftmost checkmark." if !$W->{"args"}{"kind"}; store(); # It works as &Apache2::Cookie::bake uses &err_headers_out - it is a redirect (not 200 OK). cookie(1); My::Web->http_moved("./"); } sub handler { My::Web->init( "title"=>'Captive NTFS - Linux Drivers Availability Survey', "js_push"=>"./DriverSurvey.js", "args_check"=>{ "file"=>'^[^/]*$', }, "args_persistent"=>{map(($_=>1),qw( file ))}, "css_push"=>"./Lib.css", "heading"=>0, "footer"=>0, "no_job"=>1, "http_safe"=>0, ); # Workaround persistence of 'empty' argument - omit it instead. do { $$_=undef() if !$$_; } for \$W->{"args"}{"file"}; my $error=submit() if $W->{"args"}{"submit"}; # At least after &submit ! My::Web->heading(); my $PRODUCTS_MAX=5; print <<"HERE";

Linux Drivers Availability

HERE if (!$error) { print <<"HERE";

Please take a minute before downloading Captive NTFS to fill in this survey for the possibility to extend Captive for free support of other MS-Windows drivers (besides the current file system drivers). The original MS-Windows installation (ntoskrnl.exe) would not even be needed in such case.

HERE } else { print <<"HERE";

$error

HERE } print <<"HERE";
@{[ input_hidden_persistents() ]} HERE if ($error) { print <<"HERE"; HERE } print <<"HERE";

@{[ radio "kind","owned" ]} I would like such MS-Windows drivers interface - I have a hardware device missing Linux support.

@{[ radio "kind","wannabuy" ]} I would like to buy a hardware device but so far I could not as it is not Linux compatible.

HERE for my $producti (0..$PRODUCTS_MAX-1) { print <<"HERE"; HERE } # Just a protection for non-CSS non-JS browsers to no longer display the button: if (!$W->{"args"}{"productnext"}) { print <<"HERE"; HERE } print <<"HERE";
Incompatible Hardware Details
Product #@{[ 1+$producti ]}
Vendor (if known) and product name
Product webpage URL (if known)
 
Would you like to cooperate on the driver testing? @{[ radio "coop","yes" ]} Yes, I want to test a snapshot of the driver right now.
@{[ radio "coop","buy" ]} Yes but only if the driver somehow works to buy the device first.
@{[ radio "coop","no" ]} No, I do not own the device or I do not want to test it.
@{[ radio "coop","other",'id="coop_other_radio"' ]} Other answer:
@{[ textarea "coop_other_textarea",2,q{onkeypress="click_on('coop_other_radio');"} ]}
@{[ radio "kind","oss" ]} I know a specific hardware (either mine or just seen) is not compatible but I do not want to use MS-Windows drivers in Linux.

What are the more specific reasons? Are you aware the drivers in Linux are in many times just reverse engineered out of their MS-Windows counterparts?

@{[ textarea "kind_oss",3 ]}
@{[ radio "kind","working" ]} All my hardware is working perfectly in Linux.
@{[ radio "kind","answered" ]} I already answered this survey before.
Your e-mail; optional but appreciated:
Comments
@{[ textarea "comment",3 ]}
$error
{"args"}{"file"}) : "Submit the survey" ]}" />

Direct e-mail address: @{[ a_href 'mailto:driversurvey@jankratochvil.net' ]}

HERE exit; } 1;