-
Notifications
You must be signed in to change notification settings - Fork 0
/
inbox.php
52 lines (45 loc) · 1.19 KB
/
inbox.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
<?php
session_start();
$path = 'phpseclib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
include_once('Crypt/RSA.php');
function rsa_decrypt($string, $private_key)
{
//Create an instance of the RSA cypher and load the key into it
$cipher = new Crypt_RSA();
$cipher->loadKey($private_key);
//Set the encryption mode
$cipher->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
//Return the decrypted version
return $cipher->decrypt($string);
}
function printMessages(){
$i;
$array = array();
$str = file_get_contents('messages.txt');
$array = json_decode($str);
for($i=0;$i<sizeof($array);$i++){
if($array[$i]->to === $_SESSION["login"]){
//THIS MESAGE GOES TO INBOX
$tempS = base64_decode($array[$i]->body);
$doText = rsa_decrypt($tempS, $_SESSION['privCode']);
echo $array[$i]->from . ": " . $doText . "<br/ >";
}
}
}
?>
<head>
<title>"Inbox"</title>
<meta charset = "utf-8"/>
</head>
<body>
<h1>Inbox</h1>
<p>
<?php if(file_exists('messages.txt')){
printMessages();
} ?>
</p>
<div>
<input onCLick="location.href = 'viewPosts.php';" type="submit" id="goBack" name="goBack" value="Back to Homepage"/>
</div>
</body>