-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmit.php
44 lines (36 loc) · 1.01 KB
/
submit.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
<?php
require('class/class.php');
if(!isset($_SESSION['user'])){
header('location:static/redirect.php?u=/index.php');
exit;
}
if(empty($_POST['to']) && empty($_POST['message'])){
header('location:static/redirect.php?u=/user.php');
exit;
}
$user = filter(trim($_POST['to']));
$message = filter(trim($_POST['message']));
$query = "insert into m (user,message) values ('".$user."' , '".$message."')";
$result=$db->query($query);
$db->close();
function GetIP(){
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$cip = $_SERVER["HTTP_CLIENT_IP"];
}
elseif(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
$cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif(!empty($_SERVER["REMOTE_ADDR"])){
$cip = $_SERVER["REMOTE_ADDR"];
}
else{
$cip = "NULL";
}
return $cip;
}
$file = 'it51zlog.log';
$content = sprintf("ip: %s , from: %s , to: %s , message: %s \r\n", GetIP(), $_SESSION['user'], $user, $message);
$f = file_put_contents($file, $content,FILE_APPEND);
header('location:static/redirect.php?u=/user.php');
exit;
?>