Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasWiesner committed Feb 15, 2012
1 parent c2cc150 commit 01663af
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
65 changes: 42 additions & 23 deletions incomingMail.php
Expand Up @@ -9,38 +9,57 @@ function myerror($msg) {
exit;
}

if(!isset($_POST['from']) || !isset($_POST['to']) || !isset($_POST['plain'])) {
myerror("missing data");
function verifySignature(){
$provided = $_POST['signature'];
unset($_POST['signature']);

$str = '';
foreach ($_POST as $key => $value){
$str .= $value . $config['CLOUDMAILIN_SECRET'];
}

$signature = md5($str);

print $provided . "\n";
print $signature . "\n";
}

$from = $_POST['from'];
$to = $_POST['to'];
$subject = $_POST['subject'];
$plain = $_POST['plain'];
$html = $_POST['html'];
$x_remote_ip = $_POST['x_remote_ip'];

$dsn = sprintf('mysql:host=%s;dbname=%s', $config['MYSQL_HOSTNAME'], $config['MYSQL_DATABASE']);
$pdo = new PDO($dsn, $config['MYSQL_USERNAME'], $config['MYSQL_PASSWORD']);
if (!$pdo) {
myerror("No database connection");
}
function storeMail() {
$from = $_POST['from'];
$to = $_POST['to'];
$subject = $_POST['subject'];
$plain = $_POST['plain'];
$html = $_POST['html'];
$x_remote_ip = $_POST['x_remote_ip'];

$insert = <<<SQL
$dsn = sprintf('mysql:host=%s;dbname=%s', $config['MYSQL_HOSTNAME'], $config['MYSQL_DATABASE']);
$pdo = new PDO($dsn, $config['MYSQL_USERNAME'], $config['MYSQL_PASSWORD']);
if (!$pdo) {
myerror("No database connection");
}

$insert = <<<SQL
INSERT INTO `mail`
(`date`, `from`, `to`, `subject`, `plain`, `html`, `x_remote_ip`)
VALUES
(NOW(), :from, :to, :subject, :plain, :html, :x_remote_ip)
SQL;
$insertStmt = $pdo->prepare($insert);
$insertStmt->bindValue(':from', $from, PDO::PARAM_STR);
$insertStmt->bindValue(':to', $to, PDO::PARAM_STR);
$insertStmt->bindValue(':subject', $subject, PDO::PARAM_STR);
$insertStmt->bindValue(':plain', $plain, PDO::PARAM_STR);
$insertStmt->bindValue(':html', $html, PDO::PARAM_STR);
$insertStmt->bindValue(':x_remote_ip', $x_remote_ip, PDO::PARAM_STR);
return $insertStmt->execute();
}

if(!isset($_POST['from']) || !isset($_POST['to']) || !isset($_POST['plain'])) {
myerror("missing data");
}


$insertStmt = $pdo->prepare($insert);
$insertStmt->bindValue(':from', $from, PDO::PARAM_STR);
$insertStmt->bindValue(':to', $to, PDO::PARAM_STR);
$insertStmt->bindValue(':subject', $subject, PDO::PARAM_STR);
$insertStmt->bindValue(':plain', $plain, PDO::PARAM_STR);
$insertStmt->bindValue(':html', $html, PDO::PARAM_STR);
$insertStmt->bindValue(':x_remote_ip', $x_remote_ip, PDO::PARAM_STR);
$execute = $insertStmt->execute();
storeMail();

if($execute){
header("HTTP/1.0 200 OK");
Expand Down
14 changes: 12 additions & 2 deletions index.php
@@ -1,3 +1,13 @@
<?php
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<h1>Mail List</h1>
<pre style="disply:block;background-color:silver;border:1px groove;padding:5px;">
<?php
require 'config.php';
var_dump($creds);
print_r($creds);
?>
</pre>
</body>
</html>

0 comments on commit 01663af

Please sign in to comment.