source: extensions/CryptograPHP/cryptographp/cryptographp.fct.php @ 11375

Last change on this file since 11375 was 10837, checked in by mistic100, 13 years ago

first version of CryptograPHP

File size: 1.7 KB
Line 
1<?php
2
3// -----------------------------------------------
4// Cryptographp v1.4
5// (c) 2006-2007 Sylvain BRISON
6//
7// www.cryptographp.com
8// cryptographp@alphpa.com
9//
10// Licence CeCILL modifiée
11// => Voir fichier Licence_CeCILL_V2-fr.txt)
12// -----------------------------------------------
13
14 //if(session_id() == "") session_start();
15 
16 pwg_set_session_var('cryptdir', dirname($cryptinstall));
17 
18 
19 function dsp_crypt($cfg=0,$reload=1) {
20 // Affiche le cryptogramme
21 $dir = pwg_get_session_var('cryptdir');
22 $out = "<img id='cryptogram' src='".$dir."/cryptographp.php?cfg=".$cfg."&".SID."'>";
23 if ($reload) $out .= "&nbsp;<a title='".($reload==1?'':$reload)."' style=\"cursor:pointer;vertical-align:top;\" onclick=\"javascript:document.images.cryptogram.src='".$dir."/cryptographp.php?cfg=".$cfg."&".SID."&'+Math.round(Math.random(0)*1000)+1\"><img src=\"".$dir."/images/reload.png\"></a>";
24 return $out;
25 }
26
27
28 function chk_crypt($code) {
29 // Vérifie si le code est correct
30 include (pwg_get_session_var('configfile'));
31 $code = addslashes ($code);
32 $code = str_replace(' ','',$code);  // supprime les espaces saisis par erreur.
33 $code = ($difuplow?$code:strtoupper($code));
34 switch (strtoupper($cryptsecure)) {   
35        case "MD5"  : $code = md5($code); break;
36        case "SHA1" : $code = sha1($code); break;
37        }
38 if (pwg_get_session_var('cryptcode') and (pwg_get_session_var('cryptcode') == $code))
39    {
40    pwg_unset_session_var('cryptreload');
41    if ($cryptoneuse) pwg_unset_session_var('cryptcode');   
42    return true;
43    }
44    else {
45         pwg_set_session_var('cryptreload', true);
46         return false;
47         }
48 }
49
50?>
Note: See TracBrowser for help on using the repository browser.