| 1 |
sysadm |
1.1 |
<?
|
| 2 |
|
|
require_once "../lib/db_open.inc.php";
|
| 3 |
|
|
require_once "../lib/str_process.inc.php";
|
| 4 |
|
|
require_once "./session_init.inc.php";
|
| 5 |
|
|
require_once "./check_sub.inc.php";
|
| 6 |
|
|
|
| 7 |
|
|
force_login();
|
| 8 |
|
|
|
| 9 |
|
|
$data = json_decode(file_get_contents("php://input"), true);
|
| 10 |
|
|
|
| 11 |
|
|
$photo = (isset($data["photo"]) ? intval($data["photo"]) : 0);
|
| 12 |
|
|
$introduction = (isset($data["introduction"]) ? $data["introduction"] : "");
|
| 13 |
|
|
$sign_1 = (isset($data["sign_1"]) ? $data["sign_1"] : "");
|
| 14 |
|
|
$sign_2 = (isset($data["sign_2"]) ? $data["sign_2"] : "");
|
| 15 |
|
|
$sign_3 = (isset($data["sign_3"]) ? $data["sign_3"] : "");
|
| 16 |
|
|
|
| 17 |
|
|
$result_set = array(
|
| 18 |
|
|
"return" => array(
|
| 19 |
|
|
"code" => 0,
|
| 20 |
|
|
"message" => "",
|
| 21 |
|
|
"errorFields" => array(),
|
| 22 |
|
|
)
|
| 23 |
|
|
);
|
| 24 |
|
|
|
| 25 |
|
|
header("Content-Type:application/json; charset=utf-8");
|
| 26 |
|
|
|
| 27 |
|
|
// Validate input data
|
| 28 |
|
|
$r_introduction = check_badwords(split_line($introduction, "", 80, 10), "****");
|
| 29 |
|
|
if ($introduction != $r_introduction)
|
| 30 |
|
|
{
|
| 31 |
|
|
$result_set["return"]["code"] = -1;
|
| 32 |
|
|
array_push($result_set["return"]["errorFields"], array(
|
| 33 |
|
|
"id" => "introduction",
|
| 34 |
|
|
"errMsg" => "不符合要求",
|
| 35 |
|
|
"updateValue" => $r_introduction,
|
| 36 |
|
|
));
|
| 37 |
|
|
}
|
| 38 |
|
|
|
| 39 |
|
|
$r_sign_1 = check_badwords(split_line($sign_1, "", 80, 10), "****");
|
| 40 |
|
|
if ($sign_1 != $r_sign_1)
|
| 41 |
|
|
{
|
| 42 |
|
|
$result_set["return"]["code"] = -1;
|
| 43 |
|
|
array_push($result_set["return"]["errorFields"], array(
|
| 44 |
|
|
"id" => "sign_1",
|
| 45 |
|
|
"errMsg" => "不符合要求",
|
| 46 |
|
|
"updateValue" => $r_sign_1,
|
| 47 |
|
|
));
|
| 48 |
|
|
}
|
| 49 |
|
|
|
| 50 |
|
|
$r_sign_2 = check_badwords(split_line($sign_2, "", 80, 10), "****");
|
| 51 |
|
|
if ($sign_2 != $r_sign_2)
|
| 52 |
|
|
{
|
| 53 |
|
|
$result_set["return"]["code"] = -1;
|
| 54 |
|
|
array_push($result_set["return"]["errorFields"], array(
|
| 55 |
|
|
"id" => "sign_2",
|
| 56 |
|
|
"errMsg" => "不符合要求",
|
| 57 |
|
|
"updateValue" => $r_sign_2,
|
| 58 |
|
|
));
|
| 59 |
|
|
}
|
| 60 |
|
|
|
| 61 |
|
|
$r_sign_3 = check_badwords(split_line($sign_3, "", 80, 10), "****");
|
| 62 |
|
|
if ($sign_3 != $r_sign_3)
|
| 63 |
|
|
{
|
| 64 |
|
|
$result_set["return"]["code"] = -1;
|
| 65 |
|
|
array_push($result_set["return"]["errorFields"], array(
|
| 66 |
|
|
"id" => "sign_3",
|
| 67 |
|
|
"errMsg" => "不符合要求",
|
| 68 |
|
|
"updateValue" => $r_sign_3,
|
| 69 |
|
|
));
|
| 70 |
|
|
}
|
| 71 |
|
|
|
| 72 |
|
|
if ($result_set["return"]["code"] != 0)
|
| 73 |
|
|
{
|
| 74 |
|
|
mysqli_close($db_conn);
|
| 75 |
|
|
exit(json_encode($result_set));
|
| 76 |
|
|
}
|
| 77 |
|
|
|
| 78 |
|
|
// Secure SQL statement
|
| 79 |
|
|
$introduction = mysqli_real_escape_string($db_conn, $introduction);
|
| 80 |
|
|
$sign_1 = mysqli_real_escape_string($db_conn, $sign_1);
|
| 81 |
|
|
$sign_2 = mysqli_real_escape_string($db_conn, $sign_2);
|
| 82 |
|
|
$sign_3 = mysqli_real_escape_string($db_conn, $sign_3);
|
| 83 |
|
|
|
| 84 |
|
|
// Begin transaction
|
| 85 |
|
|
$rs = mysqli_query($db_conn, "SET autocommit=0");
|
| 86 |
|
|
if ($rs == false)
|
| 87 |
|
|
{
|
| 88 |
|
|
$result_set["return"]["code"] = -2;
|
| 89 |
|
|
$result_set["return"]["message"] = "Mysqli error: " . mysqli_error($db_conn);
|
| 90 |
|
|
|
| 91 |
|
|
mysqli_close($db_conn);
|
| 92 |
|
|
exit(json_encode($result_set));
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
|
|
$rs = mysqli_query($db_conn, "BEGIN");
|
| 96 |
|
|
if ($rs == false)
|
| 97 |
|
|
{
|
| 98 |
|
|
$result_set["return"]["code"] = -2;
|
| 99 |
|
|
$result_set["return"]["message"] = "Mysqli error: " . mysqli_error($db_conn);
|
| 100 |
|
|
|
| 101 |
|
|
mysqli_close($db_conn);
|
| 102 |
|
|
exit(json_encode($result_set));
|
| 103 |
|
|
}
|
| 104 |
|
|
|
| 105 |
|
|
$sql = "UPDATE user_pubinfo SET introduction = '$introduction', ".
|
| 106 |
|
|
"photo = $photo, sign_1 = '$sign_1', sign_2 = '$sign_2', sign_3 = '$sign_3'".
|
| 107 |
|
|
" WHERE UID=" . $_SESSION["BBS_uid"];
|
| 108 |
|
|
|
| 109 |
|
|
$rs = mysqli_query($db_conn, $sql);
|
| 110 |
|
|
if ($rs == false)
|
| 111 |
|
|
{
|
| 112 |
|
|
echo "Update data error: " . mysqli_error($db_conn);
|
| 113 |
|
|
exit();
|
| 114 |
|
|
}
|
| 115 |
|
|
|
| 116 |
|
|
// Commit transaction
|
| 117 |
|
|
$rs = mysqli_query($db_conn, "COMMIT");
|
| 118 |
|
|
if ($rs == false)
|
| 119 |
|
|
{
|
| 120 |
|
|
$result_set["return"]["code"] = -2;
|
| 121 |
|
|
$result_set["return"]["message"] = "Mysqli error: " . mysqli_error($db_conn);
|
| 122 |
|
|
|
| 123 |
|
|
mysqli_close($db_conn);
|
| 124 |
|
|
exit(json_encode($result_set));
|
| 125 |
|
|
}
|
| 126 |
|
|
|
| 127 |
|
|
mysqli_close($db_conn);
|
| 128 |
|
|
exit(json_encode($result_set));
|
| 129 |
|
|
?>
|