<?php defined('SYSPATH') or die('No direct script access.');

class Mailer_User extends Mailer {

	public function welcome() 
	{
		$mail=Session::instance()->get('mail');
		$object = ORM::factory('user')->where('email','=' ,$mail)->find();
		
		$this->to 			= array($mail => $object->username);
		$this->bcc			= array('ahmetugur@gmail.com' => 'Admin');
		$this->from 		= array('kampusmarketi@gmail.com' => 'Kampus Marketi');
		$this->subject		= 'Kampus Marketi Şifre Yenileme Onayı';
		//$this->attachments	= array('/path/to/file/file.txt', '/path/to/file/file2.txt');
		$this->body_data 	= array('user' => array('name' => $object->username));
		//Throw new Exception($neew);
	}
	public function hash_password($password, $salt = FALSE)
	{
		if ($salt === FALSE)
		{
			// Create a salt seed, same length as the number of offsets in the pattern
			$salt = substr($this->hash(uniqid(NULL, TRUE)), 0, count($this->config['salt_pattern']));
		}

		// Password hash that the salt will be inserted into
		$hash = $this->hash($salt.$password);

		// Change salt to an array
		$salt = str_split($salt, 1);

		// Returned password
		$password = '';

		// Used to calculate the length of splits
		$last_offset = 0;

		foreach ($this->config['salt_pattern'] as $offset)
		{
			// Split a new part of the hash off
			$part = substr($hash, 0, $offset - $last_offset);

			// Cut the current part out of the hash
			$hash = substr($hash, $offset - $last_offset);

			// Add the part to the password, appending the salt character
			$password .= $part.array_shift($salt);

			// Set the last offset to the current offset
			$last_offset = $offset;
		}

		// Return the password, with the remaining hash appended
		return $password.$hash;
	}
			
}

?>