|
|
@@ -1400,8 +1400,11 @@ if (!empty($ou_info)) {
|
|
|
$user['enabled'] = $ou_info['enabled'];
|
|
|
if (empty($user['enabled'])) { $user['enabled']=0; }
|
|
|
$user['queue_id'] = $ou_info['queue_id'];
|
|
|
+ if (empty($user['queue_id'])) { $user['queue_id']=0; }
|
|
|
$user['filter_group_id'] = $ou_info['filter_group_id'];
|
|
|
+ if (empty($user['filter_group_id'])) { $user['filter_group_id']=0; }
|
|
|
}
|
|
|
+
|
|
|
$result = insert_record($db,"User_list",$user);
|
|
|
if (!empty($result) and $auto_mac_rule and $user_info['mac']) {
|
|
|
$auth_rule['user_id'] = $result;
|
|
|
@@ -2848,7 +2851,7 @@ function get_record_field($db, $table, $field, $filter)
|
|
|
return;
|
|
|
}
|
|
|
$old_sql = "SELECT $field FROM $table WHERE $filter LIMIT 1";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$old = mysqli_fetch_array($old_record, MYSQLI_ASSOC);
|
|
|
foreach ($old as $key => $value) {
|
|
|
if (! isset($value) or $value==='NULL') { $value = ''; }
|
|
|
@@ -2872,7 +2875,7 @@ function get_record($db, $table, $filter)
|
|
|
return;
|
|
|
}
|
|
|
$old_sql = "SELECT * FROM $table WHERE $filter LIMIT 1";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$old = mysqli_fetch_array($old_record, MYSQLI_ASSOC);
|
|
|
$result = NULL;
|
|
|
if (!empty($old)) {
|
|
|
@@ -2897,7 +2900,7 @@ function get_records($db, $table, $filter)
|
|
|
$s_filter='';
|
|
|
if (isset($filter)) { $s_filter = 'WHERE '.$filter; }
|
|
|
$old_sql = "SELECT * FROM $table $s_filter";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$result = NULL;
|
|
|
$index = 0;
|
|
|
while ($old = mysqli_fetch_array($old_record, MYSQLI_ASSOC)) {
|
|
|
@@ -2916,7 +2919,7 @@ function get_records_sql($db, $sql)
|
|
|
LOG_ERROR($db, "Empty query! Skip command.");
|
|
|
return;
|
|
|
}
|
|
|
- $record = mysqli_query($db, $sql) or LOG_ERROR($db, "Select SQL: $sql :".mysqli_error($db));
|
|
|
+ $record = mysqli_query($db, $sql) or LOG_ERROR($db, "SQL: $sql :".mysqli_error($db));
|
|
|
$index = 0;
|
|
|
$result = NULL;
|
|
|
while ($rec = mysqli_fetch_array($record, MYSQLI_ASSOC)) {
|
|
|
@@ -2935,7 +2938,7 @@ function get_record_sql($db, $sql)
|
|
|
LOG_ERROR($db, "Empty query! Skip command.");
|
|
|
return;
|
|
|
}
|
|
|
- $record = mysqli_query($db, $sql." LIMIT 1") or LOG_ERROR($db, "Select SQL: $sql LIMIT 1: ".mysqli_error($db));
|
|
|
+ $record = mysqli_query($db, $sql." LIMIT 1") or LOG_ERROR($db, "SQL: $sql LIMIT 1: ".mysqli_error($db));
|
|
|
$result = NULL;
|
|
|
$rec = mysqli_fetch_array($record, MYSQLI_ASSOC);
|
|
|
if (!empty($rec)) {
|
|
|
@@ -2993,7 +2996,7 @@ function update_record($db, $table, $filter, $newvalue)
|
|
|
return;
|
|
|
}
|
|
|
$old_sql = "SELECT * FROM $table WHERE $filter";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$old = mysqli_fetch_array($old_record, MYSQLI_ASSOC);
|
|
|
$changed_log = '';
|
|
|
$run_sql = '';
|
|
|
@@ -3040,7 +3043,7 @@ function update_record($db, $table, $filter, $newvalue)
|
|
|
|
|
|
$new_sql = "UPDATE $table SET $run_sql WHERE $filter";
|
|
|
LOG_DEBUG($db, "Run sql: $new_sql");
|
|
|
- $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "Select SQL: $new_sql :".mysqli_error($db));
|
|
|
+ $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "SQL: $new_sql :".mysqli_error($db));
|
|
|
if ($sql_result === false) { LOG_ERROR($db, "UPDATE Request: $new_sql :".mysqli_error($db)); return; }
|
|
|
LOG_VERBOSE($db, "Change table $table WHERE $filter set $changed_log");
|
|
|
}
|
|
|
@@ -3064,7 +3067,7 @@ function delete_record($db, $table, $filter)
|
|
|
return;
|
|
|
}
|
|
|
$old_sql = "SELECT * FROM $table WHERE $filter";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$old = mysqli_fetch_array($old_record, MYSQLI_ASSOC);
|
|
|
$changed_log = 'record: ';
|
|
|
foreach ($old as $key => $value) {
|
|
|
@@ -3076,12 +3079,12 @@ function delete_record($db, $table, $filter)
|
|
|
$changed_time = GetNowTimeString();
|
|
|
$new_sql = "UPDATE $table SET deleted=1, changed=1, `changed_time`='".$changed_time."' WHERE $filter";
|
|
|
LOG_DEBUG($db, "Run sql: $new_sql");
|
|
|
- $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "Select SQL: $new_sql :".mysqli_error($db));
|
|
|
+ $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "SQL: $new_sql :".mysqli_error($db));
|
|
|
if ($sql_result === false) { LOG_ERROR($db, "UPDATE Request (from delete): ".mysqli_error($db)); return; }
|
|
|
} else {
|
|
|
$new_sql = "DELETE FROM $table WHERE $filter";
|
|
|
LOG_DEBUG($db, "Run sql: $new_sql");
|
|
|
- $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "Select SQL: $new_sql :".mysqli_error($db));
|
|
|
+ $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "SQL: $new_sql :".mysqli_error($db));
|
|
|
if ($sql_result === false) { LOG_ERROR($db, "DELETE Request: $new_sql : ".mysqli_error($db)); return; }
|
|
|
}
|
|
|
LOG_VERBOSE($db, "Delete FROM table $table WHERE $filter $changed_log");
|
|
|
@@ -3120,7 +3123,7 @@ function insert_record($db, $table, $newvalue)
|
|
|
$value_list = substr_replace($value_list, "", - 1);
|
|
|
$new_sql = "insert into $table(" . $field_list . ") values(" . $value_list . ")";
|
|
|
LOG_DEBUG($db, "Run sql: $new_sql");
|
|
|
- $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "Select SQL: $new_sql :".mysqli_error($db));
|
|
|
+ $sql_result = mysqli_query($db, $new_sql) or LOG_ERROR($db, "SQL: $new_sql :".mysqli_error($db));
|
|
|
if ($sql_result === false) { LOG_ERROR($db, "INSERT Request:".mysqli_error($db)); return; }
|
|
|
$last_id = mysqli_insert_id($db);
|
|
|
LOG_VERBOSE($db, "Create record in table $table: $changed_log with id: $last_id");
|
|
|
@@ -3143,7 +3146,7 @@ function get_diff_rec($db, $table, $filter, $newvalue, $only_changed)
|
|
|
if (!isset($only_changed)) { $only_changed=0; }
|
|
|
|
|
|
$old_sql = "SELECT * FROM $table WHERE $filter";
|
|
|
- $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "Select SQL: $old_sql :".mysqli_error($db));
|
|
|
+ $old_record = mysqli_query($db, $old_sql) or LOG_ERROR($db, "SQL: $old_sql :".mysqli_error($db));
|
|
|
$old = mysqli_fetch_array($old_record, MYSQLI_ASSOC);
|
|
|
$changed_log = "\r\n";
|
|
|
foreach ($newvalue as $key => $value) {
|