Browse Source

Remove fuel package source code - auth and email

Hamilton Turner 10 years ago
parent
commit
03428473dc
22 changed files with 0 additions and 3885 deletions
  1. 0 10
      frameworks/PHP/php-fuel/fuel/packages/auth/.gitignore
  2. 0 35
      frameworks/PHP/php-fuel/fuel/packages/auth/bootstrap.php
  3. 0 430
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth.php
  4. 0 95
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/acl/driver.php
  5. 0 81
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/acl/simpleacl.php
  6. 0 123
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/driver.php
  7. 0 127
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/group/driver.php
  8. 0 86
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/group/simplegroup.php
  9. 0 249
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/login/driver.php
  10. 0 545
      frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/login/simpleauth.php
  11. 0 26
      frameworks/PHP/php-fuel/fuel/packages/auth/config/auth.php
  12. 0 99
      frameworks/PHP/php-fuel/fuel/packages/auth/config/simpleauth.php
  13. 0 38
      frameworks/PHP/php-fuel/fuel/packages/auth/examples/001_auth_create_simpleauth_table.php
  14. 0 49
      frameworks/PHP/php-fuel/fuel/packages/email/bootstrap.php
  15. 0 105
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email.php
  16. 0 1160
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver.php
  17. 0 34
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/mail.php
  18. 0 35
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/noop.php
  19. 0 56
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/sendmail.php
  20. 0 250
      frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/smtp.php
  21. 0 127
      frameworks/PHP/php-fuel/fuel/packages/email/config/email.php
  22. 0 125
      frameworks/PHP/php-fuel/fuel/packages/email/readme.md

+ 0 - 10
frameworks/PHP/php-fuel/fuel/packages/auth/.gitignore

@@ -1,10 +0,0 @@
-*~
-*.bak
-Thumbs.db
-desktop.ini
-.DS_Store
-.buildpath
-.project
-.settings
-nbproject/
-.idea

+ 0 - 35
frameworks/PHP/php-fuel/fuel/packages/auth/bootstrap.php

@@ -1,35 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-
-Autoloader::add_core_namespace('Auth');
-
-Autoloader::add_classes(array(
-	'Auth\\Auth'           => __DIR__.'/classes/auth.php',
-	'Auth\\AuthException'  => __DIR__.'/classes/auth.php',
-
-	'Auth\\Auth_Driver'  => __DIR__.'/classes/auth/driver.php',
-
-	'Auth\\Auth_Acl_Driver'     => __DIR__.'/classes/auth/acl/driver.php',
-	'Auth\\Auth_Acl_SimpleAcl'  => __DIR__.'/classes/auth/acl/simpleacl.php',
-
-	'Auth\\Auth_Group_Driver'       => __DIR__.'/classes/auth/group/driver.php',
-	'Auth\\Auth_Group_SimpleGroup'  => __DIR__.'/classes/auth/group/simplegroup.php',
-
-	'Auth\\Auth_Login_Driver'          => __DIR__.'/classes/auth/login/driver.php',
-	'Auth\\Auth_Login_SimpleAuth'      => __DIR__.'/classes/auth/login/simpleauth.php',
-	'Auth\\SimpleUserUpdateException'  => __DIR__.'/classes/auth/login/simpleauth.php',
-	'Auth\\SimpleUserWrongPassword'    => __DIR__.'/classes/auth/login/simpleauth.php',
-));
-
-
-/* End of file bootstrap.php */

+ 0 - 430
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth.php

@@ -1,430 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-class AuthException extends \FuelException {}
-
-
-/**
- * Auth
- *
- * @package     Fuel
- * @subpackage  Auth
- */
-class Auth
-{
-
-	/**
-	 * @var  Auth_Login_Driver	default instance
-	 */
-	protected static $_instance = null;
-
-	/**
-	 * @var  Array  contains references if multiple were loaded
-	 */
-	protected static $_instances = array();
-
-	/**
-	 * @var  Array  Login drivers that verified a current login
-	 */
-	protected static $_verified = array();
-
-	/**
-	 * @var  bool  Whether to verify multiple
-	 */
-	protected static $_verify_multiple = false;
-
-	/**
-	 * @var  Array  subdriver registry, takes driver name and method for checking it
-	 */
-	protected static $_drivers = array(
-		'group'  => 'member',
-		'acl'    => 'has_access',
-	);
-
-	public static function _init()
-	{
-		\Config::load('auth', true);
-
-		// Whether to allow multiple drivers of any type, defaults to not allowed
-		static::$_verify_multiple = \Config::get('auth.verify_multiple_logins', false);
-
-		foreach((array) \Config::get('auth.driver', array()) as $driver => $config)
-		{
-			$config = is_int($driver)
-				? array('driver' => $config)
-				: array_merge($config, array('driver' => $driver));
-			static::forge($config);
-		}
-		// set the first (or only) as the default instance for static usage
-		if ( ! empty(static::$_instances))
-		{
-			static::$_instance = reset(static::$_instances);
-			static::check();
-		}
-	}
-
-	/**
-	 * Load a login driver to the array of loaded drivers
-	 *
-	 * @param   Array  settings for the new driver
-	 * @throws  AuthException  on driver load failure
-	 */
-	public static function forge($custom = array())
-	{
-		// Driver is given as array key or just string in custom
-		$custom = ! is_array($custom) ? array('driver' => $custom) : $custom;
-		$config = \Config::get('auth.'.$custom['driver'].'_config', array());
-		$config = array_merge($config, $custom);
-
-		// Driver must be set
-		if (empty($config['driver']) || ! is_string($config['driver']))
-		{
-			throw new \AuthException('No auth driver given.');
-		}
-
-		// determine the driver to load
-		$driver = \Auth_Login_Driver::forge($config);
-
-		// get the driver's cookie name
-		$id = $driver->get_id();
-
-		// do we already have a driver instance for this cookie?
-		if (isset(static::$_instances[$id]))
-		{
-			// if so, they must be using the same driver class!
-			$class = get_class($driver);
-			if ( ! static::$_instances[$id] instanceof $class)
-			{
-				throw new \AuthException('You can not instantiate two different login drivers using the same id "'.$id.'"');
-			}
-		}
-		else
-		{
-			// store this instance
-			static::$_instances[$id] = $driver;
-		}
-
-		return static::$_instances[$id];
-	}
-
-	/**
-	 * Prevent instantiation
-	 */
-	final private function __construct() {}
-
-	/**
-	 * Remove individual driver, or all drivers of $type
-	 *
-	 * @param   string  driver id or null for default driver
-	 * @throws  AuthException  when $driver_id isn't valid or true
-	 */
-	public static function unload($driver_id = null)
-	{
-		if ($driver_id === null && ! empty(static::$_instance))
-		{
-			unset(static::$_instances[static::$_instance->get_id()]);
-			static::$_instance = null;
-			return true;
-		}
-		elseif (array_key_exists($driver_id, static::$_instances))
-		{
-			return false;
-		}
-
-		unset(static::$_instances[$driver_id]);
-		return true;
-	}
-
-	/**
-	 * Return a specific driver, or the default instance (is created if necessary)
-	 *
-	 * @param   string  driver id
-	 * @return  Auth_Login_Driver
-	 */
-	public static function instance($instance = null)
-	{
-		if ($instance !== null)
-		{
-			if ( ! array_key_exists($instance, static::$_instances))
-			{
-				return false;
-			}
-
-			return static::$_instances[$instance];
-		}
-
-		if (static::$_instance === null)
-		{
-			static::$_instance = static::forge();
-		}
-
-		return static::$_instance;
-	}
-
-	/**
-	 * Check login drivers for validated login
-	 *
-	 * @param   string|Array  specific driver or drivers, in this case it will always terminate after first success
-	 * @return  bool
-	 */
-	public static function check($specific = null)
-	{
-		$drivers = $specific === null ? static::$_instances : (array) $specific;
-
-		foreach ($drivers as $i)
-		{
-			if ( ! static::$_verify_multiple && ! empty(static::$_verified))
-			{
-				return true;
-			}
-
-			$i = $i instanceof Auth_Login_Driver ? $i : static::instance($i);
-			if ( ! array_key_exists($i->get_id(), static::$_verified))
-			{
-				$i->check();
-			}
-
-			if ($specific)
-			{
-				if (array_key_exists($i->get_id(), static::$_verified))
-				{
-					return true;
-				}
-			}
-		}
-
-		return $specific === null && ! empty(static::$_verified);
-	}
-
-	/**
-	 * Get verified driver or all verified drivers
-	 * returns false when specific driver has not validated
-	 * when all were requested and none validated an empty array is returned
-	 *
-	 * @param   null|string  driver id or null for all verified driver in an array
-	 * @return  Array|Auth_Login_Driver|false
-	 */
-	public static function verified($driver = null)
-	{
-		if ($driver === null)
-		{
-			return static::$_verified;
-		}
-
-		if ( ! array_key_exists($driver, static::$_verified))
-		{
-			return false;
-		}
-
-		return static::$_verified[$driver];
-	}
-
-	/**
-	 * Logs out all current logged in drivers
-	 */
-	public static function logout()
-	{
-		foreach (static::$_verified as $v)
-		{
-			$v->logout();
-		}
-
-		static::$_verified = array();
-	}
-
-	/**
-	 * Register verified Login driver
-	 *
-	 * @param  Auth_Login_Driver
-	 */
-	public static function _register_verified(Auth_Login_Driver $driver)
-	{
-		static::$_verified[$driver->get_id()] = $driver;
-	}
-
-	/**
-	 * Unregister verified Login driver
-	 *
-	 * @param  Auth_Login_Driver
-	 */
-	public static function _unregister_verified(Auth_Login_Driver $driver)
-	{
-		unset(static::$_verified[$driver->get_id()]);
-	}
-
-	/**
-	 * Register a new driver type
-	 *
-	 * @param   string  name of the driver type, may not conflict with class method name
-	 * @param   string  name of the method to use for checking this type of driver, also cannot conflict with method
-	 * @return  bool
-	 */
-	public static function register_driver_type($type, $check_method)
-	{
-		$driver_exists = ! is_string($type)
-						|| array_key_exists($type, static::$_drivers)
-						|| method_exists(get_called_class(), $check_method)
-						|| in_array($type, array('login', 'group', 'acl'));
-		$method_exists = ! is_string($type)
-						|| array_search($check_method, static::$_drivers)
-						|| method_exists(get_called_class(), $type);
-
-		if ($driver_exists && static::$_drivers[$type] == $check_method)
-		{
-			return true;
-		}
-
-		if ($driver_exists || $method_exists)
-		{
-			\Error::notice('Cannot add driver type, its name conflicts with another driver or method.');
-			return false;
-		}
-
-		static::$_drivers[$type] = $check_method;
-		return true;
-	}
-
-	/**
-	 * Unregister a driver type
-	 *
-	 * @param   string  name of the driver type
-	 * @return  bool
-	 */
-	public static function unregister_driver_type($type)
-	{
-		if (in_array('login', 'group', 'acl'))
-		{
-			\Error::notice('Cannot remove driver type, included drivers login, group and acl cannot be removed.');
-			return false;
-		}
-
-		unset(static::$_drivers[$type]);
-		return true;
-	}
-
-	/**
-	 * Magic method used to retrieve driver instances and check them for validity
-	 *
-	 * @param   string
-	 * @param   array
-	 * @return  mixed
-	 * @throws  BadMethodCallException
-	 */
-	public static function __callStatic($method, $args)
-	{
-		$args = array_pad($args, 3, null);
-		if (array_key_exists($method, static::$_drivers))
-		{
-			return static::_driver_instance($method, $args[0]);
-		}
-		if ($type = array_search($method, static::$_drivers))
-		{
-			return static::_driver_check($type, $args[0], $args[1], @$args[2]);
-		}
-		if (static::$_verify_multiple !== true and method_exists(static::$_instance, $method))
-		{
-			return call_user_func_array(array(static::$_instance, $method), $args);
-		}
-
-		throw new \BadMethodCallException('Invalid method: '.get_called_class().'::'.$method);
-	}
-
-	/**
-	 * Retrieve a loaded driver instance
-	 * (loading must be done by other driver class)
-	 *
-	 * @param   string       driver type
-	 * @param   string|true  driver id or true for an array of all loaded drivers
-	 * @return  Auth_Driver|array
-	 */
-	protected static function _driver_instance($type, $instance)
-	{
-		$class = 'Auth_'.ucfirst($type).'_Driver';
-		return $class::instance($instance);
-	}
-
-	/**
-	 * Check driver
-	 *
-	 * @param   string  driver type
-	 * @param   mixed   condition for which the driver is checked
-	 * @param   string  driver id or null to check all
-	 * @param   Array   identifier to check, should default to current user or relation therof and be
-	 *                  in the form of array(driver_id, user_id)
-	 * @return bool
-	 */
-	public static function _driver_check($type, $condition, $driver = null, $entity = null)
-	{
-		$method = static::$_drivers[$type];
-		if ($driver === null)
-		{
-			if ($entity === null)
-			{
-				if ( ! empty(static::$_verified))
-				{
-					foreach (static::$_verified as $v)
-					{
-						if ($v->$method($condition))
-						{
-							return true;
-						}
-					}
-				}
-				else
-				{
-					foreach (static::$_instances as $i)
-					{
-						if ($i->guest_login() and $i->$method($condition))
-						{
-							return true;
-						}
-					}
-				}
-			}
-			else
-			{
-				foreach (static::$_instances as $i)
-				{
-					if ($i->$method($condition, null, $entity))
-					{
-						return true;
-					}
-				}
-			}
-			return false;
-		}
-		else
-		{
-			if ($entity === null)
-			{
-				foreach (static::$_verified as $v)
-				{
-					if (static::$type($driver)->$method($condition))
-					{
-						return true;
-					}
-				}
-			}
-			elseif (static::$type($driver)->$method($condition, $entity))
-			{
-				return true;
-			}
-
-			return false;
-		}
-	}
-}
-
-/* end of file auth.php */

