-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinclude_user.php
114 lines (45 loc) · 1.43 KB
/
include_user.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
session_start();
if(!(isset($_SESSION["username"]) && isset($_SESSION["id"]))){
$newURL = "login.php?e=3";
header('Location: '.$newURL);
};
//New eras coming
$servername = "localhost";
$username = "stellaa2_costory";
$password = "CSO%YvAwSsTX";
$dbname = "stellaa2_costroy";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user_id = $_SESSION["id"];
$story_id = $_GET["i"];
$from = $_GET["f"];
if ($from == 1) {
$sql2 = "SELECT id FROM invitations WHERE user_id = '$user_id' AND story_id = '$story_id'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
$contiune = 1;
}
}
if($contiune == 1) {
$color_code = rand_color();
$sql = "INSERT INTO writers (user_id, story_id, color_code)
VALUES ('$admin_id', '$story_id', '$color_code')";
if ($conn->query($sql) === TRUE) {
$newURL = "story_index.php?i=$story_id&e=4";
header('Location: '.$newURL);
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
$newURL = "create_story.php?e=4";
header('Location: '.$newURL);
}
}
$conn->close();
function rand_color() {
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
}
?>