139 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/examples/material-design/js/jquery.router.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | plugin name: router
4 | jquery plugin to handle routes with both hash and push state
5 | why? why another routing plugin? because i couldnt find one that handles both hash and pushstate
6 | created by 24hr // camilo.tapia
7 | author twitter: camilo.tapia
8 |
9 | Copyright 2011 camilo tapia // 24hr (email : camilo.tapia@gmail.com)
10 |
11 | This program is free software; you can redistribute it and/or modify
12 | it under the terms of the GNU General Public License, version 2, as
13 | published by the Free Software Foundation.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program; if not, write to the Free Software
22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 |
24 | */
25 |
26 |
27 | (function($) {
28 |
29 | var hasPushState = (history && history.pushState);
30 | var hasHashState = !hasPushState && ("onhashchange" in window) && false;
31 | var router = {};
32 | var routeList = [];
33 | var eventAdded = false;
34 | var currentUsedUrl = location.href; //used for ie to hold the current url
35 | var firstRoute = true;
36 | var errorCallback = function() {};
37 |
38 | // hold the latest route that was activated
39 | router.currentId = "";
40 | router.currentParameters = {};
41 |
42 | // Create a default error handler
43 | router.errorCallback = errorCallback;
44 |
45 | router.capabilities = {
46 | hash: hasHashState,
47 | pushState: hasPushState,
48 | timer: !hasHashState && !hasPushState
49 | };
50 |
51 | // reset all routes
52 | router.reset = function() {
53 | var router = {};
54 | var routeList = [];
55 | router.currentId = "";
56 | router.currentParameters = {};
57 | }
58 |
59 | router.add = function(route, id, callback) {
60 | // if we only get a route and a callback, we switch the arguments
61 | if (typeof id == "function") {
62 | callback = id;
63 | delete id;
64 | }
65 |
66 | var isRegExp = typeof route == "object";
67 |
68 | if (!isRegExp) {
69 |
70 | // remove the last slash to unifiy all routes
71 | if (route.lastIndexOf("/") == route.length - 1) {
72 | route = route.substring(0, route.length - 1);
73 | }
74 |
75 | // if the routes where created with an absolute url ,we have to remove the absolut part anyway, since we cant change that much
76 | route = route.replace(location.protocol + "//", "").replace(location.hostname, "");
77 | }
78 |
79 | var routeItem = {
80 | route: route,
81 | callback: callback,
82 | type: isRegExp ? "regexp" : "string",
83 | id: id
84 | }
85 |
86 | routeList.push(routeItem);
87 |
88 | // we add the event listener after the first route is added so that we dont need to listen to events in vain
89 | if (!eventAdded) {
90 | bindStateEvents();
91 | }
92 | };
93 |
94 | router.addErrorHandler = function(callback) {
95 | this.errorCallback = callback;
96 | };
97 |
98 | function bindStateEvents() {
99 | eventAdded = true;
100 |
101 | // default value telling router that we havent replaced the url from a hash. yet.
102 | router.fromHash = false;
103 |
104 |
105 | if (hasPushState) {
106 | // if we get a request with a qualified hash (ie it begins with #!)
107 | if (location.hash.indexOf("#!/") === 0) {
108 | // replace the state
109 | var url = location.pathname + location.hash.replace(/^#!\//gi, "");
110 | history.replaceState({}, "", url);
111 |
112 | // this flag tells router that the url was converted from hash to popstate
113 | router.fromHash = true;
114 | }
115 |
116 | $(window).bind("popstate", handleRoutes);
117 | } else if (hasHashState) {
118 | $(window).bind("hashchange.router", handleRoutes);
119 | } else {
120 | // if no events are available we use a timer to check periodically for changes in the url
121 | setInterval(
122 | function() {
123 | if (location.href != currentUsedUrl) {
124 | handleRoutes();
125 | currentUsedUrl = location.href;
126 | }
127 | }, 500
128 | );
129 | }
130 |
131 | }
132 |
133 | bindStateEvents();
134 |
135 | router.go = function(url, title) {
136 | if (hasPushState) {
137 | history.pushState({}, title, url);
138 | checkRoutes();
139 | } else {
140 | // remove part of url that we dont use
141 | url = url.replace(location.protocol + "//", "").replace(location.hostname, "");
142 | var hash = url.replace(location.pathname, "");
143 |
144 | if (hash.indexOf("!") < 0) {
145 | hash = "!/" + hash;
146 | }
147 | location.hash = hash;
148 | }
149 | };
150 |
151 | // do a check without affecting the history
152 | router.check = router.redo = function() {
153 | checkRoutes(true);
154 | };
155 |
156 | // parse and wash the url to process
157 | function parseUrl(url) {
158 | var currentUrl = url ? url : location.pathname;
159 |
160 | currentUrl = decodeURI(currentUrl);
161 |
162 | // if no pushstate is availabe we have to use the hash
163 | if (!hasPushState) {
164 | if (location.hash.indexOf("#!/") === 0) {
165 | currentUrl += location.hash.substring(3);
166 | } else {
167 | return '';
168 | }
169 | }
170 |
171 | // and if the last character is a slash, we just remove it
172 | currentUrl = currentUrl.replace(/\/$/, "");
173 |
174 | return currentUrl;
175 | }
176 |
177 | // get the current parameters for either a specified url or the current one if parameters is ommited
178 | router.parameters = function(url) {
179 | // parse the url so that we handle a unified url
180 | var currentUrl = parseUrl(url);
181 |
182 | // get the list of actions for the current url
183 | var list = getParameters(currentUrl);
184 |
185 | // if the list is empty, return an empty object
186 | if (list.length == 0) {
187 | router.currentParameters = {};
188 | }
189 |
190 | // if we got results, return the first one. at least for now
191 | else {
192 | router.currentParameters = list[0].data;
193 | }
194 |
195 | return router.currentParameters;
196 | }
197 |
198 | function getParameters(url) {
199 |
200 | var dataList = [];
201 |
202 | // console.log("ROUTES:");
203 |
204 | for (var i = 0, ii = routeList.length; i < ii; i++) {
205 | var route = routeList[i];
206 |
207 | // check for mathing reg exp
208 | if (route.type == "regexp") {
209 | var result = url.match(route.route);
210 | if (result) {
211 | var data = {};
212 | data.matches = result;
213 |
214 | dataList.push({
215 | route: route,
216 | data: data
217 | });
218 |
219 | // saves the current route id
220 | router.currentId = route.id;
221 |
222 | // break after first hit
223 | break;
224 | }
225 | }
226 |
227 | // check for mathing string routes
228 | else {
229 | var currentUrlParts = url.split("/");
230 | var routeParts = route.route.split("/");
231 |
232 | //console.log("matchCounter ", matchCounter, url, route.route)
233 |
234 | // first check so that they have the same amount of elements at least
235 | if (routeParts.length == currentUrlParts.length) {
236 | var data = {};
237 | var matched = true;
238 | var matchCounter = 0;
239 |
240 | for (var j = 0, jj = routeParts.length; j < jj; j++) {
241 | var isParam = routeParts[j].indexOf(":") === 0;
242 | if (isParam) {
243 | data[routeParts[j].substring(1)] = decodeURI(currentUrlParts[j]);
244 | matchCounter++;
245 | } else {
246 | if (routeParts[j] == currentUrlParts[j]) {
247 | matchCounter++;
248 | }
249 | }
250 | }
251 |
252 | // break after first hit
253 | if (routeParts.length == matchCounter) {
254 | dataList.push({
255 | route: route,
256 | data: data
257 | });
258 |
259 | // saved the current route id
260 | router.currentId = route.id;
261 | router.currentParameters = data;
262 |
263 | break;
264 | }
265 |
266 | }
267 | }
268 |
269 | }
270 |
271 | return dataList;
272 | }
273 |
274 | function checkRoutes() {
275 | var currentUrl = parseUrl(location.pathname);
276 |
277 | // check if something is catched
278 | var actionList = getParameters(currentUrl);
279 |
280 | // If no routes have been matched
281 | if (actionList.length == 0) {
282 | // Invoke error handler
283 | return router.errorCallback(currentUrl);
284 | }
285 |
286 | // ietrate trough result (but it will only kick in one)
287 | for (var i = 0, ii = actionList.length; i < ii; i++) {
288 | actionList[i].route.callback(actionList[i].data);
289 | }
290 | }
291 |
292 |
293 | function handleRoutes(e) {
294 | if (e != null && e.originalEvent && e.originalEvent.state !== undefined) {
295 | checkRoutes();
296 | } else if (hasHashState) {
297 | checkRoutes();
298 | } else if (!hasHashState && !hasPushState) {
299 | checkRoutes();
300 | }
301 | }
302 |
303 |
304 |
305 | if (!$.router) {
306 | $.router = router;
307 | } else {
308 | if (window.console && window.console.warn) {
309 | console.warn("jQuery.status already defined. Something is using the same name.");
310 | }
311 | }
312 |
313 | })(jQuery);
314 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | .---------------------------------------------------------------------------.
2 | | The Francium Project |
3 | | http://subinsb.com/the-francium-project |
4 | | ------------------------------------------------------------------------- |
5 | | This software logSys uses the Apache License |
6 | '---------------------------------------------------------------------------'
7 |
8 | Licensed under the Apache License, Version 2.0 (the "License");
9 | you may not use this file except in compliance with the License.
10 | You may obtain a copy of the License at
11 |
12 | http://www.apache.org/licenses/LICENSE-2.0
13 |
14 | Unless required by applicable law or agreed to in writing, software
15 | distributed under the License is distributed on an "AS IS" BASIS,
16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | See the License for the specific language governing permissions and
18 | limitations under the License.
19 |
20 | License Copy (In case of no internet)
21 | -------------------------------------
22 |
23 | Apache License
24 | Version 2.0, January 2004
25 | http://www.apache.org/licenses/
26 |
27 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
28 |
29 | 1. Definitions.
30 |
31 | "License" shall mean the terms and conditions for use, reproduction,
32 | and distribution as defined by Sections 1 through 9 of this document.
33 |
34 | "Licensor" shall mean the copyright owner or entity authorized by
35 | the copyright owner that is granting the License.
36 |
37 | "Legal Entity" shall mean the union of the acting entity and all
38 | other entities that control, are controlled by, or are under common
39 | control with that entity. For the purposes of this definition,
40 | "control" means (i) the power, direct or indirect, to cause the
41 | direction or management of such entity, whether by contract or
42 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
43 | outstanding shares, or (iii) beneficial ownership of such entity.
44 |
45 | "You" (or "Your") shall mean an individual or Legal Entity
46 | exercising permissions granted by this License.
47 |
48 | "Source" form shall mean the preferred form for making modifications,
49 | including but not limited to software source code, documentation
50 | source, and configuration files.
51 |
52 | "Object" form shall mean any form resulting from mechanical
53 | transformation or translation of a Source form, including but
54 | not limited to compiled object code, generated documentation,
55 | and conversions to other media types.
56 |
57 | "Work" shall mean the work of authorship, whether in Source or
58 | Object form, made available under the License, as indicated by a
59 | copyright notice that is included in or attached to the work
60 | (an example is provided in the Appendix below).
61 |
62 | "Derivative Works" shall mean any work, whether in Source or Object
63 | form, that is based on (or derived from) the Work and for which the
64 | editorial revisions, annotations, elaborations, or other modifications
65 | represent, as a whole, an original work of authorship. For the purposes
66 | of this License, Derivative Works shall not include works that remain
67 | separable from, or merely link (or bind by name) to the interfaces of,
68 | the Work and Derivative Works thereof.
69 |
70 | "Contribution" shall mean any work of authorship, including
71 | the original version of the Work and any modifications or additions
72 | to that Work or Derivative Works thereof, that is intentionally
73 | submitted to Licensor for inclusion in the Work by the copyright owner
74 | or by an individual or Legal Entity authorized to submit on behalf of
75 | the copyright owner. For the purposes of this definition, "submitted"
76 | means any form of electronic, verbal, or written communication sent
77 | to the Licensor or its representatives, including but not limited to
78 | communication on electronic mailing lists, source code control systems,
79 | and issue tracking systems that are managed by, or on behalf of, the
80 | Licensor for the purpose of discussing and improving the Work, but
81 | excluding communication that is conspicuously marked or otherwise
82 | designated in writing by the copyright owner as "Not a Contribution."
83 |
84 | "Contributor" shall mean Licensor and any individual or Legal Entity
85 | on behalf of whom a Contribution has been received by Licensor and
86 | subsequently incorporated within the Work.
87 |
88 | 2. Grant of Copyright License. Subject to the terms and conditions of
89 | this License, each Contributor hereby grants to You a perpetual,
90 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
91 | copyright license to reproduce, prepare Derivative Works of,
92 | publicly display, publicly perform, sublicense, and distribute the
93 | Work and such Derivative Works in Source or Object form.
94 |
95 | 3. Grant of Patent License. Subject to the terms and conditions of
96 | this License, each Contributor hereby grants to You a perpetual,
97 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
98 | (except as stated in this section) patent license to make, have made,
99 | use, offer to sell, sell, import, and otherwise transfer the Work,
100 | where such license applies only to those patent claims licensable
101 | by such Contributor that are necessarily infringed by their
102 | Contribution(s) alone or by combination of their Contribution(s)
103 | with the Work to which such Contribution(s) was submitted. If You
104 | institute patent litigation against any entity (including a
105 | cross-claim or counterclaim in a lawsuit) alleging that the Work
106 | or a Contribution incorporated within the Work constitutes direct
107 | or contributory patent infringement, then any patent licenses
108 | granted to You under this License for that Work shall terminate
109 | as of the date such litigation is filed.
110 |
111 | 4. Redistribution. You may reproduce and distribute copies of the
112 | Work or Derivative Works thereof in any medium, with or without
113 | modifications, and in Source or Object form, provided that You
114 | meet the following conditions:
115 |
116 | (a) You must give any other recipients of the Work or
117 | Derivative Works a copy of this License; and
118 |
119 | (b) You must cause any modified files to carry prominent notices
120 | stating that You changed the files; and
121 |
122 | (c) You must retain, in the Source form of any Derivative Works
123 | that You distribute, all copyright, patent, trademark, and
124 | attribution notices from the Source form of the Work,
125 | excluding those notices that do not pertain to any part of
126 | the Derivative Works; and
127 |
128 | (d) If the Work includes a "NOTICE" text file as part of its
129 | distribution, then any Derivative Works that You distribute must
130 | include a readable copy of the attribution notices contained
131 | within such NOTICE file, excluding those notices that do not
132 | pertain to any part of the Derivative Works, in at least one
133 | of the following places: within a NOTICE text file distributed
134 | as part of the Derivative Works; within the Source form or
135 | documentation, if provided along with the Derivative Works; or,
136 | within a display generated by the Derivative Works, if and
137 | wherever such third-party notices normally appear. The contents
138 | of the NOTICE file are for informational purposes only and
139 | do not modify the License. You may add Your own attribution
140 | notices within Derivative Works that You distribute, alongside
141 | or as an addendum to the NOTICE text from the Work, provided
142 | that such additional attribution notices cannot be construed
143 | as modifying the License.
144 |
145 | You may add Your own copyright statement to Your modifications and
146 | may provide additional or different license terms and conditions
147 | for use, reproduction, or distribution of Your modifications, or
148 | for any such Derivative Works as a whole, provided Your use,
149 | reproduction, and distribution of the Work otherwise complies with
150 | the conditions stated in this License.
151 |
152 | 5. Submission of Contributions. Unless You explicitly state otherwise,
153 | any Contribution intentionally submitted for inclusion in the Work
154 | by You to the Licensor shall be under the terms and conditions of
155 | this License, without any additional terms or conditions.
156 | Notwithstanding the above, nothing herein shall supersede or modify
157 | the terms of any separate license agreement you may have executed
158 | with Licensor regarding such Contributions.
159 |
160 | 6. Trademarks. This License does not grant permission to use the trade
161 | names, trademarks, service marks, or product names of the Licensor,
162 | except as required for reasonable and customary use in describing the
163 | origin of the Work and reproducing the content of the NOTICE file.
164 |
165 | 7. Disclaimer of Warranty. Unless required by applicable law or
166 | agreed to in writing, Licensor provides the Work (and each
167 | Contributor provides its Contributions) on an "AS IS" BASIS,
168 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
169 | implied, including, without limitation, any warranties or conditions
170 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
171 | PARTICULAR PURPOSE. You are solely responsible for determining the
172 | appropriateness of using or redistributing the Work and assume any
173 | risks associated with Your exercise of permissions under this License.
174 |
175 | 8. Limitation of Liability. In no event and under no legal theory,
176 | whether in tort (including negligence), contract, or otherwise,
177 | unless required by applicable law (such as deliberate and grossly
178 | negligent acts) or agreed to in writing, shall any Contributor be
179 | liable to You for damages, including any direct, indirect, special,
180 | incidental, or consequential damages of any character arising as a
181 | result of this License or out of the use or inability to use the
182 | Work (including but not limited to damages for loss of goodwill,
183 | work stoppage, computer failure or malfunction, or any and all
184 | other commercial damages or losses), even if such Contributor
185 | has been advised of the possibility of such damages.
186 |
187 | 9. Accepting Warranty or Additional Liability. While redistributing
188 | the Work or Derivative Works thereof, You may choose to offer,
189 | and charge a fee for, acceptance of support, warranty, indemnity,
190 | or other liability obligations and/or rights consistent with this
191 | License. However, in accepting such obligations, You may act only
192 | on Your own behalf and on Your sole responsibility, not on behalf
193 | of any other Contributor, and only if You agree to indemnify,
194 | defend, and hold each Contributor harmless for any liability
195 | incurred by, or claims asserted against, such Contributor by reason
196 | of your accepting any such warranty or additional liability.
197 |
198 | END OF TERMS AND CONDITIONS
199 |
200 | APPENDIX: How to apply the Apache License to your work.
201 |
202 | To apply the Apache License to your work, attach the following
203 | boilerplate notice, with the fields enclosed by brackets "[]"
204 | replaced with your own identifying information. (Don't include
205 | the brackets!) The text should be enclosed in the appropriate
206 | comment syntax for the file format. We also recommend that a
207 | file or class name and description of purpose be included on the
208 | same "printed page" as the copyright notice for easier
209 | identification within third-party archives.
210 |
211 | Copyright [yyyy] [name of copyright owner]
212 |
213 | Licensed under the Apache License, Version 2.0 (the "License");
214 | you may not use this file except in compliance with the License.
215 | You may obtain a copy of the License at
216 |
217 | http://www.apache.org/licenses/LICENSE-2.0
218 |
219 | Unless required by applicable law or agreed to in writing, software
220 | distributed under the License is distributed on an "AS IS" BASIS,
221 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
222 | See the License for the specific language governing permissions and
223 | limitations under the License.
224 |
--------------------------------------------------------------------------------
/src/Fr/LS.php:
--------------------------------------------------------------------------------
1 | array(
46 | 'company' => 'My Site',
47 | 'email' => 'email@mysite.com',
48 | 'email_callback' => false,
49 |
50 | /**
51 | * Callback to override output content
52 | */
53 | 'output_callback' => false,
54 | ),
55 |
56 | /**
57 | * Database Configuration
58 | */
59 | 'db' => array(
60 | /**
61 | * @var string 'mysql' or 'postgresql' or 'sqlite'
62 | */
63 | 'type' => 'mysql',
64 |
65 | /**
66 | * MySQL/PostgreSQL options
67 | */
68 | 'host' => '',
69 | 'port' => '3306',
70 | 'username' => '',
71 | 'password' => '',
72 |
73 | /**
74 | * SQLite options
75 | */
76 | 'sqlite_path' => '',
77 |
78 | 'name' => '',
79 | 'table' => 'users',
80 | 'token_table' => 'user_tokens',
81 |
82 | 'columns' => array(
83 | 'id' => 'id',
84 | 'username' => 'username',
85 | 'password' => 'password',
86 | 'email' => 'email',
87 | 'attempt' => 'attempt',
88 | 'created' => 'created',
89 | ),
90 | ),
91 |
92 | /**
93 | * Keys used for encryption
94 | * DONT MAKE THIS PUBLIC
95 | */
96 | 'keys' => array(
97 | /**
98 | * Changing cookie key will expire all current active login sessions
99 | */
100 | 'cookie' => 'ckxc436jd*^30f840v*9!@#$',
101 | /**
102 | * `salt` should not be changed after users are created
103 | */
104 | 'salt' => '^#$4%9f+1^p9)M@4M)V$',
105 | ),
106 |
107 | /**
108 | * Enable/Disable certain features
109 | */
110 | 'features' => array(
111 |
112 | /**
113 | * Enable/Disable Login using Username & E-Mail
114 | */
115 | 'email_login' => true,
116 |
117 | /**
118 | * Enable/Disable `Remember Me` feature
119 | */
120 | 'remember_me' => true,
121 |
122 | /**
123 | * Should HTTP related functions should be ran.
124 | * This includes cookie, session, URL handling.
125 | * Useful when logSys is not used in a web app
126 | */
127 | 'run_http' => true,
128 |
129 | /**
130 | * Should \Fr\LS::init() be called automatically
131 | */
132 | 'auto_init' => false,
133 |
134 | /**
135 | * Prevent Brute Forcing
136 | * ---------------------
137 | * By enabling this, logSys will deny login for the time mentioned
138 | * in the 'brute_force'->'time_limit' seconds after 'brute_force'->'tries'
139 | * number of incorrect login tries.
140 | */
141 | 'block_brute_force' => true,
142 |
143 | /**
144 | * Two Step Login
145 | * --------------
146 | * By enabling this, a checking is done when user visits
147 | * whether the device he/she uses is approved by the user.
148 | * Allows the original user to revoke logins in other devices/places
149 | * Useful if the user forgot to logout in some place.
150 | */
151 | 'two_step_login' => false,
152 |
153 | ),
154 |
155 | /**
156 | * `Blocking Brute Force Attacks` options
157 | */
158 | 'brute_force' => array(
159 | /**
160 | * No of tries alloted to each user
161 | */
162 | 'tries' => 5,
163 | /**
164 | * The time IN SECONDS for which block from login action should be done after
165 | * incorrect login attempts. Use http://www.easysurf.cc/utime.htm#m60s
166 | * for converting minutes to seconds. Default : 5 minutes
167 | */
168 | 'time_limit' => 300,
169 |
170 | /**
171 | * Maximum bumber of tokens that can be generated
172 | */
173 | 'max_tokens' => 5,
174 | ),
175 |
176 | /**
177 | * Information about pages
178 | */
179 | 'pages' => array(
180 | /**
181 | * Pages that doesn't require logging in.
182 | * Exclude login page, but include REGISTER page.
183 | * Use RELATIVE links. To find the relative link of
184 | * a page, do var_dump( Fr\LS::curPage() );
185 | */
186 | 'no_login' => array(),
187 |
188 | /**
189 | * Pages that both logged in and not logged in users can access
190 | */
191 | 'everyone' => array(),
192 |
193 | /**
194 | * The login page. ex : /login.php or /accounts/login.php
195 | */
196 | 'login_page' => '',
197 |
198 | /**
199 | * The home page. The main page for logged in users.
200 | * logSys redirects to here after user logs in
201 | */
202 | 'home_page' => '',
203 | ),
204 |
205 | /**
206 | * Settings about cookie creation
207 | */
208 | 'cookies' => array(
209 | /**
210 | * Default : cookies expire in 30 days. The value is
211 | * for setting in strtotime() function
212 | * http://php.net/manual/en/function.strtotime.php
213 | */
214 | 'expire' => '+30 days',
215 | 'path' => '/',
216 | 'domain' => '',
217 |
218 | /**
219 | * Names of cookies created
220 | */
221 | 'names' => array(
222 | 'login_token' => 'lg',
223 | 'remember_me' => 'rm',
224 | 'device' => 'dv',
225 | 'session' => 'a',
226 | ),
227 | ),
228 |
229 | /**
230 | * 2 Step Login
231 | */
232 | 'two_step_login' => array(
233 | /**
234 | * Message to show before displaying 'Enter Token' form.
235 | */
236 | 'instruction' => '',
237 |
238 | /**
239 | * Callback when token is generated.
240 | * Used to send message to user ( Phone/E-Mail )
241 | */
242 | 'send_callback' => '',
243 |
244 | /**
245 | * The table to stoe user's sessions
246 | */
247 | 'devices_table' => 'user_devices',
248 |
249 | /**
250 | * The length of token generated.
251 | * A low value is better for tokens sent via Mobile SMS
252 | */
253 | 'token_length' => 4,
254 |
255 | /**
256 | * Maximum number of tries the user can make for entering token
257 | */
258 | 'token_tries' => 3,
259 |
260 | /**
261 | * Whether the token should be numeric only ?
262 | * Default Token : Alphabetic + Numeric mixed strings
263 | */
264 | 'numeric' => false,
265 |
266 | /**
267 | * The expire time of cookie that authorizes the device
268 | * to login using the user's account with 2 Step Verification
269 | * The value is for setting in strtotime() function
270 | * http://php.net/manual/en/function.strtotime.php
271 | */
272 | 'expire' => '+45 days',
273 |
274 | /**
275 | * Should logSys checks if device is valid, everytime
276 | * logSys is initiated ie everytime a page loads
277 | * If you want to check only the first time a user loads
278 | * a page, then set the value to TRUE, else FALSE
279 | */
280 | 'first_check_only' => true,
281 | ),
282 |
283 | /**
284 | * Debug info
285 | */
286 | 'debug' => array(
287 | /**
288 | * Enable debugging
289 | */
290 | 'enable' => false,
291 |
292 | /**
293 | * Absolute path
294 | */
295 | 'log_file' => '',
296 | ),
297 | );
298 |
299 | /**
300 | * @var array
301 | */
302 | protected $config = array();
303 |
304 | /**
305 | * Config
306 | * @param array $config [description]
307 | * @return [type] [description]
308 | */
309 | public function config($config = array())
310 | {
311 | /**
312 | * Callback to display messages for different states
313 | * @var array
314 | */
315 | self::$default_config['basic']['output_callback'] = function (&$LS, $state, $extraInfo = array()) {
316 | if ($state === 'invalidToken') {
317 | return '