";
if ($_REQUEST["action"]=="read" or $_REQUEST["action"]=="empty" or $_REQUEST["action"]=="send" or $_REQUEST["action"]=="delete") {
$db = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
if (!$db) {
die("Could not connect: ".mysqli_error($db));
} else {
mysqli_query('SET CHARACTER SET utf8');
}
}
if ($_REQUEST["action"]=="read" or $_REQUEST["action"]=="delete") { //READ MESSAGES AND MAYBE DELETE ONE
if ($_REQUEST["action"]=="delete") { //DELETE MESSAGE
mysqli_query($db,"DELETE FROM messages WHERE ID='".ID($_REQUEST["key"])."' AND DATE='".mysqli_real_escape_string($db,$_REQUEST["messagedate"])."'");
}
$ID=ID($_REQUEST["key"]);
echo "
Showing messages for ID $ID.
Give
this link or your ID to others to receive messages.
";
$res=mysqli_query($db,"SELECT text,date FROM messages WHERE ID='".ID($_REQUEST["key"])."' ORDER BY date DESC");
echo "
".mysqli_num_rows($res)."
";
while ($row=mysqli_fetch_array($res)) echo "
Date: ".$row["date"]." Size: ".strlen($row["text"])." bytes. Delete".preg_replace(array("/\n/","/(-----BEGIN PGP MESSAGE-----.+?-----END PGP MESSAGE-----)/s"),array("
","
$1
"),htmlspecialchars($row["text"]))."
";
echo "
";
echo "
";
} elseif ($_REQUEST["action"]=="send") { //SEND MESSAGE
$text=html_entity_decode($_REQUEST["text"],ENT_COMPAT,"UTF-8");
if (strlen($_REQUEST["ID"])!=12) {
echo "
You didn't give the recepient's ID.
Go back and retry.
";
} elseif (strlen($_REQUEST["text"])>$maxsize) {
echo "
Your message is ".strlen($text)." bytes long.
The maximum allowed is $maxsize.
Go back and retry with a smaller message.
";
} else {
mysqli_query($db,"INSERT INTO messages VALUES ('".mysqli_real_escape_string($db,$_REQUEST["ID"])."','".mysqli_real_escape_string($db,$text)."',NOW())");
if (mysqli_error($db)) {
echo "
Error sending message: ".mysqli_error($db)."
";
} else {
echo "
Message sent!
";
}
echo "Message size: ".strlen($text)." bytes.
";
}
if ($_REQUEST["key"]) echo "
";
echo "
";
} elseif ($_REQUEST["action"]=="empty") { //EMPTY INBOX
mysqli_query($db,"DELETE FROM messages WHERE ID='".ID($_REQUEST["key"])."'");
echo "The inbox has been emptied!
";
echo "
";
} elseif ($_REQUEST["action"]=="whynot") { //SHOW WHYNOT
echo "
";
echo "
";
} elseif ($_REQUEST["action"]=="API") { //SHOW API
echo "
API
";
echo "
ganjlePM handles all \$_REQUEST parameteres. That means that you can send/receive/delete messages by POST or GET. Below you can find the parameters for each action:
Send message: action=send, text=whatever, ID=whatever
Read messages: action=read, key=yourkey
(the message count is inside a div of that belongs to the class notifierdata and message text along with size/date/delete_link are inside divs that belongs to the class message)
Empty inbox: action=empty, key=yourkey
Delete message: action=delete, key=yourkey, messagedate=whatever
(messagedate should be exactly what is printed as date when you read the message)
";
} else { //NO ACTION: SHOW MAIN PAGE
$key=hash("sha256",rand()."|".rand()."|".rand()."|".rand()."|".rand());
$ID=ID($key);
echo
"
Allowing you to send and receive messages without registration, cookies or javascript.
To receive messages just give this link/ID to anyone:
$ID
If you need more IDs and inboxes just refresh this page!
You can read your messages using this link:
$ID Inbox
Do not loose your inbox link because it can't be restored!
This service offers privacy not security or authentication so use
GPG as required.
";
if ($_REQUEST["key"]) { echo "
";
if ($_REQUEST["key"]) echo "
";
}
?>