#!/usr/bin/wish package require http font create police -family TkTextFont -size 9 -weight normal font create tresgrosse -family TkHeadingFont -size 16 -weight bold font create grosse -family TkHeadingFont -size 12 -weight normal font create grasse -family TkTextFont -size 9 -weight bold font create petite -family TkTextFont -size 8 -weight normal option add *font police namespace eval ::md5 { } if {![catch {package require Trf 2.0}] && ![catch {::md5 -- test}]} { proc ::md5::md5 {msg} { string tolower [::hex -mode encode -- [::md5 -- $msg]] } } else { # Without Trf use the all-tcl implementation by Don Libes. # T will be inlined after the definition of md5body # test md5 # # This proc is not necessary during runtime and may be omitted if you # are simply inserting this file into a production program. # proc ::md5::test {} { foreach {msg expected} { "" "d41d8cd98f00b204e9800998ecf8427e" "a" "0cc175b9c0f1b6a831c399e269772661" "abc" "900150983cd24fb0d6963f7d28e17f72" "message digest" "f96b697d7cb7938d525a2f31aaf161d0" "abcdefghijklmnopqrstuvwxyz" "c3fcd3d76192e4007dfb496cca67e13b" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" "d174ab98d277d9f5a5611c2c9f419d9f" "12345678901234567890123456789012345678901234567890123456789012345678901234567890" "57edf4a22be3c955ac49da2e2107b67a" } { puts "testing: md5 \"$msg\"" set computed [md5 $msg] puts "expected: $expected" puts "computed: $computed" if {0 != [string compare $computed $expected]} { puts "FAILED" } else { puts "SUCCEEDED" } } } # time md5 # # This proc is not necessary during runtime and may be omitted if you # are simply inserting this file into a production program. # proc ::md5::time {} { foreach len {10 50 100 500 1000 5000 10000} { set time [::time {md5 [format %$len.0s ""]} 100] set msec [lindex $time 0] puts "input length $len: [expr {$msec/1000}] milliseconds per interation" } } # # We just define the body of md5pure::md5 here; later we # regsub to inline a few function calls for speed # set ::md5::md5body { # # 3.1 Step 1. Append Padding Bits # set msgLen [string length $msg] set padLen [expr {56 - $msgLen%64}] if {$msgLen % 64 > 56} { incr padLen 64 } # pad even if no padding required if {$padLen == 0} { incr padLen 64 } # append single 1b followed by 0b's append msg [binary format "a$padLen" \200] # # 3.2 Step 2. Append Length # # RFC doesn't say whether to use little- or big-endian # code demonstrates little-endian # This step limits our input to size 2^32b or 2^24B append msg [binary format "i1i1" [expr {8*$msgLen}] 0] # # 3.3 Step 3. Initialize MD Buffer # set A [expr 0x67452301] set B [expr 0xefcdab89] set C [expr 0x98badcfe] set D [expr 0x10325476] # # 3.4 Step 4. Process Message in 16-Word Blocks # # process each 16-word block # RFC doesn't say whether to use little- or big-endian # code says little-endian binary scan $msg i* blocks # loop over the message taking 16 blocks at a time foreach {X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15} $blocks { # Save A as AA, B as BB, C as CC, and D as DD. set AA $A set BB $B set CC $C set DD $D # Round 1. # Let [abcd k s i] denote the operation # a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). # [ABCD 0 7 1] [DABC 1 12 2] [CDAB 2 17 3] [BCDA 3 22 4] set A [expr {$B + [<<< [expr {$A + [F $B $C $D] + $X0 + $T01}] 7]}] set D [expr {$A + [<<< [expr {$D + [F $A $B $C] + $X1 + $T02}] 12]}] set C [expr {$D + [<<< [expr {$C + [F $D $A $B] + $X2 + $T03}] 17]}] set B [expr {$C + [<<< [expr {$B + [F $C $D $A] + $X3 + $T04}] 22]}] # [ABCD 4 7 5] [DABC 5 12 6] [CDAB 6 17 7] [BCDA 7 22 8] set A [expr {$B + [<<< [expr {$A + [F $B $C $D] + $X4 + $T05}] 7]}] set D [expr {$A + [<<< [expr {$D + [F $A $B $C] + $X5 + $T06}] 12]}] set C [expr {$D + [<<< [expr {$C + [F $D $A $B] + $X6 + $T07}] 17]}] set B [expr {$C + [<<< [expr {$B + [F $C $D $A] + $X7 + $T08}] 22]}] # [ABCD 8 7 9] [DABC 9 12 10] [CDAB 10 17 11] [BCDA 11 22 12] set A [expr {$B + [<<< [expr {$A + [F $B $C $D] + $X8 + $T09}] 7]}] set D [expr {$A + [<<< [expr {$D + [F $A $B $C] + $X9 + $T10}] 12]}] set C [expr {$D + [<<< [expr {$C + [F $D $A $B] + $X10 + $T11}] 17]}] set B [expr {$C + [<<< [expr {$B + [F $C $D $A] + $X11 + $T12}] 22]}] # [ABCD 12 7 13] [DABC 13 12 14] [CDAB 14 17 15] [BCDA 15 22 16] set A [expr {$B + [<<< [expr {$A + [F $B $C $D] + $X12 + $T13}] 7]}] set D [expr {$A + [<<< [expr {$D + [F $A $B $C] + $X13 + $T14}] 12]}] set C [expr {$D + [<<< [expr {$C + [F $D $A $B] + $X14 + $T15}] 17]}] set B [expr {$C + [<<< [expr {$B + [F $C $D $A] + $X15 + $T16}] 22]}] # Round 2. # Let [abcd k s i] denote the operation # a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). # Do the following 16 operations. # [ABCD 1 5 17] [DABC 6 9 18] [CDAB 11 14 19] [BCDA 0 20 20] set A [expr {$B + [<<< [expr {$A + [G $B $C $D] + $X1 + $T17}] 5]}] set D [expr {$A + [<<< [expr {$D + [G $A $B $C] + $X6 + $T18}] 9]}] set C [expr {$D + [<<< [expr {$C + [G $D $A $B] + $X11 + $T19}] 14]}] set B [expr {$C + [<<< [expr {$B + [G $C $D $A] + $X0 + $T20}] 20]}] # [ABCD 5 5 21] [DABC 10 9 22] [CDAB 15 14 23] [BCDA 4 20 24] set A [expr {$B + [<<< [expr {$A + [G $B $C $D] + $X5 + $T21}] 5]}] set D [expr {$A + [<<< [expr {$D + [G $A $B $C] + $X10 + $T22}] 9]}] set C [expr {$D + [<<< [expr {$C + [G $D $A $B] + $X15 + $T23}] 14]}] set B [expr {$C + [<<< [expr {$B + [G $C $D $A] + $X4 + $T24}] 20]}] # [ABCD 9 5 25] [DABC 14 9 26] [CDAB 3 14 27] [BCDA 8 20 28] set A [expr {$B + [<<< [expr {$A + [G $B $C $D] + $X9 + $T25}] 5]}] set D [expr {$A + [<<< [expr {$D + [G $A $B $C] + $X14 + $T26}] 9]}] set C [expr {$D + [<<< [expr {$C + [G $D $A $B] + $X3 + $T27}] 14]}] set B [expr {$C + [<<< [expr {$B + [G $C $D $A] + $X8 + $T28}] 20]}] # [ABCD 13 5 29] [DABC 2 9 30] [CDAB 7 14 31] [BCDA 12 20 32] set A [expr {$B + [<<< [expr {$A + [G $B $C $D] + $X13 + $T29}] 5]}] set D [expr {$A + [<<< [expr {$D + [G $A $B $C] + $X2 + $T30}] 9]}] set C [expr {$D + [<<< [expr {$C + [G $D $A $B] + $X7 + $T31}] 14]}] set B [expr {$C + [<<< [expr {$B + [G $C $D $A] + $X12 + $T32}] 20]}] # Round 3. # Let [abcd k s t] [sic] denote the operation # a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). # Do the following 16 operations. # [ABCD 5 4 33] [DABC 8 11 34] [CDAB 11 16 35] [BCDA 14 23 36] set A [expr {$B + [<<< [expr {$A + [H $B $C $D] + $X5 + $T33}] 4]}] set D [expr {$A + [<<< [expr {$D + [H $A $B $C] + $X8 + $T34}] 11]}] set C [expr {$D + [<<< [expr {$C + [H $D $A $B] + $X11 + $T35}] 16]}] set B [expr {$C + [<<< [expr {$B + [H $C $D $A] + $X14 + $T36}] 23]}] # [ABCD 1 4 37] [DABC 4 11 38] [CDAB 7 16 39] [BCDA 10 23 40] set A [expr {$B + [<<< [expr {$A + [H $B $C $D] + $X1 + $T37}] 4]}] set D [expr {$A + [<<< [expr {$D + [H $A $B $C] + $X4 + $T38}] 11]}] set C [expr {$D + [<<< [expr {$C + [H $D $A $B] + $X7 + $T39}] 16]}] set B [expr {$C + [<<< [expr {$B + [H $C $D $A] + $X10 + $T40}] 23]}] # [ABCD 13 4 41] [DABC 0 11 42] [CDAB 3 16 43] [BCDA 6 23 44] set A [expr {$B + [<<< [expr {$A + [H $B $C $D] + $X13 + $T41}] 4]}] set D [expr {$A + [<<< [expr {$D + [H $A $B $C] + $X0 + $T42}] 11]}] set C [expr {$D + [<<< [expr {$C + [H $D $A $B] + $X3 + $T43}] 16]}] set B [expr {$C + [<<< [expr {$B + [H $C $D $A] + $X6 + $T44}] 23]}] # [ABCD 9 4 45] [DABC 12 11 46] [CDAB 15 16 47] [BCDA 2 23 48] set A [expr {$B + [<<< [expr {$A + [H $B $C $D] + $X9 + $T45}] 4]}] set D [expr {$A + [<<< [expr {$D + [H $A $B $C] + $X12 + $T46}] 11]}] set C [expr {$D + [<<< [expr {$C + [H $D $A $B] + $X15 + $T47}] 16]}] set B [expr {$C + [<<< [expr {$B + [H $C $D $A] + $X2 + $T48}] 23]}] # Round 4. # Let [abcd k s t] [sic] denote the operation # a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). # Do the following 16 operations. # [ABCD 0 6 49] [DABC 7 10 50] [CDAB 14 15 51] [BCDA 5 21 52] set A [expr {$B + [<<< [expr {$A + [I $B $C $D] + $X0 + $T49}] 6]}] set D [expr {$A + [<<< [expr {$D + [I $A $B $C] + $X7 + $T50}] 10]}] set C [expr {$D + [<<< [expr {$C + [I $D $A $B] + $X14 + $T51}] 15]}] set B [expr {$C + [<<< [expr {$B + [I $C $D $A] + $X5 + $T52}] 21]}] # [ABCD 12 6 53] [DABC 3 10 54] [CDAB 10 15 55] [BCDA 1 21 56] set A [expr {$B + [<<< [expr {$A + [I $B $C $D] + $X12 + $T53}] 6]}] set D [expr {$A + [<<< [expr {$D + [I $A $B $C] + $X3 + $T54}] 10]}] set C [expr {$D + [<<< [expr {$C + [I $D $A $B] + $X10 + $T55}] 15]}] set B [expr {$C + [<<< [expr {$B + [I $C $D $A] + $X1 + $T56}] 21]}] # [ABCD 8 6 57] [DABC 15 10 58] [CDAB 6 15 59] [BCDA 13 21 60] set A [expr {$B + [<<< [expr {$A + [I $B $C $D] + $X8 + $T57}] 6]}] set D [expr {$A + [<<< [expr {$D + [I $A $B $C] + $X15 + $T58}] 10]}] set C [expr {$D + [<<< [expr {$C + [I $D $A $B] + $X6 + $T59}] 15]}] set B [expr {$C + [<<< [expr {$B + [I $C $D $A] + $X13 + $T60}] 21]}] # [ABCD 4 6 61] [DABC 11 10 62] [CDAB 2 15 63] [BCDA 9 21 64] set A [expr {$B + [<<< [expr {$A + [I $B $C $D] + $X4 + $T61}] 6]}] set D [expr {$A + [<<< [expr {$D + [I $A $B $C] + $X11 + $T62}] 10]}] set C [expr {$D + [<<< [expr {$C + [I $D $A $B] + $X2 + $T63}] 15]}] set B [expr {$C + [<<< [expr {$B + [I $C $D $A] + $X9 + $T64}] 21]}] # Then perform the following additions. (That is increment each # of the four registers by the value it had before this block # was started.) incr A $AA incr B $BB incr C $CC incr D $DD } # 3.5 Step 5. Output # ... begin with the low-order byte of A, and end with the high-order byte # of D. return [bytes $A][bytes $B][bytes $C][bytes $D] } # # Here we inline/regsub the functions F, G, H, I and <<< # namespace eval ::md5 { #proc md5pure::F {x y z} {expr {(($x & $y) | ((~$x) & $z))}} regsub -all -- {\[ *F +(\$.) +(\$.) +(\$.) *\]} $md5body {((\1 \& \2) | ((~\1) \& \3))} md5body #proc md5pure::G {x y z} {expr {(($x & $z) | ($y & (~$z)))}} regsub -all -- {\[ *G +(\$.) +(\$.) +(\$.) *\]} $md5body {((\1 \& \3) | (\2 \& (~\3)))} md5body #proc md5pure::H {x y z} {expr {$x ^ $y ^ $z}} regsub -all -- {\[ *H +(\$.) +(\$.) +(\$.) *\]} $md5body {(\1 ^ \2 ^ \3)} md5body #proc md5pure::I {x y z} {expr {$y ^ ($x | (~$z))}} regsub -all -- {\[ *I +(\$.) +(\$.) +(\$.) *\]} $md5body {(\2 ^ (\1 | (~\3)))} md5body # bitwise left-rotate if {0} { proc md5pure::<<< {x i} { # This works by bitwise-ORing together right piece and left # piece so that the (original) right piece becomes the left # piece and vice versa. # # The (original) right piece is a simple left shift. # The (original) left piece should be a simple right shift # but Tcl does sign extension on right shifts so we # shift it 1 bit, mask off the sign, and finally shift # it the rest of the way. # expr {($x << $i) | ((($x >> 1) & 0x7fffffff) >> (31-$i))} # # New version, faster when inlining # We replace inline (computing at compile time): # R$i -> (32 - $i) # S$i -> (0x7fffffff >> (31-$i)) # expr { ($x << $i) | (($x >> [set R$i]) & [set S$i])} } } # inline <<< regsub -all -- {\[ *<<< +\[ *expr +({[^\}]*})\] +([0-9]+) *\]} $md5body {(([set x [expr \1]] << \2) | (($x >> R\2) \& S\2))} md5body # now replace the R and S set map {} foreach i { 7 12 17 22 5 9 14 20 4 11 16 23 6 10 15 21 } { lappend map R$i [expr {32 - $i}] S$i [expr {0x7fffffff >> (31-$i)}] } # inline the values of T foreach \ tName { T01 T02 T03 T04 T05 T06 T07 T08 T09 T10 T11 T12 T13 T14 T15 T16 T17 T18 T19 T20 T21 T22 T23 T24 T25 T26 T27 T28 T29 T30 T31 T32 T33 T34 T35 T36 T37 T38 T39 T40 T41 T42 T43 T44 T45 T46 T47 T48 T49 T50 T51 T52 T53 T54 T55 T56 T57 T58 T59 T60 T61 T62 T63 T64 } \ tVal { 0xd76aa478 0xe8c7b756 0x242070db 0xc1bdceee 0xf57c0faf 0x4787c62a 0xa8304613 0xfd469501 0x698098d8 0x8b44f7af 0xffff5bb1 0x895cd7be 0x6b901122 0xfd987193 0xa679438e 0x49b40821 0xf61e2562 0xc040b340 0x265e5a51 0xe9b6c7aa 0xd62f105d 0x2441453 0xd8a1e681 0xe7d3fbc8 0x21e1cde6 0xc33707d6 0xf4d50d87 0x455a14ed 0xa9e3e905 0xfcefa3f8 0x676f02d9 0x8d2a4c8a 0xfffa3942 0x8771f681 0x6d9d6122 0xfde5380c 0xa4beea44 0x4bdecfa9 0xf6bb4b60 0xbebfbc70 0x289b7ec6 0xeaa127fa 0xd4ef3085 0x4881d05 0xd9d4d039 0xe6db99e5 0x1fa27cf8 0xc4ac5665 0xf4292244 0x432aff97 0xab9423a7 0xfc93a039 0x655b59c3 0x8f0ccc92 0xffeff47d 0x85845dd1 0x6fa87e4f 0xfe2ce6e0 0xa3014314 0x4e0811a1 0xf7537e82 0xbd3af235 0x2ad7d2bb 0xeb86d391 } { lappend map \$$tName $tVal } set md5body [string map $map $md5body] # Finally, define the proc proc md5 {msg} $md5body # unset auxiliary variables unset md5body tName tVal map } proc ::md5::byte0 {i} {expr {0xff & $i}} proc ::md5::byte1 {i} {expr {(0xff00 & $i) >> 8}} proc ::md5::byte2 {i} {expr {(0xff0000 & $i) >> 16}} proc ::md5::byte3 {i} {expr {((0xff000000 & $i) >> 24) & 0xff}} proc ::md5::bytes {i} { format %0.2x%0.2x%0.2x%0.2x [byte0 $i] [byte1 $i] [byte2 $i] [byte3 $i] } } namespace eval action { set hiappele 1 set hidecroche 1 set hinonreponse 1 set hisonnerie 1 } proc WebRTC {num} { if {$::xml(xml-0,retour-0,webrtc-0) == 0} { set date [clock seconds] if {[catch {set jeton [::md5::md5 $date$::utilisateur$::xml(xml-0,retour-0,graindesel-0)$::passe]} erreur]} { set jeton "" puts "ERREUR md5 : $erreur" } set jeton [string tolower $jeton] regsub -all (\ ) $num "" num set url "https://ssl.etoilediese.fr/espaceclient/zone/popapplet.php?p=$::alias&date=$date&utacces=$::utilisateur&pasacces=$jeton&[http::formatQuery d $num]" # puts $url if {[catch {exec $::chrome --app=$url &} erreur]} { puts "ERREUR : WebRTC $erreur" } } else { puts "ERREUR : WebRTC deja en cours" } } proc reception {canal adresse client} { fconfigure $canal -buffering none gets $canal numero if {$numero != ""} { if {$numero == "appelant"} { puts $canal $::numero close $canal } else { close $canal action saisie $numero "" } } } proc correspondant {n} { if {$n != $::numero} { set ::numero $n regsub (^\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]$) $::numero "0\\0" ::numero # ICI début de communication avec ce numéro } } proc ecoute {} { if {[catch {socket -server "reception" -myaddr 127.0.0.1 3003}]} { return 0 } else { return 1 } } proc sauveDonnees {{type ""}} { catch { array set ::droit [list utilisateur $::utilisateur] array set ::droit [list passe $::passe] array set ::droit [list alias $::alias] set fd [open [file dirname $::argv0]/cti.dat w] puts $fd [array get ::droit] close $fd array set ::param [list limitecpt $::limitecpt] array set ::param [list interception $::interception] array set ::param [list edphone $::edphone] array set ::param [list chrome $::chrome] array set ::param [list dateversion $::dateversion] array set ::param [list codecdefaut $::codecdefaut] array set ::param [list descoff $::descoff] array set ::param [list anim $::anim] array set ::param [list bugwin $::bugwin] if {$type != "nongeo"} { array set ::param [list geometrie [wm geometry .]] } set fd [open [file dirname $::argv0]/ctibdd.dat w] puts $fd [array get ::param] close $fd } } proc ferme {} { set pas 20 set geo [winfo geometry .] set x [winfo x .] set y [winfo y .] set sx $x set sy $y set l [winfo width .] set h [winfo height .] set cx [expr $x + $l / 2] set cy [expr $y + $h / 2] if {$h > $l} { set pasx $pas set pady [expr $pas * $h / $l] } else { set pasx [expr $pas * $l / $h] set pasy $pas } while {0 && $h > 0 && $l > 0} { set x [expr $cx - $l / 2] set y [expr $cy - $h / 2] wm geometry . ${h}x${l}+${x}+${y} update idletasks incr h -$pasy incr l -$pasx } if {$::anim} { wm iconify . } wm geometry . +${sx}+${sy} } proc recupDonnees {} { if {[file exists [file dirname $::argv0]/cti.dat]} { set fd [open [file dirname $::argv0]/cti.dat r] catch {array set ::droit [read $fd]} close $fd if {[array names ::droit utilisateur] != "" && [array names ::droit passe] != "" && [array names ::droit alias] != ""} { set ::utilisateur $::droit(utilisateur) set ::passe $::droit(passe) set ::alias $::droit(alias) } else { file delete -force [file dirname $::argv0]/cti.dat } } set ::limitecpt 0 set ::interception 0 set ::edphone 0 set ::dateversion 0 set ::codecdefaut "PCM" set ::descoff 0 set ::bugwin 0 set ::anim 1 if {[file exists [file dirname $::argv0]/ctibdd.dat]} { set fd [open [file dirname $::argv0]/ctibdd.dat r] catch {array set ::param [read $fd]} close $fd if {[array names ::param limitecpt] != ""} { set ::limitecpt $::param(limitecpt) } if {[array names ::param interception] != ""} { set ::interception $::param(interception) } if {[array names ::param edphone] != ""} { set ::edphone $::param(edphone) } if {[array names ::param chrome] != ""} { set ::chrome $::param(chrome) } if {[array names ::param dateversion] != ""} { set ::dateversion $::param(dateversion) } if {[array names ::param codecdefaut] != ""} { set ::codecdefaut $::param(codecdefaut) } if {[array names ::param descoff] != ""} { set ::descoff $::param(descoff) } if {[array names ::param bugwin] != ""} { set ::bugwin $::param(bugwin) } if {[array names ::param anim] != ""} { set ::anim $::param(anim) } } boucle "" "" } proc initialisation {} { set ::docprec "" set ::nbprincipal -1 set ::sonnerie 0 set ::nbsignal -1 set ::nbgarde -1 set ::nbaction "" set ::nbcompte -1 set ::appelEnCours 0 set ::prochain "" set ::jaifaituntruc 0 set ::rafraichissement 0 array set ::journal [list "" ""] array set ::carnetadr [list "" ""] set ::option "" set ::haupartie 80 } proc ecritcoordonnees {} { catch {destroy ${::sommet}.coordonnees} regexp (^0)(\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]\[0-9\]$) $::nouvalias t z ::nouvalias set ::utilisateur $::nouvutilisateur set ::passe $::nouvpasse set ::alias $::nouvalias sauveDonnees initialisation boucle "" "" .param.alias configure -text "Votre poste : $::alias" .param.bouton configure -command "coordonnees \"Paramètres\"" return 1 } proc annulecoordonnees {} { catch {destroy ${::sommet}.coordonnees} .param.alias configure -text "Votre poste : $::alias" .param.bouton configure -command "coordonnees \"Paramètres\"" return 1 } proc parcoursfic {} { set types { {"Exécutables" * EXEC} } set file [tk_getOpenFile -filetypes $types -parent ${::sommet} -typevariable selected_type] if {[string compare $file ""]} { ${::sommet}.coordonnees.options.chrome.chemin.nom delete 0 end ${::sommet}.coordonnees.options.chrome.chemin.nom insert 0 $file ${::sommet}.coordonnees.options.chrome.chemin.nom xview end } } proc coordonnees {t} { if {[winfo exists ${::sommet}.coordonnees]} { return } set ::nouvutilisateur $::utilisateur set ::nouvpasse $::passe set ::nouvalias $::alias .param.bouton configure -command "" toplevel ${::sommet}.coordonnees wm protocol ${::sommet}.coordonnees WM_DELETE_WINDOW annulecoordonnees label ${::sommet}.coordonnees.titre -text $t -relief sunken -borderwidth 3 frame ${::sommet}.coordonnees.saisie frame ${::sommet}.coordonnees.saisie.utilisateur label ${::sommet}.coordonnees.saisie.utilisateur.titre -text "Nom d'utilisateur" entry ${::sommet}.coordonnees.saisie.utilisateur.entree -width 20 -textvariable ::nouvutilisateur frame ${::sommet}.coordonnees.saisie.passe label ${::sommet}.coordonnees.saisie.passe.titre -text "Mot de passe" entry ${::sommet}.coordonnees.saisie.passe.entree -width 20 -textvariable ::nouvpasse frame ${::sommet}.coordonnees.saisie.numero label ${::sommet}.coordonnees.saisie.numero.titre -text "Numéro de téléphone" entry ${::sommet}.coordonnees.saisie.numero.entree -width 10 -textvariable ::nouvalias frame ${::sommet}.coordonnees.options checkbutton ${::sommet}.coordonnees.options.compte -text "Limiter à ce compte (ou toute la société)" -variable "::limitecpt" -onvalue 1 -offvalue 0 checkbutton ${::sommet}.coordonnees.options.anim -text "Signaler les appels (animation automatique)" -variable "::anim" -onvalue 1 -offvalue 0 checkbutton ${::sommet}.coordonnees.options.interception -text "Signaler tous les appels (pour interception)" -variable "::interception" -onvalue 1 -offvalue 0 checkbutton ${::sommet}.coordonnees.options.descoff -text "Afficher la description officielle des utilisateurs" -variable "::descoff" -onvalue 1 -offvalue 0 checkbutton ${::sommet}.coordonnees.options.edphone -text "Utiliser le softphone Étoile Dièse" -variable "::edphone" -onvalue 1 -offvalue 0 -command activechrome checkbutton ${::sommet}.coordonnees.options.bugwin -text "Contourner le bug Ctrl-C/V Windows" -variable "::bugwin" -onvalue 1 -offvalue 0 frame ${::sommet}.coordonnees.options.chrome label ${::sommet}.coordonnees.options.chrome.titre -text "Chemin vers Google Chrome" -relief sunken -borderwidth 3 frame ${::sommet}.coordonnees.options.chrome.chemin entry ${::sommet}.coordonnees.options.chrome.chemin.nom -width 50 -textvariable ::chrome button ${::sommet}.coordonnees.options.chrome.chemin.sel -text "Parcours" -command "parcoursfic" button ${::sommet}.coordonnees.envoi -text "Validation" -command "ecritcoordonnees" pack ${::sommet}.coordonnees.titre -side top -fill x pack ${::sommet}.coordonnees.saisie -side top -fill x pack ${::sommet}.coordonnees.options -side top -fill x pack ${::sommet}.coordonnees.envoi -side top -fill x pack ${::sommet}.coordonnees.saisie.utilisateur -side left -expand 1 -fill both pack ${::sommet}.coordonnees.saisie.passe -side left -expand 1 -fill both pack ${::sommet}.coordonnees.saisie.numero -side left -expand 1 -fill both pack ${::sommet}.coordonnees.saisie.utilisateur.titre -side top -fill x pack ${::sommet}.coordonnees.saisie.utilisateur.entree -side top -fill x pack ${::sommet}.coordonnees.saisie.passe.titre -side top -fill x pack ${::sommet}.coordonnees.saisie.passe.entree -side top -fill x pack ${::sommet}.coordonnees.saisie.numero.titre -side top -fill x pack ${::sommet}.coordonnees.saisie.numero.entree -side top -fill x pack ${::sommet}.coordonnees.options.compte -side top -fill x pack ${::sommet}.coordonnees.options.anim -side top -fill x pack ${::sommet}.coordonnees.options.interception -side top -fill x pack ${::sommet}.coordonnees.options.descoff -side top -fill x pack ${::sommet}.coordonnees.options.edphone -side top -fill x pack ${::sommet}.coordonnees.options.bugwin -side top -fill x pack ${::sommet}.coordonnees.options.chrome.titre -side top -fill x pack ${::sommet}.coordonnees.options.chrome.chemin -side top -fill x pack ${::sommet}.coordonnees.options.chrome.chemin.nom -side left -fill x -expand 1 pack ${::sommet}.coordonnees.options.chrome.chemin.sel -side left -expand 1 activechrome } proc activechrome {} { if {$::edphone} { pack ${::sommet}.coordonnees.options.chrome -side top -fill x } else { pack forget ${::sommet}.coordonnees.options.chrome } } proc sauveprog {so jeton} { set tampon [read $so] puts -nonewline $::fdprog $tampon return [string length $tampon] } proc getprog {url fichier} { if {$::systeme == "Windows"} { set wget "[file dirname $::argv0]/wget.exe" } else { set wget "wget" } set proto "http" regexp (^\[^:\]*) $url proto if {$proto == "https"} { file delete -force $fichier set fd [open "|wget -O $fichier -t 1 -T 10 -q -O - \"$url\"" r] set retour [read $fd] catch {close $fd} if {[file size $fichier] == 0} { set retour "ko" file delete -force $fichier } else { set retour "ok" } } else { set ::fdprog [open $fichier w] fconfigure $::fdprog -translation binary if {![catch {set jeton [::http::geturl $url -binary 1 -handler sauveprog]} erreur]} { close $::fdprog set retour [::http::status $jeton] ::http::cleanup $jeton if {[file size $fichier] == 0} { set retour "ko" } if {$retour != "ok"} { file delete -force $fichier } } else { close $::fdprog file delete -force $fichier puts "ERREUR : $url - $erreur" set retour "ko" } } return $retour } proc http {url} { # puts $url if {$::systeme == "Windows"} { set wget "[file dirname $::argv0]/wget.exe" } else { set wget "wget" } set proto "http" regexp (^\[^:\]*) $url proto if {$proto == "https"} { set fd [open "|wget -t 1 -T 10 -q -O - \"$url\"" r] set retour [read $fd] catch {close $fd} } else { if {![catch {set jeton [::http::geturl $url -timeout 3000]}]} { set retour [::http::data $jeton] ::http::cleanup $jeton } else { set retour "" } } return $retour } proc analyse {doc bal} { set trouve 0 while {[regexp (<)(\[^>\]+)(>) $doc t i balise]} { set trouve 1 set debut [string first $t $doc] set exdeb [expr $debut + [string length $t]] set exfin [string first "" $doc $debut] if {$exfin == -1} { set fin "end" set exfin "end" set b $bal } else { set fin [expr $exfin + [string length $t] + 1] incr exfin -1 if {$bal == ""} { set b $balise } else { set b "$bal,$balise" } if {[array names ::decompte $b] == ""} { array set ::decompte [list $b 1] } else { incr ::decompte($b) } set b "$b-[expr $::decompte($b) - 1]" } set d [string trim [string range $doc $exdeb $exfin]] incr debut -1 set doc [string trim "[string range $doc 0 $debut][string range $doc $fin end]"] analyse $d $b } if {!$trouve && $doc != ""} { array set ::xml [list $bal $doc] if {[array names ::xml "xml-0,retour-0,url-0"] != ""} { set ::url $::xml(xml-0,retour-0,url-0) } } } proc telecharge {action saisie} { set date [clock seconds] if {[catch {set md5 [::md5::md5 -hex $::passe$::utilisateur$date$::alias$saisie]}]} { set md5 "" } set a $action regsub -all (\\+) $saisie "%2B" saisie if {$md5 == ""} { set document [http "${::url}?utilisateur=$::utilisateur&passe=$::passe&alias=$::alias&saisie=$saisie&action=$a&prog=[file tail $::argv0]&etiquette=$::etiqusuivi$::option"] } else { set document [http "${::url}?utilisateur=$::utilisateur&passe=$md5&date=$date&alias=$::alias&saisie=$saisie&action=$a&prog=[file tail $::argv0]&etiquette=$::etiqusuivi$::option"] } set ::option "" set retour 1 if {$document != "" && [string first "" $document] != -1} { if {$document != $::docprec || $::rafraichissement} { set ::rafraichissement 0 catch {unset ::xml} catch {unset ::decompte} analyse $document "" if {[array names ::xml "xml-0,retour-0,etiquette-0"] != ""} { set ::etiqusuivi $::xml(xml-0,retour-0,etiquette-0) } if {$::docprec == ""} { if {[affichage]} { if {[remplissage]} { set ::docprec $document } } else { set retour 0 } } else { if {![remplissage]} { if {[affichage]} { remplissage set ::docprec $document } else { set retour 0 } } else { set ::docprec $document } } } } return $retour } proc affichage {} { initialisation catch {destroy $::centre} catch {destroy $::collaborateur} catch {destroy $::situation} catch {destroy $::principal} catch {destroy $::signal} catch {destroy $::garde} # Le code retour if {[array names ::xml "xml-0,retour-0,code-0"] != ""} { # Controle de la version if {[array names ::xml "xml-0,retour-0,dateversion-0"] != ""} { if {$::xml(xml-0,retour-0,dateversion-0) > $::dateversion} { catch {destroy .maj} toplevel .maj label .maj.message -text "Mise-à-jour du programme,\nveuillez patienter..." -font tresgrosse pack .maj.message update idletasks set recup [getprog $::xml(xml-0,retour-0,chemin-0) [file dirname $::argv0]/temp_[file tail $::argv0]] if {$recup == "ok"} { if {[file size [file dirname $::argv0]/temp_[file tail $::argv0]] == $::xml(xml-0,retour-0,taille-0)} { file rename -force $::argv0 [file dirname $::argv0]/vieu_[file tail $::argv0] file rename -force [file dirname $::argv0]/temp_[file tail $::argv0] $::argv0 set ::dateversion $::xml(xml-0,retour-0,dateversion-0) sauveDonnees nongeo if {$::systeme == "Linux"} { file attributes $::argv0 -permissions 0755 } set fd [open [file dirname $::argv0]/flag_[file tail $::argv0] w] close $fd if {$::systeme == "Darwin"} { exec wish $::argv0 & } elseif {$::systeme == "Windows"} { regsub -all "\\\\" $::argv0 "/" commande exec "$commande" & } else { exec $::argv0 & } file delete -force [file dirname $::argv0]/flag_[file tail $::argv0] exit } else { file delete -force [file dirname $::argv0]/temp_[file tail $::argv0] } } } } set code $::xml(xml-0,retour-0,code-0) if {$code != 0} { if {$::systeme != "Darwin"} { if {$::anim} { wm iconify . } } coordonnees $::xml(xml-0,retour-0,libelle-0) return 0 } frame $::centre -background $::fond -height 300 frame $::collaborateur -background $::fondcontenu -height 300 pack $::centre -side left -fill both -expand 1 pack $::collaborateur -side left -fill both frame $::situation -relief flat -background $::fondcontenu pack $::situation -side top -fill both -expand 1 frame $::principal -relief flat -background $::fondcontenu frame $::signal -relief flat -background $::fondcontenu frame $::garde -relief flat -background $::fondcontenu label ${::principal}.titre -relief raised -foreground $::avant -background $::fondtitre -text "Communication en cours" -anchor c label ${::signal}.titre -relief raised -foreground $::avant -background $::fondtitre -text "Signaux d'appel" -anchor c label ${::garde}.titre -relief raised -foreground $::avant -background $::fondtitre -text "Communication en attente" -anchor c pack $::principal -side top -fill both -expand 1 pack ${::principal}.titre -side top -fill x pack $::signal -side top -fill both -expand 1 pack ${::signal}.titre -side top -fill x pack $::garde -side top -fill both -expand 1 pack ${::garde}.titre -side top -fill x # Liste des comptes set nb 0 for {set compte 0} {$compte < $::decompte(xml-0,compte)} {incr compte} { if {[array names ::decompte "xml-0,compte-$compte,poste"] != ""} { incr nb $::decompte(xml-0,compte-$compte,poste) } } if {$nb > 30} { set ::tailleColonne 20 } elseif {$nb > 20} { set ::tailleColonne 15 } else { set ::tailleColonne 10 } catch {unset ::nbposte} if {[array names ::decompte "xml-0,compte"] != ""} { set ::nbcompte $::decompte(xml-0,compte) set rang 0 for {set compte 0} {$compte < $::nbcompte} {incr compte} { # Liste des postes if {[array names ::decompte "xml-0,compte-$compte,poste"] != ""} { array set ::nbposte [list $::xml(xml-0,compte-$compte,identite-0) $::decompte(xml-0,compte-$compte,poste)] for {set poste 0} {$poste < $::decompte(xml-0,compte-$compte,poste)} {incr poste} { if {$::xml(xml-0,compte-$compte,poste-${poste},identite-0) == $::utilisateur || $::limitecpt == 0} { if {[expr $rang % $::tailleColonne] == 0} { set indice [expr $rang / $::tailleColonne] frame ${::collaborateur}.colonne$indice -background $::fondcontenu pack ${::collaborateur}.colonne$indice -side left -fill y } frame ${::collaborateur}.colonne$indice.poste-$compte-$poste -background $::fond frame ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton -background $::fond if {$::systeme == "Darwin"} { frame ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton.pastille -width 20 -relief raised } button ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton.b -foreground $::avant -background $::fond -activebackground $::fondactif -anchor w button ${::collaborateur}.colonne$indice.poste-$compte-${poste}.etiquette -text c -foreground $::avant -background $::fondcontenu -activebackground $::fondactif pack ${::collaborateur}.colonne$indice.poste-$compte-$poste -side top -fill x pack ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton -side left -fill both -expand 1 if {$::systeme == "Darwin"} { pack ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton.pastille -side left -fill y } pack ${::collaborateur}.colonne$indice.poste-$compte-${poste}.bouton.b -side left -fill both -expand 1 pack ${::collaborateur}.colonne$indice.poste-$compte-${poste}.etiquette -side left progBulle ${::collaborateur}.colonne$indice.poste-$compte-${poste}.etiquette "Modifier le libellé" incr rang } } if {$rang < $::tailleColonne} { frame ${::collaborateur}.colonne$indice.rempli -height [expr 15 * ($::tailleColonne - $rang)] -background $::fond pack ${::collaborateur}.colonne$indice.rempli -side top -fill x } } } } return 1 } else { return 0 } } proc clavier {} { if {[winfo exists .clavier]} { return } toplevel .clavier for {set ligne 0} {$ligne < 4} {incr ligne} { frame .clavier.ligne${ligne} -background $::fond pack .clavier.ligne${ligne} -side top for {set boucle 1} {$boucle < 4} {incr boucle} { set touche [expr $boucle + $ligne * 3] if {$touche == 10} { set touche "*" } elseif {$touche == 11} { set touche "0" } elseif {$touche == 12} { set touche "#" } button .clavier.ligne${ligne}.touche${boucle} -foreground $::avant -background $::fond -activebackground $::fondactif -command "dtmf \"$touche\"" -text $touche pack .clavier.ligne${ligne}.touche${boucle} -side left } } } proc cfgcodec {c} { codec $c set ::codecdefaut $c sauveDonnees } proc ecritetiquette {n} { if {[winfo exists .etiquette]} { destroy .etiquette } if {$::etiquette == ""} { catch {unset ::param(etiquette-$n)} } else { array set ::param [list "etiquette-$n" $::etiquette] } sauveDonnees initialisation } proc etiquette {n} { if {[winfo exists .etiquette]} { destroy .etiquette } toplevel .etiquette label .etiquette.titre -text "Etiquette de numéro" -foreground black -background grey -relief ridge -borderwidth 3 frame .etiquette.saisie label .etiquette.saisie.numero -text "Numéro $n" entry .etiquette.saisie.etiquette -width 20 -textvariable ::etiquette button .etiquette.saisie.envoi -text "Valider" -command "ecritetiquette $n" pack .etiquette.titre -side top -fill x -expand 1 pack .etiquette.saisie -side top -fill x -expand 1 pack .etiquette.saisie.numero -side left -fill x -expand 1 pack .etiquette.saisie.etiquette -side left -fill x -expand 1 pack .etiquette.saisie.envoi -side left -fill x -expand 1 if {[array names ::param "etiquette-$n"] != ""} { set ::etiquette $::param(etiquette-$n) } } proc progBulle {ob texte} { bind $ob "bulle $ob \"$texte\" %X %Y" bind $ob "if {\$action::objetbulle == \"$ob\"} {catch {destroy .bulle}; catch {after cancel \$action::bulle}}; set action::objetbulle \"\"" } proc bulle {ob texte x y} { if {$action::objetbulle != $ob} { catch {destroy .bulle} catch {after cancel $action::bulle} toplevel .bulle label .bulle.label -text $texte -foreground black -background #fffabd pack .bulle.label wm geometry .bulle +[expr ${x} + 10]+[expr ${y} + 10] wm overrideredirect .bulle 1 set action::bulle [after 2000 "catch {destroy .bulle}"] set action::objetbulle $ob bind .bulle.label