1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-03 19:57:57 +02:00

Update plugins/captcha/crypt/cryptographp.inc.php

This commit is contained in:
Sergey Romaneko
2012-09-26 14:32:19 +03:00
parent b27ccc0cac
commit 4740a939aa

View File

@@ -21,12 +21,11 @@ if ($_GET[$_GET['sn']] == "") { unset ($_GET['sn']); }
session_start(); session_start();
// N'accepte que les fichiers de config du meme r?pertoire // Takes only the configuration files in the same directory
if (is_file($_GET['cfg']) and dirname($_GET['cfg']) == '.' ) { $_SESSION['configfile']=$_GET['cfg']; } else { $_SESSION['configfile'] = "cryptographp.cfg.php"; } if (is_file($_GET['cfg']) and dirname($_GET['cfg']) == '.' ) { $_SESSION['configfile']=$_GET['cfg']; } else { $_SESSION['configfile'] = "cryptographp.cfg.php"; }
include($_SESSION['configfile']); include($_SESSION['configfile']);
// V?rifie si l'utilisateur a le droit de (re)g?n?rer un cryptogramme
if ($_SESSION['cryptcptuse'] >= $cryptusemax) { if ($_SESSION['cryptcptuse'] >= $cryptusemax) {
header("Content-type: image/png"); header("Content-type: image/png");
readfile('images/erreur1.png'); readfile('images/erreur1.png');
@@ -46,7 +45,7 @@ if ($delai < $cryptusetimer) {
} }
} }
// Cr?ation du cryptogramme temporaire // Create temporary cryptogram
$imgtmp = imagecreatetruecolor($cryptwidth,$cryptheight); $imgtmp = imagecreatetruecolor($cryptwidth,$cryptheight);
$blank = imagecolorallocate($imgtmp,255,255,255); $blank = imagecolorallocate($imgtmp,255,255,255);
$black = imagecolorallocate($imgtmp,0,0,0); $black = imagecolorallocate($imgtmp,0,0,0);
@@ -75,7 +74,7 @@ for ($i=1;$i<= $charnb;$i++) {
$x +=$charspace; $x +=$charspace;
} }
// Calcul du racadrage horizontal du cryptogramme temporaire // Calculation of horizontal framing cryptograms temporary
$xbegin=0; $xbegin=0;
$x=0; $x=0;
while (($x<$cryptwidth)and(!$xbegin)) { while (($x<$cryptwidth)and(!$xbegin)) {
@@ -102,8 +101,7 @@ $xvariation = round(($cryptwidth/2)-(($xend-$xbegin)/2));
imagedestroy ($imgtmp); imagedestroy ($imgtmp);
// Cr?ation du cryptogramme d?finitif // Creating the final cryptogram
// Cr?ation du fond
$img = imagecreatetruecolor($cryptwidth, $cryptheight); $img = imagecreatetruecolor($cryptwidth, $cryptheight);
if ($bgimg and is_dir($bgimg)) { if ($bgimg and is_dir($bgimg)) {
@@ -131,8 +129,7 @@ if ($bgimg) {
function ecriture() { function ecriture() {
// Cr?ation de l'?criture
global $img, $ink, $charR, $charG, $charB, $charclear, $xvariation, $charnb, $charcolorrnd, $charcolorrndlevel, $tword, $charspace; global $img, $ink, $charR, $charG, $charB, $charclear, $xvariation, $charnb, $charcolorrnd, $charcolorrndlevel, $tword, $charspace;
if (function_exists ('imagecolorallocatealpha')) $ink = imagecolorallocatealpha($img,$charR,$charG,$charB,$charclear); if (function_exists ('imagecolorallocatealpha')) $ink = imagecolorallocatealpha($img,$charR,$charG,$charB,$charclear);
else $ink = imagecolorallocate ($img,$charR,$charG,$charB); else $ink = imagecolorallocate ($img,$charR,$charG,$charB);
@@ -140,7 +137,7 @@ function ecriture() {
$x = $xvariation; $x = $xvariation;
for ($i = 1; $i <= $charnb; $i++) { for ($i = 1; $i <= $charnb; $i++) {
if ($charcolorrnd) { // Choisit des couleurs au hasard if ($charcolorrnd) {
$ok = false; $ok = false;
do { do {
$rndR = rand(0,255); $rndG = rand(0,255); $rndB = rand(0,255); $rndR = rand(0,255); $rndG = rand(0,255); $rndB = rand(0,255);
@@ -204,28 +201,25 @@ if ($noiseup) {
} }
// Cr?ation du cadre // Creating frame
if ($bgframe) { if ($bgframe) {
$framecol = imagecolorallocate($img,($bgR*3+$charR)/4,($bgG*3+$charG)/4,($bgB*3+$charB)/4); $framecol = imagecolorallocate($img,($bgR*3+$charR)/4,($bgG*3+$charG)/4,($bgB*3+$charB)/4);
imagerectangle($img, 0, 0, $cryptwidth-1, $cryptheight-1, $framecol); imagerectangle($img, 0, 0, $cryptwidth-1, $cryptheight-1, $framecol);
} }
// Transformations suppl?mentaires: Grayscale et Brouillage // Additional changes: grayscale and gaussian blur
// V?rifie si la fonction existe dans la version PHP install?e
if (function_exists('imagefilter')) { if (function_exists('imagefilter')) {
if ($cryptgrayscal) imagefilter ( $img, IMG_FILTER_GRAYSCALE); if ($cryptgrayscal) imagefilter ( $img, IMG_FILTER_GRAYSCALE);
if ($cryptgaussianblur) imagefilter ( $img, IMG_FILTER_GAUSSIAN_BLUR); if ($cryptgaussianblur) imagefilter ( $img, IMG_FILTER_GAUSSIAN_BLUR);
} }
// Conversion du cryptogramme en Majuscule si insensibilit? ? la casse // Shift conversion cryptograms
$word = ($difuplow?$word:strtoupper($word)); $word = ($difuplow?$word:strtoupper($word));
// Retourne 2 informations dans la session: // Write cryptcode to the Session
// - Le code du cryptogramme (crypt? ou pas)
// - La Date/Heure de la cr?ation du cryptogramme au format integer "TimeStamp"
switch (strtoupper($cryptsecure)) { switch (strtoupper($cryptsecure)) {
case "MD5" : $_SESSION['cryptcode'] = md5($word); break; case "MD5" : $_SESSION['cryptcode'] = md5($word); break;
case "SHA1" : $_SESSION['cryptcode'] = sha1($word); break; case "SHA1" : $_SESSION['cryptcode'] = sha1($word); break;
@@ -236,7 +230,7 @@ $_SESSION['crypttime'] = time();
$_SESSION['cryptcptuse']++; $_SESSION['cryptcptuse']++;
// Envoi de l'image finale au navigateur // Render image
switch (strtoupper($cryptformat)) { switch (strtoupper($cryptformat)) {
case "JPG" : case "JPG" :
case "JPEG" : if (imagetypes() & IMG_JPG) { case "JPEG" : if (imagetypes() & IMG_JPG) {