+ 0 - 95
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/acl/driver.php

@@ -1,95 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-abstract class Auth_Acl_Driver extends \Auth_Driver
-{
-
-	/**
-	 * @var	Auth_Driver	default instance
-	 */
-	protected static $_instance = null;
-
-	/**
-	 * @var	array	contains references if multiple were loaded
-	 */
-	protected static $_instances = array();
-
-	public static function forge(array $config = array())
-	{
-		// default driver id to driver name when not given
-		! array_key_exists('id', $config) && $config['id'] = $config['driver'];
-
-		$class = \Inflector::get_namespace($config['driver']).'Auth_Acl_'.ucfirst(\Inflector::denamespace($config['driver']));
-		$driver = new $class($config);
-		static::$_instances[$driver->get_id()] = $driver;
-		is_null(static::$_instance) and static::$_instance = $driver;
-
-		foreach ($driver->get_config('drivers', array()) as $type => $drivers)
-		{
-			foreach ($drivers as $d => $custom)
-			{
-				$custom = is_int($d)
-					? array('driver' => $custom)
-					: array_merge($custom, array('driver' => $d));
-				$class = 'Auth_'.ucfirst($type).'_Driver';
-				$class::forge($custom);
-			}
-		}
-
-		return $driver;
-	}
-
-	/**
-	 * Parses a conditions string into it's array equivalent
-	 *
-	 * @rights	mixed	conditions array or string
-	 * @return	array	conditions array formatted as array(area, rights)
-	 *
-	 */
-	public static function _parse_conditions($rights)
-	{
-		if (is_array($rights))
-		{
-			return $rights;
-		}
-
-		if ( ! is_string($rights) or strpos($rights, '.') === false)
-		{
-			throw new \InvalidArgumentException('Given rights where not formatted proppery. Formatting should be like area.right or area.[right, other_right]. Received: '.$rights);
-		}
-
-		list($area, $rights) = explode('.', $rights);
-
-		if (substr($rights, 0, 1) == '[' and substr($rights, -1, 1) == ']')
-		{
-			$rights = preg_split('#( *)?,( *)?#', trim(substr($rights, 1, -1)));
-		}
-
-		return array($area, $rights);
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Check access rights
-	 *
-	 * @param	mixed	condition to check for access
-	 * @param	mixed	user or group identifier in the form of array(driver_id, id)
-	 * @return	bool
-	 */
-	abstract public function has_access($condition, Array $entity);
-}
-
-/* end of file driver.php */

+ 0 - 81
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/acl/simpleacl.php

@@ -1,81 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-class Auth_Acl_SimpleAcl extends \Auth_Acl_Driver
-{
-
-	protected static $_valid_roles = array();
-
-	public static function _init()
-	{
-		static::$_valid_roles = array_keys(\Config::get('simpleauth.roles'));
-	}
-
-	public function has_access($condition, Array $entity)
-	{
-		$group = \Auth::group($entity[0]);
-
-		$condition = static::_parse_conditions($condition);
-
-		if ( ! is_array($condition) || empty($group) || ! is_callable(array($group, 'get_roles')))
-		{
-			return false;
-		}
-
-		$area    = $condition[0];
-		$rights  = (array) $condition[1];
-		$current_roles  = $group->get_roles($entity[1]);
-		$current_rights = array();
-		if (is_array($current_roles))
-		{
-			$roles = \Config::get('simpleauth.roles', array());
-			array_key_exists('#', $roles) && array_unshift($current_roles, '#');
-			foreach ($current_roles as $r_role)
-			{
-				// continue if the role wasn't found
-				if ( ! array_key_exists($r_role, $roles))
-				{
-					continue;
-				}
-				$r_rights = $roles[$r_role];
-
-				// if one of the roles has a negative or positive wildcard return it without question
-				if (is_bool($r_rights))
-				{
-					return $r_rights;
-				}
-				// if there are roles for the current area, merge them with earlier fetched roles
-				elseif (array_key_exists($area, $r_rights))
-				{
-					$current_rights = array_unique(array_merge($current_rights, $r_rights[$area]));
-				}
-			}
-		}
-
-		// start checking rights, terminate false when right not found
-		foreach ($rights as $right)
-		{
-			if ( ! in_array($right, $current_rights))
-			{
-				return false;
-			}
-		}
-
-		// all necessary rights were found, return true
-		return true;
-	}
-}
-
-/* end of file simpleacl.php */

+ 0 - 123
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/driver.php

@@ -1,123 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-abstract class Auth_Driver
-{
-
-	/**
-	 * @var	Auth_Driver
-	 * THIS MUST BE DEFINED IN THE BASE EXTENSION
-	 */
-	// protected static $_instance = null;
-
-	/**
-	 * @var	array	contains references if multiple were loaded
-	 * THIS MUST BE DEFINED IN THE BASE EXTENSION
-	 */
-	// protected static $_instances = array();
-
-	public static function forge(array $config = array())
-	{
-		throw new \AuthException('Driver must have a factory method extension.');
-	}
-
-	/**
-	 * Return a specific driver, or the default instance
-	 *
-	 * @param	string	driver id
-	 * @return	Auth_Driver
-	 */
-	public static function instance($instance = null)
-	{
-		if ($instance === true)
-		{
-			return static::$_instances;
-		}
-		elseif ($instance !== null)
-		{
-			if ( ! array_key_exists($instance, static::$_instances))
-			{
-				return false;
-			}
-
-			return static::$_instances[$instance];
-		}
-
-		return static::$_instance;
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * @var	string	instance identifier
-	 */
-	protected $id;
-
-	/**
-	 * @var	array	given configuration array
-	 */
-	protected $config = array();
-
-	protected function __construct(Array $config)
-	{
-		$this->id = $config['id'];
-		$this->config = array_merge($this->config, $config);
-	}
-
-	/**
-	 * Get driver instance ID
-	 *
-	 * @return string
-	 */
-	public function get_id()
-	{
-		return (string) $this->id;
-	}
-
-	/**
-	 * Create or change config value
-	 *
-	 * @param	string
-	 * @param	mixed
-	 */
-	public function set_config($key, $value)
-	{
-		$this->config[$key] = $value;
-	}
-
-	/**
-	 * Retrieve config value
-	 *
-	 * @param	string
-	 * @param	mixed	return when key doesn't exist
-	 * @return	mixed
-	 */
-	public function get_config($key, $default = null)
-	{
-		return array_key_exists($key, $this->config) ? $this->config[$key] : $default;
-	}
-
-	/**
-	 * Whether this driver supports guest login
-	 *
-	 * @return  bool
-	 */
-	public function guest_login()
-	{
-		return false;
-	}
-}
-
-/* end of file driver.php */

+ 0 - 127
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/group/driver.php

@@ -1,127 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-abstract class Auth_Group_Driver extends \Auth_Driver
-{
-
-	/**
-	 * @var	Auth_Driver
-	 */
-	protected static $_instance = null;
-
-	/**
-	 * @var	array	contains references if multiple were loaded
-	 */
-	protected static $_instances = array();
-
-	public static function forge(array $config = array())
-	{
-		// default driver id to driver name when not given
-		! array_key_exists('id', $config) && $config['id'] = $config['driver'];
-
-		$class = \Inflector::get_namespace($config['driver']).'Auth_Group_'.ucfirst(\Inflector::denamespace($config['driver']));
-		$driver = new $class($config);
-		static::$_instances[$driver->get_id()] = $driver;
-		is_null(static::$_instance) and static::$_instance = $driver;
-
-		foreach ($driver->get_config('drivers', array()) as $type => $drivers)
-		{
-			foreach ($drivers as $d => $custom)
-			{
-				$custom = is_int($d)
-					? array('driver' => $custom)
-					: array_merge($custom, array('driver' => $d));
-				$class = 'Auth_'.ucfirst($type).'_Driver';
-				$class::forge($custom);
-			}
-		}
-
-		return $driver;
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Verify Acl access
-	 *
-	 * @param	mixed	condition to validate
-	 * @param	string	acl driver id or null to check all
-	 * @param	array	user identifier to check in form array(driver_id, user_id)
-	 * @return	bool
-	 */
-	public function has_access($condition, $driver, $group = null)
-	{
-		// When group was given just check the group
-		if (is_array($group))
-		{
-			if ($driver === null)
-			{
-				foreach (\Auth::acl(true) as $acl)
-				{
-					if ($acl->has_access($condition, $group))
-					{
-						return true;
-					}
-				}
-
-				return false;
-			}
-
-			return \Auth::acl($driver)->has_access($condition, $group);
-		}
-
-		// When no group was given check all logged in users
-		foreach (\Auth::verified() as $v)
-		{
-			// ... and check all those their groups
-			$gs = $v->get_groups();
-			foreach ($gs as $g_id)
-			{
-				// ... and try to validate if its group is this one
-				if ($this instanceof $g_id[0])
-				{
-					if ($this->has_access($condition, $driver, $g_id))
-					{
-						return true;
-					}
-				}
-			}
-		}
-
-		// when nothing validated yet: it has failed to
-		return false;
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Check membership of given users
-	 *
-	 * @param	mixed	condition to check for access
-	 * @param	array	user identifier in the form of array(driver_id, user_id), or null for logged in
-	 * @return	bool
-	 */
-	abstract public function member($group, $user = null);
-
-	/**
-	 * Fetch the display name of the given group
-	 *
-	 * @param	mixed	group condition to check
-	 * @return	string
-	 */
-	abstract public function get_name($group);
-}
-
-/* end of file driver.php */

+ 0 - 86
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/group/simplegroup.php

@@ -1,86 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-class Auth_Group_SimpleGroup extends \Auth_Group_Driver
-{
-
-	public static $_valid_groups = array();
-
-	public static function _init()
-	{
-		static::$_valid_groups = array_keys(\Config::get('simpleauth.groups', array()));
-	}
-
-	protected $config = array(
-		'drivers' => array('acl' => array('SimpleAcl'))
-	);
-
-	public function member($group, $user = null)
-	{
-		if ($user === null)
-		{
-			$groups = \Auth::instance()->get_groups();
-		}
-		else
-		{
-			$groups = \Auth::instance($user[0])->get_groups();
-		}
-
-		if ( ! $groups || ! in_array((int) $group, static::$_valid_groups))
-		{
-			return false;
-		}
-
-		return in_array(array($this->id, $group), $groups);
-	}
-
-	public function get_name($group = null)
-	{
-		if ($group === null)
-		{
-			if ( ! $login = \Auth::instance() or ! is_array($groups = $login->get_groups()))
-			{
-				return false;
-			}
-			$group = isset($groups[0][1]) ? $groups[0][1] : null;
-		}
-
-		return \Config::get('simpleauth.groups.'.$group.'.name', null);
-	}
-
-	public function get_roles($group = null)
-	{
-		// When group is empty, attempt to get groups from a current login
-		if ($group === null)
-		{
-			if ( ! $login = \Auth::instance()
-				or ! is_array($groups = $login->get_groups())
-				or ! isset($groups[0][1]))
-			{
-				return array();
-			}
-			$group = $groups[0][1];
-		}
-		elseif ( ! in_array((int) $group, static::$_valid_groups))
-		{
-			return array();
-		}
-
-		$groups = \Config::get('simpleauth.groups');
-		return $groups[(int) $group]['roles'];
-	}
-}
-
-/* end of file simplegroup.php */

+ 0 - 249
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/login/driver.php

@@ -1,249 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-abstract class Auth_Login_Driver extends \Auth_Driver
-{
-
-	/**
-	 * @var  Auth_Driver	default instance
-	 */
-	protected static $_instance = null;
-
-	/**
-	 * @var  array  contains references if multiple were loaded
-	 */
-	protected static $_instances = array();
-
-	public static function forge(array $config = array())
-	{
-		// default driver id to driver name when not given
-		! array_key_exists('id', $config) && $config['id'] = $config['driver'];
-
-		$class = \Inflector::get_namespace($config['driver']).'Auth_Login_'.ucfirst(\Inflector::denamespace($config['driver']));
-		$driver = new $class($config);
-		static::$_instances[$driver->get_id()] = $driver;
-		is_null(static::$_instance) and static::$_instance = $driver;
-
-		foreach ($driver->get_config('drivers', array()) as $type => $drivers)
-		{
-			foreach ($drivers as $d => $custom)
-			{
-				$custom = is_int($d)
-					? array('driver' => $custom)
-					: array_merge($custom, array('driver' => $d));
-				$class = 'Auth_'.ucfirst($type).'_Driver';
-				$class::forge($custom);
-			}
-		}
-
-		return $driver;
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * @var  array  config values
-	 */
-	protected $config = array();
-
-	/**
-	 * @var  object  PHPSecLib hash object
-	 */
-	private $hasher = null;
-
-	/**
-	 * Check for login
-	 * (final method to (un)register verification, work is done by _check())
-	 *
-	 * @return  bool
-	 */
-	final public function check()
-	{
-		if ( ! $this->perform_check())
-		{
-			\Auth::_unregister_verified($this);
-			return false;
-		}
-
-		\Auth::_register_verified($this);
-		return true;
-	}
-
-	/**
-	 * Return user info in an array, always includes email & screen_name
-	 * Additional fields can be requested in the first param or set in config,
-	 * all additional fields must have their own method "get_" + fieldname
-	 *
-	 * @param   array  additional fields
-	 * @return  array
-	 */
-	final public function get_user_array(Array $additional_fields = array())
-	{
-		$user = array(
-			'email'        => $this->get_email(),
-			'screen_name'  => $this->get_screen_name(),
-			'groups'       => $this->get_groups(),
-		);
-
-		$additional_fields = array_merge($this->config['additional_fields'], $additional_fields);
-		foreach($additional_fields as $af)
-		{
-			// only works if it actually can be fetched through a get_ method
-			if (is_callable(array($this, $method = 'get_'.$af)))
-			{
-				$user[$af] = $this->$method();
-			}
-		}
-		return $user;
-	}
-
-	/**
-	 * Verify Group membership
-	 *
-	 * @param   mixed   group identifier to check for membership
-	 * @param   string  group driver id or null to check all
-	 * @param   array   user identifier to check in form array(driver_id, user_id)
-	 * @return  bool
-	 */
-	public function member($group, $driver = null, $user = null)
-	{
-		$user = $user ?: $this->get_user_id();
-
-		if ($driver === null)
-		{
-			foreach (\Auth::group(true) as $g)
-			{
-				if ($g->member($group, $user))
-				{
-					return true;
-				}
-			}
-
-			return false;
-		}
-
-		return \Auth::group($driver)->member($group, $user);
-	}
-
-	/**
-	 * Verify Acl access
-	 *
-	 * @param   mixed   condition to validate
-	 * @param   string  acl driver id or null to check all
-	 * @param   array   user identifier to check in form array(driver_id, user_id)
-	 * @return  bool
-	 */
-	public function has_access($condition, $driver = null, $entity = null)
-	{
-		$entity = $entity ?: $this->get_user_id();
-
-		if ($driver === null)
-		{
-			foreach (\Auth::acl(true) as $acl)
-			{
-				if ($acl->has_access($condition, $entity))
-				{
-					return true;
-				}
-			}
-
-			return false;
-		}
-
-		return \Auth::acl($driver)->has_access($condition, $entity);
-	}
-
-	/**
-	 * Default password hash method
-	 *
-	 * @param   string
-	 * @return  string
-	 */
-	public function hash_password($password)
-	{
-		return base64_encode($this->hasher()->pbkdf2($password, \Config::get('auth.salt'), 10000, 32));
-	}
-
-	/**
-	 * Returns the hash object and creates it if necessary
-	 *
-	 * @return  PHPSecLib\Crypt_Hash
-	 */
-	public function hasher()
-	{
-		is_null($this->hasher) and $this->hasher = new \PHPSecLib\Crypt_Hash();
-
-		return $this->hasher;
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Perform the actual login check
-	 *
-	 * @return  bool
-	 */
-	abstract protected function perform_check();
-
-	/**
-	 * Perform the actual login check
-	 *
-	 * @return  bool
-	 */
-	abstract public function validate_user();
-
-	/**
-	 * Login method
-	 *
-	 * @return  bool  whether login succeeded
-	 */
-	abstract public function login();
-
-	/**
-	 * Logout method
-	 */
-	abstract public function logout();
-
-	/**
-	 * Get User Identifier of the current logged in user
-	 * in the form: array(driver_id, user_id)
-	 *
-	 * @return  array
-	 */
-	abstract public function get_user_id();
-
-	/**
-	 * Get User Groups of the current logged in user
-	 * in the form: array(array(driver_id, group_id), array(driver_id, group_id), etc)
-	 *
-	 * @return  array
-	 */
-	abstract public function get_groups();
-
-	/**
-	 * Get emailaddress of the current logged in user
-	 *
-	 * @return  string
-	 */
-	abstract public function get_email();
-
-	/**
-	 * Get screen name of the current logged in user
-	 *
-	 * @return  string
-	 */
-	abstract public function get_screen_name();
-}
-
-/* end of file driver.php */

+ 0 - 545
frameworks/PHP/php-fuel/fuel/packages/auth/classes/auth/login/simpleauth.php

@@ -1,545 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Auth;
-
-
-class SimpleUserUpdateException extends \FuelException {}
-
-class SimpleUserWrongPassword extends \FuelException {}
-
-/**
- * SimpleAuth basic login driver
- *
- * @package     Fuel
- * @subpackage  Auth
- */
-class Auth_Login_SimpleAuth extends \Auth_Login_Driver
-{
-
-	public static function _init()
-	{
-		\Config::load('simpleauth', true, true, true);
-	}
-
-	/**
-	 * @var  Database_Result  when login succeeded
-	 */
-	protected $user = null;
-
-	/**
-	 * @var  array  value for guest login
-	 */
-	protected static $guest_login = array(
-		'id' => 0,
-		'username' => 'guest',
-		'group' => '0',
-		'login_hash' => false,
-		'email' => false
-	);
-
-	/**
-	 * @var  array  SimpleAuth class config
-	 */
-	protected $config = array(
-		'drivers' => array('group' => array('SimpleGroup')),
-		'additional_fields' => array('profile_fields'),
-	);
-
-	/**
-	 * Check for login
-	 *
-	 * @return  bool
-	 */
-	protected function perform_check()
-	{
-		$username    = \Session::get('username');
-		$login_hash  = \Session::get('login_hash');
-
-		// only worth checking if there's both a username and login-hash
-		if ( ! empty($username) and ! empty($login_hash))
-		{
-			if (is_null($this->user) or ($this->user['username'] != $username and $this->user != static::$guest_login))
-			{
-				$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-					->where('username', '=', $username)
-					->from(\Config::get('simpleauth.table_name'))
-					->execute(\Config::get('simpleauth.db_connection'))->current();
-			}
-
-			// return true when login was verified
-			if ($this->user and $this->user['login_hash'] === $login_hash)
-			{
-				return true;
-			}
-		}
-
-		// no valid login when still here, ensure empty session and optionally set guest_login
-		$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
-		\Session::delete('username');
-		\Session::delete('login_hash');
-
-		return false;
-	}
-
-	/**
-	 * Check the user exists before logging in
-	 *
-	 * @return  bool
-	 */
-	public function validate_user($username_or_email = '', $password = '')
-	{
-		$username_or_email = trim($username_or_email) ?: trim(\Input::post(\Config::get('simpleauth.username_post_key', 'username')));
-		$password = trim($password) ?: trim(\Input::post(\Config::get('simpleauth.password_post_key', 'password')));
-
-		if (empty($username_or_email) or empty($password))
-		{
-			return false;
-		}
-
-		$password = $this->hash_password($password);
-		$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-			->where_open()
-			->where('username', '=', $username_or_email)
-			->or_where('email', '=', $username_or_email)
-			->where_close()
-			->where('password', '=', $password)
-			->from(\Config::get('simpleauth.table_name'))
-			->execute(\Config::get('simpleauth.db_connection'))->current();
-
-		return $this->user ?: false;
-	}
-
-	/**
-	 * Login user
-	 *
-	 * @param   string
-	 * @param   string
-	 * @return  bool
-	 */
-	public function login($username_or_email = '', $password = '')
-	{
-		if ( ! ($this->user = $this->validate_user($username_or_email, $password)))
-		{
-			$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
-			\Session::delete('username');
-			\Session::delete('login_hash');
-			return false;
-		}
-
-		// register so Auth::logout() can find us
-		Auth::_register_verified($this);
-
-		\Session::set('username', $this->user['username']);
-		\Session::set('login_hash', $this->create_login_hash());
-		\Session::instance()->rotate();
-		return true;
-	}
-
-	/**
-	 * Force login user
-	 *
-	 * @param   string
-	 * @return  bool
-	 */
-	public function force_login($user_id = '')
-	{
-		if (empty($user_id))
-		{
-			return false;
-		}
-
-		$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-			->where_open()
-			->where('id', '=', $user_id)
-			->where_close()
-			->from(\Config::get('simpleauth.table_name'))
-			->execute(\Config::get('simpleauth.db_connection'))
-			->current();
-
-		if ($this->user == false)
-		{
-			$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
-			\Session::delete('username');
-			\Session::delete('login_hash');
-			return false;
-		}
-
-		\Session::set('username', $this->user['username']);
-		\Session::set('login_hash', $this->create_login_hash());
-		return true;
-	}
-
-	/**
-	 * Logout user
-	 *
-	 * @return  bool
-	 */
-	public function logout()
-	{
-		$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
-		\Session::delete('username');
-		\Session::delete('login_hash');
-		return true;
-	}
-
-	/**
-	 * Create new user
-	 *
-	 * @param   string
-	 * @param   string
-	 * @param   string  must contain valid email address
-	 * @param   int     group id
-	 * @param   Array
-	 * @return  bool
-	 */
-	public function create_user($username, $password, $email, $group = 1, Array $profile_fields = array())
-	{
-		$password = trim($password);
-		$email = filter_var(trim($email), FILTER_VALIDATE_EMAIL);
-
-		if (empty($username) or empty($password) or empty($email))
-		{
-			throw new \SimpleUserUpdateException('Username, password or email address is not given, or email address is invalid', 1);
-		}
-
-		$same_users = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-			->where('username', '=', $username)
-			->or_where('email', '=', $email)
-			->from(\Config::get('simpleauth.table_name'))
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		if ($same_users->count() > 0)
-		{
-			if (in_array(strtolower($email), array_map('strtolower', $same_users->current())))
-			{
-				throw new \SimpleUserUpdateException('Email address already exists', 2);
-			}
-			else
-			{
-				throw new \SimpleUserUpdateException('Username already exists', 3);
-			}
-		}
-
-		$user = array(
-			'username'        => (string) $username,
-			'password'        => $this->hash_password((string) $password),
-			'email'           => $email,
-			'group'           => (int) $group,
-			'profile_fields'  => serialize($profile_fields),
-			'last_login'      => 0,
-			'login_hash'      => '',
-			'created_at'      => \Date::forge()->get_timestamp()
-		);
-		$result = \DB::insert(\Config::get('simpleauth.table_name'))
-			->set($user)
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		return ($result[1] > 0) ? $result[0] : false;
-	}
-
-	/**
-	 * Update a user's properties
-	 * Note: Username cannot be updated, to update password the old password must be passed as old_password
-	 *
-	 * @param   Array  properties to be updated including profile fields
-	 * @param   string
-	 * @return  bool
-	 */
-	public function update_user($values, $username = null)
-	{
-		$username = $username ?: $this->user['username'];
-		$current_values = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-			->where('username', '=', $username)
-			->from(\Config::get('simpleauth.table_name'))
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		if (empty($current_values))
-		{
-			throw new \SimpleUserUpdateException('Username not found', 4);
-		}
-
-		$update = array();
-		if (array_key_exists('username', $values))
-		{
-			throw new \SimpleUserUpdateException('Username cannot be changed.', 5);
-		}
-		if (array_key_exists('password', $values))
-		{
-			if (empty($values['old_password'])
-				or $current_values->get('password') != $this->hash_password(trim($values['old_password'])))
-			{
-				throw new \SimpleUserWrongPassword('Old password is invalid');
-			}
-
-			$password = trim(strval($values['password']));
-			if ($password === '')
-			{
-				throw new \SimpleUserUpdateException('Password can\'t be empty.', 6);
-			}
-			$update['password'] = $this->hash_password($password);
-			unset($values['password']);
-		}
-		if (array_key_exists('old_password', $values))
-		{
-			unset($values['old_password']);
-		}
-		if (array_key_exists('email', $values))
-		{
-			$email = filter_var(trim($values['email']), FILTER_VALIDATE_EMAIL);
-			if ( ! $email)
-			{
-				throw new \SimpleUserUpdateException('Email address is not valid', 7);
-			}
-			$update['email'] = $email;
-			unset($values['email']);
-		}
-		if (array_key_exists('group', $values))
-		{
-			if (is_numeric($values['group']))
-			{
-				$update['group'] = (int) $values['group'];
-			}
-			unset($values['group']);
-		}
-		if ( ! empty($values))
-		{
-			$profile_fields = @unserialize($current_values->get('profile_fields')) ?: array();
-			foreach ($values as $key => $val)
-			{
-				if ($val === null)
-				{
-					unset($profile_fields[$key]);
-				}
-				else
-				{
-					$profile_fields[$key] = $val;
-				}
-			}
-			$update['profile_fields'] = serialize($profile_fields);
-		}
-
-		$affected_rows = \DB::update(\Config::get('simpleauth.table_name'))
-			->set($update)
-			->where('username', '=', $username)
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		// Refresh user
-		if ($this->user['username'] == $username)
-		{
-			$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
-				->where('username', '=', $username)
-				->from(\Config::get('simpleauth.table_name'))
-				->execute(\Config::get('simpleauth.db_connection'))->current();
-		}
-
-		return $affected_rows > 0;
-	}
-
-	/**
-	 * Change a user's password
-	 *
-	 * @param   string
-	 * @param   string
-	 * @param   string  username or null for current user
-	 * @return  bool
-	 */
-	public function change_password($old_password, $new_password, $username = null)
-	{
-		try
-		{
-			return (bool) $this->update_user(array('old_password' => $old_password, 'password' => $new_password), $username);
-		}
-		// Only catch the wrong password exception
-		catch (SimpleUserWrongPassword $e)
-		{
-			return false;
-		}
-	}
-
-	/**
-	 * Generates new random password, sets it for the given username and returns the new password.
-	 * To be used for resetting a user's forgotten password, should be emailed afterwards.
-	 *
-	 * @param   string  $username
-	 * @return  string
-	 */
-	public function reset_password($username)
-	{
-		$new_password = \Str::random('alnum', 8);
-		$password_hash = $this->hash_password($new_password);
-
-		$affected_rows = \DB::update(\Config::get('simpleauth.table_name'))
-			->set(array('password' => $password_hash))
-			->where('username', '=', $username)
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		if ( ! $affected_rows)
-		{
-			throw new \SimpleUserUpdateException('Failed to reset password, user was invalid.', 8);
-		}
-
-		return $new_password;
-	}
-
-	/**
-	 * Deletes a given user
-	 *
-	 * @param   string
-	 * @return  bool
-	 */
-	public function delete_user($username)
-	{
-		if (empty($username))
-		{
-			throw new \SimpleUserUpdateException('Cannot delete user with empty username', 9);
-		}
-
-		$affected_rows = \DB::delete(\Config::get('simpleauth.table_name'))
-			->where('username', '=', $username)
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		return $affected_rows > 0;
-	}
-
-	/**
-	 * Creates a temporary hash that will validate the current login
-	 *
-	 * @return  string
-	 */
-	public function create_login_hash()
-	{
-		if (empty($this->user))
-		{
-			throw new \SimpleUserUpdateException('User not logged in, can\'t create login hash.', 10);
-		}
-
-		$last_login = \Date::forge()->get_timestamp();
-		$login_hash = sha1(\Config::get('simpleauth.login_hash_salt').$this->user['username'].$last_login);
-
-		\DB::update(\Config::get('simpleauth.table_name'))
-			->set(array('last_login' => $last_login, 'login_hash' => $login_hash))
-			->where('username', '=', $this->user['username'])
-			->execute(\Config::get('simpleauth.db_connection'));
-
-		$this->user['login_hash'] = $login_hash;
-
-		return $login_hash;
-	}
-
-	/**
-	 * Get the user's ID
-	 *
-	 * @return  Array  containing this driver's ID & the user's ID
-	 */
-	public function get_user_id()
-	{
-		if (empty($this->user))
-		{
-			return false;
-		}
-
-		return array($this->id, (int) $this->user['id']);
-	}
-
-	/**
-	 * Get the user's groups
-	 *
-	 * @return  Array  containing the group driver ID & the user's group ID
-	 */
-	public function get_groups()
-	{
-		if (empty($this->user))
-		{
-			return false;
-		}
-
-		return array(array('SimpleGroup', $this->user['group']));
-	}
-
-	/**
-	 * Get the user's emailaddress
-	 *
-	 * @return  string
-	 */
-	public function get_email()
-	{
-		if (empty($this->user))
-		{
-			return false;
-		}
-
-		return $this->user['email'];
-	}
-
-	/**
-	 * Get the user's screen name
-	 *
-	 * @return  string
-	 */
-	public function get_screen_name()
-	{
-		if (empty($this->user))
-		{
-			return false;
-		}
-
-		return $this->user['username'];
-	}
-
-	/**
-	 * Get the user's profile fields
-	 *
-	 * @return  Array
-	 */
-	public function get_profile_fields($field = null, $default = null)
-	{
-		if (empty($this->user))
-		{
-			return false;
-		}
-
-		if (isset($this->user['profile_fields']))
-		{
-			is_array($this->user['profile_fields']) or $this->user['profile_fields'] = @unserialize($this->user['profile_fields']);
-		}
-		else
-		{
-			$this->user['profile_fields'] = array();
-		}
-
-		return is_null($field) ? $this->user['profile_fields'] : \Arr::get($this->user['profile_fields'], $field, $default);
-	}
-
-	/**
-	 * Extension of base driver method to default to user group instead of user id
-	 */
-	public function has_access($condition, $driver = null, $user = null)
-	{
-		if (is_null($user))
-		{
-			$groups = $this->get_groups();
-			$user = reset($groups);
-		}
-		return parent::has_access($condition, $driver, $user);
-	}
-
-	/**
-	 * Extension of base driver because this supports a guest login when switched on
-	 */
-	public function guest_login()
-	{
-		return \Config::get('simpleauth.guest_login', true);
-	}
-}
-
-// end of file simpleauth.php

+ 0 - 26
frameworks/PHP/php-fuel/fuel/packages/auth/config/auth.php

@@ -1,26 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-/**
- * NOTICE:
- *
- * If you need to make modifications to the default configuration, copy
- * this file to your app/config folder, and make them in there.
- *
- * This will allow you to upgrade fuel without losing your custom config.
- */
-
-return array(
-	'driver' => 'SimpleAuth',
-	'verify_multiple_logins' => false,
-	'salt' => 'put_your_salt_here',
-);

+ 0 - 99
frameworks/PHP/php-fuel/fuel/packages/auth/config/simpleauth.php

@@ -1,99 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-/**
- * NOTICE:
- *
- * If you need to make modifications to the default configuration, copy
- * this file to your app/config folder, and make them in there.
- *
- * This will allow you to upgrade fuel without losing your custom config.
- */
-
-return array(
-
-	/**
-	 * DB connection, leave null to use default
-	 */
-	'db_connection' => null,
-
-	/**
-	 * DB table name for the user table
-	 */
-	'table_name' => 'users',
-
-	/**
-	 * Choose which columns are selected, must include: username, password, email, last_login,
-	 * login_hash, group & profile_fields
-	 */
-	'table_columns' => array('*'),
-
-	/**
-	 * This will allow you to use the group & acl driver for non-logged in users
-	 */
-	'guest_login' => true,
-
-	/**
-	 * Groups as id => array(name => <string>, roles => <array>)
-	 */
-	'groups' => array(
-		/**
-		 * Examples
-		 * ---
-		 *
-		 * -1   => array('name' => 'Banned', 'roles' => array('banned')),
-		 * 0    => array('name' => 'Guests', 'roles' => array()),
-		 * 1    => array('name' => 'Users', 'roles' => array('user')),
-		 * 50   => array('name' => 'Moderators', 'roles' => array('user', 'moderator')),
-		 * 100  => array('name' => 'Administrators', 'roles' => array('user', 'moderator', 'admin')),
-		 */
-	),
-
-	/**
-	 * Roles as name => array(location => rights)
-	 */
-	'roles' => array(
-		/**
-		 * Examples
-		 * ---
-		 *
-		 * Regular example with role "user" given create & read rights on "comments":
-		 *   'user'  => array('comments' => array('create', 'read')),
-		 * And similar additional rights for moderators:
-		 *   'moderator'  => array('comments' => array('update', 'delete')),
-		 *
-		 * Wildcard # role (auto assigned to all groups):
-		 *   '#'  => array('website' => array('read'))
-		 *
-		 * Global disallow by assigning false to a role:
-		 *   'banned' => false,
-		 *
-		 * Global allow by assigning true to a role (use with care!):
-		 *   'super' => true,
-		 */
-	),
-
-	/**
-	 * Salt for the login hash
-	 */
-	'login_hash_salt' => 'put_some_salt_in_here',
-
-	/**
-	 * $_POST key for login username
-	 */
-	'username_post_key' => 'username',
-
-	/**
-	 * $_POST key for login password
-	 */
-	'password_post_key' => 'password',
-);

+ 0 - 38
frameworks/PHP/php-fuel/fuel/packages/auth/examples/001_auth_create_simpleauth_table.php

@@ -1,38 +0,0 @@
-<?php
-
-namespace Fuel\Migrations;
-
-class Auth_Create_Simpleauth_Table
-{
-
-	function up()
-	{
-		// get the configured table name
-		$table = \Config::get('simpleauth.table_name', 'users');
-
-		// table users
-		\DBUtil::create_table($table, array(
-			'id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true),
-			'username' => array('type' => 'varchar', 'constraint' => 50),
-			'password' => array('type' => 'varchar', 'constraint' => 255),
-			'group' => array('type' => 'int', 'constraint' => 11, 'default' => 1),
-			'email' => array('type' => 'varchar', 'constraint' => 255),
-			'last_login' => array('type' => 'varchar', 'constraint' => 25),
-			'login_hash' => array('type' => 'varchar', 'constraint' => 255),
-			'profile_fields' => array('type' => 'text'),
-			'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0),
-		), array('id'));
-
-		// add a unique index on username and email
-		\DBUtil::create_index('users', array('username', 'email'), 'username', 'UNIQUE');
-	}
-
-	function down()
-	{
-		// get the configured table name
-		$table = \Config::get('simpleauth.table_name', 'users');
-
-		// drop the users table
-		\DBUtil::drop_table($table);
-	}
-}

+ 0 - 49
frameworks/PHP/php-fuel/fuel/packages/email/bootstrap.php

@@ -1,49 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-
-Autoloader::add_core_namespace('Email');
-
-Autoloader::add_classes(array(
-	/**
-	 * Email classes.
-	 */
-	'Email\\Email'							=> __DIR__.'/classes/email.php',
-	'Email\\Email_Driver'					=> __DIR__.'/classes/email/driver.php',
-	'Email\\Email_Driver_Mail'				=> __DIR__.'/classes/email/driver/mail.php',
-	'Email\\Email_Driver_Smtp'				=> __DIR__.'/classes/email/driver/smtp.php',
-	'Email\\Email_Driver_Sendmail'			=> __DIR__.'/classes/email/driver/sendmail.php',
-	'Email\\Email_Driver_Noop'				=> __DIR__.'/classes/email/driver/noop.php',
-
-	/**
-	 * Email exceptions.
-	 */
-	'Email\\AttachmentNotFoundException'	=> __DIR__.'/classes/email.php',
-	'Email\\InvalidAttachmentsException'	=> __DIR__.'/classes/email.php',
-	'Email\\InvalidEmailStringEncoding'		=> __DIR__.'/classes/email.php',
-	'Email\\EmailSendingFailedException'	=> __DIR__.'/classes/email.php',
-	'Email\\EmailValidationFailedException'	=> __DIR__.'/classes/email.php',
-
-	/**
-	 * Smtp exceptions
-	 */
-	'Email\\SmtpTimeoutException'				=> __DIR__.'/classes/email/driver/smtp.php',
-	'Email\\SmtpConnectionException'				=> __DIR__.'/classes/email/driver/smtp.php',
-	'Email\\SmtpCommandFailureException'			=> __DIR__.'/classes/email/driver/smtp.php',
-	'Email\\SmtpAuthenticationFailedException'		=> __DIR__.'/classes/email/driver/smtp.php',
-
-	/**
-	 * Sendmail exceptions
-	 */
-	'Email\\SendmailFailedException'				=> __DIR__.'/classes/email/driver/sendmail.php',
-	'Email\\SendmailConnectionException'			=> __DIR__.'/classes/email/driver/sendmail.php',
-));

+ 0 - 105
frameworks/PHP/php-fuel/fuel/packages/email/classes/email.php

@@ -1,105 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-class AttachmentNotFoundException extends \FuelException {}
-
-class InvalidAttachmentsException extends \FuelException {}
-
-class InvalidEmailStringEncoding extends \FuelException {}
-
-class EmailSendingFailedException extends \FuelException {}
-
-class EmailValidationFailedException extends \FuelException {}
-
-class Email
-{
-
-	/**
-	 * Instance for singleton usage.
-	 */
-	public static $_instance = false;
-
-	/**
-	 * Driver config defaults.
-	 */
-	protected static $_defaults;
-
-	/**
-	 * Email priorities
-	 */
-	const P_LOWEST		= '5 (Lowest)';
-	const P_LOW			= '4 (Low)';
-	const P_NORMAL		= '3 (Normal)';
-	const P_HIGH		= '2 (High)';
-	const P_HIGHEST		= '1 (Highest)';
-
-	/**
-	 * Email driver forge.
-	 *
-	 * @param	string|array	$setup		setup key for array defined in email.setups config or config array
-	 * @param	array			$config		extra config array
-	 * @return  Email_Driver    one of the email drivers
-	 */
-	public static function forge($setup = null, array $config = array())
-	{
-		empty($setup) and $setup = \Config::get('email.default_setup', 'default');
-		is_string($setup) and $setup = \Config::get('email.setups.'.$setup, array());
-
-		$setup = \Arr::merge(static::$_defaults, $setup);
-		$config = \Arr::merge($setup, $config);
-
-		$driver = '\\Email_Driver_'.ucfirst(strtolower($config['driver']));
-
-		if( ! class_exists($driver, true))
-		{
-			throw new \FuelException('Could not find Email driver: '.$config['driver']. ' ('.$driver.')');
-		}
-
-		$driver = new $driver($config);
-
-		return $driver;
-	}
-
-	/**
-	 * Init, config loading.
-	 */
-	public static function _init()
-	{
-		\Config::load('email', true);
-		static::$_defaults = \Config::get('email.defaults');
-	}
-
-	/**
-	 * Call rerouting for static usage.
-	 *
-	 * @param	string	$method		method name called
-	 * @param	array	$args		supplied arguments
-	 */
-	public static function __callStatic($method, $args = array())
-	{
-		if(static::$_instance === false)
-		{
-			$instance = static::forge();
-			static::$_instance = &$instance;
-		}
-
-		if(is_callable(array(static::$_instance, $method)))
-		{
-			return call_user_func_array(array(static::$_instance, $method), $args);
-		}
-
-		throw new \BadMethodCallException('Invalid method: '.get_called_class().'::'.$method);
-	}
-
-}

+ 0 - 1160
frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver.php

@@ -1,1160 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-abstract class Email_Driver
-{
-	/**
-	 * Driver config
-	 */
-	protected $config = array();
-
-	/**
-	 * To recipients list
-	 */
-	protected $to = array();
-
-	/**
-	 * Cc recipients list
-	 */
-	protected $cc = array();
-
-	/**
-	 * Bcc recipients list
-	 */
-	protected $bcc = array();
-
-	/**
-	 *	Reply to list
-	 */
-	protected $reply_to = array();
-
-	/**
-	 * Attachments array
-	 */
-	protected $attachments = array(
-		'inline' => array(),
-		'attachment' => array(),
-	);
-
-	/**
-	 * Message body
-	 */
-	protected $body = '';
-
-	/**
-	 * Message alt body
-	 */
-	protected $alt_body = '';
-
-	/**
-	 * Message subject
-	 */
-	protected $subject = '';
-
-	/**
-	 * Invalid addresses
-	 */
-	protected $invalid_addresses = array();
-
-	/**
-	 * Message boundaries
-	 */
-	protected $boundaries = array();
-
-	/**
-	 * Message headers
-	 */
-	protected $headers = array();
-
-	/**
-	 * Custom headers
-	 */
-	protected $extra_headers = array();
-
-	/**
-	 * Mail type
-	 */
-	protected $type = 'plain';
-
-	/**
-	 * Driver constructor
-	 *
-	 * @param	array	$config		driver config
-	 */
-	public function __construct(array $config)
-	{
-		$this->config = $config;
-	}
-
-	/**
-	 * Get a driver config setting.
-	 *
-	 * @param	string		$key		the config key
-	 * @return	mixed					the config setting value
-	 */
-	public function get_config($key, $default = null)
-	{
-		return \Arr::get($this->config, $key, $default);
-	}
-
-	/**
-	 * Set a driver config setting.
-	 *
-	 * @param	string		$key		the config key
-	 * @param	mixed		$value		the new config value
-	 * @return	object					$this
-	 */
-	public function set_config($key, $value)
-	{
-		\Arr::set($this->config, $key, $value);
-
-		return $this;
-	}
-
-	/**
-	 * Sets the body
-	 *
-	 * @param	string		$body			the message body
-	 * @return	object		$this
-	 */
-	public function body($body)
-	{
-		$this->body = (string) $body;
-
-		return $this;
-	}
-
-	/**
-	 * Sets the alt body
-	 *
-	 * @param	string		$alt_body			the message alt body
-	 * @return	object		$this
-	 */
-	public function alt_body($alt_body)
-	{
-		$this->alt_body = (string) $alt_body;
-
-		return $this;
-	}
-
-	/**
-	 * Sets the mail priority
-	 *
-	 * @param	string		$priority			the message priority
-	 * @return	object		$this
-	 */
-	public function priority($priority)
-	{
-		$this->config['priority'] = $priority;
-
-		return $this;
-	}
-
-	/**
-	 * Sets the html body and optionally a generated alt body.
-	 *
-	 * @param	string	$html 			the body html
-	 * @param	bool	$generate_alt	whether to generate the alt body, will set is html to true
-	 * @param	bool	$auto_attach	whether to auto attach inline files
-	 * @return	object	$this
-	 */
-	public function html_body($html, $generate_alt = null, $auto_attach = null)
-	{
-		$this->config['is_html'] = true;
-
-		// Check settings
-		$generate_alt = is_bool($generate_alt) ? $generate_alt : $this->config['generate_alt'];
-		$auto_attach = is_bool($auto_attach) ? $auto_attach : $this->config['auto_attach'];
-
-		// Remove html comments
-		$html = preg_replace('/<!--(.*)-->/', '', (string) $html);
-
-		if ($auto_attach)
-		{
-			// Auto attach all images
-			preg_match_all("/(src|background)=\"(.*)\"/Ui", $html, $images);
-			if ( ! empty($images[2]))
-			{
-				foreach ($images[2] as $i => $image_url)
-				{
-					// Don't attach absolute urls
-					if ( ! preg_match('/(^http\:\/\/|^https\:\/\/|^cid\:)/Ui', $image_url))
-					{
-						$cid = 'cid:'.md5(pathinfo($image_url, PATHINFO_BASENAME));
-						if ( ! isset($this->attachments['inline'][$cid]))
-						{
-							$this->attach($image_url, true, $cid);
-						}
-						$html = preg_replace("/".$images[1][$i]."=\"".preg_quote($image_url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $html);
-					}
-				}
-			}
-		}
-
-		$this->body = $html;
-
-		$generate_alt and $this->alt_body = static::generate_alt($html, $this->config['wordwrap'], $this->config['newline']);
-
-		return $this;
-	}
-
-	/**
-	 * Sets the message subject
-	 *
-	 * @param	string		$subject	the message subject
-	 * @return	object		$this
-	 */
-	public function subject($subject)
-	{
-		if ($this->config['encode_headers'])
-		{
-			$subject = $this->encode_mimeheader((string) $subject);
-		}
-		$this->subject = (string) $subject;
-
-		return $this;
-	}
-
-	/**
-	 * Sets the from address and name
-	 *
-	 * @param	string		$email	the from email address
-	 * @param	string		$name	the optional from name
-	 * @return	object		$this
-	 */
-	public function from($email, $name = false)
-	{
-		$this->config['from']['email'] = (string) $email;
-		$this->config['from']['name'] = (is_string($name)) ? $name : false;
-
-		if ($this->config['encode_headers'] and $this->config['from']['name'])
-		{
-			$this->config['from']['name'] = $this->encode_mimeheader((string) $this->config['from']['name']);
-		}
-
-		return $this;
-	}
-
-	/**
-	 * Add to the to recipients list.
-	 *
-	 * @param	string|array	$email	email address or list of email addresses, array(email => name, email)
-	 * @param	string|bool		$name	recipient name, false, null or empty for no name
-	 * @return	object			$this
-	 */
-	public function to($email, $name = false)
-	{
-		static::add_to_list('to', $email, $name);
-
-		return $this;
-	}
-
-	/**
-	 * Add to the cc recipients list.
-	 *
-	 * @param	string|array	$email	email address or list of email addresses, array(email => name, email)
-	 * @param	string|bool		$name	recipient name, false, null or empty for no name
-	 * @return	object			$this
-	 */
-	public function cc($email, $name = false)
-	{
-		static::add_to_list('cc', $email, $name);
-
-		return $this;
-	}
-
-
-	/**
-	 * Add to the bcc recipients list.
-	 *
-	 * @param	string|array	$email	email address or list of email addresses, array(email => name, email)
-	 * @param	string|bool		$name	recipient name, false, null or empty for no name
-	 * @return	object			$this
-	 */
-	public function bcc($email, $name = false)
-	{
-		static::add_to_list('bcc', $email, $name);
-
-		return $this;
-	}
-
-	/**
-	 * Add to the 'reply to' list.
-	 *
-	 * @param	string|array	$email	email address or list of email addresses, array(email => name, email)
-	 * @param	string|bool		$name	the name, false, null or empty for no name
-	 * @return	object			$this
-	 */
-	public function reply_to($email, $name = false)
-	{
-		static::add_to_list('reply_to', $email, $name);
-
-		return $this;
-	}
-
-	/**
-	 * Sets the return-path address
-	 *
-	 * @param	string		$email	the return-path email address
-	 * @return	object		$this
-	 */
-	public function return_path($email)
-	{
-		$this->config['return_path'] = (string) $email;
-
-		return $this;
-	}
-
-	/**
-	 * Add to a recipients list.
-	 *
-	 * @param	string			$list	list to add to (to, cc, bcc)
-	 * @param	string|array	$email	email address or list of email addresses, array(email => name, email)
-	 * @param	string|bool		$name	recipient name, false, null or empty for no name
-	 * @return	void
-	 */
-	protected function add_to_list($list, $email, $name = false)
-	{
-		if ( ! is_array($email))
-		{
-			$email = (is_string($name)) ? array($email => $name) : array($email);
-		}
-
-		foreach ($email as $_email => $name)
-		{
-			if (is_numeric($_email))
-			{
-				$_email = $name;
-				$name = false;
-			}
-
-			if ($this->config['encode_headers'] and $name)
-			{
-				$name = $this->encode_mimeheader($name);
-			}
-
-			$this->{$list}[$_email] = array(
-				'name' => $name,
-				'email' => $_email,
-			);
-		}
-	}
-
-	/**
-	 * Clear the a recipient list.
-	 *
-	 * @param	string|array	$list	list or array of lists
-	 * @return	void
-	 */
-	protected function clear_list($list)
-	{
-		is_array($list) or $list = array($list);
-
-		foreach ($list as $_list)
-		{
-			$this->{$_list} = array();
-		}
-	}
-
-	/**
-	 * Clear all recipient lists.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_recipients()
-	{
-		static::clear_list(array('to', 'cc', 'bcc'));
-
-		return $this;
-	}
-
-	/**
-	 * Clear all address lists.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_addresses()
-	{
-		static::clear_list(array('to', 'cc', 'bcc', 'reply_to'));
-
-		return $this;
-	}
-
-	/**
-	 * Clear the 'to' recipient list.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_to()
-	{
-		static::clear_list('to');
-
-		return $this;
-	}
-
-	/**
-	 * Clear the 'cc' recipient list.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_cc()
-	{
-		static::clear_list('cc');
-
-		return $this;
-	}
-
-	/**
-	 * Clear the 'bcc' recipient list.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_bcc()
-	{
-		static::clear_list('bcc');
-
-		return $this;
-	}
-
-	/**
-	 * Clear the 'reply to' recipient list.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_reply_to()
-	{
-		static::clear_list('reply_to');
-
-		return $this;
-	}
-
-	/**
-	 * Sets custom headers.
-	 *
-	 * @param   mixed   $header  header type or array of headers
-	 * @param   string  $value   header value
-	 * @return  object  current instance
-	 */
-	public function header($header, $value = null)
-	{
-		if(is_array($header))
-		{
-			foreach($header as $_header => $_value)
-			{
-				empty($value) or $this->extra_headers[$header] = $value;
-			}
-		}
-		else
-		{
-			empty($value) or $this->extra_headers[$header] = $value;
-		}
-
-		return $this;
-	}
-
-	/**
-	 * Attaches a file to the email.
-	 *
-	 * @param	string	$file		the file to attach
-	 * @param	bool	$inline		whether to include the file inline
-	 * @param	string	$mime		the file's mime-type
-	 * @param	string	$mime		the file's mime-type
-	 * @return  object              $this
-	 */
-	public function attach($file, $inline = false, $cid = null, $mime = null)
-	{
-		if ( ! is_array($file))
-		{
-			$file = array($file, pathinfo($file, PATHINFO_BASENAME));
-		}
-
-		// Find the attachment.
-		$file[0] = $this->find_attachment($file[0]);
-
-		if (($contents = file_get_contents($file[0])) === false or empty($contents))
-		{
-			throw new \InvalidAttachmentsException('Could not read attachment or attachment is empty: '.$file[0]);
-		}
-
-		$disp = ($inline) ? 'inline' : 'attachment';
-
-		$cid = empty($cid) ? 'cid:'.md5($file[1]) : trim($cid);
-		$cid = strpos($cid, 'cid:') === 0 ? $cid : 'cid:'.$cid;
-
-		// Fetch the file mime type.
-		$mime or $mime = static::attachment_mime($file[0]);
-
-		$this->attachments[$disp][$cid] = array(
-			'file' => $file,
-			'contents' => chunk_split(base64_encode($contents), $this->config['wordwrap'], $this->config['newline']),
-			'mime' => $mime,
-			'disp' => $disp,
-			'cid' => $cid,
-		);
-
-		return $this;
-	}
-
-	/**
-	 * Finds an attachment.
-	 *
-	 * @param    string    $path    path to the attachment
-	 * @return   string             path of the first found attachment
-	 * @throws   AttachmentNotFoundException     when no file is found.
-	 */
-	protected function find_attachment($file)
-	{
-		foreach($this->get_config('attach_paths') as $path)
-		{
-			if(is_file($path.$file))
-			{
-				return $path.$file;
-			}
-		}
-
-		// No file found?
-		throw new \AttachmentNotFoundException('Email attachment not found: '.$file);
-	}
-
-	/**
-	 * Attach a file using string input
-	 *
-	 * @param	string	$contents	file contents
-	 * @param	string	$filename	the files name
-	 * @param	bool	$inline		whether it's an inline attachment
-	 * @param	string	$mime		the file's mime-type
-	 * @return	object	$this
-	 */
-	public function string_attach($contents, $filename, $cid = null, $inline = false, $mime = null)
-	{
-		$disp = ($inline) ? 'inline' : 'attachment';
-		$cid = empty($cid) ? 'cid:'.md5($filename) : trim($cid);
-		$cid = strpos($cid, 'cid:') === 0 ? $cid : 'cid:'.$cid;
-		$mime or $mime = static::attachment_mime($filename);
-
-		$this->attachments[$disp][$cid] = array(
-			'file' => array(1 => $filename),
-			'contents' => static::encode_string($contents, 'base64', $this->config['newline']),
-			'mime' => $mime,
-			'disp' => $disp,
-			'cid' => $cid,
-		);
-
-		return $this;
-	}
-
-	/**
-	 * Clear the attachments list.
-	 *
-	 * @return	object	$this
-	 */
-	public function clear_attachments()
-	{
-		$this->attachments = array(
-			'inline' => array(),
-			'attachment' => array(),
-		);
-
-		return $this;
-	}
-
-	/**
-	 * Get the mimetype for an attachment
-	 *
-	 * @param	string	$file	the path to the attachment
-	 * @return	string			the attachment's mimetype
-	 */
-	protected static function attachment_mime($file)
-	{
-		static $mimes = false;
-
-		if ( ! $mimes)
-		{
-			$mimes = \Config::load('mimes');
-		}
-
-		$ext = pathinfo($file, PATHINFO_EXTENSION);
-
-		$mime = \Arr::get($mimes, $ext, 'application/octet-stream');
-		is_array($mime) and $mime = reset($mime);
-
-		return $mime;
-	}
-
-	/**
-	 * Validates all the email addresses.
-	 *
-	 * @return	bool|array	true if all are valid or an array of recipients which failed validation.
-	 */
-	protected function validate_addresses()
-	{
-		$failed = array();
-
-		foreach (array('to', 'cc', 'bcc') as $list)
-		{
-			foreach ($this->{$list} as $recipient)
-			{
-				if ( ! filter_var($recipient['email'], FILTER_VALIDATE_EMAIL))
-				{
-					$failed[$list][] = $recipient;
-				}
-			}
-		}
-
-		if (count($failed) === 0)
-		{
-			return true;
-		}
-
-		return $failed;
-	}
-
-	/**
-	 * Sets unique message boundaries
-	 */
-	protected function set_boundaries()
-	{
-		$uniq_id = md5(uniqid(microtime(true)));
-
-		// Message part boundary, (separates message and attachments).
-		$this->boundaries[0] = 'B1_'.$uniq_id;
-
-		// Message body boundary (separates message, alt message)
-		$this->boundaries[1] = 'B2_'.$uniq_id;
-
-		$this->boundaries[2] = 'B3_'.$uniq_id;
-	}
-
-	/**
-	 * Initiates the sending process.
-	 *
-	 * @param	mixed	whether to validate the addresses, falls back to config setting
-	 * @return	bool	success boolean
-	 */
-	public function send($validate = null)
-	{
-		if (empty($this->to) and empty($this->cc) and empty($this->bcc))
-		{
-			throw new \FuelException('Cannot send email without recipients.');
-		}
-
-		if (($from = $this->config['from']['email']) === false or empty($from))
-		{
-			throw new \FuelException('Cannot send without from address.');
-		}
-
-		// Check which validation bool to use
-		is_bool($validate) or $validate = $this->config['validate'];
-
-		// Validate the email addresses if specified
-		if ($validate and ($failed = $this->validate_addresses()) !== true)
-		{
-			$this->invalid_addresses = $failed;
-
-			$error_str = '';
-			foreach($failed as $_list => $_contents)
-			{
-				$error_str .= $_list.': '.htmlentities(static::format_addresses($_contents)).'.'.PHP_EOL;
-			}
-
-			throw new \EmailValidationFailedException('One or more email addresses did not pass validation: '.$error_str);
-		}
-
-		// Reset the headers
-		$this->headers = array();
-
-		// Set the email boundaries
-		$this->set_boundaries();
-
-		// Set RFC 822 formatted date
-		$this->set_header('Date', date('r'));
-
-		// Set return path
-		if ($this->config['return_path'] !== false)
-		{
-			$this->set_header('Return-Path', $this->config['return_path']);
-		}
-		else
-		{
-			$this->set_header('Return-Path', $this->config['from']['email']);
-		}
-
-		if (($this instanceof \Email_Driver_Mail) !== true)
-		{
-			if ( ! empty($this->to))
-			{
-				// Set from
-				$this->set_header('To', static::format_addresses($this->to));
-			}
-
-			// Set subject
-			$this->set_header('Subject', $this->subject);
-		}
-
-		$this->set_header('From', static::format_addresses(array($this->config['from'])));
-
-		foreach (array('cc' => 'Cc', 'bcc' => 'Bcc', 'reply_to' => 'Reply-To') as $list => $header)
-		{
-			if (count($this->{$list}) > 0)
-			{
-				$this->set_header($header, static::format_addresses($this->{$list}));
-			}
-		}
-
-		// Set message id
-		$this->set_header('Message-ID', $this->get_message_id());
-
-		// Set mime version
-		$this->set_header('MIME-Version', '1.0');
-
-		// Set priority
-		$this->set_header('X-Priority', $this->config['priority']);
-
-		// Set mailer useragent
-		$this->set_header('X-Mailer', $this->config['useragent']);
-
-		$newline = $this->config['newline'];
-
-		$this->type = $this->get_mail_type();
-
-		$encoding = $this->config['encoding'];
-		$charset = $this->config['charset'];
-
-		if ($this->type !== 'plain' and $this->type !== 'html')
-		{
-			$this->set_header('Content-Type', $this->get_content_type($this->type, $newline."\tboundary=\"".$this->boundaries[0].'"'));
-		}
-		else
-		{
-			$this->set_header('Content-Transfer-Encoding', $encoding);
-			$this->set_header('Content-Type', 'text/'.$this->type.'; charset="'.$this->config['charset'].'"');
-		}
-
-		// Encode messages
-		$this->body = static::encode_string($this->body, $encoding, $newline);
-		$this->alt_body = static::encode_string($this->alt_body, $encoding, $newline);
-
-		// Set wordwrapping
-		$wrapping = $this->config['wordwrap'];
-		$qp_mode = $encoding === 'quoted-printable';
-
-		$is_html = (stripos($this->type, 'html') !== false);
-
-		// Don't wrap the text when using quoted-printable
-		if ($wrapping and ! $qp_mode)
-		{
-			$this->body = static::wrap_text($this->body, $wrapping, $newline, $is_html);
-			$this->alt_body = static::wrap_text($this->alt_body, $wrapping, $newline, false);
-		}
-
-		// Send
-		$this->_send();
-
-		return true;
-	}
-
-	/**
-	 * Get the invalid addresses
-	 *
-	 * @return	array	an array of invalid email addresses
-	 */
-	public function get_invalid_addresses()
-	{
-		return $this->invalid_addresses;
-	}
-
-	/**
-	 * Sets the message headers
-	 *
-	 * @param	string	$header	the header type
-	 * @param	string	$value	the header value
-	 */
-	protected function set_header($header, $value)
-	{
-		empty($value) or $this->headers[$header] = $value;
-	}
-
-	/**
-	 * Gets the header
-	 *
-	 * @param	string	$header		the header time
-	 * @return	string|array		mail header or array of headers
-	 */
-	protected function get_header($header = null, $formatted = true)
-	{
-		if ($header === null)
-		{
-			return $this->headers;
-		}
-
-		if (array_key_exists($header, $this->headers))
-		{
-			$prefix = ($formatted) ? $header.': ' : '';
-			$suffix = ($formatted) ? $this->config['newline'] : '';
-			return $prefix.$this->headers[$header].$suffix;
-		}
-
-		return '';
-	}
-
-	/**
-	 * Encodes a mimeheader.
-	 *
-	 * @param   string  $header  header to encode
-	 * @return  string  mimeheader encoded string
-	 */
-	protected function encode_mimeheader($header)
-	{
-		$transfer_encoding = ($this->config['encoding'] === 'quoted-printable') ? 'Q' : 'B' ;
-		return mb_encode_mimeheader($header, $this->config['charset'], $transfer_encoding, $this->config['newline']);
-	}
-
-	/**
-	 * Get the attachment headers
-	 *
-	 */
-	protected function get_attachment_headers($type, $boundary)
-	{
-		$return = '';
-
-		$newline = $this->config['newline'];
-
-		foreach ($this->attachments[$type] as $attachment)
-		{
-			$return .= '--'.$boundary.$newline;
-			$return .= 'Content-Type: '.$attachment['mime'].'; name="'.$attachment['file'][1].'"'.$newline;
-			$return .= 'Content-Transfer-Encoding: base64'.$newline;
-			$type === 'inline' and $return .= 'Content-ID: <'.substr($attachment['cid'], 4).'>'.$newline;
-			$return .= 'Content-Disposition: '.$type.'; filename="'.$attachment['file'][1].'"'.$newline.$newline;
-			$return .= $attachment['contents'].$newline.$newline;
-		}
-
-		return $return;
-	}
-
-	/**
-	 * Get a unique message id
-	 *
-	 * @return	string	the message id
-	 */
-	protected function get_message_id()
-	{
-		$from = $this->config['from']['email'];
-		return "<".uniqid('').strstr($from, '@').">";
-	}
-
-	/**
-	 * Returns the mail's type
-	 *
-	 * @return	string		mail type
-	 */
-	protected function get_mail_type()
-	{
-		$return = $this->config['is_html'] ? 'html' : 'plain' ;
-		$alt = trim($this->alt_body);
-		$return .= ($this->config['is_html'] and ! empty($alt)) ? '_alt' : '';
-		$return .= ($this->config['is_html'] and count($this->attachments['inline'])) ? '_inline' : '';
-		$return .= (count($this->attachments['attachment'])) ? '_attach' : '';
-		return $return;
-	}
-
-	/**
-	 * Returns the content type
-	 *
-	 * @param	string		mail type
-	 * @return	string		mail content type
-	 */
-	protected function get_content_type($mail_type, $boundary)
-	{
-		$related = $this->config['force_mixed'] ? 'multipart/mixed; ' : 'multipart/related; ';
-
-		switch ($mail_type)
-		{
-			case 'plain':
-				return 'text/plain';
-			case 'plain_attach':
-			case 'html_attach':
-				return $related.$boundary;
-			case 'html':
-				return 'text/html';
-			case 'html_alt_attach':
-			case 'html_alt_inline_attach':
-				return 'multipart/mixed; '.$boundary;
-			case 'html_alt_inline':
-			case 'html_alt':
-			case 'html_inline':
-				return 'multipart/alternative; '.$boundary;
-			default:
-				throw new \FuelException('Invalid content-type'.$mail_type);
-		}
-	}
-
-	/**
-	 * Builds the headers and body
-	 *
-	 * @param   bool    $no_bcc  wether to exclude Bcc headers.
-	 * @return	array	an array containing the headers and the body
-	 */
-	protected function build_message($no_bcc = false)
-	{
-		$newline = $this->config['newline'];
-		$charset = $this->config['charset'];
-		$encoding = $this->config['encoding'];
-
-		$headers = '';
-		$parts = array('Date', 'Return-Path', 'From', 'To', 'Cc', 'Bcc', 'Reply-To', 'Subject', 'Message-ID', 'X-Priority', 'X-Mailer', 'MIME-Version', 'Content-Type');
-		$no_bcc and array_splice($parts, 5, 1);
-
-		foreach ($parts as $part)
-		{
-			$headers .= $this->get_header($part);
-		}
-
-		foreach ($this->extra_headers as $header => $value)
-		{
-			$headers .= $header.': '.$value.$newline;
-		}
-
-		$headers .= $newline;
-		$body = '';
-
-		if ($this->type === 'plain' or $this->type === 'html')
-		{
-			$body = $this->body;
-		}
-		else
-		{
-			switch ($this->type)
-			{
-				case 'html_alt':
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: text/plain; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->alt_body.$newline.$newline;
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: text/html; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->body.$newline.$newline;
-					$body .= '--'.$this->boundaries[0].'--';
-					break;
-				case 'plain_attach':
-				case 'html_attach':
-				case 'html_inline':
-					$body .= '--'.$this->boundaries[0].$newline;
-					$text_type = (stripos($this->type, 'html') !== false) ? 'html' : 'plain';
-					$body .= 'Content-Type: text/'.$text_type.'; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->body.$newline.$newline;
-					$attach_type = (stripos($this->type, 'attach') !== false) ? 'attachment' : 'inline';
-					$body .= $this->get_attachment_headers($attach_type, $this->boundaries[0]);
-					$body .= '--'.$this->boundaries[0].'--';
-					break;
-				case 'html_alt_inline':
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: text/plain'.'; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->alt_body.$newline.$newline;
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: multipart/related;'.$newline."\tboundary=\"{$this->boundaries[1]}\"".$newline.$newline;
-					$body .= '--'.$this->boundaries[1].$newline;
-					$body .= 'Content-Type: text/html; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->body.$newline.$newline;
-					$body .= $this->get_attachment_headers('inline', $this->boundaries[1]);
-					$body .= '--'.$this->boundaries[1].'--'.$newline.$newline;
-					$body .= '--'.$this->boundaries[0].'--';
-					break;
-				case 'html_alt_attach':
-				case 'html_inline_attach':
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: multipart/alternative;'.$newline."\t boundary=\"{$this->boundaries[1]}\"".$newline.$newline;
-					if (stripos($this->type, 'alt') !== false)
-					{
-						$body .= '--'.$this->boundaries[1].$newline;
-						$body .= 'Content-Type: text/plain; charset="'.$charset.'"'.$newline;
-						$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-						$body .= $this->alt_body.$newline.$newline;
-					}
-					$body .= '--'.$this->boundaries[1].$newline;
-					$body .= 'Content-Type: text/html; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->body.$newline.$newline;
-					if (stripos($this->type, 'inline') !== false)
-					{
-						$body .= $this->get_attachment_headers('inline', $this->boundaries[1]);
-						$body .= $this->alt_body.$newline.$newline;
-					}
-					$body .= '--'.$this->boundaries[1].'--'.$newline.$newline;
-					$body .= $this->get_attachment_headers('attachment', $this->boundaries[0]);
-					$body .= '--'.$this->boundaries[0].'--';
-					break;
-				case 'html_alt_inline_attach':
-					$body .= '--'.$this->boundaries[0].$newline;
-					$body .= 'Content-Type: multipart/alternative;'.$newline."\t boundary=\"{$this->boundaries[1]}\"".$newline.$newline;
-					$body .= '--'.$this->boundaries[1].$newline;
-					$body .= 'Content-Type: text/plain; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->alt_body.$newline.$newline;
-					$body .= '--'.$this->boundaries[1].$newline;
-					$body .= 'Content-Type: multipart/related;'.$newline."\t boundary=\"{$this->boundaries[2]}\"".$newline.$newline;
-					$body .= '--'.$this->boundaries[2].$newline;
-					$body .= 'Content-Type: text/html; charset="'.$charset.'"'.$newline;
-					$body .= 'Content-Transfer-Encoding: '.$encoding.$newline.$newline;
-					$body .= $this->body.$newline.$newline;
-					$body .= $this->get_attachment_headers('inline', $this->boundaries[2]);
-					$body .= $this->alt_body.$newline.$newline;
-					$body .= '--'.$this->boundaries[2].'--'.$newline.$newline;
-					$body .= '--'.$this->boundaries[1].'--'.$newline.$newline;
-					$body .= $this->get_attachment_headers('attachment', $this->boundaries[0]);
-					$body .= '--'.$this->boundaries[0].'--';
-					break;
-			}
-
-		}
-
-		return array(
-			'header' => $headers,
-			'body' => $body,
-		);
-	}
-
-	/**
-	 * Wraps the body or alt text
-	 *
-	 * @param	string	$message	the text to wrap
-	 * @param	int		$length		the max line length
-	 * @param	string	$charset	the text charset
-	 * @param	string	$newline	the newline delimiter
-	 * @param	bool	$qp_mode	whether the text is quoted printable encoded
-	 */
-	protected static function wrap_text($message, $length, $newline, $is_html = true)
-	{
-		$length = ($length > 76) ? 76 : $length;
-		$is_html and $message = preg_replace('/[\r|\n|\t]/m', '', $message);
-		$message = wordwrap($message, $length, $newline, false);
-
-		return $message;
-	}
-
-	/**
-	 * Standardize newlines.
-	 *
-	 * @param	string	$string		string to prep
-	 * @param	string	$newline	the newline delimiter
-	 * @return	string	string with standardized newlines
-	 */
-	protected static function prep_newlines($string, $newline = null)
-	{
-		$newline or $newline = \Config::get('email.defaults.newline', "\n");
-
-		$replace = array(
-			"\r\n"	=> "\n",
-			"\n\r"	=> "\n",
-			"\r"	=> "\n",
-			"\n"	=> $newline,
-		);
-
-		foreach ($replace as $from => $to)
-		{
-			$string = str_replace($from, $to, $string);
-		}
-
-		return $string;
-	}
-
-	/**
-	 * Encodes a string in the given encoding.
-	 *
-	 * @param	string	$string		string to encode
-	 * @param	string	$encoding	the charset
-	 * @return	string	encoded string
-	 */
-	protected static function encode_string($string, $encoding, $newline = null)
-	{
-		$newline or $newline = \Config::get('email.defaults.newline', "\n");
-
-		switch ($encoding)
-		{
-			case 'quoted-printable':
-				return quoted_printable_encode($string);
-			case '7bit':
-			case '8bit':
-				return static::prep_newlines(rtrim($string, $newline), $newline);
-			case 'base64':
-				return chunk_split(base64_encode($string), 76, $newline);
-			default:
-				throw new \InvalidEmailStringEncoding($encoding.' is not a supported encoding method.');
-		}
-	}
-
-	/**
-	 * Returns a formatted string of email addresses.
-	 *
-	 * @param	array	$addresses	array of adresses array(array(name=>name, email=>email));
-	 * @return	string	correctly formatted email addresses
-	 */
-	protected static function format_addresses($addresses)
-	{
-		$return = array();
-
-		foreach ($addresses as $recipient)
-		{
-			$recipient['name'] and $recipient['email'] = $recipient['name'].' <'.$recipient['email'].'>';
-			$return[] = $recipient['email'];
-		}
-
-		return join(', ', $return);
-	}
-
-	/**
-	 * Generates an alt body
-	 *
-	 * @param	string	$html		html body to al body generate from
-	 * @param	int		$wordwrap	wordwrap length
-	 * @param	string	$newline	line separator to use
-	 * @return	string	the generated alt body
-	 */
-	protected static function generate_alt($html, $wordwrap, $newline)
-	{
-		$html = preg_replace('/[ |	]{2,}/m', ' ', $html);
-		$html = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $html)));
-		$lines = explode($newline, $html);
-		$result = array();
-		$first_newline = true;
-		foreach ($lines as $line)
-		{
-			$line = trim($line);
-			if ( ! empty($line) or $first_newline)
-			{
-				$first_newline = false;
-				$result[] = $line;
-			}
-			else
-			{
-				$first_newline = true;
-			}
-		}
-
-		$html = join($newline, $result);
-		return wordwrap($html, $wordwrap, $newline, true);
-	}
-
-	/**
-	 * Initiates the sending process.
-	 *
-	 * @return	bool	success boolean
-	 */
-	abstract protected function _send();
-
-}

+ 0 - 34
frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/mail.php

@@ -1,34 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-
-class Email_Driver_Mail extends \Email_Driver
-{
-	/**
-	 * Send the email using php's mail function.
-	 *
-	 * @return	bool	success boolean.
-	 */
-	protected function _send()
-	{
-		$message = $this->build_message();
-		$return_path = ($this->config['return_path'] !== false) ? $this->config['return_path'] : $this->config['from']['email'];
-		if ( ! @mail(static::format_addresses($this->to), $this->subject, $message['body'], $message['header'], '-oi -f '.$return_path))
-		{
-			throw new \EmailSendingFailedException('Failed sending email');
-		}
-		return true;
-	}
-
-}

+ 0 - 35
frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/noop.php

@@ -1,35 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-
-class Email_Driver_Noop extends \Email_Driver
-{
-	/**
-	 * Noop send: only log the request
-	 *
-	 * @return	bool	success boolean.
-	 */
-	protected function _send()
-	{
-		$message = $this->build_message();
-
-		logger(\Fuel::L_INFO, 'To: '.static::format_addresses($this->to), 'Email NoOp driver');
-		logger(\Fuel::L_INFO, 'Subject: '.$this->subject, 'Email NoOp driver');
-		logger(\Fuel::L_INFO, 'Header: '.$message['header'], 'Email NoOp driver');
-		logger(\Fuel::L_INFO, 'Body: '.$message['body'], 'Email NoOp driver');
-
-		return true;
-	}
-
-}

+ 0 - 56
frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/sendmail.php

@@ -1,56 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-class SendmailConnectionException extends \FuelException {}
-
-class SendmailFailedException extends \EmailSendingFailedException {}
-
-class Email_Driver_Sendmail extends \Email_Driver
-{
-
-	/**
-	 * Initalted all needed for Sendmail mailing.
-	 *
-	 * @return	bool	success boolean
-	 */
-	protected function _send()
-	{
-		// Build the message
-		$message = $this->build_message();
-
-		// Open a connection
-		$return_path = ($this->config['return_path'] !== false) ? $this->config['return_path'] : $this->config['from']['email'];
-		$handle = @popen($this->config['sendmail_path'] . " -oi -f ".$return_path." -t", 'w');
-
-		// No connection?
-		if(! is_resource($handle))
-		{
-			throw new \SendmailConnectionException('Could not open a sendmail connection at: '.$this->config['sendmail_path']);
-		}
-
-		// Send the headers
-		fputs($handle, $message['header']);
-
-		// Send the body
-		fputs($handle, $message['body']);
-
-		if(pclose($handle) === -1)
-		{
-			throw new \SendmailFailedException('Failed sending email through sendmail.');
-		}
-
-		return true;
-	}
-
-}

+ 0 - 250
frameworks/PHP/php-fuel/fuel/packages/email/classes/email/driver/smtp.php

@@ -1,250 +0,0 @@
-<?php
-/**
- * Fuel is a fast, lightweight, community driven PHP5 framework.
- *
- * @package    Fuel
- * @version    1.5
- * @author     Fuel Development Team
- * @license    MIT License
- * @copyright  2010 - 2013 Fuel Development Team
- * @link       http://fuelphp.com
- */
-
-namespace Email;
-
-
-class SmtpConnectionException extends \FuelException {}
-
-class SmtpCommandFailureException extends \EmailSendingFailedException {}
-
-class SmtpTimeoutException extends \EmailSendingFailedException {}
-
-class SmtpAuthenticationFailedException extends \FuelException {}
-
-class Email_Driver_Smtp extends \Email_Driver
-{
-
-	/**
-	 * The SMTP connection
-	 */
-	protected $smtp_connection = 0;
-
-	/**
-	 * Initalted all needed for SMTP mailing.
-	 *
-	 * @return	bool	success boolean
-	 */
-	protected function _send()
-	{
-		$message = $this->build_message(true);
-
-		if(empty($this->config['smtp']['host']) or empty($this->config['smtp']['port']))
-		{
-			throw new \FuelException('Must supply a SMTP host and port, none given.');
-		}
-
-		// Use authentication?
-		$authenticate = ! empty($this->config['smtp']['username']) and ! empty($this->config['smtp']['password']);
-
-		// Connect
-		$this->smtp_connect();
-
-		// Authenticate when needed
-		$authenticate and $this->smtp_authenticate();
-
-		// Set from
-		$this->smtp_send('MAIL FROM:<'.$this->config['from']['email'].'>', 250);
-
-		foreach(array('to', 'cc', 'bcc') as $list)
-		{
-			foreach($this->{$list} as $recipient)
-			{
-				$this->smtp_send('RCPT TO:<'.$recipient['email'].'>', array(250, 251));
-			}
-		}
-
-		// Prepare for data sending
-		$this->smtp_send('DATA', 354);
-
-		$lines = explode($this->config['newline'], $message['header'].$this->config['newline'].preg_replace('/^\./m', '..$1', $message['body']));
-
-		foreach($lines as $line)
-		{
-			if(substr($line, 0, 1) === '.')
-			{
-				$line = '.'.$line;
-			}
-
-			fputs($this->smtp_connection, $line.$this->config['newline']);
-		}
-
-		// Finish the message
-		$this->smtp_send('.', 250);
-
-		// Close the connection
-		$this->smtp_disconnect();
-
-		return true;
-	}
-
-	/**
-	 * Connects to the given smtp and says hello to the other server.
-	 */
-	protected function smtp_connect()
-	{
-		$this->smtp_connection = @fsockopen(
-			$this->config['smtp']['host'],
-			$this->config['smtp']['port'],
-			$error_number,
-			$error_string,
-			$this->config['smtp']['timeout']
-		);
-
-		if(empty($this->smtp_connection))
-		{
-			throw new \SmtpConnectionException('Could not connect to SMTP: ('.$error_number.') '.$error_string);
-		}
-
-		// Clear the smtp response
-		$this->smtp_get_response();
-
-		// Just say hello!
-		try
-		{
-			$this->smtp_send('EHLO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
-		}
-		catch(\SmtpCommandFailureException $e)
-		{
-			// Didn't work? Try HELO
-			$this->smtp_send('HELO'.' '.\Input::server('SERVER_NAME', 'localhost.local'), 250);
-		}
-
-		try
-		{
-			$this->smtp_send('HELP', 214);
-		}
-		catch(\SmtpCommandFailureException $e)
-		{
-			// Let this pass as some servers don't support this.
-		}
-	}
-
-	/**
-	 * Close SMTP connection
-	 */
-	protected function smtp_disconnect()
-	{
-		$this->smtp_send('QUIT', 221);
-		fclose($this->smtp_connection);
-		$this->smtp_connection = 0;
-	}
-
-	/**
-	 * Performs authentication with the SMTP host
-	 */
-	protected function smtp_authenticate()
-	{
-		// Encode login data
-		$username = base64_encode($this->config['smtp']['username']);
-		$password = base64_encode($this->config['smtp']['password']);
-
-		try
-		{
-			// Prepare login
-			$this->smtp_send('AUTH LOGIN', 334);
-
-			// Send username
-			$this->smtp_send($username, 334);
-
-			// Send password
-			$this->smtp_send($password, 235);
-
-		}
-		catch(\SmtpCommandFailureException $e)
-		{
-			throw new \SmtpAuthenticationFailedException('Failed authentication.');
-		}
-
-	}
-
-	/**
-	 * Sends data to the SMTP host
-	 *
-	 * @param	 string   $data                the SMTP command
-	 * @param	 mixed    $expecting           the expected response
-	 * @param    bool     $return_number       set to true to return the status number
-	 * @return   mixed                         result or result number, false when expecting is false
-	 * @throws   SmtpCommandFailureException   when the command failed an expecting is not set to false.
-	 */
-	protected function smtp_send($data, $expecting, $return_number = false)
-	{
-		! is_array($expecting) and $expecting !== false and $expecting = array($expecting);
-
-		stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
-		if ( ! fputs($this->smtp_connection, $data . $this->config['newline']))
-		{
-			if($expecting === false)
-			{
-				return false;
-			}
-			throw new \SmtpCommandFailureException('Failed executing command: '. $data);
-		}
-
-		$info = stream_get_meta_data($this->smtp_connection);
-		if($info['timed_out'])
-		{
-			throw new \SmtpTimeoutException('SMTP connection timed out.');
-		}
-
-		// Get the reponse
-		$response = $this->smtp_get_response();
-
-		// Get the reponse number
-		$number = (int) substr(trim($response), 0, 3);
-
-		// Check against expected result
-		if($expecting !== false and ! in_array($number, $expecting))
-		{
-			throw new \SmtpCommandFailureException('Got an unexpected response from host on command: ['.$data.'] expecting: '.join(' or ',$expecting).' received: '.$response);
-		}
-
-		if($return_number)
-		{
-			return $number;
-		}
-
-		return $response;
-	}
-
-	/**
-	 * Get SMTP response
-	 *
-	 * @return	string	SMTP response
-	 */
-	protected function smtp_get_response()
-	{
-		$data = '';
-
-		// set the timeout.
-		stream_set_timeout($this->smtp_connection, $this->config['smtp']['timeout']);
-
-		while($str = fgets($this->smtp_connection, 512))
-		{
-			$info = stream_get_meta_data($this->smtp_connection);
-			if($info['timed_out'])
-			{
-				throw new \SmtpTimeoutException('SMTP connection timed out.');
-			}
-
-			$data .= $str;
-
-			if (substr($str, 3, 1) === ' ')
-			{
-				break;
-			}
-		}
-
-		return $data;
-	}
-
-}

+ 0 - 127
frameworks/PHP/php-fuel/fuel/packages/email/config/email.php

@@ -1,127 +0,0 @@
-<?php
-
-return array(
-
-	/**
-	 * Default settings
-	 */
-	'defaults' => array(
-
-		/**
-		 * Mail useragent string
-		 */
-		'useragent'	=> 'FuelPHP, PHP 5.3 Framework',
-		/**
-		 * Mail driver (mail, smtp, sendmail, noop)
-		 */
-		'driver'		=> 'mail',
-
-		/**
-		 * Whether to send as html, set to null for autodetection.
-		 */
-		'is_html'		=> null,
-
-		/**
-		 * Email charset
-		 */
-		'charset'		=> 'utf-8',
-
-		/**
-		 * Wether to encode subject and recipient names.
-		 * Requires the mbstring extension: http://www.php.net/manual/en/ref.mbstring.php
-		 */
-		'encode_headers' => true,
-
-		/**
-		 * Ecoding (8bit, base64 or quoted-printable)
-		 */
-		'encoding'		=> '8bit',
-
-		/**
-		 * Email priority
-		 */
-		'priority'		=> \Email::P_NORMAL,
-
-		/**
-		 * Default sender details
-		 */
-		'from'		=> array(
-			'email'		=> false,
-			'name'		=> false,
-		),
-
-		/**
-		 * Default return path
-		 */
-		'return_path'   => false,
-
-		/**
-		 * Whether to validate email addresses
-		 */
-		'validate'	=> true,
-
-		/**
-		 * Auto attach inline files
-		 */
-		'auto_attach' => true,
-
-		/**
-		 * Auto generate alt body from html body
-		 */
-		'generate_alt' => true,
-
-		/**
-		 * Forces content type multipart/related to be set as multipart/mixed.
-		 */
-		'force_mixed'   => false,
-
-		/**
-		 * Wordwrap size, set to null, 0 or false to disable wordwrapping
-		 */
-		'wordwrap'	=> 76,
-
-		/**
-		 * Path to sendmail
-		 */
-		'sendmail_path' => '/usr/sbin/sendmail',
-
-		/**
-		 * SMTP settings
-		 */
-		'smtp'	=> array(
-			'host'		=> '',
-			'port'		=> 25,
-			'username'	=> '',
-			'password'	=> '',
-			'timeout'	=> 5,
-		),
-
-		/**
-		 * Newline
-		 */
-		'newline'	=> "\n",
-
-		/**
-		 * Attachment paths
-		 */
-		'attach_paths' => array(
-			// absolute path
-			'',
-			// relative to docroot.
-			DOCROOT,
-		),
-	),
-
-	/**
-	 * Default setup group
-	 */
-	'default_setup' => 'default',
-
-	/**
-	 * Setup groups
-	 */
-	'setups' => array(
-		'default' => array(),
-	),
-
-);

+ 0 - 125
frameworks/PHP/php-fuel/fuel/packages/email/readme.md

@@ -1,125 +0,0 @@
-# Fuel Email Package.
-
-A full fledged email class for Fuel. Send mails using php's mail function, sendmail or SMTP.
-
-# Summary
-
-* Send plain/text or html with (optional) alternative plain/text bodies using mail, sendmail or SMTP.
-* Add attachments, normal or inline and string or file.
-* Automatic inline file attachments for html bodies.
-* Configurable attachment paths.
-
-# Usage
-
-	$mail = Email::forge();
-	$mail->from('[email protected]', 'Your Name Here');
-	
-	// Set to
-	$mail->to('[email protected]');
-	
-	// Set with name
-	$mail->to('[email protected]', 'His/Her Name');
-	
-	// Set as arrau
-	$mail->to(array(
-		// Without name
-		'[email protected]',
-		
-		// With name
-		'[email protected]' => 'His/Her Name',
-	));
-	
-	// Work the same for ->cc and ->bcc and ->reply_to
-	
-	
-	// Set a body message
-	$email->body('My email body');
-	
-	// Set a html body message
-	$email->html_body(\View::forge('email/template', $email_data));
-	
-	/**
-	
-		By default this will also generate an alt body from the html,
-		and attach any inline files (not paths like http://...)
-	
-	**/
-	
-	// Set an alt body
-	$email->alt_body('This is my alt body, for non-html viewers.');
-	
-	// Set a subject
-	$email->subject('This is the subject');
-	
-	// Change the priority
-	$email->priority(\Email::P_HIGH);
-	
-	// And send it
-	$result = $email->send();
-
-# Exceptions
-
-	+ \EmailValidationFailedException, thrown when one or more email addresses doesn't pass validation
-	+ \EmailSendingFailedException, thrown when the driver failed to send the exception
-
-Example:
-
-	// Use the default config and change the driver
-	$email = \Email::forge('default', array('driver' => 'smtp'));
-	$email->subject('My Subject');
-	$email->html_body(\View::forge('email/template', $email_data));
-	$email->from('[email protected]', 'It's Me!');
-	$email->to('[email protected]', 'It's the Other!');
-	
-	try
-	{
-		$email->send();
-	}
-	catch(\EmailValidationFailedException $e)
-	{
-		// The validation failed
-	}
-	catch(\EmailSendingFailedException $e)
-	{
-		// The driver could not send the email
-	}
-	
-# Priorities
-
-These can me one of the following:
-
-	+ \Email::P_LOWEST - 1 (lowest)
-	+ \Email::P_LOW - 2 (low)
-	+ \Email::P_NORMAL - 3 (normal) - this is the default
-	+ \Email::P_HIGH - 4 (high)
-	+ \Email::P_HIGHEST - 5 (highest)
-	
-# Attachments
-
-There are multiple ways to add attachments:
-
-	$email = Email::forge();
-	
-	// Add an attachment
-	$email->attach(DOCROOT.'dir/my_img.png');
-	
-	// Add an inline attachment
-	// Add a cid here to point to the html
-	$email->attach(DOCROOT.'dir/my_img.png', true, 'cid:my_conten_id');
-	
-
-You can also add string attachments
-
-	$contents = file_get_contents($my_file);
-	$email->string_attach($contents, $filename);
-	
-By default html images are auto included, but it only includes local files.
-Look at the following html to see how it works.
-
-	// This is included
-	<img src="path/to/my/file.png" />
-	
-	// This is not included
-	<img src="http://remote_host/file.jpeg" />
-	
-# That's it. Questions?