-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.php
More file actions
147 lines (99 loc) · 3.46 KB
/
chat.php
File metadata and controls
147 lines (99 loc) · 3.46 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
if(isset($_GET['id'])&& isset($_GET['to']))
{
$id=$_GET['id'];
$to=$_GET['to'];
}
if(isset($_POST['id']) && isset($_POST['to']))
{
$id=$_POST['id'];
$to=$_POST['to'];
}
require("connect.php");
mysql_select_db("winter");
$extract=mysql_query("SELECT * FROM table2 WHERE id='$id'");
$row = mysql_fetch_assoc($extract);
$status=$row['status'];
if($status==1)
{
if(isset($_GET['id'])&& isset($_GET['to']))
{
echo "<form action=\"chat.php\" method=\"POST\">";
echo "<fieldset><legend align=\"center\"><p style=\"color:skyblue;\">mesage</p></legend>" ;
echo" <p> YOUR MESSAGE:<textarea name=\"message\" rows=\"5\" cols=\"50\"></textarea></p><br />";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"hidden\" name=\"to\" value=\"$to\"></input>";
echo "<p><input type=\"submit\" name=\"submit\" value=\"submit\"></input>";
echo "</fieldset>";
echo "</form>";
}
if(isset($_POST['message']))
{
$message=$_POST['message'];
$id=$_POST['id'];
$to=$_POST['to'];
if(strlen($message)==0)
{
echo "EMPTY MESSAGES ARE NOT ALLOWED<br />";
echo "<form action=\"chat.php\" method=\"GET\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"hidden\" name=\"to\" value=\"$to\"></input>";
echo "<input type=\"submit\" name=\"submit\" value=\"MESSAGE AGAIN\"></input>";
echo "</form>";
echo "<form action=\"contacts.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"submit\" name=\"submit\" value=\"BACK TO THE CONTACTS\"></input>";
echo "</form>";
}
else
{
require("connect.php");
mysql_select_db("winter");
$chat="chat".$to;
if($extract=mysql_query("SELECT $chat FROM table2 WHERE id=$id"))
{
$flag=1;
}
else{
mysql_query("ALTER TABLE table2 ADD $chat LONGTEXT NOT NULL AFTER ID");
$flag=1;
}
if($flag==1)
{
$extract=mysql_query("SELECT * FROM table2 WHERE id=$id");
$row=mysql_fetch_assoc($extract);
$array=$row[$chat];
$array1=unserialize($array);
$size=sizeof($array1);
if($array1=="")
{
$array1[0]=$message;
}
else
{
$k=array_push($array1,"$message");
}
$array2=serialize($array1);
$array3=unserialize($array2);
print_r($array3);
$update = mysql_query("UPDATE table2 SET $chat='$array2' WHERE id='$id'");
echo "YOUR MESSAGE WAS SUCEESSFULLY SENT<br />";
echo "<form action=\"contacts.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"submit\" name=\"submit\" value=\"BACK TO THE CONTACTS\"></input>";
echo "</form>";
echo "<form action=\"chat.php\" method=\"GET\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"hidden\" name=\"to\" value=\"$to\"></input>";
echo "<input type=\"submit\" name=\"submit\" value=\"MESSAGE AGAIN\"></input>";
echo "</form>";
}
}
}
}
else
{
echo "YOUR ACCOUNT IS NOW IN LOG OFF STATE <br /> PLEASE ENTER INTO YOUR ACCOUNT THROUGH A SECURE METHOD OF LOGIN<br />";
require("login.php");
}
?>