Record.pl
上传用户:qdrechuli
上传日期:2022-08-01
资源大小:917k
文件大小:7k
- #!/usr/bin/perl -w
- use strict;
- use DBI;
- use CGI;
- #use Jpc::Html;
- sub Document
- {
- (my $Titre,my $Act,my $Cam,my $Year,my $Mon,my $Day,my $Hour,my $Cur) = @_;
- my $Meta;
- print "Content-type: text/htmln";
- print "n";
- print '<HTML>',"n";
- print '<HEAD>',"n";
- my $Cmd = $Cam;
- $Cmd .= '-'.$Year;
- $Cmd .= '-'.$Mon;
- $Cmd .= '-'.$Day;
- $Cmd .= '-'.$Hour;
- if ($Act eq 'ReculerV') { $Cur -=3 ; }
- if ($Act eq 'Lire') { $Cur +=1 ; }
- if ($Act eq 'AvancerV') { $Cur +=3 ; }
- $Cmd .= '-'.$Cur;
- $Cmd .= '-'.$Act;
-
- # $Meta = '/cgi-bin/Net-Cam/Record.pl?VL_Cmd='.$Cmd;
- $Meta = 'Record.pl?VL_Cmd='.$Cmd;
- if ($Act eq 'Lire' or $Act eq 'AvancerV' or $Act eq 'ReculerV')
- {
- print '<meta http-equiv="Refresh" content="1;URL=',$Meta,'">';
- # print '<meta http-equiv="Refresh" content="3">';
- }
- print '<TITLE>',$Meta,'</TITLE>',"n";
- print '</HEAD>',"n";
- print '<BODY BGCOLOR="#FFFFFF" BACKGROUND="/NetAdmin/images/fond2.jpg">',"n";
- }
- sub Titre
- {
- print '<H1 ALIGN="CENTER">',$_[0],"</H1><P>n";
- }
- sub Chapitre
- {
- print '<H3>',$_[0],"</H3>n";
- }
-
- sub Fin_Document
- {
- print '</BODY>',"n";
- print '</HTML>',"n";
- }
- sub main
- {
- my $sql;
- my $sqlreq;
-
- my $h = new CGI;
- my $Pos;
-
- my $PCmd = $h->param('VL_Cmd');
- $Pos = index($PCmd,"-");
- my $CamID = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
- $Pos = index($PCmd,"-");
- my $Year = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
- $Pos = index($PCmd,"-");
- my $Mon = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
-
- $Pos = index($PCmd,"-");
- my $Day = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
-
- $Pos = index($PCmd,"-");
- my $Hour = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
- $Pos = index($PCmd,"-");
- my $Cur = substr($PCmd,0,$Pos);
- $PCmd = substr($PCmd,$Pos+1,length($PCmd)-$Pos-1);
- my $Act = $PCmd;
- Document("Net-Cam : Visualisation Enregistrement",$Act,$CamID,$Year,$Mon,$Day,$Hour,$Cur);
- Titre("Net-Cam : Visualisation Enregistrement");
- print '<FONT FACE=verdana>';
- print '<FONT SIZE="+1">';
- my $db = DBI->connect("DBI:mysql:netcam","root","");
- $sqlreq = "SELECT C_Url,C_Name,C_Active,C_Freq FROM cam WHERE C_ID LIKE '".$CamID."'";
- $sql = $db->prepare($sqlreq);
- $sql->execute();
- (my $CUrl,my $CName,my $CActive,my $CFreq) = $sql->fetchrow();
- $sql->finish();
- print "Camera = ",$CName," ";
- print "Url = HTTP://",$CUrl,"<BR>";
- print "<B>";
- if ($CActive)
- {
- print "<FONT COLOR=GREEN>Enregistrement ACTIF</FONT> ";
- print "Fr閝uence = 1 image toutes les ",$CFreq," secondes<BR>n";
- }
- else
- {
- print "<FONT COLOR=RED>Enregistrement INACTIF</FONT><BR>n";
- }
- print "</B><P>n";
- my $Date = $Year;
- if ($Mon<10) { $Date .= '0'; }
- $Date .= $Mon;
- if ($Day<10) { $Date .= '0'; }
- $Date .= $Day;
- if ($Hour<10) { $Date .= '0'; }
- $Date .= $Hour;
- $sqlreq = "SELECT T_Index FROM tranche WHERE ";
- $sqlreq .= "T_Cam=".$CamID." ";
- $sqlreq .= "AND T_Day ='".substr($Date,0,8)."' ";
- $sqlreq .= "AND T_Hour =".substr($Date,8,2)." ";
- $sql = $db->prepare($sqlreq);
- $sql->execute();
- (my $NbImg) = $sql->fetchrow();
- $sql->finish();
- print $NbImg," images sur cette p閞iode ",$Date,"<BR>n";
- if ($NbImg)
- {
- my $SDate = $Date;
- my $Minutes = int($Cur/60);
- if ($Minutes<10) { $SDate .= '0'; }
- $SDate .= $Minutes;
- my $Secondes = $Cur % 60;
- if ($Secondes<10) { $SDate .= '0'; }
- $SDate .= $Secondes;
- print '<P>SearchDate = ',$SDate," Cur=",$Cur,"<BR>n";
- my $sqlreq = "SELECT R_Date,R_Index FROM record WHERE ";
- $sqlreq .= "R_Cam=".$CamID." ";
- $sqlreq .= "AND R_Day ='".substr($Date,0,8)."' ";
- $sqlreq .= "AND R_Hour =".substr($Date,8,2)." ";
- $sqlreq .= "AND R_Index =".$Cur." ORDER BY R_Index ";
- $sqlreq .= "LIMIT 0,1";
- my $sql = $db->prepare($sqlreq);
- $sql->execute();
- (my $TimeDate,my $Index) = $sql->fetchrow();
- #(my $TimeDate,my $Index) = ('toto',0);
- $sql->finish();
- print "<P>New index = ",$Index,"n";
- $Cur = $Index;
- print "<P>New index = ",$Cur,"n";
- if ($TimeDate eq '')
- {
- print "<P>Timedate blancn";
- $Cur=$NbImg;
- $sqlreq = "SELECT R_Date,R_Index FROM record WHERE ";
- $sqlreq .= "R_Cam=".$CamID." ";
- $sqlreq .= "AND R_Day like '".substr($Date,0,8)."' ";
- $sqlreq .= "AND R_Hour =".substr($Date,8,2)." ";
- $sqlreq .= "AND R_Index >=".$Cur." ORDER BY R_Index LIMIT 0,1";
- $sql = $db->prepare($sqlreq);
- $sql->execute();
- ($TimeDate,$Index) = $sql->fetchrow();
- $sql->finish();
- $Cur = $Index;
- }
- print "<BR>",$Act," ",$Cur,"<BR>";
- if ($Act eq 'D閎ut') { $Cur = 1; }
- if ($Act eq 'Reculer') { $Cur -= 1; }
- if ($Act eq 'Avancer') { $Cur += 1; }
- if ($Act eq 'Lire') { $Cur += 1; }
- if ($Act eq 'Fin') { $Cur = $NbImg; }
- if ($Cur<1) { $Cur=1; }
- if ($Cur>$NbImg) { $Cur = $NbImg; $Act = 'Stop'; }
- my $Cmd = $CamID;
- $Cmd .= '-'.$Year;
- $Cmd .= '-'.$Mon;
- $Cmd .= '-'.$Day;
- $Cmd .= '-'.$Hour;
- $Cmd .= '-'.$Cur;
- $Cmd .= '-';
- print '<TABLE COLS=8>';
- print '<TR>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'D閎ut">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="D閎ut">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'ReculerV">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Reculer Vite">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'Reculer">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Reculer">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'Lire">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Lire">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'Stop">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Stop">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'Avancer">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Avancer">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'AvancerV">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Avancer Vite">';
- print "</FORM>";
- print '</TD>';
- print '<TD>';
- print "<FORM METHOD=GET ACTION=Record.pl>","n";
- print ' <INPUT NAME="VL_Cmd" TYPE="HIDDEN" VALUE="',$Cmd,'Fin">';
- print '<INPUT NAME="VL_Ok" TYPE="SUBMIT" VALUE="Fin">';
- print "</FORM>";
- print '</TD>';
- print '</TR>';
- print '</TABLE>';
- print '<CENTER>';
- print "Image = ",$Index," Horodatage = ",$TimeDate,"n";
- print '<BR><CENTER><IMG SRC="DispImg.pl?VL_Cam=',$CamID,';VL_Date=',$Date,';VL_Cur=',$Index,'">',"</CENTER>n",
- }
- $db->disconnect();
- Fin_Document();
- }
- main();
- exit(0);