Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Resync with latest production code #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dice/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FilesMatch "\.(key|dat)$">
deny from all
</FilesMatch>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this file is going to affect anything since we're using nginx and not apache.

122 changes: 66 additions & 56 deletions dice/MARTI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,77 @@
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>

<!DOCTYPE html>
<html>
<head>
<title> M.A.R.T.I. Server --> "more accurate rolls than irony"- server</title>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$output = [];

$send = $_POST['send'];
$numsides = $_POST['numsides'];
$numdice = $_POST['numdice'];
$output['subject'] = $_POST['subject'];
$email1 = $_POST['roller'];
$email2 = $_POST['gm'];

//check posted data
if(!is_numeric($numsides) || !is_numeric($numdice) || empty($output['subject']) || empty($email1)) {
exit("fatal error: wrong input!");
}
if(empty($email2)) {
exit("fatal error: no second email found. Please enter an email address into the Cc-field!");
}
//format multiple emails in one line
$emails1 = explode(" ", $email1);
$emails2 = explode(" ", $email2);

$output['emails'] = array_merge($emails1, $emails2);
// get exact server time
$output['time'] = date("Y-m-d H:i:s");

include_once('dice.class.php');

$dice = new dice;

//validate emails and exit if email is wrong
/*foreach($output['emails'] as $value) { //Not working checkEmail always returns true!
if(! dice::checkEmail($value)) {
exit("fatal error: at least one email is spelled wrong. check: \"$value\" !");
}
}*/
// check if all emails are registered
try {
$dice->checkIfMailsAreRegistered($output['emails']);
} catch(exception $e) {
exit($e->getMessage());
}

//create dice
$output['dice'] = $dice->createdice($numdice, $numsides);

//encrypt the output array
$enc_array = $dice->encrypt_data($output);

//send email; if delivery fails the script is aborted!
$dice->sendEmail($output['emails'], $output['subject'], $output['dice'], $enc_array['iv'], $enc_array['data']);

//show dice
echo "your dice are: " . $output['dice'] . "<p><p>";
?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$output = array();

$send = $_POST['send'];
$numsides = $_POST['numsides'];
$numdice = $_POST['numdice'];
$output['subject'] = $_POST['subject'];
$email1 = $_POST['roller'];
$email2 = $_POST['gm'];

//check posted data
if(!is_numeric($numsides) || !is_numeric($numdice) || empty($output['subject']) || empty($email1)) {
exit("fatal error: wrong input!");

}
if(empty($email2)) {
exit("fatal error: no second email found. Please enter an email address into the Cc-field!");

}
//format multiple emails in one line
$emails1 = explode(" ", $email1);
$emails2 = explode(" ", $email2);

$output['emails'] = array_merge($emails1, $emails2);
// get exact server time
$output['time'] = date("Y-m-d H:i:s");


include_once('dice.class.php');

$dice = new dice;

//validate emails and exit if email is wrong
foreach($output['emails'] as $value) {
if(! dice::checkEmail($value)) {
exit("fatal error: at least one email is spelled wrong. check: \"$value\" !");
}
}

// check if all emails are registered
try{
$dice->checkIfMailsAreRegistered($output['emails']);
}
catch(exception $e) {
exit($e->getMessage());
}

//create dice
$output['dice'] = $dice->createdice($numdice, $numsides);

//update the stats in the database: number of requests and dice rolled
//$dice->updateStats($numdice);

//encrypt the output array
$enc_array = $dice->encrypt_data($output);

//send email; if delivery fails the script is aborted!
$dice->sendEmail($output['emails'], $output['subject'], $output['dice'], $enc_array['iv'], $enc_array['data']);

//show dice
echo "your dice are: " . $output['dice'] . "<p><p>";

?>
</body>
</html>
Expand Down
39 changes: 15 additions & 24 deletions dice/MARTI_verify.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>MARTI Verifyer</title>
</head>
<body>
<?php
include_once('dice.class.php');

if(!isset($_GET["iv"]) || !isset($_GET["enc"])){
exit("error: You used an invalid link!");
}

$iv = $_GET["iv"];
$enc = $_GET["enc"];

$dice = new dice();

$outputArray = $dice->decrypt_data(null, $iv, $enc);

echo "Dice were authentic: " . $outputArray['dice'];
?>
</body>
</html>
<?php
include_once('dice.class.php');

if(!isset($_GET["iv"]) || !isset($_GET["enc"]))
exit("error: You used an invalid link!");

$iv = $_GET["iv"];
$enc = $_GET["enc"];

$dice = new dice();

$outputArray = $dice->decrypt_data(null, $iv, $enc);

echo "Dice were authentic: " . $outputArray['dice'];
?>
Loading