ImgDirect.pl
上传用户:qdrechuli
上传日期:2022-08-01
资源大小:917k
文件大小:1k
- #!/usr/bin/perl -w
- use strict;
- use DBI;
- use CGI;
- use LWP::UserAgent;
- sub main
- {
- my $h = new CGI;
- my $CamID = $h->param('VL_Cam');
- my $db = DBI->connect("DBI:mysql:netcam","root","");
- my $sqlreq = "SELECT C_Url,C_User,C_Pwd FROM cam WHERE ";
- $sqlreq .= "C_ID=".$CamID." ";
- my $sql = $db->prepare($sqlreq);
- $sql->execute();
- (my $CUrl,my $CUser,my$CPwd) = $sql->fetchrow();
- $sql->finish();
- $db->disconnect();
- print "Content-Type: image/jpegn";
- # print "Content-Length: " . "0" . "n";
- print "Pragma: no-cachen";
- print "n";
- my $ua = LWP::UserAgent->new;
- $ua->agent("$0/0.1 " . $ua->agent);
- my $req = HTTP::Request->new(GET => 'http://'.$CUrl.'/axis-cgi/mjpg/video.cgi');
- $req->authorization_basic($CUser,$CPwd);
- my $res = $ua->request($req);
- if ($res->is_success)
- {
- print $res->content;
- }
- }
-
- main();
- exit(0);