DoCamera.pl
上传用户:qdrechuli
上传日期:2022-08-01
资源大小:917k
文件大小:3k
- #!/usr/bin/perl -w
- use strict;
- use DBI;
- use CGI;
- use vars qw(%base);
- use Jpc::Html;
- 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 SetStateGet
- {
- (my $State) = @_;
- my $db = DBI->connect("DBI:mysql:netcam","root","");
- my $sqlreq = "UPDATE vars SET V_Value='".$State."' WHERE V_Var='GetCamState'";
- my $sql = $db->prepare($sqlreq);
- $sql->execute();
- $sql->finish();
- $db->disconnect();
- }
- sub SetStateOpt
- {
- (my $State) = @_;
- my $db = DBI->connect("DBI:mysql:netcam","root","");
- my $sqlreq = "UPDATE vars SET V_Value='".$State."' WHERE V_Var='OptCamState'";
- my $sql = $db->prepare($sqlreq);
- $sql->execute();
- $sql->finish();
- $db->disconnect();
- }
- sub main
- {
- my $sql;
- my $sqlreq;
- my $h = new CGI;
- my $CID = $h->param('VL_Cam');
- my $Act = $h->param('VL_Act');
- if ($Act eq 'Cr閑r')
- {
- Document("Confirmation Cr閍tion Cam閞a");
- Titre("Confirmation Cr閍tion Cam閞a");
- }
- if ($Act eq 'Modifier')
- {
- Document("Confirmation Modification Cam閞a");
- Titre("Confirmation Modification Cam閞a");
- }
- if ($Act eq 'Supprimer')
- {
- Document("Confirmation Suppression Cam閞a");
- Titre("Confirmation Suppression Cam閞a");
- }
- print '<FONT FACE=verdana SIZE=+1>';
- my $db = DBI->connect("DBI:mysql:netcam","root","");
- my $CName = $h->param('VL_Name');
- my $CUrl = $h->param('VL_Url');
- my $CUser = $h->param('VL_User');
- my $CPwd = $h->param('VL_Pwd');
- my $CActive = $h->param('VL_Active');
- my $CFreq = $h->param('VL_Freq');
- my $CAge = $h->param('VL_Age');
- print '<BR>Cam閞a ID : ',$CID,"n";
- print '<BR>Cam閞a : ',$CName,"n";
- print '<BR>Url : ',$CUrl,"n";
- print '<BR>User : ',$CUser,"n";
- print '<BR>Password : ',$CPwd,"n";
- print '<BR>Enregistrer : ',$CActive,"n";
- print '<BR>Fr閝uence : ',$CFreq,"n";
- print '<BR>R閠ention : ',$CAge,"n";
- if ($Act eq 'Cr閑r')
- {
- $base{insert} = $db->prepare("INSERT INTO cam VALUES ( ?,?,?,?,?,?,?,?,?)");
- $db->do("LOCK TABLE cam LOW_PRIORITY WRITE");
- $base{insert}->execute('',$CName,$CUrl,$CUser,$CPwd,$CActive,$CFreq,0,$CAge);
- $db->do("UNLOCK TABLE");
- SetStateGet('RESTART');
- SetStateOpt('RESTART');
- }
- if ($Act eq 'Modifier')
- {
- SetStateGet('STOP');
- SetStateOpt('STOP');
- sleep(10);
-
- $base{update} = $db->prepare("UPDATE cam SET C_Name=?,C_Url=?,C_User=?,C_Pwd=?,C_Active=?,C_Freq=?,C_Age=? WHERE C_ID=?");
- $db->do("LOCK TABLE cam LOW_PRIORITY WRITE");
- $base{update}->execute($CName,$CUrl,$CUser,$CPwd,$CActive,$CFreq,$CAge,$CID);
- $db->do("UNLOCK TABLE");
-
- SetStateGet('START');
- SetStateOpt('START');
- }
- if ($Act eq 'Supprimer')
- {
- SetStateGet('STOP');
- SetStateOpt('STOP');
- sleep(10);
- $base{delete} = $db->prepare("DELETE FROM cam WHERE C_ID=?");
- $db->do("LOCK TABLE cam LOW_PRIORITY WRITE");
- $base{delete}->execute($CID);
- $db->do("UNLOCK TABLE");
- $base{delete} = $db->prepare("DELETE FROM record WHERE R_CAM=?");
- $db->do("LOCK TABLE record LOW_PRIORITY WRITE");
- $base{delete}->execute($CID);
- $db->do("UNLOCK TABLE");
- SetStateGet('START');
- SetStateOpt('START');
- }
- $db->disconnect();
- Fin_Document();
- }
- main();
- exit(0);