+
+ public static function edit_core($arr)
+ {
+ $conn = sqlnew();
+ $user = $arr['user'];
+ $info = $arr['info'];
+ foreach($info as $key => $val)
+ {
+ $value = NULL;
+ if (!$val || !strlen($val) || BadPtr($val))
+ continue;
+ if (!strcmp($key,"update_fname") && $val != $user->first_name)
+ {
+ $value = "user_fname";
+ $valuestr = "first name";
+ }
+ elseif (!strcmp($key,"update_lname") && $val != $user->last_name)
+ {
+ $value = "user_lname";
+ $valuestr = "last name";
+ }
+ elseif (!strcmp($key,"update_bio") && $val != $user->bio)
+ {
+ $value = "user_bio";
+ $valuestr = "bio";
+ }
+ elseif (!strcmp($key,"update_pass") || !strcmp($key,"update_pass_conf"))
+ {
+ $value = "user_pass";
+ $valuestr = "password";
+ }
+ elseif(!strcmp($key,"update_email") && $val != $user->email)
+ {
+ $value = "user_email";
+ $valuestr = "email address";
+ }
+
+ if (!$value)
+ continue;
+ $query = "UPDATE " . SQL_PREFIX . "users SET $value=:value WHERE user_id = :id";
+ $stmt = $conn->prepare($query);
+ $stmt->execute(["value" => $val, "id" => $user->id]);
+
+ if (!$stmt->rowCount() && $stmt->errorInfo()[0] != "00000")
+ Message::Fail("Could not update $valuestr for $user->username: ".$stmt->errorInfo()[0]." (CODE: ".$stmt->errorCode().")");
+
+ else
+ Message::Success("Successfully updated the $valuestr for $user->username");
+ }
+ }