grommunio /
grommunio-web
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Status codes returned by MAPI functions |
||
| 4 | * |
||
| 5 | * |
||
| 6 | */ |
||
| 7 | |||
| 8 | /* From winerror.h */ |
||
| 9 | // |
||
| 10 | // Success codes |
||
| 11 | // |
||
| 12 | define('S_OK', 0x00000000); |
||
| 13 | define('S_FALSE', 0x00000001); |
||
| 14 | define('SEVERITY_ERROR', 1); |
||
| 15 | |||
| 16 | /* from winerror.h */ |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Function to make an error |
||
| 20 | */ |
||
| 21 | function make_mapi_e($code) |
||
| 22 | { |
||
| 23 | return (int) mapi_make_scode(1, $code); |
||
| 24 | } |
||
| 25 | |||
| 26 | |||
| 27 | /** |
||
| 28 | * Function to make a warning |
||
| 29 | */ |
||
| 30 | function make_mapi_s($code) |
||
| 31 | { |
||
| 32 | return (int) mapi_make_scode(0, $code); |
||
| 33 | } |
||
| 34 | |||
| 35 | /* From mapicode.h */ |
||
| 36 | /* |
||
| 37 | * On Windows NT 3.5 and Windows 95, scodes are 32-bit values |
||
| 38 | * laid out as follows: |
||
| 39 | * |
||
| 40 | * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 |
||
| 41 | * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 |
||
| 42 | * +-+-+-+-+-+---------------------+-------------------------------+ |
||
| 43 | * |S|R|C|N|r| Facility | Code | |
||
| 44 | * +-+-+-+-+-+---------------------+-------------------------------+ |
||
| 45 | * |
||
| 46 | * where |
||
| 47 | * |
||
| 48 | * S - Severity - indicates success/fail |
||
| 49 | * |
||
| 50 | * 0 - Success |
||
| 51 | * 1 - Fail (COERROR) |
||
| 52 | * |
||
| 53 | * R - reserved portion of the facility code, corresponds to NT's |
||
| 54 | * second severity bit. |
||
| 55 | * |
||
| 56 | * C - reserved portion of the facility code, corresponds to NT's |
||
| 57 | * C field. |
||
| 58 | * |
||
| 59 | * N - reserved portion of the facility code. Used to indicate a |
||
| 60 | * mapped NT status value. |
||
| 61 | * |
||
| 62 | * r - reserved portion of the facility code. Reserved for internal |
||
| 63 | * use. Used to indicate HRESULT values that are not status |
||
| 64 | * values, but are instead message ids for display strings. |
||
| 65 | * |
||
| 66 | * Facility - is the facility code |
||
| 67 | * FACILITY_NULL 0x0 |
||
| 68 | * FACILITY_RPC 0x1 |
||
| 69 | * FACILITY_DISPATCH 0x2 |
||
| 70 | * FACILITY_STORAGE 0x3 |
||
| 71 | * FACILITY_ITF 0x4 |
||
| 72 | * FACILITY_WIN32 0x7 |
||
| 73 | * FACILITY_WINDOWS 0x8 |
||
| 74 | * |
||
| 75 | * Code - is the facility's status code |
||
| 76 | * |
||
| 77 | */ |
||
| 78 | define('NOERROR' ,0); |
||
| 79 | |||
| 80 | // The following codes don't use make_mapi_e because they are in the 0x000FF000 range, |
||
| 81 | // but we cannot use the HEX value as would make most sense as that would break in 64bit PHP |
||
| 82 | // (Gromox server will return a negative value, but PHP would convert this define into a positive |
||
| 83 | // value). Hence we declare the value exactly as we need it as integer and bypass the |
||
| 84 | // 32bit/64bit hell. |
||
| 85 | define('ecUnknownUser' ,0x000003EB); |
||
| 86 | define('ecLoginPerm' ,0x000003F2); |
||
| 87 | define('ecMsgCycle' ,0x00000504); |
||
| 88 | define('MAPI_E_CALL_FAILED' ,0x80004005); |
||
| 89 | define('MAPI_E_NOT_ENOUGH_MEMORY' ,0x8007000E); |
||
| 90 | define('MAPI_E_INVALID_PARAMETER' ,0x80070057); |
||
| 91 | define('MAPI_E_INTERFACE_NOT_SUPPORTED' ,0x80004002); |
||
| 92 | define('MAPI_E_NO_ACCESS' ,0x80070005); |
||
| 93 | |||
| 94 | define('MAPI_E_NO_SUPPORT' ,make_mapi_e(0x102)); |
||
| 95 | define('MAPI_E_BAD_CHARWIDTH' ,make_mapi_e(0x103)); |
||
| 96 | define('MAPI_E_STRING_TOO_LONG' ,make_mapi_e(0x105)); |
||
| 97 | define('MAPI_E_UNKNOWN_FLAGS' ,make_mapi_e(0x106)); |
||
| 98 | define('MAPI_E_INVALID_ENTRYID' ,make_mapi_e(0x107)); |
||
| 99 | define('MAPI_E_INVALID_OBJECT' ,make_mapi_e(0x108)); |
||
| 100 | define('MAPI_E_OBJECT_CHANGED' ,make_mapi_e(0x109)); |
||
| 101 | define('MAPI_E_OBJECT_DELETED' ,make_mapi_e(0x10A)); |
||
| 102 | define('MAPI_E_BUSY' ,make_mapi_e(0x10B)); |
||
| 103 | define('MAPI_E_NOT_ENOUGH_DISK' ,make_mapi_e(0x10D)); |
||
| 104 | define('MAPI_E_NOT_ENOUGH_RESOURCES' ,make_mapi_e(0x10E)); |
||
| 105 | define('MAPI_E_NOT_FOUND' ,make_mapi_e(0x10F)); |
||
| 106 | define('MAPI_E_VERSION' ,make_mapi_e(0x110)); |
||
| 107 | define('MAPI_E_LOGON_FAILED' ,make_mapi_e(0x111)); |
||
| 108 | define('MAPI_E_SESSION_LIMIT' ,make_mapi_e(0x112)); |
||
| 109 | define('MAPI_E_USER_CANCEL' ,make_mapi_e(0x113)); |
||
| 110 | define('MAPI_E_UNABLE_TO_ABORT' ,make_mapi_e(0x114)); |
||
| 111 | define('MAPI_E_NETWORK_ERROR' ,make_mapi_e(0x115)); |
||
| 112 | define('MAPI_E_DISK_ERROR' ,make_mapi_e(0x116)); |
||
| 113 | define('MAPI_E_TOO_COMPLEX' ,make_mapi_e(0x117)); |
||
| 114 | define('MAPI_E_BAD_COLUMN' ,make_mapi_e(0x118)); |
||
| 115 | define('MAPI_E_EXTENDED_ERROR' ,make_mapi_e(0x119)); |
||
| 116 | define('MAPI_E_COMPUTED' ,make_mapi_e(0x11A)); |
||
| 117 | define('MAPI_E_CORRUPT_DATA' ,make_mapi_e(0x11B)); |
||
| 118 | define('MAPI_E_UNCONFIGURED' ,make_mapi_e(0x11C)); |
||
| 119 | define('MAPI_E_FAILONEPROVIDER' ,make_mapi_e(0x11D)); |
||
| 120 | define('MAPI_E_UNKNOWN_CPID' ,make_mapi_e(0x11E)); |
||
| 121 | define('MAPI_E_UNKNOWN_LCID' ,make_mapi_e(0x11F)); |
||
| 122 | |||
| 123 | /* Flavors of E_ACCESSDENIED, used at logon */ |
||
| 124 | |||
| 125 | define('MAPI_E_PASSWORD_CHANGE_REQUIRED' ,make_mapi_e(0x120)); |
||
| 126 | define('MAPI_E_PASSWORD_EXPIRED' ,make_mapi_e(0x121)); |
||
| 127 | define('MAPI_E_INVALID_WORKSTATION_ACCOUNT' ,make_mapi_e(0x122)); |
||
| 128 | define('MAPI_E_INVALID_ACCESS_TIME' ,make_mapi_e(0x123)); |
||
| 129 | define('MAPI_E_ACCOUNT_DISABLED' ,make_mapi_e(0x124)); |
||
| 130 | define('MAPI_E_WEBAPP_FEATURE_DISABLED' ,make_mapi_e(0x125)); |
||
| 131 | |||
| 132 | /* MAPI base function and status object specific errors and warnings */ |
||
| 133 | |||
| 134 | define('MAPI_E_END_OF_SESSION' ,make_mapi_e(0x200)); |
||
| 135 | define('MAPI_E_UNKNOWN_ENTRYID' ,make_mapi_e(0x201)); |
||
| 136 | define('MAPI_E_MISSING_REQUIRED_COLUMN' ,make_mapi_e(0x202)); |
||
| 137 | define('MAPI_W_NO_SERVICE' ,make_mapi_s(0x203)); |
||
| 138 | |||
| 139 | /* Property specific errors and warnings */ |
||
| 140 | |||
| 141 | define('MAPI_E_BAD_VALUE' ,make_mapi_e(0x301)); |
||
| 142 | define('MAPI_E_INVALID_TYPE' ,make_mapi_e(0x302)); |
||
| 143 | define('MAPI_E_TYPE_NO_SUPPORT' ,make_mapi_e(0x303)); |
||
| 144 | define('MAPI_E_UNEXPECTED_TYPE' ,make_mapi_e(0x304)); |
||
| 145 | define('MAPI_E_TOO_BIG' ,make_mapi_e(0x305)); |
||
| 146 | define('MAPI_E_DECLINE_COPY' ,make_mapi_e(0x306)); |
||
| 147 | define('MAPI_E_UNEXPECTED_ID' ,make_mapi_e(0x307)); |
||
| 148 | |||
| 149 | define('MAPI_W_ERRORS_RETURNED' ,make_mapi_s(0x380)); |
||
| 150 | |||
| 151 | /* Table specific errors and warnings */ |
||
| 152 | |||
| 153 | define('MAPI_E_UNABLE_TO_COMPLETE' ,make_mapi_e(0x400)); |
||
| 154 | define('MAPI_E_TIMEOUT' ,make_mapi_e(0x401)); |
||
| 155 | define('MAPI_E_TABLE_EMPTY' ,make_mapi_e(0x402)); |
||
| 156 | define('MAPI_E_TABLE_TOO_BIG' ,make_mapi_e(0x403)); |
||
| 157 | |||
| 158 | define('MAPI_E_INVALID_BOOKMARK' ,make_mapi_e(0x405)); |
||
| 159 | |||
| 160 | define('MAPI_W_POSITION_CHANGED' ,make_mapi_s(0x481)); |
||
| 161 | define('MAPI_W_APPROX_COUNT' ,make_mapi_s(0x482)); |
||
| 162 | |||
| 163 | /* Transport specific errors and warnings */ |
||
| 164 | |||
| 165 | define('MAPI_E_WAIT' ,make_mapi_e(0x500)); |
||
| 166 | define('MAPI_E_CANCEL' ,make_mapi_e(0x501)); |
||
| 167 | define('MAPI_E_NOT_ME' ,make_mapi_e(0x502)); |
||
| 168 | |||
| 169 | define('MAPI_W_CANCEL_MESSAGE' ,make_mapi_s(0x580)); |
||
| 170 | |||
| 171 | /* Message Store, Folder, and Message specific errors and warnings */ |
||
| 172 | |||
| 173 | define('MAPI_E_CORRUPT_STORE' ,make_mapi_e(0x600)); |
||
| 174 | define('MAPI_E_NOT_IN_QUEUE' ,make_mapi_e(0x601)); |
||
| 175 | define('MAPI_E_NO_SUPPRESS' ,make_mapi_e(0x602)); |
||
| 176 | define('MAPI_E_COLLISION' ,make_mapi_e(0x604)); |
||
| 177 | define('MAPI_E_NOT_INITIALIZED' ,make_mapi_e(0x605)); |
||
| 178 | define('MAPI_E_NON_STANDARD' ,make_mapi_e(0x606)); |
||
| 179 | define('MAPI_E_NO_RECIPIENTS' ,make_mapi_e(0x607)); |
||
| 180 | define('MAPI_E_SUBMITTED' ,make_mapi_e(0x608)); |
||
| 181 | define('MAPI_E_HAS_FOLDERS' ,make_mapi_e(0x609)); |
||
| 182 | define('MAPI_E_HAS_MESSAGES' ,make_mapi_e(0x60A)); |
||
| 183 | define('MAPI_E_FOLDER_CYCLE' ,make_mapi_e(0x60B)); |
||
| 184 | define('MAPI_E_STORE_FULL' ,make_mapi_e(0x60C)); |
||
| 185 | |||
| 186 | define('MAPI_W_PARTIAL_COMPLETION' ,make_mapi_s(0x680)); |
||
| 187 | |||
| 188 | /* Address Book specific errors and warnings */ |
||
| 189 | |||
| 190 | define('MAPI_E_AMBIGUOUS_RECIP' ,make_mapi_e(0x700)); |
||
| 191 | |||
| 192 | /* ICS errors and warnings */ |
||
| 193 | |||
| 194 | define('SYNC_E_UNKNOWN_FLAGS', MAPI_E_UNKNOWN_FLAGS); |
||
| 195 | define('SYNC_E_INVALID_PARAMETER', MAPI_E_INVALID_PARAMETER); |
||
| 196 | define('SYNC_E_ERROR', MAPI_E_CALL_FAILED); |
||
| 197 | define('SYNC_E_OBJECT_DELETED', make_mapi_e(0x800)); |
||
| 198 | define('SYNC_E_IGNORE', make_mapi_e(0x801)); |
||
| 199 | define('SYNC_E_CONFLICT', make_mapi_e(0x802)); |
||
| 200 | define('SYNC_E_NO_PARENT', make_mapi_e(0x803)); |
||
| 201 | define('SYNC_E_INCEST', make_mapi_e(0x804)); |
||
| 202 | define('SYNC_E_UNSYNCHRONIZED', make_mapi_e(0x805)); |
||
| 203 | |||
| 204 | define('SYNC_W_PROGRESS', make_mapi_s(0x820)); |
||
| 205 | define('SYNC_W_CLIENT_CHANGE_NEWER', make_mapi_s(0x821)); |
||
| 206 | |||
| 207 | function mapi_strerror($e) |
||
| 208 | { |
||
| 209 | switch ($e) { |
||
| 210 | case S_OK: return "success"; |
||
| 211 | case MAPI_E_CALL_FAILED: return "An error of unexpected or unknown origin occurred"; |
||
| 212 | case MAPI_E_NOT_ENOUGH_MEMORY: return "Not enough memory was available to complete the operation"; |
||
| 213 | case MAPI_E_INVALID_PARAMETER: return "An invalid parameter was passed to a function or remote procedure call"; |
||
| 214 | case MAPI_E_INTERFACE_NOT_SUPPORTED: return "MAPI interface not supported"; |
||
| 215 | case MAPI_E_NO_ACCESS: return "An attempt was made to access a message store or object for which the user has insufficient permissions"; |
||
| 216 | case MAPI_E_NO_SUPPORT: return "Function is not implemented"; |
||
| 217 | case MAPI_E_BAD_CHARWIDTH: return "An incompatibility exists in the character sets supported by the caller and the implementation"; |
||
| 218 | case MAPI_E_STRING_TOO_LONG: return "In the context of this method call, a string exceeds the maximum permitted length"; |
||
| 219 | case MAPI_E_UNKNOWN_FLAGS: return "One or more values for a flags parameter were not valid"; |
||
| 220 | case MAPI_E_INVALID_ENTRYID: return "invalid entryid"; |
||
| 221 | case MAPI_E_INVALID_OBJECT: return "A method call was made using a reference to an object that has been destroyed or is not in a viable state"; |
||
| 222 | case MAPI_E_OBJECT_CHANGED: return "An attempt to commit changes failed because the object was changed separately"; |
||
| 223 | case MAPI_E_OBJECT_DELETED: return "An operation failed because the object was deleted separately"; |
||
| 224 | case MAPI_E_BUSY: return "A table operation failed because a separate operation was in progress at the same time"; |
||
| 225 | case MAPI_E_NOT_ENOUGH_DISK: return "Not enough disk space was available to complete the operation"; |
||
| 226 | case MAPI_E_NOT_ENOUGH_RESOURCES: return "Not enough system resources were available to complete the operation"; |
||
| 227 | case MAPI_E_NOT_FOUND: return "The requested object could not be found at the server"; |
||
| 228 | case MAPI_E_VERSION: return "Client and server versions are not compatible"; |
||
| 229 | case MAPI_E_LOGON_FAILED: return "A client was unable to log on to the server"; |
||
| 230 | case MAPI_E_SESSION_LIMIT: return "A server or service is unable to create any more sessions"; |
||
| 231 | case MAPI_E_USER_CANCEL: return "An operation failed because a user cancelled it"; |
||
| 232 | case MAPI_E_UNABLE_TO_ABORT: return "A ropAbort or ropAbortSubmit ROP request was unsuccessful"; |
||
| 233 | case MAPI_E_NETWORK_ERROR: return "An operation was unsuccessful because of a problem with network operations or services"; |
||
| 234 | case MAPI_E_DISK_ERROR: return "There was a problem writing to or reading from disk"; |
||
| 235 | case MAPI_E_TOO_COMPLEX: return "The operation requested is too complex for the server to handle (often w.r.t. restrictions)"; |
||
| 236 | case MAPI_E_BAD_COLUMN: return "The column requested is not allowed in this type of table"; |
||
| 237 | case MAPI_E_EXTENDED_ERROR: return "extended error"; |
||
| 238 | case MAPI_E_COMPUTED: return "A property cannot be updated because it is read-only, computed by the server"; |
||
| 239 | case MAPI_E_CORRUPT_DATA: return "There is an internal inconsistency in a database, or in a complex property value"; |
||
| 240 | case MAPI_E_UNCONFIGURED: return "unconfigured"; |
||
| 241 | case MAPI_E_FAILONEPROVIDER: return "failoneprovider"; |
||
| 242 | case MAPI_E_UNKNOWN_CPID: return "The server is not configured to support the code page requested by the client"; |
||
| 243 | case MAPI_E_UNKNOWN_LCID: return "The server is not configured to support the locale requested by the client"; |
||
| 244 | case MAPI_E_PASSWORD_CHANGE_REQUIRED: return "password change required"; |
||
| 245 | case MAPI_E_PASSWORD_EXPIRED: return "password expired"; |
||
| 246 | case MAPI_E_INVALID_WORKSTATION_ACCOUNT: return "invalid workstation account"; |
||
| 247 | case MAPI_E_INVALID_ACCESS_TIME: return "The operation failed due to clock skew between servers"; |
||
| 248 | case MAPI_E_ACCOUNT_DISABLED: return "account disabled"; |
||
| 249 | case MAPI_E_END_OF_SESSION: return "The server session has been destroyed, possibly by a server restart"; |
||
| 250 | case MAPI_E_UNKNOWN_ENTRYID: return "The EntryID passed to OpenEntry was created by a different MAPI provider"; |
||
| 251 | case MAPI_E_MISSING_REQUIRED_COLUMN: return "missing required column"; |
||
| 252 | case MAPI_W_NO_SERVICE: return "no service"; |
||
| 253 | case MAPI_E_BAD_VALUE: return "bad value"; |
||
| 254 | case MAPI_E_INVALID_TYPE: return "invalid type"; |
||
| 255 | case MAPI_E_TYPE_NO_SUPPORT: return "type no support"; |
||
| 256 | case MAPI_E_UNEXPECTED_TYPE: return "unexpected_type"; |
||
| 257 | case MAPI_E_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
| 258 | case MAPI_E_DECLINE_COPY: return "The provider implements this method by calling a support object method, and the caller has passed the MAPI_DECLINE_OK flag"; |
||
| 259 | case MAPI_E_UNEXPECTED_ID: return "unexpected id"; |
||
| 260 | case MAPI_W_ERRORS_RETURNED: return "The call succeeded, but the message store provider has error information available"; |
||
| 261 | case MAPI_E_UNABLE_TO_COMPLETE: return "A complex operation such as building a table row set could not be completed"; |
||
| 262 | case MAPI_E_TIMEOUT: return "An asynchronous operation did not succeed within the specified time-out"; |
||
| 263 | case MAPI_E_TABLE_EMPTY: return "A table essential to the operation is empty"; |
||
| 264 | case MAPI_E_TABLE_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
| 265 | case MAPI_E_INVALID_BOOKMARK: return "The bookmark passed to a table operation was not created on the same table"; |
||
| 266 | case MAPI_W_POSITION_CHANGED: return "position changed"; |
||
| 267 | case MAPI_W_APPROX_COUNT: return "approx count"; |
||
| 268 | case MAPI_E_WAIT: return "A wait time-out has expired"; |
||
| 269 | case MAPI_E_CANCEL: return "The operation had to be canceled"; |
||
| 270 | case MAPI_E_NOT_ME: return "not me"; |
||
| 271 | case MAPI_W_CANCEL_MESSAGE: return "cancel message"; |
||
| 272 | case MAPI_E_CORRUPT_STORE: return "corrupt store"; |
||
| 273 | case MAPI_E_NOT_IN_QUEUE: return "not in queue"; |
||
| 274 | case MAPI_E_NO_SUPPRESS: return "The server does not support the suppression of read receipts"; |
||
| 275 | case MAPI_E_COLLISION: return "A folder or item cannot be created because one with the same name or other criteria already exists"; |
||
| 276 | case MAPI_E_NOT_INITIALIZED: return "The subsystem is not ready"; |
||
| 277 | case MAPI_E_NON_STANDARD: return "non standard"; |
||
| 278 | case MAPI_E_NO_RECIPIENTS: return "A message cannot be sent because it has no recipients"; |
||
| 279 | case MAPI_E_SUBMITTED: return "A message cannot be opened for modification because it has already been sent"; |
||
| 280 | case MAPI_E_HAS_FOLDERS: return "A folder cannot be deleted because it still contains subfolders"; |
||
| 281 | case MAPI_E_HAS_MESSAGES: return "A folder cannot be deleted because it still contains messages"; |
||
| 282 | case MAPI_E_FOLDER_CYCLE: return "A folder move or copy operation would create a cycle"; |
||
| 283 | case MAPI_W_PARTIAL_COMPLETION: return "The call succeeded, but not all entries were successfully operated on"; |
||
| 284 | case MAPI_E_AMBIGUOUS_RECIP: return "An unresolved recipient matches more than one directory entry"; |
||
| 285 | case MAPI_E_STORE_FULL: return "Store full"; |
||
| 286 | default: return sprintf("%xh", $e); |
||
| 287 | } |
||
| 288 | } |
||
| 289 | |||
| 290 | |||
| 291 | ?> |
||
|
0 ignored issues
–
show
|
|||
| 292 |
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.