1: <?php
2:
3: /**
4: * To use these overrides, you must first enable the "site" module in your
5: * config/app.php file to activate the module.
6: */
7:
8: /**
9: * Override the session class. These are the methods that must be overriden to
10: * create a new session backend. The "session_type" value in your config/app.php must
11: * be set to "custom" to activate this class. There are several other
12: * properties and methods that can be modified to create custom sessions:
13: *
14: * https://cypht.org/docs/code_docs/class-Hm_Session.html
15: *
16: * This example extends the standard PHP session class. You can also extend the
17: * DB or Memcached classes, or the base session class. In this example we just
18: * defer to the PHP session class methods.
19: *
20: * @package modules
21: * @subpackage site
22: */
23: class Custom_Session extends Hm_PHP_Session {
24:
25: /**
26: * check for an active session or an attempt to start one
27: * @param object $request request object
28: * @return bool
29: */
30: public function check($request, $user=false, $pass=false, $fingerprint=true) {
31: return parent::check($request, $user, $pass, $fingerprint);
32: }
33:
34: /**
35: * Start the session. This could be an existing session or a new login
36: * @param object $request request details
37: * @return void
38: */
39: public function start($request, $existing_session=false) {
40: return parent::start($request, $existing_session);
41: }
42:
43: /**
44: * Call the configured authentication method to check user credentials
45: * @param string $user username
46: * @param string $pass password
47: * @return bool true if the authentication was successful
48: */
49: public function auth($user, $pass) {
50: return parent::auth($user, $pass);
51: }
52:
53: /**
54: * Return a session value, or a user settings value stored in the session
55: * @param string $name session value name to return
56: * @param mixed $default value to return if $name is not found
57: * @return mixed the value if found, otherwise $defaultHm_Auth
58: */
59: public function get($name, $default=false, $user=false) {
60: return parent::get($name, $default, $user);
61: }
62:
63: /**
64: * Save a value in the session
65: * @param string $name the name to save
66: * @param string $value the value to save
67: * @return void
68: */
69: public function set($name, $value, $user=false) {
70: return parent::set($name, $value);
71: }
72:
73: /**
74: * Delete a value from the session
75: * @param string $name name of value to deleteHm_Auth
76: * @return void
77: */
78: public function del($name) {
79: return parent::del($name);
80: }
81:
82: /**
83: * End a session after a page request is complete. This only closes the session and
84: * does not destroy it
85: * @return void
86: */
87: public function end() {
88: return parent::end();
89: }
90:
91: /**
92: * Destroy a session for good
93: * @param object $request request details
94: * @return void
95: */
96: public function destroy($request) {
97: return parent::destroy($request);
98: }
99:
100: }
101:
102: /**
103: * Override the authentication class. This method needs to be overriden to
104: * create a custom authentication backend. You must set the "auth_type" setting
105: * in your config/app.php file to "custom" to activate this class. More information
106: * about the base class for authentication is located here:
107: *
108: * https://cypht.org/docs/code_docs/class-Hm_Auth.html
109: *
110: * This example extends the auth DB class, and simply defers the parent class
111: * method
112: * @package modules
113: * @subpackage site
114: */
115: class Custom_Auth extends Hm_Auth_DB {
116:
117: /**
118: * This is the method new auth mechs need to override.
119: * @param string $user username
120: * @param string $pass password
121: * @return bool true if the user is authenticated, false otherwise
122: */
123: public function check_credentials($user, $pass) {
124: return parent::check_credentials($user, $pass);
125: }
126: }
127:
128: /*
129: function format_msg_html($str, $images=false) {
130: return '';
131: }
132: */
133: