Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezwebdavcontentbackendauth.php
Go to the documentation of this file.
1 <?php
22 class eZWebDAVContentBackendAuth implements ezcWebdavAnonymousAuthenticator, ezcWebdavBasicAuthenticator, ezcWebdavAuthorizer, ezcWebdavLockAuthorizer
23 {
24 public function authenticateAnonymous( ezcWebdavAnonymousAuth $data )
25 {
26 // added by @ds to fix problems with IE6 SP2
27 $path = ezcWebdavServer::getInstance()->pathFactory->parseUriToPath( $_SERVER['REQUEST_URI'] );
28 return ( $path === '/' );
29 }
30
43 public function authenticateBasic( ezcWebdavBasicAuth $data )
44 {
45 $loginHandler = 'standard';
46
47 eZWebDAVContentBackend::appendLogEntry( "Got username: {$data->username}" );
48 // added by @ds to fix problems with IE6 SP2
49 if ( preg_match( '(^' . preg_quote( $_SERVER['SERVER_NAME'] ) . '(.+))', $data->username, $matches ) > 0 )
50 {
51 $data->username = $matches[1];
52 }
53 eZWebDAVContentBackend::appendLogEntry( "Processed to username: {$data->username}" );
54
55 $userClass = eZUserLoginHandler::instance( $loginHandler );
56 $user = $userClass->loginUser( $data->username, $data->password );
57
58 if ( !( $user instanceof eZUser ) )
59 {
60 return false;
61 }
62 eZWebDAVContentBackend::appendLogEntry( "AuthenticatedBasic" );
63 return true;
64 }
65
101 public function authorize( $user, $path, $access = self::ACCESS_READ )
102 {
103 $fullPath = $path;
104 if ( $fullPath === '' )
105 {
106 $fullPath = '/';
107 }
108
109 if ( $access === self::ACCESS_READ )
110 {
111 // reading the root (/) is allowed
112 return true;
113 }
114
115 $target = $this->splitFirstPathElement( $fullPath, $site );
116 if ( $target === ''
117 && $access === self::ACCESS_READ )
118 {
119 // reading the site list is allowed
120 return true;
121 }
122 else
123 {
124 if ( $target !== '' )
125 {
126 $target = $this->splitFirstPathElement( $target, $element );
127 }
128 }
129
130 if ( $target === '' && $access = self::ACCESS_WRITE )
131 {
132 // writing to second-level paths (/plain_site_user/) is not allowed
133 return false;
134 }
135
136 $user = eZUser::currentUser();
137 $result = $user->hasAccessTo( 'user', 'login' );
138 $accessWord = $result['accessWord'];
139
140 if ( $accessWord == 'limited' )
141 {
142 $hasAccess = false;
143 $policyChecked = false;
144 foreach ( array_keys( $result['policies'] ) as $key )
145 {
146 $policy =& $result['policies'][$key];
147 if ( isset( $policy['SiteAccess'] ) )
148 {
149 $policyChecked = true;
150 if ( in_array( eZSys::ezcrc32( $site ), $policy['SiteAccess'] ) )
151 {
152 $hasAccess = true;
153 break;
154 }
155 }
156 if ( $hasAccess )
157 {
158 break;
159 }
160 }
161 if ( !$policyChecked )
162 {
163 $hasAccess = true;
164 }
165 }
166 else if ( $accessWord == 'yes' )
167 {
168 $hasAccess = true;
169 }
170 else if ( $accessWord == 'no' )
171 {
172 $hasAccess = false;
173 }
174 return $hasAccess;
175 }
176
194 public function assignLock( $user, $lockToken )
195 {
196 // @as @todo implement
197 }
198
208 public function ownsLock( $user, $lockToken )
209 {
210 // @as @todo implement
211 }
212
224 public function releaseLock( $user, $lockToken )
225 {
226 // @as @todo implement
227 }
228
247 protected function splitFirstPathElement( $path, &$element )
248 {
249 if ( $path[0] == '/' )
250 {
251 $path = substr( $path, 1 );
252 }
253 $pos = strpos( $path, '/' );
254 if ( $pos === false )
255 {
256 $element = $path;
257 $path = '';
258 }
259 else
260 {
261 $element = substr( $path, 0, $pos );
262 $path = substr( $path, $pos + 1 );
263 }
264 return $path;
265 }
266 }
267 ?>
$access
if(! $user->isRegistered()) $access
Definition: authorize.php:88
eZSys\ezcrc32
static ezcrc32( $string)
Definition: ezsys.php:1298
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZWebDAVContentBackendAuth
Manages WebDAV basic authentication.
Definition: ezwebdavcontentbackendauth.php:23
eZWebDAVContentBackendAuth\authorize
authorize( $user, $path, $access=self::ACCESS_READ)
Definition: ezwebdavcontentbackendauth.php:101
eZWebDAVContentBackendAuth\releaseLock
releaseLock( $user, $lockToken)
Definition: ezwebdavcontentbackendauth.php:224
eZWebDAVContentBackendAuth\authenticateBasic
authenticateBasic(ezcWebdavBasicAuth $data)
Definition: ezwebdavcontentbackendauth.php:43
eZWebDAVContentBackendAuth\ownsLock
ownsLock( $user, $lockToken)
Definition: ezwebdavcontentbackendauth.php:208
eZWebDAVContentBackendAuth\assignLock
assignLock( $user, $lockToken)
Definition: ezwebdavcontentbackendauth.php:194
eZWebDAVContentBackendAuth\splitFirstPathElement
splitFirstPathElement( $path, &$element)
Definition: ezwebdavcontentbackendauth.php:247
eZWebDAVContentBackendAuth\authenticateAnonymous
authenticateAnonymous(ezcWebdavAnonymousAuth $data)
Definition: ezwebdavcontentbackendauth.php:24
eZWebDAVContentBackend\appendLogEntry
static appendLogEntry( $logString, $label=false)
Definition: ezwebdavcontentbackend.php:3086
$result
$result
Definition: companysearch.php:94
$element
if(! $parent) $element
Definition: folder.php:64
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.