Skip to content

Commit

Permalink
nntpchan: work around php nonsense
Browse files Browse the repository at this point in the history
  • Loading branch information
czaks committed Aug 19, 2016
1 parent 78cca22 commit b3aa079
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion inc/nntpchan/nntpchan.php
Expand Up @@ -124,7 +124,7 @@ function post2nntp($post, $msgid) {
$query->execute() or error(db_error($query));

if ($result = $query->fetch(PDO::FETCH_ASSOC)) {
return ">>".substr($result['message_id_digest'], 0, 16);
return ">>".substr($result['message_id_digest'], 0, 18);
}
else {
return $o[0]; // Should send URL imo
Expand Down
29 changes: 17 additions & 12 deletions post.php
Expand Up @@ -88,31 +88,36 @@
$content = file_get_contents("php://input");
}
elseif ($ct == 'multipart/mixed' || $ct == 'multipart/form-data') {
_syslog(LOG_INFO, "MM: Files: ".print_r($GLOBALS, true));
_syslog(LOG_INFO, "MM: Files: ".print_r($GLOBALS, true)); // Debug

$content = '';

$tmpfiles = $_FILES['attachment'];
foreach ($tmpfiles as $id => $file) {
if ($file['type'] == 'text/plain') {
$content .= file_get_contents($file['tmp_name']);
unset($_FILES['attachment'][$id]);
$newfiles = array();
foreach ($_FILES['attachment']['error'] as $id => $error) {
if ($_FILES['attachment']['type'][$id] == 'text/plain') {
$content .= file_get_contents($_FILES['attachment']['tmp_name'][$id]);
}
elseif ($file['type'] == 'message/rfc822') { // Signed message, ignore for now
unset($_FILES['attachment'][$id]);
elseif ($_FILES['attachment']['type'][$id] == 'message/rfc822') { // Signed message, ignore for now
}
else { // A real attachment :^)
$file = array();
$file['name'] = $_FILES['attachment']['name'][$id];
$file['type'] = $_FILES['attachment']['type'][$id];
$file['size'] = $_FILES['attachment']['size'][$id];
$file['tmp_name'] = $_FILES['attachment']['tmp_name'][$id];
$file['error'] = $_FILES['attachment']['error'][$id];

$newfiles["file$id"] = $file;
}
}

$_FILES = $_FILES['attachment'];


$_FILES = $newfiles;
}
else {
error("NNTPChan: Wrong mime type: $ct");
}

$_POST['subject'] = isset($_GET['Subject']) ? $_GET['Subject'] : '';
$_POST['subject'] = isset($_GET['Subject']) ? ($_GET['Subject'] == 'None' ? '' : $_GET['Subject']) : '';
$_POST['board'] = $xboard;

if (isset ($_GET['From'])) {
Expand Down

0 comments on commit b3aa079

Please sign in to comment.