1: <?php
2: /**
3: * Implementation of the Quota API for Mercury/32 IMAP servers.
4: * For reading Quota, read size folder user.
5: *
6: *****************************************************************************
7: * PROBLEM TO ACCESS NETWORK DIRECTORY
8: *****************************************************************************
9: * Matt Grimm
10: * 06-Jun-2003 10:25
11: *
12: * Thought I could help clarify something with accessing network shares on a
13: * Windows network (2000 in this case), running PHP 4.3.2 under Apache 2.0.44.
14: * However you are logged into the Windows box, your Apache service must be
15: * running under an account which has access to the share. The easiest (and
16: * probably least safe) way for me was to change the user for the Apache
17: * service to the computer administrator (do this in the service properties,
18: * under the "Log On" tab). After restarting Apache, I could access mapped
19: * drives by their assigned drive letter ("z:\\") or regular shares by their
20: * UNC path ("\\\\shareDrive\\shareDir").
21: *****************************************************************************
22: *
23: * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
24: *
25: * See the enclosed file COPYING for license information (GPL). If you
26: * did not receive this file, see http://www.horde.org/licenses/gpl.
27: *
28: * @author Frank Lupo <frank_lupo@email.it>
29: * @category Horde
30: * @license http://www.horde.org/licenses/gpl GPL
31: * @package IMP
32: */
33: class IMP_Quota_Mercury32 extends IMP_Quota_Base
34: {
35: /**
36: * Constructor.
37: *
38: * @param array $params Parameters:
39: * <pre>
40: * 'mail_user_folder' - (string) [REQUIRED] The path to folder mail
41: mercury.
42: * </pre>
43: *
44: * @throws IMP_Exception
45: */
46: public function __construct(array $params = array())
47: {
48: if (!isset($params['mail_user_folder'])) {
49: throw new IMP_Exception('Missing mail_user_folder parameter in quota config.');
50: }
51:
52: parent::__construct($params);
53: }
54:
55: /**
56: * Get quota information (used/allocated), in bytes.
57: *
58: * @return array An array with the following keys:
59: * 'limit' = Maximum quota allowed
60: * 'usage' = Currently used portion of quota (in bytes)
61: * @throws IMP_Exception
62: */
63: public function getQuota()
64: {
65: $quota = 0;
66:
67: try {
68: $di = new DirectoryIterator($this->_params['mail_user_folder'] . '/' . $this->_params['username'] . '/');
69: } catch (UnexpectedValueException $e) {
70: throw new IMP_Exception(_("Unable to retrieve quota"));
71: }
72:
73: foreach ($di as $val) {
74: $quota += $val->getSize();
75: }
76:
77: return array(
78: 'limit' => 0,
79: 'usage' => $quota
80: );
81: }
82:
83: }
84: