1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#===================#
#== Password ==#
#== ISOTOP ©Viduc 2009 ==#
#== isotop.info@gmail.com ==#
#===================#
#===========#
#== Définition ==#
#===========#
# Ce script sert à récupérer un mot de passe renseigner par un utilisateur.
# Une boite de dialogue permet d'entrer le mot de passe de façon confidentiel.
# Le script enverra ensuite le mot de passe sous forme d'argument à un autre scirpt Batch ou VBS.
#====================#
#== Déclaration des modules ==#
#====================#
use strict;
use Tk; use Tk::Dialog;
#=========================#
#== Définition des Variables Globales ==#
#=========================#
my $Password;
#======================#
#== Définition des Variables Tk ==#
#======================#
my ($Fenetre_Principale, $Frame_Principale);
my ($Label_Password_1, $Label_Password_2, $Entry_Password_1, $Entry_Password_2, $Bouton_VALIDER, $Label_Info);
#=========================#
#== Création de la fenêtre principale ==#
#=========================#
$Fenetre_Principale = MainWindow->new();
$Fenetre_Principale->minsize('400','300');
$Fenetre_Principale->title("DSI Stendhal Administration");
#================#
#== Gestion Password ==#
#================#
Main_Frame();
#========================#
#== Gestion des paramètres visuels ==#
#========================#
#== Centrer la fenêtre principale
CentrerWidget($Fenetre_Principale);
#== Enlever les décors
$Fenetre_Principale -> overrideredirect(1);
#==================#
#== Lanceur d'évènement ==#
#==================#
MainLoop;
#===========#
#== Fonctions ==#
#===========#
sub CentrerWidget
{
#========================================
# But : Centrer un widget automatiquement
# Arguments : widget
# Retour : Rien
#========================================
unless ( scalar(@_) == 1 ) {die('Usage : CentrerWidget( $MainWidget );');}
my ( $Widget ) = @_;
# Height and width of the screen
my $LargeurEcran = $Widget->screenwidth();
my $HauteurEcran = $Widget->screenheight();
# update le widget pour recuperer les vraies dimensions
$Widget->update;
my $LargeurWidget = $Widget->width;
my $HauteurWidget = $Widget->height;
# On centre le widget en fonction de la taille de l'ecran
my $NouvelleLargeur = int( ( $LargeurEcran - $LargeurWidget ) / 2 );
my $NouvelleHauteur = int( ( $HauteurEcran - $HauteurWidget ) / 2 );
$Widget->geometry($LargeurWidget . "x" . $HauteurWidget . "+$NouvelleLargeur+$NouvelleHauteur");
$Widget->update;
return;
}
sub Main_Frame
{
my ($Sequence) = @_;
# -- Création de la Frame Centrale -- #
$Frame_Principale = $Fenetre_Principale->Frame(-relief => 'groove',
-borderwidth => 5,
-background => 'black',
-foreground => 'black');
$Frame_Principale->pack(-anchor => 'center',
-fill => 'both',
-expand => 1);
$Label_Password_1 = $Frame_Principale -> Label(-text => 'Entrez votre mot de passe',
-background => 'black',
-foreground => 'green');
$Label_Password_2 = $Frame_Principale -> Label(-text => 'Retapez votre mot de passe',
-background => 'black',
-foreground => 'green');
$Entry_Password_1 = $Frame_Principale -> Entry(-text => '', -justify => 'center', -width => 25, -show => '*');
$Entry_Password_2 = $Frame_Principale -> Entry(-text => '', -justify => 'center', -width => 25, -show => '*');
$Bouton_VALIDER = $Frame_Principale -> Button(-text => "Valider",
-command => \& Verification_Password);
if ($Sequence eq "wrong")
{
$Label_Info = $Frame_Principale -> Label(-text => 'Vous avez entré un mauvais mot de passe',
-background => 'black',
-foreground => 'red');
$Label_Info -> pack(-fill => 'none', -side => 'top', -expand => 1);
}
$Label_Password_1 -> pack(-fill => 'none', -side => 'top', -expand => 1);
$Entry_Password_1 -> pack(-fill => 'none', -side => 'top', -expand => 1);
$Label_Password_2 -> pack(-fill => 'none', -side => 'top', -expand => 1);
$Entry_Password_2 -> pack(-fill => 'none', -side => 'top', -expand => 1);
$Bouton_VALIDER -> pack(-fill => 'none', -side => 'top', -expand => 1);
}
sub Verification_Password
{
my $Password_1 = $Entry_Password_1 -> get();
my $Password_2 = $Entry_Password_2 -> get();
if ($Password_1 eq $Password_2 and $Password_1 ne "")
{
exec('wscript', 'Password.vbs', $Password_1);
exit(0);
}
else
{$Frame_Principale -> destroy(); Main_Frame("wrong");}
} |