Code Search for Developers
 
 
  

Stream.php from Astrum Futura at Krugle


Show Stream.php syntax highlighted

<?php

/**
 * Provides a custom registered stream for use with a transport protocol
 * This is part of the Swift Mailer unit testing stuff.
 * It uses a command processor to do that actual reading/writing
 */
class Swift_Stream
{
	/**
	 * The command processor
	 * @var object singleton processor
	 */
	private $processor;
	
	/**
	 * PHP's call back for fopen() actions on the fake stream
	 */
	public function stream_open($path, $mode, $options, &$opened_path)
	{
		$this->processor = Swift_Stream_Processor::getInstance();
		$this->processor->isOpen = true;
		return $this->processor->isOpen;
	}
	/**
	 * PHP Callback for fread() fgets() etc
	 */
	public function stream_read($size)
	{
		return $this->processor->getResponse($size);
	}
	/**
	 * fwrite() callback
	 */
	public function stream_write($string)
	{
		if ($this->processor->isOpen)
		{
			$this->processor->setCommand($string);
			return strlen($string);
		}
		else return 0;
	}
	/**
	 * Only here to prevent errors
	 */
	public function stream_eof()
	{
		//Does nothing... SMTP doesn't implement it
		// It's vital we can work this out ourselves
	}
	/**
	 * Singletons never really get destroyed much, this just nulls it out
	 */
	public function stream_close()
	{
		$this->processor->destroy();
	}
}

//Registers a stream which can be accessed as swift://url
stream_wrapper_register('swift', 'Swift_Stream');

?>



See more files for this project here

Astrum Futura

Multiplayer space strategy game written in PHP5 with the Zend Framework. User interface uses Javascript/AJAX for dynamic interaction. Players compete across a hexagonal map of 10,000 sectors, planets, stars and other locations through trade and combat.

Project homepage: http://sourceforge.net/projects/astrumfutura
Programming language(s): PHP,XML
License: other

  Authenticator/
    CRAMMD5.php
    LOGIN.php
    PLAIN.php
    POP3SMTP_.php
    README
  Connection/
    Multi.php
    NativeMail.php
    Rotator.php
    SMTP.php
    Sendmail.php
  Plugin/
    AntiFlood.php
    ConnectionRotator.php
    Errors.php
    Example.php
    Template.php
  Stream/
    MailProxy.php
    Processor.php
  Stream.php