Add files using upload-large-folder tool
Browse files- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/agent/config.html +201 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/agent/usage.html +539 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/asset/advanced.html +193 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/asset/config.html +229 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/asset/usage.html +617 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/advanced.html +74 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/config.html +193 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/usage.html +358 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/base.html +312 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/hybrid.html +67 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/rest.html +312 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/template.html +195 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/opauth/usage.html +364 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/ormauth/intro.html +386 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/ormauth/usage.html +1329 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/simpleauth/intro.html +267 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/simpleauth/usage.html +1301 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/acl.html +273 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/group.html +331 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/login.html +571 -0
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/agent/config.html
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Agent::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Agent Config - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Agent Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The agent class allows you to retrieve information about browser type, version, platform or operating system, etc, based on the clients User Agent string.</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3 id="config">Configuration</h3>
|
| 54 |
+
|
| 55 |
+
<p>
|
| 56 |
+
The agent class uses the PHP function <a href="http://php.net/manual/en/function.get-browser.php">get_browser()</a>,
|
| 57 |
+
which attempts to determine the capabilities of the user's browser, by looking up the browser's information in the browscap.ini file.
|
| 58 |
+
</p>
|
| 59 |
+
|
| 60 |
+
<p>The following global configuration values can be defined:</p>
|
| 61 |
+
<table class="config">
|
| 62 |
+
<tbody>
|
| 63 |
+
<tr class="header">
|
| 64 |
+
<th>Param</th>
|
| 65 |
+
<th>Type</th>
|
| 66 |
+
<th>Default</th>
|
| 67 |
+
<th>Description</th>
|
| 68 |
+
</tr>
|
| 69 |
+
<tr>
|
| 70 |
+
<th>browscap</th>
|
| 71 |
+
<td>array</td>
|
| 72 |
+
<td><pre class="php"><code>array(
|
| 73 |
+
'enabled' => true,
|
| 74 |
+
'url' => 'http://browsers.garykeith.com/stream.asp?BrowsCapINI',
|
| 75 |
+
'method' => 'wrapper',
|
| 76 |
+
'file' => '/tmp/php_browscap.ini',
|
| 77 |
+
)</code></pre>
|
| 78 |
+
</td>
|
| 79 |
+
<td>
|
| 80 |
+
browscap.ini retrieval configuration.
|
| 81 |
+
</td>
|
| 82 |
+
</tr>
|
| 83 |
+
<tr>
|
| 84 |
+
<th>cache</th>
|
| 85 |
+
<td>array</td>
|
| 86 |
+
<td><pre class="php"><code>array(
|
| 87 |
+
'driver' => '',
|
| 88 |
+
'expiry' => 604800,
|
| 89 |
+
'identifier' => 'fuel.agent',
|
| 90 |
+
)</code></pre>
|
| 91 |
+
</td>
|
| 92 |
+
<td>
|
| 93 |
+
browscap.ini caching configuration.
|
| 94 |
+
</td>
|
| 95 |
+
</tr>
|
| 96 |
+
</tbody>
|
| 97 |
+
</table>
|
| 98 |
+
|
| 99 |
+
<section>
|
| 100 |
+
<h5 id="browsercap_config">Browscap.ini configuration</h5>
|
| 101 |
+
|
| 102 |
+
<p>
|
| 103 |
+
If PHP has not been configured to use the browscap.ini file, the agent class will retrieve the file from the location defined in
|
| 104 |
+
the <strong>config/agent.php</strong> config file, and cached locally for re-use. This cache will be updated on a regular basis, based
|
| 105 |
+
on the timeout value defined in the configuration.
|
| 106 |
+
</p>
|
| 107 |
+
|
| 108 |
+
<table class="config">
|
| 109 |
+
<tbody>
|
| 110 |
+
<tr class="header">
|
| 111 |
+
<th>Param</th>
|
| 112 |
+
<th>Type</th>
|
| 113 |
+
<th>Default</th>
|
| 114 |
+
<th>Description</th>
|
| 115 |
+
</tr>
|
| 116 |
+
<tr>
|
| 117 |
+
<th>enabled</th>
|
| 118 |
+
<td>boolean</td>
|
| 119 |
+
<td><pre class="php"><code>true</code></pre></td>
|
| 120 |
+
<td>Enable download of the browscap.ini file. If disabled, and PHP has not been configured to the browscap functionality through get_browser(), browser detection is disabled, and the agent class will return 'unknown'.</td>
|
| 121 |
+
</tr>
|
| 122 |
+
<tr>
|
| 123 |
+
<th>method</th>
|
| 124 |
+
<td>string</td>
|
| 125 |
+
<td><pre class="php"><code>'wrapper'</code></pre></td>
|
| 126 |
+
<td>
|
| 127 |
+
Method used to retrieve the browscap.ini file. Supported methods are:<ul style="margin:0;">
|
| 128 |
+
<li>'wrapper': This method uses <strong>file_get_contents()</strong>. This is the preferred option, but it might be disabled by your hosting provider.</li>
|
| 129 |
+
<li>'curl': This method <strong>curl</strong> extensions. You can use this in case the 'wrapper' method doesn't work.</li>
|
| 130 |
+
<li>'local': Use an external method to download the browscap.ini file (for example a cron job).</li>
|
| 131 |
+
<li>'sockets': <em><strong>reserved for future use</strong></em></li>
|
| 132 |
+
</ul>
|
| 133 |
+
</td>
|
| 134 |
+
</tr>
|
| 135 |
+
<tr>
|
| 136 |
+
<th>url</th>
|
| 137 |
+
<td>string</td>
|
| 138 |
+
<td><pre class="php"><code>'http://browsers.garykeith.com/stream.asp?BrowsCapINI'</code></pre></td>
|
| 139 |
+
<td>For the methods 'wrapper', 'curl' and 'sockets', the url to download an update of the browscap.ini file.</td>
|
| 140 |
+
</tr>
|
| 141 |
+
<tr>
|
| 142 |
+
<th>file</th>
|
| 143 |
+
<td>string</td>
|
| 144 |
+
<td><pre class="php"><code>'/tmp/php_browscap.ini'</code></pre></td>
|
| 145 |
+
<td>For the method 'local', the name and location of the browscap.ini file on a local storage system.</td>
|
| 146 |
+
</tr>
|
| 147 |
+
</tbody>
|
| 148 |
+
</table>
|
| 149 |
+
</section>
|
| 150 |
+
|
| 151 |
+
<section>
|
| 152 |
+
<h5 id="cache_config">Cache configuration</h5>
|
| 153 |
+
|
| 154 |
+
<p>
|
| 155 |
+
It the agent class is configured to process a browscap.ini file, it will cache the result of both the ini file parser and individual user agent requests
|
| 156 |
+
in order to increase the response time of the class. These configuration settings determine how the data is cached. For more information, see the <a href="../cache/config.html">Cache</a> class documentation.
|
| 157 |
+
</p>
|
| 158 |
+
|
| 159 |
+
<table class="config">
|
| 160 |
+
<tbody>
|
| 161 |
+
<tr class="header">
|
| 162 |
+
<th>Param</th>
|
| 163 |
+
<th>Type</th>
|
| 164 |
+
<th>Default</th>
|
| 165 |
+
<th>Description</th>
|
| 166 |
+
</tr>
|
| 167 |
+
<tr>
|
| 168 |
+
<th>driver</th>
|
| 169 |
+
<td>string</td>
|
| 170 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 171 |
+
<td>Cache driver to use to cache the agent data. If you leave this empty, the default cache driver, configured in the cache configuration, will be used.</td>
|
| 172 |
+
</tr>
|
| 173 |
+
<tr>
|
| 174 |
+
<th>expiry</th>
|
| 175 |
+
<td>integer</td>
|
| 176 |
+
<td><pre class="php"><code>604800</code></pre></td>
|
| 177 |
+
<td>Number of seconds until the cached data expires. By default, this is 7 days, since the browscap.ini file doesn't change that often. It is recommended not to refresh more frequent than once a day.
|
| 178 |
+
<br />The minumum setting is 7200 seconds (two hours), your server will be banned from the browscap website if you download more often!</td>
|
| 179 |
+
</tr>
|
| 180 |
+
<tr>
|
| 181 |
+
<th>identifier</th>
|
| 182 |
+
<td>string</td>
|
| 183 |
+
<td><pre class="php"><code>'fuel.agent'</code></pre></td>
|
| 184 |
+
<td>Prefix to name of the cache.</td>
|
| 185 |
+
</tr>
|
| 186 |
+
</tbody>
|
| 187 |
+
</table>
|
| 188 |
+
</section>
|
| 189 |
+
|
| 190 |
+
</section>
|
| 191 |
+
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<footer>
|
| 195 |
+
<p>
|
| 196 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 197 |
+
</p>
|
| 198 |
+
</footer>
|
| 199 |
+
</div>
|
| 200 |
+
</body>
|
| 201 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/agent/usage.html
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Agent::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Agent Usage - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Agent Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The agent class allows you to retrieve information about browser type, version, platform or operating system, etc, based on the clients User Agent string.</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h2>Usage</h2>
|
| 54 |
+
|
| 55 |
+
<article>
|
| 56 |
+
<h4 id="method_accepts_charset" class="method">accepts_charset($charset = 'utf-8')</h4>
|
| 57 |
+
<p>Check if the current browser accepts a specific character set.</p>
|
| 58 |
+
<table class="method">
|
| 59 |
+
<tbody>
|
| 60 |
+
<tr>
|
| 61 |
+
<th class="legend">Static</th>
|
| 62 |
+
<td>Yes</td>
|
| 63 |
+
</tr>
|
| 64 |
+
<tr>
|
| 65 |
+
<th>Parameters</th>
|
| 66 |
+
<td>
|
| 67 |
+
<table class="parameters">
|
| 68 |
+
<tr>
|
| 69 |
+
<th>Param</th>
|
| 70 |
+
<th>Default</th>
|
| 71 |
+
<th class="description">Description</th>
|
| 72 |
+
</tr>
|
| 73 |
+
<tr>
|
| 74 |
+
<th><kbd>$charset</kbd></th>
|
| 75 |
+
<td><i>string</i></td>
|
| 76 |
+
<td>Name of the characterset</td>
|
| 77 |
+
</tr>
|
| 78 |
+
</table>
|
| 79 |
+
</td>
|
| 80 |
+
</tr>
|
| 81 |
+
<tr>
|
| 82 |
+
<th>Returns</th>
|
| 83 |
+
<td>boolean</td>
|
| 84 |
+
</tr>
|
| 85 |
+
<tr>
|
| 86 |
+
<th>Example</th>
|
| 87 |
+
<td>
|
| 88 |
+
<pre class="php"><code>// Check if the users browser accepts iso-8859-1
|
| 89 |
+
if (Agent::accepts_charset('iso-8859-1'))
|
| 90 |
+
{
|
| 91 |
+
echo "Yes, the browser accepts this characterset!";
|
| 92 |
+
}
|
| 93 |
+
</code></pre>
|
| 94 |
+
</td>
|
| 95 |
+
</tr>
|
| 96 |
+
</tbody>
|
| 97 |
+
</table>
|
| 98 |
+
</article>
|
| 99 |
+
|
| 100 |
+
<article>
|
| 101 |
+
<h4 id="method_accepts_language" class="method">accepts_language($language = 'en')</h4>
|
| 102 |
+
<p>Check if the current browser accepts a specific ISO language code.</p>
|
| 103 |
+
<table class="method">
|
| 104 |
+
<tbody>
|
| 105 |
+
<tr>
|
| 106 |
+
<th class="legend">Static</th>
|
| 107 |
+
<td>Yes</td>
|
| 108 |
+
</tr>
|
| 109 |
+
<tr>
|
| 110 |
+
<th>Parameters</th>
|
| 111 |
+
<td>
|
| 112 |
+
<table class="parameters">
|
| 113 |
+
<tr>
|
| 114 |
+
<th>Param</th>
|
| 115 |
+
<th>Default</th>
|
| 116 |
+
<th class="description">Description</th>
|
| 117 |
+
</tr>
|
| 118 |
+
<tr>
|
| 119 |
+
<th><kbd>$language</kbd></th>
|
| 120 |
+
<td><i>string</i></td>
|
| 121 |
+
<td>ISO language code</td>
|
| 122 |
+
</tr>
|
| 123 |
+
</table>
|
| 124 |
+
</td>
|
| 125 |
+
</tr>
|
| 126 |
+
<tr>
|
| 127 |
+
<th>Returns</th>
|
| 128 |
+
<td>boolean</td>
|
| 129 |
+
</tr>
|
| 130 |
+
<tr>
|
| 131 |
+
<th>Example</th>
|
| 132 |
+
<td>
|
| 133 |
+
<pre class="php"><code>// Check if the users browser accepts Flemish (Belgian Dutch)
|
| 134 |
+
if (Agent::accepts_language('nl_BE'))
|
| 135 |
+
{
|
| 136 |
+
echo "Yes, the browser is configured for the Flemish language!";
|
| 137 |
+
}
|
| 138 |
+
</code></pre>
|
| 139 |
+
</td>
|
| 140 |
+
</tr>
|
| 141 |
+
</tbody>
|
| 142 |
+
</table>
|
| 143 |
+
</article>
|
| 144 |
+
|
| 145 |
+
<article>
|
| 146 |
+
<h4 id="method_browser" class="method">browser()</h4>
|
| 147 |
+
<p>Returns the normalized browser name from the user agent string.</p>
|
| 148 |
+
<table class="method">
|
| 149 |
+
<tbody>
|
| 150 |
+
<tr>
|
| 151 |
+
<th class="legend">Static</th>
|
| 152 |
+
<td>Yes</td>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<th>Parameters</th>
|
| 156 |
+
<td>None</td>
|
| 157 |
+
</tr>
|
| 158 |
+
<tr>
|
| 159 |
+
<th>Returns</th>
|
| 160 |
+
<td>string</td>
|
| 161 |
+
</tr>
|
| 162 |
+
<tr>
|
| 163 |
+
<th>Example</th>
|
| 164 |
+
<td>
|
| 165 |
+
<pre class="php"><code>// Process based on the browser name
|
| 166 |
+
switch (Agent::browser())
|
| 167 |
+
{
|
| 168 |
+
case 'Firefox':
|
| 169 |
+
// do something specific here
|
| 170 |
+
break;
|
| 171 |
+
case 'IE':
|
| 172 |
+
// do something specific here
|
| 173 |
+
break;
|
| 174 |
+
case 'Chrome':
|
| 175 |
+
// do something specific here
|
| 176 |
+
break;
|
| 177 |
+
case 'Unknown':
|
| 178 |
+
// do something specific here
|
| 179 |
+
break;
|
| 180 |
+
default:
|
| 181 |
+
// these are not all supported browser...
|
| 182 |
+
break;
|
| 183 |
+
}</code></pre>
|
| 184 |
+
</td>
|
| 185 |
+
</tr>
|
| 186 |
+
</tbody>
|
| 187 |
+
</table>
|
| 188 |
+
</article>
|
| 189 |
+
|
| 190 |
+
<article>
|
| 191 |
+
<h4 id="method_platform" class="method">platform()</h4>
|
| 192 |
+
<p>Returns the normalized platform name from the user agent string.</p>
|
| 193 |
+
<table class="method">
|
| 194 |
+
<tbody>
|
| 195 |
+
<tr>
|
| 196 |
+
<th class="legend">Static</th>
|
| 197 |
+
<td>Yes</td>
|
| 198 |
+
</tr>
|
| 199 |
+
<tr>
|
| 200 |
+
<th>Parameters</th>
|
| 201 |
+
<td>None</td>
|
| 202 |
+
</tr>
|
| 203 |
+
<tr>
|
| 204 |
+
<th>Returns</th>
|
| 205 |
+
<td>string</td>
|
| 206 |
+
</tr>
|
| 207 |
+
<tr>
|
| 208 |
+
<th>Example</th>
|
| 209 |
+
<td>
|
| 210 |
+
<pre class="php"><code>// Process based on the browser platform
|
| 211 |
+
switch (Agent::platform())
|
| 212 |
+
{
|
| 213 |
+
case 'Win95':
|
| 214 |
+
case 'Win98':
|
| 215 |
+
case 'WinNT':
|
| 216 |
+
case 'WinME':
|
| 217 |
+
case 'Win2000':
|
| 218 |
+
// do something specific here
|
| 219 |
+
break;
|
| 220 |
+
case 'WinXP':
|
| 221 |
+
case 'WinVista':
|
| 222 |
+
case 'Win7':
|
| 223 |
+
// do something specific here
|
| 224 |
+
break;
|
| 225 |
+
case 'Linux':
|
| 226 |
+
// do something specific here
|
| 227 |
+
break;
|
| 228 |
+
case 'MacOSX':
|
| 229 |
+
case 'MacPPC':
|
| 230 |
+
// do something specific here
|
| 231 |
+
break;
|
| 232 |
+
case 'SunOS':
|
| 233 |
+
case 'FreeBSD':
|
| 234 |
+
case 'Debian':
|
| 235 |
+
case 'HP-UX':
|
| 236 |
+
case 'IRIX64':
|
| 237 |
+
// do something specific here
|
| 238 |
+
break;
|
| 239 |
+
case 'unknown':
|
| 240 |
+
// do something specific here
|
| 241 |
+
break;
|
| 242 |
+
default:
|
| 243 |
+
// these are not all supported platforms...
|
| 244 |
+
break;
|
| 245 |
+
}</code></pre>
|
| 246 |
+
</td>
|
| 247 |
+
</tr>
|
| 248 |
+
</tbody>
|
| 249 |
+
</table>
|
| 250 |
+
</article>
|
| 251 |
+
|
| 252 |
+
<article>
|
| 253 |
+
<h4 id="method_version" class="method">version()</h4>
|
| 254 |
+
<p>Returns the browser version.</p>
|
| 255 |
+
<table class="method">
|
| 256 |
+
<tbody>
|
| 257 |
+
<tr>
|
| 258 |
+
<th class="legend">Static</th>
|
| 259 |
+
<td>Yes</td>
|
| 260 |
+
</tr>
|
| 261 |
+
<tr>
|
| 262 |
+
<th>Parameters</th>
|
| 263 |
+
<td>None</td>
|
| 264 |
+
</tr>
|
| 265 |
+
<tr>
|
| 266 |
+
<th>Returns</th>
|
| 267 |
+
<td>float</td>
|
| 268 |
+
</tr>
|
| 269 |
+
<tr>
|
| 270 |
+
<th>Example</th>
|
| 271 |
+
<td>
|
| 272 |
+
<pre class="php"><code>// Check if an old Internet Explorer version is used
|
| 273 |
+
if (Agent::browser() == 'IE' and Agent::version() < 7)
|
| 274 |
+
{
|
| 275 |
+
echo "Sorry, no support for outdated browsers!";
|
| 276 |
+
}
|
| 277 |
+
</code></pre>
|
| 278 |
+
</td>
|
| 279 |
+
</tr>
|
| 280 |
+
</tbody>
|
| 281 |
+
</table>
|
| 282 |
+
</article>
|
| 283 |
+
|
| 284 |
+
<article>
|
| 285 |
+
<h4 id="method_charsets" class="method">charsets()</h4>
|
| 286 |
+
<p>Returns an array with all charactersets accepted by the browser.</p>
|
| 287 |
+
<table class="method">
|
| 288 |
+
<tbody>
|
| 289 |
+
<tr>
|
| 290 |
+
<th class="legend">Static</th>
|
| 291 |
+
<td>Yes</td>
|
| 292 |
+
</tr>
|
| 293 |
+
<tr>
|
| 294 |
+
<th>Parameters</th>
|
| 295 |
+
<td>None</td>
|
| 296 |
+
</tr>
|
| 297 |
+
<tr>
|
| 298 |
+
<th>Returns</th>
|
| 299 |
+
<td>array</td>
|
| 300 |
+
</tr>
|
| 301 |
+
<tr>
|
| 302 |
+
<th>Example</th>
|
| 303 |
+
<td>
|
| 304 |
+
<pre class="php"><code>// Check if the users browser accepts iso-8859-1
|
| 305 |
+
$sets = Agent::charsets();
|
| 306 |
+
if (in_array('iso-8859-1', $sets))
|
| 307 |
+
{
|
| 308 |
+
echo "Yes, the browser accepts this characterset!";
|
| 309 |
+
}
|
| 310 |
+
</code></pre>
|
| 311 |
+
</td>
|
| 312 |
+
</tr>
|
| 313 |
+
</tbody>
|
| 314 |
+
</table>
|
| 315 |
+
</article>
|
| 316 |
+
|
| 317 |
+
<article>
|
| 318 |
+
<h4 id="method_languages" class="method">languages()</h4>
|
| 319 |
+
<p>Returns an array with all ISO languages accepted by the browser.</p>
|
| 320 |
+
<table class="method">
|
| 321 |
+
<tbody>
|
| 322 |
+
<tr>
|
| 323 |
+
<th class="legend">Static</th>
|
| 324 |
+
<td>Yes</td>
|
| 325 |
+
</tr>
|
| 326 |
+
<tr>
|
| 327 |
+
<th>Parameters</th>
|
| 328 |
+
<td>None</td>
|
| 329 |
+
</tr>
|
| 330 |
+
<tr>
|
| 331 |
+
<th>Returns</th>
|
| 332 |
+
<td>array</td>
|
| 333 |
+
</tr>
|
| 334 |
+
<tr>
|
| 335 |
+
<th>Example</th>
|
| 336 |
+
<td>
|
| 337 |
+
<pre class="php"><code>// Check if the users browser accepts Flemish (Belgian Dutch)
|
| 338 |
+
$lang = Agent::languages();
|
| 339 |
+
if (in_array('nl_BE', $lang))
|
| 340 |
+
{
|
| 341 |
+
echo "Yes, the browser is configured for the Flemish language!";
|
| 342 |
+
}
|
| 343 |
+
</code></pre>
|
| 344 |
+
</td>
|
| 345 |
+
</tr>
|
| 346 |
+
</tbody>
|
| 347 |
+
</table>
|
| 348 |
+
</article>
|
| 349 |
+
|
| 350 |
+
<article>
|
| 351 |
+
<h4 id="method_properties" class="method">properties()</h4>
|
| 352 |
+
<p>Returns an array with all properties of the detected browser.</p>
|
| 353 |
+
<table class="method">
|
| 354 |
+
<tbody>
|
| 355 |
+
<tr>
|
| 356 |
+
<th class="legend">Static</th>
|
| 357 |
+
<td>Yes</td>
|
| 358 |
+
</tr>
|
| 359 |
+
<tr>
|
| 360 |
+
<th>Parameters</th>
|
| 361 |
+
<td>None</td>
|
| 362 |
+
</tr>
|
| 363 |
+
<tr>
|
| 364 |
+
<th>Returns</th>
|
| 365 |
+
<td>array</td>
|
| 366 |
+
</tr>
|
| 367 |
+
<tr>
|
| 368 |
+
<th>Example</th>
|
| 369 |
+
<td>
|
| 370 |
+
<pre class="php"><code>// Get the browser properties
|
| 371 |
+
$properties = Agent::properties();
|
| 372 |
+
|
| 373 |
+
/**
|
| 374 |
+
* These are the supported properties, and their default value
|
| 375 |
+
*
|
| 376 |
+
* $properties = array(
|
| 377 |
+
* 'browser' => "unknown",
|
| 378 |
+
* 'version' => 0,
|
| 379 |
+
* 'majorver' => 0,
|
| 380 |
+
* 'minorver' => 0,
|
| 381 |
+
* 'platform' => 'unknown',
|
| 382 |
+
* 'alpha' => false,
|
| 383 |
+
* 'beta' => false,
|
| 384 |
+
* 'win16' => false,
|
| 385 |
+
* 'win32' => false,
|
| 386 |
+
* 'win64' => false,
|
| 387 |
+
* 'frames' => false,
|
| 388 |
+
* 'iframes' => false,
|
| 389 |
+
* 'tables' => false,
|
| 390 |
+
* 'cookies' => false,
|
| 391 |
+
* 'backgroundsounds' => false,
|
| 392 |
+
* 'javascript' => false,
|
| 393 |
+
* 'vbscript' => false,
|
| 394 |
+
* 'javaapplets' => false,
|
| 395 |
+
* 'activexcontrols' => false,
|
| 396 |
+
* 'isbanned' => false,
|
| 397 |
+
* 'ismobiledevice' => false,
|
| 398 |
+
* 'issyndicationreader' => false,
|
| 399 |
+
* 'crawler' => false,
|
| 400 |
+
* 'cssversion' => 0,
|
| 401 |
+
* 'aolversion' => 0,
|
| 402 |
+
* );
|
| 403 |
+
*
|
| 404 |
+
* Note that the booleans indicate a specific supported functionality.
|
| 405 |
+
* It does not indicated if it is enabled or not.
|
| 406 |
+
*/</code></pre>
|
| 407 |
+
</td>
|
| 408 |
+
</tr>
|
| 409 |
+
</tbody>
|
| 410 |
+
</table>
|
| 411 |
+
</article>
|
| 412 |
+
|
| 413 |
+
<article>
|
| 414 |
+
<h4 id="method_property" class="method">property($property = null)</h4>
|
| 415 |
+
<p>Return a specific browser property. See properties() for the list of supported properties.</p>
|
| 416 |
+
<table class="method">
|
| 417 |
+
<tbody>
|
| 418 |
+
<tr>
|
| 419 |
+
<th class="legend">Static</th>
|
| 420 |
+
<td>Yes</td>
|
| 421 |
+
</tr>
|
| 422 |
+
<tr>
|
| 423 |
+
<th>Parameters</th>
|
| 424 |
+
<td>
|
| 425 |
+
<table class="parameters">
|
| 426 |
+
<tr>
|
| 427 |
+
<th>Param</th>
|
| 428 |
+
<th>Default</th>
|
| 429 |
+
<th class="description">Description</th>
|
| 430 |
+
</tr>
|
| 431 |
+
<tr>
|
| 432 |
+
<th><kbd>$property</kbd></th>
|
| 433 |
+
<td><i>string</i></td>
|
| 434 |
+
<td>Name of the property to retrieve. The name is case-sensitive!</td>
|
| 435 |
+
</tr>
|
| 436 |
+
</table>
|
| 437 |
+
</td>
|
| 438 |
+
</tr>
|
| 439 |
+
<tr>
|
| 440 |
+
<th>Returns</th>
|
| 441 |
+
<td>mixed</td>
|
| 442 |
+
</tr>
|
| 443 |
+
<tr>
|
| 444 |
+
<th>Example</th>
|
| 445 |
+
<td>
|
| 446 |
+
<pre class="php"><code>// Check if the browser supports cookies
|
| 447 |
+
if (Agent::property('cookies') === true)
|
| 448 |
+
{
|
| 449 |
+
echo "Yes, the browser supports Cookies!";
|
| 450 |
+
}
|
| 451 |
+
</code></pre>
|
| 452 |
+
</td>
|
| 453 |
+
</tr>
|
| 454 |
+
</tbody>
|
| 455 |
+
</table>
|
| 456 |
+
</article>
|
| 457 |
+
|
| 458 |
+
<article>
|
| 459 |
+
<h4 id="method_is_mobiledevice" class="method">is_mobiledevice()</h4>
|
| 460 |
+
<p>Checks if the browser used is running on a mobile device.</p>
|
| 461 |
+
<table class="method">
|
| 462 |
+
<tbody>
|
| 463 |
+
<tr>
|
| 464 |
+
<th class="legend">Static</th>
|
| 465 |
+
<td>Yes</td>
|
| 466 |
+
</tr>
|
| 467 |
+
<tr>
|
| 468 |
+
<th>Parameters</th>
|
| 469 |
+
<td>None</td>
|
| 470 |
+
</tr>
|
| 471 |
+
<tr>
|
| 472 |
+
<th>Returns</th>
|
| 473 |
+
<td>boolean</td>
|
| 474 |
+
</tr>
|
| 475 |
+
<tr>
|
| 476 |
+
<th>Example</th>
|
| 477 |
+
<td>
|
| 478 |
+
<pre class="php"><code>// Load a platform specific view
|
| 479 |
+
if (Agent::is_mobiledevice())
|
| 480 |
+
{
|
| 481 |
+
$content = View::forge('mobile/viewname');
|
| 482 |
+
}
|
| 483 |
+
else
|
| 484 |
+
{
|
| 485 |
+
$content = View::forge('standard/viewname');
|
| 486 |
+
}</code></pre>
|
| 487 |
+
</td>
|
| 488 |
+
</tr>
|
| 489 |
+
</tbody>
|
| 490 |
+
</table>
|
| 491 |
+
</article>
|
| 492 |
+
|
| 493 |
+
<article>
|
| 494 |
+
<h4 id="method_is_robot" class="method">is_robot()</h4>
|
| 495 |
+
<p>Checks if the browser agent indicates the visitor is a robot or crawler.</p>
|
| 496 |
+
<table class="method">
|
| 497 |
+
<tbody>
|
| 498 |
+
<tr>
|
| 499 |
+
<th class="legend">Static</th>
|
| 500 |
+
<td>Yes</td>
|
| 501 |
+
</tr>
|
| 502 |
+
<tr>
|
| 503 |
+
<th>Parameters</th>
|
| 504 |
+
<td>None</td>
|
| 505 |
+
</tr>
|
| 506 |
+
<tr>
|
| 507 |
+
<th>Returns</th>
|
| 508 |
+
<td>boolean</td>
|
| 509 |
+
</tr>
|
| 510 |
+
<tr>
|
| 511 |
+
<th>Example</th>
|
| 512 |
+
<td>
|
| 513 |
+
<pre class="php"><code>// Load a crawler specific view (note: this is frowned upon!)
|
| 514 |
+
if (Agent::is_robot())
|
| 515 |
+
{
|
| 516 |
+
$content = View::forge('robot/viewname');
|
| 517 |
+
}
|
| 518 |
+
else
|
| 519 |
+
{
|
| 520 |
+
$content = View::forge('standard/viewname');
|
| 521 |
+
}</code></pre>
|
| 522 |
+
</td>
|
| 523 |
+
</tr>
|
| 524 |
+
</tbody>
|
| 525 |
+
</table>
|
| 526 |
+
</article>
|
| 527 |
+
|
| 528 |
+
</section>
|
| 529 |
+
|
| 530 |
+
</div>
|
| 531 |
+
|
| 532 |
+
<footer>
|
| 533 |
+
<p>
|
| 534 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 535 |
+
</p>
|
| 536 |
+
</footer>
|
| 537 |
+
</div>
|
| 538 |
+
</body>
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Asset::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Asset Advanced - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Asset Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The asset class is a set of methods to help with the collection, grouping and displaying of assets (js, css, img).</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3>Advanced usage</h3>
|
| 54 |
+
|
| 55 |
+
<p>
|
| 56 |
+
The Asset class supports the use of multiple instances. This might prove useful if you are using themes, where
|
| 57 |
+
every theme has its own set of assets, or you are developing a modular application where each module provides
|
| 58 |
+
its own set of assets.
|
| 59 |
+
</p>
|
| 60 |
+
<p>
|
| 61 |
+
In these cases, it would not be handy to have only a single instance and use search paths, since the chances of
|
| 62 |
+
a duplicate asset name are quite high, causing your application to load the wrong asset.
|
| 63 |
+
</p>
|
| 64 |
+
<p>
|
| 65 |
+
You can use the same methods on an asset instance as you would when you the static methods. For the method
|
| 66 |
+
definition see the <a href="./usage.html">class usage</a> page.
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<article>
|
| 70 |
+
<h4 class="method" id="method_forge">forge($config = array())</h4>
|
| 71 |
+
<p>
|
| 72 |
+
The <strong>forge</strong> method allows you to manually instantiate an asset instance.
|
| 73 |
+
</p>
|
| 74 |
+
<table class="method">
|
| 75 |
+
<tbody>
|
| 76 |
+
<tr>
|
| 77 |
+
<th>Static</th>
|
| 78 |
+
<td>Yes</td>
|
| 79 |
+
</tr>
|
| 80 |
+
<tr>
|
| 81 |
+
<th>Parameters</th>
|
| 82 |
+
<td>
|
| 83 |
+
<table class="parameters">
|
| 84 |
+
<tr>
|
| 85 |
+
<th>Param</th>
|
| 86 |
+
<th>Default</th>
|
| 87 |
+
<th>Description</th>
|
| 88 |
+
</tr>
|
| 89 |
+
<tr>
|
| 90 |
+
<th><kbd>$name</kbd></th>
|
| 91 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 92 |
+
<td>
|
| 93 |
+
Name of the instance requested. If it doesn't exist, it will be forged. If no name is
|
| 94 |
+
given, the default instance is returned.
|
| 95 |
+
</td>
|
| 96 |
+
</tr>
|
| 97 |
+
<tr>
|
| 98 |
+
<th><kbd>$config</kbd></th>
|
| 99 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 100 |
+
<td>
|
| 101 |
+
You can pass a custom configuration when forging a new asset instance. The configuration array
|
| 102 |
+
has the same structure as the asset configuration file. The custom config will be merged with
|
| 103 |
+
a default configuration as documented <a href="./config.html">here</a> and with the
|
| 104 |
+
configuration in your asset config file, so you only have to pass values you want changed.
|
| 105 |
+
</td>
|
| 106 |
+
</tr>
|
| 107 |
+
</table>
|
| 108 |
+
</td>
|
| 109 |
+
</tr>
|
| 110 |
+
<tr>
|
| 111 |
+
<th>Returns</th>
|
| 112 |
+
<td>object - The instantiated asset object.</td>
|
| 113 |
+
</tr>
|
| 114 |
+
<tr>
|
| 115 |
+
<th>Example</th>
|
| 116 |
+
<td>
|
| 117 |
+
<pre class="php"><code>// instantiate a asset object with a custom search path
|
| 118 |
+
$asset = Asset::forge('custom', array('paths' => 'custom/assets/');
|
| 119 |
+
|
| 120 |
+
// define some css files
|
| 121 |
+
$asset->css(array('header.css', 'footer.css'), array(), 'layout', false);</code></pre>
|
| 122 |
+
</td>
|
| 123 |
+
</tr>
|
| 124 |
+
</tbody>
|
| 125 |
+
</table>
|
| 126 |
+
</article>
|
| 127 |
+
|
| 128 |
+
<article>
|
| 129 |
+
<h4 class="method" id="method_instance">instance($name = null)</h4>
|
| 130 |
+
<p>
|
| 131 |
+
The <strong>instance</strong> method allows you load a named instance of the asset class.
|
| 132 |
+
</p>
|
| 133 |
+
<table class="method">
|
| 134 |
+
<tbody>
|
| 135 |
+
<tr>
|
| 136 |
+
<th>Static</th>
|
| 137 |
+
<td>Yes</td>
|
| 138 |
+
</tr>
|
| 139 |
+
<tr>
|
| 140 |
+
<th>Parameters</th>
|
| 141 |
+
<td>
|
| 142 |
+
<table class="parameters">
|
| 143 |
+
<tr>
|
| 144 |
+
<th>Param</th>
|
| 145 |
+
<th>Default</th>
|
| 146 |
+
<th>Description</th>
|
| 147 |
+
</tr>
|
| 148 |
+
<tr>
|
| 149 |
+
<th><kbd>$name</kbd></th>
|
| 150 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 151 |
+
<td>
|
| 152 |
+
Name of the instance requested. If it doesn't exist, false is returned. If no name is
|
| 153 |
+
given, the default instance is returned.
|
| 154 |
+
</td>
|
| 155 |
+
</tr>
|
| 156 |
+
</table>
|
| 157 |
+
</td>
|
| 158 |
+
</tr>
|
| 159 |
+
<tr>
|
| 160 |
+
<th>Returns</th>
|
| 161 |
+
<td>mixed - The named asset instance or false if the instance does not exist.</td>
|
| 162 |
+
</tr>
|
| 163 |
+
<tr>
|
| 164 |
+
<th>Example</th>
|
| 165 |
+
<td>
|
| 166 |
+
<pre class="php"><code>// instantiate a named asset object with a custom search path
|
| 167 |
+
Asset::forge('custom', array('paths' => 'custom/assets/'));
|
| 168 |
+
|
| 169 |
+
// define some css files using the defined instance
|
| 170 |
+
Asset::instance('custom')->css(array('header.css', 'footer.css'), array(), 'layout', false);</code></pre>
|
| 171 |
+
</td>
|
| 172 |
+
</tr>
|
| 173 |
+
</tbody>
|
| 174 |
+
</table>
|
| 175 |
+
</article>
|
| 176 |
+
|
| 177 |
+
<p class="note">
|
| 178 |
+
The static methods of the Asset class will also use the default instance. Remember this if you
|
| 179 |
+
alter the configuration (for example search paths) of the default instance!
|
| 180 |
+
</p>
|
| 181 |
+
|
| 182 |
+
</section>
|
| 183 |
+
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<footer>
|
| 187 |
+
<p>
|
| 188 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 189 |
+
</p>
|
| 190 |
+
</footer>
|
| 191 |
+
</div>
|
| 192 |
+
</body>
|
| 193 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/asset/config.html
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Asset::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Asset Config - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Asset Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The asset class is a set of methods to help with the collection, grouping and displaying of assets (js, css, img).</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3 id="config">Configuration</h3>
|
| 54 |
+
|
| 55 |
+
<p>The asset class's defaults are configured through the fuel/core/config/asset.php configuration file. It
|
| 56 |
+
is already populated with a default configuration. You can override this configuration adding a config file
|
| 57 |
+
with the same name to your application config directory, and set the values you want to change there. These
|
| 58 |
+
will overwrite the core config but keep what you didn't overwrite.</p>
|
| 59 |
+
|
| 60 |
+
<p>The following global configuration values can be defined:</p>
|
| 61 |
+
<table class="config">
|
| 62 |
+
<tbody>
|
| 63 |
+
<tr class="header">
|
| 64 |
+
<th>Param</th>
|
| 65 |
+
<th>Type</th>
|
| 66 |
+
<th>Default</th>
|
| 67 |
+
<th>Description</th>
|
| 68 |
+
</tr>
|
| 69 |
+
<tr>
|
| 70 |
+
<th>paths</th>
|
| 71 |
+
<td>array</td>
|
| 72 |
+
<td><pre class="php"><code>array('assets/')</code></pre></td>
|
| 73 |
+
<td>
|
| 74 |
+
The default asset root paths. Paths must include a trailing slash.
|
| 75 |
+
</td>
|
| 76 |
+
</tr>
|
| 77 |
+
<tr>
|
| 78 |
+
<th>css_dir</th>
|
| 79 |
+
<td>string</td>
|
| 80 |
+
<td><pre class="php"><code>'css/'</code></pre></td>
|
| 81 |
+
<td>
|
| 82 |
+
The default css sub-folder. It must include a trailing slash.
|
| 83 |
+
</td>
|
| 84 |
+
</tr>
|
| 85 |
+
<tr>
|
| 86 |
+
<th>js_dir</th>
|
| 87 |
+
<td>string</td>
|
| 88 |
+
<td><pre class="php"><code>'js/'</code></pre></td>
|
| 89 |
+
<td>
|
| 90 |
+
The default js sub-folder. It must include a trailing slash.
|
| 91 |
+
</td>
|
| 92 |
+
</tr>
|
| 93 |
+
<tr>
|
| 94 |
+
<th>img_dir</th>
|
| 95 |
+
<td>string</td>
|
| 96 |
+
<td><pre class="php"><code>'img/'</code></pre></td>
|
| 97 |
+
<td>
|
| 98 |
+
The default image sub-folder. It must include a trailing slash.
|
| 99 |
+
</td>
|
| 100 |
+
</tr>
|
| 101 |
+
<tr>
|
| 102 |
+
<th>folders</th>
|
| 103 |
+
<td>array</td>
|
| 104 |
+
<td><pre class="php"><code>array(
|
| 105 |
+
'css' => array(),
|
| 106 |
+
'js' => array(),
|
| 107 |
+
'img' => array(),
|
| 108 |
+
),
|
| 109 |
+
</code></pre></td>
|
| 110 |
+
<td>
|
| 111 |
+
To specify one or more individual asset folders per asset type.
|
| 112 |
+
</td>
|
| 113 |
+
</tr>
|
| 114 |
+
<tr>
|
| 115 |
+
<th>url</th>
|
| 116 |
+
<td>string</td>
|
| 117 |
+
<td><pre class="php"><code>\Config::get('base_url')</code></pre></td>
|
| 118 |
+
<td>
|
| 119 |
+
URL to the root of your assets. When loading an asset, the asset path and the asset name will be appended to this URL.
|
| 120 |
+
</td>
|
| 121 |
+
</tr>
|
| 122 |
+
<tr>
|
| 123 |
+
<th>add_mtime</th>
|
| 124 |
+
<td>bool</td>
|
| 125 |
+
<td><pre class="php"><code>true</code></pre></td>
|
| 126 |
+
<td>
|
| 127 |
+
Whether to append the assets last modified timestamp to the url. This will aid in asset caching, and is recommended.
|
| 128 |
+
</td>
|
| 129 |
+
</tr>
|
| 130 |
+
<tr>
|
| 131 |
+
<th>indent_level</th>
|
| 132 |
+
<td>integer</td>
|
| 133 |
+
<td><pre class="php"><code>1</code></pre></td>
|
| 134 |
+
<td>
|
| 135 |
+
To keep the generated HTML tidy, the Asset class can indent tags. This sets the level of indentation.
|
| 136 |
+
</td>
|
| 137 |
+
</tr>
|
| 138 |
+
<tr>
|
| 139 |
+
<th>indent_with</th>
|
| 140 |
+
<td>string</td>
|
| 141 |
+
<td><pre class="php"><code>"\t"</code></pre></td>
|
| 142 |
+
<td>
|
| 143 |
+
String to indent the generated HTML with. This defaults to a single tab.
|
| 144 |
+
</td>
|
| 145 |
+
</tr>
|
| 146 |
+
<tr>
|
| 147 |
+
<th>auto_render</th>
|
| 148 |
+
<td>bool</td>
|
| 149 |
+
<td><pre class="php"><code>true</code></pre></td>
|
| 150 |
+
<td>
|
| 151 |
+
This controls whether to return the generated HTML when an asset method is called without a group name.
|
| 152 |
+
If false, the asset will be added to the default group to be rendered later.
|
| 153 |
+
</td>
|
| 154 |
+
</tr>
|
| 155 |
+
<tr>
|
| 156 |
+
<th>fail_silently</th>
|
| 157 |
+
<td>bool</td>
|
| 158 |
+
<td><pre class="php"><code>false</code></pre></td>
|
| 159 |
+
<td>
|
| 160 |
+
When set to true the exception will not be thrown when an asset file is not found.
|
| 161 |
+
The asset will then be ignored.
|
| 162 |
+
</td>
|
| 163 |
+
</tr>
|
| 164 |
+
</tbody>
|
| 165 |
+
</table>
|
| 166 |
+
</section>
|
| 167 |
+
|
| 168 |
+
<section>
|
| 169 |
+
<h3 id="asset_paths">Asset paths</h3>
|
| 170 |
+
|
| 171 |
+
<p>
|
| 172 |
+
There are several ways to define asset paths. You can define global asset search paths, which define the 'root'
|
| 173 |
+
of your assets. The sub-folder defined for the loaded asset is appended to these paths when searching for an asset.
|
| 174 |
+
If you use multiple global search paths, they must all use the same sub-folder structure.
|
| 175 |
+
<pre class="php"><code>// assuming:
|
| 176 |
+
// - your URL is "http://example.org/"
|
| 177 |
+
// - your global search path is "assets/"
|
| 178 |
+
// - your img_dir is "img/"
|
| 179 |
+
// this would return <img src="http://example.org/assets/img/icons/myicon.png" />
|
| 180 |
+
echo Asset::img('icons/myicon.png');
|
| 181 |
+
</code></pre>
|
| 182 |
+
</p>
|
| 183 |
+
|
| 184 |
+
<p>
|
| 185 |
+
If you don't want a standard sub-folder structure, or you have to work in an existing environment in which
|
| 186 |
+
the asset paths are already defined, the Asset class allows you to define the individual asset search folders
|
| 187 |
+
for each type of asset supported.
|
| 188 |
+
<pre class="php"><code>// if this is your config
|
| 189 |
+
// 'folders' => array(
|
| 190 |
+
// 'css' => array('assets/css'),
|
| 191 |
+
// 'js' => array('assets/js', 'global/js/'),
|
| 192 |
+
// 'img' => array('assets/img/', 'assets/icons'),
|
| 193 |
+
// ),
|
| 194 |
+
// and your icons are in 'assets/icons',
|
| 195 |
+
// this would return <img src="http://example.org/assets/icons/myicon.png" />
|
| 196 |
+
echo Asset::img('myicon.png');
|
| 197 |
+
</code></pre>
|
| 198 |
+
</p>
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
<p>Both search paths and search folders can be defined at runtime using the <a href="./usage.html#method_add_path">add_path()</a> method.</p>
|
| 202 |
+
</section>
|
| 203 |
+
|
| 204 |
+
<section>
|
| 205 |
+
<h3 id="static_assets">Static assets</h3>
|
| 206 |
+
|
| 207 |
+
<p>
|
| 208 |
+
If (some of your) your assets are not stored within the docroot of the application but are using a different host in the URL,
|
| 209 |
+
you use the following techniques to load an asset:
|
| 210 |
+
<pre class="php"><code>// individually, per asset
|
| 211 |
+
echo Asset::img('http://static.example.org/icons/myicon.png');
|
| 212 |
+
|
| 213 |
+
// for all sets, set your Asset URL to 'http://static.example.org/'
|
| 214 |
+
echo Asset::img('icons/myicon.png');
|
| 215 |
+
</code></pre>
|
| 216 |
+
In this case search paths are ignored.
|
| 217 |
+
</p>
|
| 218 |
+
</section>
|
| 219 |
+
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<footer>
|
| 223 |
+
<p>
|
| 224 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 225 |
+
</p>
|
| 226 |
+
</footer>
|
| 227 |
+
</div>
|
| 228 |
+
</body>
|
| 229 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/asset/usage.html
ADDED
|
@@ -0,0 +1,617 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Asset::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Asset Usage - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Asset Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The asset class is a set of methods to help with the collection, grouping and displaying of assets (js, css, img).</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3 id="usage">Usage</h3>
|
| 54 |
+
|
| 55 |
+
<p>
|
| 56 |
+
Using assets can be done in 2 ways: through static usage of the Asset class and through asset objects
|
| 57 |
+
returned by the Asset::forge() or Asset::instance(). This section covers static usage which will always work
|
| 58 |
+
with the default instance using the configuration specified in the <a href="config.html">configuration</a>.
|
| 59 |
+
</p>
|
| 60 |
+
|
| 61 |
+
<p class="note">
|
| 62 |
+
<strong>Note:</strong> the css, js and img methods will return the current instance when adding to a group.
|
| 63 |
+
This will happen when you supply a group or <em>auto_render</em> is <em>false</em> and no group (or
|
| 64 |
+
<em>null</em>) is supplied in the call.
|
| 65 |
+
</p>
|
| 66 |
+
|
| 67 |
+
<p>
|
| 68 |
+
Using asset objects, Asset::instance() and Asset::forge() is explained in the <a href="advanced.html">advanced</a> section.
|
| 69 |
+
</p>
|
| 70 |
+
|
| 71 |
+
<article>
|
| 72 |
+
<h4 id="method_add_path" class="method">add_path($path, $type = null)</h4>
|
| 73 |
+
<p>
|
| 74 |
+
The <strong>add_path</strong> method adds the given path to the front of the global assets search path array.
|
| 75 |
+
If a $type is specified, it will add the path to the front of the search folder array for the given type.
|
| 76 |
+
</p>
|
| 77 |
+
<table class="method">
|
| 78 |
+
<tbody>
|
| 79 |
+
<tr>
|
| 80 |
+
<th class="legend">Static</th>
|
| 81 |
+
<td>Yes</td>
|
| 82 |
+
</tr>
|
| 83 |
+
<tr>
|
| 84 |
+
<th>Parameters</th>
|
| 85 |
+
<td>
|
| 86 |
+
<table class="parameters">
|
| 87 |
+
<tr>
|
| 88 |
+
<th>Param</th>
|
| 89 |
+
<th>Default</th>
|
| 90 |
+
<th class="description">Description</th>
|
| 91 |
+
</tr>
|
| 92 |
+
<tr>
|
| 93 |
+
<th><kbd>$path</kbd></th>
|
| 94 |
+
<td><i>required</i></td>
|
| 95 |
+
<td>The path to add to the front of the assets path array (RELATIVE to the asset url and WITH trailing slash).</td>
|
| 96 |
+
</tr>
|
| 97 |
+
<tr>
|
| 98 |
+
<th><kbd>$type</kbd></th>
|
| 99 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 100 |
+
<td>
|
| 101 |
+
If adding a folder, the type to add it to. The asset class has the types 'img', 'css' and 'js' predefined.
|
| 102 |
+
If you pass an undefined type, a new paths structure will be created for this type.
|
| 103 |
+
To add the same path to multiple types, pass them as an array of types.
|
| 104 |
+
</td>
|
| 105 |
+
</tr>
|
| 106 |
+
</table>
|
| 107 |
+
</td>
|
| 108 |
+
</tr>
|
| 109 |
+
<tr>
|
| 110 |
+
<th>Returns</th>
|
| 111 |
+
<td>current instance</td>
|
| 112 |
+
</tr>
|
| 113 |
+
<tr>
|
| 114 |
+
<th>Example</th>
|
| 115 |
+
<td>
|
| 116 |
+
<pre class="php"><code>/*
|
| 117 |
+
* These paths would need to have subfolders as defined in the config
|
| 118 |
+
* file, depending on the type of content you were trying to use.
|
| 119 |
+
*/
|
| 120 |
+
Asset::add_path('resources/template_1/');
|
| 121 |
+
Asset::add_path('resources/template_2/');
|
| 122 |
+
|
| 123 |
+
/*
|
| 124 |
+
* Add a global path for all asset types, then add individual paths
|
| 125 |
+
* for images and css files.
|
| 126 |
+
*/
|
| 127 |
+
Asset::add_path('assets/global/', array('css', 'js', 'img'));
|
| 128 |
+
Asset::add_path('assets/icons/', 'img');
|
| 129 |
+
Asset::add_path('assets/images/', 'img');
|
| 130 |
+
Asset::add_path('assets/css/', 'css');
|
| 131 |
+
|
| 132 |
+
/*
|
| 133 |
+
* Create a new asset type
|
| 134 |
+
*/
|
| 135 |
+
Asset::add_path('assets/docs/', 'pdf');
|
| 136 |
+
|
| 137 |
+
/*
|
| 138 |
+
* You can chain the calls as well.
|
| 139 |
+
*/
|
| 140 |
+
Asset::add_path('resources/templates/dark/')
|
| 141 |
+
->add_path('resources/templates/light')
|
| 142 |
+
->add_path('resources/templates/brown');
|
| 143 |
+
</code></pre>
|
| 144 |
+
</td>
|
| 145 |
+
</tr>
|
| 146 |
+
</tbody>
|
| 147 |
+
</table>
|
| 148 |
+
</article>
|
| 149 |
+
|
| 150 |
+
<article>
|
| 151 |
+
<h4 id="method_css" class="method">css($stylesheets = array(), $attr = array(), $group = NULL, $raw = false)</h4>
|
| 152 |
+
<p>The <strong>css</strong> method adds css to a named group, the default group, or returns the css tag.</p>
|
| 153 |
+
<table class="method">
|
| 154 |
+
<tbody>
|
| 155 |
+
<tr>
|
| 156 |
+
<th class="legend">Static</th>
|
| 157 |
+
<td>Yes</td>
|
| 158 |
+
</tr>
|
| 159 |
+
<tr>
|
| 160 |
+
<th>Parameters</th>
|
| 161 |
+
<td>
|
| 162 |
+
<table class="parameters">
|
| 163 |
+
<tr>
|
| 164 |
+
<th>Param</th>
|
| 165 |
+
<th>Default</th>
|
| 166 |
+
<th class="description">Description</th>
|
| 167 |
+
</tr>
|
| 168 |
+
<tr>
|
| 169 |
+
<th><kbd>$stylesheets</kbd></th>
|
| 170 |
+
<td><i>required</i></td>
|
| 171 |
+
<td>An array/string of stylesheet filename(s) to be added to the group or be returned as tags, or a string containing inline CSS.</td>
|
| 172 |
+
</tr>
|
| 173 |
+
<tr>
|
| 174 |
+
<th><kbd>$attr</kbd></th>
|
| 175 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 176 |
+
<td>An array of attributes to be applied to the css file(s).</td>
|
| 177 |
+
</tr>
|
| 178 |
+
<tr>
|
| 179 |
+
<th><kbd>$group</kbd></th>
|
| 180 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 181 |
+
<td>A group name to categorize the css. If left null the method will return the css tag.</td>
|
| 182 |
+
</tr>
|
| 183 |
+
<tr>
|
| 184 |
+
<th><kbd>$raw</kbd></th>
|
| 185 |
+
<td><pre class="php"><code>false</code></pre></td>
|
| 186 |
+
<td>If set to true, the result css tags will include the string or file contents directly in the HTML, instead of via a link tag.</td>
|
| 187 |
+
</tr>
|
| 188 |
+
</table>
|
| 189 |
+
</td>
|
| 190 |
+
</tr>
|
| 191 |
+
<tr>
|
| 192 |
+
<th>Returns</th>
|
| 193 |
+
<td>Rendered asset string or current instance when adding to group.</td>
|
| 194 |
+
</tr>
|
| 195 |
+
<tr>
|
| 196 |
+
<th>Example</th>
|
| 197 |
+
<td>
|
| 198 |
+
<pre class="php"><code>// adds file to group and returns '' if group is not null
|
| 199 |
+
Asset::css(array('header.css', 'footer.css'), array(), 'layout', false);
|
| 200 |
+
|
| 201 |
+
/* returns
|
| 202 |
+
* <link href="../assets/css/inline.css" rel="stylesheet" />
|
| 203 |
+
* if auto_render in the config is set to true.
|
| 204 |
+
* if not, the asset will be added to the default group for later rendering
|
| 205 |
+
*/
|
| 206 |
+
echo Asset::css('inline.css');
|
| 207 |
+
|
| 208 |
+
/* returns
|
| 209 |
+
* <style>
|
| 210 |
+
* .bold_class { font-weight: bold }
|
| 211 |
+
* #header {height: 50px}
|
| 212 |
+
* </style>
|
| 213 |
+
*/
|
| 214 |
+
echo Asset::css('inline.css', array(), null, true);
|
| 215 |
+
|
| 216 |
+
/* returns
|
| 217 |
+
* <style>
|
| 218 |
+
* .bold_class { font-weight: bold }
|
| 219 |
+
* #header {height: 50px}
|
| 220 |
+
* </style>
|
| 221 |
+
*/
|
| 222 |
+
Asset::css(".bold_class { font-weight: bold }\n#header {height: 50px}", array(), 'inline', true);
|
| 223 |
+
echo Asset::render('inline');
|
| 224 |
+
|
| 225 |
+
/* this will do the same */
|
| 226 |
+
echo Asset::css(".bold_class { font-weight: bold }\n#header {height: 50px}", array(), null, true);
|
| 227 |
+
</code></pre>
|
| 228 |
+
</td>
|
| 229 |
+
</tr>
|
| 230 |
+
</tbody>
|
| 231 |
+
</table>
|
| 232 |
+
</article>
|
| 233 |
+
|
| 234 |
+
<article>
|
| 235 |
+
<h4 id="method_find_file" class="method">find_file($file, $type, $folder = '')</h4>
|
| 236 |
+
<p>The <strong>find_file</strong> locates a file of a given type in all defined asset search folders for that type.</p>
|
| 237 |
+
<table class="method">
|
| 238 |
+
<tbody>
|
| 239 |
+
<tr>
|
| 240 |
+
<th class="legend">Static</th>
|
| 241 |
+
<td>Yes</td>
|
| 242 |
+
</tr>
|
| 243 |
+
<tr>
|
| 244 |
+
<th>Parameters</th>
|
| 245 |
+
<td>
|
| 246 |
+
<table class="parameters">
|
| 247 |
+
<tr>
|
| 248 |
+
<th>Param</th>
|
| 249 |
+
<th>Default</th>
|
| 250 |
+
<th class="description">Description</th>
|
| 251 |
+
</tr>
|
| 252 |
+
<tr>
|
| 253 |
+
<th><kbd>$file</kbd></th>
|
| 254 |
+
<td><i>required</i></td>
|
| 255 |
+
<td>The name of the file you are searching for.</td>
|
| 256 |
+
</tr>
|
| 257 |
+
<tr>
|
| 258 |
+
<th><kbd>$type</kbd></th>
|
| 259 |
+
<td><i>required</i></td>
|
| 260 |
+
<td>The type of asset being searched (css, js, img).</td>
|
| 261 |
+
</tr>
|
| 262 |
+
<tr>
|
| 263 |
+
<th><kbd>$folder</kbd></th>
|
| 264 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 265 |
+
<td>The name of the sub-folder to append to each search folder.</td>
|
| 266 |
+
</tr>
|
| 267 |
+
</table>
|
| 268 |
+
</td>
|
| 269 |
+
</tr>
|
| 270 |
+
<tr>
|
| 271 |
+
<th>Returns</th>
|
| 272 |
+
<td>Either the path to the file or false if not found</td>
|
| 273 |
+
</tr>
|
| 274 |
+
<tr>
|
| 275 |
+
<th>Example</th>
|
| 276 |
+
<td>
|
| 277 |
+
<pre class="php"><code>// find a css file
|
| 278 |
+
$path = Asset::find_file('layout.css', 'css');
|
| 279 |
+
|
| 280 |
+
// find an icon image (assuming icons are in an img sub-folder called 'icons')
|
| 281 |
+
$path = Asset::find_file('icon.png', 'img','icons/');</code></pre>
|
| 282 |
+
</td>
|
| 283 |
+
</tr>
|
| 284 |
+
</tbody>
|
| 285 |
+
</table>
|
| 286 |
+
</article>
|
| 287 |
+
|
| 288 |
+
<article>
|
| 289 |
+
<h4 id="method_img" class="method">img($images = array(), $attr = array(), $group = NULL)</h4>
|
| 290 |
+
<p>The <strong>img</strong> method either adds the image to a named group, the default group, or returns the image tag.</p>
|
| 291 |
+
<table class="method">
|
| 292 |
+
<tbody>
|
| 293 |
+
<tr>
|
| 294 |
+
<th class="legend">Static</th>
|
| 295 |
+
<td>Yes</td>
|
| 296 |
+
</tr>
|
| 297 |
+
<tr>
|
| 298 |
+
<th>Parameters</th>
|
| 299 |
+
<td>
|
| 300 |
+
<table class="parameters">
|
| 301 |
+
<tr>
|
| 302 |
+
<th>Param</th>
|
| 303 |
+
<th>Default</th>
|
| 304 |
+
<th class="description">Description</th>
|
| 305 |
+
</tr>
|
| 306 |
+
<tr>
|
| 307 |
+
<th><kbd>$images</kbd></th>
|
| 308 |
+
<td><i>required</i></td>
|
| 309 |
+
<td>An array/string of image filename(s) to be applied to the group or returned as tags.</td>
|
| 310 |
+
</tr>
|
| 311 |
+
<tr>
|
| 312 |
+
<th><kbd>$attr</kbd></th>
|
| 313 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 314 |
+
<td>An array of attributes to apply to the image tag(s).</td>
|
| 315 |
+
</tr>
|
| 316 |
+
<tr>
|
| 317 |
+
<th><kbd>$group</kbd></th>
|
| 318 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 319 |
+
<td>The group to apply the images to.</td>
|
| 320 |
+
</tr>
|
| 321 |
+
</table>
|
| 322 |
+
</td>
|
| 323 |
+
</tr>
|
| 324 |
+
<tr>
|
| 325 |
+
<th>Returns</th>
|
| 326 |
+
<td>Rendered asset string or current instance when adding to group.</td>
|
| 327 |
+
</tr>
|
| 328 |
+
<tr>
|
| 329 |
+
<th>Example</th>
|
| 330 |
+
<td>
|
| 331 |
+
<pre class="php"><code>/* returns
|
| 332 |
+
* <img src="../assets/img/logo.png" id="logo">
|
| 333 |
+
* if auto_render in the config is set to true.
|
| 334 |
+
* if not, the asset will be added to the default group for later rendering
|
| 335 |
+
*/
|
| 336 |
+
echo Asset::img('logo.png', array('id' => 'logo'));
|
| 337 |
+
|
| 338 |
+
Asset::img(array('bob.jpg', 'joe.jpg', 'sally.jpg'), array('class' => 'thumbnail'), 'team_avatars');</code></pre>
|
| 339 |
+
</td>
|
| 340 |
+
</tr>
|
| 341 |
+
</tbody>
|
| 342 |
+
</table>
|
| 343 |
+
</article>
|
| 344 |
+
|
| 345 |
+
<article>
|
| 346 |
+
<h4 id="method_js" class="method">js($scripts = array(), $attr = array(), $group = NULL, $raw = false)</h4>
|
| 347 |
+
<p>The <strong>js</strong> method either adds the javascript to a named group, the default group, or returns the script tag.</p>
|
| 348 |
+
<table class="method">
|
| 349 |
+
<tbody>
|
| 350 |
+
<tr>
|
| 351 |
+
<th class="legend">Static</th>
|
| 352 |
+
<td>Yes</td>
|
| 353 |
+
</tr>
|
| 354 |
+
<tr>
|
| 355 |
+
<th>Parameters</th>
|
| 356 |
+
<td>
|
| 357 |
+
<table class="parameters">
|
| 358 |
+
<tr>
|
| 359 |
+
<th>Param</th>
|
| 360 |
+
<th>Default</th>
|
| 361 |
+
<th class="description">Description</th>
|
| 362 |
+
</tr>
|
| 363 |
+
<tr>
|
| 364 |
+
<th><kbd>$scripts</kbd></th>
|
| 365 |
+
<td><i>required</i></td>
|
| 366 |
+
<td>An array/string of stylesheet filename(s) to be added to the group or be returned as tags, or a string containing inline javascript.</td>
|
| 367 |
+
</tr>
|
| 368 |
+
<tr>
|
| 369 |
+
<th><kbd>$attr</kbd></th>
|
| 370 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 371 |
+
<td>An array of attributes to be applied to the js file(s).</td>
|
| 372 |
+
</tr>
|
| 373 |
+
<tr>
|
| 374 |
+
<th><kbd>$group</kbd></th>
|
| 375 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 376 |
+
<td>A group name to categorize the js. If left null the method will return the js tag.</td>
|
| 377 |
+
</tr>
|
| 378 |
+
<tr>
|
| 379 |
+
<th><kbd>$raw</kbd></th>
|
| 380 |
+
<td><pre class="php"><code>false</code></pre></td>
|
| 381 |
+
<td>If set to true, the result javascript tags will include the string or file contents directly in the HTML, instead of via a script tag.</td>
|
| 382 |
+
</tr>
|
| 383 |
+
</table>
|
| 384 |
+
</td>
|
| 385 |
+
</tr>
|
| 386 |
+
<tr>
|
| 387 |
+
<th>Returns</th>
|
| 388 |
+
<td>Rendered asset string or current instance when adding to group.</td>
|
| 389 |
+
</tr>
|
| 390 |
+
<tr>
|
| 391 |
+
<th>Example</th>
|
| 392 |
+
<td>
|
| 393 |
+
<pre class="php"><code>// returns '' if $raw is set to false
|
| 394 |
+
Asset::js(array('jquery.js', 'jqueryui.js'), array(), 'jquery', false);
|
| 395 |
+
|
| 396 |
+
/* returns
|
| 397 |
+
* <script type="text/javascript">
|
| 398 |
+
* var menu = getElementById('menu');
|
| 399 |
+
* menu.initialize_menu();
|
| 400 |
+
* </script>
|
| 401 |
+
*/
|
| 402 |
+
echo Asset::js('menu_init.js', array(), null, true);
|
| 403 |
+
|
| 404 |
+
/* returns
|
| 405 |
+
* <script type="text/javascript" src="../assets/js/jquery.js"></script>
|
| 406 |
+
* if auto_render in the config is set to true.
|
| 407 |
+
* if not, the asset will be added to the default group for later rendering
|
| 408 |
+
*/
|
| 409 |
+
echo Asset::js('jquery.js');
|
| 410 |
+
|
| 411 |
+
/* returns
|
| 412 |
+
* <script type="text/javascript">
|
| 413 |
+
* var menu = getElementById('menu');
|
| 414 |
+
* menu.initialize_menu();
|
| 415 |
+
* </script>
|
| 416 |
+
*/
|
| 417 |
+
Asset::js("var menu = getElementById('menu');\nmenu.initialize_menu();", array(), 'inline', true);
|
| 418 |
+
echo Asset::render('inline');
|
| 419 |
+
|
| 420 |
+
/* this will do the same */
|
| 421 |
+
echo Asset::js("var menu = getElementById('menu');\nmenu.initialize_menu();", array(), null, true);
|
| 422 |
+
</code></pre>
|
| 423 |
+
</td>
|
| 424 |
+
</tr>
|
| 425 |
+
</tbody>
|
| 426 |
+
</table>
|
| 427 |
+
</article>
|
| 428 |
+
|
| 429 |
+
<article>
|
| 430 |
+
<h4 id="method_get_file" class="method">get_file($file, $type, $folder = '')</h4>
|
| 431 |
+
<p>The <strong>get_file</strong> method allows you to get the URL to an asset file.</p>
|
| 432 |
+
<table class="method">
|
| 433 |
+
<tbody>
|
| 434 |
+
<tr>
|
| 435 |
+
<th class="legend">Static</th>
|
| 436 |
+
<td>Yes</td>
|
| 437 |
+
</tr>
|
| 438 |
+
<tr>
|
| 439 |
+
<th>Parameters</th>
|
| 440 |
+
<td>
|
| 441 |
+
<table class="parameters">
|
| 442 |
+
<tr>
|
| 443 |
+
<th>Param</th>
|
| 444 |
+
<th>Default</th>
|
| 445 |
+
<th class="description">Description</th>
|
| 446 |
+
</tr>
|
| 447 |
+
<tr>
|
| 448 |
+
<th><kbd>$file</kbd></th>
|
| 449 |
+
<td><i>required</i></td>
|
| 450 |
+
<td>Name of the asset to look for.</td>
|
| 451 |
+
</tr>
|
| 452 |
+
<tr>
|
| 453 |
+
<th><kbd>$type</kbd></th>
|
| 454 |
+
<td><i>required</i></td>
|
| 455 |
+
<td>Type of asset to search for. 'img', 'css', and 'js' are supported types.</td>
|
| 456 |
+
</tr>
|
| 457 |
+
<tr>
|
| 458 |
+
<th><kbd>$folder</kbd></th>
|
| 459 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 460 |
+
<td>Optionally you can specify sub-folders if the asset is in a sub-folder of one of the defined asset search paths.</td>
|
| 461 |
+
</tr>
|
| 462 |
+
</table>
|
| 463 |
+
</td>
|
| 464 |
+
</tr>
|
| 465 |
+
<tr>
|
| 466 |
+
<th>Returns</th>
|
| 467 |
+
<td>Fully qualified asset URL (depending on the base_url defined) or false if not found.</td>
|
| 468 |
+
</tr>
|
| 469 |
+
<tr>
|
| 470 |
+
<th>Example</th>
|
| 471 |
+
<td>
|
| 472 |
+
<pre class="php"><code>// returns something like 'http://example.org/assets/js/jquery.js'
|
| 473 |
+
echo Asset::get_file('jquery.js', 'js');</code></pre>
|
| 474 |
+
</td>
|
| 475 |
+
</tr>
|
| 476 |
+
</tbody>
|
| 477 |
+
</table>
|
| 478 |
+
</article>
|
| 479 |
+
|
| 480 |
+
<article>
|
| 481 |
+
<h4 id="method_remove_path" class="method">remove_path($path, $type = null)</h4>
|
| 482 |
+
<p>
|
| 483 |
+
The <strong>remove_path</strong> method removes the given path from the global assets search path array.
|
| 484 |
+
If a $type is specified, it will remove the path from the search folder array for the given type.
|
| 485 |
+
</p>
|
| 486 |
+
<table class="method">
|
| 487 |
+
<tbody>
|
| 488 |
+
<tr>
|
| 489 |
+
<th class="legend">Static</th>
|
| 490 |
+
<td>Yes</td>
|
| 491 |
+
</tr>
|
| 492 |
+
<tr>
|
| 493 |
+
<th>Parameters</th>
|
| 494 |
+
<td>
|
| 495 |
+
<table class="parameters">
|
| 496 |
+
<tr>
|
| 497 |
+
<th>Param</th>
|
| 498 |
+
<th>Default</th>
|
| 499 |
+
<th class="description">Description</th>
|
| 500 |
+
</tr>
|
| 501 |
+
<tr>
|
| 502 |
+
<th><kbd>$path</kbd></th>
|
| 503 |
+
<td><i>required</i></td>
|
| 504 |
+
<td>The path to from the assets path array.</td>
|
| 505 |
+
</tr>
|
| 506 |
+
<tr>
|
| 507 |
+
<th><kbd>$type</kbd></th>
|
| 508 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 509 |
+
<td>
|
| 510 |
+
If adding a folder, the type to add it to. Currently, 'img', 'css' and 'js' are suppored.
|
| 511 |
+
To add the same path to multiple types, pass them as an array of types.
|
| 512 |
+
</td>
|
| 513 |
+
</tr>
|
| 514 |
+
</table>
|
| 515 |
+
</td>
|
| 516 |
+
</tr>
|
| 517 |
+
<tr>
|
| 518 |
+
<th>Returns</th>
|
| 519 |
+
<td>The current instance</td>
|
| 520 |
+
</tr>
|
| 521 |
+
<tr>
|
| 522 |
+
<th>Example</th>
|
| 523 |
+
<td>
|
| 524 |
+
<pre class="php"><code>/*
|
| 525 |
+
* Remove global search paths
|
| 526 |
+
*/
|
| 527 |
+
Asset::remove_path('resources/template_1/');
|
| 528 |
+
Asset::remove_path('resources/template_2/');
|
| 529 |
+
|
| 530 |
+
/*
|
| 531 |
+
* Remove individual paths for different asset types
|
| 532 |
+
*/
|
| 533 |
+
Asset::remove_path('assets/global/', array('css', 'js', 'img'));
|
| 534 |
+
Asset::remove_path('assets/icons/', 'img');
|
| 535 |
+
Asset::remove_path('assets/images/', 'img');
|
| 536 |
+
Asset::remove_path('assets/css/', 'css');
|
| 537 |
+
|
| 538 |
+
/*
|
| 539 |
+
* Or chain the calls.
|
| 540 |
+
*/
|
| 541 |
+
Asset::remove_path('resources/templates/dark/')
|
| 542 |
+
->remove_path('resources/templates/light')
|
| 543 |
+
->remove_path('resources/templates/brown');
|
| 544 |
+
</code></pre>
|
| 545 |
+
</td>
|
| 546 |
+
</tr>
|
| 547 |
+
</tbody>
|
| 548 |
+
</table>
|
| 549 |
+
</article>
|
| 550 |
+
|
| 551 |
+
<article>
|
| 552 |
+
<h4 id="method_render" class="method">render($group = null, $raw = false)</h4>
|
| 553 |
+
<p>
|
| 554 |
+
The <strong>render</strong> renders the group of assets and returns the tags.
|
| 555 |
+
If no group is specified, the default group will be rendered.
|
| 556 |
+
</p>
|
| 557 |
+
<table class="method">
|
| 558 |
+
<tbody>
|
| 559 |
+
<tr>
|
| 560 |
+
<th class="legend">Static</th>
|
| 561 |
+
<td>Yes</td>
|
| 562 |
+
</tr>
|
| 563 |
+
<tr>
|
| 564 |
+
<th>Parameters</th>
|
| 565 |
+
<td>
|
| 566 |
+
<table class="parameters">
|
| 567 |
+
<tr>
|
| 568 |
+
<th>Param</th>
|
| 569 |
+
<th>Default</th>
|
| 570 |
+
<th class="description">Description</th>
|
| 571 |
+
</tr>
|
| 572 |
+
<tr>
|
| 573 |
+
<th><kbd>$group</kbd></th>
|
| 574 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 575 |
+
<td>The name of the group to render or null for the default group.</td>
|
| 576 |
+
</tr>
|
| 577 |
+
<tr>
|
| 578 |
+
<th><kbd>$raw</kbd></th>
|
| 579 |
+
<td><pre class="php"><code>false</code></pre></td>
|
| 580 |
+
<td>If true this method will include the contents of css/js files for embedding.</td>
|
| 581 |
+
</tr>
|
| 582 |
+
</table>
|
| 583 |
+
</td>
|
| 584 |
+
</tr>
|
| 585 |
+
<tr>
|
| 586 |
+
<th>Returns</th>
|
| 587 |
+
<td>string</td>
|
| 588 |
+
</tr>
|
| 589 |
+
<tr>
|
| 590 |
+
<th>Example</th>
|
| 591 |
+
<td>
|
| 592 |
+
<pre class="php"><code>/* returns
|
| 593 |
+
* <link href="../assets/css/header.css" rel="stylesheet" />
|
| 594 |
+
* <link href="../assets/css/footer.css" rel="stylesheet" />
|
| 595 |
+
*/
|
| 596 |
+
echo Asset::render('layout');
|
| 597 |
+
|
| 598 |
+
// renders the default group
|
| 599 |
+
echo Asset::render();</code></pre>
|
| 600 |
+
</td>
|
| 601 |
+
</tr>
|
| 602 |
+
</tbody>
|
| 603 |
+
</table>
|
| 604 |
+
</article>
|
| 605 |
+
|
| 606 |
+
</section>
|
| 607 |
+
|
| 608 |
+
</div>
|
| 609 |
+
|
| 610 |
+
<footer>
|
| 611 |
+
<p>
|
| 612 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 613 |
+
</p>
|
| 614 |
+
</footer>
|
| 615 |
+
</div>
|
| 616 |
+
</body>
|
| 617 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/advanced.html
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Cache::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Cache Advanced - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Cache Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The cache class allows you to cache the result of a resource heavy operation.</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3>Advanced usage</h3>
|
| 54 |
+
|
| 55 |
+
<p>Using cache as an object instance.</p>
|
| 56 |
+
<pre><code>$options = array(...); //These are the same as in the cache config file.
|
| 57 |
+
|
| 58 |
+
$cache = Cache::forge('my_cache', $options)</code></pre>
|
| 59 |
+
<p>Data can then be saved to the cache using the <kbd>set()</kbd> function.</p>
|
| 60 |
+
<pre id="php"><code>$cache->set($myData, 604800);</code></pre>
|
| 61 |
+
<p>This sets the data in one block and sets the expiration time to one week (604800 seconds). If the second parameter is set to null then the cache will never expire.</p>
|
| 62 |
+
<p>Data can be retrieved in the same way as when using <kbd>Cache</kbd> statically.</p>
|
| 63 |
+
</section>
|
| 64 |
+
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
<footer>
|
| 68 |
+
<p>
|
| 69 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 70 |
+
</p>
|
| 71 |
+
</footer>
|
| 72 |
+
</div>
|
| 73 |
+
</body>
|
| 74 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/config.html
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Cache::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Cache Config - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Cache Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The cache class allows you to cache the result of a resource heavy operation.</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3 id="config">Configuration</h3>
|
| 54 |
+
|
| 55 |
+
<p>The cache class's defaults are configured through the fuel/core/config/cache.php configuration file. It
|
| 56 |
+
is already populated with a default configuration. You can override this configuration adding a config file
|
| 57 |
+
with the same name to your application config directory, and set the values you want to change there. These
|
| 58 |
+
will overwrite the core config but keep what you didn't overwrite.</p>
|
| 59 |
+
|
| 60 |
+
<p>The following global configuration values can be defined:</p>
|
| 61 |
+
<table class="config">
|
| 62 |
+
<tbody>
|
| 63 |
+
<tr class="header">
|
| 64 |
+
<th>Param</th>
|
| 65 |
+
<th>Type</th>
|
| 66 |
+
<th>Default</th>
|
| 67 |
+
<th>Description</th>
|
| 68 |
+
</tr>
|
| 69 |
+
<tr>
|
| 70 |
+
<th>driver</th>
|
| 71 |
+
<td>string</td>
|
| 72 |
+
<td><pre class="php"><code>'file'</code></pre></td>
|
| 73 |
+
<td>
|
| 74 |
+
The default storage driver used for saving the caches.
|
| 75 |
+
</td>
|
| 76 |
+
</tr>
|
| 77 |
+
<tr>
|
| 78 |
+
<th>expiration</th>
|
| 79 |
+
<td>int</td>
|
| 80 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 81 |
+
<td>
|
| 82 |
+
The default number of seconds until expiration, used when no lifetime is given. When set to
|
| 83 |
+
null it won't expire.
|
| 84 |
+
</td>
|
| 85 |
+
</tr>
|
| 86 |
+
<tr>
|
| 87 |
+
<th>(type)_handler</th>
|
| 88 |
+
<td>string</td>
|
| 89 |
+
<td><pre class="php"><code>serialize</code></pre></td>
|
| 90 |
+
<td>
|
| 91 |
+
When caching strings nothing special happens unless when caching more complex things like
|
| 92 |
+
objects, or even more primitive like doubles. For those cases there are "content handlers"
|
| 93 |
+
included which can ensure you'll get your object back as the right kind of object. By
|
| 94 |
+
default handlers are included for using PHP serialization and JSON encoding.<br />
|
| 95 |
+
You can add your own or handle different kinds of objects/primitive types in different ways
|
| 96 |
+
by adding handlers for each of them: 'int_handler' => 'json', 'string_handler' => 'string',
|
| 97 |
+
'Model_Post' => 'serialize', etc...
|
| 98 |
+
</td>
|
| 99 |
+
</tr>
|
| 100 |
+
</tbody>
|
| 101 |
+
</table>
|
| 102 |
+
|
| 103 |
+
<p>For each of the cache storage drivers, a separate configuration section exists. This section contains
|
| 104 |
+
the driver specific parameters.</p>
|
| 105 |
+
|
| 106 |
+
<section>
|
| 107 |
+
<h5 id="file_driver_config">File driver configuration</h5>
|
| 108 |
+
|
| 109 |
+
<p>Saves the caches to the filesystem.</p>
|
| 110 |
+
|
| 111 |
+
<p>Specific driver configuration:</p>
|
| 112 |
+
<table class="config">
|
| 113 |
+
<tbody>
|
| 114 |
+
<tr class="header">
|
| 115 |
+
<th>Param</th>
|
| 116 |
+
<th>Type</th>
|
| 117 |
+
<th>Default</th>
|
| 118 |
+
<th>Description</th>
|
| 119 |
+
</tr>
|
| 120 |
+
<tr>
|
| 121 |
+
<th>path</th>
|
| 122 |
+
<td>string</td>
|
| 123 |
+
<td><pre class="php"><code>APPPATH.'cache/'</code></pre></td>
|
| 124 |
+
<td>Basepath for saving the caches.</td>
|
| 125 |
+
</tr>
|
| 126 |
+
</tbody>
|
| 127 |
+
</table>
|
| 128 |
+
</section>
|
| 129 |
+
|
| 130 |
+
<section>
|
| 131 |
+
<h5 id="memcache_driver_config">MemCached driver configuration</h5>
|
| 132 |
+
|
| 133 |
+
<p>Specific driver configuration:</p>
|
| 134 |
+
<table class="config">
|
| 135 |
+
<tbody>
|
| 136 |
+
<tr class="header">
|
| 137 |
+
<th>Param</th>
|
| 138 |
+
<th>Type</th>
|
| 139 |
+
<th>Default</th>
|
| 140 |
+
<th>Description</th>
|
| 141 |
+
</tr>
|
| 142 |
+
<tr>
|
| 143 |
+
<th>cache_id</th>
|
| 144 |
+
<td>string</td>
|
| 145 |
+
<td><pre class="php"><code>'fuel'</code></pre></td>
|
| 146 |
+
<td>Unique id to distinguish fuel cache items from others stored on the same server(s).</td>
|
| 147 |
+
</tr>
|
| 148 |
+
<tr>
|
| 149 |
+
<th>servers</th>
|
| 150 |
+
<td>string</td>
|
| 151 |
+
<td><pre class="php"><code>array(
|
| 152 |
+
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100)
|
| 153 |
+
)</code></pre></td>
|
| 154 |
+
<td>Array of servers and portnumbers that run the memcached service.</td>
|
| 155 |
+
</tr>
|
| 156 |
+
</tbody>
|
| 157 |
+
</table>
|
| 158 |
+
</section>
|
| 159 |
+
|
| 160 |
+
<section>
|
| 161 |
+
<h5 id="redis_driver_config">Redis driver configuration</h5>
|
| 162 |
+
|
| 163 |
+
<p>Specific driver configuration:</p>
|
| 164 |
+
<table class="config">
|
| 165 |
+
<tbody>
|
| 166 |
+
<tr class="header">
|
| 167 |
+
<th>Param</th>
|
| 168 |
+
<th>Type</th>
|
| 169 |
+
<th>Default</th>
|
| 170 |
+
<th>Description</th>
|
| 171 |
+
</tr>
|
| 172 |
+
<tr>
|
| 173 |
+
<th>database</th>
|
| 174 |
+
<td>string</td>
|
| 175 |
+
<td><pre class="php"><code>'default'</code></pre></td>
|
| 176 |
+
<td>Name of the redis database to use (as configured in config/db.php)</td>
|
| 177 |
+
</tr>
|
| 178 |
+
</tbody>
|
| 179 |
+
</table>
|
| 180 |
+
</section>
|
| 181 |
+
|
| 182 |
+
</section>
|
| 183 |
+
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<footer>
|
| 187 |
+
<p>
|
| 188 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 189 |
+
</p>
|
| 190 |
+
</footer>
|
| 191 |
+
</div>
|
| 192 |
+
</body>
|
| 193 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/classes/cache/usage.html
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
var class_prefix = "Cache::";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Cache Usage - Classes - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2>Cache Class</h2>
|
| 49 |
+
|
| 50 |
+
<p>The cache class allows you to cache the result of a resource heavy operation.</p>
|
| 51 |
+
|
| 52 |
+
<section>
|
| 53 |
+
<h3 id="usage">Usage</h3>
|
| 54 |
+
|
| 55 |
+
<p>Using caches can be done in 2 ways: through static usage of the Cache class and through cache objects
|
| 56 |
+
returned by the Cache::forge(). This section covers static usage which will always work with the same
|
| 57 |
+
driver as specified in the <a href="config.html">configuration</a>.</p>
|
| 58 |
+
|
| 59 |
+
<p>Using cache objects and Cache::forge() is explained in the <a href="advanced.html">advanced</a>
|
| 60 |
+
section.</p>
|
| 61 |
+
|
| 62 |
+
<h3 id="gc">Garbage Collection</h3>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
There is currently <strong>NO</strong> garbage collection mechanism build into the Cache drivers. Storage backends that
|
| 66 |
+
have built-in support for data expiration, such as APC, Memcached or Redis, will use that feature, and
|
| 67 |
+
will auto expire stale cache entries.
|
| 68 |
+
</p>
|
| 69 |
+
<p class="note">
|
| 70 |
+
This means that if you use files to store your cached entries, you will have to write a cron job that will
|
| 71 |
+
periodically delete all old files based on their last modified timestamp!
|
| 72 |
+
</p>
|
| 73 |
+
|
| 74 |
+
<article>
|
| 75 |
+
<h4 class="method" id="method_set">set($identifier, $contents = null, $expiration = false, $dependencies = array())</h4>
|
| 76 |
+
<p>Writes a cache.</p>
|
| 77 |
+
<table class="method">
|
| 78 |
+
<tbody>
|
| 79 |
+
<tr>
|
| 80 |
+
<th class="legend">Static</th>
|
| 81 |
+
<td>Yes</td>
|
| 82 |
+
</tr>
|
| 83 |
+
<tr>
|
| 84 |
+
<th>Parameters</th>
|
| 85 |
+
<td>
|
| 86 |
+
<table class="parameters">
|
| 87 |
+
<tr>
|
| 88 |
+
<th>Param</th>
|
| 89 |
+
<th>Default</th>
|
| 90 |
+
<th class="description">Description</th>
|
| 91 |
+
</tr>
|
| 92 |
+
<tr>
|
| 93 |
+
<th><kbd>$identifier</kbd></th>
|
| 94 |
+
<td><i>string</i></td>
|
| 95 |
+
<td>Name of the cache</td>
|
| 96 |
+
</tr>
|
| 97 |
+
<tr>
|
| 98 |
+
<th><kbd>$contents</kbd></th>
|
| 99 |
+
<td><i>mixed</i></td>
|
| 100 |
+
<td>Contents to be cached</td>
|
| 101 |
+
</tr>
|
| 102 |
+
<tr>
|
| 103 |
+
<th><kbd>$expiration</kbd></th>
|
| 104 |
+
<td><i>int</i></td>
|
| 105 |
+
<td>Amount of seconds until the cache expires. null will make it never expire, false
|
| 106 |
+
makes it use the default expiration set in config.</td>
|
| 107 |
+
</tr>
|
| 108 |
+
<tr>
|
| 109 |
+
<th><kbd>$dependencies</kbd></th>
|
| 110 |
+
<td><i>array</i></td>
|
| 111 |
+
<td>Array of identifiers this cache depends on, this cache expires if one of those
|
| 112 |
+
is newer or doesn't exist anymore.</td>
|
| 113 |
+
</tr>
|
| 114 |
+
</table>
|
| 115 |
+
</td>
|
| 116 |
+
</tr>
|
| 117 |
+
<tr>
|
| 118 |
+
<th>Returns</th>
|
| 119 |
+
<td>void</td>
|
| 120 |
+
</tr>
|
| 121 |
+
<tr>
|
| 122 |
+
<th>Example</th>
|
| 123 |
+
<td>
|
| 124 |
+
<pre class="php"><code>// Cache 'String to be cached' for 3 hours with identifier "test"
|
| 125 |
+
Cache::set('test', 'String to be cached.', 3600 * 3);</code></pre>
|
| 126 |
+
</td>
|
| 127 |
+
</tr>
|
| 128 |
+
</tbody>
|
| 129 |
+
</table>
|
| 130 |
+
</article>
|
| 131 |
+
|
| 132 |
+
<article>
|
| 133 |
+
<h4 class="method" id="method_get">get($identifier, $use_expiration = true)</h4>
|
| 134 |
+
<p>Retrieves a cache.</p>
|
| 135 |
+
<table class="method">
|
| 136 |
+
<tbody>
|
| 137 |
+
<tr>
|
| 138 |
+
<th class="legend">Static</th>
|
| 139 |
+
<td>Yes</td>
|
| 140 |
+
</tr>
|
| 141 |
+
<tr>
|
| 142 |
+
<th>Parameters</th>
|
| 143 |
+
<td>
|
| 144 |
+
<table class="parameters">
|
| 145 |
+
<tr>
|
| 146 |
+
<th>Param</th>
|
| 147 |
+
<th>Default</th>
|
| 148 |
+
<th class="description">Description</th>
|
| 149 |
+
</tr>
|
| 150 |
+
<tr>
|
| 151 |
+
<th><kbd>$identifier</kbd></th>
|
| 152 |
+
<td><i>string</i></td>
|
| 153 |
+
<td>Name of the cache</td>
|
| 154 |
+
</tr>
|
| 155 |
+
<tr>
|
| 156 |
+
<th><kbd>$use_expiration</kbd></th>
|
| 157 |
+
<td><i>true</i></td>
|
| 158 |
+
<td>Disable cache expiration for this fetching by setting this to false</td>
|
| 159 |
+
</tr>
|
| 160 |
+
</table>
|
| 161 |
+
</td>
|
| 162 |
+
</tr>
|
| 163 |
+
<tr>
|
| 164 |
+
<th>Returns</th>
|
| 165 |
+
<td>mixed - cache contents</td>
|
| 166 |
+
</tr>
|
| 167 |
+
<tr>
|
| 168 |
+
<th>Throws</th>
|
| 169 |
+
<td>CacheNotFoundException when Cache doesn't exist or CacheExpiredException when it has expired</td>
|
| 170 |
+
</tr>
|
| 171 |
+
<tr>
|
| 172 |
+
<th>Example</th>
|
| 173 |
+
<td>
|
| 174 |
+
<pre class="php"><code>// try to retrieve the cache and save to $content var
|
| 175 |
+
try
|
| 176 |
+
{
|
| 177 |
+
$content = Cache::get('test');
|
| 178 |
+
}
|
| 179 |
+
catch (\CacheNotFoundException $e)
|
| 180 |
+
{
|
| 181 |
+
/*
|
| 182 |
+
Catching the CacheNotFoundException exception will catch
|
| 183 |
+
both CacheNotFoundException and CacheExpiredException.
|
| 184 |
+
Use this when catching the exception.
|
| 185 |
+
*/
|
| 186 |
+
}
|
| 187 |
+
</code></pre>
|
| 188 |
+
</td>
|
| 189 |
+
</tr>
|
| 190 |
+
</tbody>
|
| 191 |
+
</table>
|
| 192 |
+
</article>
|
| 193 |
+
|
| 194 |
+
<article>
|
| 195 |
+
<h4 class="method" id="method_delete">delete($identifier)</h4>
|
| 196 |
+
<p>Deletes a cache.</p>
|
| 197 |
+
<table class="method">
|
| 198 |
+
<tbody>
|
| 199 |
+
<tr>
|
| 200 |
+
<th class="legend">Static</th>
|
| 201 |
+
<td>Yes</td>
|
| 202 |
+
</tr>
|
| 203 |
+
<tr>
|
| 204 |
+
<th>Parameters</th>
|
| 205 |
+
<td>
|
| 206 |
+
<table class="parameters">
|
| 207 |
+
<tr>
|
| 208 |
+
<th>Param</th>
|
| 209 |
+
<th>Default</th>
|
| 210 |
+
<th class="description">Description</th>
|
| 211 |
+
</tr>
|
| 212 |
+
<tr>
|
| 213 |
+
<th><kbd>$identifier</kbd></th>
|
| 214 |
+
<td><i>string</i></td>
|
| 215 |
+
<td>Name of the cache</td>
|
| 216 |
+
</tr>
|
| 217 |
+
</table>
|
| 218 |
+
</td>
|
| 219 |
+
</tr>
|
| 220 |
+
<tr>
|
| 221 |
+
<th>Returns</th>
|
| 222 |
+
<td>void</td>
|
| 223 |
+
</tr>
|
| 224 |
+
<tr>
|
| 225 |
+
<th>Example</th>
|
| 226 |
+
<td>
|
| 227 |
+
<pre class="php"><code>Cache::delete('test');</code></pre>
|
| 228 |
+
</td>
|
| 229 |
+
</tr>
|
| 230 |
+
</tbody>
|
| 231 |
+
</table>
|
| 232 |
+
</article>
|
| 233 |
+
|
| 234 |
+
<article>
|
| 235 |
+
<h4 class="method" id="method_delete_all">delete_all($section = null, $driver = null)</h4>
|
| 236 |
+
<p>Flushes the whole cache for a specific storage driver or just a subsection of it.</p>
|
| 237 |
+
<table class="method">
|
| 238 |
+
<tbody>
|
| 239 |
+
<tr>
|
| 240 |
+
<th class="legend">Static</th>
|
| 241 |
+
<td>Yes</td>
|
| 242 |
+
</tr>
|
| 243 |
+
<tr>
|
| 244 |
+
<th>Parameters</th>
|
| 245 |
+
<td>
|
| 246 |
+
<table class="parameters">
|
| 247 |
+
<tr>
|
| 248 |
+
<th>Param</th>
|
| 249 |
+
<th>Default</th>
|
| 250 |
+
<th class="description">Description</th>
|
| 251 |
+
</tr>
|
| 252 |
+
<tr>
|
| 253 |
+
<th><kbd>$section</kbd></th>
|
| 254 |
+
<td><i>string</i></td>
|
| 255 |
+
<td>Name of a section or directory of the cache, null to delete everything</td>
|
| 256 |
+
</tr>
|
| 257 |
+
<tr>
|
| 258 |
+
<th><kbd>$driver</kbd></th>
|
| 259 |
+
<td><i>string</i></td>
|
| 260 |
+
<td>Name of the driver to use, null to use the default driver.</td>
|
| 261 |
+
</tr>
|
| 262 |
+
</table>
|
| 263 |
+
</td>
|
| 264 |
+
</tr>
|
| 265 |
+
<tr>
|
| 266 |
+
<th>Returns</th>
|
| 267 |
+
<td>void</td>
|
| 268 |
+
</tr>
|
| 269 |
+
<tr>
|
| 270 |
+
<th>Example</th>
|
| 271 |
+
<td>
|
| 272 |
+
<pre class="php"><code>// Delete the whole cache for the default driver
|
| 273 |
+
Cache::delete_all();
|
| 274 |
+
|
| 275 |
+
// Delete the subdirectory "test" of file
|
| 276 |
+
Cache::delete_all('test', 'file');</code></pre>
|
| 277 |
+
</td>
|
| 278 |
+
</tr>
|
| 279 |
+
</tbody>
|
| 280 |
+
</table>
|
| 281 |
+
</article>
|
| 282 |
+
|
| 283 |
+
<article>
|
| 284 |
+
<h4 class="method" id="method_call">call($identifier, $callback, $args = array(), $expiration = null, $dependencies = array())</h4>
|
| 285 |
+
<p>Cache the result of any callable function or method.</p>
|
| 286 |
+
<table class="method">
|
| 287 |
+
<tbody>
|
| 288 |
+
<tr>
|
| 289 |
+
<th class="legend">Static</th>
|
| 290 |
+
<td>Yes</td>
|
| 291 |
+
</tr>
|
| 292 |
+
<tr>
|
| 293 |
+
<th>Parameters</th>
|
| 294 |
+
<td>
|
| 295 |
+
<table class="parameters">
|
| 296 |
+
<tr>
|
| 297 |
+
<th>Param</th>
|
| 298 |
+
<th>Default</th>
|
| 299 |
+
<th class="description">Description</th>
|
| 300 |
+
</tr>
|
| 301 |
+
<tr>
|
| 302 |
+
<th><kbd>$identifier</kbd></th>
|
| 303 |
+
<td><i>string</i></td>
|
| 304 |
+
<td>Name of the cache</td>
|
| 305 |
+
</tr>
|
| 306 |
+
<tr>
|
| 307 |
+
<th><kbd>$callback</kbd></th>
|
| 308 |
+
<td><i>mixed</i></td>
|
| 309 |
+
<td>Any valid PHP callback</td>
|
| 310 |
+
</tr>
|
| 311 |
+
<tr>
|
| 312 |
+
<th><kbd>$args</kbd></th>
|
| 313 |
+
<td><i>array</i></td>
|
| 314 |
+
<td>Any arguments for the callback</td>
|
| 315 |
+
</tr>
|
| 316 |
+
<tr>
|
| 317 |
+
<th><kbd>$expiration</kbd></th>
|
| 318 |
+
<td><i>int</i></td>
|
| 319 |
+
<td>Amount of seconds until the cache expires. null will make it never expire, false
|
| 320 |
+
makes it use the default expiration set in config.</td>
|
| 321 |
+
</tr>
|
| 322 |
+
<tr>
|
| 323 |
+
<th><kbd>$dependencies</kbd></th>
|
| 324 |
+
<td><i>array</i></td>
|
| 325 |
+
<td>Array of identifiers this cache depends on, this cache expires if one of those
|
| 326 |
+
is newer or doesn't exist anymore.</td>
|
| 327 |
+
</tr>
|
| 328 |
+
</table>
|
| 329 |
+
</td>
|
| 330 |
+
</tr>
|
| 331 |
+
<tr>
|
| 332 |
+
<th>Returns</th>
|
| 333 |
+
<td>void</td>
|
| 334 |
+
</tr>
|
| 335 |
+
<tr>
|
| 336 |
+
<th>Example</th>
|
| 337 |
+
<td>
|
| 338 |
+
<pre class="php"><code>// Cache the result of a model find
|
| 339 |
+
Cache::call('article_something', array('Model_Article', 'find'), array("all", array( 'where' => array('something' => $something) ));
|
| 340 |
+
</code></pre>
|
| 341 |
+
</td>
|
| 342 |
+
</tr>
|
| 343 |
+
</tbody>
|
| 344 |
+
</table>
|
| 345 |
+
</article>
|
| 346 |
+
|
| 347 |
+
</section>
|
| 348 |
+
|
| 349 |
+
</div>
|
| 350 |
+
|
| 351 |
+
<footer>
|
| 352 |
+
<p>
|
| 353 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 354 |
+
</p>
|
| 355 |
+
</footer>
|
| 356 |
+
</div>
|
| 357 |
+
</body>
|
| 358 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/base.html
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Controller - General - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
|
| 47 |
+
<h2>Controllers</h2>
|
| 48 |
+
|
| 49 |
+
<h3 id="what_is_a_controller">What is a controller?</h3>
|
| 50 |
+
|
| 51 |
+
<p>
|
| 52 |
+
Controllers are classes that can be reached through the URL and take care of handling the request.
|
| 53 |
+
A controller calls models and other classes to fetch the information. Finally, it will pass everything
|
| 54 |
+
to a view for output. If a URL like www.yoursite.com/example/index is requested, the first segment
|
| 55 |
+
("example") will be the controller that is called and the second segment ("index") will be the method
|
| 56 |
+
of that controller that is called.
|
| 57 |
+
</p>
|
| 58 |
+
|
| 59 |
+
<h3 id="creating_a_controller">Creating a controller</h3>
|
| 60 |
+
|
| 61 |
+
<p>
|
| 62 |
+
In FuelPHP, Controllers are put in the <kbd>fuel/app/classes/controller</kbd> directory, and are prefixed
|
| 63 |
+
with <kbd>"Controller_"</kbd>. Optionally, they should extend the <kbd>Controller</kbd> class for the full
|
| 64 |
+
feature set. Below is an example of the controller "example":
|
| 65 |
+
</p>
|
| 66 |
+
|
| 67 |
+
<pre class="php"><code>class Controller_Example extends Controller
|
| 68 |
+
{
|
| 69 |
+
|
| 70 |
+
public function action_index()
|
| 71 |
+
{
|
| 72 |
+
$data['css'] = Asset::css(array('reset.css','960.css','main.css'));
|
| 73 |
+
return Response::forge(View::forge('welcome/index'));
|
| 74 |
+
}
|
| 75 |
+
}</code></pre>
|
| 76 |
+
|
| 77 |
+
<p>
|
| 78 |
+
Methods that can be requested through the URL are prefixed with <kbd>"action_"</kbd>. This means
|
| 79 |
+
that you're not limited by PHP's constructs on which name you might use (example: method "list"
|
| 80 |
+
isn't allowed, "action_list" is no problem). But this also means you can give your controller public
|
| 81 |
+
methods that can be used from other classes but are not routable.
|
| 82 |
+
</p>
|
| 83 |
+
|
| 84 |
+
<h3 id="http_method_prefixed_actions">HTTP method prefixed action.</h3>
|
| 85 |
+
|
| 86 |
+
<p>
|
| 87 |
+
It's possible to route to HTTP method prefixed actions. Here is an example:
|
| 88 |
+
</p>
|
| 89 |
+
|
| 90 |
+
<pre class="php"><code>class Controller_Example extends Controller
|
| 91 |
+
{
|
| 92 |
+
public function get_index()
|
| 93 |
+
{
|
| 94 |
+
// This will be called when the HTTP method is GET.
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
public function post_index()
|
| 98 |
+
{
|
| 99 |
+
// This will be called when the HTTP method is POST.
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
</code></pre>
|
| 103 |
+
|
| 104 |
+
<h4 id="controller_in_subdir">Controllers in Sub-Directories</h4>
|
| 105 |
+
|
| 106 |
+
<p>
|
| 107 |
+
You can also put a controller in a subdirectory, like
|
| 108 |
+
<kbd>fuel/app/classes/controller/subdir/test.php</kbd>. In this case, the controller must include
|
| 109 |
+
the dirname in the classname like this: <var>Controller_Subdir_Test</var>.
|
| 110 |
+
</p>
|
| 111 |
+
|
| 112 |
+
<p>
|
| 113 |
+
Unlimited nested sub-directories are supported, so
|
| 114 |
+
<kbd>fuel/app/classes/controller/subdir1/subdir2/subdir3/test.php</kbd>. would have a class name of
|
| 115 |
+
<var>Controller_Subdir1_Subdir2_Subdir3_Test</var>.
|
| 116 |
+
</p>
|
| 117 |
+
|
| 118 |
+
<h4 id="controller_namespacing">Namespacing controllers</h4>
|
| 119 |
+
|
| 120 |
+
<p>
|
| 121 |
+
As mentioned in the introduction by default controllers are created in the <kbd>app/classes/controller</kbd> folder,
|
| 122 |
+
and are prefixed with <var>Controller_</var>. This prefix is defined in your <kbd>app/config/config.php</kbd> configuration file
|
| 123 |
+
(and if not this is the default), but can be changed if you want to namespace your controllers, or if you
|
| 124 |
+
want to move them to a different folder structure.
|
| 125 |
+
</p>
|
| 126 |
+
|
| 127 |
+
<p>
|
| 128 |
+
Lets move the example given above to the <kbd>Controller</kbd> namespace. You tell FuelPHP that you've done this by setting the
|
| 129 |
+
config setting <var>controller_prefix</var> from <kbd>'Controller_'</kbd> to <kbd>'Controller\\'</kbd> in your app's config.php file.
|
| 130 |
+
</p>
|
| 131 |
+
|
| 132 |
+
<pre class="php"><code>namespace Controller;
|
| 133 |
+
|
| 134 |
+
class Example extends \Controller
|
| 135 |
+
{
|
| 136 |
+
|
| 137 |
+
public function action_index()
|
| 138 |
+
{
|
| 139 |
+
$data['css'] = Asset::css(array('reset.css','960.css','main.css'));
|
| 140 |
+
return Response::forge(View::forge('welcome/index'));
|
| 141 |
+
}
|
| 142 |
+
}</code></pre>
|
| 143 |
+
|
| 144 |
+
<p class="note">
|
| 145 |
+
Note that now that your controller lives in a namespace, you have to prefix "Controller" with a backslash, since it needs to be
|
| 146 |
+
loaded from the global namespace.
|
| 147 |
+
</p>
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
<h4 id="more_parameters">Using more parameters from the URL</h4>
|
| 152 |
+
|
| 153 |
+
<p>Let say we also have the following method in our Controller_Example: </p>
|
| 154 |
+
|
| 155 |
+
<pre class="php"><code>public function action_name_to_upper($name_1, $name_2)
|
| 156 |
+
{
|
| 157 |
+
$data['name_1'] = strtoupper($name_1);
|
| 158 |
+
$data['name_2'] = strtoupper($name_2);
|
| 159 |
+
return View::forge('test/name_to_upper', $data);
|
| 160 |
+
}</code></pre>
|
| 161 |
+
|
| 162 |
+
<p>
|
| 163 |
+
If we call this method using: <kbd>www.yoursite.com/example/name_to_upper/fuel/php</kbd>, it will
|
| 164 |
+
return the view <kbd>test/name_to_upper</kbd>. "FUEL" and "PHP" will be passed along as values
|
| 165 |
+
<var>$name_1</var> and <var>$name_2</var> in the <var>$data</var> array.
|
| 166 |
+
</p>
|
| 167 |
+
|
| 168 |
+
<h4 id="returning_results">Returning the result</h4>
|
| 169 |
+
|
| 170 |
+
<p>
|
| 171 |
+
Ideally, a controller action must return a Response object. Optionally you can specify special HTTP headers,
|
| 172 |
+
or a custom HTTP status code (a code other than "200 OK"). If you don't return a response object, the default
|
| 173 |
+
<kbd>after()</kbd> method will wrap the return value of the action in a Response object for you.
|
| 174 |
+
</p>
|
| 175 |
+
|
| 176 |
+
<p>
|
| 177 |
+
If your controller extends one of the base controllers, your action can also return any value that can be cast to string,
|
| 178 |
+
like for example a View object. The after() method of the base controller will convert it into a Response object for you.
|
| 179 |
+
</p>
|
| 180 |
+
<p>
|
| 181 |
+
If your controller does not extend one of the base controllers, and you want to use this feature,
|
| 182 |
+
your controller must contain it's own after() method that will accept the actions return value, and has to wrap it into
|
| 183 |
+
a Reponse object which it must return.
|
| 184 |
+
</p>
|
| 185 |
+
|
| 186 |
+
<h3 id="special_methods">Special controller methods</h3>
|
| 187 |
+
|
| 188 |
+
<p class="note">
|
| 189 |
+
Don't overwrite the class constructor <kbd>__construct()</kbd>, use <kbd>before()</kbd> instead.
|
| 190 |
+
Unless you have studied the base Controller from the Core first and understand how it must be extended
|
| 191 |
+
not to break Fuel.
|
| 192 |
+
</p>
|
| 193 |
+
|
| 194 |
+
<article>
|
| 195 |
+
<h4 id="action_index">action_index()</h4>
|
| 196 |
+
<p>
|
| 197 |
+
This method will be called if the controller is called without a second parameter. In the above
|
| 198 |
+
example <kbd>www.yoursite.com/example/index</kbd> will be the same as
|
| 199 |
+
<kbd>www.yoursite.com/example</kbd>.
|
| 200 |
+
</p>
|
| 201 |
+
</article>
|
| 202 |
+
|
| 203 |
+
<article>
|
| 204 |
+
<h4 id="before">before()</h4>
|
| 205 |
+
<p>
|
| 206 |
+
The before() method is used as a general pre-method prepping method, to execute code required in
|
| 207 |
+
every controller method called. This method will be executed <strong>before</strong> the method
|
| 208 |
+
from the URL is called on your controller. It will not be called if that method turns out not to exist.
|
| 209 |
+
You should not use this method for routing decisions. If you need that, use the <strong>router</strong> method instead.
|
| 210 |
+
</p>
|
| 211 |
+
</article>
|
| 212 |
+
|
| 213 |
+
<article>
|
| 214 |
+
<h4 id="after">after($response)</h4>
|
| 215 |
+
<p>
|
| 216 |
+
This method will be executed <strong>after</strong> the method from the URL was called successfully,
|
| 217 |
+
this will not be called if the method turns out not to exist. <a href="#response"><var>$response</var></a> parameter is required.
|
| 218 |
+
The after() method <strong>MUST</strong> return a Response object.
|
| 219 |
+
</p>
|
| 220 |
+
<p class="note">
|
| 221 |
+
If the <kbd>after()</kbd> method has to construct a Response object, it can use the <kbd>response_status</kbd> property of
|
| 222 |
+
the controller to set the HTTP status of the response. By default, this property contains "200" (OK).
|
| 223 |
+
</p>
|
| 224 |
+
</article>
|
| 225 |
+
|
| 226 |
+
<article>
|
| 227 |
+
<h4 id="router">router($method, $params)</h4>
|
| 228 |
+
<p>
|
| 229 |
+
This method will take over the internal routing of the controller. Once the controller is loaded,
|
| 230 |
+
the router() method will be called and use the <var>$method</var> that is being passed in, instead
|
| 231 |
+
of the default method. It will also pass in <var>$params</var>, in an array, to that
|
| 232 |
+
<var>$method</var>. The before() and after() methods will still work as expected.
|
| 233 |
+
</p>
|
| 234 |
+
</article>
|
| 235 |
+
|
| 236 |
+
<h3 id="extending_other_controllers">Extending other controllers</h3>
|
| 237 |
+
|
| 238 |
+
<p>
|
| 239 |
+
Thanks to the autoloader, you can extend other controllers without writing anything more than its
|
| 240 |
+
name in the class definition:
|
| 241 |
+
</p>
|
| 242 |
+
|
| 243 |
+
<pre class="php"><code>class Controller_Example extends Controller_Welcome
|
| 244 |
+
{
|
| 245 |
+
|
| 246 |
+
// your methods
|
| 247 |
+
|
| 248 |
+
}</code></pre>
|
| 249 |
+
|
| 250 |
+
<p>
|
| 251 |
+
This may sound strange at first, but extending controllers allows you to share methods and create base
|
| 252 |
+
controllers really easily.
|
| 253 |
+
</p>
|
| 254 |
+
|
| 255 |
+
<h3>Creating Base Controllers</h3>
|
| 256 |
+
|
| 257 |
+
<p>
|
| 258 |
+
A base controller is a shared controller, like <kbd>Controller_Public</kbd> or <kbd>Controller_Admin</kbd> and are used to share logic between groups of controllers.
|
| 259 |
+
For example, the <kbd>Controller_Admin</kbd> controller could contain your login/logout actions and maybe a dashboard, but it could also contain a <kbd>before()</kbd> method
|
| 260 |
+
that checks to see if the user is logged in as an admin. Then all other controllers in your admin panel will extend this and automatically be secured.
|
| 261 |
+
</p>
|
| 262 |
+
|
| 263 |
+
<pre class="php"><code>class Controller_Admin extends Controller
|
| 264 |
+
{
|
| 265 |
+
|
| 266 |
+
public function before()
|
| 267 |
+
{
|
| 268 |
+
// check for admin
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
// your methods
|
| 272 |
+
|
| 273 |
+
public function action_index()
|
| 274 |
+
{
|
| 275 |
+
// load the dashboard
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
public function action_login()
|
| 279 |
+
{
|
| 280 |
+
// log in the user
|
| 281 |
+
}
|
| 282 |
+
}</code></pre>
|
| 283 |
+
|
| 284 |
+
<p>
|
| 285 |
+
That code will go in <kbd>fuel/app/classes/controller/admin.php</kbd> and all of your other controllers
|
| 286 |
+
should go in <kbd>fuel/app/classes/controller/admin/</kbd>, like this one:
|
| 287 |
+
</p>
|
| 288 |
+
|
| 289 |
+
<pre class="php"><code>class Controller_Admin_User extends Controller_Admin
|
| 290 |
+
{
|
| 291 |
+
|
| 292 |
+
public function action_index()
|
| 293 |
+
{
|
| 294 |
+
// overrides the dashboard with the user index listing
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
public function action_edit($id)
|
| 298 |
+
{
|
| 299 |
+
// edit users
|
| 300 |
+
}
|
| 301 |
+
}</code></pre>
|
| 302 |
+
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
<footer>
|
| 306 |
+
<p>
|
| 307 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 308 |
+
</p>
|
| 309 |
+
</footer>
|
| 310 |
+
</div>
|
| 311 |
+
</body>
|
| 312 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/hybrid.html
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Hybrid Controller - General - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
|
| 47 |
+
<h2 id="hybrid_controller">Hybrid Controller</h2>
|
| 48 |
+
|
| 49 |
+
<p>
|
| 50 |
+
The hybrid controller brings together the functionality of both the REST controller and the
|
| 51 |
+
Template controller in a single base controller.
|
| 52 |
+
</p>
|
| 53 |
+
|
| 54 |
+
<p class="note">
|
| 55 |
+
For more information about the Template or Rest functionality, see the <a href="./rest.html">Controller_Rest</a> or <a href="./template.html">Controller_Template</a> pages.
|
| 56 |
+
</p>
|
| 57 |
+
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<footer>
|
| 61 |
+
<p>
|
| 62 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 63 |
+
</p>
|
| 64 |
+
</footer>
|
| 65 |
+
</div>
|
| 66 |
+
</body>
|
| 67 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/rest.html
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Rest Controller - General - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
|
| 47 |
+
<h2 id="rest_controller">Rest Controller</h2>
|
| 48 |
+
|
| 49 |
+
<h3 id="what_is_rest">What is a Rest controller?</h3>
|
| 50 |
+
|
| 51 |
+
<p>
|
| 52 |
+
A Rest Controller is an extension of the Base Controller which has RESTful support built in.
|
| 53 |
+
This will allow you to build API's with ease.
|
| 54 |
+
</p>
|
| 55 |
+
|
| 56 |
+
<p class="note">
|
| 57 |
+
<strong>Please note:</strong> if you have a <kbd>before()</kbd> or <kbd>router</kbd> method in
|
| 58 |
+
your REST controller extension you <strong>must</strong> call the parent method
|
| 59 |
+
<kbd>parent::before()</kbd> (or router) for it to keep working properly.
|
| 60 |
+
</p>
|
| 61 |
+
|
| 62 |
+
<h3 id="usage">Using the Rest controller</h3>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
Like all Controllers, you create a class in the <kbd>fuel/app/classes/controller</kbd> directory.
|
| 66 |
+
They need to extend the <kbd>Controller_Rest</kbd> class and are prefixed by default by "Controller_".
|
| 67 |
+
Below is an example of the controller "test":
|
| 68 |
+
</p>
|
| 69 |
+
|
| 70 |
+
<pre class="php"><code>class Controller_Test extends Controller_Rest
|
| 71 |
+
{
|
| 72 |
+
|
| 73 |
+
public function get_list()
|
| 74 |
+
{
|
| 75 |
+
return $this->response(array(
|
| 76 |
+
'foo' => Input::get('foo'),
|
| 77 |
+
'baz' => array(
|
| 78 |
+
1, 50, 219
|
| 79 |
+
),
|
| 80 |
+
'empty' => null
|
| 81 |
+
));
|
| 82 |
+
}
|
| 83 |
+
}</code></pre>
|
| 84 |
+
|
| 85 |
+
<p>
|
| 86 |
+
This controller method "list" is called by the following URL:
|
| 87 |
+
<pre>http://localhost/test/list.json?foo=bar</pre>
|
| 88 |
+
</p>
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
<p class="note">
|
| 92 |
+
You'll notice that instead of the usual "action_" prefix the Rest Controller uses the HTTP method as a prefix.
|
| 93 |
+
When no method with the corresponding HTTP method prefix is found it will fall back to the "action_" prefix.
|
| 94 |
+
All common HTTP methods are supported by the Rest Controller, such as:
|
| 95 |
+
</p>
|
| 96 |
+
|
| 97 |
+
<table class="config">
|
| 98 |
+
<tbody>
|
| 99 |
+
<tr class="header">
|
| 100 |
+
<th>HTTP Method</th>
|
| 101 |
+
<th>Description</th>
|
| 102 |
+
</tr>
|
| 103 |
+
<tr>
|
| 104 |
+
<th>GET</th>
|
| 105 |
+
<td>
|
| 106 |
+
Used to fetch information about an existing resource. This is used by browsers when you
|
| 107 |
+
enter a URL and hit go, or when you click on a link, so it perfect for fetching information
|
| 108 |
+
on one of your resources (like user). Forms can also use this method to fetch information submitting a query string (i.e. Search forms).
|
| 109 |
+
</td>
|
| 110 |
+
</tr>
|
| 111 |
+
<tr>
|
| 112 |
+
<th>POST</th>
|
| 113 |
+
<td>
|
| 114 |
+
Used to create a new resource. It is also used to update a resource because of the lack of HTML support for the PUT method. Most forms use POST method except when their intend is to fetch information submitting a query string.
|
| 115 |
+
</td>
|
| 116 |
+
</tr>
|
| 117 |
+
<tr>
|
| 118 |
+
<th>PUT</th>
|
| 119 |
+
<td>
|
| 120 |
+
Used to create or update a resource with a known id. You are expected to pass all properties. Missing ones should be set to NULL. Less commonly used as it is not yet supported by HTML (v.5). It is although supported for XMLHttpRequests by most browsers.
|
| 121 |
+
</td>
|
| 122 |
+
</tr>
|
| 123 |
+
<tr>
|
| 124 |
+
<th>DELETE</th>
|
| 125 |
+
<td>
|
| 126 |
+
Used to delete an existing resource. As for PUT, it is not supported by HTML (v.5) but supported for XMLHttpRequests by most browsers.
|
| 127 |
+
</td>
|
| 128 |
+
</tr>
|
| 129 |
+
<tr>
|
| 130 |
+
<th>PATCH</th>
|
| 131 |
+
<td>
|
| 132 |
+
Used to update a resource with a known id. You only pass properties you want to update. Less commonly used as it is not yet supported by HTML (v.5). It is although supported for XMLHttpRequests by most browsers.
|
| 133 |
+
</td>
|
| 134 |
+
</tr>
|
| 135 |
+
</tbody>
|
| 136 |
+
</table>
|
| 137 |
+
<p class="note">This is not a restrictive list, the FuelPHP framework accepts any HTTP method accepted by your webserver.</p>
|
| 138 |
+
|
| 139 |
+
<h3 id="output">Output</h3>
|
| 140 |
+
|
| 141 |
+
<pre class="javascript"><code>{
|
| 142 |
+
"foo":"bar",
|
| 143 |
+
"baz":[1,50,219],
|
| 144 |
+
"empty":null
|
| 145 |
+
}</code></pre>
|
| 146 |
+
|
| 147 |
+
<p>
|
| 148 |
+
This is output as json because a file extension was defined in the URL. By default, responses will be
|
| 149 |
+
formatted as XML or whichever format is set in <em>fuel/core/config/rest.php</em>.
|
| 150 |
+
</p>
|
| 151 |
+
|
| 152 |
+
<h3 id="config">Configuration</h3>
|
| 153 |
+
|
| 154 |
+
<p>
|
| 155 |
+
The REST controllers can be globally configured via the <strong>fuel/core/config/rest.php</strong> configuration file. It
|
| 156 |
+
is already populated with a default configuration. You can override this configuration adding a config file
|
| 157 |
+
with the same name to your application config directory, and set the values you want to change there. These
|
| 158 |
+
will overwrite the core config but keep what you didn't overwrite.
|
| 159 |
+
</p>
|
| 160 |
+
|
| 161 |
+
<p>The following global configuration values can be defined:</p>
|
| 162 |
+
<table class="config">
|
| 163 |
+
<tbody>
|
| 164 |
+
<tr class="header">
|
| 165 |
+
<th>Param</th>
|
| 166 |
+
<th>Type</th>
|
| 167 |
+
<th>Default</th>
|
| 168 |
+
<th>Description</th>
|
| 169 |
+
</tr>
|
| 170 |
+
<tr>
|
| 171 |
+
<th>default_format</th>
|
| 172 |
+
<td>string</td>
|
| 173 |
+
<td><pre class="php"><code>'xml'</code></pre></td>
|
| 174 |
+
<td>
|
| 175 |
+
The default format to return the result in. This will only be used when no format is defined in the
|
| 176 |
+
controller, and all autodetection mechanisms fail.
|
| 177 |
+
</td>
|
| 178 |
+
</tr>
|
| 179 |
+
<tr>
|
| 180 |
+
<th>xml_basenode</th>
|
| 181 |
+
<td>string</td>
|
| 182 |
+
<td><pre class="php"><code>'xml'</code></pre></td>
|
| 183 |
+
<td>
|
| 184 |
+
The <a href="#xml_basenode">basenode XML tag</a> to be used when outputting XML structures.
|
| 185 |
+
</td>
|
| 186 |
+
</tr>
|
| 187 |
+
<tr>
|
| 188 |
+
<th>realm</th>
|
| 189 |
+
<td>string</td>
|
| 190 |
+
<td><pre class="php"><code>'REST API'</code></pre></td>
|
| 191 |
+
<td>
|
| 192 |
+
The name for the password protected REST API displayed on login dialogs.
|
| 193 |
+
</td>
|
| 194 |
+
</tr>
|
| 195 |
+
<tr>
|
| 196 |
+
<th>auth</th>
|
| 197 |
+
<td>string</td>
|
| 198 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 199 |
+
<td>
|
| 200 |
+
Defines the type of authentication needed. Valid values are 'basic' and 'digest'. You can also define a
|
| 201 |
+
name of controller method which must be called to check authorization. This method may return a boolean
|
| 202 |
+
(true will allow the request, false will return a default 401 response is returned), or a Response object.
|
| 203 |
+
<br />Leave this empty if no autorization need to be performed.
|
| 204 |
+
</td>
|
| 205 |
+
</tr>
|
| 206 |
+
<tr>
|
| 207 |
+
<th>valid_logins</th>
|
| 208 |
+
<td>array</td>
|
| 209 |
+
<td><pre class="php"><code>array('admin' => '1234')</code></pre></td>
|
| 210 |
+
<td>
|
| 211 |
+
An array of key/value pairs, defining valid usernames and passwords for the 'basic' and 'digest' authorization methods.
|
| 212 |
+
</td>
|
| 213 |
+
</tr>
|
| 214 |
+
<tr>
|
| 215 |
+
<th>ignore_http_accept</th>
|
| 216 |
+
<td>boolean</td>
|
| 217 |
+
<td><pre class="php"><code>false</code></pre></td>
|
| 218 |
+
<td>
|
| 219 |
+
Whether or not the HTTP_ACCEPT header should be parsed on a REST request to determine the format to return.
|
| 220 |
+
</td>
|
| 221 |
+
</tr>
|
| 222 |
+
</tbody>
|
| 223 |
+
</table>
|
| 224 |
+
|
| 225 |
+
<h3 id="formats">Supported Formats</h3>
|
| 226 |
+
|
| 227 |
+
<ul>
|
| 228 |
+
<li><strong>xml</strong> - almost any programming language can read XML</li>
|
| 229 |
+
<li><strong>json</strong> - useful for JavaScript and increasingly PHP apps.</li>
|
| 230 |
+
<li><strong>csv</strong> - open with spreadsheet programs</li>
|
| 231 |
+
<li><strong>html</strong> - a simple HTML table</li>
|
| 232 |
+
<li><strong>php</strong> - Representation of PHP code that can be <kbd>eval()</kbd>'ed</li>
|
| 233 |
+
<li><strong>serialize</strong> - Serialized data that can be unserialized in PHP</li>
|
| 234 |
+
</ul>
|
| 235 |
+
|
| 236 |
+
<h3 id="format_determination">Format determination</h3>
|
| 237 |
+
|
| 238 |
+
<p>
|
| 239 |
+
To determine the format in which the result should be returned, the REST controller uses the following algorithm:
|
| 240 |
+
</p>
|
| 241 |
+
<ul>
|
| 242 |
+
<li>use the protected property <kbd>$format</kbd> if it contains a supported format</li>
|
| 243 |
+
<li>use the URL extension if it is a supported format</li>
|
| 244 |
+
<li>use the format specified by the <kbd>:format</kbd> variable in the route if it contains a supported format</li>
|
| 245 |
+
<li>use the format defined in the <kbd>HTTP_ACCEPT</kbd> header</li>
|
| 246 |
+
<li>use the default value defined by the <kbd>$rest_format</kbd> property of your class</li>
|
| 247 |
+
<li>use the <kbd>default_format</kbd> value defined in the global configuration file</li>
|
| 248 |
+
</ul>
|
| 249 |
+
|
| 250 |
+
<p>
|
| 251 |
+
In most cases the <kbd>HTTP_ACCEPT</kbd> is present and contains (at least) <u>text/html</u>, which is a valid
|
| 252 |
+
result format. This has the implication that the <kbd>$rest_format</kbd>, and any global default defined in the <strong>rest.php</strong>
|
| 253 |
+
configuration file, will never be used.
|
| 254 |
+
</p>
|
| 255 |
+
|
| 256 |
+
<p>
|
| 257 |
+
To disable the <kbd>HTTP_ACCEPT</kbd> as a valid format source, set the configuration key <strong>ignore_http_accept</strong>
|
| 258 |
+
in the <strong>rest.php</strong> to <code>false</code>.
|
| 259 |
+
</p>
|
| 260 |
+
|
| 261 |
+
<p class="note">
|
| 262 |
+
Note that it is considered bad practice to hardcode any result format in your REST controller. It should be up to the client
|
| 263 |
+
to specify in which format the result should be returned. In case of <kbd>HTTP_ACCEPT</kbd>, most ajax solutions like for example
|
| 264 |
+
<code>jQuery.ajax()</code> allow you to set the accept header to <u>application/json</u>.
|
| 265 |
+
</p>
|
| 266 |
+
|
| 267 |
+
<h3 id="xml_basenode">XML Base Node Name</h3>
|
| 268 |
+
|
| 269 |
+
<p>
|
| 270 |
+
When using XML output you can set the XML basenode by setting the <code>$xml_basenode</code> param.
|
| 271 |
+
</p>
|
| 272 |
+
|
| 273 |
+
<pre class="php"><code>class Controller_Test extends Controller_Rest
|
| 274 |
+
{
|
| 275 |
+
// Set it for the whole controller
|
| 276 |
+
protected $xml_basenode = 'my_basenode';
|
| 277 |
+
|
| 278 |
+
// Or inside your controller function
|
| 279 |
+
public function get_items()
|
| 280 |
+
{
|
| 281 |
+
$this->xml_basenode = 'other_basenode';
|
| 282 |
+
|
| 283 |
+
return $this->response(array(
|
| 284 |
+
'foo' => Input::get('foo'),
|
| 285 |
+
'baz' => array(
|
| 286 |
+
1, 50, 219
|
| 287 |
+
),
|
| 288 |
+
'empty' => null
|
| 289 |
+
));
|
| 290 |
+
}
|
| 291 |
+
}</code></pre>
|
| 292 |
+
|
| 293 |
+
<h3 id="special_methods">Special controller methods</h3>
|
| 294 |
+
|
| 295 |
+
<article>
|
| 296 |
+
<h4 id="response">response($data = array(), $http_code = 200)</h4>
|
| 297 |
+
<p>
|
| 298 |
+
This method is used to send your response data through the formatting and output logic. You can
|
| 299 |
+
optionally set a status code as the 2nd parameter.
|
| 300 |
+
</p>
|
| 301 |
+
</article>
|
| 302 |
+
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
<footer>
|
| 306 |
+
<p>
|
| 307 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 308 |
+
</p>
|
| 309 |
+
</footer>
|
| 310 |
+
</div>
|
| 311 |
+
</body>
|
| 312 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/general/controllers/template.html
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Template Controller - General - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
|
| 47 |
+
<h2>Template Controller</h2>
|
| 48 |
+
|
| 49 |
+
<h3>What is a template controller?</h3>
|
| 50 |
+
|
| 51 |
+
<p>A Template Controller is an extension of the Base Controller which has template support built in using some pre-defined before() and after() methods. Basically it can be used to wrap
|
| 52 |
+
your view in a layout with a header, footer, sidebar, etc.</p>
|
| 53 |
+
|
| 54 |
+
<h3>Using the template controller</h3>
|
| 55 |
+
|
| 56 |
+
<p>Like all Controllers you create a class in the <kbd>fuel/app/classes/controller</kbd> directory. They need to extend the <kbd>Controller_Template</kbd> class and are prefixed by default by "Controller_". Below is an example of the controller "example": </p>
|
| 57 |
+
|
| 58 |
+
<p class="note"><strong>Please note:</strong> by default, all methods of a class that extends Controller_Template will use the template.
|
| 59 |
+
<br />However, it is possible to <a href="#omit_methods">omit methods</a> from the template.</p>
|
| 60 |
+
|
| 61 |
+
<pre><code>class Controller_Example extends Controller_Template
|
| 62 |
+
{
|
| 63 |
+
public function action_index()
|
| 64 |
+
{
|
| 65 |
+
$data = array();
|
| 66 |
+
$this->template->title = 'Example Page';
|
| 67 |
+
$this->template->content = View::forge('test/index', $data);
|
| 68 |
+
}
|
| 69 |
+
}</code></pre>
|
| 70 |
+
|
| 71 |
+
<h3>Using the template controller with before() and/or after()</h3>
|
| 72 |
+
|
| 73 |
+
<p class="note"><strong>Please note:</strong> if you have a before() method in your template controller extension you
|
| 74 |
+
<strong>must</strong> add <kbd>parent::before();</kbd> to that method or the <kbd>$this->template</kbd> will
|
| 75 |
+
not be available. <strong>Make after() compatible</strong> with that of the Controller_Template:
|
| 76 |
+
use <kbd>after($response)</kbd> instead of just after().</p>
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
<pre><code>class Controller_Example extends Controller_Template
|
| 80 |
+
{
|
| 81 |
+
/**
|
| 82 |
+
* Your before method
|
| 83 |
+
*/
|
| 84 |
+
public function before()
|
| 85 |
+
{
|
| 86 |
+
parent::before(); // Without this line, templating won't work!
|
| 87 |
+
|
| 88 |
+
// do stuff
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Make after() compatible with Controller_Template by adding $response as a parameter
|
| 93 |
+
*/
|
| 94 |
+
public function after($response)
|
| 95 |
+
{
|
| 96 |
+
$response = parent::after($response); // not needed if you create your own response object
|
| 97 |
+
|
| 98 |
+
// do stuff
|
| 99 |
+
|
| 100 |
+
return $response; // make sure after() returns the response object
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
public function action_index()
|
| 104 |
+
{
|
| 105 |
+
$data = array();
|
| 106 |
+
$this->template->title = 'Example Page';
|
| 107 |
+
$this->template->content = View::forge('test/index', $data);
|
| 108 |
+
}
|
| 109 |
+
}</code></pre>
|
| 110 |
+
|
| 111 |
+
<h3>Example template</h3>
|
| 112 |
+
|
| 113 |
+
<p>
|
| 114 |
+
The template file is a great place to call up your JS, CSS, etc, structure your HTML and call view partials. It allows you to give your output
|
| 115 |
+
structure. It is just a view file, by default the Template Controller will look here: <kbd>fuel/app/views/template.php</kbd>.
|
| 116 |
+
</p>
|
| 117 |
+
|
| 118 |
+
<pre><code><!DOCTYPE html>
|
| 119 |
+
<html>
|
| 120 |
+
<head>
|
| 121 |
+
<meta charset="utf-8">
|
| 122 |
+
<title><?php echo $title; ?></title>
|
| 123 |
+
|
| 124 |
+
<?php echo Asset::css('main.css'); ?>
|
| 125 |
+
</head>
|
| 126 |
+
<body>
|
| 127 |
+
<div id="wrapper">
|
| 128 |
+
<h1><?php echo $title; ?></h1>
|
| 129 |
+
|
| 130 |
+
<div id="content">
|
| 131 |
+
<?php echo $content; ?>
|
| 132 |
+
</div>
|
| 133 |
+
</div>
|
| 134 |
+
</body>
|
| 135 |
+
</html></code></pre>
|
| 136 |
+
|
| 137 |
+
<h3>Changing the default template file</h3>
|
| 138 |
+
|
| 139 |
+
<p>
|
| 140 |
+
You can easily change the default <kbd>APPPATH/views/template.php</kbd> file to something different.<br/>
|
| 141 |
+
You must set the public variable <kbd>$template</kbd> (note: you don't need .php extension here) to something different, example:
|
| 142 |
+
</p>
|
| 143 |
+
|
| 144 |
+
<pre><code>class Controller_Example extends Controller_Template
|
| 145 |
+
{
|
| 146 |
+
|
| 147 |
+
public $template = 'template_admin';
|
| 148 |
+
|
| 149 |
+
public function action_index()
|
| 150 |
+
{
|
| 151 |
+
$this->template->title = 'Example Page';
|
| 152 |
+
$this->template->content = View::forge('test/index', $data);
|
| 153 |
+
}
|
| 154 |
+
}</code></pre>
|
| 155 |
+
|
| 156 |
+
<h3 id="omit_methods">Omit methods from the Template Controller</h3>
|
| 157 |
+
|
| 158 |
+
<p>
|
| 159 |
+
By default, all methods of a class that extends <kbd>Controller_Template</kbd> will use the template.<br />
|
| 160 |
+
If you want to omit methods from the template, you can do this by returning something else in a
|
| 161 |
+
<kbd>Response</kbd> object. That will overwrite the default template output.
|
| 162 |
+
</p>
|
| 163 |
+
|
| 164 |
+
<pre><code>class Controller_Example extends Controller_Template
|
| 165 |
+
{
|
| 166 |
+
public $template = 'template_admin';
|
| 167 |
+
|
| 168 |
+
public function action_index()
|
| 169 |
+
{
|
| 170 |
+
$this->template->title = 'Example Page';
|
| 171 |
+
$this->template->content = View::forge('test/index', $data);
|
| 172 |
+
|
| 173 |
+
// this will show content in template
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
public function action_example()
|
| 177 |
+
{
|
| 178 |
+
$data['title'] = "Example Page";
|
| 179 |
+
$data['content'] = "Don't show me in the template";
|
| 180 |
+
|
| 181 |
+
// returned Response object takes precedence and will show content without template
|
| 182 |
+
return new Response(View::forge('index/test', $data));
|
| 183 |
+
}
|
| 184 |
+
}</code></pre>
|
| 185 |
+
|
| 186 |
+
</div>
|
| 187 |
+
|
| 188 |
+
<footer>
|
| 189 |
+
<p>
|
| 190 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 191 |
+
</p>
|
| 192 |
+
</footer>
|
| 193 |
+
</div>
|
| 194 |
+
</body>
|
| 195 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/opauth/usage.html
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Usage - Opauth - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
|
| 48 |
+
<h2 id="usage">Opauth Usage</h2>
|
| 49 |
+
|
| 50 |
+
<p>As said in the <a href="intro.html">introduction</a> of the Opauth extension to Auth, the wrapper class configures itself
|
| 51 |
+
automatically for either Simpleauth or Ormauth, based on the driver configured in the <strong>auth.php</strong> configuration
|
| 52 |
+
file.</p>
|
| 53 |
+
|
| 54 |
+
<p>If you don't use these drivers, but you have enrolled your own driver set in the Auth framework, you can still use the Opauth
|
| 55 |
+
integration class, but you'll have to create the 'providers' table defined in the migration 008 manually.
|
| 56 |
+
You can name it anything you like. Also, your custom Login driver should provide the methods <strong>Auth::check()</strong>,
|
| 57 |
+
<strong>Auth::instance()->get_user_id()</strong>, <strong>Auth::instance()->force_login()</strong> and
|
| 58 |
+
<strong>Auth::create_user()</strong>, with prototypes compatible with Simpleauth. Without these, it will not work.</p>
|
| 59 |
+
|
| 60 |
+
<h3 id="runtime_config">Runtime configuration</h3>
|
| 61 |
+
|
| 62 |
+
<p>Most of the Opauth configuration is done through the <strong>opauth.php</strong> configuration file, and all of the options in that
|
| 63 |
+
file can be altered at runtime by passing a new value to the forge() using the $config array. In addition to this, there are some
|
| 64 |
+
configuration values you can only pass at runtime, they are not supported in the configuration file:
|
| 65 |
+
</p>
|
| 66 |
+
|
| 67 |
+
<table class="config">
|
| 68 |
+
<thead>
|
| 69 |
+
<tr class="header">
|
| 70 |
+
<th style="width:20%;">Param</th>
|
| 71 |
+
<th style="width:10%;">Type</th>
|
| 72 |
+
<th>Default</th>
|
| 73 |
+
<th>Description</th>
|
| 74 |
+
</tr>
|
| 75 |
+
</thead>
|
| 76 |
+
<tbody>
|
| 77 |
+
<tr>
|
| 78 |
+
<td>table</td>
|
| 79 |
+
<td>string</td>
|
| 80 |
+
<td><pre><i>auto detected</i></pre></td>
|
| 81 |
+
<td>
|
| 82 |
+
Allows you to define the name of the table that contains the provider information manually. When using Simpleauth or
|
| 83 |
+
Ormauth, the name of this table is auto-detected. If you use a custom Auth driver set, and have created the table
|
| 84 |
+
manually, you will have to pass this table name on every forge call.
|
| 85 |
+
</td>
|
| 86 |
+
</tr>
|
| 87 |
+
<tr>
|
| 88 |
+
<td>path</td>
|
| 89 |
+
<td>string</td>
|
| 90 |
+
<td><pre><i>auto detected</i></pre></td>
|
| 91 |
+
<td>
|
| 92 |
+
URI path to the controller method that does your OAuth authentication. By default, it is set to whatever the current
|
| 93 |
+
path is when you forge an Opauth object.
|
| 94 |
+
</td>
|
| 95 |
+
</tr>
|
| 96 |
+
<tr>
|
| 97 |
+
<td>callback_url</td>
|
| 98 |
+
<td>string</td>
|
| 99 |
+
<td><pre><i>auto detected</i></pre></td>
|
| 100 |
+
<td>
|
| 101 |
+
URI path to the controller method that handles the OAuth provider callback. By default, it is set to call the 'action_callback'
|
| 102 |
+
or 'get_callback' method in the same controller that <strong>path</strong> points to.
|
| 103 |
+
</td>
|
| 104 |
+
</tr>
|
| 105 |
+
<tr>
|
| 106 |
+
<td>provider</td>
|
| 107 |
+
<td>string</td>
|
| 108 |
+
<td><pre><i>auto detected</i></pre></td>
|
| 109 |
+
<td>
|
| 110 |
+
If you have manually set the <strong>path</strong>, auto detection of the OAuth provider called doesn't work, and you will
|
| 111 |
+
have to define the provider name manually. This is case sensitive, and MUST match the case used by the strategy provider
|
| 112 |
+
and the key used to define the strategy in the <strong>opauth.php</strong> configuration file.
|
| 113 |
+
</td>
|
| 114 |
+
</tr>
|
| 115 |
+
</tbody>
|
| 116 |
+
</table>
|
| 117 |
+
<p class="note">When using Simpleauth or Ormauth, and you have followed the example code for integrating Opauth in your application,
|
| 118 |
+
none of these runtime configuration values are needed, the auto-detected values will do the trick just fine.</p>
|
| 119 |
+
|
| 120 |
+
<h3 id="classmethods">Class methods</h3>
|
| 121 |
+
|
| 122 |
+
<article>
|
| 123 |
+
<h4 id="method_forge" class="method">forge($config = array(), $autorun = true)</h4>
|
| 124 |
+
<p>The <strong>forge</strong> method creates an instance of the Auth_Opauth class, which provides OAuth integration to your application.</p>
|
| 125 |
+
<table class="method">
|
| 126 |
+
<tbody>
|
| 127 |
+
<tr>
|
| 128 |
+
<th class="legend">Static</th>
|
| 129 |
+
<td>Yes</td>
|
| 130 |
+
</tr>
|
| 131 |
+
<tr>
|
| 132 |
+
<th>Parameters</th>
|
| 133 |
+
<td>
|
| 134 |
+
<table class="parameters">
|
| 135 |
+
<tr>
|
| 136 |
+
<th>Param</th>
|
| 137 |
+
<th>Default</th>
|
| 138 |
+
<th class="description">Description</th>
|
| 139 |
+
</tr>
|
| 140 |
+
<tr>
|
| 141 |
+
<th><kbd>$config</kbd></th>
|
| 142 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 143 |
+
<td>Any runtime configuration values you want to pass to the instance</td>
|
| 144 |
+
</tr>
|
| 145 |
+
<tr>
|
| 146 |
+
<th><kbd>$autorun</kbd></th>
|
| 147 |
+
<td><pre class="php"><code>true</code></pre></td>
|
| 148 |
+
<td>If true, it will automatically initiate a connection to the OAuth provider. If false, it will just instantiate the object.</td>
|
| 149 |
+
</tr>
|
| 150 |
+
</table>
|
| 151 |
+
</td>
|
| 152 |
+
</tr>
|
| 153 |
+
<tr>
|
| 154 |
+
<th>Returns</th>
|
| 155 |
+
<td>Auth_Opauth</td>
|
| 156 |
+
</tr>
|
| 157 |
+
<tr>
|
| 158 |
+
<th>Example</th>
|
| 159 |
+
<td>
|
| 160 |
+
<pre class="php"><code>/**
|
| 161 |
+
* load the wrapper, and have it process the provider defined in the URI
|
| 162 |
+
*
|
| 163 |
+
* this redirects to the providers authentication page, so it should be the
|
| 164 |
+
* last line in your method
|
| 165 |
+
*/
|
| 166 |
+
\Auth_Opauth::forge();
|
| 167 |
+
|
| 168 |
+
// forge an object with a runtime config
|
| 169 |
+
\Auth_Opauth::forge(array(
|
| 170 |
+
'default_group' => $custom_group_id,
|
| 171 |
+
));
|
| 172 |
+
|
| 173 |
+
// forge an object with a runtime config, to process a callback
|
| 174 |
+
$opauth = \Auth_Opauth::forge(array(
|
| 175 |
+
'default_group' => $custom_group_id,
|
| 176 |
+
), false);
|
| 177 |
+
</code></pre>
|
| 178 |
+
</td>
|
| 179 |
+
</tr>
|
| 180 |
+
</tbody>
|
| 181 |
+
</table>
|
| 182 |
+
<p class="note">If you want to process a callback without passing a custom config, you don't have to pass an empty array, you
|
| 183 |
+
can use <strong>\Auth_Opauth::forge(false);</strong> as a shortcut.</p>
|
| 184 |
+
</article>
|
| 185 |
+
|
| 186 |
+
<article>
|
| 187 |
+
<h4 id="method_login_or_register" class="method">login_or_register()</h4>
|
| 188 |
+
<p>The <strong>login_or_register</strong> method processes the provider callback. If the returned provider UID is known, the user will
|
| 189 |
+
be logged in using the local account it is associated to. If not, the user is asked to either register for a new account, or login with
|
| 190 |
+
and existing account and associate the UID with that account.</p>
|
| 191 |
+
<table class="method">
|
| 192 |
+
<tbody>
|
| 193 |
+
<tr>
|
| 194 |
+
<th class="legend">Static</th>
|
| 195 |
+
<td>No</td>
|
| 196 |
+
</tr>
|
| 197 |
+
<tr>
|
| 198 |
+
<th>Parameters</th>
|
| 199 |
+
<td>
|
| 200 |
+
None
|
| 201 |
+
</td>
|
| 202 |
+
</tr>
|
| 203 |
+
<tr>
|
| 204 |
+
<th>Returns</th>
|
| 205 |
+
<td>
|
| 206 |
+
string, status code. The following status codes are supported:
|
| 207 |
+
<ul>
|
| 208 |
+
<li>'linked': the UID is succesfully linked to the current logged-in user</li>
|
| 209 |
+
<li>'logged_in': the user is succesfully logged-in using the OAuth account</li>
|
| 210 |
+
<li>'registered': the UID is linked to a newly registered account, and the user is logged-in</li>
|
| 211 |
+
<li>'register': the UID is not known, and no logged-in user exists, have the user register first</li>
|
| 212 |
+
</ul>
|
| 213 |
+
</td>
|
| 214 |
+
</tr>
|
| 215 |
+
<tr>
|
| 216 |
+
<th>Example</th>
|
| 217 |
+
<td>
|
| 218 |
+
<pre class="php"><code>// get the Opauth object
|
| 219 |
+
$opauth = \Auth_Opauth::forge(false);
|
| 220 |
+
|
| 221 |
+
// attempt to auto-login using the provider callback data
|
| 222 |
+
$status = $opauth->login_or_register();
|
| 223 |
+
</code></pre>
|
| 224 |
+
</td>
|
| 225 |
+
</tr>
|
| 226 |
+
</tbody>
|
| 227 |
+
</table>
|
| 228 |
+
</article>
|
| 229 |
+
|
| 230 |
+
<article>
|
| 231 |
+
<h4 id="method_link_provider" class="method">link_provider(array $data)</h4>
|
| 232 |
+
<p>The <strong>link_provider</strong> method allows you to manually link a local user account to an OAuth login. You need this if you want
|
| 233 |
+
to provide the option for new users to register for a local account first, and then create the link between that account and the provider
|
| 234 |
+
UID manually.</p>
|
| 235 |
+
<table class="method">
|
| 236 |
+
<tbody>
|
| 237 |
+
<tr>
|
| 238 |
+
<th class="legend">Static</th>
|
| 239 |
+
<td>No</td>
|
| 240 |
+
</tr>
|
| 241 |
+
<tr>
|
| 242 |
+
<th>Parameters</th>
|
| 243 |
+
<td>
|
| 244 |
+
<table class="parameters">
|
| 245 |
+
<tr>
|
| 246 |
+
<th>Param</th>
|
| 247 |
+
<th>Default</th>
|
| 248 |
+
<th class="description">Description</th>
|
| 249 |
+
</tr>
|
| 250 |
+
<tr>
|
| 251 |
+
<th><kbd>$data</kbd></th>
|
| 252 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 253 |
+
<td>Array with all data required to create the link (see example)</td>
|
| 254 |
+
</tr>
|
| 255 |
+
</table>
|
| 256 |
+
</td>
|
| 257 |
+
</tr>
|
| 258 |
+
<tr>
|
| 259 |
+
<th>Returns</th>
|
| 260 |
+
<td>mixed. The <strong>insert id</strong> of the created provider link record, or <strong>false</strong> if the creation failed.</td>
|
| 261 |
+
</tr>
|
| 262 |
+
<tr>
|
| 263 |
+
<th>Example</th>
|
| 264 |
+
<td>
|
| 265 |
+
<pre class="php"><code>// get the opauth object
|
| 266 |
+
$opauth = \Auth_Opauth::forge(false);
|
| 267 |
+
|
| 268 |
+
// do we have OAuth strategy data?
|
| 269 |
+
if ($authentication = \Session::get('auth-strategy.authentication', array()))
|
| 270 |
+
{
|
| 271 |
+
// get the current Auth userid
|
| 272 |
+
list(, $userid) = \Auth::instance()->get_user_id();
|
| 273 |
+
|
| 274 |
+
// and link it to the provider
|
| 275 |
+
$insert_id = $opauth->link_provider(array(
|
| 276 |
+
'parent_id' => $userid,
|
| 277 |
+
'provider' => $authentication['provider'],
|
| 278 |
+
'uid' => $authentication['uid'],
|
| 279 |
+
'access_token' => $authentication['access_token'],
|
| 280 |
+
'secret' => $authentication['secret'],
|
| 281 |
+
'refresh_token' => $authentication['refresh_token'],
|
| 282 |
+
'expires' => $authentication['expires'],
|
| 283 |
+
'created_at' => time(),
|
| 284 |
+
));
|
| 285 |
+
}
|
| 286 |
+
else
|
| 287 |
+
{
|
| 288 |
+
// no data available, looks like we didn't receive an OAuth callback earlier?
|
| 289 |
+
}
|
| 290 |
+
</code></pre>
|
| 291 |
+
</td>
|
| 292 |
+
</tr>
|
| 293 |
+
</tbody>
|
| 294 |
+
</table>
|
| 295 |
+
</article>
|
| 296 |
+
|
| 297 |
+
<article>
|
| 298 |
+
<h4 id="method_get" class="method">get($key, $default = null)</h4>
|
| 299 |
+
<p>The <strong>get</strong> method is a getter that allows direct access to the raw provider callback response structure as
|
| 300 |
+
created by the Opauth strategy.</p>
|
| 301 |
+
<table class="method">
|
| 302 |
+
<tbody>
|
| 303 |
+
<tr>
|
| 304 |
+
<th class="legend">Static</th>
|
| 305 |
+
<td>No</td>
|
| 306 |
+
</tr>
|
| 307 |
+
<tr>
|
| 308 |
+
<th>Parameters</th>
|
| 309 |
+
<td>
|
| 310 |
+
<table class="parameters">
|
| 311 |
+
<tr>
|
| 312 |
+
<th>Param</th>
|
| 313 |
+
<th>Default</th>
|
| 314 |
+
<th class="description">Description</th>
|
| 315 |
+
</tr>
|
| 316 |
+
<tr>
|
| 317 |
+
<th><kbd>$key</kbd></th>
|
| 318 |
+
<td><em>required</em></td>
|
| 319 |
+
<td>Name of the key to the desired value in the response array</td>
|
| 320 |
+
</tr>
|
| 321 |
+
<tr>
|
| 322 |
+
<th><kbd>$default</kbd></th>
|
| 323 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 324 |
+
<td>Default value to return if the requested key does not exist</td>
|
| 325 |
+
</tr>
|
| 326 |
+
</table>
|
| 327 |
+
</td>
|
| 328 |
+
</tr>
|
| 329 |
+
<tr>
|
| 330 |
+
<th>Returns</th>
|
| 331 |
+
<td>mixed. The value referenced by the given key, or whatever was defined as $default.</td>
|
| 332 |
+
</tr>
|
| 333 |
+
<tr>
|
| 334 |
+
<th>Example</th>
|
| 335 |
+
<td>
|
| 336 |
+
<pre class="php"><code>// get the opauth object
|
| 337 |
+
$opauth = \Auth_Opauth::forge(false);
|
| 338 |
+
|
| 339 |
+
// get some auth data
|
| 340 |
+
$provider = $opauth->get('auth.provider');
|
| 341 |
+
$uid = $opauth->get('auth.uid');
|
| 342 |
+
$token = $opauth->get('credentials.token', null);
|
| 343 |
+
$secret = $opauth->get('credentials.secret', null);
|
| 344 |
+
$expires = $opauth->get('credentials.expires', null);
|
| 345 |
+
$refresh_token = $opauth->get('credentials.refresh_token', null);
|
| 346 |
+
</code></pre>
|
| 347 |
+
</td>
|
| 348 |
+
</tr>
|
| 349 |
+
</tbody>
|
| 350 |
+
</table>
|
| 351 |
+
<p class="note">You can only use this in the method in which you are processing the callback. In all other cases, there
|
| 352 |
+
is no OAuth response available. If there was a valid response processed earlier, its basic data is stored in the session
|
| 353 |
+
using the session key "auth-strategy".</p>
|
| 354 |
+
</article>
|
| 355 |
+
</div>
|
| 356 |
+
|
| 357 |
+
<footer>
|
| 358 |
+
<p>
|
| 359 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 360 |
+
</p>
|
| 361 |
+
</footer>
|
| 362 |
+
</div>
|
| 363 |
+
</body>
|
| 364 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/ormauth/intro.html
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Introduction - OrmAuth - Auth Package - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
<h2>OrmAuth - Introduction</h2>
|
| 47 |
+
|
| 48 |
+
<p>
|
| 49 |
+
Ormauth is a set of authentication and authorisation drivers that provide a similar functionality as Simpleauth,
|
| 50 |
+
but stores it's data in the database instead of in a configuration file. The data is accessed through ORM models.
|
| 51 |
+
</p>
|
| 52 |
+
<p>
|
| 53 |
+
Besides this, it also comes with additional functionality. Unlike Simpleauth, Ormauth supports roles assigned directly
|
| 54 |
+
to users, and permissions assigned to both users and groups, allowing for a much more fine-grained permission system.
|
| 55 |
+
It stores the user's metadata not in a serialized array, but in a separate metadata table, using the ORM's EAV functionality,
|
| 56 |
+
allowing you to access metadata like any other property of the user. It also keeps track of the previous login time,
|
| 57 |
+
which can be displayed to the user at login time as an additional security measure.
|
| 58 |
+
</p>
|
| 59 |
+
|
| 60 |
+
<h3 id="setup">Auth setup</h3>
|
| 61 |
+
|
| 62 |
+
<p>
|
| 63 |
+
Configuration starts with telling the Auth package that you are going to use the Ormauth driver.
|
| 64 |
+
This is done through the auth.php configuration file. A default file is provided in the Auth package.
|
| 65 |
+
You should copy this file to your app/config folder before making any changes. The default file is configured
|
| 66 |
+
for the Simpleauth drivers, so you need to change that. You will find an explaination of this config file <a href="../intro.html#/configuration">here</a>.
|
| 67 |
+
</p>
|
| 68 |
+
<p>
|
| 69 |
+
After you have done this, you can choose to autoload the package through the <strong>always_load</strong> section of the app/config/config.php.
|
| 70 |
+
</p>
|
| 71 |
+
|
| 72 |
+
<p class="note">As OrmAuth uses the ORM to access the database, make sure you have added the 'orm' package to the <strong>always_load</strong> section too!</p>
|
| 73 |
+
|
| 74 |
+
<h3 id="acl">ACL's</h3>
|
| 75 |
+
|
| 76 |
+
<p>
|
| 77 |
+
OrmAuth has a much more fine-grained ACL system then SimpleAuth. It uses standard ORM relations to construct the permission set
|
| 78 |
+
for any given user, and has the following features:
|
| 79 |
+
</p>
|
| 80 |
+
|
| 81 |
+
<ul>
|
| 82 |
+
<li>Every user is a member of one, and exactly one, group</li>
|
| 83 |
+
<li>Every user has zero or more roles assigned to it</li>
|
| 84 |
+
<li>Every group has zero or more roles assigned to it</li>
|
| 85 |
+
<li>Every user can have zero or more permissions assigned to it</li>
|
| 86 |
+
<li>Every group can have zero or more permissions assigned to it</li>
|
| 87 |
+
<li>Every role can have zero or more permissions assigned to it</li>
|
| 88 |
+
<li>Every permission belongs to a permission area</li>
|
| 89 |
+
<li>Every permission can have zero or more associated actions</li>
|
| 90 |
+
</ul>
|
| 91 |
+
|
| 92 |
+
<p>
|
| 93 |
+
All the permissions are aggregated per user. A role can have special permission filters, that may alter the
|
| 94 |
+
assigned aggregated permissions. These are:
|
| 95 |
+
</p>
|
| 96 |
+
|
| 97 |
+
<ul>
|
| 98 |
+
<li>"All access", stored as "A". Users with this role have all access. This is typically used for a 'super-admin' role. It overrules all permissions set.</li>
|
| 99 |
+
<li>"No access", stored as "D". Users with this role have no access. This is typically used for a 'banned' role. It overrules all permissions set.</li>
|
| 100 |
+
<li>"Revoke permissions", stored as "R". Permissions set on this role will be removed from the aggregated permissions set.</li>
|
| 101 |
+
</ul>
|
| 102 |
+
|
| 103 |
+
<p class="note">
|
| 104 |
+
Note that "revoked" permissions are checked before all others. This allows you to create permission constructs like "all access
|
| 105 |
+
for this super-admin, except to the top-secret area of the application"...
|
| 106 |
+
</p>
|
| 107 |
+
|
| 108 |
+
<p>Assigning a permission is using standard ORM relations, and is very straitforward:</p>
|
| 109 |
+
<pre class="php"><code>// get the Role identified by $role_id
|
| 110 |
+
$role = \Model\Auth_Role::find($role_id);
|
| 111 |
+
|
| 112 |
+
// get the Permission identified by $perm_id
|
| 113 |
+
$perm = \Model\Auth_Permission::find($perm_id);
|
| 114 |
+
|
| 115 |
+
// relate the two
|
| 116 |
+
$role->permissions = $perm;
|
| 117 |
+
|
| 118 |
+
// and save the relation
|
| 119 |
+
$role->save();</code></pre>
|
| 120 |
+
|
| 121 |
+
<h4 id="actions">Actions</h4>
|
| 122 |
+
|
| 123 |
+
<p>
|
| 124 |
+
As mentioned above, you can add additional granularity by adding a list of actions to a permission (a combination of area and permission).
|
| 125 |
+
</p>
|
| 126 |
+
|
| 127 |
+
<p>
|
| 128 |
+
Actions are stored as an indexed array of strings in the permission record, serialized and unserialized automatically by the ORM.
|
| 129 |
+
You can define as many actions as you want, and chose any strings you like. If needed this allows you to set a permission on each
|
| 130 |
+
and every action on a form, more fine-grained then you would probably ever need!
|
| 131 |
+
</p>
|
| 132 |
+
|
| 133 |
+
<p>
|
| 134 |
+
The action list defined on a permission specify which possible actions can be assigned when assigning the permission to either a
|
| 135 |
+
user, a group, or a role. The assigned actions are stored as an array of keys, that defines which of the actions were assigned.
|
| 136 |
+
</p>
|
| 137 |
+
|
| 138 |
+
<pre class="php"><code>// if these are the possible actions:
|
| 139 |
+
array('add', 'view', 'edit', 'delete')
|
| 140 |
+
|
| 141 |
+
// then you should store this when assigning 'view' and 'edit':
|
| 142 |
+
array(1, 2)
|
| 143 |
+
</code></pre>
|
| 144 |
+
|
| 145 |
+
<p>
|
| 146 |
+
To store this, ORM Models have been provided to directly access the relationship or though table that connects either the user, the
|
| 147 |
+
role or the group to the permission.
|
| 148 |
+
</p>
|
| 149 |
+
|
| 150 |
+
<pre class="php"><code>// get the Role identified by $role_id
|
| 151 |
+
$role = \Model\Auth_Role::find($role_id);
|
| 152 |
+
|
| 153 |
+
// get the Permission identified by $perm_id
|
| 154 |
+
$perm = \Model\Auth_Permission::find($perm_id);
|
| 155 |
+
|
| 156 |
+
// relate the two, adding a subselection of actions
|
| 157 |
+
$role->rolepermission[] = \Model\Auth_Rolepermission::forge(array(
|
| 158 |
+
'role_id' => $role->id,
|
| 159 |
+
'perms_id' => $perm->id,
|
| 160 |
+
'actions' => array(1,2),
|
| 161 |
+
));
|
| 162 |
+
|
| 163 |
+
// and save the relation
|
| 164 |
+
$role->save();</code></pre>
|
| 165 |
+
|
| 166 |
+
<p>
|
| 167 |
+
When checking for access, you specify the required access as either <code>area.permission</code> (when you want to check for
|
| 168 |
+
a single right, <code>area.[permission,permission,...]</code> when you want to check for multiple permissions at once, or if you
|
| 169 |
+
want to check for associated actions, you can use <code>area.permission[action,action,...]</code>. This is an AND check,
|
| 170 |
+
so when you specify multiple rights, the user must have ALL of them assigned to be granted access.
|
| 171 |
+
This will allow you to construct checks like <code>blog.comments[read,create,write,write-own,delete,delete-own]</code>.
|
| 172 |
+
</p>
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
<h3 id="caching">Caching</h3>
|
| 177 |
+
|
| 178 |
+
<p>
|
| 179 |
+
To reduce database I/O, the OrmAuth drivers make heavy use of caching, to avoid having to retrieve the entire permission set for the
|
| 180 |
+
logged-in user on every page request. Make sure your cache configuration is setup before you start using OrmAuth.
|
| 181 |
+
</p>
|
| 182 |
+
|
| 183 |
+
<p>
|
| 184 |
+
All cache entries are created with the prefix defined in the OrmAuth configuration file. They are created without expiration timestamp,
|
| 185 |
+
so when you design your admin backend, make sure do delete the required cache entries after an update, so the cache can be refreshed.
|
| 186 |
+
</p>
|
| 187 |
+
|
| 188 |
+
<p>
|
| 189 |
+
The following cache keys are used by OrmAuth:
|
| 190 |
+
</p>
|
| 191 |
+
<ul>
|
| 192 |
+
<li><strong><prefix>.groups</strong> - complete list of all defined groups</li>
|
| 193 |
+
<li><strong><prefix>.roles</strong> - complete list of all defined roles</li>
|
| 194 |
+
<li><strong><prefix>.permissions.user_<id></strong> - effective permissions for user <id></li>
|
| 195 |
+
</ul>
|
| 196 |
+
|
| 197 |
+
<p>
|
| 198 |
+
After an update to the permissions system, make sure to flush the cached permissions, and, if you have changed either role or group
|
| 199 |
+
definitions, flush them too.
|
| 200 |
+
</p>
|
| 201 |
+
|
| 202 |
+
<pre class="php"><code>// flush all the cached permissions
|
| 203 |
+
\Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions');
|
| 204 |
+
|
| 205 |
+
// flush all the cached groups
|
| 206 |
+
\Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.groups');
|
| 207 |
+
|
| 208 |
+
// flush all the cached roles
|
| 209 |
+
\Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.roles');
|
| 210 |
+
|
| 211 |
+
// flush the permissions of a single user (with id 12211)
|
| 212 |
+
\Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions.user_12211');</code></pre>
|
| 213 |
+
|
| 214 |
+
<h3 id="configuration">Configuration</h3>
|
| 215 |
+
|
| 216 |
+
<p>
|
| 217 |
+
The Ormauth authentication system is configured through a configuration file, not suprisingly called
|
| 218 |
+
'ormauth.php'. A default file is provided in the Auth package. You should copy this file
|
| 219 |
+
to your app/config folder before making any changes.
|
| 220 |
+
</p>
|
| 221 |
+
|
| 222 |
+
<p>The following configuration values can be defined:</p>
|
| 223 |
+
<table class="config">
|
| 224 |
+
<tbody>
|
| 225 |
+
<tr class="header">
|
| 226 |
+
<th>Param</th>
|
| 227 |
+
<th>Type</th>
|
| 228 |
+
<th>Default</th>
|
| 229 |
+
<th>Description</th>
|
| 230 |
+
</tr>
|
| 231 |
+
<tr>
|
| 232 |
+
<th>db_connection</th>
|
| 233 |
+
<td>string</td>
|
| 234 |
+
<td><pre class="php"><code>null</code></pre>
|
| 235 |
+
</td>
|
| 236 |
+
<td>
|
| 237 |
+
Name of the database connection to use. This should match the definition in your applications db.php configuration file.
|
| 238 |
+
Set it to <strong>null</strong> to use the default DB instance.
|
| 239 |
+
</td>
|
| 240 |
+
</tr>
|
| 241 |
+
<tr>
|
| 242 |
+
<th>table_name</th>
|
| 243 |
+
<td>string</td>
|
| 244 |
+
<td><pre class="php"><code>'users'</code></pre>
|
| 245 |
+
</td>
|
| 246 |
+
<td>
|
| 247 |
+
Name of the users table to use.
|
| 248 |
+
</td>
|
| 249 |
+
</tr>
|
| 250 |
+
<tr>
|
| 251 |
+
<th>table_columns</th>
|
| 252 |
+
<td>array</td>
|
| 253 |
+
<td><pre class="php"><code>array('*')</code></pre>
|
| 254 |
+
</td>
|
| 255 |
+
<td>
|
| 256 |
+
List of columns to select from the users table, or '*' to select all columns. You have to at least include
|
| 257 |
+
'username', 'password', 'email', 'last_login', 'login_hash', 'group' and 'profile_fields'.
|
| 258 |
+
</td>
|
| 259 |
+
</tr>
|
| 260 |
+
<tr>
|
| 261 |
+
<th>cache_prefix</th>
|
| 262 |
+
<td>string</td>
|
| 263 |
+
<td><pre class="php"><code>'auth'</code></pre>
|
| 264 |
+
</td>
|
| 265 |
+
<td>
|
| 266 |
+
Prefix used for cache keys when caching ORM data.
|
| 267 |
+
</td>
|
| 268 |
+
</tr>
|
| 269 |
+
<tr>
|
| 270 |
+
<th>guest_login</th>
|
| 271 |
+
<td>boolean</td>
|
| 272 |
+
<td><pre class="php"><code>true</code></pre>
|
| 273 |
+
</td>
|
| 274 |
+
<td>
|
| 275 |
+
If true a dummy 'guest' user will be created if no one is logged in. This allows you to use the group and
|
| 276 |
+
acl drivers even when no one is logged in.
|
| 277 |
+
</td>
|
| 278 |
+
</tr>
|
| 279 |
+
<tr>
|
| 280 |
+
<th>remember_me</th>
|
| 281 |
+
<td>array</td>
|
| 282 |
+
<td><pre class="php"><code>array(
|
| 283 |
+
'enabled' => false,
|
| 284 |
+
'cookie_name' => 'rmcookie',
|
| 285 |
+
'expiration' => 86400*31
|
| 286 |
+
)</code></pre>
|
| 287 |
+
</td>
|
| 288 |
+
<td>
|
| 289 |
+
Configuration for the Ormauth 'remember_me' functionality
|
| 290 |
+
</td>
|
| 291 |
+
</tr>
|
| 292 |
+
<tr>
|
| 293 |
+
<th>multiple_logins</th>
|
| 294 |
+
<td>boolean</td>
|
| 295 |
+
<td><pre class="php"><code>false</code></pre>
|
| 296 |
+
</td>
|
| 297 |
+
<td>
|
| 298 |
+
If true multiple concurrent logins of the same user are allowed. If false, when a user logs in, any previous login will be
|
| 299 |
+
cancelled. Note that enabling this will disable some login session hijacking measures!
|
| 300 |
+
</td>
|
| 301 |
+
</tr>
|
| 302 |
+
<tr>
|
| 303 |
+
<th>login_hash_salt</th>
|
| 304 |
+
<td>string</td>
|
| 305 |
+
<td><pre class="php"><code>'put_some_salt_in_here'</code></pre>
|
| 306 |
+
</td>
|
| 307 |
+
<td>
|
| 308 |
+
To make the passwords used by the OrmAuth drivers extra secure, a salt value is used when hashing
|
| 309 |
+
the passwords to store them into the database. Make sure you change this default to a very random string!
|
| 310 |
+
To hash passwords, OrmAuth uses <a href="http://en.wikipedia.org/wiki/PBKDF2" target="_blank">PBKDF2</a>, a very secure hashing mechanism.
|
| 311 |
+
</td>
|
| 312 |
+
</tr>
|
| 313 |
+
<tr>
|
| 314 |
+
<th>username_post_key</th>
|
| 315 |
+
<td>string</td>
|
| 316 |
+
<td><pre class="php"><code>'username'</code></pre>
|
| 317 |
+
</td>
|
| 318 |
+
<td>
|
| 319 |
+
Name of the input field on the login form that contains the username.
|
| 320 |
+
</td>
|
| 321 |
+
</tr>
|
| 322 |
+
<tr>
|
| 323 |
+
<th>password_post_key</th>
|
| 324 |
+
<td>string</td>
|
| 325 |
+
<td><pre class="php"><code>'password'</code></pre>
|
| 326 |
+
</td>
|
| 327 |
+
<td>
|
| 328 |
+
Name of the input field on the login form that contains the password.
|
| 329 |
+
</td>
|
| 330 |
+
</tr>
|
| 331 |
+
</tbody>
|
| 332 |
+
</table>
|
| 333 |
+
|
| 334 |
+
<p class="note">
|
| 335 |
+
If you want to use the 'remember-me' functionality, make sure you have a valid <a href="../../../classes/crypt.html">Crypt</a> configuration, as it
|
| 336 |
+
uses an encrypted cookie to store the user information to be remembered.
|
| 337 |
+
</p>
|
| 338 |
+
|
| 339 |
+
<h3 id="database">Database table</h3>
|
| 340 |
+
|
| 341 |
+
<p>
|
| 342 |
+
OrmAuth relies on a quite a few tables to store all information. The Auth package contains the required migration files to create these tables.<br />
|
| 343 |
+
Just run <code>oil refine migrate --packages=auth</code> to have these tables created for you.
|
| 344 |
+
</p>
|
| 345 |
+
|
| 346 |
+
<h3 id="example">Example</h3>
|
| 347 |
+
|
| 348 |
+
<p>This is a sample login action:</p>
|
| 349 |
+
|
| 350 |
+
<pre class="php"><code>public function action_login()
|
| 351 |
+
{
|
| 352 |
+
$data = array();
|
| 353 |
+
|
| 354 |
+
// If so, you pressed the submit button. Let's go over the steps.
|
| 355 |
+
if (Input::post())
|
| 356 |
+
{
|
| 357 |
+
// Check the credentials. This assumes that you have the previous table created and
|
| 358 |
+
// you have used the table definition and configuration as mentioned above.
|
| 359 |
+
if (Auth::login())
|
| 360 |
+
{
|
| 361 |
+
// Credentials ok, go right in.
|
| 362 |
+
Response::redirect('success_page');
|
| 363 |
+
}
|
| 364 |
+
else
|
| 365 |
+
{
|
| 366 |
+
// Oops, no soup for you. Try to login again. Set some values to
|
| 367 |
+
// repopulate the username field and give some error text back to the view.
|
| 368 |
+
$data['username'] = Input::post('username');
|
| 369 |
+
$data['login_error'] = 'Wrong username/password combo. Try again';
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
// Show the login form.
|
| 374 |
+
echo View::forge('auth/login',$data);
|
| 375 |
+
}</code></pre>
|
| 376 |
+
|
| 377 |
+
</div>
|
| 378 |
+
|
| 379 |
+
<footer>
|
| 380 |
+
<p>
|
| 381 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 382 |
+
</p>
|
| 383 |
+
</footer>
|
| 384 |
+
</div>
|
| 385 |
+
</body>
|
| 386 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/ormauth/usage.html
ADDED
|
@@ -0,0 +1,1329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Usage - OrmAuth - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
<h2 id="usage">OrmAuth Usage</h2>
|
| 48 |
+
|
| 49 |
+
<p>
|
| 50 |
+
As said in the <a href="../intro.html">introduction</a> of the Auth package, an authentication system comes with
|
| 51 |
+
three different drivers, each dealing with a part of the system:
|
| 52 |
+
</p>
|
| 53 |
+
<p>
|
| 54 |
+
The Ormauth <kbd>login</kbd> driver provides the logic for creating, updating, deleting and validating user accounts
|
| 55 |
+
stored in a local database table, for getting information about those accounts, for generating or resetting
|
| 56 |
+
passwords, and for login and logout operations (creating a user session).
|
| 57 |
+
</p>
|
| 58 |
+
|
| 59 |
+
<p>
|
| 60 |
+
The Ormauth <kbd>group</kbd> driver stores it's group definitions in the database, and accesses it through ORM. It provides the logic
|
| 61 |
+
for checking if a user is a member of a group, and for retrieving group information, or the roles defined to to a group.
|
| 62 |
+
</p>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
The Ormauth <kbd>acl</kbd> driver is role driven, and stores it's acl definitions in the database, and accesses it through ORM.
|
| 66 |
+
It provides the logic for checking if a user has access to a named ACL.
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<h3 id="classmethods">Static vs Dynamic</h3>
|
| 70 |
+
|
| 71 |
+
<p>As explained in the introduction, the Auth package provides a static interface to most of the method available, providing you
|
| 72 |
+
only a single driver set. These methods will be defined below as "Static: Yes". All methods are also accessable via chaining on the
|
| 73 |
+
Auth instance or an Auth driver instance object, including the ones marked as static. </p>
|
| 74 |
+
|
| 75 |
+
<h3 id="classmethods">Class methods</h3>
|
| 76 |
+
|
| 77 |
+
<article>
|
| 78 |
+
<h4 id="method_validate_user" class="method">validate_user($username_or_email = '', $password = '')</h4>
|
| 79 |
+
<p>The <strong>validate_user</strong> method validates user credentials. This method supports both email address and username as valid credential.</p>
|
| 80 |
+
<table class="method">
|
| 81 |
+
<tbody>
|
| 82 |
+
<tr>
|
| 83 |
+
<th class="legend">Static</th>
|
| 84 |
+
<td>Yes</td>
|
| 85 |
+
</tr>
|
| 86 |
+
<tr>
|
| 87 |
+
<th>Parameters</th>
|
| 88 |
+
<td>
|
| 89 |
+
<table class="parameters">
|
| 90 |
+
<tr>
|
| 91 |
+
<th>Param</th>
|
| 92 |
+
<th>Default</th>
|
| 93 |
+
<th class="description">Description</th>
|
| 94 |
+
</tr>
|
| 95 |
+
<tr>
|
| 96 |
+
<th><kbd>$username_or_email</kbd></th>
|
| 97 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 98 |
+
<td>Either the users username or email address</td>
|
| 99 |
+
</tr>
|
| 100 |
+
<tr>
|
| 101 |
+
<th><kbd>$password</kbd></th>
|
| 102 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 103 |
+
<td>The users password</td>
|
| 104 |
+
</tr>
|
| 105 |
+
</table>
|
| 106 |
+
</td>
|
| 107 |
+
</tr>
|
| 108 |
+
<tr>
|
| 109 |
+
<th>Returns</th>
|
| 110 |
+
<td>mixed. <strong>false</strong> if the user didn't pass validation, or an instance of <strong>\Model\Auth_User</strong> with the users information if the credentials were valid.</td>
|
| 111 |
+
</tr>
|
| 112 |
+
<tr>
|
| 113 |
+
<th>Example</th>
|
| 114 |
+
<td>
|
| 115 |
+
<pre class="php"><code>// validate the a username and password
|
| 116 |
+
if ($user = Auth::validate_user($name, $pass))
|
| 117 |
+
{
|
| 118 |
+
// the combination of $name and $pass validated, print the users screen name
|
| 119 |
+
echo $user->username;
|
| 120 |
+
}
|
| 121 |
+
</code></pre>
|
| 122 |
+
</td>
|
| 123 |
+
</tr>
|
| 124 |
+
</tbody>
|
| 125 |
+
</table>
|
| 126 |
+
<p class="note">This method only validates if a given combination of username and password is correct. It does NOT log the user in!</p>
|
| 127 |
+
</article>
|
| 128 |
+
|
| 129 |
+
<article>
|
| 130 |
+
<h4 id="method_login" class="method">login($username_or_email = '', $password = '')</h4>
|
| 131 |
+
<p>The <strong>login</strong> method performs a login request. If a parameter is not given, it will attempt to
|
| 132 |
+
retrieve it from posted data, used the form fieldnames configured in the ormauth.php configuration file.
|
| 133 |
+
Internally it calls the validate_user() method to validate the request before attempting a login.</p>
|
| 134 |
+
<table class="method">
|
| 135 |
+
<tbody>
|
| 136 |
+
<tr>
|
| 137 |
+
<th class="legend">Static</th>
|
| 138 |
+
<td>Yes</td>
|
| 139 |
+
</tr>
|
| 140 |
+
<tr>
|
| 141 |
+
<th>Parameters</th>
|
| 142 |
+
<td>
|
| 143 |
+
<table class="parameters">
|
| 144 |
+
<tr>
|
| 145 |
+
<th>Param</th>
|
| 146 |
+
<th>Default</th>
|
| 147 |
+
<th class="description">Description</th>
|
| 148 |
+
</tr>
|
| 149 |
+
<tr>
|
| 150 |
+
<th><kbd>$username_or_email</kbd></th>
|
| 151 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 152 |
+
<td>Either the users username or email address</td>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<th><kbd>$password</kbd></th>
|
| 156 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 157 |
+
<td>The users password</td>
|
| 158 |
+
</tr>
|
| 159 |
+
</table>
|
| 160 |
+
</td>
|
| 161 |
+
</tr>
|
| 162 |
+
<tr>
|
| 163 |
+
<th>Returns</th>
|
| 164 |
+
<td>boolean. returns <strong>true</strong> if the login was succesful, <strong>false</strong> otherwise.</td>
|
| 165 |
+
</tr>
|
| 166 |
+
<tr>
|
| 167 |
+
<th>Example</th>
|
| 168 |
+
<td>
|
| 169 |
+
<pre class="php"><code>// perform a login
|
| 170 |
+
if (Auth::login($name, $pass))
|
| 171 |
+
{
|
| 172 |
+
// the user is succesfully logged in
|
| 173 |
+
}
|
| 174 |
+
</code></pre>
|
| 175 |
+
</td>
|
| 176 |
+
</tr>
|
| 177 |
+
</tbody>
|
| 178 |
+
</table>
|
| 179 |
+
<p class="note">After a succesful login, the 'username' and the current 'login_hash' will be available as a session variable.</p>
|
| 180 |
+
</article>
|
| 181 |
+
|
| 182 |
+
<article>
|
| 183 |
+
<h4 id="method_check" class="method">check()</h4>
|
| 184 |
+
<p>The <strong>check</strong> method checks if a logged-in user is present.</p>
|
| 185 |
+
<table class="method">
|
| 186 |
+
<tbody>
|
| 187 |
+
<tr>
|
| 188 |
+
<th class="legend">Static</th>
|
| 189 |
+
<td>Yes</td>
|
| 190 |
+
</tr>
|
| 191 |
+
<tr>
|
| 192 |
+
<th>Parameters</th>
|
| 193 |
+
<td>
|
| 194 |
+
None
|
| 195 |
+
</td>
|
| 196 |
+
</tr>
|
| 197 |
+
<tr>
|
| 198 |
+
<th>Returns</th>
|
| 199 |
+
<td>boolean. returns <strong>true</strong> if the is a logged-in user, <strong>false</strong> otherwise.</td>
|
| 200 |
+
</tr>
|
| 201 |
+
<tr>
|
| 202 |
+
<th>Example</th>
|
| 203 |
+
<td>
|
| 204 |
+
<pre class="php"><code>// login if we're not logged-in
|
| 205 |
+
if ( ! Auth::check())
|
| 206 |
+
{
|
| 207 |
+
Response::redirect('/login');
|
| 208 |
+
}
|
| 209 |
+
</code></pre>
|
| 210 |
+
</td>
|
| 211 |
+
</tr>
|
| 212 |
+
</tbody>
|
| 213 |
+
</table>
|
| 214 |
+
</article>
|
| 215 |
+
|
| 216 |
+
<article>
|
| 217 |
+
<h4 id="method_force_login" class="method">force_login($user_id = '')</h4>
|
| 218 |
+
<p>
|
| 219 |
+
The <strong>force_login</strong> method performs a forced login request. You can use this for an automated login, when you know
|
| 220 |
+
the users id, but you don't know the password. This can be used for example to implement a "remember me" feature.</p>
|
| 221 |
+
<table class="method">
|
| 222 |
+
<tbody>
|
| 223 |
+
<tr>
|
| 224 |
+
<th class="legend">Static</th>
|
| 225 |
+
<td>Yes</td>
|
| 226 |
+
</tr>
|
| 227 |
+
<tr>
|
| 228 |
+
<th>Parameters</th>
|
| 229 |
+
<td>
|
| 230 |
+
<table class="parameters">
|
| 231 |
+
<tr>
|
| 232 |
+
<th>Param</th>
|
| 233 |
+
<th>Default</th>
|
| 234 |
+
<th class="description">Description</th>
|
| 235 |
+
</tr>
|
| 236 |
+
<tr>
|
| 237 |
+
<th><kbd>$user_id</kbd></th>
|
| 238 |
+
<td>required</td>
|
| 239 |
+
<td>The id of the user you want to login, or a valid instance of \Model\Auth_User</td>
|
| 240 |
+
</tr>
|
| 241 |
+
</table>
|
| 242 |
+
</td>
|
| 243 |
+
</tr>
|
| 244 |
+
<tr>
|
| 245 |
+
<th>Returns</th>
|
| 246 |
+
<td>boolean. returns <strong>true</strong> if the login was succesful, <strong>false</strong> otherwise.</td>
|
| 247 |
+
</tr>
|
| 248 |
+
<tr>
|
| 249 |
+
<th>Example</th>
|
| 250 |
+
<td>
|
| 251 |
+
<pre class="php"><code>// perform a forced login for user 12121
|
| 252 |
+
if (Auth::force_login(12121))
|
| 253 |
+
{
|
| 254 |
+
// the user is succesfully logged in. Any previously logged-in user will be logged out!
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
// perform a forced login for user object 12121
|
| 258 |
+
$user = \Model\Auth_User::find(12121);
|
| 259 |
+
if (Auth::force_login($user))
|
| 260 |
+
{
|
| 261 |
+
// the user is succesfully logged in. Any previously logged-in user will be logged out!
|
| 262 |
+
}</code></pre>
|
| 263 |
+
</td>
|
| 264 |
+
</tr>
|
| 265 |
+
</tbody>
|
| 266 |
+
</table>
|
| 267 |
+
</article>
|
| 268 |
+
|
| 269 |
+
<article>
|
| 270 |
+
<h4 id="method_logout" class="method">logout()</h4>
|
| 271 |
+
<p>The <strong>logout</strong> method logs out the current logged-in user.</p>
|
| 272 |
+
<table class="method">
|
| 273 |
+
<tbody>
|
| 274 |
+
<tr>
|
| 275 |
+
<th class="legend">Static</th>
|
| 276 |
+
<td>Yes</td>
|
| 277 |
+
</tr>
|
| 278 |
+
<tr>
|
| 279 |
+
<th>Parameters</th>
|
| 280 |
+
<td>
|
| 281 |
+
None
|
| 282 |
+
</td>
|
| 283 |
+
</tr>
|
| 284 |
+
<tr>
|
| 285 |
+
<th>Returns</th>
|
| 286 |
+
<td>boolean. returns <strong>true</strong> if the logout was succesful, <strong>false</strong> otherwise.</td>
|
| 287 |
+
</tr>
|
| 288 |
+
<tr>
|
| 289 |
+
<th>Example</th>
|
| 290 |
+
<td>
|
| 291 |
+
<pre class="php"><code>// perform a logout
|
| 292 |
+
Auth::logout();
|
| 293 |
+
</code></pre>
|
| 294 |
+
</td>
|
| 295 |
+
</tr>
|
| 296 |
+
</tbody>
|
| 297 |
+
</table>
|
| 298 |
+
<p class="note">If you have enabled guest user support, the guest user will be setup after a succesful logout.</p>
|
| 299 |
+
</article>
|
| 300 |
+
|
| 301 |
+
<article>
|
| 302 |
+
<h4 id="method_create_user" class="method">create_user($username, $password, $email, $group = 1, Array $profile_fields = array())</h4>
|
| 303 |
+
<p>
|
| 304 |
+
The <strong>create_user</strong> allows method you to create a new user record in the users table.
|
| 305 |
+
</p>
|
| 306 |
+
<table class="method">
|
| 307 |
+
<tbody>
|
| 308 |
+
<tr>
|
| 309 |
+
<th class="legend">Static</th>
|
| 310 |
+
<td>Yes</td>
|
| 311 |
+
</tr>
|
| 312 |
+
<tr>
|
| 313 |
+
<th>Parameters</th>
|
| 314 |
+
<td>
|
| 315 |
+
<table class="parameters">
|
| 316 |
+
<tr>
|
| 317 |
+
<th>Param</th>
|
| 318 |
+
<th>Default</th>
|
| 319 |
+
<th class="description">Description</th>
|
| 320 |
+
</tr>
|
| 321 |
+
<tr>
|
| 322 |
+
<th><kbd>$username</kbd></th>
|
| 323 |
+
<td>required</td>
|
| 324 |
+
<td>The name of the user you want to create</td>
|
| 325 |
+
</tr>
|
| 326 |
+
<tr>
|
| 327 |
+
<th><kbd>$password</kbd></th>
|
| 328 |
+
<td>required</td>
|
| 329 |
+
<td>The password you want to assign to the user</td>
|
| 330 |
+
</tr>
|
| 331 |
+
<tr>
|
| 332 |
+
<th><kbd>$email</kbd></th>
|
| 333 |
+
<td>required</td>
|
| 334 |
+
<td>The email address of the user you want to create</td>
|
| 335 |
+
</tr>
|
| 336 |
+
<tr>
|
| 337 |
+
<th><kbd>$group</kbd></th>
|
| 338 |
+
<td>1</td>
|
| 339 |
+
<td>The group you want to assign this user to. By default, the user is assigned to group 1.</td>
|
| 340 |
+
</tr>
|
| 341 |
+
<tr>
|
| 342 |
+
<th><kbd>$profile_fields</kbd></th>
|
| 343 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 344 |
+
<td>Any additional user metadata you want to assign to this user</td>
|
| 345 |
+
</tr>
|
| 346 |
+
</table>
|
| 347 |
+
</td>
|
| 348 |
+
</tr>
|
| 349 |
+
<tr>
|
| 350 |
+
<th>Throws</th>
|
| 351 |
+
<td>SimpleUserUpdateException</td>
|
| 352 |
+
</tr>
|
| 353 |
+
<tr>
|
| 354 |
+
<th>Returns</th>
|
| 355 |
+
<td>mixed. returns the id of the user record created, or <strong>false</strong> if the creation failed.</td>
|
| 356 |
+
</tr>
|
| 357 |
+
<tr>
|
| 358 |
+
<th>Example</th>
|
| 359 |
+
<td>
|
| 360 |
+
<pre class="php"><code>// create a new user
|
| 361 |
+
Auth::create_user(
|
| 362 |
+
'anewuser',
|
| 363 |
+
'thisismysecretpassword',
|
| 364 |
+
'anewuser@example.org',
|
| 365 |
+
1,
|
| 366 |
+
array(
|
| 367 |
+
'fullname' => 'A. New User',
|
| 368 |
+
)
|
| 369 |
+
);
|
| 370 |
+
</code></pre>
|
| 371 |
+
</td>
|
| 372 |
+
</tr>
|
| 373 |
+
</tbody>
|
| 374 |
+
</table>
|
| 375 |
+
<p class="note">The $profile_fields parameter is defined for API compatibility with Simpleauth. The field in the user
|
| 376 |
+
table is not used, any metadata passed is stored in the metadata table.</p>
|
| 377 |
+
</article>
|
| 378 |
+
|
| 379 |
+
<article>
|
| 380 |
+
<h4 id="method_update_user" class="method">update_user($values, $username = null)</h4>
|
| 381 |
+
<p>
|
| 382 |
+
The <strong>update_user</strong> method allows you to update values in the user record,
|
| 383 |
+
either for a named user, or for the current logged-in user.
|
| 384 |
+
</p>
|
| 385 |
+
<table class="method">
|
| 386 |
+
<tbody>
|
| 387 |
+
<tr>
|
| 388 |
+
<th class="legend">Static</th>
|
| 389 |
+
<td>Yes</td>
|
| 390 |
+
</tr>
|
| 391 |
+
<tr>
|
| 392 |
+
<th>Parameters</th>
|
| 393 |
+
<td>
|
| 394 |
+
<table class="parameters">
|
| 395 |
+
<tr>
|
| 396 |
+
<th>Param</th>
|
| 397 |
+
<th>Default</th>
|
| 398 |
+
<th class="description">Description</th>
|
| 399 |
+
</tr>
|
| 400 |
+
<tr>
|
| 401 |
+
<th><kbd>$values</kbd></th>
|
| 402 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 403 |
+
<td>Associative array with column name / value pairs for the columns or profile fields you want to update.</td>
|
| 404 |
+
</tr>
|
| 405 |
+
<tr>
|
| 406 |
+
<th><kbd>$username</kbd></th>
|
| 407 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 408 |
+
<td>The name of the user you want to update</td>
|
| 409 |
+
</tr>
|
| 410 |
+
</table>
|
| 411 |
+
</td>
|
| 412 |
+
</tr>
|
| 413 |
+
<tr>
|
| 414 |
+
<th>Throws</th>
|
| 415 |
+
<td>SimpleUserUpdateException</td>
|
| 416 |
+
</tr>
|
| 417 |
+
<tr>
|
| 418 |
+
<th>Returns</th>
|
| 419 |
+
<td>boolean. returns <strong>true</strong> if columns were updated, or <strong>false</strong> if no columns were affected.</td>
|
| 420 |
+
</tr>
|
| 421 |
+
<tr>
|
| 422 |
+
<th>Example</th>
|
| 423 |
+
<td>
|
| 424 |
+
<pre class="php"><code>// update the data for the current user
|
| 425 |
+
Auth::update_user(
|
| 426 |
+
array(
|
| 427 |
+
'email' => 'anewemail@example.org', // set a new email address
|
| 428 |
+
'password' => 'thisismynewpassword', // set a new password
|
| 429 |
+
'old_password' => 'thisismysecretpassword', // to do so, give the current one!
|
| 430 |
+
'phone' => '+1 (555) 123-1212', // and add the phone number to the metadata
|
| 431 |
+
)
|
| 432 |
+
);
|
| 433 |
+
</code></pre>
|
| 434 |
+
</td>
|
| 435 |
+
</tr>
|
| 436 |
+
</tbody>
|
| 437 |
+
</table>
|
| 438 |
+
<p class="note">
|
| 439 |
+
This method is primary provided to allow the user to do profile updates. And as a security measure, it will <strong>not</strong> allow you
|
| 440 |
+
to change the username, and if you want to change the password, you <strong>have</strong> to pass the current password in $values as "old_password".
|
| 441 |
+
</p>
|
| 442 |
+
</article>
|
| 443 |
+
|
| 444 |
+
<article>
|
| 445 |
+
<h4 id="method_change_password" class="method">change_password($old_password, $new_password, $username = null)</h4>
|
| 446 |
+
<p>
|
| 447 |
+
The <strong>change_password</strong> method allows you to change a users password.
|
| 448 |
+
</p>
|
| 449 |
+
<table class="method">
|
| 450 |
+
<tbody>
|
| 451 |
+
<tr>
|
| 452 |
+
<th class="legend">Static</th>
|
| 453 |
+
<td>Yes</td>
|
| 454 |
+
</tr>
|
| 455 |
+
<tr>
|
| 456 |
+
<th>Parameters</th>
|
| 457 |
+
<td>
|
| 458 |
+
<table class="parameters">
|
| 459 |
+
<tr>
|
| 460 |
+
<th>Param</th>
|
| 461 |
+
<th>Default</th>
|
| 462 |
+
<th class="description">Description</th>
|
| 463 |
+
</tr>
|
| 464 |
+
<tr>
|
| 465 |
+
<th><kbd>$old_password</kbd></th>
|
| 466 |
+
<td>required</td>
|
| 467 |
+
<td>The users current password</td>
|
| 468 |
+
</tr>
|
| 469 |
+
<tr>
|
| 470 |
+
<th><kbd>$new_password</kbd></th>
|
| 471 |
+
<td>required</td>
|
| 472 |
+
<td>The users new password</td>
|
| 473 |
+
</tr>
|
| 474 |
+
<tr>
|
| 475 |
+
<th><kbd>$username</kbd></th>
|
| 476 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 477 |
+
<td>The name of the user of whom you want to change the password</td>
|
| 478 |
+
</tr>
|
| 479 |
+
</table>
|
| 480 |
+
</td>
|
| 481 |
+
</tr>
|
| 482 |
+
<tr>
|
| 483 |
+
<th>Throws</th>
|
| 484 |
+
<td>SimpleUserUpdateException</td>
|
| 485 |
+
</tr>
|
| 486 |
+
<tr>
|
| 487 |
+
<th>Returns</th>
|
| 488 |
+
<td>boolean. returns <strong>true</strong> if the password was changed, or <strong>false</strong> if the old password was incorrect.</td>
|
| 489 |
+
</tr>
|
| 490 |
+
<tr>
|
| 491 |
+
<th>Example</th>
|
| 492 |
+
<td>
|
| 493 |
+
<pre class="php"><code>// reset the password for the current user
|
| 494 |
+
Auth::change_password('thisismynewpassword','thisismysecretpassword');
|
| 495 |
+
</code></pre>
|
| 496 |
+
</td>
|
| 497 |
+
</tr>
|
| 498 |
+
</tbody>
|
| 499 |
+
</table>
|
| 500 |
+
<p class="note">
|
| 501 |
+
This method is provided to allow the user to change his password. And as a security measure, you <strong>have</strong> to
|
| 502 |
+
pass the current password in "old_password".
|
| 503 |
+
</p>
|
| 504 |
+
</article>
|
| 505 |
+
|
| 506 |
+
<article>
|
| 507 |
+
<h4 id="method_reset_password" class="method">reset_password($username)</h4>
|
| 508 |
+
<p>
|
| 509 |
+
The <strong>reset_password</strong> method allows you to assign a new random password to a user.
|
| 510 |
+
</p>
|
| 511 |
+
<table class="method">
|
| 512 |
+
<tbody>
|
| 513 |
+
<tr>
|
| 514 |
+
<th class="legend">Static</th>
|
| 515 |
+
<td>Yes</td>
|
| 516 |
+
</tr>
|
| 517 |
+
<tr>
|
| 518 |
+
<th>Parameters</th>
|
| 519 |
+
<td>
|
| 520 |
+
<table class="parameters">
|
| 521 |
+
<tr>
|
| 522 |
+
<th>Param</th>
|
| 523 |
+
<th>Default</th>
|
| 524 |
+
<th class="description">Description</th>
|
| 525 |
+
</tr>
|
| 526 |
+
<tr>
|
| 527 |
+
<th><kbd>$username</kbd></th>
|
| 528 |
+
<td>required</td>
|
| 529 |
+
<td>The name of the user for whom you want to reset the password</td>
|
| 530 |
+
</tr>
|
| 531 |
+
</table>
|
| 532 |
+
</td>
|
| 533 |
+
</tr>
|
| 534 |
+
<tr>
|
| 535 |
+
<th>Throws</th>
|
| 536 |
+
<td>SimpleUserUpdateException</td>
|
| 537 |
+
</tr>
|
| 538 |
+
<tr>
|
| 539 |
+
<th>Returns</th>
|
| 540 |
+
<td>string, the generated random password.</td>
|
| 541 |
+
</tr>
|
| 542 |
+
<tr>
|
| 543 |
+
<th>Example</th>
|
| 544 |
+
<td>
|
| 545 |
+
<pre class="php"><code>// reset the password for the current user
|
| 546 |
+
$new_password = Auth::reset_password('thisusername');
|
| 547 |
+
</code></pre>
|
| 548 |
+
</td>
|
| 549 |
+
</tr>
|
| 550 |
+
</tbody>
|
| 551 |
+
</table>
|
| 552 |
+
</article>
|
| 553 |
+
|
| 554 |
+
<article>
|
| 555 |
+
<h4 id="method_delete_user" class="method">delete_user($username)</h4>
|
| 556 |
+
<p>
|
| 557 |
+
The <strong>delete_user</strong> method allows you to delete a user account.
|
| 558 |
+
</p>
|
| 559 |
+
<table class="method">
|
| 560 |
+
<tbody>
|
| 561 |
+
<tr>
|
| 562 |
+
<th class="legend">Static</th>
|
| 563 |
+
<td>Yes</td>
|
| 564 |
+
</tr>
|
| 565 |
+
<tr>
|
| 566 |
+
<th>Parameters</th>
|
| 567 |
+
<td>
|
| 568 |
+
<table class="parameters">
|
| 569 |
+
<tr>
|
| 570 |
+
<th>Param</th>
|
| 571 |
+
<th>Default</th>
|
| 572 |
+
<th class="description">Description</th>
|
| 573 |
+
</tr>
|
| 574 |
+
<tr>
|
| 575 |
+
<th><kbd>$username</kbd></th>
|
| 576 |
+
<td>required</td>
|
| 577 |
+
<td>The name of the user account you want to delete</td>
|
| 578 |
+
</tr>
|
| 579 |
+
</table>
|
| 580 |
+
</td>
|
| 581 |
+
</tr>
|
| 582 |
+
<tr>
|
| 583 |
+
<th>Throws</th>
|
| 584 |
+
<td>SimpleUserUpdateException</td>
|
| 585 |
+
</tr>
|
| 586 |
+
<tr>
|
| 587 |
+
<th>Returns</th>
|
| 588 |
+
<td>boolean. returns <strong>true</strong> if the user account was deleted, or <strong>false</strong> if it failed (because the username did not exist).</td>
|
| 589 |
+
</tr>
|
| 590 |
+
<tr>
|
| 591 |
+
<th>Example</th>
|
| 592 |
+
<td>
|
| 593 |
+
<pre class="php"><code>// delete the user
|
| 594 |
+
Auth::delete_user('thisusername');
|
| 595 |
+
</code></pre>
|
| 596 |
+
</td>
|
| 597 |
+
</tr>
|
| 598 |
+
</tbody>
|
| 599 |
+
</table>
|
| 600 |
+
<p class="note">This will delete all metadata too, using ORM's cascade_delete feature.</p>
|
| 601 |
+
</article>
|
| 602 |
+
|
| 603 |
+
<article>
|
| 604 |
+
<h4 id="method_create_login_hash" class="method">create_login_hash()</h4>
|
| 605 |
+
<p>The <strong>create_login_hash</strong> method generates a new login hash for the currently logged-in user.</p>
|
| 606 |
+
<table class="method">
|
| 607 |
+
<tbody>
|
| 608 |
+
<tr>
|
| 609 |
+
<th class="legend">Static</th>
|
| 610 |
+
<td>Yes</td>
|
| 611 |
+
</tr>
|
| 612 |
+
<tr>
|
| 613 |
+
<th>Parameters</th>
|
| 614 |
+
<td>
|
| 615 |
+
None
|
| 616 |
+
</td>
|
| 617 |
+
</tr>
|
| 618 |
+
<tr>
|
| 619 |
+
<th>Returns</th>
|
| 620 |
+
<td>string, the generated login hash.</td>
|
| 621 |
+
</tr>
|
| 622 |
+
<tr>
|
| 623 |
+
<th>Example</th>
|
| 624 |
+
<td>
|
| 625 |
+
<pre class="php"><code>// generate a new random hash
|
| 626 |
+
Auth::create_login_hash();
|
| 627 |
+
</code></pre>
|
| 628 |
+
</td>
|
| 629 |
+
</tr>
|
| 630 |
+
</tbody>
|
| 631 |
+
</table>
|
| 632 |
+
<p class="note">This method is normally used when a user logs in, but you can use this as an extra security measure by rotating
|
| 633 |
+
the hash regularly for logged-in users.</p>
|
| 634 |
+
<p class="note">Note that login hash protection is <kbd>not</kbd> used when multiple logins is enabled!</p>
|
| 635 |
+
</article>
|
| 636 |
+
|
| 637 |
+
<article>
|
| 638 |
+
<h4 id="method_get" class="method">get($field, $default = null)</h4>
|
| 639 |
+
<p>The <strong>get</strong> method is a generic getter for user properties, either from the user record, or from the metadata.</p>
|
| 640 |
+
<table class="method">
|
| 641 |
+
<tbody>
|
| 642 |
+
<tr>
|
| 643 |
+
<th class="legend">Static</th>
|
| 644 |
+
<td>Yes</td>
|
| 645 |
+
</tr>
|
| 646 |
+
<tr>
|
| 647 |
+
<th>Parameters</th>
|
| 648 |
+
<td>
|
| 649 |
+
<table class="parameters">
|
| 650 |
+
<tr>
|
| 651 |
+
<th>Param</th>
|
| 652 |
+
<th>Default</th>
|
| 653 |
+
<th class="description">Description</th>
|
| 654 |
+
</tr>
|
| 655 |
+
<tr>
|
| 656 |
+
<th><kbd>$field</kbd></th>
|
| 657 |
+
<td>required</td>
|
| 658 |
+
<td>The name of the property you want the value of</td>
|
| 659 |
+
</tr>
|
| 660 |
+
<tr>
|
| 661 |
+
<th><kbd>$default</kbd></th>
|
| 662 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 663 |
+
<td>The value to return is the property is not set</td>
|
| 664 |
+
</tr>
|
| 665 |
+
</table>
|
| 666 |
+
</td>
|
| 667 |
+
</tr>
|
| 668 |
+
<tr>
|
| 669 |
+
<th>Returns</th>
|
| 670 |
+
<td>mixed.</td>
|
| 671 |
+
</tr>
|
| 672 |
+
<tr>
|
| 673 |
+
<th>Example</th>
|
| 674 |
+
<td>
|
| 675 |
+
<pre class="php"><code>// get the user creation date
|
| 676 |
+
$created_at = Auth::get('created_at');
|
| 677 |
+
</code></pre>
|
| 678 |
+
</td>
|
| 679 |
+
</tr>
|
| 680 |
+
</tbody>
|
| 681 |
+
</table>
|
| 682 |
+
</article>
|
| 683 |
+
|
| 684 |
+
<article>
|
| 685 |
+
<h4 id="method_get_user_id" class="method">get_user_id()</h4>
|
| 686 |
+
<p>The <strong>get_user_id</strong> method returns an array structure containing the drivers id value, and the id of
|
| 687 |
+
the currently logged-in user. It uses this structure because you can have multiple login drivers active, each can have
|
| 688 |
+
a different id for the currently logged-in user.</p>
|
| 689 |
+
<table class="method">
|
| 690 |
+
<tbody>
|
| 691 |
+
<tr>
|
| 692 |
+
<th class="legend">Static</th>
|
| 693 |
+
<td>Yes</td>
|
| 694 |
+
</tr>
|
| 695 |
+
<tr>
|
| 696 |
+
<th>Parameters</th>
|
| 697 |
+
<td>
|
| 698 |
+
None
|
| 699 |
+
</td>
|
| 700 |
+
</tr>
|
| 701 |
+
<tr>
|
| 702 |
+
<th>Returns</th>
|
| 703 |
+
<td>mixed. returns a numeric array in the form <strong>array([0]=>driver_id, [1]=>user_id)</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 704 |
+
</tr>
|
| 705 |
+
<tr>
|
| 706 |
+
<th>Example</th>
|
| 707 |
+
<td>
|
| 708 |
+
<pre class="php"><code>// get all login id information
|
| 709 |
+
$id_info = Auth::get_user_id();
|
| 710 |
+
|
| 711 |
+
// print driver and id info
|
| 712 |
+
if ($id_info)
|
| 713 |
+
{
|
| 714 |
+
foreach ($id_info as $info)
|
| 715 |
+
{
|
| 716 |
+
echo 'Driver: ',$info[0],' with ID ',$info[1],'<br />';
|
| 717 |
+
}
|
| 718 |
+
}
|
| 719 |
+
else
|
| 720 |
+
{
|
| 721 |
+
echo 'Nobody is logged in!';
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
// if you only use one driver, you can also do
|
| 725 |
+
list($driver, $userid) = Auth::get_user_id();
|
| 726 |
+
|
| 727 |
+
// or this if you only need the userid
|
| 728 |
+
list(, $userid) = Auth::get_user_id();
|
| 729 |
+
</code></pre>
|
| 730 |
+
</td>
|
| 731 |
+
</tr>
|
| 732 |
+
</tbody>
|
| 733 |
+
</table>
|
| 734 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the user id of the guest user.</p>
|
| 735 |
+
</article>
|
| 736 |
+
|
| 737 |
+
<article>
|
| 738 |
+
<h4 id="method_get_groups" class="method">get_groups()</h4>
|
| 739 |
+
<p>The <strong>get_groups</strong> method returns the user groups assigned to the currently logged-in user.</p>
|
| 740 |
+
<table class="method">
|
| 741 |
+
<tbody>
|
| 742 |
+
<tr>
|
| 743 |
+
<th class="legend">Static</th>
|
| 744 |
+
<td>Yes</td>
|
| 745 |
+
</tr>
|
| 746 |
+
<tr>
|
| 747 |
+
<th>Parameters</th>
|
| 748 |
+
<td>
|
| 749 |
+
None
|
| 750 |
+
</td>
|
| 751 |
+
</tr>
|
| 752 |
+
<tr>
|
| 753 |
+
<th>Returns</th>
|
| 754 |
+
<td>mixed. returns an array in the form <strong>array(array(driver, group_id))</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 755 |
+
</tr>
|
| 756 |
+
<th>Example</th>
|
| 757 |
+
<td>
|
| 758 |
+
<pre class="php"><code>// get all group id information
|
| 759 |
+
$id_info = Auth::get_groups();
|
| 760 |
+
|
| 761 |
+
// print driver and id info
|
| 762 |
+
if ($id_info)
|
| 763 |
+
{
|
| 764 |
+
foreach ($id_info as $info)
|
| 765 |
+
{
|
| 766 |
+
echo 'Driver: ',$info[0],' with group ID ',$info[1],'<br />';
|
| 767 |
+
}
|
| 768 |
+
}
|
| 769 |
+
else
|
| 770 |
+
{
|
| 771 |
+
echo 'Nobody is logged in!';
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
// if you only use one driver, you can also do
|
| 775 |
+
list($driver, $groupid) = Auth::get_groups();
|
| 776 |
+
</code></pre>
|
| 777 |
+
</td>
|
| 778 |
+
</tr>
|
| 779 |
+
</tbody>
|
| 780 |
+
</table>
|
| 781 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the group information of the guest user.</p>
|
| 782 |
+
</article>
|
| 783 |
+
|
| 784 |
+
<article>
|
| 785 |
+
<h4 id="method_get_email" class="method">get_email()</h4>
|
| 786 |
+
<p>The <strong>get_email</strong> method returns the email address assigned to the currently logged-in user.</p>
|
| 787 |
+
<table class="method">
|
| 788 |
+
<tbody>
|
| 789 |
+
<tr>
|
| 790 |
+
<th class="legend">Static</th>
|
| 791 |
+
<td>Yes</td>
|
| 792 |
+
</tr>
|
| 793 |
+
<tr>
|
| 794 |
+
<th>Parameters</th>
|
| 795 |
+
<td>
|
| 796 |
+
None
|
| 797 |
+
</td>
|
| 798 |
+
</tr>
|
| 799 |
+
<tr>
|
| 800 |
+
<th>Returns</th>
|
| 801 |
+
<td>mixed. returns an email address if a user is logged in, or <strong>false</strong> if there is no user logged-in.</td>
|
| 802 |
+
</tr>
|
| 803 |
+
<tr>
|
| 804 |
+
<th>Example</th>
|
| 805 |
+
<td>
|
| 806 |
+
<pre class="php"><code>// get the current users email address
|
| 807 |
+
$email = Auth::get_email();
|
| 808 |
+
|
| 809 |
+
// note that there is a difference between false and empty:
|
| 810 |
+
if ($email === false)
|
| 811 |
+
{
|
| 812 |
+
// nobody logged in
|
| 813 |
+
}
|
| 814 |
+
if (empty($email))
|
| 815 |
+
{
|
| 816 |
+
// a user is logged in, but doesn't have an email address
|
| 817 |
+
}
|
| 818 |
+
</code></pre>
|
| 819 |
+
</td>
|
| 820 |
+
</tr>
|
| 821 |
+
</tbody>
|
| 822 |
+
</table>
|
| 823 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the email address of the guest user.</p>
|
| 824 |
+
</article>
|
| 825 |
+
|
| 826 |
+
<article>
|
| 827 |
+
<h4 id="method_get_screen_name" class="method">get_screen_name()</h4>
|
| 828 |
+
<p>The <strong>get_screen_name</strong> method returns the screen- or display name of the currently logged-in user.</p>
|
| 829 |
+
<table class="method">
|
| 830 |
+
<tbody>
|
| 831 |
+
<tr>
|
| 832 |
+
<th class="legend">Static</th>
|
| 833 |
+
<td>Yes</td>
|
| 834 |
+
</tr>
|
| 835 |
+
<tr>
|
| 836 |
+
<th>Parameters</th>
|
| 837 |
+
<td>
|
| 838 |
+
None
|
| 839 |
+
</td>
|
| 840 |
+
</tr>
|
| 841 |
+
<tr>
|
| 842 |
+
<th>Returns</th>
|
| 843 |
+
<td>mixed. returns a string containing the name, or <strong>false</strong> if there is no user logged-in.</td>
|
| 844 |
+
</tr>
|
| 845 |
+
<tr>
|
| 846 |
+
<th>Example</th>
|
| 847 |
+
<td>
|
| 848 |
+
<pre class="php"><code>// get the current users screen name
|
| 849 |
+
$name = Auth::get_screen_name();
|
| 850 |
+
|
| 851 |
+
// name is required, so if not present it means nobody is logged in
|
| 852 |
+
if (empty($name))
|
| 853 |
+
{
|
| 854 |
+
// nobody logged in
|
| 855 |
+
}
|
| 856 |
+
</code></pre>
|
| 857 |
+
</td>
|
| 858 |
+
</tr>
|
| 859 |
+
</tbody>
|
| 860 |
+
</table>
|
| 861 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the user name of the guest user.</p>
|
| 862 |
+
</article>
|
| 863 |
+
|
| 864 |
+
<article>
|
| 865 |
+
<h4 id="method_get_profile_fields" class="method">get_profile_fields($field = null, $default = null)</h4>
|
| 866 |
+
<p>The <strong>get_profile_fields</strong> method returns one or all stored profile fields for the logged-in user.</p>
|
| 867 |
+
<table class="method">
|
| 868 |
+
<tbody>
|
| 869 |
+
<tr>
|
| 870 |
+
<th class="legend">Static</th>
|
| 871 |
+
<td>Yes</td>
|
| 872 |
+
</tr>
|
| 873 |
+
<tr>
|
| 874 |
+
<th>Parameters</th>
|
| 875 |
+
<td>
|
| 876 |
+
<table class="parameters">
|
| 877 |
+
<tr>
|
| 878 |
+
<th>Param</th>
|
| 879 |
+
<th>Default</th>
|
| 880 |
+
<th class="description">Description</th>
|
| 881 |
+
</tr>
|
| 882 |
+
<tr>
|
| 883 |
+
<th><kbd>$field</kbd></th>
|
| 884 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 885 |
+
<td>The name of the profile field you want to get.</td>
|
| 886 |
+
</tr>
|
| 887 |
+
<tr>
|
| 888 |
+
<th><kbd>$default</kbd></th>
|
| 889 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 890 |
+
<td>The value you want returned if the requested profile field does not exist.</td>
|
| 891 |
+
</tr>
|
| 892 |
+
</table>
|
| 893 |
+
</td>
|
| 894 |
+
</tr>
|
| 895 |
+
<tr>
|
| 896 |
+
<th>Returns</th>
|
| 897 |
+
<td>mixed</td>
|
| 898 |
+
</tr>
|
| 899 |
+
<tr>
|
| 900 |
+
<th>Example</th>
|
| 901 |
+
<td>
|
| 902 |
+
<pre class="php"><code>// get all profile fields defined
|
| 903 |
+
$profile = Auth::get_profile_fields();
|
| 904 |
+
|
| 905 |
+
// get a specific profile fields defined
|
| 906 |
+
$fullname = Auth::get_profile_fields('fullname', 'Unknown');
|
| 907 |
+
|
| 908 |
+
// will return null, as username is not part of the metadata
|
| 909 |
+
$fullname = Auth::get_profile_fields('username', 'Unknown username');
|
| 910 |
+
</code></pre>
|
| 911 |
+
</td>
|
| 912 |
+
</tr>
|
| 913 |
+
</tbody>
|
| 914 |
+
</table>
|
| 915 |
+
</article>
|
| 916 |
+
|
| 917 |
+
<article>
|
| 918 |
+
<h4 id="method_member" class="method">member($group, $user = null)</h4>
|
| 919 |
+
<p>The <strong>member</strong> method allows you to check if a user is member of a given group.</p>
|
| 920 |
+
<table class="method">
|
| 921 |
+
<tbody>
|
| 922 |
+
<tr>
|
| 923 |
+
<th class="legend">Static</th>
|
| 924 |
+
<td>Yes</td>
|
| 925 |
+
</tr>
|
| 926 |
+
<tr>
|
| 927 |
+
<th>Parameters</th>
|
| 928 |
+
<td>
|
| 929 |
+
<table class="parameters">
|
| 930 |
+
<tr>
|
| 931 |
+
<th>Param</th>
|
| 932 |
+
<th>Default</th>
|
| 933 |
+
<th class="description">Description</th>
|
| 934 |
+
</tr>
|
| 935 |
+
<tr>
|
| 936 |
+
<th><kbd>$group</kbd></th>
|
| 937 |
+
<td>required</td>
|
| 938 |
+
<td>The id of the group you want to check for membership, or a valid \Model\Auth_Group instance.</td>
|
| 939 |
+
</tr>
|
| 940 |
+
<tr>
|
| 941 |
+
<th><kbd>$user</kbd></th>
|
| 942 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 943 |
+
<td>A specific user, identified by the result of get_user_id(), or <strong>null</strong> for the currently logged-in user.</td>
|
| 944 |
+
</tr>
|
| 945 |
+
</table>
|
| 946 |
+
</td>
|
| 947 |
+
</tr>
|
| 948 |
+
<tr>
|
| 949 |
+
<th>Returns</th>
|
| 950 |
+
<td>boolean. <strong>true</strong> if the user is member of the group, or <strong>false</strong> if not.</td>
|
| 951 |
+
</tr>
|
| 952 |
+
<tr>
|
| 953 |
+
<th>Example</th>
|
| 954 |
+
<td>
|
| 955 |
+
<pre class="php"><code>// Check if the current user is an administrator
|
| 956 |
+
if (Auth::member(100))
|
| 957 |
+
{
|
| 958 |
+
// we are in the administrator group!
|
| 959 |
+
}
|
| 960 |
+
|
| 961 |
+
// Check if the current user is an administrator
|
| 962 |
+
$group = \Model\Auth_Group::find(100);
|
| 963 |
+
if (Auth::member($group))
|
| 964 |
+
{
|
| 965 |
+
// we are in the administrator group!
|
| 966 |
+
}
|
| 967 |
+
</code></pre>
|
| 968 |
+
</td>
|
| 969 |
+
</tr>
|
| 970 |
+
</tbody>
|
| 971 |
+
</table>
|
| 972 |
+
</article>
|
| 973 |
+
|
| 974 |
+
<article>
|
| 975 |
+
<h4 id="method_groups" class="method">groups($driver = null)</h4>
|
| 976 |
+
<p>The <strong>groups</strong> method allows you to fetch all defined groups, or all defined groups in a specific driver.</p>
|
| 977 |
+
<table class="method">
|
| 978 |
+
<tbody>
|
| 979 |
+
<tr>
|
| 980 |
+
<th class="legend">Static</th>
|
| 981 |
+
<td>Yes</td>
|
| 982 |
+
</tr>
|
| 983 |
+
<tr>
|
| 984 |
+
<th>Parameters</th>
|
| 985 |
+
<td>
|
| 986 |
+
<table class="parameters">
|
| 987 |
+
<tr>
|
| 988 |
+
<th>Param</th>
|
| 989 |
+
<th>Default</th>
|
| 990 |
+
<th class="description">Description</th>
|
| 991 |
+
</tr>
|
| 992 |
+
<tr>
|
| 993 |
+
<th><kbd>$driver</kbd></th>
|
| 994 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 995 |
+
<td>The name of the group driver you want to get groups of</td>
|
| 996 |
+
</tr>
|
| 997 |
+
</table>
|
| 998 |
+
</td>
|
| 999 |
+
</tr>
|
| 1000 |
+
<tr>
|
| 1001 |
+
<th>Returns</th>
|
| 1002 |
+
<td>array of \Model\Auth_Group objects. If the group driver does not exist or no groups are defined, an empty array is returned.</td>
|
| 1003 |
+
</tr>
|
| 1004 |
+
<tr>
|
| 1005 |
+
<th>Example</th>
|
| 1006 |
+
<td>
|
| 1007 |
+
<pre class="php"><code>// Get all defined groups (for all loaded group drivers)
|
| 1008 |
+
$groups = Auth::groups();
|
| 1009 |
+
|
| 1010 |
+
// Get all the groups from the default group driver
|
| 1011 |
+
$groups = Auth::group()->groups();
|
| 1012 |
+
|
| 1013 |
+
// Get all the groups from a specific driver
|
| 1014 |
+
$groups = Auth::group('Ormgroup')->groups();
|
| 1015 |
+
</code></pre>
|
| 1016 |
+
</td>
|
| 1017 |
+
</tr>
|
| 1018 |
+
</tbody>
|
| 1019 |
+
</table>
|
| 1020 |
+
<p class="note">You need to call this method on the Auth group drivers instance if you want groups defined by a specific driver.</p>
|
| 1021 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the group id's are unique over <strong>all</strong> drivers!</p>
|
| 1022 |
+
</article>
|
| 1023 |
+
|
| 1024 |
+
<article>
|
| 1025 |
+
<h4 id="method_roles" class="method">roles($driver = null)</h4>
|
| 1026 |
+
<p>The <strong>roles</strong> method allows you to fetch all defined roles, or all defined roles in a specific driver.</p>
|
| 1027 |
+
<table class="method">
|
| 1028 |
+
<tbody>
|
| 1029 |
+
<tr>
|
| 1030 |
+
<th class="legend">Static</th>
|
| 1031 |
+
<td>Yes</td>
|
| 1032 |
+
</tr>
|
| 1033 |
+
<tr>
|
| 1034 |
+
<th>Parameters</th>
|
| 1035 |
+
<td>
|
| 1036 |
+
<table class="parameters">
|
| 1037 |
+
<tr>
|
| 1038 |
+
<th>Param</th>
|
| 1039 |
+
<th>Default</th>
|
| 1040 |
+
<th class="description">Description</th>
|
| 1041 |
+
</tr>
|
| 1042 |
+
<tr>
|
| 1043 |
+
<th><kbd>$driver</kbd></th>
|
| 1044 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1045 |
+
<td>The name of the group driver you want to get roles of</td>
|
| 1046 |
+
</tr>
|
| 1047 |
+
</table>
|
| 1048 |
+
</td>
|
| 1049 |
+
</tr>
|
| 1050 |
+
<tr>
|
| 1051 |
+
<th>Returns</th>
|
| 1052 |
+
<td>array or \Model\Auth_Roles objects. If the acl driver does not exist or no roles are defined, an empty array is returned.</td>
|
| 1053 |
+
</tr>
|
| 1054 |
+
<tr>
|
| 1055 |
+
<th>Example</th>
|
| 1056 |
+
<td>
|
| 1057 |
+
<pre class="php"><code>// Get all defined roles (for all loaded acl drivers)
|
| 1058 |
+
$roles = Auth::roles();
|
| 1059 |
+
|
| 1060 |
+
// Get all the roles from the default acl driver
|
| 1061 |
+
$roles = Auth::acl()->roles();
|
| 1062 |
+
|
| 1063 |
+
// Get all the roles from a specific driver
|
| 1064 |
+
$roles = Auth::acl('Ormacl')->roles();
|
| 1065 |
+
</code></pre>
|
| 1066 |
+
</td>
|
| 1067 |
+
</tr>
|
| 1068 |
+
</tbody>
|
| 1069 |
+
</table>
|
| 1070 |
+
<p class="note">You need to call this method on the Auth acl drivers instance if you want groups defined by a specific driver.</p>
|
| 1071 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the role id's are unique over <strong>all</strong> drivers!</p>
|
| 1072 |
+
</article>
|
| 1073 |
+
|
| 1074 |
+
<article>
|
| 1075 |
+
<h4 id="method_get_name" class="method">get_name($group = null)</h4>
|
| 1076 |
+
<p>The <strong>get_name</strong> method allows you to fetch the name of a specific group. If no group is given, it will return the name
|
| 1077 |
+
of the group of the current logged-in user.</p>
|
| 1078 |
+
<table class="method">
|
| 1079 |
+
<tbody>
|
| 1080 |
+
<tr>
|
| 1081 |
+
<th class="legend">Static</th>
|
| 1082 |
+
<td>No</td>
|
| 1083 |
+
</tr>
|
| 1084 |
+
<tr>
|
| 1085 |
+
<th>Parameters</th>
|
| 1086 |
+
<td>
|
| 1087 |
+
<table class="parameters">
|
| 1088 |
+
<tr>
|
| 1089 |
+
<th>Param</th>
|
| 1090 |
+
<th>Default</th>
|
| 1091 |
+
<th class="description">Description</th>
|
| 1092 |
+
</tr>
|
| 1093 |
+
<tr>
|
| 1094 |
+
<th><kbd>$group</kbd></th>
|
| 1095 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1096 |
+
<td>The id of the group you want to get the name of</td>
|
| 1097 |
+
</tr>
|
| 1098 |
+
</table>
|
| 1099 |
+
</td>
|
| 1100 |
+
</tr>
|
| 1101 |
+
<tr>
|
| 1102 |
+
<th>Returns</th>
|
| 1103 |
+
<td>mixed. The name of the group, or <kbd>null</kbd> if a group with the given id does not exist.</td>
|
| 1104 |
+
</tr>
|
| 1105 |
+
<tr>
|
| 1106 |
+
<th>Example</th>
|
| 1107 |
+
<td>
|
| 1108 |
+
<pre class="php"><code>// Get all the name for the group of the current logged-in user
|
| 1109 |
+
$name = Auth::group()->get_name();
|
| 1110 |
+
|
| 1111 |
+
// Get the name of a specific group from a specific driver
|
| 1112 |
+
$name = Auth::group('Ormgroup')->get_name(100); // returns 'Administrators'
|
| 1113 |
+
</code></pre>
|
| 1114 |
+
</td>
|
| 1115 |
+
</tr>
|
| 1116 |
+
</tbody>
|
| 1117 |
+
</table>
|
| 1118 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the group id's are unique over <strong>all</strong> drivers!</p>
|
| 1119 |
+
</article>
|
| 1120 |
+
|
| 1121 |
+
<article>
|
| 1122 |
+
<h4 id="method_has_access" class="method">has_access($condition)</h4>
|
| 1123 |
+
<p>The <strong>has_access</strong> method allows you to check if the current logged-in user has access to a specific location with specific rights.</p>
|
| 1124 |
+
<table class="method">
|
| 1125 |
+
<tbody>
|
| 1126 |
+
<tr>
|
| 1127 |
+
<th class="legend">Static</th>
|
| 1128 |
+
<td>Yes</td>
|
| 1129 |
+
</tr>
|
| 1130 |
+
<tr>
|
| 1131 |
+
<th>Parameters</th>
|
| 1132 |
+
<td>
|
| 1133 |
+
<table class="parameters">
|
| 1134 |
+
<tr>
|
| 1135 |
+
<th>Param</th>
|
| 1136 |
+
<th>Default</th>
|
| 1137 |
+
<th class="description">Description</th>
|
| 1138 |
+
</tr>
|
| 1139 |
+
<tr>
|
| 1140 |
+
<th><kbd>$condition</kbd></th>
|
| 1141 |
+
<td>required</td>
|
| 1142 |
+
<td>The access condition you want to check</td>
|
| 1143 |
+
</tr>
|
| 1144 |
+
</table>
|
| 1145 |
+
</td>
|
| 1146 |
+
</tr>
|
| 1147 |
+
<tr>
|
| 1148 |
+
<th>Returns</th>
|
| 1149 |
+
<td>boolean. <strong>true</strong> if the user has access, or <strong>false</strong> if not.</td>
|
| 1150 |
+
</tr>
|
| 1151 |
+
<tr>
|
| 1152 |
+
<th>Example</th>
|
| 1153 |
+
<td>
|
| 1154 |
+
<pre class="php"><code>// check if the user has access to read blog posts
|
| 1155 |
+
if (Auth::has_access('blog.comments'))
|
| 1156 |
+
{
|
| 1157 |
+
// yes, the user has access
|
| 1158 |
+
}
|
| 1159 |
+
|
| 1160 |
+
// if you have multiple login instances, use the instance to call this method.
|
| 1161 |
+
// you can also check for multiple permissions in one go
|
| 1162 |
+
if (Auth::instance('Ormauth')->has_access('blog.[posts,comments]'))
|
| 1163 |
+
{
|
| 1164 |
+
// yes, the user has access to both blog posts and blog comments
|
| 1165 |
+
}
|
| 1166 |
+
|
| 1167 |
+
// you can also specify the permissions to check as an array
|
| 1168 |
+
if (Auth::has_access(array('blog' => array('post'), 'comments' => array('post')))
|
| 1169 |
+
{
|
| 1170 |
+
// yes, the user has access to read both blogs and comments posts
|
| 1171 |
+
}
|
| 1172 |
+
|
| 1173 |
+
// if you have multiple login instances, you can also pick a specific ACL driver
|
| 1174 |
+
if (Auth::acl('Ormacl')->has_access('blog.[posts,comments]'))
|
| 1175 |
+
{
|
| 1176 |
+
// yes, the user has access to both blog posts and blog comments
|
| 1177 |
+
}
|
| 1178 |
+
|
| 1179 |
+
// you can get more fine-grained permissions by using permission actions.
|
| 1180 |
+
if (Auth::has_access('blog.comments[read,create,update,delete]'))
|
| 1181 |
+
{
|
| 1182 |
+
// yes, the user has all access to blog comments
|
| 1183 |
+
}
|
| 1184 |
+
</code></pre>
|
| 1185 |
+
</td>
|
| 1186 |
+
</tr>
|
| 1187 |
+
</tbody>
|
| 1188 |
+
</table>
|
| 1189 |
+
</article>
|
| 1190 |
+
|
| 1191 |
+
<article>
|
| 1192 |
+
<h4 id="method_guest_login" class="method">guest_login()</h4>
|
| 1193 |
+
<p>The <strong>guest_login</strong> method allows you to check if guest access is enabled.</p>
|
| 1194 |
+
<table class="method">
|
| 1195 |
+
<tbody>
|
| 1196 |
+
<tr>
|
| 1197 |
+
<th class="legend">Static</th>
|
| 1198 |
+
<td>Yes</td>
|
| 1199 |
+
</tr>
|
| 1200 |
+
<tr>
|
| 1201 |
+
<th>Parameters</th>
|
| 1202 |
+
<td>
|
| 1203 |
+
None
|
| 1204 |
+
</td>
|
| 1205 |
+
</tr>
|
| 1206 |
+
<tr>
|
| 1207 |
+
<th>Returns</th>
|
| 1208 |
+
<td>boolean. returns <strong>true</strong> if the guest support is enabled, or <strong>false</strong> if not.</td>
|
| 1209 |
+
</tr>
|
| 1210 |
+
<tr>
|
| 1211 |
+
<th>Example</th>
|
| 1212 |
+
<td>
|
| 1213 |
+
<pre class="php"><code>// redirect to login if we we require a user and no guest access is enabled
|
| 1214 |
+
if ( ! Auth::check() and ! Auth::guest_login())
|
| 1215 |
+
{
|
| 1216 |
+
Response::redirect('/login');
|
| 1217 |
+
}
|
| 1218 |
+
</code></pre>
|
| 1219 |
+
</td>
|
| 1220 |
+
</tr>
|
| 1221 |
+
</tbody>
|
| 1222 |
+
</table>
|
| 1223 |
+
</article>
|
| 1224 |
+
|
| 1225 |
+
<article>
|
| 1226 |
+
<h4 id="method_remember_me" class="method">remember_me($user_id = null)</h4>
|
| 1227 |
+
<p>The <strong>remember_me</strong> method allows you to set a remember_me cookie. If $user_id is not given, the current logged-in user is used.</p>
|
| 1228 |
+
<table class="method">
|
| 1229 |
+
<tbody>
|
| 1230 |
+
<tr>
|
| 1231 |
+
<th class="legend">Static</th>
|
| 1232 |
+
<td>Yes</td>
|
| 1233 |
+
</tr>
|
| 1234 |
+
<tr>
|
| 1235 |
+
<th>Parameters</th>
|
| 1236 |
+
<td>
|
| 1237 |
+
<table class="parameters">
|
| 1238 |
+
<tr>
|
| 1239 |
+
<th>Param</th>
|
| 1240 |
+
<th>Default</th>
|
| 1241 |
+
<th class="description">Description</th>
|
| 1242 |
+
</tr>
|
| 1243 |
+
<tr>
|
| 1244 |
+
<th><kbd>$user_id</kbd></th>
|
| 1245 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1246 |
+
<td>The id of the user to be remembered</td>
|
| 1247 |
+
</tr>
|
| 1248 |
+
</table>
|
| 1249 |
+
</td>
|
| 1250 |
+
</tr>
|
| 1251 |
+
<tr>
|
| 1252 |
+
<th>Returns</th>
|
| 1253 |
+
<td>
|
| 1254 |
+
boolean. returns <strong>true</strong> if the remember me cookie was correctly set, or <strong>false</strong>
|
| 1255 |
+
if there was no user_id present, or the remember_me functionality was disabled in the configuration.
|
| 1256 |
+
</td>
|
| 1257 |
+
</tr>
|
| 1258 |
+
<tr>
|
| 1259 |
+
<th>Example</th>
|
| 1260 |
+
<td>
|
| 1261 |
+
<pre class="php"><code>// process the login form POST, and set the remember-me cookie if needed
|
| 1262 |
+
if (\Input::method() == 'POST')
|
| 1263 |
+
{
|
| 1264 |
+
// check the credentials.
|
| 1265 |
+
if (\Auth::instance()->login(\Input::param('username'), \Input::param('password')))
|
| 1266 |
+
{
|
| 1267 |
+
// does the user want to be remembered?
|
| 1268 |
+
if (\Input::param('rememberme', false))
|
| 1269 |
+
{
|
| 1270 |
+
// create the remember-me cookie
|
| 1271 |
+
\Auth::remember_me();
|
| 1272 |
+
}
|
| 1273 |
+
else
|
| 1274 |
+
{
|
| 1275 |
+
// delete the remember-me cookie if present
|
| 1276 |
+
\Auth::dont_remember_me();
|
| 1277 |
+
}
|
| 1278 |
+
|
| 1279 |
+
// logged in, go the homepage
|
| 1280 |
+
\Response::redirect('/');
|
| 1281 |
+
}
|
| 1282 |
+
else
|
| 1283 |
+
{
|
| 1284 |
+
// login failed, show an error message
|
| 1285 |
+
$data['username'] = \Input::param('username');
|
| 1286 |
+
$data['login_error'] = \Lang::get('login.failure');
|
| 1287 |
+
}
|
| 1288 |
+
}
|
| 1289 |
+
</code></pre>
|
| 1290 |
+
</td>
|
| 1291 |
+
</tr>
|
| 1292 |
+
</tbody>
|
| 1293 |
+
</table>
|
| 1294 |
+
</article>
|
| 1295 |
+
|
| 1296 |
+
<article>
|
| 1297 |
+
<h4 id="method_dont_remember_me" class="method">dont_remember_me()</h4>
|
| 1298 |
+
<p>The <strong>dont_remember_me</strong> method destroys the remember_me cookie, if present.</p>
|
| 1299 |
+
<table class="method">
|
| 1300 |
+
<tbody>
|
| 1301 |
+
<tr>
|
| 1302 |
+
<th class="legend">Static</th>
|
| 1303 |
+
<td>Yes</td>
|
| 1304 |
+
</tr>
|
| 1305 |
+
<tr>
|
| 1306 |
+
<th>Parameters</th>
|
| 1307 |
+
<td>
|
| 1308 |
+
None
|
| 1309 |
+
</td>
|
| 1310 |
+
</tr>
|
| 1311 |
+
<tr>
|
| 1312 |
+
<th>Example</th>
|
| 1313 |
+
<td>
|
| 1314 |
+
See <a href="#method_remember_me">remember_me()</a> for an example
|
| 1315 |
+
</td>
|
| 1316 |
+
</tr>
|
| 1317 |
+
</tbody>
|
| 1318 |
+
</table>
|
| 1319 |
+
</article>
|
| 1320 |
+
</div>
|
| 1321 |
+
|
| 1322 |
+
<footer>
|
| 1323 |
+
<p>
|
| 1324 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 1325 |
+
</p>
|
| 1326 |
+
</footer>
|
| 1327 |
+
</div>
|
| 1328 |
+
</body>
|
| 1329 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/simpleauth/intro.html
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
</script>
|
| 12 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 13 |
+
<title>Introduction - SimpleAuth - Auth Package - FuelPHP Documentation</title>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<div id="container">
|
| 17 |
+
<header id="header">
|
| 18 |
+
<div class="table">
|
| 19 |
+
<h1>
|
| 20 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 21 |
+
Documentation
|
| 22 |
+
</h1>
|
| 23 |
+
|
| 24 |
+
<form id="google_search">
|
| 25 |
+
<p>
|
| 26 |
+
<span id="search_clear"> </span>
|
| 27 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 28 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 29 |
+
</p>
|
| 30 |
+
</form>
|
| 31 |
+
</div>
|
| 32 |
+
<nav>
|
| 33 |
+
|
| 34 |
+
<div class="clear"></div>
|
| 35 |
+
</nav>
|
| 36 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 37 |
+
<div class="clear"></div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div id="cse">
|
| 41 |
+
<div id="cse_point"></div>
|
| 42 |
+
<div id="cse_content"></div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div id="main">
|
| 46 |
+
<h2>SimpleAuth - Introduction</h2>
|
| 47 |
+
|
| 48 |
+
<p>
|
| 49 |
+
Simpleauth is, as it's name implies, a simple authentication system which is included in the Auth package.
|
| 50 |
+
Besides being a working Auth implementation, it is also an example for other Auth drivers.
|
| 51 |
+
You can use this as a reference when building your own driver.
|
| 52 |
+
</p>
|
| 53 |
+
|
| 54 |
+
<h3 id="setup">Auth setup</h3>
|
| 55 |
+
|
| 56 |
+
<p>
|
| 57 |
+
Configuration starts with telling the Auth package that you are going to use the Simpleauth driver.
|
| 58 |
+
This is done through the auth.php configuration file. A default file is provided in the Auth package.
|
| 59 |
+
You should copy this file to your app/config folder before making any changes. The default file is already
|
| 60 |
+
configured for the Simpleauth package. You will find an explaination of this config file <a href="../intro.html#/configuration">here</a>.
|
| 61 |
+
</p>
|
| 62 |
+
<p>
|
| 63 |
+
After you have done this, you can choose to autoload the package through the <strong>always_load</strong> section of the app/config/config.php.
|
| 64 |
+
</p>
|
| 65 |
+
|
| 66 |
+
<h3 id="acl">ACL's</h3>
|
| 67 |
+
|
| 68 |
+
<p>
|
| 69 |
+
SimpleAuth comes with an ACL driver that supports the following ACL structure:
|
| 70 |
+
</p>
|
| 71 |
+
|
| 72 |
+
<ul>
|
| 73 |
+
<li>Every user is a member of one, and exactly one, group</li>
|
| 74 |
+
<li>Every group has zero or more roles assigned to it</li>
|
| 75 |
+
<li>Every role can have zero or more rights assigned to it</li>
|
| 76 |
+
</ul>
|
| 77 |
+
|
| 78 |
+
<p>
|
| 79 |
+
When checking for access, you specify the required access as either <code>role.right</code> (when you want to check for
|
| 80 |
+
a single right, or <code>role.[right,right]</code> when you want to check for multiple rights at once. This is an AND check,
|
| 81 |
+
so when you specify multiple rights, the user must have ALL of them assigned to be granted access.
|
| 82 |
+
</p>
|
| 83 |
+
|
| 84 |
+
<h3 id="configuration">Configuration</h3>
|
| 85 |
+
|
| 86 |
+
<p>
|
| 87 |
+
The Simpleauth authentication system is configured through a configuration file, not suprisingly called
|
| 88 |
+
'simpleauth.php'. A default file is provided in the Auth package. You should copy this file
|
| 89 |
+
to your app/config folder before making any changes.
|
| 90 |
+
</p>
|
| 91 |
+
|
| 92 |
+
<p>The following configuration values can be defined:</p>
|
| 93 |
+
<table class="config">
|
| 94 |
+
<tbody>
|
| 95 |
+
<tr class="header">
|
| 96 |
+
<th>Param</th>
|
| 97 |
+
<th>Type</th>
|
| 98 |
+
<th>Default</th>
|
| 99 |
+
<th>Description</th>
|
| 100 |
+
</tr>
|
| 101 |
+
<tr>
|
| 102 |
+
<th>db_connection</th>
|
| 103 |
+
<td>string</td>
|
| 104 |
+
<td><pre class="php"><code>null</code></pre>
|
| 105 |
+
</td>
|
| 106 |
+
<td>
|
| 107 |
+
Name of the database connection to use. This should match the definition in your applications db.php configuration file.
|
| 108 |
+
Set it to <strong>null</strong> to use the default DB instance.
|
| 109 |
+
</td>
|
| 110 |
+
</tr>
|
| 111 |
+
<tr>
|
| 112 |
+
<th>table_name</th>
|
| 113 |
+
<td>string</td>
|
| 114 |
+
<td><pre class="php"><code>'users'</code></pre>
|
| 115 |
+
</td>
|
| 116 |
+
<td>
|
| 117 |
+
Name of the users table to use.
|
| 118 |
+
</td>
|
| 119 |
+
</tr>
|
| 120 |
+
<tr>
|
| 121 |
+
<th>table_columns</th>
|
| 122 |
+
<td>array</td>
|
| 123 |
+
<td><pre class="php"><code>array('*')</code></pre>
|
| 124 |
+
</td>
|
| 125 |
+
<td>
|
| 126 |
+
List of columns to select from the users table, or '*' to select all columns. You have to at least include
|
| 127 |
+
'username', 'password', 'email', 'last_login', 'login_hash', 'group' and 'profile_fields'.
|
| 128 |
+
</td>
|
| 129 |
+
</tr>
|
| 130 |
+
<tr>
|
| 131 |
+
<th>guest_login</th>
|
| 132 |
+
<td>boolean</td>
|
| 133 |
+
<td><pre class="php"><code>true</code></pre>
|
| 134 |
+
</td>
|
| 135 |
+
<td>
|
| 136 |
+
If true a dummy 'guest' user will be created if no one is logged in. This allows you to use the group and
|
| 137 |
+
acl drivers even when no one is logged in.
|
| 138 |
+
</td>
|
| 139 |
+
</tr>
|
| 140 |
+
<tr>
|
| 141 |
+
<th>remember_me</th>
|
| 142 |
+
<td>array</td>
|
| 143 |
+
<td><pre class="php"><code>array(
|
| 144 |
+
'enabled' => false,
|
| 145 |
+
'cookie_name' => 'rmcookie',
|
| 146 |
+
'expiration' => 86400*31
|
| 147 |
+
)</code></pre>
|
| 148 |
+
</td>
|
| 149 |
+
<td>
|
| 150 |
+
Configuration for the Simpleauth 'remember_me' functionality
|
| 151 |
+
</td>
|
| 152 |
+
</tr>
|
| 153 |
+
<tr>
|
| 154 |
+
<th>multiple_logins</th>
|
| 155 |
+
<td>boolean</td>
|
| 156 |
+
<td><pre class="php"><code>false</code></pre>
|
| 157 |
+
</td>
|
| 158 |
+
<td>
|
| 159 |
+
If true multiple concurrent logins of the same user are allowed. If false, when a user logs in, any previous login will be
|
| 160 |
+
cancelled. Note that enabling this will disable some login session hijacking measures!
|
| 161 |
+
</td>
|
| 162 |
+
</tr>
|
| 163 |
+
<tr>
|
| 164 |
+
<th>groups</th>
|
| 165 |
+
<td>array</td>
|
| 166 |
+
<td><pre class="php"><code>array()</code></pre>
|
| 167 |
+
</td>
|
| 168 |
+
<td>
|
| 169 |
+
Defined groups, to be used by the SimpleAuth groups driver. See the default configuration file for an
|
| 170 |
+
description of the groups array structure.
|
| 171 |
+
</td>
|
| 172 |
+
</tr>
|
| 173 |
+
<tr>
|
| 174 |
+
<th>roles</th>
|
| 175 |
+
<td>array</td>
|
| 176 |
+
<td><pre class="php"><code>array()</code></pre>
|
| 177 |
+
</td>
|
| 178 |
+
<td>
|
| 179 |
+
Defined roles, to be used by the SimpleAuth acl driver. See the default configuration file for an
|
| 180 |
+
description of the roles array structure.
|
| 181 |
+
</td>
|
| 182 |
+
</tr>
|
| 183 |
+
<tr>
|
| 184 |
+
<th>login_hash_salt</th>
|
| 185 |
+
<td>string</td>
|
| 186 |
+
<td><pre class="php"><code>'put_some_salt_in_here'</code></pre>
|
| 187 |
+
</td>
|
| 188 |
+
<td>
|
| 189 |
+
To make the passwords used by the SimpleAuth drivers extra secure, a salt value is used when hashing
|
| 190 |
+
the passwords to store them into the database. Make sure you change this default to a very random string!
|
| 191 |
+
To hash passwords, SimpleAuth uses <a href="http://en.wikipedia.org/wiki/PBKDF2" target="_blank">PBKDF2</a>, a very secure hashing mechanism.
|
| 192 |
+
</td>
|
| 193 |
+
</tr>
|
| 194 |
+
<tr>
|
| 195 |
+
<th>username_post_key</th>
|
| 196 |
+
<td>string</td>
|
| 197 |
+
<td><pre class="php"><code>'username'</code></pre>
|
| 198 |
+
</td>
|
| 199 |
+
<td>
|
| 200 |
+
Name of the input field on the login form that contains the username.
|
| 201 |
+
</td>
|
| 202 |
+
</tr>
|
| 203 |
+
<tr>
|
| 204 |
+
<th>password_post_key</th>
|
| 205 |
+
<td>string</td>
|
| 206 |
+
<td><pre class="php"><code>'password'</code></pre>
|
| 207 |
+
</td>
|
| 208 |
+
<td>
|
| 209 |
+
Name of the input field on the login form that contains the password.
|
| 210 |
+
</td>
|
| 211 |
+
</tr>
|
| 212 |
+
</tbody>
|
| 213 |
+
</table>
|
| 214 |
+
|
| 215 |
+
<p class="note">
|
| 216 |
+
If you want to use the 'remember-me' functionality, make sure you have a valid <a href="../../../classes/crypt.html">Crypt</a> configuration, as it
|
| 217 |
+
uses an encrypted cookie to store the user information to be remembered.
|
| 218 |
+
</p>
|
| 219 |
+
|
| 220 |
+
<h3 id="database">Database table</h3>
|
| 221 |
+
|
| 222 |
+
<p>
|
| 223 |
+
SimpleAuth relies on a single table. The Auth package contains the required migration files to create this table.<br />
|
| 224 |
+
Just run <code>oil refine migrate --packages=auth</code> to have the table created for you.
|
| 225 |
+
</p>
|
| 226 |
+
|
| 227 |
+
<h3 id="example">Example</h3>
|
| 228 |
+
|
| 229 |
+
<p>This is a sample login action:</p>
|
| 230 |
+
|
| 231 |
+
<pre class="php"><code>public function action_login()
|
| 232 |
+
{
|
| 233 |
+
$data = array();
|
| 234 |
+
|
| 235 |
+
// If so, you pressed the submit button. Let's go over the steps.
|
| 236 |
+
if (Input::post())
|
| 237 |
+
{
|
| 238 |
+
// Check the credentials. This assumes that you have the previous table created and
|
| 239 |
+
// you have used the table definition and configuration as mentioned above.
|
| 240 |
+
if (Auth::login())
|
| 241 |
+
{
|
| 242 |
+
// Credentials ok, go right in.
|
| 243 |
+
Response::redirect('success_page');
|
| 244 |
+
}
|
| 245 |
+
else
|
| 246 |
+
{
|
| 247 |
+
// Oops, no soup for you. Try to login again. Set some values to
|
| 248 |
+
// repopulate the username field and give some error text back to the view.
|
| 249 |
+
$data['username'] = Input::post('username');
|
| 250 |
+
$data['login_error'] = 'Wrong username/password combo. Try again';
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
// Show the login form.
|
| 255 |
+
echo View::forge('auth/login',$data);
|
| 256 |
+
}</code></pre>
|
| 257 |
+
|
| 258 |
+
</div>
|
| 259 |
+
|
| 260 |
+
<footer>
|
| 261 |
+
<p>
|
| 262 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 263 |
+
</p>
|
| 264 |
+
</footer>
|
| 265 |
+
</div>
|
| 266 |
+
</body>
|
| 267 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/simpleauth/usage.html
ADDED
|
@@ -0,0 +1,1301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Usage - SimpleAuth - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
<h2 id="usage">SimpleAuth Usage</h2>
|
| 48 |
+
|
| 49 |
+
<p>
|
| 50 |
+
As said in the <a href="../intro.html">introduction</a> of the Auth package, an authentication system comes with
|
| 51 |
+
three different drivers, each dealing with a part of the system:
|
| 52 |
+
</p>
|
| 53 |
+
<p>
|
| 54 |
+
The Simpleauth <kbd>login</kbd> driver provides the logic for creating, updating, deleting and validating user accounts
|
| 55 |
+
stored in a local database table, for getting information about those accounts, for generating or resetting
|
| 56 |
+
passwords, and for login and logout operations (creating a user session).
|
| 57 |
+
</p>
|
| 58 |
+
|
| 59 |
+
<p>
|
| 60 |
+
The Simpleauth <kbd>group</kbd> driver stores it's group definitions in the simpleauth configuration file. It provides the logic
|
| 61 |
+
for checking if a user is a member of a group, and for retrieving group information, or the roles defined to to a group.
|
| 62 |
+
</p>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
The Simpleauth <kbd>acl</kbd> driver is role driven, and stores it's acl definitions in the simpleauth configuration file.
|
| 66 |
+
It provides the logic for checking if a user has access to a named ACL.
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<h3 id="classmethods">Static vs Dynamic</h3>
|
| 70 |
+
|
| 71 |
+
<p>As explained in the introduction, the Auth package provides a static interface to most of the method available, providing you
|
| 72 |
+
only a single driver set. These methods will be defined below as "Static: Yes". All methods are also accessable via chaining on the
|
| 73 |
+
Auth instance object, including the ones marked as static. </p>
|
| 74 |
+
|
| 75 |
+
<h3 id="classmethods">Class methods</h3>
|
| 76 |
+
|
| 77 |
+
<article>
|
| 78 |
+
<h4 id="method_validate_user" class="method">validate_user($username_or_email = '', $password = '')</h4>
|
| 79 |
+
<p>The <strong>validate_user</strong> method validates user credentials. This method supports both email address and username as valid credential.</p>
|
| 80 |
+
<table class="method">
|
| 81 |
+
<tbody>
|
| 82 |
+
<tr>
|
| 83 |
+
<th class="legend">Static</th>
|
| 84 |
+
<td>Yes</td>
|
| 85 |
+
</tr>
|
| 86 |
+
<tr>
|
| 87 |
+
<th>Parameters</th>
|
| 88 |
+
<td>
|
| 89 |
+
<table class="parameters">
|
| 90 |
+
<tr>
|
| 91 |
+
<th>Param</th>
|
| 92 |
+
<th>Default</th>
|
| 93 |
+
<th class="description">Description</th>
|
| 94 |
+
</tr>
|
| 95 |
+
<tr>
|
| 96 |
+
<th><kbd>$username_or_email</kbd></th>
|
| 97 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 98 |
+
<td>Either the users username or email address</td>
|
| 99 |
+
</tr>
|
| 100 |
+
<tr>
|
| 101 |
+
<th><kbd>$password</kbd></th>
|
| 102 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 103 |
+
<td>The users password</td>
|
| 104 |
+
</tr>
|
| 105 |
+
</table>
|
| 106 |
+
</td>
|
| 107 |
+
</tr>
|
| 108 |
+
<tr>
|
| 109 |
+
<th>Returns</th>
|
| 110 |
+
<td>mixed. <strong>false</strong> if the user didn't pass validation, or an <strong>array</strong> with the users information if the credentials were valid.</td>
|
| 111 |
+
</tr>
|
| 112 |
+
<tr>
|
| 113 |
+
<th>Example</th>
|
| 114 |
+
<td>
|
| 115 |
+
<pre class="php"><code>// validate the a username and password
|
| 116 |
+
if ($user = Auth::validate_user($name, $pass))
|
| 117 |
+
{
|
| 118 |
+
// the combination of $name and $pass validated, print the users screen name
|
| 119 |
+
echo $user['username'];
|
| 120 |
+
}
|
| 121 |
+
</code></pre>
|
| 122 |
+
</td>
|
| 123 |
+
</tr>
|
| 124 |
+
</tbody>
|
| 125 |
+
</table>
|
| 126 |
+
<p class="note">This method only validates if a given combination of username and password is correct. It does NOT log the user in!</p>
|
| 127 |
+
</article>
|
| 128 |
+
|
| 129 |
+
<article>
|
| 130 |
+
<h4 id="method_login" class="method">login($username_or_email = '', $password = '')</h4>
|
| 131 |
+
<p>The <strong>login</strong> method performs a login request. If a parameter is not given, it will attempt to
|
| 132 |
+
retrieve it from posted data, used the form fieldnames configured in the simpleauth.php configuration file.
|
| 133 |
+
Internally it calls the validate_user() method to validate the request before attempting a login.</p>
|
| 134 |
+
<table class="method">
|
| 135 |
+
<tbody>
|
| 136 |
+
<tr>
|
| 137 |
+
<th class="legend">Static</th>
|
| 138 |
+
<td>Yes</td>
|
| 139 |
+
</tr>
|
| 140 |
+
<tr>
|
| 141 |
+
<th>Parameters</th>
|
| 142 |
+
<td>
|
| 143 |
+
<table class="parameters">
|
| 144 |
+
<tr>
|
| 145 |
+
<th>Param</th>
|
| 146 |
+
<th>Default</th>
|
| 147 |
+
<th class="description">Description</th>
|
| 148 |
+
</tr>
|
| 149 |
+
<tr>
|
| 150 |
+
<th><kbd>$username_or_email</kbd></th>
|
| 151 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 152 |
+
<td>Either the users username or email address</td>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<th><kbd>$password</kbd></th>
|
| 156 |
+
<td><pre class="php"><code>''</code></pre></td>
|
| 157 |
+
<td>The users password</td>
|
| 158 |
+
</tr>
|
| 159 |
+
</table>
|
| 160 |
+
</td>
|
| 161 |
+
</tr>
|
| 162 |
+
<tr>
|
| 163 |
+
<th>Returns</th>
|
| 164 |
+
<td>boolean. returns <strong>true</strong> if the login was succesful, <strong>false</strong> otherwise.</td>
|
| 165 |
+
</tr>
|
| 166 |
+
<tr>
|
| 167 |
+
<th>Example</th>
|
| 168 |
+
<td>
|
| 169 |
+
<pre class="php"><code>// perform a login
|
| 170 |
+
if (Auth::login($name, $pass))
|
| 171 |
+
{
|
| 172 |
+
// the user is succesfully logged in
|
| 173 |
+
}
|
| 174 |
+
</code></pre>
|
| 175 |
+
</td>
|
| 176 |
+
</tr>
|
| 177 |
+
</tbody>
|
| 178 |
+
</table>
|
| 179 |
+
<p class="note">After a succesful login, the 'username' and the current 'login_hash' will be available as a session variable.</p>
|
| 180 |
+
</article>
|
| 181 |
+
|
| 182 |
+
<article>
|
| 183 |
+
<h4 id="method_check" class="method">check()</h4>
|
| 184 |
+
<p>The <strong>check</strong> method checks if a logged-in user is present.</p>
|
| 185 |
+
<table class="method">
|
| 186 |
+
<tbody>
|
| 187 |
+
<tr>
|
| 188 |
+
<th class="legend">Static</th>
|
| 189 |
+
<td>Yes</td>
|
| 190 |
+
</tr>
|
| 191 |
+
<tr>
|
| 192 |
+
<th>Parameters</th>
|
| 193 |
+
<td>
|
| 194 |
+
None
|
| 195 |
+
</td>
|
| 196 |
+
</tr>
|
| 197 |
+
<tr>
|
| 198 |
+
<th>Returns</th>
|
| 199 |
+
<td>boolean. returns <strong>true</strong> if the is a logged-in user, <strong>false</strong> otherwise.</td>
|
| 200 |
+
</tr>
|
| 201 |
+
<tr>
|
| 202 |
+
<th>Example</th>
|
| 203 |
+
<td>
|
| 204 |
+
<pre class="php"><code>// login if we're not logged-in
|
| 205 |
+
if ( ! Auth::check())
|
| 206 |
+
{
|
| 207 |
+
Response::redirect('/login');
|
| 208 |
+
}
|
| 209 |
+
</code></pre>
|
| 210 |
+
</td>
|
| 211 |
+
</tr>
|
| 212 |
+
</tbody>
|
| 213 |
+
</table>
|
| 214 |
+
</article>
|
| 215 |
+
|
| 216 |
+
<article>
|
| 217 |
+
<h4 id="method_force_login" class="method">force_login($user_id = '')</h4>
|
| 218 |
+
<p>
|
| 219 |
+
The <strong>force_login</strong> method performs a forced login request. You can use this for an automated login, when you know
|
| 220 |
+
the users id, but you don't know the password. This can be used for example to implement a "remember me" feature.</p>
|
| 221 |
+
<table class="method">
|
| 222 |
+
<tbody>
|
| 223 |
+
<tr>
|
| 224 |
+
<th class="legend">Static</th>
|
| 225 |
+
<td>Yes</td>
|
| 226 |
+
</tr>
|
| 227 |
+
<tr>
|
| 228 |
+
<th>Parameters</th>
|
| 229 |
+
<td>
|
| 230 |
+
<table class="parameters">
|
| 231 |
+
<tr>
|
| 232 |
+
<th>Param</th>
|
| 233 |
+
<th>Default</th>
|
| 234 |
+
<th class="description">Description</th>
|
| 235 |
+
</tr>
|
| 236 |
+
<tr>
|
| 237 |
+
<th><kbd>$user_id</kbd></th>
|
| 238 |
+
<td>required</td>
|
| 239 |
+
<td>The id of the user you want to login</td>
|
| 240 |
+
</tr>
|
| 241 |
+
</table>
|
| 242 |
+
</td>
|
| 243 |
+
</tr>
|
| 244 |
+
<tr>
|
| 245 |
+
<th>Returns</th>
|
| 246 |
+
<td>boolean. returns <strong>true</strong> if the login was succesful, <strong>false</strong> otherwise.</td>
|
| 247 |
+
</tr>
|
| 248 |
+
<tr>
|
| 249 |
+
<th>Example</th>
|
| 250 |
+
<td>
|
| 251 |
+
<pre class="php"><code>// perform a forced login for user 12121
|
| 252 |
+
if (Auth::force_login(12121))
|
| 253 |
+
{
|
| 254 |
+
// the user is succesfully logged in. Any previously logged-in user will be logged out!
|
| 255 |
+
}
|
| 256 |
+
</code></pre>
|
| 257 |
+
</td>
|
| 258 |
+
</tr>
|
| 259 |
+
</tbody>
|
| 260 |
+
</table>
|
| 261 |
+
</article>
|
| 262 |
+
|
| 263 |
+
<article>
|
| 264 |
+
<h4 id="method_logout" class="method">logout()</h4>
|
| 265 |
+
<p>The <strong>logout</strong> method logs out the current logged-in user.</p>
|
| 266 |
+
<table class="method">
|
| 267 |
+
<tbody>
|
| 268 |
+
<tr>
|
| 269 |
+
<th class="legend">Static</th>
|
| 270 |
+
<td>Yes</td>
|
| 271 |
+
</tr>
|
| 272 |
+
<tr>
|
| 273 |
+
<th>Parameters</th>
|
| 274 |
+
<td>
|
| 275 |
+
None
|
| 276 |
+
</td>
|
| 277 |
+
</tr>
|
| 278 |
+
<tr>
|
| 279 |
+
<th>Returns</th>
|
| 280 |
+
<td>boolean. returns <strong>true</strong> if the logout was succesful, <strong>false</strong> otherwise.</td>
|
| 281 |
+
</tr>
|
| 282 |
+
<tr>
|
| 283 |
+
<th>Example</th>
|
| 284 |
+
<td>
|
| 285 |
+
<pre class="php"><code>// perform a logout
|
| 286 |
+
Auth::logout();
|
| 287 |
+
</code></pre>
|
| 288 |
+
</td>
|
| 289 |
+
</tr>
|
| 290 |
+
</tbody>
|
| 291 |
+
</table>
|
| 292 |
+
<p class="note">If you have enabled guest user support, the guest user will be setup after a succesful logout.</p>
|
| 293 |
+
</article>
|
| 294 |
+
|
| 295 |
+
<article>
|
| 296 |
+
<h4 id="method_create_user" class="method">create_user($username, $password, $email, $group = 1, Array $profile_fields = array())</h4>
|
| 297 |
+
<p>
|
| 298 |
+
The <strong>create_user</strong> allows method you to create a new user record in the users table.
|
| 299 |
+
</p>
|
| 300 |
+
<table class="method">
|
| 301 |
+
<tbody>
|
| 302 |
+
<tr>
|
| 303 |
+
<th class="legend">Static</th>
|
| 304 |
+
<td>Yes</td>
|
| 305 |
+
</tr>
|
| 306 |
+
<tr>
|
| 307 |
+
<th>Parameters</th>
|
| 308 |
+
<td>
|
| 309 |
+
<table class="parameters">
|
| 310 |
+
<tr>
|
| 311 |
+
<th>Param</th>
|
| 312 |
+
<th>Default</th>
|
| 313 |
+
<th class="description">Description</th>
|
| 314 |
+
</tr>
|
| 315 |
+
<tr>
|
| 316 |
+
<th><kbd>$username</kbd></th>
|
| 317 |
+
<td>required</td>
|
| 318 |
+
<td>The name of the user you want to create</td>
|
| 319 |
+
</tr>
|
| 320 |
+
<tr>
|
| 321 |
+
<th><kbd>$password</kbd></th>
|
| 322 |
+
<td>required</td>
|
| 323 |
+
<td>The password you want to assign to the user</td>
|
| 324 |
+
</tr>
|
| 325 |
+
<tr>
|
| 326 |
+
<th><kbd>$email</kbd></th>
|
| 327 |
+
<td>required</td>
|
| 328 |
+
<td>The email address of the user you want to create</td>
|
| 329 |
+
</tr>
|
| 330 |
+
<tr>
|
| 331 |
+
<th><kbd>$group</kbd></th>
|
| 332 |
+
<td>1</td>
|
| 333 |
+
<td>The group you want to assign this user to. By default, the user is assigned to group 1.</td>
|
| 334 |
+
</tr>
|
| 335 |
+
<tr>
|
| 336 |
+
<th><kbd>$profile_fields</kbd></th>
|
| 337 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 338 |
+
<td>Any additional profile fields or user metadata you want to assign to this user</td>
|
| 339 |
+
</tr>
|
| 340 |
+
</table>
|
| 341 |
+
</td>
|
| 342 |
+
</tr>
|
| 343 |
+
<tr>
|
| 344 |
+
<th>Throws</th>
|
| 345 |
+
<td>SimpleUserUpdateException</td>
|
| 346 |
+
</tr>
|
| 347 |
+
<tr>
|
| 348 |
+
<th>Returns</th>
|
| 349 |
+
<td>mixed. returns the id of the user record created, or <strong>false</strong> if the creation failed.</td>
|
| 350 |
+
</tr>
|
| 351 |
+
<tr>
|
| 352 |
+
<th>Example</th>
|
| 353 |
+
<td>
|
| 354 |
+
<pre class="php"><code>// create a new user
|
| 355 |
+
Auth::create_user(
|
| 356 |
+
'anewuser',
|
| 357 |
+
'thisismysecretpassword',
|
| 358 |
+
'anewuser@example.org',
|
| 359 |
+
1,
|
| 360 |
+
array(
|
| 361 |
+
'fullname' => 'A. New User',
|
| 362 |
+
)
|
| 363 |
+
);
|
| 364 |
+
</code></pre>
|
| 365 |
+
</td>
|
| 366 |
+
</tr>
|
| 367 |
+
</tbody>
|
| 368 |
+
</table>
|
| 369 |
+
</article>
|
| 370 |
+
|
| 371 |
+
<article>
|
| 372 |
+
<h4 id="method_update_user" class="method">update_user($values, $username = null)</h4>
|
| 373 |
+
<p>
|
| 374 |
+
The <strong>update_user</strong> method allows you to update values in the user record,
|
| 375 |
+
either for a named user, or for the current logged-in user.
|
| 376 |
+
</p>
|
| 377 |
+
<table class="method">
|
| 378 |
+
<tbody>
|
| 379 |
+
<tr>
|
| 380 |
+
<th class="legend">Static</th>
|
| 381 |
+
<td>Yes</td>
|
| 382 |
+
</tr>
|
| 383 |
+
<tr>
|
| 384 |
+
<th>Parameters</th>
|
| 385 |
+
<td>
|
| 386 |
+
<table class="parameters">
|
| 387 |
+
<tr>
|
| 388 |
+
<th>Param</th>
|
| 389 |
+
<th>Default</th>
|
| 390 |
+
<th class="description">Description</th>
|
| 391 |
+
</tr>
|
| 392 |
+
<tr>
|
| 393 |
+
<th><kbd>$values</kbd></th>
|
| 394 |
+
<td><pre class="php"><code>array()</code></pre></td>
|
| 395 |
+
<td>Associative array with column name / value pairs for the columns or profile fields you want to update.</td>
|
| 396 |
+
</tr>
|
| 397 |
+
<tr>
|
| 398 |
+
<th><kbd>$username</kbd></th>
|
| 399 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 400 |
+
<td>The name of the user you want to update</td>
|
| 401 |
+
</tr>
|
| 402 |
+
</table>
|
| 403 |
+
</td>
|
| 404 |
+
</tr>
|
| 405 |
+
<tr>
|
| 406 |
+
<th>Throws</th>
|
| 407 |
+
<td>SimpleUserUpdateException</td>
|
| 408 |
+
</tr>
|
| 409 |
+
<tr>
|
| 410 |
+
<th>Returns</th>
|
| 411 |
+
<td>boolean. returns <strong>true</strong> if columns were updated, or <strong>false</strong> if no columns were affected.</td>
|
| 412 |
+
</tr>
|
| 413 |
+
<tr>
|
| 414 |
+
<th>Example</th>
|
| 415 |
+
<td>
|
| 416 |
+
<pre class="php"><code>// update the data for the current user
|
| 417 |
+
Auth::update_user(
|
| 418 |
+
array(
|
| 419 |
+
'email' => 'anewemail@example.org', // set a new email address
|
| 420 |
+
'password' => 'thisismynewpassword', // set a new password
|
| 421 |
+
'old_password' => 'thisismysecretpassword', // to do so, give the current one!
|
| 422 |
+
'phone' => '+1 (555) 123-1212', // and add the phone number to the metadata
|
| 423 |
+
)
|
| 424 |
+
);
|
| 425 |
+
</code></pre>
|
| 426 |
+
</td>
|
| 427 |
+
</tr>
|
| 428 |
+
</tbody>
|
| 429 |
+
</table>
|
| 430 |
+
<p class="note">
|
| 431 |
+
This method is primary provided to allow the user to do profile updates. And as a security measure, it will <strong>not</strong> allow you
|
| 432 |
+
to change the username, and if you want to change the password, you <strong>have</strong> to pass the current password in $values as "old_password".
|
| 433 |
+
</p>
|
| 434 |
+
</article>
|
| 435 |
+
|
| 436 |
+
<article>
|
| 437 |
+
<h4 id="method_change_password" class="method">change_password($old_password, $new_password, $username = null)</h4>
|
| 438 |
+
<p>
|
| 439 |
+
The <strong>change_password</strong> method allows you to change a users password.
|
| 440 |
+
</p>
|
| 441 |
+
<table class="method">
|
| 442 |
+
<tbody>
|
| 443 |
+
<tr>
|
| 444 |
+
<th class="legend">Static</th>
|
| 445 |
+
<td>Yes</td>
|
| 446 |
+
</tr>
|
| 447 |
+
<tr>
|
| 448 |
+
<th>Parameters</th>
|
| 449 |
+
<td>
|
| 450 |
+
<table class="parameters">
|
| 451 |
+
<tr>
|
| 452 |
+
<th>Param</th>
|
| 453 |
+
<th>Default</th>
|
| 454 |
+
<th class="description">Description</th>
|
| 455 |
+
</tr>
|
| 456 |
+
<tr>
|
| 457 |
+
<th><kbd>$old_password</kbd></th>
|
| 458 |
+
<td>required</td>
|
| 459 |
+
<td>The users current password</td>
|
| 460 |
+
</tr>
|
| 461 |
+
<tr>
|
| 462 |
+
<th><kbd>$new_password</kbd></th>
|
| 463 |
+
<td>required</td>
|
| 464 |
+
<td>The users new password</td>
|
| 465 |
+
</tr>
|
| 466 |
+
<tr>
|
| 467 |
+
<th><kbd>$username</kbd></th>
|
| 468 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 469 |
+
<td>The name of the user of whom you want to change the password</td>
|
| 470 |
+
</tr>
|
| 471 |
+
</table>
|
| 472 |
+
</td>
|
| 473 |
+
</tr>
|
| 474 |
+
<tr>
|
| 475 |
+
<th>Throws</th>
|
| 476 |
+
<td>SimpleUserUpdateException</td>
|
| 477 |
+
</tr>
|
| 478 |
+
<tr>
|
| 479 |
+
<th>Returns</th>
|
| 480 |
+
<td>boolean. returns <strong>true</strong> if the password was changed, or <strong>false</strong> if the old password was incorrect.</td>
|
| 481 |
+
</tr>
|
| 482 |
+
<tr>
|
| 483 |
+
<th>Example</th>
|
| 484 |
+
<td>
|
| 485 |
+
<pre class="php"><code>// reset the password for the current user
|
| 486 |
+
Auth::change_password('thisismynewpassword','thisismysecretpassword');
|
| 487 |
+
</code></pre>
|
| 488 |
+
</td>
|
| 489 |
+
</tr>
|
| 490 |
+
</tbody>
|
| 491 |
+
</table>
|
| 492 |
+
<p class="note">
|
| 493 |
+
This method is provided to allow the user to change his password. And as a security measure, you <strong>have</strong> to
|
| 494 |
+
pass the current password in "old_password".
|
| 495 |
+
</p>
|
| 496 |
+
</article>
|
| 497 |
+
|
| 498 |
+
<article>
|
| 499 |
+
<h4 id="method_reset_password" class="method">reset_password($username)</h4>
|
| 500 |
+
<p>
|
| 501 |
+
The <strong>reset_password</strong> method allows you to assign a new random password to a user.
|
| 502 |
+
</p>
|
| 503 |
+
<table class="method">
|
| 504 |
+
<tbody>
|
| 505 |
+
<tr>
|
| 506 |
+
<th class="legend">Static</th>
|
| 507 |
+
<td>Yes</td>
|
| 508 |
+
</tr>
|
| 509 |
+
<tr>
|
| 510 |
+
<th>Parameters</th>
|
| 511 |
+
<td>
|
| 512 |
+
<table class="parameters">
|
| 513 |
+
<tr>
|
| 514 |
+
<th>Param</th>
|
| 515 |
+
<th>Default</th>
|
| 516 |
+
<th class="description">Description</th>
|
| 517 |
+
</tr>
|
| 518 |
+
<tr>
|
| 519 |
+
<th><kbd>$username</kbd></th>
|
| 520 |
+
<td>required</td>
|
| 521 |
+
<td>The name of the user for whom you want to reset the password</td>
|
| 522 |
+
</tr>
|
| 523 |
+
</table>
|
| 524 |
+
</td>
|
| 525 |
+
</tr>
|
| 526 |
+
<tr>
|
| 527 |
+
<th>Throws</th>
|
| 528 |
+
<td>SimpleUserUpdateException</td>
|
| 529 |
+
</tr>
|
| 530 |
+
<tr>
|
| 531 |
+
<th>Returns</th>
|
| 532 |
+
<td>string, the generated random password.</td>
|
| 533 |
+
</tr>
|
| 534 |
+
<tr>
|
| 535 |
+
<th>Example</th>
|
| 536 |
+
<td>
|
| 537 |
+
<pre class="php"><code>// reset the password for the current user
|
| 538 |
+
$new_password = Auth::reset_password('thisusername');
|
| 539 |
+
</code></pre>
|
| 540 |
+
</td>
|
| 541 |
+
</tr>
|
| 542 |
+
</tbody>
|
| 543 |
+
</table>
|
| 544 |
+
</article>
|
| 545 |
+
|
| 546 |
+
<article>
|
| 547 |
+
<h4 id="method_delete_user" class="method">delete_user($username)</h4>
|
| 548 |
+
<p>
|
| 549 |
+
The <strong>delete_user</strong> method allows you to delete a user account.
|
| 550 |
+
</p>
|
| 551 |
+
<table class="method">
|
| 552 |
+
<tbody>
|
| 553 |
+
<tr>
|
| 554 |
+
<th class="legend">Static</th>
|
| 555 |
+
<td>Yes</td>
|
| 556 |
+
</tr>
|
| 557 |
+
<tr>
|
| 558 |
+
<th>Parameters</th>
|
| 559 |
+
<td>
|
| 560 |
+
<table class="parameters">
|
| 561 |
+
<tr>
|
| 562 |
+
<th>Param</th>
|
| 563 |
+
<th>Default</th>
|
| 564 |
+
<th class="description">Description</th>
|
| 565 |
+
</tr>
|
| 566 |
+
<tr>
|
| 567 |
+
<th><kbd>$username</kbd></th>
|
| 568 |
+
<td>required</td>
|
| 569 |
+
<td>The name of the user account you want to delete</td>
|
| 570 |
+
</tr>
|
| 571 |
+
</table>
|
| 572 |
+
</td>
|
| 573 |
+
</tr>
|
| 574 |
+
<tr>
|
| 575 |
+
<th>Throws</th>
|
| 576 |
+
<td>SimpleUserUpdateException</td>
|
| 577 |
+
</tr>
|
| 578 |
+
<tr>
|
| 579 |
+
<th>Returns</th>
|
| 580 |
+
<td>boolean. returns <strong>true</strong> if the user account was deleted, or <strong>false</strong> if it failed (because the username did not exist).</td>
|
| 581 |
+
</tr>
|
| 582 |
+
<tr>
|
| 583 |
+
<th>Example</th>
|
| 584 |
+
<td>
|
| 585 |
+
<pre class="php"><code>// delete the user
|
| 586 |
+
Auth::delete_user('thisusername');
|
| 587 |
+
</code></pre>
|
| 588 |
+
</td>
|
| 589 |
+
</tr>
|
| 590 |
+
</tbody>
|
| 591 |
+
</table>
|
| 592 |
+
</article>
|
| 593 |
+
|
| 594 |
+
<article>
|
| 595 |
+
<h4 id="method_create_login_hash" class="method">create_login_hash()</h4>
|
| 596 |
+
<p>The <strong>create_login_hash</strong> method generates a new login hash for the currently logged-in user.</p>
|
| 597 |
+
<table class="method">
|
| 598 |
+
<tbody>
|
| 599 |
+
<tr>
|
| 600 |
+
<th class="legend">Static</th>
|
| 601 |
+
<td>Yes</td>
|
| 602 |
+
</tr>
|
| 603 |
+
<tr>
|
| 604 |
+
<th>Parameters</th>
|
| 605 |
+
<td>
|
| 606 |
+
None
|
| 607 |
+
</td>
|
| 608 |
+
</tr>
|
| 609 |
+
<tr>
|
| 610 |
+
<th>Returns</th>
|
| 611 |
+
<td>string, the generated login hash.</td>
|
| 612 |
+
</tr>
|
| 613 |
+
<tr>
|
| 614 |
+
<th>Example</th>
|
| 615 |
+
<td>
|
| 616 |
+
<pre class="php"><code>// generate a new random hash
|
| 617 |
+
Auth::create_login_hash();
|
| 618 |
+
</code></pre>
|
| 619 |
+
</td>
|
| 620 |
+
</tr>
|
| 621 |
+
</tbody>
|
| 622 |
+
</table>
|
| 623 |
+
<p class="note">This method is normally used when a user logs in, but you can use this as an extra security measure by rotating
|
| 624 |
+
the hash regularly for logged-in users.</p>
|
| 625 |
+
<p class="note">Note that login hash protection is <kbd>not</kbd> used when multiple logins is enabled!</p>
|
| 626 |
+
</article>
|
| 627 |
+
|
| 628 |
+
<article>
|
| 629 |
+
<h4 id="method_get" class="method">get($field, $default = null)</h4>
|
| 630 |
+
<p>The <strong>get</strong> method is a generic getter for user properties, either from the user record, or from the metadata.</p>
|
| 631 |
+
<table class="method">
|
| 632 |
+
<tbody>
|
| 633 |
+
<tr>
|
| 634 |
+
<th class="legend">Static</th>
|
| 635 |
+
<td>Yes</td>
|
| 636 |
+
</tr>
|
| 637 |
+
<tr>
|
| 638 |
+
<th>Parameters</th>
|
| 639 |
+
<td>
|
| 640 |
+
<table class="parameters">
|
| 641 |
+
<tr>
|
| 642 |
+
<th>Param</th>
|
| 643 |
+
<th>Default</th>
|
| 644 |
+
<th class="description">Description</th>
|
| 645 |
+
</tr>
|
| 646 |
+
<tr>
|
| 647 |
+
<th><kbd>$field</kbd></th>
|
| 648 |
+
<td>required</td>
|
| 649 |
+
<td>The name of the property you want the value of</td>
|
| 650 |
+
</tr>
|
| 651 |
+
<tr>
|
| 652 |
+
<th><kbd>$default</kbd></th>
|
| 653 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 654 |
+
<td>The value to return is the property is not set</td>
|
| 655 |
+
</tr>
|
| 656 |
+
</table>
|
| 657 |
+
</td>
|
| 658 |
+
</tr>
|
| 659 |
+
<tr>
|
| 660 |
+
<th>Returns</th>
|
| 661 |
+
<td>mixed.</td>
|
| 662 |
+
</tr>
|
| 663 |
+
<tr>
|
| 664 |
+
<th>Example</th>
|
| 665 |
+
<td>
|
| 666 |
+
<pre class="php"><code>// get the user creation date
|
| 667 |
+
$created_at = Auth::get('created_at');
|
| 668 |
+
</code></pre>
|
| 669 |
+
</td>
|
| 670 |
+
</tr>
|
| 671 |
+
</tbody>
|
| 672 |
+
</table>
|
| 673 |
+
</article>
|
| 674 |
+
|
| 675 |
+
<article>
|
| 676 |
+
<h4 id="method_get_user_id" class="method">get_user_id()</h4>
|
| 677 |
+
<p>The <strong>get_user_id</strong> method returns an array structure containing the drivers id value, and the id of
|
| 678 |
+
the currently logged-in user. It uses this structure because you can have multiple login drivers active, each can have
|
| 679 |
+
a different id for the currently logged-in user.</p>
|
| 680 |
+
<table class="method">
|
| 681 |
+
<tbody>
|
| 682 |
+
<tr>
|
| 683 |
+
<th class="legend">Static</th>
|
| 684 |
+
<td>Yes</td>
|
| 685 |
+
</tr>
|
| 686 |
+
<tr>
|
| 687 |
+
<th>Parameters</th>
|
| 688 |
+
<td>
|
| 689 |
+
None
|
| 690 |
+
</td>
|
| 691 |
+
</tr>
|
| 692 |
+
<tr>
|
| 693 |
+
<th>Returns</th>
|
| 694 |
+
<td>mixed. returns a numeric array in the form <strong>array([0]=>driver_id, [1]=>user_id)</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 695 |
+
</tr>
|
| 696 |
+
<tr>
|
| 697 |
+
<th>Example</th>
|
| 698 |
+
<td>
|
| 699 |
+
<pre class="php"><code>// get all login id information
|
| 700 |
+
$id_info = Auth::get_user_id();
|
| 701 |
+
|
| 702 |
+
// print driver and id info
|
| 703 |
+
if ($id_info)
|
| 704 |
+
{
|
| 705 |
+
foreach ($id_info as $info)
|
| 706 |
+
{
|
| 707 |
+
echo 'Driver: ',$info[0],' with ID ',$info[1],'<br />';
|
| 708 |
+
}
|
| 709 |
+
}
|
| 710 |
+
else
|
| 711 |
+
{
|
| 712 |
+
echo 'Nobody is logged in!';
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
// if you only use one driver, you can also do
|
| 716 |
+
list($driver, $userid) = Auth::get_user_id();
|
| 717 |
+
|
| 718 |
+
// or this if you only need the userid
|
| 719 |
+
list(, $userid) = Auth::get_user_id();
|
| 720 |
+
</code></pre>
|
| 721 |
+
</td>
|
| 722 |
+
</tr>
|
| 723 |
+
</tbody>
|
| 724 |
+
</table>
|
| 725 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the user id of the guest user.</p>
|
| 726 |
+
</article>
|
| 727 |
+
|
| 728 |
+
<article>
|
| 729 |
+
<h4 id="method_get_groups" class="method">get_groups()</h4>
|
| 730 |
+
<p>The <strong>get_groups</strong> method returns the user groups assigned to the currently logged-in user.</p>
|
| 731 |
+
<table class="method">
|
| 732 |
+
<tbody>
|
| 733 |
+
<tr>
|
| 734 |
+
<th class="legend">Static</th>
|
| 735 |
+
<td>Yes</td>
|
| 736 |
+
</tr>
|
| 737 |
+
<tr>
|
| 738 |
+
<th>Parameters</th>
|
| 739 |
+
<td>
|
| 740 |
+
None
|
| 741 |
+
</td>
|
| 742 |
+
</tr>
|
| 743 |
+
<tr>
|
| 744 |
+
<th>Returns</th>
|
| 745 |
+
<td>mixed. returns an array in the form <strong>array(array(driver, group_id))</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 746 |
+
</tr>
|
| 747 |
+
<th>Example</th>
|
| 748 |
+
<td>
|
| 749 |
+
<pre class="php"><code>// get all group id information
|
| 750 |
+
$id_info = Auth::get_groups();
|
| 751 |
+
|
| 752 |
+
// print driver and id info
|
| 753 |
+
if ($id_info)
|
| 754 |
+
{
|
| 755 |
+
foreach ($id_info as $info)
|
| 756 |
+
{
|
| 757 |
+
echo 'Driver: ',$info[0],' with group ID ',$info[1],'<br />';
|
| 758 |
+
}
|
| 759 |
+
}
|
| 760 |
+
else
|
| 761 |
+
{
|
| 762 |
+
echo 'Nobody is logged in!';
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
// if you only use one driver, you can also do
|
| 766 |
+
list($driver, $groupid) = Auth::get_groups();
|
| 767 |
+
</code></pre>
|
| 768 |
+
</td>
|
| 769 |
+
</tr>
|
| 770 |
+
</tbody>
|
| 771 |
+
</table>
|
| 772 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the group information of the guest user.</p>
|
| 773 |
+
</article>
|
| 774 |
+
|
| 775 |
+
<article>
|
| 776 |
+
<h4 id="method_get_email" class="method">get_email()</h4>
|
| 777 |
+
<p>The <strong>get_email</strong> method returns the email address assigned to the currently logged-in user.</p>
|
| 778 |
+
<table class="method">
|
| 779 |
+
<tbody>
|
| 780 |
+
<tr>
|
| 781 |
+
<th class="legend">Static</th>
|
| 782 |
+
<td>Yes</td>
|
| 783 |
+
</tr>
|
| 784 |
+
<tr>
|
| 785 |
+
<th>Parameters</th>
|
| 786 |
+
<td>
|
| 787 |
+
None
|
| 788 |
+
</td>
|
| 789 |
+
</tr>
|
| 790 |
+
<tr>
|
| 791 |
+
<th>Returns</th>
|
| 792 |
+
<td>mixed. returns an email address if a user is logged in, or <strong>false</strong> if there is no user logged-in.</td>
|
| 793 |
+
</tr>
|
| 794 |
+
<tr>
|
| 795 |
+
<th>Example</th>
|
| 796 |
+
<td>
|
| 797 |
+
<pre class="php"><code>// get the current users email address
|
| 798 |
+
$email = Auth::get_email();
|
| 799 |
+
|
| 800 |
+
// note that there is a difference between false and empty:
|
| 801 |
+
if ($email === false)
|
| 802 |
+
{
|
| 803 |
+
// nobody logged in
|
| 804 |
+
}
|
| 805 |
+
if (empty($email))
|
| 806 |
+
{
|
| 807 |
+
// a user is logged in, but doesn't have an email address
|
| 808 |
+
}
|
| 809 |
+
</code></pre>
|
| 810 |
+
</td>
|
| 811 |
+
</tr>
|
| 812 |
+
</tbody>
|
| 813 |
+
</table>
|
| 814 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the email address of the guest user.</p>
|
| 815 |
+
</article>
|
| 816 |
+
|
| 817 |
+
<article>
|
| 818 |
+
<h4 id="method_get_screen_name" class="method">get_screen_name()</h4>
|
| 819 |
+
<p>The <strong>get_screen_name</strong> method returns the screen- or display name of the currently logged-in user.</p>
|
| 820 |
+
<table class="method">
|
| 821 |
+
<tbody>
|
| 822 |
+
<tr>
|
| 823 |
+
<th class="legend">Static</th>
|
| 824 |
+
<td>Yes</td>
|
| 825 |
+
</tr>
|
| 826 |
+
<tr>
|
| 827 |
+
<th>Parameters</th>
|
| 828 |
+
<td>
|
| 829 |
+
None
|
| 830 |
+
</td>
|
| 831 |
+
</tr>
|
| 832 |
+
<tr>
|
| 833 |
+
<th>Returns</th>
|
| 834 |
+
<td>mixed. returns a string containing the name, or <strong>false</strong> if there is no user logged-in.</td>
|
| 835 |
+
</tr>
|
| 836 |
+
<tr>
|
| 837 |
+
<th>Example</th>
|
| 838 |
+
<td>
|
| 839 |
+
<pre class="php"><code>// get the current users screen name
|
| 840 |
+
$name = Auth::get_screen_name();
|
| 841 |
+
|
| 842 |
+
// name is required, so if not present it means nobody is logged in
|
| 843 |
+
if (empty($name))
|
| 844 |
+
{
|
| 845 |
+
// nobody logged in
|
| 846 |
+
}
|
| 847 |
+
</code></pre>
|
| 848 |
+
</td>
|
| 849 |
+
</tr>
|
| 850 |
+
</tbody>
|
| 851 |
+
</table>
|
| 852 |
+
<p class="note">If guest user support is enabled, you will never get <strong>false</strong> returned, because the method will return the user name of the guest user.</p>
|
| 853 |
+
</article>
|
| 854 |
+
|
| 855 |
+
<article>
|
| 856 |
+
<h4 id="method_get_profile_fields" class="method">get_profile_fields($field = null, $default = null)</h4>
|
| 857 |
+
<p>The <strong>get_profile_fields</strong> method returns one or all stored profile fields for the logged-in user.</p>
|
| 858 |
+
<table class="method">
|
| 859 |
+
<tbody>
|
| 860 |
+
<tr>
|
| 861 |
+
<th class="legend">Static</th>
|
| 862 |
+
<td>Yes</td>
|
| 863 |
+
</tr>
|
| 864 |
+
<tr>
|
| 865 |
+
<th>Parameters</th>
|
| 866 |
+
<td>
|
| 867 |
+
<table class="parameters">
|
| 868 |
+
<tr>
|
| 869 |
+
<th>Param</th>
|
| 870 |
+
<th>Default</th>
|
| 871 |
+
<th class="description">Description</th>
|
| 872 |
+
</tr>
|
| 873 |
+
<tr>
|
| 874 |
+
<th><kbd>$field</kbd></th>
|
| 875 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 876 |
+
<td>The name of the profile field you want to get.</td>
|
| 877 |
+
</tr>
|
| 878 |
+
<tr>
|
| 879 |
+
<th><kbd>$default</kbd></th>
|
| 880 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 881 |
+
<td>The value you want returned if the requested profile field does not exist.</td>
|
| 882 |
+
</tr>
|
| 883 |
+
</table>
|
| 884 |
+
</td>
|
| 885 |
+
</tr>
|
| 886 |
+
<tr>
|
| 887 |
+
<th>Returns</th>
|
| 888 |
+
<td>mixed</td>
|
| 889 |
+
</tr>
|
| 890 |
+
<tr>
|
| 891 |
+
<th>Example</th>
|
| 892 |
+
<td>
|
| 893 |
+
<pre class="php"><code>// get all profile fields defined
|
| 894 |
+
$profile = Auth::get_profile_fields();
|
| 895 |
+
</code></pre>
|
| 896 |
+
</td>
|
| 897 |
+
</tr>
|
| 898 |
+
</tbody>
|
| 899 |
+
</table>
|
| 900 |
+
</article>
|
| 901 |
+
|
| 902 |
+
<article>
|
| 903 |
+
<h4 id="method_member" class="method">member($group, $user = null)</h4>
|
| 904 |
+
<p>The <strong>member</strong> method allows you to check if a user is member of a given group.</p>
|
| 905 |
+
<table class="method">
|
| 906 |
+
<tbody>
|
| 907 |
+
<tr>
|
| 908 |
+
<th class="legend">Static</th>
|
| 909 |
+
<td>Yes</td>
|
| 910 |
+
</tr>
|
| 911 |
+
<tr>
|
| 912 |
+
<th>Parameters</th>
|
| 913 |
+
<td>
|
| 914 |
+
<table class="parameters">
|
| 915 |
+
<tr>
|
| 916 |
+
<th>Param</th>
|
| 917 |
+
<th>Default</th>
|
| 918 |
+
<th class="description">Description</th>
|
| 919 |
+
</tr>
|
| 920 |
+
<tr>
|
| 921 |
+
<th><kbd>$group</kbd></th>
|
| 922 |
+
<td>required</td>
|
| 923 |
+
<td>The id of the group you want to check for membership</td>
|
| 924 |
+
</tr>
|
| 925 |
+
<tr>
|
| 926 |
+
<th><kbd>$user</kbd></th>
|
| 927 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 928 |
+
<td>A specific user, identified by the result of get_user_id(), or <strong>null</strong> for the currently logged-in user.</td>
|
| 929 |
+
</tr>
|
| 930 |
+
</table>
|
| 931 |
+
</td>
|
| 932 |
+
</tr>
|
| 933 |
+
<tr>
|
| 934 |
+
<th>Returns</th>
|
| 935 |
+
<td>boolean. <strong>true</strong> if the user is member of the group, or <strong>false</strong> if not.</td>
|
| 936 |
+
</tr>
|
| 937 |
+
<tr>
|
| 938 |
+
<th>Example</th>
|
| 939 |
+
<td>
|
| 940 |
+
<pre class="php"><code>// Check if the current user is an administrator
|
| 941 |
+
if (Auth::member(100))
|
| 942 |
+
{
|
| 943 |
+
// we are in the administrator group!
|
| 944 |
+
}
|
| 945 |
+
</code></pre>
|
| 946 |
+
</td>
|
| 947 |
+
</tr>
|
| 948 |
+
</tbody>
|
| 949 |
+
</table>
|
| 950 |
+
</article>
|
| 951 |
+
|
| 952 |
+
<article>
|
| 953 |
+
<h4 id="method_groups" class="method">groups($driver = null)</h4>
|
| 954 |
+
<p>The <strong>groups</strong> method allows you to fetch all defined groups, or all defined groups in a specific driver.</p>
|
| 955 |
+
<table class="method">
|
| 956 |
+
<tbody>
|
| 957 |
+
<tr>
|
| 958 |
+
<th class="legend">Static</th>
|
| 959 |
+
<td>Yes</td>
|
| 960 |
+
</tr>
|
| 961 |
+
<tr>
|
| 962 |
+
<th>Parameters</th>
|
| 963 |
+
<td>
|
| 964 |
+
<table class="parameters">
|
| 965 |
+
<tr>
|
| 966 |
+
<th>Param</th>
|
| 967 |
+
<th>Default</th>
|
| 968 |
+
<th class="description">Description</th>
|
| 969 |
+
</tr>
|
| 970 |
+
<tr>
|
| 971 |
+
<th><kbd>$driver</kbd></th>
|
| 972 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 973 |
+
<td>The name of the group driver you want to get groups of</td>
|
| 974 |
+
</tr>
|
| 975 |
+
</table>
|
| 976 |
+
</td>
|
| 977 |
+
</tr>
|
| 978 |
+
<tr>
|
| 979 |
+
<th>Returns</th>
|
| 980 |
+
<td>array. If the group driver does not exist or no groups are defined, an empty array is returned.</td>
|
| 981 |
+
</tr>
|
| 982 |
+
<tr>
|
| 983 |
+
<th>Example</th>
|
| 984 |
+
<td>
|
| 985 |
+
<pre class="php"><code>// Get all defined groups (for all loaded group drivers)
|
| 986 |
+
$groups = Auth::groups();
|
| 987 |
+
|
| 988 |
+
// Get all the groups from the default group driver
|
| 989 |
+
$groups = Auth::group()->groups();
|
| 990 |
+
|
| 991 |
+
// Get all the groups from a specific driver
|
| 992 |
+
$groups = Auth::group('Simplegroup')->groups();
|
| 993 |
+
</code></pre>
|
| 994 |
+
</td>
|
| 995 |
+
</tr>
|
| 996 |
+
</tbody>
|
| 997 |
+
</table>
|
| 998 |
+
<p class="note">You need to call this method on the Auth group drivers instance if you want groups defined by a specific driver.</p>
|
| 999 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the group id's are unique over <strong>all</strong> drivers!</p>
|
| 1000 |
+
</article>
|
| 1001 |
+
|
| 1002 |
+
<article>
|
| 1003 |
+
<h4 id="method_roles" class="method">roles($driver = null)</h4>
|
| 1004 |
+
<p>The <strong>roles</strong> method allows you to fetch all defined roles, or all defined roles in a specific driver.</p>
|
| 1005 |
+
<table class="method">
|
| 1006 |
+
<tbody>
|
| 1007 |
+
<tr>
|
| 1008 |
+
<th class="legend">Static</th>
|
| 1009 |
+
<td>Yes</td>
|
| 1010 |
+
</tr>
|
| 1011 |
+
<tr>
|
| 1012 |
+
<th>Parameters</th>
|
| 1013 |
+
<td>
|
| 1014 |
+
<table class="parameters">
|
| 1015 |
+
<tr>
|
| 1016 |
+
<th>Param</th>
|
| 1017 |
+
<th>Default</th>
|
| 1018 |
+
<th class="description">Description</th>
|
| 1019 |
+
</tr>
|
| 1020 |
+
<tr>
|
| 1021 |
+
<th><kbd>$driver</kbd></th>
|
| 1022 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1023 |
+
<td>The name of the group driver you want to get roles of</td>
|
| 1024 |
+
</tr>
|
| 1025 |
+
</table>
|
| 1026 |
+
</td>
|
| 1027 |
+
</tr>
|
| 1028 |
+
<tr>
|
| 1029 |
+
<th>Returns</th>
|
| 1030 |
+
<td>array. If the acl driver does not exist or no roles are defined, an empty array is returned.</td>
|
| 1031 |
+
</tr>
|
| 1032 |
+
<tr>
|
| 1033 |
+
<th>Example</th>
|
| 1034 |
+
<td>
|
| 1035 |
+
<pre class="php"><code>// Get all defined roles (for all loaded acl drivers)
|
| 1036 |
+
$roles = Auth::roles();
|
| 1037 |
+
|
| 1038 |
+
// Get all the roles from the default acl driver
|
| 1039 |
+
$roles = Auth::acl()->roles();
|
| 1040 |
+
|
| 1041 |
+
// Get all the roles from a specific driver
|
| 1042 |
+
$roles = Auth::acl('Simpleacl')->roles();
|
| 1043 |
+
</code></pre>
|
| 1044 |
+
</td>
|
| 1045 |
+
</tr>
|
| 1046 |
+
</tbody>
|
| 1047 |
+
</table>
|
| 1048 |
+
<p class="note">You need to call this method on the Auth acl drivers instance if you want groups defined by a specific driver.</p>
|
| 1049 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the role id's are unique over <strong>all</strong> drivers!</p>
|
| 1050 |
+
</article>
|
| 1051 |
+
|
| 1052 |
+
<article>
|
| 1053 |
+
<h4 id="method_get_name" class="method">get_name($group = null)</h4>
|
| 1054 |
+
<p>The <strong>get_name</strong> method allows you to fetch the name of a specific group. If no group is given, it will return the name
|
| 1055 |
+
of the group of the current logged-in user.</p>
|
| 1056 |
+
<table class="method">
|
| 1057 |
+
<tbody>
|
| 1058 |
+
<tr>
|
| 1059 |
+
<th class="legend">Static</th>
|
| 1060 |
+
<td>No</td>
|
| 1061 |
+
</tr>
|
| 1062 |
+
<tr>
|
| 1063 |
+
<th>Parameters</th>
|
| 1064 |
+
<td>
|
| 1065 |
+
<table class="parameters">
|
| 1066 |
+
<tr>
|
| 1067 |
+
<th>Param</th>
|
| 1068 |
+
<th>Default</th>
|
| 1069 |
+
<th class="description">Description</th>
|
| 1070 |
+
</tr>
|
| 1071 |
+
<tr>
|
| 1072 |
+
<th><kbd>$group</kbd></th>
|
| 1073 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1074 |
+
<td>The id of the group you want to get the name of</td>
|
| 1075 |
+
</tr>
|
| 1076 |
+
</table>
|
| 1077 |
+
</td>
|
| 1078 |
+
</tr>
|
| 1079 |
+
<tr>
|
| 1080 |
+
<th>Returns</th>
|
| 1081 |
+
<td>mixed. The name of the group, or <kbd>null</kbd> if a group with the given id does not exist.</td>
|
| 1082 |
+
</tr>
|
| 1083 |
+
<tr>
|
| 1084 |
+
<th>Example</th>
|
| 1085 |
+
<td>
|
| 1086 |
+
<pre class="php"><code>// Get all the name for the group of the current logged-in user
|
| 1087 |
+
$name = Auth::group()->get_name();
|
| 1088 |
+
|
| 1089 |
+
// Get the name of a specific group from a specific driver
|
| 1090 |
+
$name = Auth::group('Simplegroup')->get_name(100); // returns 'Administrators'
|
| 1091 |
+
</code></pre>
|
| 1092 |
+
</td>
|
| 1093 |
+
</tr>
|
| 1094 |
+
</tbody>
|
| 1095 |
+
</table>
|
| 1096 |
+
<p class="note">If you use multiple drivers, this method only works reliably if the group id's are unique over <strong>all</strong> drivers!</p>
|
| 1097 |
+
</article>
|
| 1098 |
+
|
| 1099 |
+
<article>
|
| 1100 |
+
<h4 id="method_has_access" class="method">has_access($condition)</h4>
|
| 1101 |
+
<p>The <strong>has_access</strong> method allows you to check if the current logged-in user has access to a specific location with specific rights.</p>
|
| 1102 |
+
<table class="method">
|
| 1103 |
+
<tbody>
|
| 1104 |
+
<tr>
|
| 1105 |
+
<th class="legend">Static</th>
|
| 1106 |
+
<td>Yes</td>
|
| 1107 |
+
</tr>
|
| 1108 |
+
<tr>
|
| 1109 |
+
<th>Parameters</th>
|
| 1110 |
+
<td>
|
| 1111 |
+
<table class="parameters">
|
| 1112 |
+
<tr>
|
| 1113 |
+
<th>Param</th>
|
| 1114 |
+
<th>Default</th>
|
| 1115 |
+
<th class="description">Description</th>
|
| 1116 |
+
</tr>
|
| 1117 |
+
<tr>
|
| 1118 |
+
<th><kbd>$condition</kbd></th>
|
| 1119 |
+
<td>required</td>
|
| 1120 |
+
<td>The access condition you want to check</td>
|
| 1121 |
+
</tr>
|
| 1122 |
+
</table>
|
| 1123 |
+
</td>
|
| 1124 |
+
</tr>
|
| 1125 |
+
<tr>
|
| 1126 |
+
<th>Returns</th>
|
| 1127 |
+
<td>boolean. <strong>true</strong> if the user has access, or <strong>false</strong> if not.</td>
|
| 1128 |
+
</tr>
|
| 1129 |
+
<tr>
|
| 1130 |
+
<th>Example</th>
|
| 1131 |
+
<td>
|
| 1132 |
+
<pre class="php"><code>// check if the user has access to read blog posts
|
| 1133 |
+
if (Auth::has_access('blog.read'))
|
| 1134 |
+
{
|
| 1135 |
+
// yes, the user has access
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
// if you have multiple login instances, use the instance to call this method.
|
| 1139 |
+
// you can also check for multiple rights in one go
|
| 1140 |
+
if (Auth::instance('simpleauth')->has_access('blog.[read,write,delete]'))
|
| 1141 |
+
{
|
| 1142 |
+
// yes, the user has access and may read, write and delete
|
| 1143 |
+
}
|
| 1144 |
+
|
| 1145 |
+
// you can also specify the rights to check as an array
|
| 1146 |
+
if (Auth::has_access(array('blog' => array('read'), 'comments' => array('read')))
|
| 1147 |
+
{
|
| 1148 |
+
// yes, the user has access to read blogs and comments
|
| 1149 |
+
}
|
| 1150 |
+
|
| 1151 |
+
// if you have multiple login instances, you can also pick a specific ACL driver
|
| 1152 |
+
if (Auth::acl('simpleacl')->has_access('blog.[read,write,delete]'))
|
| 1153 |
+
{
|
| 1154 |
+
// yes, the user has access and may read, write and delete
|
| 1155 |
+
}
|
| 1156 |
+
</code></pre>
|
| 1157 |
+
</td>
|
| 1158 |
+
</tr>
|
| 1159 |
+
</tbody>
|
| 1160 |
+
</table>
|
| 1161 |
+
</article>
|
| 1162 |
+
|
| 1163 |
+
<article>
|
| 1164 |
+
<h4 id="method_guest_login" class="method">guest_login()</h4>
|
| 1165 |
+
<p>The <strong>guest_login</strong> allows you to check if guest access is enabled.</p>
|
| 1166 |
+
<table class="method">
|
| 1167 |
+
<tbody>
|
| 1168 |
+
<tr>
|
| 1169 |
+
<th class="legend">Static</th>
|
| 1170 |
+
<td>Yes</td>
|
| 1171 |
+
</tr>
|
| 1172 |
+
<tr>
|
| 1173 |
+
<th>Parameters</th>
|
| 1174 |
+
<td>
|
| 1175 |
+
None
|
| 1176 |
+
</td>
|
| 1177 |
+
</tr>
|
| 1178 |
+
<tr>
|
| 1179 |
+
<th>Returns</th>
|
| 1180 |
+
<td>boolean. returns <strong>true</strong> if the guest support is enabled, or <strong>false</strong> if not.</td>
|
| 1181 |
+
</tr>
|
| 1182 |
+
<tr>
|
| 1183 |
+
<th>Example</th>
|
| 1184 |
+
<td>
|
| 1185 |
+
<pre class="php"><code>// redirect to login if we we require a user and no guest access is enabled
|
| 1186 |
+
if ( ! Auth::check() and ! Auth::guest_login())
|
| 1187 |
+
{
|
| 1188 |
+
Response::redirect('/login');
|
| 1189 |
+
}
|
| 1190 |
+
</code></pre>
|
| 1191 |
+
</td>
|
| 1192 |
+
</tr>
|
| 1193 |
+
</tbody>
|
| 1194 |
+
</table>
|
| 1195 |
+
</article>
|
| 1196 |
+
|
| 1197 |
+
<article>
|
| 1198 |
+
<h4 id="method_remember_me" class="method">remember_me($user_id = null)</h4>
|
| 1199 |
+
<p>The <strong>remember_me</strong> method allows you to set a remember_me cookie. If $user_id is not given, the current logged-in user is used.</p>
|
| 1200 |
+
<table class="method">
|
| 1201 |
+
<tbody>
|
| 1202 |
+
<tr>
|
| 1203 |
+
<th class="legend">Static</th>
|
| 1204 |
+
<td>Yes</td>
|
| 1205 |
+
</tr>
|
| 1206 |
+
<tr>
|
| 1207 |
+
<th>Parameters</th>
|
| 1208 |
+
<td>
|
| 1209 |
+
<table class="parameters">
|
| 1210 |
+
<tr>
|
| 1211 |
+
<th>Param</th>
|
| 1212 |
+
<th>Default</th>
|
| 1213 |
+
<th class="description">Description</th>
|
| 1214 |
+
</tr>
|
| 1215 |
+
<tr>
|
| 1216 |
+
<th><kbd>$user_id</kbd></th>
|
| 1217 |
+
<td><pre class="php"><code>null</code></pre></td>
|
| 1218 |
+
<td>The id of the user to be remembered</td>
|
| 1219 |
+
</tr>
|
| 1220 |
+
</table>
|
| 1221 |
+
</td>
|
| 1222 |
+
</tr>
|
| 1223 |
+
<tr>
|
| 1224 |
+
<th>Returns</th>
|
| 1225 |
+
<td>
|
| 1226 |
+
boolean. returns <strong>true</strong> if the remember me cookie was correctly set, or <strong>false</strong>
|
| 1227 |
+
if there was no user_id present, or the remember_me functionality was disabled in the configuration.
|
| 1228 |
+
</td>
|
| 1229 |
+
</tr>
|
| 1230 |
+
<tr>
|
| 1231 |
+
<th>Example</th>
|
| 1232 |
+
<td>
|
| 1233 |
+
<pre class="php"><code>// process the login form POST, and set the remember-me cookie if needed
|
| 1234 |
+
if (\Input::method() == 'POST')
|
| 1235 |
+
{
|
| 1236 |
+
// check the credentials.
|
| 1237 |
+
if (\Auth::instance()->login(\Input::param('username'), \Input::param('password')))
|
| 1238 |
+
{
|
| 1239 |
+
// does the user want to be remembered?
|
| 1240 |
+
if (\Input::param('rememberme', false))
|
| 1241 |
+
{
|
| 1242 |
+
// create the remember-me cookie
|
| 1243 |
+
\Auth::remember_me();
|
| 1244 |
+
}
|
| 1245 |
+
else
|
| 1246 |
+
{
|
| 1247 |
+
// delete the remember-me cookie if present
|
| 1248 |
+
\Auth::dont_remember_me();
|
| 1249 |
+
}
|
| 1250 |
+
|
| 1251 |
+
// logged in, go the homepage
|
| 1252 |
+
\Response::redirect('/');
|
| 1253 |
+
}
|
| 1254 |
+
else
|
| 1255 |
+
{
|
| 1256 |
+
// login failed, show an error message
|
| 1257 |
+
$data['username'] = \Input::param('username');
|
| 1258 |
+
$data['login_error'] = \Lang::get('login.failure');
|
| 1259 |
+
}
|
| 1260 |
+
}
|
| 1261 |
+
</code></pre>
|
| 1262 |
+
</td>
|
| 1263 |
+
</tr>
|
| 1264 |
+
</tbody>
|
| 1265 |
+
</table>
|
| 1266 |
+
</article>
|
| 1267 |
+
|
| 1268 |
+
<article>
|
| 1269 |
+
<h4 id="method_dont_remember_me" class="method">dont_remember_me()</h4>
|
| 1270 |
+
<p>The <strong>dont_remember_me</strong> method destroys the remember_me cookie, if present.</p>
|
| 1271 |
+
<table class="method">
|
| 1272 |
+
<tbody>
|
| 1273 |
+
<tr>
|
| 1274 |
+
<th class="legend">Static</th>
|
| 1275 |
+
<td>Yes</td>
|
| 1276 |
+
</tr>
|
| 1277 |
+
<tr>
|
| 1278 |
+
<th>Parameters</th>
|
| 1279 |
+
<td>
|
| 1280 |
+
None
|
| 1281 |
+
</td>
|
| 1282 |
+
</tr>
|
| 1283 |
+
<tr>
|
| 1284 |
+
<th>Example</th>
|
| 1285 |
+
<td>
|
| 1286 |
+
See <a href="#method_remember_me">remember_me()</a> for an example
|
| 1287 |
+
</td>
|
| 1288 |
+
</tr>
|
| 1289 |
+
</tbody>
|
| 1290 |
+
</table>
|
| 1291 |
+
</article>
|
| 1292 |
+
</div>
|
| 1293 |
+
|
| 1294 |
+
<footer>
|
| 1295 |
+
<p>
|
| 1296 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 1297 |
+
</p>
|
| 1298 |
+
</footer>
|
| 1299 |
+
</div>
|
| 1300 |
+
</body>
|
| 1301 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/acl.html
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>ACL - Driver types - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
<h2>Auth package</h2>
|
| 48 |
+
|
| 49 |
+
<p>The Auth package provides a standardized interface for authentication in Fuel. This allows our users to
|
| 50 |
+
write their own drivers and easily integrate a new driver to work with old code by keeping the basic methods
|
| 51 |
+
consistent.</p>
|
| 52 |
+
|
| 53 |
+
<section>
|
| 54 |
+
<h2 id="driver_types">Auth_Acl_Driver</h2>
|
| 55 |
+
|
| 56 |
+
<p>
|
| 57 |
+
This driver is the base class for all Auth acl drivers. It is defined as an abstract class which contains
|
| 58 |
+
all methods generic to all acl drivers, and abstract method definitions for all methods any acl driver
|
| 59 |
+
MUST implement.
|
| 60 |
+
</p>
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
<h3 id="static">Static interface</h3>
|
| 64 |
+
|
| 65 |
+
<p>For ease of use, the <kbd>has_access()</kbd> method is exposed through the generic Auth static interface.</p>
|
| 66 |
+
|
| 67 |
+
<p>Using the static interface, you can do</p>
|
| 68 |
+
|
| 69 |
+
<pre class="php"><code>// returns true if the current user has the required permissions
|
| 70 |
+
$may_access_comments = Auth::has_access('comments[read,write]');
|
| 71 |
+
</code></pre>
|
| 72 |
+
|
| 73 |
+
<h3 id="generic_methods">Generic methods</h3>
|
| 74 |
+
|
| 75 |
+
<p>
|
| 76 |
+
Generic methods are defined in the acl base driver, and are available to all Auth acl drivers through
|
| 77 |
+
extension. These methods provide functions to interact with specific acls, and to check for access.
|
| 78 |
+
</p>
|
| 79 |
+
<p class="note">The methods defined in the classes but not documented here are used internally, and should not be called directly.</p>
|
| 80 |
+
|
| 81 |
+
<article>
|
| 82 |
+
<h4 id="method_get_id" class="method">get_id()</h4>
|
| 83 |
+
<p>Returns the drivers unique id. This can be used to identify the driver, or to select a specific driver instance.</p>
|
| 84 |
+
<table class="method">
|
| 85 |
+
<tbody>
|
| 86 |
+
<tr>
|
| 87 |
+
<th class="legend">Static</th>
|
| 88 |
+
<td>No</td>
|
| 89 |
+
</tr>
|
| 90 |
+
<tr>
|
| 91 |
+
<th>Parameters</th>
|
| 92 |
+
<td>
|
| 93 |
+
None
|
| 94 |
+
</td>
|
| 95 |
+
</tr>
|
| 96 |
+
<tr>
|
| 97 |
+
<th>Returns</th>
|
| 98 |
+
<td>The drivers id string.</td>
|
| 99 |
+
</tr>
|
| 100 |
+
<tr>
|
| 101 |
+
<th>Example</th>
|
| 102 |
+
<td>
|
| 103 |
+
<pre class="php"><code>// returns 'simpleacl'
|
| 104 |
+
$id = Auth::acl()->get_id();
|
| 105 |
+
</code></pre>
|
| 106 |
+
</td>
|
| 107 |
+
</tr>
|
| 108 |
+
</tbody>
|
| 109 |
+
</table>
|
| 110 |
+
</article>
|
| 111 |
+
|
| 112 |
+
<article>
|
| 113 |
+
<h4 id="method_set_config" class="method">set_config($key, $value)</h4>
|
| 114 |
+
<p>Sets a driver configuration value.</p>
|
| 115 |
+
<table class="method">
|
| 116 |
+
<tbody>
|
| 117 |
+
<tr>
|
| 118 |
+
<th class="legend">Static</th>
|
| 119 |
+
<td>No</td>
|
| 120 |
+
</tr>
|
| 121 |
+
<tr>
|
| 122 |
+
<th>Parameters</th>
|
| 123 |
+
<td>
|
| 124 |
+
<table class="parameters">
|
| 125 |
+
<tr>
|
| 126 |
+
<th>Param</th>
|
| 127 |
+
<th>Default</th>
|
| 128 |
+
<th class="description">Description</th>
|
| 129 |
+
</tr>
|
| 130 |
+
<tr>
|
| 131 |
+
<th><kbd>$key</kbd></th>
|
| 132 |
+
<td>required</td>
|
| 133 |
+
<td>Configuration key name</td>
|
| 134 |
+
</tr>
|
| 135 |
+
<tr>
|
| 136 |
+
<th><kbd>$value</kbd></th>
|
| 137 |
+
<td>required</td>
|
| 138 |
+
<td>Value for this configuration key</td>
|
| 139 |
+
</tr>
|
| 140 |
+
</table>
|
| 141 |
+
</td>
|
| 142 |
+
</tr>
|
| 143 |
+
<tr>
|
| 144 |
+
<th>Returns</th>
|
| 145 |
+
<td>void</td>
|
| 146 |
+
</tr>
|
| 147 |
+
<tr>
|
| 148 |
+
<th>Example</th>
|
| 149 |
+
<td>
|
| 150 |
+
<pre class="php"><code>// set a config value on the simpleacl driver
|
| 151 |
+
Auth::acl()->set_config('key', 'value');
|
| 152 |
+
</code></pre>
|
| 153 |
+
</td>
|
| 154 |
+
</tr>
|
| 155 |
+
</tbody>
|
| 156 |
+
</table>
|
| 157 |
+
</article>
|
| 158 |
+
|
| 159 |
+
<article>
|
| 160 |
+
<h4 id="method_get_config" class="method">get_config($key, $default = null)</h4>
|
| 161 |
+
<p>Gets a driver configuration value.</p>
|
| 162 |
+
<table class="method">
|
| 163 |
+
<tbody>
|
| 164 |
+
<tr>
|
| 165 |
+
<th class="legend">Static</th>
|
| 166 |
+
<td>No</td>
|
| 167 |
+
</tr>
|
| 168 |
+
<tr>
|
| 169 |
+
<th>Parameters</th>
|
| 170 |
+
<td>
|
| 171 |
+
<table class="parameters">
|
| 172 |
+
<tr>
|
| 173 |
+
<th>Param</th>
|
| 174 |
+
<th>Default</th>
|
| 175 |
+
<th class="description">Description</th>
|
| 176 |
+
</tr>
|
| 177 |
+
<tr>
|
| 178 |
+
<th><kbd>$key</kbd></th>
|
| 179 |
+
<td>required</td>
|
| 180 |
+
<td>Configuration key name</td>
|
| 181 |
+
</tr>
|
| 182 |
+
<tr>
|
| 183 |
+
<th><kbd>$default</kbd></th>
|
| 184 |
+
<td><i>null</i></td>
|
| 185 |
+
<td>Default value to be returned if the requested key does not exist</td>
|
| 186 |
+
</tr>
|
| 187 |
+
</table>
|
| 188 |
+
</td>
|
| 189 |
+
</tr>
|
| 190 |
+
<tr>
|
| 191 |
+
<th>Returns</th>
|
| 192 |
+
<td>mixed</td>
|
| 193 |
+
</tr>
|
| 194 |
+
<tr>
|
| 195 |
+
<th>Example</th>
|
| 196 |
+
<td>
|
| 197 |
+
<pre class="php"><code>// get a config value of the simpleacl driver, return false if it doesn't exist
|
| 198 |
+
$key = Auth::instance(simpleacl)->get_config('key', false);
|
| 199 |
+
</code></pre>
|
| 200 |
+
</td>
|
| 201 |
+
</tr>
|
| 202 |
+
</tbody>
|
| 203 |
+
</table>
|
| 204 |
+
</article>
|
| 205 |
+
|
| 206 |
+
<h3 id="abstract_methods">Abstract methods</h3>
|
| 207 |
+
|
| 208 |
+
<p>
|
| 209 |
+
Every acl driver you develop MUST provide all of these methods, and the MUST return the values documented here.
|
| 210 |
+
</p>
|
| 211 |
+
|
| 212 |
+
<article>
|
| 213 |
+
<h4 id="method_has_access" class="method">has_access($condition, Array $entity)</h4>
|
| 214 |
+
<p>The <strong>has_access</strong> method uses the defined ACL drivers to check the users access according to the given condition.</p>
|
| 215 |
+
<table class="method">
|
| 216 |
+
<tbody>
|
| 217 |
+
<tr>
|
| 218 |
+
<th class="legend">Static</th>
|
| 219 |
+
<td>No</td>
|
| 220 |
+
</tr>
|
| 221 |
+
<tr>
|
| 222 |
+
<th>Parameters</th>
|
| 223 |
+
<td>
|
| 224 |
+
<table class="parameters">
|
| 225 |
+
<tr>
|
| 226 |
+
<th>Param</th>
|
| 227 |
+
<th>Default</th>
|
| 228 |
+
<th class="description">Description</th>
|
| 229 |
+
</tr>
|
| 230 |
+
<tr>
|
| 231 |
+
<th><kbd>$condition</kbd></th>
|
| 232 |
+
<td>required</td>
|
| 233 |
+
<td>takes a location and the required rights on the location as either a string or
|
| 234 |
+
an array</td>
|
| 235 |
+
</tr>
|
| 236 |
+
<tr>
|
| 237 |
+
<th><kbd>$entity</kbd></th>
|
| 238 |
+
<td>required</td>
|
| 239 |
+
<td>user or group identifier in the form of array(driver_id, id).</td>
|
| 240 |
+
</tr>
|
| 241 |
+
</table>
|
| 242 |
+
</td>
|
| 243 |
+
</tr>
|
| 244 |
+
<tr>
|
| 245 |
+
<th>Returns</th>
|
| 246 |
+
<td>boolean, <strong>true</strong> if access was granted, <strong>false</strong> if not.</td>
|
| 247 |
+
</tr>
|
| 248 |
+
<tr>
|
| 249 |
+
<th>Example</th>
|
| 250 |
+
<td>
|
| 251 |
+
<pre class="php"><code>// check if user is allowed to comment
|
| 252 |
+
if ( ! Auth::acl()->has_access('comments.create'), array('simplegroup', 1))
|
| 253 |
+
{
|
| 254 |
+
Response::redirect('no_admin');
|
| 255 |
+
}</code></pre>
|
| 256 |
+
</td>
|
| 257 |
+
</tr>
|
| 258 |
+
</tbody>
|
| 259 |
+
</table>
|
| 260 |
+
</article>
|
| 261 |
+
|
| 262 |
+
</section>
|
| 263 |
+
|
| 264 |
+
</div>
|
| 265 |
+
|
| 266 |
+
<footer>
|
| 267 |
+
<p>
|
| 268 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 269 |
+
</p>
|
| 270 |
+
</footer>
|
| 271 |
+
</div>
|
| 272 |
+
</body>
|
| 273 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/group.html
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Group - Driver types - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
<h2>Auth package</h2>
|
| 48 |
+
|
| 49 |
+
<p>The Auth package provides a standardized interface for authentication in Fuel. This allows our users to
|
| 50 |
+
write their own drivers and easily integrate a new driver to work with old code by keeping the basic methods
|
| 51 |
+
consistent.</p>
|
| 52 |
+
|
| 53 |
+
<section>
|
| 54 |
+
<h2 id="driver_types">Auth_Group_Driver</h2>
|
| 55 |
+
|
| 56 |
+
<p>
|
| 57 |
+
This driver is the base class for all Auth group drivers. It is defined as an abstract class which contains
|
| 58 |
+
all methods generic to all group drivers, and abstract method definitions for all methods any group driver
|
| 59 |
+
MUST implement.
|
| 60 |
+
</p>
|
| 61 |
+
|
| 62 |
+
<h3 id="driver_config">Driver configuration</h3>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
A group driver can load additional drivers that it depends on. Generally, these are ACL drivers. But your implementation
|
| 66 |
+
could introduce and use custom driver types as well. To do so, add this structure to your driver class:
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<pre class="php"><code>// autoload the Simpleacl acl driver when loading this group driver
|
| 70 |
+
protected $config = array(
|
| 71 |
+
'drivers' => array('acl' => array('Simpleacl'))
|
| 72 |
+
);
|
| 73 |
+
</code></pre>
|
| 74 |
+
|
| 75 |
+
<h3 id="static">Static interface</h3>
|
| 76 |
+
|
| 77 |
+
<p>For ease of use, the <kbd>member()</kbd> method is exposed through the generic Auth static interface.</p>
|
| 78 |
+
|
| 79 |
+
<p>Using the static interface, you can do</p>
|
| 80 |
+
|
| 81 |
+
<pre class="php"><code>// returns true if the current user is member of group 16.
|
| 82 |
+
$is_member = Auth::member(16);
|
| 83 |
+
</code></pre>
|
| 84 |
+
|
| 85 |
+
<h3 id="generic_methods">Generic methods</h3>
|
| 86 |
+
|
| 87 |
+
<p>
|
| 88 |
+
Generic methods are defined in the group base driver, and are available to all Auth group drivers through
|
| 89 |
+
extension. These methods provide functions to interact with groups, and to check for access.
|
| 90 |
+
</p>
|
| 91 |
+
<p class="note">The methods defined in the classes but not documented here are used internally, and should not be called directly.</p>
|
| 92 |
+
|
| 93 |
+
<article>
|
| 94 |
+
<h4 id="method_get_id" class="method">get_id()</h4>
|
| 95 |
+
<p>Returns the drivers unique id. This can be used to identify the driver, or to select a specific driver instance.</p>
|
| 96 |
+
<table class="method">
|
| 97 |
+
<tbody>
|
| 98 |
+
<tr>
|
| 99 |
+
<th class="legend">Static</th>
|
| 100 |
+
<td>No</td>
|
| 101 |
+
</tr>
|
| 102 |
+
<tr>
|
| 103 |
+
<th>Parameters</th>
|
| 104 |
+
<td>
|
| 105 |
+
None
|
| 106 |
+
</td>
|
| 107 |
+
</tr>
|
| 108 |
+
<tr>
|
| 109 |
+
<th>Returns</th>
|
| 110 |
+
<td>The drivers id string.</td>
|
| 111 |
+
</tr>
|
| 112 |
+
<tr>
|
| 113 |
+
<th>Example</th>
|
| 114 |
+
<td>
|
| 115 |
+
<pre class="php"><code>// returns 'simpleauth'
|
| 116 |
+
$id = Auth::group()->get_id();
|
| 117 |
+
</code></pre>
|
| 118 |
+
</td>
|
| 119 |
+
</tr>
|
| 120 |
+
</tbody>
|
| 121 |
+
</table>
|
| 122 |
+
</article>
|
| 123 |
+
|
| 124 |
+
<article>
|
| 125 |
+
<h4 id="method_set_config" class="method">set_config($key, $value)</h4>
|
| 126 |
+
<p>Sets a driver configuration value.</p>
|
| 127 |
+
<table class="method">
|
| 128 |
+
<tbody>
|
| 129 |
+
<tr>
|
| 130 |
+
<th class="legend">Static</th>
|
| 131 |
+
<td>No</td>
|
| 132 |
+
</tr>
|
| 133 |
+
<tr>
|
| 134 |
+
<th>Parameters</th>
|
| 135 |
+
<td>
|
| 136 |
+
<table class="parameters">
|
| 137 |
+
<tr>
|
| 138 |
+
<th>Param</th>
|
| 139 |
+
<th>Default</th>
|
| 140 |
+
<th class="description">Description</th>
|
| 141 |
+
</tr>
|
| 142 |
+
<tr>
|
| 143 |
+
<th><kbd>$key</kbd></th>
|
| 144 |
+
<td>required</td>
|
| 145 |
+
<td>Configuration key name</td>
|
| 146 |
+
</tr>
|
| 147 |
+
<tr>
|
| 148 |
+
<th><kbd>$value</kbd></th>
|
| 149 |
+
<td>required</td>
|
| 150 |
+
<td>Value for this configuration key</td>
|
| 151 |
+
</tr>
|
| 152 |
+
</table>
|
| 153 |
+
</td>
|
| 154 |
+
</tr>
|
| 155 |
+
<tr>
|
| 156 |
+
<th>Returns</th>
|
| 157 |
+
<td>void</td>
|
| 158 |
+
</tr>
|
| 159 |
+
<tr>
|
| 160 |
+
<th>Example</th>
|
| 161 |
+
<td>
|
| 162 |
+
<pre class="php"><code>// set a config value on the simplegroup driver
|
| 163 |
+
Auth::group()->set_config('key', 'value');
|
| 164 |
+
</code></pre>
|
| 165 |
+
</td>
|
| 166 |
+
</tr>
|
| 167 |
+
</tbody>
|
| 168 |
+
</table>
|
| 169 |
+
</article>
|
| 170 |
+
|
| 171 |
+
<article>
|
| 172 |
+
<h4 id="method_get_config" class="method">get_config($key, $default = null)</h4>
|
| 173 |
+
<p>Gets a driver configuration value.</p>
|
| 174 |
+
<table class="method">
|
| 175 |
+
<tbody>
|
| 176 |
+
<tr>
|
| 177 |
+
<th class="legend">Static</th>
|
| 178 |
+
<td>No</td>
|
| 179 |
+
</tr>
|
| 180 |
+
<tr>
|
| 181 |
+
<th>Parameters</th>
|
| 182 |
+
<td>
|
| 183 |
+
<table class="parameters">
|
| 184 |
+
<tr>
|
| 185 |
+
<th>Param</th>
|
| 186 |
+
<th>Default</th>
|
| 187 |
+
<th class="description">Description</th>
|
| 188 |
+
</tr>
|
| 189 |
+
<tr>
|
| 190 |
+
<th><kbd>$key</kbd></th>
|
| 191 |
+
<td>required</td>
|
| 192 |
+
<td>Configuration key name</td>
|
| 193 |
+
</tr>
|
| 194 |
+
<tr>
|
| 195 |
+
<th><kbd>$default</kbd></th>
|
| 196 |
+
<td><i>null</i></td>
|
| 197 |
+
<td>Default value to be returned if the requested key does not exist</td>
|
| 198 |
+
</tr>
|
| 199 |
+
</table>
|
| 200 |
+
</td>
|
| 201 |
+
</tr>
|
| 202 |
+
<tr>
|
| 203 |
+
<th>Returns</th>
|
| 204 |
+
<td>mixed</td>
|
| 205 |
+
</tr>
|
| 206 |
+
<tr>
|
| 207 |
+
<th>Example</th>
|
| 208 |
+
<td>
|
| 209 |
+
<pre class="php"><code>// get a config value of the simplegroup driver, return false if it doesn't exist
|
| 210 |
+
$key = Auth::instance(simplegroup)->get_config('key', false);
|
| 211 |
+
</code></pre>
|
| 212 |
+
</td>
|
| 213 |
+
</tr>
|
| 214 |
+
</tbody>
|
| 215 |
+
</table>
|
| 216 |
+
</article>
|
| 217 |
+
|
| 218 |
+
<h3 id="abstract_methods">Abstract methods</h3>
|
| 219 |
+
|
| 220 |
+
<p>
|
| 221 |
+
Every group driver you develop MUST provide all of these methods, and the MUST return the values documented here.
|
| 222 |
+
</p>
|
| 223 |
+
|
| 224 |
+
<article>
|
| 225 |
+
<h4 id="method_member" class="method">member($group, $specific = null)</h4>
|
| 226 |
+
<p>Checks if user is a member of the given group in either all loaded Group drivers or just those
|
| 227 |
+
specified as the 2nd parameter.</p>
|
| 228 |
+
<table class="method">
|
| 229 |
+
<tbody>
|
| 230 |
+
<tr>
|
| 231 |
+
<th class="legend">Static</th>
|
| 232 |
+
<td>Yes</td>
|
| 233 |
+
</tr>
|
| 234 |
+
<tr>
|
| 235 |
+
<th>Parameters</th>
|
| 236 |
+
<td>
|
| 237 |
+
<table class="parameters">
|
| 238 |
+
<tr>
|
| 239 |
+
<th>Param</th>
|
| 240 |
+
<th>Default</th>
|
| 241 |
+
<th class="description">Description</th>
|
| 242 |
+
</tr>
|
| 243 |
+
<tr>
|
| 244 |
+
<th><kbd>$group</kbd></th>
|
| 245 |
+
<td><i>required</i></td>
|
| 246 |
+
<td>group id</td>
|
| 247 |
+
</tr>
|
| 248 |
+
<tr>
|
| 249 |
+
<th><kbd>$specific</kbd></th>
|
| 250 |
+
<td><i>null</i></td>
|
| 251 |
+
<td>null to check all or one ore more driver id's (single string or array of strings)</td>
|
| 252 |
+
</tr>
|
| 253 |
+
</table>
|
| 254 |
+
</td>
|
| 255 |
+
</tr>
|
| 256 |
+
<tr>
|
| 257 |
+
<th>Returns</th>
|
| 258 |
+
<td>bool, whether one of the (given) drivers had the current user registered as a member</td>
|
| 259 |
+
</tr>
|
| 260 |
+
<tr>
|
| 261 |
+
<th>Example</th>
|
| 262 |
+
<td>
|
| 263 |
+
<pre class="php"><code>if ( ! Auth::member(100) )
|
| 264 |
+
{
|
| 265 |
+
Response::redirect('no_admin');
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
// specific driver
|
| 269 |
+
Auth::member(1, 'simplegroup');
|
| 270 |
+
|
| 271 |
+
// Multiple drivers
|
| 272 |
+
Auth::member(0, array('simplegroup', 'genericgroup'));</code></pre>
|
| 273 |
+
</td>
|
| 274 |
+
</tr>
|
| 275 |
+
</tbody>
|
| 276 |
+
</table>
|
| 277 |
+
</article>
|
| 278 |
+
|
| 279 |
+
<article>
|
| 280 |
+
<h4 id="method_get_name" class="method">get_name($group)</h4>
|
| 281 |
+
<p>Get the display name of the given group name.</p>
|
| 282 |
+
<table class="method">
|
| 283 |
+
<tbody>
|
| 284 |
+
<tr>
|
| 285 |
+
<th class="legend">Static</th>
|
| 286 |
+
<td>Yes</td>
|
| 287 |
+
</tr>
|
| 288 |
+
<tr>
|
| 289 |
+
<th>Parameters</th>
|
| 290 |
+
<td>
|
| 291 |
+
<table class="parameters">
|
| 292 |
+
<tr>
|
| 293 |
+
<th>Param</th>
|
| 294 |
+
<th>Default</th>
|
| 295 |
+
<th class="description">Description</th>
|
| 296 |
+
</tr>
|
| 297 |
+
<tr>
|
| 298 |
+
<th><kbd>$group</kbd></th>
|
| 299 |
+
<td><i>null</i></td>
|
| 300 |
+
<td>name of the group you want to get the display name of</td>
|
| 301 |
+
</tr>
|
| 302 |
+
</table>
|
| 303 |
+
</td>
|
| 304 |
+
</tr>
|
| 305 |
+
<tr>
|
| 306 |
+
<th>Returns</th>
|
| 307 |
+
<td>mixed, the retrieved group display name, or <strong>false</strong> if the given group does not exist.</td>
|
| 308 |
+
</tr>
|
| 309 |
+
<tr>
|
| 310 |
+
<th>Example</th>
|
| 311 |
+
<td>
|
| 312 |
+
<pre class="php"><code>// get the display name of the admin group
|
| 313 |
+
Auth::group()->get_name('admin');</code></pre>
|
| 314 |
+
</td>
|
| 315 |
+
</tr>
|
| 316 |
+
</tbody>
|
| 317 |
+
</table>
|
| 318 |
+
</article>
|
| 319 |
+
|
| 320 |
+
</section>
|
| 321 |
+
|
| 322 |
+
</div>
|
| 323 |
+
|
| 324 |
+
<footer>
|
| 325 |
+
<p>
|
| 326 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 327 |
+
</p>
|
| 328 |
+
</footer>
|
| 329 |
+
</div>
|
| 330 |
+
</body>
|
| 331 |
+
</html>
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/docs/packages/auth/types/login.html
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="./../../../assets/css/combined.css">
|
| 7 |
+
<link rel="shortcut icon" href="./../../../favicon.ico" />
|
| 8 |
+
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
| 9 |
+
<script type="text/javascript">
|
| 10 |
+
var path = './../../../';
|
| 11 |
+
var class_prefix = "$object->";
|
| 12 |
+
</script>
|
| 13 |
+
<script src="./../../../assets/js/combined.js"></script>
|
| 14 |
+
<title>Login - Driver types - Auth Package - FuelPHP Documentation</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<div id="container">
|
| 18 |
+
<header id="header">
|
| 19 |
+
<div class="table">
|
| 20 |
+
<h1>
|
| 21 |
+
<strong>FuelPHP, a PHP 5.3 Framework</strong>
|
| 22 |
+
Documentation
|
| 23 |
+
</h1>
|
| 24 |
+
|
| 25 |
+
<form id="google_search">
|
| 26 |
+
<p>
|
| 27 |
+
<span id="search_clear"> </span>
|
| 28 |
+
<input type="submit" name="search_submit" id="search_submit" value="search" />
|
| 29 |
+
<input type="text" value="" id="search_input" name="search_input" />
|
| 30 |
+
</p>
|
| 31 |
+
</form>
|
| 32 |
+
</div>
|
| 33 |
+
<nav>
|
| 34 |
+
|
| 35 |
+
<div class="clear"></div>
|
| 36 |
+
</nav>
|
| 37 |
+
<a href="#" id="toc_handle">table of contents</a>
|
| 38 |
+
<div class="clear"></div>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<div id="cse">
|
| 42 |
+
<div id="cse_point"></div>
|
| 43 |
+
<div id="cse_content"></div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<div id="main">
|
| 47 |
+
<h2>Auth package</h2>
|
| 48 |
+
|
| 49 |
+
<p>The Auth package provides a standardized interface for authentication in Fuel. This allows our users to
|
| 50 |
+
write their own drivers and easily integrate a new driver to work with old code by keeping the basic methods
|
| 51 |
+
consistent.</p>
|
| 52 |
+
|
| 53 |
+
<section>
|
| 54 |
+
<h2 id="driver_types">Auth_Login_Driver</h2>
|
| 55 |
+
|
| 56 |
+
<p>
|
| 57 |
+
This driver is the base class for all Auth login drivers. It is defined as an abstract class which contains
|
| 58 |
+
all methods generic to all login drivers, and abstract method definitions for all methods any login driver
|
| 59 |
+
MUST implement.
|
| 60 |
+
</p>
|
| 61 |
+
|
| 62 |
+
<h3 id="driver_config">Driver configuration</h3>
|
| 63 |
+
|
| 64 |
+
<p>
|
| 65 |
+
A group driver can load additional drivers that it depends on. Generally, these are Group drivers. But your implementation
|
| 66 |
+
could introduce and use custom driver types as well. To do so, add this structure to your driver class:
|
| 67 |
+
</p>
|
| 68 |
+
|
| 69 |
+
<pre class="php"><code>// autoload the Simplegroup group driver when loading this login driver
|
| 70 |
+
// this also defines the additional user record fields this driver has a getter for
|
| 71 |
+
protected $config = array(
|
| 72 |
+
'drivers' => array('group' => array('Simplegroup')),
|
| 73 |
+
'additional_fields' => array('profile_fields'),
|
| 74 |
+
);
|
| 75 |
+
</code></pre>
|
| 76 |
+
<h3 id="static">Static interface</h3>
|
| 77 |
+
|
| 78 |
+
<p>For ease of use, the Auth package provides a static interface on the public methods of the Login driver.
|
| 79 |
+
for this reason, the login base driver also defines the methods <kbd>member()</kbd> and <kbd>has_access()</kbd>,
|
| 80 |
+
which provide static access to these methods in the group and ACL driver.</p>
|
| 81 |
+
|
| 82 |
+
<p>Using the static interface, you can do</p>
|
| 83 |
+
|
| 84 |
+
<pre class="php"><code>// returns 'simpleauth'
|
| 85 |
+
$id = Auth::get_id();
|
| 86 |
+
</code></pre>
|
| 87 |
+
|
| 88 |
+
<p>instead of</p>
|
| 89 |
+
|
| 90 |
+
<pre class="php"><code>// returns 'simpleauth'
|
| 91 |
+
$id = Auth::instance()->get_id();
|
| 92 |
+
</code></pre>
|
| 93 |
+
<p class="note">This only works if "verify_multiple_logins" is set to <kbd>false</kbd> in the Auth config, as you can
|
| 94 |
+
not map a static interface to multiple active login drivers!</p>
|
| 95 |
+
|
| 96 |
+
<h3 id="generic_methods">Generic methods</h3>
|
| 97 |
+
|
| 98 |
+
<p>
|
| 99 |
+
Generic methods are defined in the login base driver, and are available to all Auth login drivers through
|
| 100 |
+
extension. These methods provide functions to create and retrieve instances, to set and get configuration
|
| 101 |
+
values, as well as generic method for password hashing and access to the <a href="acl.html">ACL</a> and <a href="group.html">Group</a> drivers.
|
| 102 |
+
</p>
|
| 103 |
+
<p class="note">The methods defined in the classes but not documented here are used internally, and should not be called directly.</p>
|
| 104 |
+
|
| 105 |
+
<article>
|
| 106 |
+
<h4 id="method_get_id" class="method">get_id()</h4>
|
| 107 |
+
<p>Returns the drivers unique id. This can be used to identify the driver, or to select a specific driver instance.</p>
|
| 108 |
+
<table class="method">
|
| 109 |
+
<tbody>
|
| 110 |
+
<tr>
|
| 111 |
+
<th class="legend">Static</th>
|
| 112 |
+
<td>No</td>
|
| 113 |
+
</tr>
|
| 114 |
+
<tr>
|
| 115 |
+
<th>Parameters</th>
|
| 116 |
+
<td>
|
| 117 |
+
None
|
| 118 |
+
</td>
|
| 119 |
+
</tr>
|
| 120 |
+
<tr>
|
| 121 |
+
<th>Returns</th>
|
| 122 |
+
<td>The drivers id string.</td>
|
| 123 |
+
</tr>
|
| 124 |
+
<tr>
|
| 125 |
+
<th>Example</th>
|
| 126 |
+
<td>
|
| 127 |
+
<pre class="php"><code>// returns 'simpleauth'
|
| 128 |
+
$id = Auth::instance('simpleauth')->get_id();
|
| 129 |
+
</code></pre>
|
| 130 |
+
</td>
|
| 131 |
+
</tr>
|
| 132 |
+
</tbody>
|
| 133 |
+
</table>
|
| 134 |
+
</article>
|
| 135 |
+
|
| 136 |
+
<article>
|
| 137 |
+
<h4 id="method_set_config" class="method">set_config($key, $value)</h4>
|
| 138 |
+
<p>Sets a driver configuration value.</p>
|
| 139 |
+
<table class="method">
|
| 140 |
+
<tbody>
|
| 141 |
+
<tr>
|
| 142 |
+
<th class="legend">Static</th>
|
| 143 |
+
<td>No</td>
|
| 144 |
+
</tr>
|
| 145 |
+
<tr>
|
| 146 |
+
<th>Parameters</th>
|
| 147 |
+
<td>
|
| 148 |
+
<table class="parameters">
|
| 149 |
+
<tr>
|
| 150 |
+
<th>Param</th>
|
| 151 |
+
<th>Default</th>
|
| 152 |
+
<th class="description">Description</th>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<th><kbd>$key</kbd></th>
|
| 156 |
+
<td>required</td>
|
| 157 |
+
<td>Configuration key name</td>
|
| 158 |
+
</tr>
|
| 159 |
+
<tr>
|
| 160 |
+
<th><kbd>$value</kbd></th>
|
| 161 |
+
<td>required</td>
|
| 162 |
+
<td>Value for this configuration key</td>
|
| 163 |
+
</tr>
|
| 164 |
+
</table>
|
| 165 |
+
</td>
|
| 166 |
+
</tr>
|
| 167 |
+
<tr>
|
| 168 |
+
<th>Returns</th>
|
| 169 |
+
<td>void</td>
|
| 170 |
+
</tr>
|
| 171 |
+
<tr>
|
| 172 |
+
<th>Example</th>
|
| 173 |
+
<td>
|
| 174 |
+
<pre class="php"><code>// set a config value
|
| 175 |
+
Auth::instance()->set_config('key', 'value');
|
| 176 |
+
</code></pre>
|
| 177 |
+
</td>
|
| 178 |
+
</tr>
|
| 179 |
+
</tbody>
|
| 180 |
+
</table>
|
| 181 |
+
</article>
|
| 182 |
+
|
| 183 |
+
<article>
|
| 184 |
+
<h4 id="method_get_config" class="method">get_config($key, $default = null)</h4>
|
| 185 |
+
<p>Gets a driver configuration value.</p>
|
| 186 |
+
<table class="method">
|
| 187 |
+
<tbody>
|
| 188 |
+
<tr>
|
| 189 |
+
<th class="legend">Static</th>
|
| 190 |
+
<td>No</td>
|
| 191 |
+
</tr>
|
| 192 |
+
<tr>
|
| 193 |
+
<th>Parameters</th>
|
| 194 |
+
<td>
|
| 195 |
+
<table class="parameters">
|
| 196 |
+
<tr>
|
| 197 |
+
<th>Param</th>
|
| 198 |
+
<th>Default</th>
|
| 199 |
+
<th class="description">Description</th>
|
| 200 |
+
</tr>
|
| 201 |
+
<tr>
|
| 202 |
+
<th><kbd>$key</kbd></th>
|
| 203 |
+
<td>required</td>
|
| 204 |
+
<td>Configuration key name</td>
|
| 205 |
+
</tr>
|
| 206 |
+
<tr>
|
| 207 |
+
<th><kbd>$default</kbd></th>
|
| 208 |
+
<td><i>null</i></td>
|
| 209 |
+
<td>Default value to be returned if the requested key does not exist</td>
|
| 210 |
+
</tr>
|
| 211 |
+
</table>
|
| 212 |
+
</td>
|
| 213 |
+
</tr>
|
| 214 |
+
<tr>
|
| 215 |
+
<th>Returns</th>
|
| 216 |
+
<td>mixed</td>
|
| 217 |
+
</tr>
|
| 218 |
+
<tr>
|
| 219 |
+
<th>Example</th>
|
| 220 |
+
<td>
|
| 221 |
+
<pre class="php"><code>// get a config value, return false if it doesn't exist
|
| 222 |
+
$key = Auth::instance()->get_config('key', false);
|
| 223 |
+
</code></pre>
|
| 224 |
+
</td>
|
| 225 |
+
</tr>
|
| 226 |
+
</tbody>
|
| 227 |
+
</table>
|
| 228 |
+
</article>
|
| 229 |
+
|
| 230 |
+
<article>
|
| 231 |
+
<h4 id="method_guest_login" class="method">guest_login()</h4>
|
| 232 |
+
<p>Returns if the driver supports guest logins (a non-authenticated guest user).</p>
|
| 233 |
+
<table class="method">
|
| 234 |
+
<tbody>
|
| 235 |
+
<tr>
|
| 236 |
+
<th class="legend">Static</th>
|
| 237 |
+
<td>No</td>
|
| 238 |
+
</tr>
|
| 239 |
+
<tr>
|
| 240 |
+
<th>Parameters</th>
|
| 241 |
+
<td>
|
| 242 |
+
None.
|
| 243 |
+
</td>
|
| 244 |
+
</tr>
|
| 245 |
+
<tr>
|
| 246 |
+
<th>Returns</th>
|
| 247 |
+
<td>boolean</td>
|
| 248 |
+
</tr>
|
| 249 |
+
<tr>
|
| 250 |
+
<th>Example</th>
|
| 251 |
+
<td>
|
| 252 |
+
<pre class="php"><code>// check if the default instance supports guests
|
| 253 |
+
if (Auth::instance()->guest_login())
|
| 254 |
+
{
|
| 255 |
+
// this driver supports guest logins!
|
| 256 |
+
}
|
| 257 |
+
</code></pre>
|
| 258 |
+
</td>
|
| 259 |
+
</tr>
|
| 260 |
+
</tbody>
|
| 261 |
+
</table>
|
| 262 |
+
|
| 263 |
+
<p class="note">By default, this method returns 'false'. If your login driver supports guest logins, overload this
|
| 264 |
+
method in your driver class.</p>
|
| 265 |
+
</article>
|
| 266 |
+
|
| 267 |
+
<article>
|
| 268 |
+
<h4 id="method_get_user_array" class="method">get_user_array(Array $additional_fields = array())</h4>
|
| 269 |
+
<p>Returns an array describing the current logged in user, always includes at least a screenname and
|
| 270 |
+
an emailaddress. Additional fields can be configured in the driver config or requested through the
|
| 271 |
+
$additional_fields array, but they must have a get_user_<em>fieldname</em>() method within the driver
|
| 272 |
+
to be gettable.</p>
|
| 273 |
+
<table class="method">
|
| 274 |
+
<tbody>
|
| 275 |
+
<tr>
|
| 276 |
+
<th class="legend">Static</th>
|
| 277 |
+
<td>No</td>
|
| 278 |
+
</tr>
|
| 279 |
+
<tr>
|
| 280 |
+
<th>Parameters</th>
|
| 281 |
+
<td>
|
| 282 |
+
<table class="parameters">
|
| 283 |
+
<tr>
|
| 284 |
+
<th>Param</th>
|
| 285 |
+
<th>Default</th>
|
| 286 |
+
<th class="description">Description</th>
|
| 287 |
+
</tr>
|
| 288 |
+
<tr>
|
| 289 |
+
<th><kbd>$additional_fields</kbd></th>
|
| 290 |
+
<td><i>array()</i></td>
|
| 291 |
+
<td>an array with fieldnames to fetch</td>
|
| 292 |
+
</tr>
|
| 293 |
+
</table>
|
| 294 |
+
</td>
|
| 295 |
+
</tr>
|
| 296 |
+
<tr>
|
| 297 |
+
<th>Returns</th>
|
| 298 |
+
<td>array</td>
|
| 299 |
+
</tr>
|
| 300 |
+
<tr>
|
| 301 |
+
<th>Example</th>
|
| 302 |
+
<td>
|
| 303 |
+
<pre class="php"><code>// call the method on the default instance
|
| 304 |
+
$user = Auth::instance()->get_user_array();
|
| 305 |
+
|
| 306 |
+
// call the method on a specific instance
|
| 307 |
+
$user = Auth::instance('simpleauth')->get_user_array();
|
| 308 |
+
|
| 309 |
+
// static call (if "verify_multiple_logins" is set to false)
|
| 310 |
+
$user = Auth::get_user_array();
|
| 311 |
+
</code></pre>
|
| 312 |
+
</td>
|
| 313 |
+
</tr>
|
| 314 |
+
</tbody>
|
| 315 |
+
</table>
|
| 316 |
+
|
| 317 |
+
<p class="note">You can define the 'additional_fields' in the driver configuration array to have them included by default when you call this method.</p>
|
| 318 |
+
</article>
|
| 319 |
+
|
| 320 |
+
<article>
|
| 321 |
+
<h4 id="method_hash_password" class="method">hash_password($password)</h4>
|
| 322 |
+
<p>Returns a base64 encoded hash of the given password. This method uses the very secure <a href="http://en.wikipedia.org/wiki/PBKDF2">pbkdf2</a> hashing algorithm.</p>
|
| 323 |
+
<table class="method">
|
| 324 |
+
<tbody>
|
| 325 |
+
<tr>
|
| 326 |
+
<th class="legend">Static</th>
|
| 327 |
+
<td>No</td>
|
| 328 |
+
</tr>
|
| 329 |
+
<tr>
|
| 330 |
+
<th>Parameters</th>
|
| 331 |
+
<td>
|
| 332 |
+
<table class="parameters">
|
| 333 |
+
<tr>
|
| 334 |
+
<th>Param</th>
|
| 335 |
+
<th>Default</th>
|
| 336 |
+
<th class="description">Description</th>
|
| 337 |
+
</tr>
|
| 338 |
+
<tr>
|
| 339 |
+
<th><kbd>$password</kbd></th>
|
| 340 |
+
<td>required</td>
|
| 341 |
+
<td>The password to hash</td>
|
| 342 |
+
</tr>
|
| 343 |
+
</table>
|
| 344 |
+
</td>
|
| 345 |
+
</tr>
|
| 346 |
+
<tr>
|
| 347 |
+
<th>Returns</th>
|
| 348 |
+
<td>string</td>
|
| 349 |
+
</tr>
|
| 350 |
+
<tr>
|
| 351 |
+
<th>Example</th>
|
| 352 |
+
<td>
|
| 353 |
+
<pre class="php"><code>// hash a users password
|
| 354 |
+
$password = Auth::instance()->hash_password($password);
|
| 355 |
+
</code></pre>
|
| 356 |
+
</td>
|
| 357 |
+
</tr>
|
| 358 |
+
</tbody>
|
| 359 |
+
</table>
|
| 360 |
+
</article>
|
| 361 |
+
|
| 362 |
+
<h3 id="abstract_methods">Abstract methods</h3>
|
| 363 |
+
|
| 364 |
+
<p>
|
| 365 |
+
Every login driver you develop MUST provide all of these methods, and the MUST return the values documented here.
|
| 366 |
+
</p>
|
| 367 |
+
|
| 368 |
+
<article>
|
| 369 |
+
<h4 id="method_perform_check" class="method">perform_check()</h4>
|
| 370 |
+
<p>Internal class method which checks if there is a valid session for the current user. It is up to you how your driver will determine this.</p>
|
| 371 |
+
<table class="method">
|
| 372 |
+
<tbody>
|
| 373 |
+
<tr>
|
| 374 |
+
<th class="legend">Static</th>
|
| 375 |
+
<td>No</td>
|
| 376 |
+
</tr>
|
| 377 |
+
<tr>
|
| 378 |
+
<th>Parameters</th>
|
| 379 |
+
<td>
|
| 380 |
+
None
|
| 381 |
+
</td>
|
| 382 |
+
</tr>
|
| 383 |
+
<tr>
|
| 384 |
+
<th>Returns</th>
|
| 385 |
+
<td>boolean, <strong>true</strong> if there is a valid user session, <strong>false</strong> if there isn't.</td>
|
| 386 |
+
</tr>
|
| 387 |
+
</tbody>
|
| 388 |
+
</table>
|
| 389 |
+
<p class="note">This method is called by Auth::check(), it should not be called directly by the application.</p>
|
| 390 |
+
</article>
|
| 391 |
+
|
| 392 |
+
<article>
|
| 393 |
+
<h4 id="method_validate_user" class="method">validate_user()</h4>
|
| 394 |
+
<p>The <strong>validate_user</strong> method validates a login request. It is up to you how your driver will do this.</p>
|
| 395 |
+
<table class="method">
|
| 396 |
+
<tbody>
|
| 397 |
+
<tr>
|
| 398 |
+
<th class="legend">Static</th>
|
| 399 |
+
<td>No</td>
|
| 400 |
+
</tr>
|
| 401 |
+
<tr>
|
| 402 |
+
<th>Parameters</th>
|
| 403 |
+
<td>
|
| 404 |
+
None
|
| 405 |
+
</td>
|
| 406 |
+
</tr>
|
| 407 |
+
<tr>
|
| 408 |
+
<th>Returns</th>
|
| 409 |
+
<td>mixed. it should return <strong>false</strong> if the user didn't pass validation. Any value that evaluates to true is considered to be valid.</td>
|
| 410 |
+
</tr>
|
| 411 |
+
</tbody>
|
| 412 |
+
</table>
|
| 413 |
+
<p class="note">Applications calling this method should not make assumptions about the return value if it isn't <strong>false</strong>!</p>
|
| 414 |
+
</article>
|
| 415 |
+
|
| 416 |
+
<article>
|
| 417 |
+
<h4 id="method_login" class="method">login()</h4>
|
| 418 |
+
<p>The <strong>login</strong> method performs a login request. It should call the validate_user() to validate the request. It is up to you how your driver will do this.</p>
|
| 419 |
+
<table class="method">
|
| 420 |
+
<tbody>
|
| 421 |
+
<tr>
|
| 422 |
+
<th class="legend">Static</th>
|
| 423 |
+
<td>No</td>
|
| 424 |
+
</tr>
|
| 425 |
+
<tr>
|
| 426 |
+
<th>Parameters</th>
|
| 427 |
+
<td>
|
| 428 |
+
None
|
| 429 |
+
</td>
|
| 430 |
+
</tr>
|
| 431 |
+
<tr>
|
| 432 |
+
<th>Returns</th>
|
| 433 |
+
<td>boolean. returns <strong>true</strong> if the login was succesful, <strong>false</strong> otherwise.</td>
|
| 434 |
+
</tr>
|
| 435 |
+
</tbody>
|
| 436 |
+
</table>
|
| 437 |
+
<p class="note">If your driver has guest user support, it must setup the guest before returning <strong>false</strong>.</p>
|
| 438 |
+
</article>
|
| 439 |
+
|
| 440 |
+
<article>
|
| 441 |
+
<h4 id="method_logout" class="method">logout()</h4>
|
| 442 |
+
<p>The <strong>logout</strong> method logs out the current logged-in user. It is up to you how your driver will do this.</p>
|
| 443 |
+
<table class="method">
|
| 444 |
+
<tbody>
|
| 445 |
+
<tr>
|
| 446 |
+
<th class="legend">Static</th>
|
| 447 |
+
<td>No</td>
|
| 448 |
+
</tr>
|
| 449 |
+
<tr>
|
| 450 |
+
<th>Parameters</th>
|
| 451 |
+
<td>
|
| 452 |
+
None
|
| 453 |
+
</td>
|
| 454 |
+
</tr>
|
| 455 |
+
<tr>
|
| 456 |
+
<th>Returns</th>
|
| 457 |
+
<td>boolean. returns <strong>true</strong> if the logout was succesful, <strong>false</strong> otherwise.</td>
|
| 458 |
+
</tr>
|
| 459 |
+
</tbody>
|
| 460 |
+
</table>
|
| 461 |
+
<p class="note">If your driver has guest user support, it must setup the guest as current user after a succesful logout.</p>
|
| 462 |
+
</article>
|
| 463 |
+
|
| 464 |
+
<article>
|
| 465 |
+
<h4 id="method_get_user_id" class="method">get_user_id()</h4>
|
| 466 |
+
<p>The <strong>get_user_id</strong> method returns an array structure containing the drivers id value, and the id of the currently logged-in user.</p>
|
| 467 |
+
<table class="method">
|
| 468 |
+
<tbody>
|
| 469 |
+
<tr>
|
| 470 |
+
<th class="legend">Static</th>
|
| 471 |
+
<td>No</td>
|
| 472 |
+
</tr>
|
| 473 |
+
<tr>
|
| 474 |
+
<th>Parameters</th>
|
| 475 |
+
<td>
|
| 476 |
+
None
|
| 477 |
+
</td>
|
| 478 |
+
</tr>
|
| 479 |
+
<tr>
|
| 480 |
+
<th>Returns</th>
|
| 481 |
+
<td>mixed. returns an array in the form <strong>array(driver_id, user_id)</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 482 |
+
</tr>
|
| 483 |
+
</tbody>
|
| 484 |
+
</table>
|
| 485 |
+
<p class="note">If your driver has guest user support, it must return the array with the (dummy) user_id of your guest, and not <strong>false</strong>!</p>
|
| 486 |
+
</article>
|
| 487 |
+
|
| 488 |
+
<article>
|
| 489 |
+
<h4 id="method_get_groups" class="method">get_groups()</h4>
|
| 490 |
+
<p>The <strong>get_groups</strong> method returns the user groups assigned to the currently logged-in user.</p>
|
| 491 |
+
<table class="method">
|
| 492 |
+
<tbody>
|
| 493 |
+
<tr>
|
| 494 |
+
<th class="legend">Static</th>
|
| 495 |
+
<td>No</td>
|
| 496 |
+
</tr>
|
| 497 |
+
<tr>
|
| 498 |
+
<th>Parameters</th>
|
| 499 |
+
<td>
|
| 500 |
+
None
|
| 501 |
+
</td>
|
| 502 |
+
</tr>
|
| 503 |
+
<tr>
|
| 504 |
+
<th>Returns</th>
|
| 505 |
+
<td>mixed. returns an array in the form <strong>array(array(driver_id, group_id), array(driver_id, group_id), etc)</strong> if a user is logged in, or <strong>false</strong> otherwise.</td>
|
| 506 |
+
</tr>
|
| 507 |
+
</tbody>
|
| 508 |
+
</table>
|
| 509 |
+
<p class="note">If your driver has guest user support, it must return the array your guest user groups, and not <strong>false</strong>!</p>
|
| 510 |
+
</article>
|
| 511 |
+
|
| 512 |
+
<article>
|
| 513 |
+
<h4 id="method_get_email" class="method">get_email()</h4>
|
| 514 |
+
<p>The <strong>get_email</strong> method returns the email address assigned to the currently logged-in user.</p>
|
| 515 |
+
<table class="method">
|
| 516 |
+
<tbody>
|
| 517 |
+
<tr>
|
| 518 |
+
<th class="legend">Static</th>
|
| 519 |
+
<td>No</td>
|
| 520 |
+
</tr>
|
| 521 |
+
<tr>
|
| 522 |
+
<th>Parameters</th>
|
| 523 |
+
<td>
|
| 524 |
+
None
|
| 525 |
+
</td>
|
| 526 |
+
</tr>
|
| 527 |
+
<tr>
|
| 528 |
+
<th>Returns</th>
|
| 529 |
+
<td>mixed. returns an email address if a user is logged in, or <strong>false</strong> if no email address is defined for the current user, or there is no user logged-in.</td>
|
| 530 |
+
</tr>
|
| 531 |
+
</tbody>
|
| 532 |
+
</table>
|
| 533 |
+
<p class="note">If your driver has guest user support, don't forget to return <strong>false</strong> if the guest does not have an email address defined!</p>
|
| 534 |
+
</article>
|
| 535 |
+
|
| 536 |
+
<article>
|
| 537 |
+
<h4 id="method_get_screen_name" class="method">get_screen_name()</h4>
|
| 538 |
+
<p>The <strong>get_screen_name</strong> method returns the screen- or display name of the currently logged-in user.</p>
|
| 539 |
+
<table class="method">
|
| 540 |
+
<tbody>
|
| 541 |
+
<tr>
|
| 542 |
+
<th class="legend">Static</th>
|
| 543 |
+
<td>No</td>
|
| 544 |
+
</tr>
|
| 545 |
+
<tr>
|
| 546 |
+
<th>Parameters</th>
|
| 547 |
+
<td>
|
| 548 |
+
None
|
| 549 |
+
</td>
|
| 550 |
+
</tr>
|
| 551 |
+
<tr>
|
| 552 |
+
<th>Returns</th>
|
| 553 |
+
<td>mixed. returns a string containing the name, or <strong>false</strong> if there is no user logged-in.</td>
|
| 554 |
+
</tr>
|
| 555 |
+
</tbody>
|
| 556 |
+
</table>
|
| 557 |
+
<p class="note">If your driver has guest user support, it must return the guests display name, and not <strong>false</strong>!</p>
|
| 558 |
+
</article>
|
| 559 |
+
|
| 560 |
+
</section>
|
| 561 |
+
|
| 562 |
+
</div>
|
| 563 |
+
|
| 564 |
+
<footer>
|
| 565 |
+
<p>
|
| 566 |
+
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
|
| 567 |
+
</p>
|
| 568 |
+
</footer>
|
| 569 |
+
</div>
|
| 570 |
+
</body>
|
| 571 |
+
</html>
|