Première version publique
[auf_paf.git] / includes / tclyit_cam_pc.php
1 <?php
2 //--Veuillez m'aider pour améliorer cette fonction--et envoyer à tclyit@gmail.com
3 //--------Vos critiques sont bienvenues!!----------------------------------------
4 //----------Encrypt----------------------------
5
6 function tcly($string, $key) {
7 $result = '';
8 for($i=0; $i<strlen($string); $i++){
9 $char = substr($string, $i, 1);
10 $keychar = substr($key, ($i % strlen($key))-1, 1);
11 $char = chr(ord($char)+ord($keychar));
12 $result.=$char;
13 }
14 return base64_encode($result);
15 }
16
17 /*$key1 = "Chhunly";
18 $Se = "1@2!3#^&%()-_+=[{}}|\;:,.Chhunly";
19 $See = encrypt($Se,$key1);
20 echo "Encrypt: ".$See."<br /><br />";*/
21
22 //----------Decrypt----------------------------
23 function bbcsr($string, $key) {
24 $result = '';
25 $string = base64_decode($string);
26
27 for($i=0; $i<strlen($string); $i++){
28 $char = substr($string, $i, 1);
29 $keychar = substr($key, ($i % strlen($key))-1, 1);
30 $char = chr(ord($char)-ord($keychar));
31 $result.=$char;
32 }
33 return $result;
34 }
35 /*$key2 = "Chhunly";
36 $Sd = "n4OaiaiRyp91kIqZy5CrnuPl8urItIqUj6/UzeOx1OE=";
37 $Sdd = decrypt($Sd,$key2);
38 echo "Decrypt: ".$Sdd;*/
39
40 //------------Valider Email Addresse--------------------------------
41
42 function check_emails($email){
43 // First, we check that there's one @ symbol, and that the lengths are right
44 if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)){
45 return false;
46 }
47 // Split it into sections
48 $email_array = explode("@", $email);
49 $local_array = explode(".", $email_array[0]);
50 for ($i = 0; $i < sizeof($local_array); $i++){
51 if (!ereg("^(([A-Za-z0-9!#$%&#038;'*+/=?^_`{|}~-][A-Za-z0-9!#$%&#038;'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])){
52 return false;
53 }
54 }
55 // Check if domain is IP. If not, it should be valid domain name
56 if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])){
57 $domain_array = explode(".", $email_array[1]);
58 if (sizeof($domain_array) < 2) {
59 return false; // Not enough parts to domain
60 }
61 for ($i = 0; $i < sizeof($domain_array); $i++){
62 if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])){
63 return false;
64 }
65 }
66 }
67 return true;
68 }
69 ?>