[imp] Quota/logfile.php
Tim Gorter
email@teletechnics.com
Thu, 3 Oct 2002 17:24:07 +0000
This message is in MIME format.
---------------------- multipart/mixed attachment
Attached is a driver for Quota extradition from a log file.
horde/imp/lib/Quota/logfile.php
It basically extracts the Quota information from a server logfile. This is for
when get_imap_quota is not supported. This basically looks at the tail of the
logfile (may it be messages or similar) and extracts the info needed.
all parameters needed are listed at the top of the file.
Do note that for this to work your logfile needs to be readable, and thus you
may want to adjust how your server keeps your logs.
cheers,
tim.
---------------------- multipart/mixed attachment
PD9waHANCi8qDQogKiAkSG9yZGU6IGltcC9saWIvUXVvdGEvbG9nZmlsZS5waHAsIHh4eHh4eHh4
eHh4eHh4eHh4eHggRXhwICQNCiAqDQogKiBTZWUgdGhlIGVuY2xvc2VkIGZpbGUgQ09QWUlORyBm
b3IgbGljZW5zZSBpbmZvcm1hdGlvbiAoR1BMKS4gSWYgeW91DQogKiBkaWQgbm90IHJlY2VpdmUg
dGhpcyBmaWxlLCBzZWUgaHR0cDovL3d3dy5mc2Yub3JnL2NvcHlsZWZ0L2dwbC5odG1sLg0KICov
DQoNCi8qKg0KICogSW1wbGVtZW50YXRpb24gb2YgdGhlIFF1b3RhIEFQSSBmb3Igc2VydmVycyB3
aGVyZSBJTUFQIFF1b3RhIGlzIG5vdCBzdXBwb3J0ZWQsIA0KICogYnV0IGl0IGFwcGVhcnMgaW4g
dGhlIHNlcnZlcnMgbWVzc2FnZXMgbG9nIGZvciB0aGUgSU1BUCBzZXJ2ZXIuDQogKg0KICogQGF1
dGhvciAgVGltIEdvcnRlciA8ZW1haWxAdGVsZXRlY2huaWNzLmNvLm56Pg0KICogQHZlcnNpb24g
JFJldmlzaW9uOiAxLjEgJA0KICogQHNpbmNlICAgSU1QIDQuMA0KICogQHBhY2thZ2UgaW1wDQog
KiANCiAqIHJlcXVpcmVzIGZvbGxvd2luZyBwYXJhbWV0ZXIgc2V0dGluZ3MgaW4gaW1wL3NlcnZl
cnMucGhwDQogKiAgICAncXVvd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NTCgkdXNhZ2UsICRzdG9yYWdlKTsNCiAg
ICAgICAgfQ0KICAgICAgICByZXR1cm4gJHRoaXMtPl9xdW90YUVycm9yKF8oIlVuYWJsZSB0byBy
ZXRyaWV2ZSBxdW90YSIpKTsNCiAgICB9DQoNCn0NCj8+
---------------------- multipart/mixed attachment--