예제 #1
0
 function getCleanRandomString($len)
 {
     $spotParser = new SpotParser();
     $spotSigning = new SpotSigning();
     return substr($spotParser->specialString(base64_encode($spotSigning->makeRandomStr($len))), 0, $len);
 }
예제 #2
0
		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