-
Notifications
You must be signed in to change notification settings - Fork 0
/
Core_EditUser.php
69 lines (60 loc) · 1.91 KB
/
Core_EditUser.php
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
<?php
require_once("DB_Manager.php");
require_once("Validation_Utility.php");
require_once("Validation_Manager.php");
$sessionActive = ValidationUtility::sessionExists();
if( $sessionActive ){
$id = (int)$_SESSION["id"];
if( isset($_POST["twitter_name"]) and
isset($_POST["name"]) and
isset($_POST["school"]) and
isset($_POST["password"]) ){
$twitter_name = $_POST["twitter_name"];
$name = $_POST["name"];
$school = $_POST["school"];
$password = $_POST["password"];
$new_password = $_POST["new_password"];
$new_password_check = $_POST["new_password_check"];
$passwordChange = !(empty($new_password));
if( !ValidationManager::validateFormEditUser($twitter_name, $name, $school, $password, $new_password, $new_password_check) ){
header("location: View_EditUser.php");
exit;
}
$db = new DBManager();
$savedPassword = $db->getContestantPassword($id);
if( $password != $savedPassword ){
unset($db);
ValidationUtility::setErrorCode("U_savedPasswordNotMatch");
header("location: View_EditUser.php");
exit;
}
$twitter_id = ValidationManager::twitterNameToID($twitter_name);
if( $twitter_id == false ){
header("location: View_EditUser.php");
exit;
}
if($passwordChange){
if( !$db->editContestantInformation($id, $twitter_id, $twitter_name, $name, $school, $new_password) ){
ValidationUtility::setErrorCode("DB_Failure");
header("location: View_EditUser.php");
exit;
}
} else {
if( !$db->editContestantInformationWoPassword($id, $twitter_id, $twitter_name, $name, $school)){
ValidationUtility::setErrorCode("DB_Failure");
header("location: View_EditUser.php");
exit;
}
}
unset($db);
ValidationUtility::setStatusCode("U_EditOK");
$_SESSION["twitter_name"] = $twitter_name;
header("location: index.php");
exit;
}
} else {
ValidationUtility::setErrorCode("U_missingInformation");
header("location: View_EditUser.php");
exit;
}
?>