-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgingamsgserver.php
76 lines (58 loc) · 1.6 KB
/
gingamsgserver.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
<html>
<head>
<title>gingamsgserver</title>
</head>
<body>
<p>
<?php
//codigo php aqui:
//http://example.com/?msg=...
//http://www.tv.unesp.br/ftp/files/convidado/ufabc/mensagem/gingamsgserver.php/?msg=
//http://www.tv.unesp.br/webftp/geiza/chat/gingamsgserver.php/...
define("MSG", "mensagens.txt");
function read($fileName){
if(!file_exists($fileName))
return 0;
if($arq = fopen($fileName, "r+")){
$oldMsg = fread($arq, filesize($fileName));
fclose($arq);
return $oldMsg;
}
}
function write($fileName, $usr, $msg){
//echo "<" . time() . "> ";
$oldFile = read($fileName);
$oldFile = str_replace(array("\n<CONVERSA>\n","</CONVERSA>\n"), "",$oldFile);
$toWrite = "\t<MENSAGEM>\n" .
"\t\t<TIME>" . time() . "</TIME>" . "\n" .
"\t\t<USR>" . $usr . "</USR>" . "\n" .
"\t\t<MSG>" . $msg . "</MSG>" . "\n" .
"\t</MENSAGEM>\n";
$msg = $oldFile . $toWrite;
$msg = "\n<CONVERSA>\n" . $msg . "</CONVERSA>\n\n";
if($arq = fopen($fileName, "w+")){
fwrite($arq, $msg);
fclose($arq);
}
return $msg;
}
// http://felipemeloni.xyz/gingamsgserver.php/?msg=teste&nome=teste
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
echo "<br />";
foreach($_GET as $key => $value)
echo $key . " : " . $value . "<br />";
$usr = $_GET["usr"];
$msg = $_GET["msg"];
write(MSG, $usr, $msg);
/*
if(isset($_REQUEST["msg"])){
echo $_REQUEST;
write(MSG, $msg);
echo $msg;
}
*/
?>
</p>
</body>
</html>