1: <?php
2: declare(strict_types=1);
3: /**
4: * +------------------------------------------------------------+
5: * | apnscp |
6: * +------------------------------------------------------------+
7: * | Copyright (c) Apis Networks |
8: * +------------------------------------------------------------+
9: * | Licensed under Artistic License 2.0 |
10: * +------------------------------------------------------------+
11: * | Author: Matt Saladna (msaladna@apisnetworks.com) |
12: * +------------------------------------------------------------+
13: */
14:
15: /**
16: * htaccess/htpasswd
17: *
18: * @package core
19: */
20: class Htpasswd_Module extends Module_Skeleton
21: {
22: const HTPASSWD_DIR = '/var/www/.htfiles';
23: const DEF_REALM_NAME = 'Restricted Area';
24:
25: /**
26: * {{{ void __construct(void)
27: *
28: * @ignore
29: */
30: public function __construct()
31: {
32: parent::__construct();
33: $this->exportedFunctions = array(
34: 'is_protected' => PRIVILEGE_SITE,
35: 'get_locations' => PRIVILEGE_SITE,
36: 'delete_location' => PRIVILEGE_SITE,
37: 'edit_location' => PRIVILEGE_SITE,
38: 'location_info' => PRIVILEGE_SITE
39: );
40: }
41:
42: public function is_protected($host, $path = '/')
43: {
44:
45: }
46:
47: public function protect_location(
48: $host,
49: $path = '/',
50: $realm = self::DEF_REALM_NAME,
51: $type = 'digest'
52: ) {
53:
54: }
55:
56: public function get_locations($host)
57: {
58:
59: }
60:
61: public function delete_location($host, $path)
62: {
63:
64: }
65:
66: public function edit_location($host, $path, $opts)
67: {
68:
69: }
70:
71: public function location_info($host, $path)
72: {
73:
74: }
75:
76: public function user_exists($host, $user)
77: {
78:
79: }
80:
81: public function add_user($host, $user, $passwd = null)
82: {
83:
84: }
85:
86: public function delete_user($host, $user)
87: {
88:
89: }
90:
91: public function get_users($host)
92: {
93:
94: }
95:
96: public function get_groups($host)
97: {
98:
99: }
100:
101: public function change_password($host, $user)
102: {
103:
104: }
105:
106: public function create_group($host, $group, $users = array())
107: {
108:
109: }
110:
111: public function user_in_group($host, $user, $group)
112: {
113:
114: }
115:
116: public function remove_user_group($host, $user, $group)
117: {
118:
119: }
120:
121: public function add_user_group($host, $user, $group)
122: {
123:
124: }
125:
126: public function delete_group($host, $group)
127: {
128:
129: }
130:
131: public function deauthorize_role($host, $role)
132: {
133:
134: }
135:
136: public function authorize_role($host, $role)
137: {
138:
139: }
140:
141: public function is_authorized($host, $role, $path = '/')
142: {
143:
144: }
145:
146: /**
147: * Load .htpasswd
148: *
149: * @param string $host host
150: * @return string .htpasswd contents
151: */
152: private function _load_htpasswd($host)
153: {
154: if (!preg_match(Regex::HTTP_HOST)) {
155: return error($host . ': invalid host');
156: }
157: $htpasswd = $this->domain_fs_path() . self::HTPASSWD_DIR . '/' . $host;
158: if (!file_exists($htpasswd)) {
159: return error(self::HTPASSWD_DIR . '/' . $host . ': htpasswd does not exist');
160: }
161:
162: return file_get_contents($htpasswd);
163: }
164:
165: private function _load_htaccess($host, $path = '/')
166: {
167:
168: }
169: }
170:
171: ?>
172: