-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuser_add_sqldb.php
More file actions
182 lines (146 loc) · 5.53 KB
/
user_add_sqldb.php
File metadata and controls
182 lines (146 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
include ("./lib/defines.php");
include ("./lib/functions.php");
include ("./lib/database.php");
include ("locale.php");
session_start();
getpost_ifset(array('view','add','update','remove','uuid','fname','lname','userName','userPass','phone','userEmail','userAdmin'));
// this variable specifie the debug type (0 => nothing, 1 => sql result, 2 => boucle checking, 3 other value checking)
$FG_DEBUG = 0;
// The variable FG_TABLE_NAME define the table name to use
$FG_TABLE_NAME=DB_TABLEUSERS;
// The variable Var_col would define the col that we want show in your table
// First Name of the column in the html page, second name of the field
$FG_TABLE_COL = array();
$FG_TABLE_COL[]=array (_("ID"), "userName", "8%", "center", "", "30");
$FG_TABLE_COL[]=array (_("ConfId"), "confno", "12%", "center", "", "19");
$FG_TABLE_COL[]=array (_("Password"), "pin", "12%", "center", "", "30");
$FG_TABLE_COL[]=array (_("starttime"), "starttime", "15%", "center", "", "30");
$FG_TABLE_COL[]=array (_("endtime"), "endtime", "15%", "center", "", "30");
$FG_TABLE_COL[]=array (_("Callers"), "maxUser", "12%", "center", "", "30","list", $mode_list);
$FG_TABLE_DEFAULT_ORDER = "UserName";
$FG_TABLE_DEFAULT_SENS = "DESC";
// This Variable store the argument for the SQL query
$FG_COL_QUERY='id, email, password, first_name,last_name,telephone, admin';
// The variable LIMITE_DISPLAY define the limit of record to display by page
$FG_LIMITE_DISPLAY=30;
$FG_LIMITE_DISPLAY_BLANK_LINE=5;
// Number of column in the html table
//This variable will store the total number of column
$FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL;
//This variable define the Title of the HTML table
$FG_HTML_TABLE_TITLE=" - Users : - ";
//This variable define the width of the HTML table
$FG_HTML_TABLE_WIDTH="100%";
if ($FG_DEBUG == 3) echo "<br>Table : $FG_TABLE_NAME - Col_query : $FG_COL_QUERY";
//if ( is_null ($order) || is_null($sens) ){
$order = $FG_TABLE_DEFAULT_ORDER;
$sens = $FG_TABLE_DEFAULT_SENS;
//}
/* ACTION * * * * * * *********************************************************/
if($userAdmin)
{
$userAdmin = 'Admin';
}
else
{
$userAdmin = 'User';
}
if ($add){
if ($_SESSION['privilege'] == 'Admin') {
if (checkEmail($userEmail)) {
$FG_TABLE_CLAUSE="email='$userEmail'";
$conflict = $db->getOne("SELECT COUNT(*) FROM $FG_TABLE_NAME WHERE $FG_TABLE_CLAUSE");
if (!intval($conflict)){
// $userPass = md5($userPass);
$data = array(NULL,$userEmail,$userPass,$fname,$lname,$phone,$userAdmin);
$query = "INSERT INTO $FG_TABLE_NAME VALUES (?,?,?,?,?,?,?)";
$result = $db->query($query, $data);
}
} else {
$Error = "You have entered an invalid email address";
}
}
}
if (($update)){
if ($_SESSION['privilege'] == 'Admin') {
if (checkEmail($userEmail)) {
$FG_EDITION_CLAUSE=" id='$uuid' ";
$FG_TABLE_CLAUSE="id='$uuid'";
$conflict = $db->getOne("SELECT COUNT(*) FROM $FG_TABLE_NAME WHERE $FG_EDITION_CLAUSE");
if($userPass)
{
// $userPass = md5($userPass);
$userPass = "$userPass";
}
if (intval($conflict) == 1){
$data = array($userEmail,$userAdmin,$fname,$lname,$phone,$userPass);
$query = "UPDATE $FG_TABLE_NAME SET email=? ,admin=? ,first_name=? ,last_name=? ,telephone=? ,password=? WHERE $FG_EDITION_CLAUSE";
$result = $db->query($query, $data);
$conflict=0;
}
} else {
$Error = "You have entered an invalid email address";
}
}
}
if ($remove){
if ($_SESSION['privilege'] == 'Admin') {
$query = "DELETE FROM $FG_TABLE_NAME WHERE id=?";
$data = array($uuid);
$result = $db->query($query, $data);
}
}
/* * * * * * * * *********************************************************/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php print GUI_TITLE; ?> <?php print _("control"); ?></title>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css">
<style type="text/css" media="screen">
@import url("css/content.css");
@import url("css/docbook.css");
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body>
<?php if ($userAdmin == "Admin") {
$isAdmin="Yes";
} else {
$isAdmin="No";
}
?>
<?php if (($add || $update) && (intval($conflict) == 0) && !($remove)) {
if (!strlen($Error)) { ?>
<center><strong> <?php print _("User Created"); ?>: </strong></center><br>
<center><?php print _("User Name"); ?>: <?php print $fname." ".$lname ?> <br></center>
<center><?php print _("User Password"); ?>: <?php print $userPass ?> <br></center>
<center><?php print _("User Email"); ?>: <?php print $userEmail ?> <br></center>
<center><?php print _("Is Admin"); ?>: <?php print $isAdmin ?><br></center>
<FORM METHOD=POST ACTION="./meetme_control.php?&s=3&t=1" target="_top">
<center><INPUT TYPE="Submit" VALUE="Continue"/></center>
</FORM>
<?php } else { ?>
<center><strong> <?php print $Error; ?> </strong></center>
<?php } ?>
<?php } ?>
<?php if($remove) { ?>
<center><strong> <?php print _("User Deleted"); ?> </strong></center><br>
<FORM METHOD=POST ACTION="./meetme_control.php?&s=3&t=1" target="_top">
<center><INPUT TYPE="Submit" VALUE="Continue"/></center>
</FORM>
<?php } ?>
<?php if ((intval($conflict) != 0) ) { ?>
<center><strong> <?php print _("User Not Created"); ?>: </strong></center><br>
<?php } ?>
<br><br>
</body>
</html>