Add the dialup_admin web interface. Hope everything works fine
[freeradius.git] / dialup_admin / lib / sql / user_info.php3
1 <?php
2 require('../lib/sql/attrmap.php3');
3 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
4         include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
5 else{
6         echo "<b>Could not include SQL library</b><br>\n";
7         exit();
8 }
9 $user_exists = 'no';
10 $link = @da_sql_pconnect($config);
11 if ($link){
12         $res = @da_sql_query($link,$config,
13         "SELECT Attribute,Value FROM $config[sql_check_table] WHERE UserName = '$login';");
14         if ($res){
15                 if (@da_sql_num_rows($res,$config))
16                         $user_exists = 'yes';
17                 while(($row = @da_sql_fetch_array($res,$config))){
18                         $attr = $row[Attribute];
19                         $val = $row[Value];
20                         $tmp["$attr"][]="$val";
21                         $tmp["$attr"][count]++;
22                 }
23                 $res = @da_sql_query($link,$config,
24                 "SELECT Attribute,Value FROM $config[sql_reply_table] WHERE UserName = '$login';");
25                 if ($res){
26                         while(($row = @da_sql_fetch_array($res,$config))){
27                                 $attr = $row[Attribute];
28                                 $val = $row[Value];
29                                 $tmp["$attr"][] = "$val";
30                                 $tmp["$attr"][count]++;
31                         }
32                         if ($config[sql_use_user_info_table] == 'true'){
33                                 $res = @da_sql_query($link,$config,
34                                 "SELECT * FROM $config[sql_user_info_table] WHERE UserName = '$login';");
35                                 if ($res){
36                                         if (($row = @da_sql_fetch_array($res,$config))){        
37                                                 $cn = ($row[Name]) ? $row[Name] : '-';
38                                                 $telephonenumber = ($row[WorkPhone]) ? $row[WorkPhone] : '-';
39                                                 $homephone = ($row[HomePhone]) ? $row[HomePhone] : '-';
40                                                 $ou = ($row[Depatment]) ? $row[Department] : '-';
41                                                 $mail = ($row[Mail]) ? $row[Mail] : '-';
42                                                 $mobile = ($row[Mobile]) ? $row[Mobile] : '-';
43                                         }
44                                 }                       
45                         }
46                 }
47                 else
48                         echo "<b>Database query failed partially</b><br>\n";
49                 foreach($attrmap as $key => $val){
50                         if (isset($tmp[$val])){
51                                 $item_vals["$key"] = $tmp[$val];
52                                 $item_vals["$key"][count] = $tmp[$val][count];
53                         }
54                 }
55
56         }
57         else
58                 echo "<b>Database query failed</b><br>\n";      
59 }
60 else
61         echo "<b>Could not connect to database</b><br>\n";
62 ?>