public function log_user_action($db, $primary_key) { if (\defender::safe()) { $output_fields = array(); $field = flatten_array($this->fields); $output_fields[$db] = $this->callback_data; foreach ($field as $arr => $field_data) { $target_database = $field_data['field_cat_db'] ? DB_PREFIX . $field_data['field_cat_db'] : $db; $col_name = $field_data['field_cat_index'] ? $field_data['field_cat_index'] : $primary_key; $index_value = isset($_POST[$col_name]) ? form_sanitizer($_POST[$col_name], 0) : ''; if ($field_data['field_log'] == TRUE && isset($this->callback_data[$field_data['field_name']]) && isset($this->output_fields[$target_database][$field_data['field_name']]) && $this->callback_data[$field_data['field_name']] !== $this->output_fields[$target_database][$field_data['field_name']]) { //print_p($this->callback_data[$field_data['field_name']]." => ".$this->output_fields[$target_database][$field_data['field_name']]); save_user_log($index_value, $field_data['field_name'], $this->output_fields[$target_database][$field_data['field_name']], $this->callback_data[$field_data['field_name']]); } //print_p($field_data); //print_p($this->output_fields); // nothing to return } } }
/** * Update User Fields * @return bool */ public function saveUpdate() { $locale = fusion_get_locale(); $settings = fusion_get_settings(); $this->_method = "validate_update"; //$this->data = $this->userData; // Turn off for Next $this->_settUserName(); $this->_setPassword(); if (!defined('ADMIN_PANEL')) { $this->_setAdminPassword(); } $this->_setUserEmail(); if ($this->validation == 1) { $this->_setValidationError(); } $this->_setUserAvatar(); $quantum = new QuantumFields(); $quantum->setCategoryDb(DB_USER_FIELD_CATS); $quantum->setFieldDb(DB_USER_FIELDS); $quantum->setPluginFolder(INCLUDES . "user_fields/"); $quantum->setPluginLocaleFolder(LOCALE . LOCALESET . "user_fields/"); $quantum->load_fields(); $quantum->load_field_cats(); $quantum->setCallbackData($this->data); $_input = $quantum->return_fields_input(DB_USERS, 'user_id'); if (!empty($_input)) { foreach ($_input as $input) { $this->data += $input; } } if (\defender::safe()) { if ($this->_userName != $this->userData['user_name']) { save_user_log($this->userData['user_id'], "user_name", $this->_userName, $this->userData['user_name']); } if ($this->_userEmail != $this->userData['user_email']) { save_user_log($this->userData['user_id'], "user_email", $this->_userEmail, $this->userData['user_email']); } $quantum->log_user_action(DB_USERS, "user_id"); dbquery_insert(DB_USERS, $this->data, 'update'); $this->_completeMessage = $locale['u163']; if ($this->isAdminPanel && $this->_isValidCurrentPassword && $this->_newUserPassword && $this->_newUserPassword2) { // inform user that password has changed. and tell him your new password include INCLUDES . "sendmail_include.php"; addNotice("success", str_replace("USER_NAME", $this->userData['user_name'], $locale['global_458'])); $input = array("mailname" => $this->userData['user_name'], "email" => $this->userData['user_email'], "subject" => str_replace("[SITENAME]", $settings['sitename'], $locale['global_456']), "message" => str_replace(array("[SITENAME]", "[SITEUSERNAME]", "USER_NAME", "[PASSWORD]"), array($settings['sitename'], $settings['siteusername'], $this->userData['user_name'], $this->_newUserPassword), $locale['global_457'])); if (!sendemail($input['mailname'], $input['email'], $settings['siteusername'], $settings['siteemail'], $input['subject'], $input['message'])) { addNotice('warning', str_replace("USER_NAME", $this->userData['user_name'], $locale['global_459'])); } } if (\defender::safe()) { addNotice('success', $locale['u169']); } return true; } return false; }
private function _setUserDataUpdate() { global $locale; $user_info = array(); $quantum = new QuantumFields(); $quantum->setCategoryDb(DB_USER_FIELD_CATS); $quantum->setFieldDb(DB_USER_FIELDS); $quantum->setPluginFolder(INCLUDES . "user_fields/"); $quantum->setPluginLocaleFolder(LOCALE . LOCALESET . "user_fields/"); $quantum->set_Fields(); $quantum->load_field_cats(); $quantum->setCallbackData($this->data); $fields_input = $quantum->return_fields_input(DB_USERS, 'user_id'); $user_info += $this->_setEmptyFields(); if (!empty($fields_input)) { foreach ($fields_input as $table_name => $fields_array) { $user_info += $fields_array; } } if (\defender::safe()) { if ($this->_userName != $this->userData['user_name']) { save_user_log($this->userData['user_id'], "user_name", $this->_userName, $this->userData['user_name']); } if ($this->_userEmail != $this->userData['user_email']) { save_user_log($this->userData['user_id'], "user_email", $this->_userEmail, $this->userData['user_email']); } } $quantum->log_user_action(DB_USERS, "user_id"); // @todo: now that updates doesn't override unspecified column, i think can remove this line. confirm later. if (iADMIN) { $user_info['user_admin_algo'] = $this->data['user_admin_algo']; $user_info['user_admin_salt'] = $this->data['user_admin_salt']; $user_info['user_admin_password'] = $this->data['user_admin_password']; } dbquery_insert(DB_USERS, $user_info, 'update'); $this->_completeMessage = $locale['u163']; }