Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2005 Aurelien 1
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
/**
3
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP 4.3.2 or newer
6
 *
7
 * @package		CodeIgniter
8
 * @author		ExpressionEngine Dev Team
9
 * @copyright	Copyright (c) 2008, EllisLab, Inc.
10
 * @license		http://codeigniter.com/user_guide/license.html
11
 * @link		http://codeigniter.com
12
 * @since		Version 1.0
13
 * @filesource
14
 */
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * CodeIgniter Cookie Helpers
20
 *
21
 * @package		CodeIgniter
22
 * @subpackage	Helpers
23
 * @category	Helpers
24
 * @author		ExpressionEngine Dev Team
25
 * @link		http://codeigniter.com/user_guide/helpers/cookie_helper.html
26
 */
27
28
// ------------------------------------------------------------------------
29
30
/**
31
 * Set cookie
32
 *
33
 * Accepts six parameter, or you can submit an associative
34
 * array in the first parameter containing all the values.
35
 *
36
 * @access	public
37
 * @param	mixed
38
 * @param	string	the value of the cookie
39
 * @param	string	the number of seconds until expiration
40
 * @param	string	the cookie domain.  Usually:  .yourdomain.com
41
 * @param	string	the cookie path
42
 * @param	string	the cookie prefix
43
 * @return	void
44
 */
45
if ( ! function_exists('set_cookie'))
46
{
47
	function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
48
	{
49
		if (is_array($name))
50
		{
51
			foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
52
			{
53
				if (isset($name[$item]))
54
				{
55
					$$item = $name[$item];
56
				}
57
			}
58
		}
59
60
		// Set the config file options
61
		$CI =& get_instance();
62
63
		if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
64
		{
65
			$prefix = $CI->config->item('cookie_prefix');
66
		}
67
		if ($domain == '' AND $CI->config->item('cookie_domain') != '')
68
		{
69
			$domain = $CI->config->item('cookie_domain');
70
		}
71
		if ($path == '/' AND $CI->config->item('cookie_path') != '/')
72
		{
73
			$path = $CI->config->item('cookie_path');
74
		}
75
76
		if ( ! is_numeric($expire))
77
		{
78
			$expire = time() - 86500;
79
		}
80
		else
81
		{
82
			if ($expire > 0)
83
			{
84
				$expire = time() + $expire;
85
			}
86
			else
87
			{
88
				$expire = 0;
89
			}
90
		}
91
92
		setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
93
	}
94
}
95
96
// --------------------------------------------------------------------
97
98
/**
99
 * Fetch an item from the COOKIE array
100
 *
101
 * @access	public
102
 * @param	string
103
 * @param	bool
104
 * @return	mixed
105
 */
106
if ( ! function_exists('get_cookie'))
107
{
108
	function get_cookie($index = '', $xss_clean = FALSE)
109
	{
110
		$CI =& get_instance();
111
		return $CI->input->cookie($index, $xss_clean);
112
	}
113
}
114
115
// --------------------------------------------------------------------
116
117
/**
118
 * Delete a COOKIE
119
 *
120
 * @param	mixed
121
 * @param	string	the cookie domain.  Usually:  .yourdomain.com
122
 * @param	string	the cookie path
123
 * @param	string	the cookie prefix
124
 * @return	void
125
 */
126
if ( ! function_exists('delete_cookie'))
127
{
128
	function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
129
	{
130
		set_cookie($name, '', '', $domain, $path, $prefix);
131
	}
132
}
133
134
135
/* End of file cookie_helper.php */
136
/* Location: ./system/helpers/cookie_helper.php */