source: branches/web-klask/ctrl.php @ 40

Last change on this file since 40 was 40, checked in by g7moreau, 16 years ago
  • Add web-klask project from Kevin Reverchon
File size: 1.7 KB
Line 
1<?
2
3function ctrlAuth() {
4        //session_start();
5        if ((!isset($_SESSION['login'])) or (!isset($_SESSION['passwd']))) {
6               
7                return 0;
8        }else{
9                return 1;
10        }
11}
12
13function auth($idLogin, $passwd) {
14
15   if ( $idLogin == $GLOBALS['adminApp'] ) {
16                $GLOBALS['auth'] = "classic" ;
17        }
18
19   if ( $GLOBALS['auth'] == "ldap" ) {
20          // must exist in database user
21          $resultat = selectUser($idLogin);
22          if ( !is_string($resultat) ) {
23                while ( $row = mysql_fetch_assoc($resultat) ) {
24                   if ( $row['idUser'] == $idLogin ) {
25                      return auth_ldap($idLogin, $passwd) ;
26                   }
27                 }
28                return "ACCESS DENIED FOR USER $idLogin";
29           }
30         
31           
32        }else{
33                if (  $GLOBALS['auth'] == "classic" ) {
34                       
35                        return  auth_user($idLogin, $passwd);
36                }
37        }
38       
39}
40
41function ctrlEmpty($value, $saisie) {
42        if (empty($value) ) {
43                return "le champs $saisie est obligatoire";
44        }else{
45                return 1;
46        }
47}
48
49function ctrlUnixAccount($idLogin) {
50        $command='id '.$idLogin ;
51       
52        if ( exec($command) ) {
53                return  1;
54        }else{
55                return 0;
56        }       
57}
58
59function ctrlIP($ip){
60       
61        $Tsplit= split("[.]" , $ip ) ;
62
63        if ( count($Tsplit) != 4 ) {
64                return "Adresse IP non valide";
65        }
66        return 1;
67}
68
69function ctrlMac($mac) {
70        $Tsplit = split("[:]", $mac);
71       
72        if ( count($Tsplit ) != 6 ) {
73                return "Adresse MAC non valide";
74        }
75       
76        return 1;
77       
78}
79
80
81function ctrlAddressNetwork($addressNetwork) {
82       
83        $Tsplit = split("[/]", $addressNetwork); 
84        if ( count($Tsplit) != 2) {
85                return "Adresse Network non valide : netmask non saisie";
86        }
87       
88        if ( !is_numeric($Tsplit[1]) ) {
89                return "Adresse Network non valide : netmask non valide";
90        }
91       
92        $TsplitIP= split("[.]" , $Tsplit[0] ) ;
93
94        if ( count($TsplitIP) != 4 ) {
95                return "Adresse Network non valide";
96        }
97       
98        return 1;
99}
100
101
102     
103?>
Note: See TracBrowser for help on using the repository browser.