function postFullSpot($user, $serverPrivKey, $newsgroup, $spot) { # instantiate the necessary objects $spotSigning = new SpotSigning(); /* * Create the spotnet from header part accrdoing to the following structure: * From: [Nickname] <[USER PUBLIC KEY]@[CAT][KEY-ID][SUBCAT].[SIZE].[RANDOM].[DATE].[CUSTOM-ID].[CUSTOM-VALUE].[SIGNATURE]> */ $spotHeader = $spot['category'] + 1 . $spot['key']; // Append the category and keyid # Process each subcategory and add them to the from header foreach ($spot['subcatlist'] as $subcat) { $spotHeader .= $subcat[0] . str_pad(substr($subcat, 1), 2, '0', STR_PAD_LEFT); } # foreach $spotHeader .= '.' . $spot['filesize']; $spotHeader .= '.' . 10; // some kind of magic number? $spotHeader .= '.' . time(); $spotHeader .= '.' . $spotSigning->makeRandomStr(4); $spotHeader .= '.' . $spotSigning->makeRandomStr(3); # If a tag is given, add it to the subject if (strlen(trim($spot['tag'])) > 0) { $spot['title'] = $spot['title'] . ' | ' . $spot['tag']; } # if # sign the header by using the users' key $header_signature = $spotSigning->signMessage($user['privatekey'], $spot['title'] . $spotHeader . $spot['poster']); # sign the XML with the users' key $xml_signature = $spotSigning->signMessage($user['privatekey'], $spot['spotxml']); # Extract the users' publickey $userPubKey = $spotSigning->getPublicKey($user['privatekey']); # Create the From header $spotnetFrom = $user['username'] . ' <' . $this->_spotParser->specialString($userPubKey['publickey']['modulo']) . '@'; $header = 'From: ' . $spotnetFrom . $spotHeader . '.' . $this->_spotParser->specialString($header_signature['signature']) . ">\r\n"; # Add the Spotnet XML file, but split it in chunks of 900 characters $tmpXml = explode("\r\n", chunk_split($spot['spotxml'], 900)); foreach ($tmpXml as $xmlChunk) { if (strlen(trim($xmlChunk)) > 0) { $header .= 'X-XML: ' . $xmlChunk . "\r\n"; } # if } # foreach $header .= 'X-XML-Signature: ' . $this->_spotParser->specialString($xml_signature['signature']) . "\r\n"; # post the message return $this->postSignedMessage($user, $serverPrivKey, $newsgroup, $spot, $header); }
function postComment($user, $serverPrivKey, $newsgroup, $title, $comment) { # FIXME: Het aantal nullen (minimaal 4) instelbaar maken via settings.php # instantieer de benodigde objecten $spotSigning = new SpotSigning(); $spotParser = new SpotParser(); # sign het messageid $user_signature = $spotSigning->signMessage($user['privatekey'], '<' . $comment['newmessageid'] . '>'); # ook door de php server $server_signature = $spotSigning->signMessage($serverPrivKey, $comment['newmessageid']); $header = 'From: ' . $user['username'] . " <" . trim($user['username']) . '@spot.net>' . "\r\n"; $header .= 'Subject: Re: ' . $title . "\r\n"; $header .= 'Newsgroups: ' . $newsgroup . "\r\n"; $header .= 'Message-ID: <' . $comment['newmessageid'] . ">\r\n"; $header .= 'References: <' . $comment['inreplyto']. ">\r\n"; $header .= 'X-User-Signature: ' . $spotParser->specialString($user_signature['signature']) . "\r\n"; $header .= 'X-Server-Signature: ' . $spotParser->specialString($server_signature['signature']) . "\r\n"; $header .= 'X-User-Key: ' . $spotSigning->pubkeyToXml($user_signature['publickey']) . "\r\n"; $header .= 'X-Server-Key: ' . $spotSigning->pubkeyToXml($server_signature['publickey']) . "\r\n"; $header .= 'X-User-Rating: ' . (int) $comment['rating'] . "\r\n"; # $header .= 'X-User-Avatar: ' # Message-ID van een avatar # $header .= 'X-User-Gravatar: ' # Hashcode van een Gravatar $header .= "X-Newsreader: SpotWeb v" . SPOTWEB_VERSION . "\r\n"; $header .= "X-No-Archive: yes\r\n"; return $this->post(array($header, $comment['body'])); } # postComment