summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2010-09-29 10:04:09 +0000
committerthomascube <thomas@roundcube.net>2010-09-29 10:04:09 +0000
commitb9c08759f0433d9a24f0c8595c16624684f63e0d (patch)
tree472b055c14714e60cf60b1cf07955a30e99f505d
parent2baa16ae6d8355e0dfb38e400fd4115057b0680d (diff)
Remove development stuff and update versions
-rw-r--r--CHANGELOG812
-rw-r--r--README8
-rwxr-xr-xbin/dumpschema.sh101
-rwxr-xr-xbin/makedoc.sh25
-rw-r--r--index.php2
-rw-r--r--plugins/enigma/README33
-rw-r--r--plugins/enigma/config.inc.php14
-rw-r--r--plugins/enigma/enigma.js207
-rw-r--r--plugins/enigma/enigma.php472
-rw-r--r--plugins/enigma/home/.htaccess2
-rw-r--r--plugins/enigma/lib/Crypt/GPG.php2542
-rw-r--r--plugins/enigma/lib/Crypt/GPG/DecryptStatusHandler.php336
-rw-r--r--plugins/enigma/lib/Crypt/GPG/Engine.php1758
-rw-r--r--plugins/enigma/lib/Crypt/GPG/Exceptions.php473
-rw-r--r--plugins/enigma/lib/Crypt/GPG/Key.php223
-rw-r--r--plugins/enigma/lib/Crypt/GPG/Signature.php428
-rw-r--r--plugins/enigma/lib/Crypt/GPG/SubKey.php649
-rw-r--r--plugins/enigma/lib/Crypt/GPG/UserId.php373
-rw-r--r--plugins/enigma/lib/Crypt/GPG/VerifyStatusHandler.php216
-rw-r--r--plugins/enigma/lib/enigma_driver.php106
-rw-r--r--plugins/enigma/lib/enigma_driver_gnupg.php305
-rw-r--r--plugins/enigma/lib/enigma_engine.php547
-rw-r--r--plugins/enigma/lib/enigma_error.php62
-rw-r--r--plugins/enigma/lib/enigma_key.php129
-rw-r--r--plugins/enigma/lib/enigma_signature.php34
-rw-r--r--plugins/enigma/lib/enigma_subkey.php57
-rw-r--r--plugins/enigma/lib/enigma_ui.php410
-rw-r--r--plugins/enigma/lib/enigma_userid.php31
-rw-r--r--plugins/enigma/localization/en_US.inc48
-rw-r--r--plugins/enigma/skins/default/enigma.css182
-rw-r--r--plugins/enigma/skins/default/enigma.pngbin1592 -> 0 bytes
-rw-r--r--plugins/enigma/skins/default/enigma_error.pngbin1960 -> 0 bytes
-rw-r--r--plugins/enigma/skins/default/key.pngbin1743 -> 0 bytes
-rw-r--r--plugins/enigma/skins/default/key_add.pngbin1967 -> 0 bytes
-rw-r--r--plugins/enigma/skins/default/keys_toolbar.pngbin14977 -> 0 bytes
-rw-r--r--plugins/enigma/skins/default/templates/keyimport.html20
-rw-r--r--plugins/enigma/skins/default/templates/keyinfo.html17
-rw-r--r--plugins/enigma/skins/default/templates/keys.html76
-rwxr-xr-xprogram/include/iniset.php2
-rw-r--r--tests/mailfunc.php136
-rw-r--r--tests/modcss.php45
-rwxr-xr-xtests/runtests.sh54
-rw-r--r--tests/src/BID-26800.txt52
-rw-r--r--tests/src/apple.vcf49
-rw-r--r--tests/src/htmlbody.txt51
-rw-r--r--tests/src/htmlxss.txt22
-rw-r--r--tests/src/johndoe.vcf11
-rw-r--r--tests/src/mailto.txt8
-rw-r--r--tests/src/plainbody.txt37
-rw-r--r--tests/src/valid.css30
-rw-r--r--tests/vcards.php53
51 files changed, 2 insertions, 11246 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 510df78dd..7f8076002 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,815 +32,3 @@ CHANGELOG Roundcube Webmail
- Fix list_cols is not updated after column dragging (#1486999)
- Support %z variable in host configuration options (#1487003)
-RELEASE 0.4
------------
-- Fix disapearing upload form disapears when user selects a file on Safari (#1486823)
-- Don't replace error messages with loading info (#1486300)
-- Fix JS errors on compose mode switch (#1486870)
-- Fix message structure parsing when it lacks optional fields (#1486881)
-- Include all recipients in sendmail log
-- Support HTTP_X_FORWARDED_PROTO header for HTTPS detecting (#1486866)
-- Fix default IMAP port configuration (#1486864)
-- Create Sent folder when starting to compose a new message (#1486802)
-- Fix handling of messages with Content-Type: application/* and no filename (#1484050)
-- Improved compose screen: resizable body and attachments list, vertical splitter, options menu
-- Fix RC forgets search results (#1483883)
-- TinyMCE 3.3.7
-- Improve parsing of styled empty tags in HTML messages (#1486812)
-- Add %dc variable support in base_dn/bind_dn config (#1486779)
-- Add button to hide/unhide the preview pane (#1484215)
-- Fix no-cache headers on https to prevent content caching by proxies (#1486798)
-- Fix attachment filenames broken with TNEF decoder using long filenames (#1486795)
-- Use user's timezone in Date header, not server's timezone (#1486119)
-- Add option to set separate footer for HTML messages (#1486660)
-- Add real SMTP error description to displayed error messages (#1485927)
-- Fix some IMAP errors handling when opening the message (#1485443)
-- Fix related parts aren't displayed when got mimetype other than image/* (#1486432)
-- Multiple identity and database support for squirrelmail_usercopy plugin (#1486517)
-- Support dynamic hostname (%d/%n) variables in configuration options (#1485438)
-- Add 'messages_list' hook (#1486266)
-- Add request* event triggers in http_post/http_request (#1486054)
-- Fix use RFC-compliant line-delimiter when saving messages on IMAP (#1486712)
-- Add 'imap_timeout' option (#1486760)
-- Fix forwarding of messages with winmail attachments
-- Fix handling of uuencoded attachments in message body (#1485839)
-- Added list_mailboxes hook in rcube_imap::list_unsubscribed() (#1486668)
-- Fix wrong message on file upload error (#1486725)
-- Add support for data URI scheme [RFC2397] (#1486740)
-- Added 'actionbefore', 'actionafter', 'responsebefore', 'responseafter' events
-- Fix double-addition of e-mail domain to content ID in HTML images
-- Read and send messages with format=flowed (#1484370), fixes word wrapping issues (#1486543)
-- Fix duplicated attachments when forwarding a message (#1486487)
-- Fix message/rfc822 attachments containing only attachments are not parsed properly (#1486743)
-- Fix %00 character in winmail.dat attachments names (#1486738)
-- Fix handling errors of folder deletion (#1486705)
-- Parse untagged CAPABILITY response for LOGIN command (#1486742)
-- Renamed all php-cli scripts to use .sh extension
-- Some files from /bin + spellchecking actions moved to the new 'utils' task
-- Added thread tree icons
-- Extend contact groups support (#1486682)
-- Fix check-recent action issues and performance (#1486526)
-- Fix messages order after checking for recent (#1484664)
-- Fix autocomplete shows entries without email (#1486452)
-- Fix listupdate event doesn't trigger on search response (#1486708)
-- Fix select_all_mode value after selecting a message (#1486720)
-- Set focus to editor on reply in HTML mode (#1486632)
-- Fix composing in HTML jumps cursor to body instead of recipients (#1486674)
-- Allow columns order change per user - drag&drop (#1485795)
-- Add References header in read receipt (#1486681)
-- Fix database constraint violation when opening a message (#1486696)
-- Add 'loading' message while login is in progress (#1486667)
-- Fix quota_zero_as_unlimited (#1486662)
-- Fix folder subscription checking (#1486684)
-- Fix INBOX appears (sometimes) twice in mailbox list (#1486672)
-- Fix listing of attachments of some types e.g. "x-epoc/x-sisx-app" (#1486653)
-- Fix DB Schema checking when some db_table_* options are not set (#1486654)
-
-RELEASE 0.4-beta
-----------------
-- Add sizelimit and timelimit variables in LDAP config (#1486544)
-- Hide IMAP host dropdown when single host is defined (#1486326)
-- Add images pre-loading on login page (#1451160)
-- Add HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR to successful logins log (#1486441)
-- Fix setting spellcheck languages with extended codes (#1486605)
-- Fix messages list scrolling in FF3.6 (#1486472)
-- Fix quicksearch input focus (#1486637)
-- Always set changed date when flagging a DB record as deleted + provide a cleanup script
-- Fix address book/group selection (#1486619)
-- Assign newly created contacts to the active group (#1486626)
-- Added option not to mark messages as read when viewed in preview pane (#1485012)
-- Allow plugins modify the Sent folder when composing (#1486548)
-- Added optional (max_recipients) support to restrict total number of recipients per message (#1484542)
-- Re-organize editor buttons, add blockquote and search buttons
-- Make possible to write inside or after a quoted html message (#1485476)
-- Fix bugs on unexpected IMAP connection close (#1486190, #1486270)
-- Iloha's imap.inc rewritten into rcube_imap_generic class
-- Added contact groups in address book (not finished yet)
-- Added PageUp/PageDown/Home/End keys support on lists (#1486430)
-- Added possibility to select all messages in a folder (#1484756)
-- Added 'imap_force_caps' option for after-login CAPABILITY checking (#1485750)
-- Password: Support dovecotpw encryption
-- TinyMCE 3.3.1
-- Implemented messages copying using drag&drop + SHIFT (#1484086)
-- Improved performance of folders operations (#1486525)
-- Fix blocked.gif attachment is not attached to the message (#1486516)
-- Managesieve: import from Horde-INGO
-- Managesieve: support for more than one match (#1486078)
-- Managesieve: support for selectively disabling rules within a single sieve script (#1485882)
-- Threaded message listing now available
-- Added sorting by ARRIVAL and CC
-- Message list columns configurable by the user
-- Removed 'index_sort' option, now we're using empty 'message_sort_col' for this
-- virtuser_query: support other identity data (#1486148)
-- Options virtuser_* replaced with virtuser_* plugins
-- Plugin API: Implemented 'email2user' and 'user2email' hooks
-- Fix forwarding message omits CC header (#1486305)
-- Add 'default_charset' option to user preferences (#1485451)
-- Add 'delete_always' option to user preferences
-- Support/Require tls:// prefix in 'smtp_server' option for TLS connections
-- Fix inconsistent behaviour of 'delete_always' option (#1486299)
-- Fix deleting all messages from last list page (#1486293)
-- Flag original messages when sending a draft (#1486203)
-- Changed signature separator when top-posting (#1486330)
-- Let the admin define defaults for search modifiers (#1485897)
-- Fix long e-mail addresses validation (#1486453)
-- Remember search modifiers in user prefs (#1486146)
-- Added force_7bit option to force MIME encoding of plain/text messages (#1486510)
-- Use case sensitive check when checking for default folders (#1486346)
-- Fix checking for new mail: now checks unseen count of inbox (#1485794)
-- Improve performance by avoiding unnecessary updates to the session table (#1486325)
-- Fix invalid <font> tags which cause HTML message rendering problems (#1486521)
-- Fix CVE-2010-0464: Disable DNS prefetching (#1486449)
-- Fix Received headers to behave better with SpamAssassin (#1486513)
-- Password: Make passwords encoding consistent with core, add 'password_charset' global option (#1486473)
-- Fix adding contacts SQL error on mysql (#1486459)
-- Squirrelmail_usercopy: support reply-to field (#1486506)
-- Fix IE spellcheck suggestion popup issue (#1486471)
-- Fix email address auto-completion shows regexp pattern (#1486258)
-- Fix merging of configuration parameters: user prefs always survive (#1486368)
-- Fix quota indicator value after folder purge/expunge (#1486488)
-- Fix external mailto links support for use as protocol handler (#1486037)
-- Fix attachment excessive memory use, support messages of any size (#1484660)
-- Fix setting task name according to auth state
-- Password: fix vpopmaild driver (#1486478)
-- Add workaround for MySQL bug [http://bugs.mysql.com/bug.php?id=46293] (#1486474)
-- Fix quoted text wrapping when replying to an HTML email in plain text (#1484141)
-- Fix handling of extended mailto links (with params) (#1486354)
-- Fix sorting by date of messages without date header on servers without SORT (#1486286)
-- Fix inconsistency when not using default table names (#1486467)
-- Fix folder rename/delete buttons do not appear on creation of first folder (#1486468)
-- Fix character set conversion fails on systems where iconv doesn't accept //IGNORE (#1486375)
-- Log in performance: Create default folders on first login only
-- Import contacts into the selected address book (by Phil Weir)
-- Add support for MDB2's 'sqlsrv' driver (#1486395)
-- Use jQuery-1.4
-- Removed problematic browser-caching of messages
-- Fix incompatybility with suhosin.executor.disable_emodifier (#1486321)
-- Use PLAIN auth when CRAM fails and imap_auth_type='check' (#1486371)
-- Fix removal of <title> tag from HTML messages (#1486432)
-- Fix 'force_https' to specified port when URL contains a port number (#1486411)
-- Fix to-text converting of HTML entities inside b/strong/th/hX tags (#1486422)
-- Bug in spellchecker suggestions when server charset != UTF8 (#1486406)
-- Managesieve: Fix requires generation for multiple actions (#1486397)
-- Fix LDAP problem with special characters in RDN (#1486320)
-- Improved handling of message parts of type message/rfc822
-- Plugin API: added 'quota' hook
-- Fix parsing conditional comments in HTML messages (#1486350)
-- Use built-in json_encode() for proper JSON format in AJAX replies
-- Allow setting only selected params in 'message_compose' hook (#1486312)
-- Plugin API: added 'message_compose_body' hook (#1486285)
-- Fix counters of all folders are checked in 'getunread' action with check_all_folders disabled (#1486128)
-- Fix displaying alternative parts in messages of type message/rfc822 (#1486246)
-- Fix possible messages exposure when using Roundcube behind a proxy (#1486281)
-- Fix unicode para and line separators in javascript response (#1486310)
-- Additional_message_headers: allow unsetting headers, support plugin's config file (#1486268)
-- Fix displaying of hidden directories in skins list (#1486301)
-- Fix open_basedir restriction error when reading skins list (#1486304)
-- Fix pasting from Office apps into html editor (#1486271)
-- Fix empty <a> tags parsing (#1486272)
-- Don't cut off attachment names when using non-RFC2231 encoding (#1485515)
-- Allow inserting signatures above replied message body (#1484272)
-- Managesieve 2.0: multi-script support
-- Fix imap_auth_type regression (#1486263)
-
-RELEASE 0.3.1
-------------------
-- Specify toolbar container in compose template (#1486247)
-- Fix $_SERVER['HTTPS'] check for SSL forcing on IIS (#1486243)
-- Avoid unnecessary page loads for selected tab (#1486032)
-- Fix quota indicator issues by content generation on client-size (#1486197, #1486220)
-- Don't display disabled sections in Settings (#1486099)
-- Added server-side e-mail address validation with 'email_dns_check' option (#1485857)
-- Fix login page loading into an iframe when session expires (#1485952)
-- Allow setting port number in 'force_https' option (#1486091)
-- Option 'force_https' replaced by 'force_https' plugin
-- Fix IE issue with non-UTF-8 characters in AJAX response (#1486159)
-- Partially fixed "empty body" issue by showing raw body of malformed message (#1486166)
-- Fix importing/sending to email address with whitespace (#1486214)
-- Added XIMSS (CommuniGate) driver for Password plugin
-- Fix newly attached files are not saved in drafts w/o editing any text (#1486202)
-- Added attachment upload indicator with parallel upload (#1486058)
-- Use default_charset for bodies of messages without charset definition (#1486187)
-- Password: added cPanel driver
-- Fix return to first page from e-mail screen (#1486105)
-- Fix handling HTML comments in HTML messages (#1486189)
-- Fix folder/messagelist controls alignment - icons used (#1486072)
-- Fix LDAP addressbook shows 'Contact not found' error sometimes (#1486178)
-- Fix cache status checking + improve cache operations performance (#1486104)
-- Prevent from setting INBOX as any of special folders (#1486114)
-- Fix regular expression for e-mail address (#1486152)
-- Fix Received header format
-- Implemented sorting by message index - added 'index_sort' option (#1485936)
-- Fix dl() use in installer (#1486150)
-- Added 'ldap_debug' option
-- Fix "Empty startup greeting" bug (#1486085)
-- Fix setting user name in 'new_user_identity' plugin (#1486137)
-- Fix incorrect count of new messages in folder list when using multiple IMAP clients (#1485995)
-- Fix all folders checking for new messages with disabled caching (#1486128)
-- Support skins in 'archive' and 'markasjunk' plugins
-- Added 'html_editor' hook (#1486068)
-- Fix DB constraint violation when populating messages cache (#1486052)
-- Password: added password strength options (#1486062)
-- Fix LDAP partial result warning (#1485536)
-- Fix delete in message view deletes permanently with flag_for_deletion=true (#1486101)
-- Use faster/secure mt_rand() (#1486094)
-- Fix roundcube hangs on empty inbox with bincimapd (#1486093)
-- Fix wrong headers for IE on servers without $_SERVER['HTTPS'] (#1485926)
-- Force IE style headers for attachments in non-HTTPS session, 'use_https' option (#1485655)
-- Check 'post_max_size' for upload max filesize (#1486089)
-- Password Plugin: Fix %d inserts username instead of domain (#1486088)
-- Fix rcube_mdb2::affected_rows() (#1486082)
-
-RELEASE 0.3-stable
-------------------
-- Fix gn and givenName should be synonymous in LDAP addressbook (#1485892)
-- Add mail_domain to LDAP email entries without @ sign (#1485201)
-- Fix saving empty values in LDAP contact data (#1485781)
-- Fix LDAP contact update when RDN field is changed (#1485788)
-- Fix LDAP attributes case senitivity problems (#1485830)
-- Fix LDAP addressbook browsing when only one directory is used (#1486022)
-- Fix endless loop on error response for APPEND command (#1486060)
-- Don't require date.timezone setting in installer (#1485989)
-- Fix date sorting problem with Courier IMAP server (#1486065)
-- Unselect pressed buttons on mouse up (#1485987)
-- Don't set php_value error_log in .htaccess but mention in INSTALL (#1485924)
-- Fix too small status/flag/attachment columns in Safari 4 (#1486063)
-- Fix selection disabling while dragging splitter in webkit browsers (#1486056)
-- Added 'new_messages' plugin hook (#1486005)
-- Added 'logout_after' plugin hook (#1486042)
-- Added 'message_compose' hook
-- Added 'imap_connect' hook (#1485956)
-- Fix vcard_attachments plugin (#1486035)
-- Updated PEAR::Auth_SASL to 1.0.3 version
-- Use sequence names only with PostgreSQL (#1486018)
-- Re-designed User Preferences interface
-- Fix MS SQL DDL (#1486020)
-- Fix rcube_mdb2.php: call to setCharset not implemented in mssql driver (#1486019)
-- Added 'display_next' option
-- Fix rcube_mdb2::unixtimestamp for MS SQL (#1486015)
-- Fix HTML washing to respect character encoding
-- Fix endless loop in iil_C_Login() with Courier IMAP (#1486010)
-- Fix #messagemenu display on IE (#1486006)
-- Speedup UI by using sprites for (toolbar) buttons
-- Fix charset names with X- prefix handling
-- Fix displaying of HTML messages with unknown/malformed tags (#1486003)
-
-RELEASE 0.3-RC1
----------------
-- Fix import of vCard entries with params (#1485453)
-- Fix HTML messages output with empty block elements (#1485974)
-- Use request tokens to protect POST requests from CSRF
-- Added hook when killing a session
-- Added hook to write_log function (#1485971)
-- Performance improvements by use UID commands (#1485690)
-- Fix HTML editor tabIndex setting (#1485972)
-- Added 'imap_debug' and 'smtp_debug' options
-- Support strftime's format modifiers in date_* options (#1484806)
-- Support %h variable in 'smtp_server' option (#1485766)
-- Show SMTP errors in browser (#1485927)
-- Allow WBR tag in HTML message (#1485960)
-- Use spl_autoload_register() instead of __autoload (#1485947)
-- Add hook for identities listing (#1485958)
-- Trigger hook 'smtp_connect' when opening an SMTP connection (#1485954)
-- Added config option to enforce HTTPS connections
-- Fix non-unicode characters caching in unicode database (#1484608)
-- Performance improvements of messages caching
-- Fix empty Date header issue (#1485923)
-- Open collapsed folders during drag & drop (#1485914)
-- Fixed link text replacements (#1485789)
-- Also trigger 'insertrow' events on page load (#1485826)
-- No link on subject in IE browsers (#1484913)
-- Fixed filename encoding according to RFC2231 (#1485875)
-- Added message Edit feature (#1483891, #1484440)
-- Fix message Etag generation for counter issues (#1485623)
-- Fix messages searching on MailEnable IMAP (#1485762)
-- Fixed many 'skip_deleted' issues (#1485634)
-- Fixed messages list sorting on servers without SORT capability
-- Colorized signatures in plain text messages
-- Reviewed/fixed skip_deleted/read_when_deleted/flag_for_deletion options handling in UI
-- Fix displaying of big maximum upload filesize (#1485889)
-- Added possibility to invert messages selection
-- After move/delete from 'show' action display next message instead of messages list (#1485887)
-- Fixed problem with double quote at the end of folder name (#1485884)
-- Speedup UI by using CSS sprites and etags/expires/deflate in Apache config (#1484858,#1485800)
-- Support UID EXPUNGE: remove only moved/deleted messages
-- Add drag cancelling with ESC key (#1484344)
-- Support initial identity name from virtuser_query (#1484003)
-- Added message menu, removed Print and Source buttons
-- Added possibility to save message as .eml file (#1485861)
-- Added 1 minute interval in autosave options (#1485854)
-- Support UTF-7 encoding in messages (#1485832)
-- Better support for malformed character names (#1485758)
-
-RELEASE 0.3-BETA
-----------------
-- Plugin API + jQuery engine
-- Added possibility to encrypt received header, option 'http_received_header_encrypt',
- added some more logic in encrypt/decrypt functions for security
-- Fix Answered/Forwarded flag setting for messages in subfolders
-- Fix autocomplete problem with capital letters (#1485792)
-- Support UUencode content encoding (#1485839)
-- Minimize chance of race condition in session handling (#1485659, #1484678)
-- Fix session handling on non-session SQL query error (#1485734)
-- Fix html editor mode setting when reopening draft message (#1485834)
-- Added quick search box menu (#1484304)
-- Fix wrong column sort order icons (#1485823)
-- Updated TinyMCE to 3.2.3 version
-- Fix attachment names encoding when charset isn't specified in attachment part (#1484969)
-- Fix message normal priority problem (#1485820)
-- Fix autocomplete spinning wheel does not disappear (#1485804)
-- Added log_date_format option (#1485709)
-- Fix text wrapping in HTML editor after switching from plain text to HTML (#1485521)
-- Fix auto-complete function hangs with plus sign (#1485815)
-- Fix AJAX requests errors handler (#1485000)
-- Speed up message list displaying on IE
-- Fix read/write database recognition (#1485811)
-
-RELEASE 0.2.2
--------------
-- Fix quicksearchbox look in Chrome and Konqueror (#1484841)
-- Fix UTF-8 byte-order mark removing (#1485514)
-- Fix folders subscribtions on Konqueror (#1484841)
-- Fix debug console on Konqueror and Safari
-- Fix messagelist focus issue when modifying status of selected messages (#1485807)
-- Support STARTTLS in IMAP connection (#1485284)
-- Fix DEL key problem in search boxes (#1485528)
-- Support several e-mail addresses per user from virtuser_file (#1485678)
-- Fix drag&drop with scrolling on IE (#1485786)
-- Fix adding signature separator in html mode (#1485350)
-- Fix opening attachment marks message as read (#1485803)
-- Fix 'temp_dir' does not support relative path under Windows (#1484529)
-- Fix "Initialize Database" button missing from installer (#1485802)
-- Fix compose window doesn't fit 1024x768 window (#1485396)
-- Fix service not available error when pressing back from compose dialog (#1485552)
-- Fix using mail() on Windows (#1485779)
-- Fix word wrapping in message-part's <PRE>s for printing (#1485787)
-- Fix incorrect word wrapping in outgoing plaintext multibyte messages (#1485714)
-- Fix double footer in HTML message with embedded images
-- Fix TNEF implementation bug (#1485773)
-- Fix incorrect row id parsing for LDAP contacts list (#1485784)
-- Fix 'mode' parameter in sqlite DSN (#1485772)
-
-RELEASE 0.2.1
-------------------
-- Use US-ASCII as failover when Unicode searching fails (#1485762)
-- Fix errors handling in IMAP command continuations (#1485762)
-- Fix FETCH result parsing for servers returning flags at the end of result (#1485763)
-- Fix datetime columns defaults in mysql's DDL (#1485641)
-- Fix attaching more than nine inline images (#1485759)
-- Support 'UNICODE-1-1-UTF-7' alias for UTF-7 encoding (#1485758)
-- Fix mime-type detection using a hard-coded map (#1485311)
-- Don't return empty string if charset conversion failed (#1485757)
-- Disable concurrent autocomplete query results display (#1485743)
-- Fix new lines stripped from message footer (#1485751)
-- Fix IE problem with mouse click autocomplete (#1485739)
-- Fix html body washing on reply/forward + fix attachments handling (#1485676)
-- Fix multiple recipients input parsing (#1485733)
-- Fix replying to message with html attachment (#1485676)
-- Use default_charset for messages without specified charset (#1485661, #1484961)
-- Support non-standard "GMT-XXXX" literal in date header (#1485729)
-- Added TNEF support to decode MS Outlook attachments (winmail.dat)
-- Fix "value continuation" MIME headers by adding required semicolon (#1485727)
-- Fix pressing select all/unread multiple times (#1485723)
-- Fix selecting all unread does not honor new messages (#1485724)
-- Fix some base64 encoded attachments handling (#1485725)
-- Support NGINX as IMAP backend: better BAD response handling (#1485720)
-- Performance fix: don't fetch attachment parts headers twice to parse filename
-- Fix checking for recent messages on various IMAP servers (#1485702)
-- Performance fix: Don't fetch quota and recent messages in "message view" mode
-- Fix displaying of alternative-inside-alternative messages (#1485713)
-- Fix MDNSent flag checking, use arbitrary keywords (asterisk) flag (#1485706)
-- Fix creation of folders with '&' sign in name
-- Fix parsing of email addresses without angle brackets (#1485693)
-- Save spellcheck corrections when switching from plain to html editor (and spellchecking is on)
-- Fix large search results on server without SORT capability (#1485668)
-- Get rid of preg_replace() with eval modifier and create_function usage (#1485686)
-- Bring back <base> and <link> tags in HTML messages
-- Fix XSS vulnerability through background attributes as reported by Julien Cayssol
-- Fix problems with backslash as IMAP hierarchy delimiter (#1484467)
-- Secure vcard export by getting rid of preg's 'e' modifier use (#1485689)
-- Fix authentication when submitting form with existing session (#1485679)
-- Allow absolute URLs to images in HTML messages/sigs (#1485666)
-- Fix message body which contains both inline attachments and emotions
-- Fix SQL query execution errors handling in rcube_mdb2 class (#1485509)
-- Fix address names with '@' sign handling (#1485654)
-- Improve messages display performance
-- Fix messages searching with 'to:' modifier
-
-RELEASE 0.2-STABLE
-------------------
-- Fix mark popup in IE 7 (#1485369)
-- Fix line-break issue when copy & paste in Firefox (#1485425)
-- Fix autocomplete "unknown server error" (#1485637)
-- Fix STARTTLS before AUTH in SMTP connection (#1484883)
-- Support multiple quota values in QUOTAROOT resonse (#1485626)
-- Only abbreviate file name for IE < 7 browsers (#1485063)
-- Performance: allow setting imap rootdir and delimiter before connect (#1485172)
-- Fix sorting of folders with more than 2 levels (#1485569)
-- Fix search results page jumps in LDAP addressbook (#1485253)
-- Fix empty line before the signature in IE (#1485351)
-- Fix horizontal scrollbar in preview pane on IE (#1484633)
-- Add Robots meta tag in login page and installer (#1484846)
-- Added 'show_images' option, removed 'addrbook_show_images' (#1485597)
-- Option to check for new mails in all folders (#1484374)
-- Don't set client busy when checking for new messages (#1485276)
-- Allow UTF-8 folder names in config (#1485579)
-- Add junk_mbox option configuration in installer (#1485579)
-- Do serverside addressbook queries for autocompletion (#1485531)
-- Allow setting attachment col position in 'list_cols' option
-- Allow override 'list_cols' via skin (#1485577)
-- Fix 'cache' table cleanup on session destroy (#1485516)
-- Increase speed of session destroy and garbage clean up
-- Fix session timeout when DB server got clock skew (#1485490)
-- Fix handling of some malformed messages (#1484438)
-- Speed up raw message body handling
-- Better HTML entities conversion in html2text (#1485519)
-- Fix big memory consumption and speed up searching on servers without SORT capability
-- Fix setting locale to tr_TR, ku and az_AZ (#1485470)
-- Use SORT for searching on servers with SORT capability
-- Added message status filter
-- Fix empty file sending (#1485389)
-- Improved searching with many criterias (calling one SEARCH command)
-- Fix HTML editor initialization on IE (#1485304)
-- Add warning when switching editor mode from html to plain (#1485488)
-- Make identities list scrollable (#1485538)
-- Fix problem with numeric folder names (#1485527)
-- Added BYE response simple support to prevent from endless loops in imap.inc (#1483956)
-- Fix unread message unintentionally marked as read if read_when_deleted=true (#1485409)
-- Remove port number from SERVER_NAME in smtp_helo_host (#1485518)
-- Don't send disposition notification receipts for messages marked as 'read' (#1485523)
-- Added 'keep_alive' and 'min_keep_alive' options (#1485360)
-- Added option 'identities_level', removed 'multiple_identities'
-- Allow deleting identities when multiple_identities=false (#1485435)
-- Added option focus_on_new_message (#1485374)
-- Fix html2text class autoloading on Windows (#1485505)
-- Fix html signature formatting when identity save error occured (#1485426)
-- Add feedback and set busy when moving folder (#1485497)
-- Fix 'Empty' link visibility for some languages e.g. Slovak (#1485489)
-- Fix messages count bar overlapping (#1485270)
-- Fix adding signature in drafts compose mode (#1485484)
-- Fix iil_C_Sort() to support very long and/or divided responses (#1485283)
-- Fix matching case sensitivity when setting identity on reply (#1485480)
-- Prefer default identity on reply
-- Fix imap searching on ISMail server (#1485466)
-- Add css class for flagged messages (#1485464)
-- Write username instead of id in sendmail log (#1485477)
-- Fix htmlspecialchars() use for PHP version < 5.2.3 (#1485475)
-- Fix js keywords escaping in json_serialize() for IE/Opera (#1485472)
-- Added bin/killcache.php script (#1485434)
-- Add support for SJIS, GB2312, BIG5 in rc_detect_encoding()
-- Fix vCard file encoding detection for non-UTF-8 strings (#1485410)
-- Add 'skip_deleted' option in User Preferences (#1485445)
-- Minimize "inline" javascript scripts use (#1485433)
-- Fix css class setting for folders with names matching defined classes names (#1485355)
-- Fix race conditions when changing mailbox
-- Fix spellchecking when switching to html editor (#1485362)
-- Fix compose window width/height (#1485396)
-- Allow calling msgimport.sh/msgexport.sh from any directory (#1485431)
-- Localized filesize units (#1485340)
-- Better handling of "no identity" and "no email in identity" situations (#1485117)
-- Added 'mime_param_folding' option with possibility to choose long/non-ascii attachment names encoding eg. to be readable in MS Outlook/OE (#1485320)
-- Added "advanced options" feature in User Preferences
-- Fix unread counter when displaying cached massage in preview panel (#1485290)
-- Fix htmleditor spellchecking on MS Windows (#1485397)
-- Fix problem with non-ascii attachment names in Mail_mime (#1485267, #1485096)
-- Fix language autodetection (#1485401)
-- Fix button label in folders management (#1485405)
-- Fix collapsed folder not indicating unread msgs count of all subfolders (#1485403)
-- Fix handling of apostrophes in filenames decoded according to rfc2231
-
-RELEASE 0.2-BETA
-----------------
-- Made config files location configurable (#1485215)
-- Reduced memory footprint when forwarding attachments (#1485345)
-- Allow and use spellcheck attribute for input/textarea fields (#1485060)
-- Added icons for forwarded/forwarded+replied messages (#1485257)
-- Added Reply-To to forwarded emails (#1485315)
-- Display progress message for folders create/delete/rename (#1485357)
-- Smart Tags and NOBR tag support in html messages (#1485363, #1485327)
-- Redesign of the identities settings (#1484042)
-- Add config option to disable creation/deletion of identities (#1484498)
-- Added 'sendmail_delay' option to restrict messages sending interval (#1484491)
-- Added vertical splitter for folders list resizing
-- Added possibility to view all headers in message view
-- Fixed splitter drag/resize on Opera (#1485170)
-- Fixed quota img height/width setting from template (#1484857)
-- Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)
-- Insert "virtual" folders in subscription list (#1484779)
-- Added link to open message in new window
-- Enable export of address book contacts as vCard
-- Add feature to import contacts from vcard files (#1326103)
-- Respect Content-Location headers in multipart/related messages according to RFC2110 (#1484946)
-- Allowed max. attachment size now indicated in compose screen (#1485030)
-- Also capture backspace key in list mode (#1484566)
-- Allow application/pgp parts to be displayed (#1484753)
-- Correctly handle options in mailto-links (#1485228)
-- Immediately save sort_col/sort_order in user prefs (#1485265)
-- Truncate very long (above 50 characters) attachment filenames when displaying
-- Allow to auto-detect client language if none set (#1484434)
-- Auto-detect the client timezone (user configurable)
-- Add RFC2231 header value continuations support for attachment filenames + hack for servers that not support that feature
-- Fix Reply-To header displaying (#1485314)
-- Mark form buttons that provide the most obvious operation (mainaction)
-- Added option 'quota_zero_as_unlimited' (#1484604)
-- Added PRE handling in html2text class (#1484740)
-- Added folder hierarchy collapsing
-- Added options to use syslog instead of log file (#1484850)
-- Added Logging & Debugging section in Installer
-- Fix In-Reply-To and References headers when composing saved draft message (#1485288)
-- Fix html message charset conversion for charsets with underline (#1485287)
-- Fix buttons status after contacts deletion (#1485233)
-- Fix escaping of To: and From: fields when building message body for reply or forward in the HTML editor (#1484904)
-- Use current mailbox name in template (#1485256)
-- Better fix for skipping untagged responses (#1485261)
-- Added pspell support patch by Kris Steinhoff (#1483960)
-- Enable spellchecker for HTML editor (#1485114)
-- Respect spellcheck_uri in tinyMCE spellchecker (#1484196)
-- Case insensitive contacts searching using PostgreSQL (#1485259)
-- Make default imap folders configurable for each user (#1485075)
-- Save outgoing mail to selectable folder (#1324581)
-- Fix hiding of mark menu when clicking th button again (#1484944)
-- Use long date format in print mode (#1485191)
-- Updated TinyMCE to version 3.1.0.1
-- Re-enable autocomplete attribute for login form (#1485211)
-- Check PERMANENTFLAGS before saving $MDNSent flag (#1484963, #1485163)
-- Added flag column on messages list (#1484623)
-- Patched Mail/MimePart.php (http://pear.php.net/bugs/bug.php?id=14232)
-- Allow trash/junk subfolders to be purged (#1485085)
-- Store compose parameters in session and redirect to a unique URL
-- Fixed CRAM-MD5 authentication (#1484819)
-- Fixed forwarding messages with one HTML attachment (#1484442)
-- Fixed encoding of message/rfc822 attachments and image/pjpeg handling (#1484914)
-- Added option to select skin in user preferences
-- Added option to configure displaying of attached images below the message body
-- Added option to display images in messages from known senders (#1484601)
-- User preferences grouped in more fieldsets
-- Fix corrupted MIME headers of messages in Sent folder (#1485111)
-- Fixed bug in MDB2 package: http://pear.php.net/bugs/bug.php?id=14124
-- Use keypress instead of keydown to select list's row (#1484816)
-- Don't call expunge and don't remove message row after message move if flag_for_deletion is set to true (#1485002)
-
-RELEASE 0.2-ALPHA
------------------
-- Added option to disable autocompletion from selected LDAP address books (#1484922)
-- TLS support in LDAP connections: 'use_tls' property (#1485104)
-- Fixed removing messages from search set after deleting them (#1485106)
-- imap.inc: Fixed iil_C_FetchStructureString() to handle many
- literal strings in response (#1484969)
-- Support for subfolders in default/protected folders (#1484665)
-- Disallowed delimiter in folder name (#1484803)
-- Support " and \ in folder names
-- Escape \ in login (#1484614)
-- Better HTML sanitization with the DOM-based washtml script (#1484701)
-- Fixed sorting of folders with non-ascii characters
-- Fixed Mysql DDL for default identities creation (#1485070)
-- In Preferences added possibility to configure 'read_when_deleted',
- 'mdn_requests', 'flag_for_deletion' options
-- Made IMAP auth type configurable (#1483825)
-- Fixed empty values with FROM_UNIXTIME() in rcube_mdb2 (#1485055)
-- Fixed attachment list on IE 6/7 (#1484807)
-- Fixed JavaScript in compose.html that shows cc/bcc fields if populated
-- Make password input fields of type password in installer (#1484886)
-- Don't attempt to delete cache entries if enable_caching is FALSE (#1485051)
-- Optimized messages sorting on servers without sort capability (#1485049)
-- Corrected message headers decoding when charset isn't specified and improved
- support for native languages (#1485050, #1485048)
-- Expanded LDAP configuration options to support LDAP server writes.
-- Installer: encode special characters in DB username/password (#1485042)
-- Fixed management of folders with national characters in names (#1485036, #1485001)
-- Fixed identities saving when using MDB2 pgsql driver (#1485032)
-- Fixed BCC header reset (#1484997)
-- Improved messages list performance - patch from Justin Heesemann
-- Append skin_path to images location only when it starts with '/' sign (#1484859)
-- Fix IMAP response in message body when message has no body (#1484964)
-- Fixed non-RFC dates formatting (#1484901)
-- Fixed typo in set_charset() (#1484991)
-- Decode entities when inserting HTML signature to plain text message (#1484990)
-- HTML editing is now working with PHP5 updates and TinyMCE v3.0.6
-- Fixed signature loading on Windows (#1484545)
-- Added language support to HTML editing (#1484862)
-- Fixed remove signature when replying (#1333167)
-- Fixed problem with line with a space at the end (#1484916)
-- Fixed <!DOCTYPE> tag filtering (#1484391)
-- Fixed <?xml> tag filtering (#1484403)
-- Added sections (fieldset+label) in Settings interface
-- Mark as read in one action with message preview (#1484972)
-- Deleted redundant quota reads (#1484972)
-- Added options for empty trash and expunge inbox on logout (#1483863)
-- Removed lines wrapping when displaying message
-- Fixed month localization
-- Changed codebase to PHP5 with autoloader
-
-RELEASE 0.1.1
--------------
-- Clear selection when selecting single item (#1484942)
-- Remove hard-coded image size in skin templates (#1484893)
-- Database schema improvements (dropped unnecessary indexes)
-- Fixed creating a new folder with a comma in its name (#1484681)
-- Fixed sorting of messages when default mailbox is empty (#1484317)
-- Improve message previewpane - less loading (#1484316)
-- Fixed login form autoompletion (#1484839)
-- Fixed virtuser_query option for mdb2 backend (#1484874)
-- Fixed attachment resoting from Drafts when message body was empty (#1484506)
-- Fixed usage of ob_gzhandler (#1484851)
-- Fixed message part window in IE6 (#1484610)
-- Fixed decoding of mime-encoded strings (#1484191)
-- Fixed some iconv/mb_string problems (#1484598)
-- Correctly quote mailbox name when using in URL (#1484313)
-- Fixed "headers already sent" errors (#1484860)
-
-RELEASE 0.1-STABLE
-------------------
-- Added interactive installer script
-- Fix folder adding/renaming inspired by #1484800
-- Localize folder name in page title (#1484785)
-- Fix code using wrong variable name (#1484018)
-- Allow to send mail with BCC recipients only
-- condense TinyMCE toolbar down to one line, removing table buttons (#1484747)
-- Add function to mark the selected messages as read/unread (#1457360)
-- Also do charset decoding as suggested in RFC 2231 (fix #1484321)
-- Show message count in folder list and hint when creating a subfolder
-- Distinguish ssl and tls for imap connections (#1484667)
-- Added some charset aliases to fix typical mis-labelling (#1484565)
-- Remember decision to display images for a certain message during session (#1484754)
-- Truncate attachment filenames to 55 characters due to an IE bug (#1484757)
-- Make sending of read receipts configurable
-- Respect config when localize folder names (#1484707)
-- Also respect receipt and priority settings when re-opening a draft message
-- Remember search results (closes #1483883), patch by the_glu
-- Add Received header on outgoing mail
-- Upgrade to TinyMCE 2.1.3
-- Allow inserting image attachments into HTML messages while composing (#1484557)
-- Implement Message-Disposition-Notification (Receipts)
-- Fix overriding of session vars when register_globals is on (#1484670)
-- Fix bug with case-sensitive folder names (#1484245)
-- Don't create default folders by default
-- Fixed some potential security risks (audited by Andris)
-- Only show new messages if they match the current search (#1484176)
-- Switch to/from when searcing in Sent folder (#1484555)
-- Correctly read the References header (#1484646)
-- Unset old cookie before sending a new value (#1484639)
-- Correctly decode attachments when downloading them (#1484645 and #1484642)
-- Suppress IE errors when clearing attachments form (#1484356)
-- Log error when login fails due to auto_create_user turned off
-- Filter linked/imported CSS files (closes #1484056)
-- Improve message compose screen (closes #1484383)
-- Select next row after removing one from list (#1484387)
-
-RELEASE 0.1-RC2
----------------
-- Enable drag-&-dropping of folders to a new parent and allow to create subfolders (#1457344)
-- Suppress IE errors when clearing attachments form (#1484356)
-- Set preferences field in user table to NULL (#1484386)
-- Log error when login fails due to auto_create_user turned off
-- Filter linked/imported CSS files (closes #1484056)
-- Improve message compose screen (closes #1484383)
-- Select next row after removing one from list (#1484387)
-- Make smtp HELO/EHLO hostname configurable (#1484067)
-- IPv6 Compatability (#1484322), Patch #1484373
-- Unlock interface when message sending fails (#1484570)
-- Eval PHP code in template includes (if configured)
-- Show message when folder is empty. Mo more static text in table (#1484395)
-- Only display unread count in page title when new messages arrived
-- Fixed wrong delete button tooltip (#1483965)
-- Fixed charset encoding bug (#1484429)
-- Applied patch for LDAP version (#1484552)
-- Improved XHTML validation
-- Fix message list selection (#1484550)
-- Better fix lowercased usernames (#1484473)
-- Update pngbehavior Script as suggested in #1484490
-- Fixed moving/deleting messages when more than 1 is selected
-- Applied patch for LDAP contacts listing by Glen Ogilvie
-- Applied patch for more address fields in LDAP contacts (#1484402)
-- Add alternative for getallheaders() (fix #1484508)
-- Identify mailboxes case-sensitive
-- Sort mailbox list case-insensitive (closes #1484338)
-- Fix display of multipart messages from Apple Mail (closes #1484027)
-- Protect AJAX request from being fetched by a foreign site (XSS)
-- Make autocomplete for loginform configurable by the skin template
-- Fix compose function from address book (closes #1484426)
-- Added //IGNORE to iconv call (patch #1484420, closes #1484023)
-- Check if mbstring supports charset (#1484290 and #1484292)
-- Prefer iconv over mbstring (as suggested in #1484292)
-- Check filesize of template includes (#1484409)
-- Fixed bug with buttons not dimming/enabling properly after switching folders
-- Fixed compose window becoming unresponsive after saving a draft (#1484487)
-- Re-enabled "Back" button in compose window now that bug #1484487 is fixed
-- Fixed unresponsive interface issue when downloading attachments (#1484496)
-- Lowered status message time from 5 to 3 seconds to improve responsiveness
-- Raised .htaccess upload_max_filesize from 2M to 5M to differ from default php.ini
-- Increased "mailboxcontrols" mail.css width from 160 to 170px to fix non-english languages (#1484499)
-- Fix status message bug #1484464 with regard to #1484353
-- Fix address adding bug reported by David Koblas
-- Applied socket error patch by Thomas Mangin
-- Pass-by-reference workarround for PHP5 in sendmail.inc
-- Fixed buggy imap_root settings (closes #1484379)
-- Prevent default events on subject links (#1484399)
-- Use HTTP-POST requests for actions that change state
-
-RELEASE 0.1-RC1
----------------
-- Use global filters and bind username/ for Ldap searches (#1484159)
-- Hide quota display if imap server does not support it
-- Hide address groups if no LDAP servers configured
-- Add link to message subjects (closes #1484257)
-- Better SQL query for contact listing/search (closes #1484369)
-- Fixed marking as read in preview pane (closes #1484364)
-- CSS hack to display attachments correctly in IE6
-- Wrap message body text (closes #1484148)
-- LDAP access is back in address book (closes #1484087)
-- Added search function for contacts
-- New Template parsing and output encoding
-- Fixed bugs #1484119 and #1483978
-- Fixed message moving procedure (closes #1484308)
-- Fixed display of multiple attachments (closes #1466563)
-- Fixed check for new messages (closes #1484310)
-- List attachments without filename
-- New session authentication: Change sessid cookie when login, authentication with sessauth cookie is now configurable.
- Should close bugs #1483951 and #1484299
-- Correctly translate mailbox names (closes #1484276)
-- Quote e-mail address links (closes #1484300)
-- Updated PEAR::Mail_mime package
-- Accept single quotes for HTML attributes when modifying message body (thanks Jason)
-- Sanitize input for new users/identities (thanks Colin Alston)
-- Don't download HTML message parts
-- Convert HTML parts to plaintext if 'prefer_html' is off
-- Correctly parse message/rfc822 parts (closes #1484045)
-- Also use user_id for unique key in messages table (closes #1484074)
-- Hide contacts drop down on blur (closes #1484203)
-- Make entries in contacts drop down clickable
-- Turn off browser autocompletion on login page
-- Quote <? in text/html message parts
-- Hide border around radio buttons
-- Applied patch for attachment download by crichardson (closes #1484198)
-- Fixed bug in Postgres DB handling (closes #1484068)
-- Fixed bug of invalid calls to fetchRow() in rcube_db.inc (closes #1484280)
-- Fixed array_merge bug (closes #1484281)
-- Fixed flag for deletion in list view (closes #1484264)
-- Finally support semicolons as recipient separator (closes ##1484251)
-- Fixed message headers (subject) encoding
-- check if safe mode is on or not (closes #1484269)
-- Show "no subject" in message list if subject is missing (closes #1484243)
-- Solved page caching of message preview (closes #1484153)
-- Only use gzip compression if configured (closes #1484236)
-- Fixed priority selector issue (#1484150)
-- Fixed some CSS issues in default skin (closes #1484210 and #1484161)
-- Prevent from double quoting of numeric HTML character references (closes #1484253)
-- Fixed display of HTML message attachments (closes #1484178)
-- Applied patch for preview caching (closes #1484186)
-- Added error handling for attachment uploads
-- Use multibyte safe string functions where necessary (closes #1483988)
-- Applied security patch to validate the submitted host value (by Kees Cook)
-- Applied security patch to validate input values when deleting contacts (by Kees Cook)
-- Applied security patch that sanitizes emoticon paths when attaching them (by Kees Cook)
-- Applied a patch to more aggressively sanitize a HTML message
-- Visualize blocked images in HTML messages
-- Fixed wrong message listing when showing search results (closes #1484131)
-- Show remote images when opening HTML message part as attachment
-- Improve memory usage when sending mail (closes #1484098)
-- Mark messages as read once the preview is loaded (closes #1484132)
-- Include smtp final response in log (closes #1484081)
-- Corrected date string in sent message header (closes #1484125)
-- Correclty choose "To" column in sent and draft mailboxes (closes #1483943)
-- Changed srong tooltips for message browse buttons (closes #1483930)
-- Fixed signature delimeter character to be standard (Bug #1484035)
-- Fixed XSS vulnerability (Bug #1484109)
-- Remove newlines from mail headers (Bug #1484031)
-- Selection issues when moving/deleting (Bug #1484044)
-- Applied patch of Clement Moulin for imap host auto-selection
-- ISO-encode IMAP password for plaintext login (Bugs #1483977 & #1483886)
-- Fixed folder name encoding in subscription list (Bug #1484113)
-- Fixed JS errors in identity list (Bug #1484120)
-- Translate foldernames in folder form (closes #1484113)
-- Added first and last buttons to message list, address book
- and message detail
-- Pressing Shift-Del bypasses Trash folder
-- Enable purge command for Junk folder
-- Fetch all aliases if virtuser_query is used instead
-- Re-enabled multi select of contacts (Bug #1484017)
-- Enable contact editing right after creation (Bug #1459641)
-- Correct UTF-7 to UTF-8 conversion if mbstring is not available
-- Fixed IMAP fetch of message body (Bug #1484019)
-- Fixed safe_mode problems (Bug #1418381)
-- Fixed wrong header encoding (Bug #1483976)
-- Made automatic draft saving configurable
-- Fixed JS bug when renaming folders (Bug #1483989)
-- Added quota display as image (by Brett Patterson)
-- Corrected creation of a message-id
-- New indentation for quoted message text
-- Improved HTML validity
-- Fixed URL character set (Ticket #1445501)
-- Fixed saving of contact into MySQL from LDAP query results (Ticket #1483820)
-- Fixed folder renaming: unsubscribe before rename (Bug #1483920)
-- Finalized new message parsing (+ chaching)
-- Fixed wrong usage of mbstring (Bug #1462439)
-- Set default spelling language (Ticket #1483938)
-- Added support for Nox Spell Server
-- Re-built message parsing (Bug #1327068)
- Now based on the message structure delivered by the IMAP server.
-- Fixed some XSS and SQL injection issues
-- Fixed charset problems with folder renaming
-
-
-
-
diff --git a/README b/README
index d2a234242..a4e661a52 100644
--- a/README
+++ b/README
@@ -1,14 +1,6 @@
Roundcube Webmail (http://roundcube.net)
-ATTENTION
----------
-This is just a snapshot of the current SVN repository and is NOT A STABLE
-version of Roundcube. It's not recommended to replace an existing installation
-of Roundcube with this version. Also using a separate database for this
-installation is highly recommended.
-
-
Introduction:
-------------
Roundcube Webmail is a browser-based multilingual IMAP client with an
diff --git a/bin/dumpschema.sh b/bin/dumpschema.sh
deleted file mode 100755
index 13b156270..000000000
--- a/bin/dumpschema.sh
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env php
-<?php
-/*
-
- +-----------------------------------------------------------------------+
- | bin/dumpschema.sh |
- | |
- | This file is part of the Roundcube Webmail client |
- | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland |
- | Licensed under the GNU GPL |
- | |
- | PURPOSE: |
- | Dumps database schema in XML format using MDB2_Schema |
- | |
- +-----------------------------------------------------------------------+
- | Author: Thomas Bruederli <roundcube@gmail.com> |
- +-----------------------------------------------------------------------+
-
- $Id$
-
-*/
-
-if (php_sapi_name() != 'cli') {
- die('Not on the "shell" (php-cli).');
-}
-
-define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
-require INSTALL_PATH.'program/include/iniset.php';
-
-/** callback function for schema dump **/
-function print_schema($dump)
-{
- foreach ((array)$dump as $part)
- echo $dump . "\n";
-}
-
-$config = new rcube_config();
-
-// don't allow public access if not in devel_mode
-if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) {
- header("HTTP/1.0 401 Access denied");
- die("Access denied!");
-}
-
-$options = array(
- 'use_transactions' => false,
- 'log_line_break' => "\n",
- 'idxname_format' => '%s',
- 'debug' => false,
- 'quote_identifier' => true,
- 'force_defaults' => false,
- 'portability' => false,
-);
-
-$dsnw = $config->get('db_dsnw');
-$dsn_array = MDB2::parseDSN($dsnw);
-
-// set options for postgres databases
-if ($dsn_array['phptype'] == 'pgsql') {
- $options['disable_smart_seqname'] = true;
- $options['seqname_format'] = '%s';
-}
-
-$schema =& MDB2_Schema::factory($dsnw, $options);
-$schema->db->supported['transactions'] = false;
-
-
-// send as text/xml when opened in browser
-if ($_SERVER['REMOTE_ADDR'])
- header('Content-Type: text/xml');
-
-
-if (PEAR::isError($schema)) {
- $error = $schema->getMessage() . ' ' . $schema->getUserInfo();
-}
-else {
- $dump_config = array(
- // 'output_mode' => 'file',
- 'output' => 'print_schema',
- );
-
- $definition = $schema->getDefinitionFromDatabase();
- $definition['charset'] = 'utf8';
-
- if (PEAR::isError($definition)) {
- $error = $definition->getMessage() . ' ' . $definition->getUserInfo();
- }
- else {
- $operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE);
- if (PEAR::isError($operation)) {
- $error = $operation->getMessage() . ' ' . $operation->getUserInfo();
- }
- }
-}
-
-$schema->disconnect();
-
-if ($error && !$_SERVER['REMOTE_ADDR'])
- fputs(STDERR, $error);
-
-?>
diff --git a/bin/makedoc.sh b/bin/makedoc.sh
deleted file mode 100755
index 40c75bf47..000000000
--- a/bin/makedoc.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-TITLE="Roundcube Classes"
-PACKAGES="Core"
-
-INSTALL_PATH="`dirname $0`/.."
-PATH_PROJECT=$INSTALL_PATH/program/include
-PATH_DOCS=$INSTALL_PATH/doc/phpdoc
-BIN_PHPDOC="`/usr/bin/which phpdoc`"
-
-if [ ! -x "$BIN_PHPDOC" ]
-then
- echo "phpdoc not found: $BIN_PHPDOC"
- exit 1
-fi
-
-OUTPUTFORMAT=HTML
-CONVERTER=frames
-TEMPLATE=earthli
-PRIVATE=off
-
-# make documentation
-$BIN_PHPDOC -d $PATH_PROJECT -t $PATH_DOCS -ti "$TITLE" -dn $PACKAGES \
--o $OUTPUTFORMAT:$CONVERTER:$TEMPLATE -pp $PRIVATE
-
diff --git a/index.php b/index.php
index 6bc771c1d..a6e2ada46 100644
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
/*
+-------------------------------------------------------------------------+
| Roundcube Webmail IMAP Client |
- | Version 0.4-20100807 |
+ | Version 0.4.1 |
| |
| Copyright (C) 2005-2010, Roundcube Dev. - Switzerland |
| |
diff --git a/plugins/enigma/README b/plugins/enigma/README
deleted file mode 100644
index 71b5ea531..000000000
--- a/plugins/enigma/README
+++ /dev/null
@@ -1,33 +0,0 @@
-------------------------------------------------------------------
-THIS IS NOT EVEN AN "ALPHA" STATE. USE ONLY FOR DEVELOPMENT!!!!!!!
-------------------------------------------------------------------
-
-Enigma Plugin Status:
-
-* DONE:
-
-- PGP signed messages verification
-- Handling of PGP keys files attached to incoming messages
-- PGP encrypted messages decryption (started)
-- PGP keys management UI (started)
-
-* TODO (must have):
-
-- Parsing of decrypted messages into array (see rcube_mime_struct) and then into rcube_message_part structure
- (create core class rcube_mime_parser or take over PEAR::Mail_mimeDecode package and improve it)
-- Sending encrypted/signed messages (probably some changes in core will be needed)
-- Per-Identity settings (including keys/certs) (+ split Identities details page into tabs)
-- Handling big messages with temp files (including changes in Roundcube core)
-- Performance improvements (some caching, code review)
-- better (and more) icons
-
-* TODO (later):
-
-- Keys generation
-- Certs generation
-- Keys/Certs info in Contacts details page (+ split Contact details page into tabs)
-- Key server support
-- S/MIME signed messages verification
-- S/MIME encrypted messages decryption
-- Handling of S/MIME certs files attached to incoming messages
-- SSL (S/MIME) Certs management
diff --git a/plugins/enigma/config.inc.php b/plugins/enigma/config.inc.php
deleted file mode 100644
index ca841d0ac..000000000
--- a/plugins/enigma/config.inc.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-// Enigma Plugin options
-// --------------------
-
-// A driver to use for PGP. Default: "gnupg".
-$rcmail_config['enigma_pgp_driver'] = 'gnupg';
-
-// A driver to use for S/MIME. Default: "phpssl".
-$rcmail_config['enigma_smime_driver'] = 'phpssl';
-
-// Keys directory for all users. Default 'enigma/home'.
-// Must be writeable by PHP process
-$rcmail_config['enigma_pgp_homedir'] = null;
diff --git a/plugins/enigma/enigma.js b/plugins/enigma/enigma.js
deleted file mode 100644
index 2cd2d62e3..000000000
--- a/plugins/enigma/enigma.js
+++ /dev/null
@@ -1,207 +0,0 @@
-/* Enigma Plugin */
-
-if (window.rcmail)
-{
- rcmail.addEventListener('init', function(evt)
- {
- if (rcmail.env.task == 'settings') {
- rcmail.register_command('plugin.enigma', function() { rcmail.goto_url('plugin.enigma') }, true);
- rcmail.register_command('plugin.enigma-key-import', function() { rcmail.enigma_key_import() }, true);
- rcmail.register_command('plugin.enigma-key-export', function() { rcmail.enigma_key_export() }, true);
-
- if (rcmail.gui_objects.keyslist)
- {
- var p = rcmail;
- rcmail.keys_list = new rcube_list_widget(rcmail.gui_objects.keyslist,
- {multiselect:false, draggable:false, keyboard:false});
- rcmail.keys_list.addEventListener('select', function(o){ p.enigma_key_select(o); });
- rcmail.keys_list.init();
- rcmail.keys_list.focus();
-
- rcmail.enigma_list();
-
- rcmail.register_command('firstpage', function(props) {return rcmail.enigma_list_page('first'); });
- rcmail.register_command('previouspage', function(props) {return rcmail.enigma_list_page('previous'); });
- rcmail.register_command('nextpage', function(props) {return rcmail.enigma_list_page('next'); });
- rcmail.register_command('lastpage', function(props) {return rcmail.enigma_list_page('last'); });
- }
-
- if (rcmail.env.action == 'edit-prefs') {
- rcmail.register_command('search', function(props) {return rcmail.enigma_search(props); }, true);
- rcmail.register_command('reset-search', function(props) {return rcmail.enigma_search_reset(props); }, true);
- }
- else if (rcmail.env.action == 'plugin.enigma') {
- rcmail.register_command('plugin.enigma-import', function() { rcmail.enigma_import() }, true);
- rcmail.register_command('plugin.enigma-export', function() { rcmail.enigma_export() }, true);
- }
- }
- });
-}
-
-/*********************************************************/
-/********* Enigma Settings/Keys/Certs UI *********/
-/*********************************************************/
-
-// Display key(s) import form
-rcube_webmail.prototype.enigma_key_import = function()
-{
- this.enigma_loadframe(null, '&_a=keyimport');
-};
-
-// Submit key(s) form
-rcube_webmail.prototype.enigma_import = function()
-{
- var form, file;
- if (form = this.gui_objects.importform) {
- file = document.getElementById('rcmimportfile');
- if (file && !file.value) {
- alert(this.get_label('selectimportfile'));
- return;
- }
- form.submit();
- this.set_busy(true, 'importwait');
- this.lock_form(form, true);
- }
-};
-
-// list row selection handler
-rcube_webmail.prototype.enigma_key_select = function(list)
-{
- var id;
- if (id = list.get_single_selection())
- this.enigma_loadframe(id);
-};
-
-// load key frame
-rcube_webmail.prototype.enigma_loadframe = function(id, url)
-{
- var frm, win;
- if (this.env.contentframe && window.frames && (frm = window.frames[this.env.contentframe])) {
- if (!id && !url && (win = window.frames[this.env.contentframe])) {
- if (win.location && win.location.href.indexOf(this.env.blankpage)<0)
- win.location.href = this.env.blankpage;
- return;
- }
- this.set_busy(true);
- if (!url)
- url = '&_a=keyinfo&_id='+id;
- frm.location.href = this.env.comm_path+'&_action=plugin.enigma&_framed=1' + url;
- }
-};
-
-// Search keys/certs
-rcube_webmail.prototype.enigma_search = function(props)
-{
- if (!props && this.gui_objects.qsearchbox)
- props = this.gui_objects.qsearchbox.value;
-
- if (props || this.env.search_request) {
- var params = {'_a': 'keysearch', '_q': urlencode(props)};
-// if (this.gui_objects.search_filter)
- // addurl += '&_filter=' + this.gui_objects.search_filter.value;
- this.env.current_page = 1;
- this.set_busy(true, 'searching');
-
- this.enigma_loadframe();
- this.enigma_clear_list();
- this.http_post('plugin.enigma', params, true);
- }
-
- return false;
-}
-
-// Reset search filter and the list
-rcube_webmail.prototype.enigma_search_reset = function(props)
-{
- var s = this.env.search_request;
- this.reset_qsearch();
-
- if (s) {
- this.enigma_loadframe();
- this.enigma_clear_list();
-
- // refresh the list
- this.enigma_list();
- }
-
- return false;
-}
-
-// Keys/certs listing
-rcube_webmail.prototype.enigma_list = function(page)
-{
- var params = {'_a': 'keylist'};
-
- this.env.current_page = page ? page : 1;
- this.set_busy(true, 'loading');
-
- if (this.env.search_request)
- params._q = this.env.search_request;
- if (page)
- params._p = page;
-
- this.enigma_clear_list();
- this.http_post('plugin.enigma', params, true);
-}
-
-// Change list page
-rcube_webmail.prototype.enigma_list_page = function(page)
-{
- if (page == 'next')
- page = this.env.current_page + 1;
- else if (page == 'last')
- page = this.env.pagecount;
- else if (page == 'prev' && this.env.current_page > 1)
- page = this.env.current_page - 1;
- else if (page == 'first' && this.env.current_page > 1)
- page = 1;
-
- this.enigma_list(page);
-}
-
-// Remove list rows
-rcube_webmail.prototype.enigma_clear_list = function()
-{
- this.enigma_loadframe();
- if (this.keys_list)
- this.keys_list.clear(true);
-}
-
-// Adds a row to the list
-rcube_webmail.prototype.enigma_add_list_row = function(r)
-{
- if (!this.gui_objects.keyslist || !this.keys_list)
- return false;
-
- var list = this.keys_list,
- tbody = this.gui_objects.keyslist.tBodies[0],
- rowcount = tbody.rows.length,
- even = rowcount%2,
- css_class = 'message'
- + (even ? ' even' : ' odd'),
- // for performance use DOM instead of jQuery here
- row = document.createElement('tr'),
- col = document.createElement('td');
-
- row.id = 'rcmrow' + r.id;
- row.className = css_class;
-
- col.innerHTML = r.name;
- row.appendChild(col);
- list.insert_row(row);
-}
-
-/*********************************************************/
-/********* Enigma Message methods *********/
-/*********************************************************/
-
-// Import attached keys/certs file
-rcube_webmail.prototype.enigma_import_attachment = function(mime_id)
-{
- this.set_busy(true, 'loading');
- this.http_post('plugin.enigmaimport', '_uid='+this.env.uid+'&_mbox='
- +urlencode(this.env.mailbox)+'&_part='+urlencode(mime_id), true);
-
- return false;
-};
-
diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php
deleted file mode 100644
index ad4f65a0e..000000000
--- a/plugins/enigma/enigma.php
+++ /dev/null
@@ -1,472 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Enigma Plugin for Roundcube |
- | Version 0.1 |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-/*
- This class contains only hooks and action handlers.
- Most plugin logic is placed in enigma_engine and enigma_ui classes.
-*/
-
-class enigma extends rcube_plugin
-{
- public $task = 'mail|settings';
- public $rc;
- public $engine;
-
- private $env_loaded;
- private $message;
- private $keys_parts = array();
- private $keys_bodies = array();
-
-
- /**
- * Plugin initialization.
- */
- function init()
- {
- $rcmail = rcmail::get_instance();
- $this->rc = $rcmail;
-
- if ($this->rc->task == 'mail') {
- // message parse/display hooks
- $this->add_hook('message_part_structure', array($this, 'parse_structure'));
- $this->add_hook('message_body_prefix', array($this, 'status_message'));
-
- // message sending hooks
- //$this->add_hook('outgoing_message_body', array($this, 'msg_encode'));
- //$this->add_hook('outgoing_message_body', array($this, 'msg_sign'));
-
- if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
- $this->add_hook('message_load', array($this, 'message_load'));
- $this->add_hook('template_object_messagebody', array($this, 'message_output'));
- }
-
- $this->register_action('plugin.enigmaimport', array($this, 'import_file'));
- }
- else if ($this->rc->task == 'settings') {
- // add hooks for Enigma settings
- $this->add_hook('preferences_sections_list', array($this, 'preferences_section'));
- $this->add_hook('preferences_list', array($this, 'preferences_list'));
- $this->add_hook('preferences_save', array($this, 'preferences_save'));
-
- // register handler for keys/certs management
- $this->register_action('plugin.enigma', array($this, 'preferences_ui'));
-
- // grab keys/certs management iframe requests
- $section = get_input_value('_section', RCUBE_INPUT_GET);
- if ($this->rc->action == 'edit-prefs' && preg_match('/^enigma(certs|keys)/', $section)) {
- $this->load_ui();
- $this->ui->init($section);
- }
-
- // include main js script
-// $this->include_script('enigma.js');
- }
- }
-
- /**
- * Plugin environment initialization.
- */
- function load_env()
- {
- if ($this->env_loaded)
- return;
-
- $this->env_loaded = true;
-
- // Add include path for Enigma classes and drivers
- $include_path = $this->home . '/lib' . PATH_SEPARATOR;
- $include_path .= ini_get('include_path');
- set_include_path($include_path);
-
- // load the Enigma plugin configuration
- $this->load_config();
-
- // include localization (if wasn't included before)
- $this->add_texts('localization/');
- }
-
- /**
- * Plugin UI initialization.
- */
- function load_ui()
- {
- if ($this->ui)
- return;
-
- // load config/localization
- $this->load_env();
-
- // Load UI
- $this->ui = new enigma_ui($this, $this->home);
- }
-
- /**
- * Plugin engine initialization.
- */
- function load_engine()
- {
- if ($this->engine)
- return;
-
- // load config/localization
- $this->load_env();
-
- $this->engine = new enigma_engine($this);
- }
-
- /**
- * Handler for message_part_structure hook.
- * Called for every part of the message.
- *
- * @param array Original parameters
- *
- * @return array Modified parameters
- */
- function parse_structure($p)
- {
- $struct = $p['structure'];
-
- if ($p['mimetype'] == 'text/plain' || $p['mimetype'] == 'application/pgp') {
- $this->parse_plain($p);
- }
- else if ($p['mimetype'] == 'multipart/signed') {
- $this->parse_signed($p);
- }
- else if ($p['mimetype'] == 'multipart/encrypted') {
- $this->parse_encrypted($p);
- }
- else if ($p['mimetype'] == 'application/pkcs7-mime') {
- $this->parse_encrypted($p);
- }
-
- return $p;
- }
-
- /**
- * Handler for preferences_sections_list hook.
- * Adds Enigma settings sections into preferences sections list.
- *
- * @param array Original parameters
- *
- * @return array Modified parameters
- */
- function preferences_section($p)
- {
- // add labels
- $this->add_texts('localization/');
-
- $p['list']['enigmasettings'] = array(
- 'id' => 'enigmasettings', 'section' => $this->gettext('enigmasettings'),
- );
- $p['list']['enigmacerts'] = array(
- 'id' => 'enigmacerts', 'section' => $this->gettext('enigmacerts'),
- );
- $p['list']['enigmakeys'] = array(
- 'id' => 'enigmakeys', 'section' => $this->gettext('enigmakeys'),
- );
-
- return $p;
- }
-
- /**
- * Handler for preferences_list hook.
- * Adds options blocks into Enigma settings sections in Preferences.
- *
- * @param array Original parameters
- *
- * @return array Modified parameters
- */
- function preferences_list($p)
- {
- if ($p['section'] == 'enigmasettings') {
- // This makes that section is not removed from the list
- $p['blocks']['dummy']['options']['dummy'] = array();
- }
- else if ($p['section'] == 'enigmacerts') {
- // This makes that section is not removed from the list
- $p['blocks']['dummy']['options']['dummy'] = array();
- }
- else if ($p['section'] == 'enigmakeys') {
- // This makes that section is not removed from the list
- $p['blocks']['dummy']['options']['dummy'] = array();
- }
-
- return $p;
- }
-
- /**
- * Handler for preferences_save hook.
- * Executed on Enigma settings form submit.
- *
- * @param array Original parameters
- *
- * @return array Modified parameters
- */
- function preferences_save($p)
- {
- if ($p['section'] == 'enigmasettings') {
- $a['prefs'] = array(
-// 'dummy' => get_input_value('_dummy', RCUBE_INPUT_POST),
- );
- }
-
- return $p;
- }
-
- /**
- * Handler for keys/certs management UI template.
- */
- function preferences_ui()
- {
- $this->load_ui();
- $this->ui->init();
- }
-
- /**
- * Handler for message_body_prefix hook.
- * Called for every displayed (content) part of the message.
- * Adds infobox about signature verification and/or decryption
- * status above the body.
- *
- * @param array Original parameters
- *
- * @return array Modified parameters
- */
- function status_message($p)
- {
- $part_id = $p['part']->mime_id;
-
- // skip: not a message part
- if ($p['part'] instanceof rcube_message)
- return $p;
-
- // skip: message has no signed/encoded content
- if (!$this->engine)
- return $p;
-
- // Decryption status
- if (isset($this->engine->decryptions[$part_id])) {
-
- // get decryption status
- $status = $this->engine->decryptions[$part_id];
-
- // Load UI and add css script
- $this->load_ui();
- $this->ui->add_css();
-
- // display status info
- $attrib['id'] = 'enigma-message';
-
- if ($status instanceof enigma_error) {
- $attrib['class'] = 'enigmaerror';
- $code = $status->getCode();
- if ($code == enigma_error::E_KEYNOTFOUND)
- $msg = Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')),
- $this->gettext('decryptnokey')));
- else if ($code == enigma_error::E_BADPASS)
- $msg = Q($this->gettext('decryptbadpass'));
- else
- $msg = Q($this->gettext('decrypterror'));
- }
- else {
- $attrib['class'] = 'enigmanotice';
- $msg = Q($this->gettext('decryptok'));
- }
-
- $p['prefix'] .= html::div($attrib, $msg);
- }
-
- // Signature verification status
- if (isset($this->engine->signed_parts[$part_id])
- && ($sig = $this->engine->signatures[$this->engine->signed_parts[$part_id]])
- ) {
- // add css script
- $this->load_ui();
- $this->ui->add_css();
-
- // display status info
- $attrib['id'] = 'enigma-message';
-
- if ($sig instanceof enigma_signature) {
- if ($sig->valid) {
- $attrib['class'] = 'enigmanotice';
- $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>';
- $msg = Q(str_replace('$sender', $sender, $this->gettext('sigvalid')));
- }
- else {
- $attrib['class'] = 'enigmawarning';
- $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>';
- $msg = Q(str_replace('$sender', $sender, $this->gettext('siginvalid')));
- }
- }
- else if ($sig->getCode() == enigma_error::E_KEYNOTFOUND) {
- $attrib['class'] = 'enigmawarning';
- $msg = Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')),
- $this->gettext('signokey')));
- }
- else {
- $attrib['class'] = 'enigmaerror';
- $msg = Q($this->gettext('sigerror'));
- }
-/*
- $msg .= '&nbsp;' . html::a(array('href' => "#sigdetails",
- 'onclick' => JS_OBJECT_NAME.".command('enigma-sig-details')"),
- Q($this->gettext('showdetails')));
-*/
- // test
-// $msg .= '<br /><pre>'.$sig->body.'</pre>';
-
- $p['prefix'] .= html::div($attrib, $msg);
-
- // Display each signature message only once
- unset($this->engine->signatures[$this->engine->signed_parts[$part_id]]);
- }
-
- return $p;
- }
-
- /**
- * Handler for plain/text message.
- *
- * @param array Reference to hook's parameters (see enigma::parse_structure())
- */
- private function parse_plain(&$p)
- {
- $this->load_engine();
- $this->engine->parse_plain($p);
- }
-
- /**
- * Handler for multipart/signed message.
- * Verifies signature.
- *
- * @param array Reference to hook's parameters (see enigma::parse_structure())
- */
- private function parse_signed(&$p)
- {
- $this->load_engine();
- $this->engine->parse_signed($p);
- }
-
- /**
- * Handler for multipart/encrypted and application/pkcs7-mime message.
- *
- * @param array Reference to hook's parameters (see enigma::parse_structure())
- */
- private function parse_encrypted(&$p)
- {
- $this->load_engine();
- $this->engine->parse_encrypted($p);
- }
-
- /**
- * Handler for message_load hook.
- * Check message bodies and attachments for keys/certs.
- */
- function message_load($p)
- {
- $this->message = $p['object'];
-
- // handle attachments vcard attachments
- foreach ((array)$this->message->attachments as $attachment) {
- if ($this->is_keys_part($attachment)) {
- $this->keys_parts[] = $attachment->mime_id;
- }
- }
- // the same with message bodies
- foreach ((array)$this->message->parts as $idx => $part) {
- if ($this->is_keys_part($part)) {
- $this->keys_parts[] = $part->mime_id;
- $this->keys_bodies[] = $part->mime_id;
- }
- }
- // @TODO: inline PGP keys
-
- if ($this->keys_parts) {
- $this->add_texts('localization');
- }
- }
-
- /**
- * Handler for template_object_messagebody hook.
- * This callback function adds a box below the message content
- * if there is a key/cert attachment available
- */
- function message_output($p)
- {
- $attach_script = false;
-
- foreach ($this->keys_parts as $part) {
-
- // remove part's body
- if (in_array($part, $this->keys_bodies))
- $p['content'] = '';
-
- $style = "margin:0 1em; padding:0.2em 0.5em; border:1px solid #999; width: auto"
- ." border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px";
-
- // add box below messsage body
- $p['content'] .= html::p(array('style' => $style),
- html::a(array(
- 'href' => "#",
- 'onclick' => "return ".JS_OBJECT_NAME.".enigma_import_attachment('".JQ($part)."')",
- 'title' => $this->gettext('keyattimport')),
- html::img(array('src' => $this->url('skins/default/key_add.png'), 'style' => "vertical-align:middle")))
- . ' ' . html::span(null, $this->gettext('keyattfound')));
-
- $attach_script = true;
- }
-
- if ($attach_script) {
- $this->include_script('enigma.js');
- }
-
- return $p;
- }
-
- /**
- * Handler for attached keys/certs import
- */
- function import_file()
- {
- $this->load_engine();
- $this->engine->import_file();
- }
-
- /**
- * Checks if specified message part is a PGP-key or S/MIME cert data
- *
- * @param rcube_message_part Part object
- *
- * @return boolean True if part is a key/cert
- */
- private function is_keys_part($part)
- {
- // @TODO: S/MIME
- return (
- // Content-Type: application/pgp-keys
- $part->mimetype == 'application/pgp-keys'
- );
- }
-}
diff --git a/plugins/enigma/home/.htaccess b/plugins/enigma/home/.htaccess
deleted file mode 100644
index 8e6a345dc..000000000
--- a/plugins/enigma/home/.htaccess
+++ /dev/null
@@ -1,2 +0,0 @@
-Order allow,deny
-Deny from all \ No newline at end of file
diff --git a/plugins/enigma/lib/Crypt/GPG.php b/plugins/enigma/lib/Crypt/GPG.php
deleted file mode 100644
index 6e8e717e8..000000000
--- a/plugins/enigma/lib/Crypt/GPG.php
+++ /dev/null
@@ -1,2542 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Crypt_GPG is a package to use GPG from PHP
- *
- * This package provides an object oriented interface to GNU Privacy
- * Guard (GPG). It requires the GPG executable to be on the system.
- *
- * Though GPG can support symmetric-key cryptography, this package is intended
- * only to facilitate public-key cryptography.
- *
- * This file contains the main GPG class. The class in this file lets you
- * encrypt, decrypt, sign and verify data; import and delete keys; and perform
- * other useful GPG tasks.
- *
- * Example usage:
- * <code>
- * <?php
- * // encrypt some data
- * $gpg = new Crypt_GPG();
- * $gpg->addEncryptKey($mySecretKeyId);
- * $encryptedData = $gpg->encrypt($data);
- * ?>
- * </code>
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: GPG.php 302814 2010-08-26 15:43:07Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://pear.php.net/manual/en/package.encryption.crypt-gpg.php
- * @link http://www.gnupg.org/
- */
-
-/**
- * Signature handler class
- */
-require_once 'Crypt/GPG/VerifyStatusHandler.php';
-
-/**
- * Decryption handler class
- */
-require_once 'Crypt/GPG/DecryptStatusHandler.php';
-
-/**
- * GPG key class
- */
-require_once 'Crypt/GPG/Key.php';
-
-/**
- * GPG sub-key class
- */
-require_once 'Crypt/GPG/SubKey.php';
-
-/**
- * GPG user id class
- */
-require_once 'Crypt/GPG/UserId.php';
-
-/**
- * GPG process and I/O engine class
- */
-require_once 'Crypt/GPG/Engine.php';
-
-/**
- * GPG exception classes
- */
-require_once 'Crypt/GPG/Exceptions.php';
-
-// {{{ class Crypt_GPG
-
-/**
- * A class to use GPG from PHP
- *
- * This class provides an object oriented interface to GNU Privacy Guard (GPG).
- *
- * Though GPG can support symmetric-key cryptography, this class is intended
- * only to facilitate public-key cryptography.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-class Crypt_GPG
-{
- // {{{ class error constants
-
- /**
- * Error code returned when there is no error.
- */
- const ERROR_NONE = 0;
-
- /**
- * Error code returned when an unknown or unhandled error occurs.
- */
- const ERROR_UNKNOWN = 1;
-
- /**
- * Error code returned when a bad passphrase is used.
- */
- const ERROR_BAD_PASSPHRASE = 2;
-
- /**
- * Error code returned when a required passphrase is missing.
- */
- const ERROR_MISSING_PASSPHRASE = 3;
-
- /**
- * Error code returned when a key that is already in the keyring is
- * imported.
- */
- const ERROR_DUPLICATE_KEY = 4;
-
- /**
- * Error code returned the required data is missing for an operation.
- *
- * This could be missing key data, missing encrypted data or missing
- * signature data.
- */
- const ERROR_NO_DATA = 5;
-
- /**
- * Error code returned when an unsigned key is used.
- */
- const ERROR_UNSIGNED_KEY = 6;
-
- /**
- * Error code returned when a key that is not self-signed is used.
- */
- const ERROR_NOT_SELF_SIGNED = 7;
-
- /**
- * Error code returned when a public or private key that is not in the
- * keyring is used.
- */
- const ERROR_KEY_NOT_FOUND = 8;
-
- /**
- * Error code returned when an attempt to delete public key having a
- * private key is made.
- */
- const ERROR_DELETE_PRIVATE_KEY = 9;
-
- /**
- * Error code returned when one or more bad signatures are detected.
- */
- const ERROR_BAD_SIGNATURE = 10;
-
- /**
- * Error code returned when there is a problem reading GnuPG data files.
- */
- const ERROR_FILE_PERMISSIONS = 11;
-
- // }}}
- // {{{ class constants for data signing modes
-
- /**
- * Signing mode for normal signing of data. The signed message will not
- * be readable without special software.
- *
- * This is the default signing mode.
- *
- * @see Crypt_GPG::sign()
- * @see Crypt_GPG::signFile()
- */
- const SIGN_MODE_NORMAL = 1;
-
- /**
- * Signing mode for clearsigning data. Clearsigned signatures are ASCII
- * armored data and are readable without special software. If the signed
- * message is unencrypted, the message will still be readable. The message
- * text will be in the original encoding.
- *
- * @see Crypt_GPG::sign()
- * @see Crypt_GPG::signFile()
- */
- const SIGN_MODE_CLEAR = 2;
-
- /**
- * Signing mode for creating a detached signature. When using detached
- * signatures, only the signature data is returned. The original message
- * text may be distributed separately from the signature data. This is
- * useful for miltipart/signed email messages as per
- * {@link http://www.ietf.org/rfc/rfc3156.txt RFC 3156}.
- *
- * @see Crypt_GPG::sign()
- * @see Crypt_GPG::signFile()
- */
- const SIGN_MODE_DETACHED = 3;
-
- // }}}
- // {{{ class constants for fingerprint formats
-
- /**
- * No formatting is performed.
- *
- * Example: C3BC615AD9C766E5A85C1F2716D27458B1BBA1C4
- *
- * @see Crypt_GPG::getFingerprint()
- */
- const FORMAT_NONE = 1;
-
- /**
- * Fingerprint is formatted in the format used by the GnuPG gpg command's
- * default output.
- *
- * Example: C3BC 615A D9C7 66E5 A85C 1F27 16D2 7458 B1BB A1C4
- *
- * @see Crypt_GPG::getFingerprint()
- */
- const FORMAT_CANONICAL = 2;
-
- /**
- * Fingerprint is formatted in the format used when displaying X.509
- * certificates
- *
- * Example: C3:BC:61:5A:D9:C7:66:E5:A8:5C:1F:27:16:D2:74:58:B1:BB:A1:C4
- *
- * @see Crypt_GPG::getFingerprint()
- */
- const FORMAT_X509 = 3;
-
- // }}}
- // {{{ other class constants
-
- /**
- * URI at which package bugs may be reported.
- */
- const BUG_URI = 'http://pear.php.net/bugs/report.php?package=Crypt_GPG';
-
- // }}}
- // {{{ protected class properties
-
- /**
- * Engine used to control the GPG subprocess
- *
- * @var Crypt_GPG_Engine
- *
- * @see Crypt_GPG::setEngine()
- */
- protected $engine = null;
-
- /**
- * Keys used to encrypt
- *
- * The array is of the form:
- * <code>
- * array(
- * $key_id => array(
- * 'fingerprint' => $fingerprint,
- * 'passphrase' => null
- * )
- * );
- * </code>
- *
- * @var array
- * @see Crypt_GPG::addEncryptKey()
- * @see Crypt_GPG::clearEncryptKeys()
- */
- protected $encryptKeys = array();
-
- /**
- * Keys used to decrypt
- *
- * The array is of the form:
- * <code>
- * array(
- * $key_id => array(
- * 'fingerprint' => $fingerprint,
- * 'passphrase' => $passphrase
- * )
- * );
- * </code>
- *
- * @var array
- * @see Crypt_GPG::addSignKey()
- * @see Crypt_GPG::clearSignKeys()
- */
- protected $signKeys = array();
-
- /**
- * Keys used to sign
- *
- * The array is of the form:
- * <code>
- * array(
- * $key_id => array(
- * 'fingerprint' => $fingerprint,
- * 'passphrase' => $passphrase
- * )
- * );
- * </code>
- *
- * @var array
- * @see Crypt_GPG::addDecryptKey()
- * @see Crypt_GPG::clearDecryptKeys()
- */
- protected $decryptKeys = array();
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new GPG object
- *
- * Available options are:
- *
- * - <kbd>string homedir</kbd> - the directory where the GPG
- * keyring files are stored. If not
- * specified, Crypt_GPG uses the
- * default of <kbd>~/.gnupg</kbd>.
- * - <kbd>string publicKeyring</kbd> - the file path of the public
- * keyring. Use this if the public
- * keyring is not in the homedir, or
- * if the keyring is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * keyring with this option
- * (/foo/bar/pubring.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string privateKeyring</kbd> - the file path of the private
- * keyring. Use this if the private
- * keyring is not in the homedir, or
- * if the keyring is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * keyring with this option
- * (/foo/bar/secring.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string trustDb</kbd> - the file path of the web-of-trust
- * database. Use this if the trust
- * database is not in the homedir, or
- * if the database is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * trust database with this option
- * (/foo/bar/trustdb.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string binary</kbd> - the location of the GPG binary. If
- * not specified, the driver attempts
- * to auto-detect the GPG binary
- * location using a list of known
- * default locations for the current
- * operating system. The option
- * <kbd>gpgBinary</kbd> is a
- * deprecated alias for this option.
- * - <kbd>boolean debug</kbd> - whether or not to use debug mode.
- * When debug mode is on, all
- * communication to and from the GPG
- * subprocess is logged. This can be
- *
- * @param array $options optional. An array of options used to create the
- * GPG object. All options are optional and are
- * represented as key-value pairs.
- *
- * @throws Crypt_GPG_FileException if the <kbd>homedir</kbd> does not exist
- * and cannot be created. This can happen if <kbd>homedir</kbd> is
- * not specified, Crypt_GPG is run as the web user, and the web
- * user has no home directory. This exception is also thrown if any
- * of the options <kbd>publicKeyring</kbd>,
- * <kbd>privateKeyring</kbd> or <kbd>trustDb</kbd> options are
- * specified but the files do not exist or are are not readable.
- * This can happen if the user running the Crypt_GPG process (for
- * example, the Apache user) does not have permission to read the
- * files.
- *
- * @throws PEAR_Exception if the provided <kbd>binary</kbd> is invalid, or
- * if no <kbd>binary</kbd> is provided and no suitable binary could
- * be found.
- */
- public function __construct(array $options = array())
- {
- $this->setEngine(new Crypt_GPG_Engine($options));
- }
-
- // }}}
- // {{{ importKey()
-
- /**
- * Imports a public or private key into the keyring
- *
- * Keys may be removed from the keyring using
- * {@link Crypt_GPG::deletePublicKey()} or
- * {@link Crypt_GPG::deletePrivateKey()}.
- *
- * @param string $data the key data to be imported.
- *
- * @return array an associative array containing the following elements:
- * - <kbd>fingerprint</kbd> - the fingerprint of the
- * imported key,
- * - <kbd>public_imported</kbd> - the number of public
- * keys imported,
- * - <kbd>public_unchanged</kbd> - the number of unchanged
- * public keys,
- * - <kbd>private_imported</kbd> - the number of private
- * keys imported,
- * - <kbd>private_unchanged</kbd> - the number of unchanged
- * private keys.
- *
- * @throws Crypt_GPG_NoDataException if the key data is missing or if the
- * data is is not valid key data.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function importKey($data)
- {
- return $this->_importKey($data, false);
- }
-
- // }}}
- // {{{ importKeyFile()
-
- /**
- * Imports a public or private key file into the keyring
- *
- * Keys may be removed from the keyring using
- * {@link Crypt_GPG::deletePublicKey()} or
- * {@link Crypt_GPG::deletePrivateKey()}.
- *
- * @param string $filename the key file to be imported.
- *
- * @return array an associative array containing the following elements:
- * - <kbd>fingerprint</kbd> - the fingerprint of the
- * imported key,
- * - <kbd>public_imported</kbd> - the number of public
- * keys imported,
- * - <kbd>public_unchanged</kbd> - the number of unchanged
- * public keys,
- * - <kbd>private_imported</kbd> - the number of private
- * keys imported,
- * - <kbd>private_unchanged</kbd> - the number of unchanged
- * private keys.
- * private keys.
- *
- * @throws Crypt_GPG_NoDataException if the key data is missing or if the
- * data is is not valid key data.
- *
- * @throws Crypt_GPG_FileException if the key file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function importKeyFile($filename)
- {
- return $this->_importKey($filename, true);
- }
-
- // }}}
- // {{{ exportPublicKey()
-
- /**
- * Exports a public key from the keyring
- *
- * The exported key remains on the keyring. To delete the public key, use
- * {@link Crypt_GPG::deletePublicKey()}.
- *
- * If more than one key fingerprint is available for the specified
- * <kbd>$keyId</kbd> (for example, if you use a non-unique uid) only the
- * first public key is exported.
- *
- * @param string $keyId either the full uid of the public key, the email
- * part of the uid of the public key or the key id of
- * the public key. For example,
- * "Test User (example) <test@example.com>",
- * "test@example.com" or a hexadecimal string.
- * @param boolean $armor optional. If true, ASCII armored data is returned;
- * otherwise, binary data is returned. Defaults to
- * true.
- *
- * @return string the public key data.
- *
- * @throws Crypt_GPG_KeyNotFoundException if a public key with the given
- * <kbd>$keyId</kbd> is not found.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function exportPublicKey($keyId, $armor = true)
- {
- $fingerprint = $this->getFingerprint($keyId);
-
- if ($fingerprint === null) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'Public key not found: ' . $keyId,
- Crypt_GPG::ERROR_KEY_NOT_FOUND, $keyId);
- }
-
- $keyData = '';
- $operation = '--export ' . escapeshellarg($fingerprint);
- $arguments = ($armor) ? array('--armor') : array();
-
- $this->engine->reset();
- $this->engine->setOutput($keyData);
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- if ($code !== Crypt_GPG::ERROR_NONE) {
- throw new Crypt_GPG_Exception(
- 'Unknown error exporting public key. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
-
- return $keyData;
- }
-
- // }}}
- // {{{ deletePublicKey()
-
- /**
- * Deletes a public key from the keyring
- *
- * If more than one key fingerprint is available for the specified
- * <kbd>$keyId</kbd> (for example, if you use a non-unique uid) only the
- * first public key is deleted.
- *
- * The private key must be deleted first or an exception will be thrown.
- * See {@link Crypt_GPG::deletePrivateKey()}.
- *
- * @param string $keyId either the full uid of the public key, the email
- * part of the uid of the public key or the key id of
- * the public key. For example,
- * "Test User (example) <test@example.com>",
- * "test@example.com" or a hexadecimal string.
- *
- * @return void
- *
- * @throws Crypt_GPG_KeyNotFoundException if a public key with the given
- * <kbd>$keyId</kbd> is not found.
- *
- * @throws Crypt_GPG_DeletePrivateKeyException if the specified public key
- * has an associated private key on the keyring. The private key
- * must be deleted first.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function deletePublicKey($keyId)
- {
- $fingerprint = $this->getFingerprint($keyId);
-
- if ($fingerprint === null) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'Public key not found: ' . $keyId,
- Crypt_GPG::ERROR_KEY_NOT_FOUND, $keyId);
- }
-
- $operation = '--delete-key ' . escapeshellarg($fingerprint);
- $arguments = array(
- '--batch',
- '--yes'
- );
-
- $this->engine->reset();
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- break;
- case Crypt_GPG::ERROR_DELETE_PRIVATE_KEY:
- throw new Crypt_GPG_DeletePrivateKeyException(
- 'Private key must be deleted before public key can be ' .
- 'deleted.', $code, $keyId);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error deleting public key. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
- }
-
- // }}}
- // {{{ deletePrivateKey()
-
- /**
- * Deletes a private key from the keyring
- *
- * If more than one key fingerprint is available for the specified
- * <kbd>$keyId</kbd> (for example, if you use a non-unique uid) only the
- * first private key is deleted.
- *
- * Calls GPG with the <kbd>--delete-secret-key</kbd> command.
- *
- * @param string $keyId either the full uid of the private key, the email
- * part of the uid of the private key or the key id of
- * the private key. For example,
- * "Test User (example) <test@example.com>",
- * "test@example.com" or a hexadecimal string.
- *
- * @return void
- *
- * @throws Crypt_GPG_KeyNotFoundException if a private key with the given
- * <kbd>$keyId</kbd> is not found.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function deletePrivateKey($keyId)
- {
- $fingerprint = $this->getFingerprint($keyId);
-
- if ($fingerprint === null) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'Private key not found: ' . $keyId,
- Crypt_GPG::ERROR_KEY_NOT_FOUND, $keyId);
- }
-
- $operation = '--delete-secret-key ' . escapeshellarg($fingerprint);
- $arguments = array(
- '--batch',
- '--yes'
- );
-
- $this->engine->reset();
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- break;
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- throw new Crypt_GPG_KeyNotFoundException(
- 'Private key not found: ' . $keyId,
- $code, $keyId);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error deleting private key. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
- }
-
- // }}}
- // {{{ getKeys()
-
- /**
- * Gets the available keys in the keyring
- *
- * Calls GPG with the <kbd>--list-keys</kbd> command and grabs keys. See
- * the first section of <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG package} for a detailed
- * description of how the GPG command output is parsed.
- *
- * @param string $keyId optional. Only keys with that match the specified
- * pattern are returned. The pattern may be part of
- * a user id, a key id or a key fingerprint. If not
- * specified, all keys are returned.
- *
- * @return array an array of {@link Crypt_GPG_Key} objects. If no keys
- * match the specified <kbd>$keyId</kbd> an empty array is
- * returned.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG_Key
- */
- public function getKeys($keyId = '')
- {
- // get private key fingerprints
- if ($keyId == '') {
- $operation = '--list-secret-keys';
- } else {
- $operation = '--list-secret-keys ' . escapeshellarg($keyId);
- }
-
- // According to The file 'doc/DETAILS' in the GnuPG distribution, using
- // double '--with-fingerprint' also prints the fingerprint for subkeys.
- $arguments = array(
- '--with-colons',
- '--with-fingerprint',
- '--with-fingerprint',
- '--fixed-list-mode'
- );
-
- $output = '';
-
- $this->engine->reset();
- $this->engine->setOutput($output);
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- // ignore not found key errors
- break;
- case Crypt_GPG::ERROR_FILE_PERMISSIONS:
- $filename = $this->engine->getErrorFilename();
- if ($filename) {
- throw new Crypt_GPG_FileException(sprintf(
- 'Error reading GnuPG data file \'%s\'. Check to make ' .
- 'sure it is readable by the current user.', $filename),
- $code, $filename);
- }
- throw new Crypt_GPG_FileException(
- 'Error reading GnuPG data file. Check to make GnuPG data ' .
- 'files are readable by the current user.', $code);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error getting keys. Please use the \'debug\' option ' .
- 'when creating the Crypt_GPG object, and file a bug report ' .
- 'at ' . self::BUG_URI, $code);
- }
-
- $privateKeyFingerprints = array();
-
- $lines = explode(PHP_EOL, $output);
- foreach ($lines as $line) {
- $lineExp = explode(':', $line);
- if ($lineExp[0] == 'fpr') {
- $privateKeyFingerprints[] = $lineExp[9];
- }
- }
-
- // get public keys
- if ($keyId == '') {
- $operation = '--list-public-keys';
- } else {
- $operation = '--list-public-keys ' . escapeshellarg($keyId);
- }
-
- $output = '';
-
- $this->engine->reset();
- $this->engine->setOutput($output);
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- // ignore not found key errors
- break;
- case Crypt_GPG::ERROR_FILE_PERMISSIONS:
- $filename = $this->engine->getErrorFilename();
- if ($filename) {
- throw new Crypt_GPG_FileException(sprintf(
- 'Error reading GnuPG data file \'%s\'. Check to make ' .
- 'sure it is readable by the current user.', $filename),
- $code, $filename);
- }
- throw new Crypt_GPG_FileException(
- 'Error reading GnuPG data file. Check to make GnuPG data ' .
- 'files are readable by the current user.', $code);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error getting keys. Please use the \'debug\' option ' .
- 'when creating the Crypt_GPG object, and file a bug report ' .
- 'at ' . self::BUG_URI, $code);
- }
-
- $keys = array();
-
- $key = null; // current key
- $subKey = null; // current sub-key
-
- $lines = explode(PHP_EOL, $output);
- foreach ($lines as $line) {
- $lineExp = explode(':', $line);
-
- if ($lineExp[0] == 'pub') {
-
- // new primary key means last key should be added to the array
- if ($key !== null) {
- $keys[] = $key;
- }
-
- $key = new Crypt_GPG_Key();
-
- $subKey = Crypt_GPG_SubKey::parse($line);
- $key->addSubKey($subKey);
-
- } elseif ($lineExp[0] == 'sub') {
-
- $subKey = Crypt_GPG_SubKey::parse($line);
- $key->addSubKey($subKey);
-
- } elseif ($lineExp[0] == 'fpr') {
-
- $fingerprint = $lineExp[9];
-
- // set current sub-key fingerprint
- $subKey->setFingerprint($fingerprint);
-
- // if private key exists, set has private to true
- if (in_array($fingerprint, $privateKeyFingerprints)) {
- $subKey->setHasPrivate(true);
- }
-
- } elseif ($lineExp[0] == 'uid') {
-
- $string = stripcslashes($lineExp[9]); // as per documentation
- $userId = new Crypt_GPG_UserId($string);
-
- if ($lineExp[1] == 'r') {
- $userId->setRevoked(true);
- }
-
- $key->addUserId($userId);
-
- }
- }
-
- // add last key
- if ($key !== null) {
- $keys[] = $key;
- }
-
- return $keys;
- }
-
- // }}}
- // {{{ getFingerprint()
-
- /**
- * Gets a key fingerprint from the keyring
- *
- * If more than one key fingerprint is available (for example, if you use
- * a non-unique user id) only the first key fingerprint is returned.
- *
- * Calls the GPG <kbd>--list-keys</kbd> command with the
- * <kbd>--with-fingerprint</kbd> option to retrieve a public key
- * fingerprint.
- *
- * @param string $keyId either the full user id of the key, the email
- * part of the user id of the key, or the key id of
- * the key. For example,
- * "Test User (example) <test@example.com>",
- * "test@example.com" or a hexadecimal string.
- * @param integer $format optional. How the fingerprint should be formatted.
- * Use {@link Crypt_GPG::FORMAT_X509} for X.509
- * certificate format,
- * {@link Crypt_GPG::FORMAT_CANONICAL} for the format
- * used by GnuPG output and
- * {@link Crypt_GPG::FORMAT_NONE} for no formatting.
- * Defaults to <code>Crypt_GPG::FORMAT_NONE</code>.
- *
- * @return string the fingerprint of the key, or null if no fingerprint
- * is found for the given <kbd>$keyId</kbd>.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function getFingerprint($keyId, $format = Crypt_GPG::FORMAT_NONE)
- {
- $output = '';
- $operation = '--list-keys ' . escapeshellarg($keyId);
- $arguments = array(
- '--with-colons',
- '--with-fingerprint'
- );
-
- $this->engine->reset();
- $this->engine->setOutput($output);
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- // ignore not found key errors
- break;
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error getting key fingerprint. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
-
- $fingerprint = null;
-
- $lines = explode(PHP_EOL, $output);
- foreach ($lines as $line) {
- if (substr($line, 0, 3) == 'fpr') {
- $lineExp = explode(':', $line);
- $fingerprint = $lineExp[9];
-
- switch ($format) {
- case Crypt_GPG::FORMAT_CANONICAL:
- $fingerprintExp = str_split($fingerprint, 4);
- $format = '%s %s %s %s %s %s %s %s %s %s';
- $fingerprint = vsprintf($format, $fingerprintExp);
- break;
-
- case Crypt_GPG::FORMAT_X509:
- $fingerprintExp = str_split($fingerprint, 2);
- $fingerprint = implode(':', $fingerprintExp);
- break;
- }
-
- break;
- }
- }
-
- return $fingerprint;
- }
-
- // }}}
- // {{{ encrypt()
-
- /**
- * Encrypts string data
- *
- * Data is ASCII armored by default but may optionally be returned as
- * binary.
- *
- * @param string $data the data to be encrypted.
- * @param boolean $armor optional. If true, ASCII armored data is returned;
- * otherwise, binary data is returned. Defaults to
- * true.
- *
- * @return string the encrypted data.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified.
- * See {@link Crypt_GPG::addEncryptKey()}.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @sensitive $data
- */
- public function encrypt($data, $armor = true)
- {
- return $this->_encrypt($data, false, null, $armor);
- }
-
- // }}}
- // {{{ encryptFile()
-
- /**
- * Encrypts a file
- *
- * Encrypted data is ASCII armored by default but may optionally be saved
- * as binary.
- *
- * @param string $filename the filename of the file to encrypt.
- * @param string $encryptedFile optional. The filename of the file in
- * which to store the encrypted data. If null
- * or unspecified, the encrypted data is
- * returned as a string.
- * @param boolean $armor optional. If true, ASCII armored data is
- * returned; otherwise, binary data is
- * returned. Defaults to true.
- *
- * @return void|string if the <kbd>$encryptedFile</kbd> parameter is null,
- * a string containing the encrypted data is returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified.
- * See {@link Crypt_GPG::addEncryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function encryptFile($filename, $encryptedFile = null, $armor = true)
- {
- return $this->_encrypt($filename, true, $encryptedFile, $armor);
- }
-
- // }}}
- // {{{ encryptAndSign()
-
- /**
- * Encrypts and signs data
- *
- * Data is encrypted and signed in a single pass.
- *
- * NOTE: Until GnuPG version 1.4.10, it was not possible to verify
- * encrypted-signed data without decrypting it at the same time. If you try
- * to use {@link Crypt_GPG::verify()} method on encrypted-signed data with
- * earlier GnuPG versions, you will get an error. Please use
- * {@link Crypt_GPG::decryptAndVerify()} to verify encrypted-signed data.
- *
- * @param string $data the data to be encrypted and signed.
- * @param boolean $armor optional. If true, ASCII armored data is returned;
- * otherwise, binary data is returned. Defaults to
- * true.
- *
- * @return string the encrypted signed data.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified
- * or if no signing key is specified. See
- * {@link Crypt_GPG::addEncryptKey()} and
- * {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG::decryptAndVerify()
- */
- public function encryptAndSign($data, $armor = true)
- {
- return $this->_encryptAndSign($data, false, null, $armor);
- }
-
- // }}}
- // {{{ encryptAndSignFile()
-
- /**
- * Encrypts and signs a file
- *
- * The file is encrypted and signed in a single pass.
- *
- * NOTE: Until GnuPG version 1.4.10, it was not possible to verify
- * encrypted-signed files without decrypting them at the same time. If you
- * try to use {@link Crypt_GPG::verify()} method on encrypted-signed files
- * with earlier GnuPG versions, you will get an error. Please use
- * {@link Crypt_GPG::decryptAndVerifyFile()} to verify encrypted-signed
- * files.
- *
- * @param string $filename the name of the file containing the data to
- * be encrypted and signed.
- * @param string $signedFile optional. The name of the file in which the
- * encrypted, signed data should be stored. If
- * null or unspecified, the encrypted, signed
- * data is returned as a string.
- * @param boolean $armor optional. If true, ASCII armored data is
- * returned; otherwise, binary data is returned.
- * Defaults to true.
- *
- * @return void|string if the <kbd>$signedFile</kbd> parameter is null, a
- * string containing the encrypted, signed data is
- * returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified
- * or if no signing key is specified. See
- * {@link Crypt_GPG::addEncryptKey()} and
- * {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG::decryptAndVerifyFile()
- */
- public function encryptAndSignFile($filename, $signedFile = null,
- $armor = true
- ) {
- return $this->_encryptAndSign($filename, true, $signedFile, $armor);
- }
-
- // }}}
- // {{{ decrypt()
-
- /**
- * Decrypts string data
- *
- * This method assumes the required private key is available in the keyring
- * and throws an exception if the private key is not available. To add a
- * private key to the keyring, use the {@link Crypt_GPG::importKey()} or
- * {@link Crypt_GPG::importKeyFile()} methods.
- *
- * @param string $encryptedData the data to be decrypted.
- *
- * @return string the decrypted data.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function decrypt($encryptedData)
- {
- return $this->_decrypt($encryptedData, false, null);
- }
-
- // }}}
- // {{{ decryptFile()
-
- /**
- * Decrypts a file
- *
- * This method assumes the required private key is available in the keyring
- * and throws an exception if the private key is not available. To add a
- * private key to the keyring, use the {@link Crypt_GPG::importKey()} or
- * {@link Crypt_GPG::importKeyFile()} methods.
- *
- * @param string $encryptedFile the name of the encrypted file data to
- * decrypt.
- * @param string $decryptedFile optional. The name of the file to which the
- * decrypted data should be written. If null
- * or unspecified, the decrypted data is
- * returned as a string.
- *
- * @return void|string if the <kbd>$decryptedFile</kbd> parameter is null,
- * a string containing the decrypted data is returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function decryptFile($encryptedFile, $decryptedFile = null)
- {
- return $this->_decrypt($encryptedFile, true, $decryptedFile);
- }
-
- // }}}
- // {{{ decryptAndVerify()
-
- /**
- * Decrypts and verifies string data
- *
- * This method assumes the required private key is available in the keyring
- * and throws an exception if the private key is not available. To add a
- * private key to the keyring, use the {@link Crypt_GPG::importKey()} or
- * {@link Crypt_GPG::importKeyFile()} methods.
- *
- * @param string $encryptedData the encrypted, signed data to be decrypted
- * and verified.
- *
- * @return array two element array. The array has an element 'data'
- * containing the decrypted data and an element
- * 'signatures' containing an array of
- * {@link Crypt_GPG_Signature} objects for the signed data.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function decryptAndVerify($encryptedData)
- {
- return $this->_decryptAndVerify($encryptedData, false, null);
- }
-
- // }}}
- // {{{ decryptAndVerifyFile()
-
- /**
- * Decrypts and verifies a signed, encrypted file
- *
- * This method assumes the required private key is available in the keyring
- * and throws an exception if the private key is not available. To add a
- * private key to the keyring, use the {@link Crypt_GPG::importKey()} or
- * {@link Crypt_GPG::importKeyFile()} methods.
- *
- * @param string $encryptedFile the name of the signed, encrypted file to
- * to decrypt and verify.
- * @param string $decryptedFile optional. The name of the file to which the
- * decrypted data should be written. If null
- * or unspecified, the decrypted data is
- * returned in the results array.
- *
- * @return array two element array. The array has an element 'data'
- * containing the decrypted data and an element
- * 'signatures' containing an array of
- * {@link Crypt_GPG_Signature} objects for the signed data.
- * If the decrypted data is written to a file, the 'data'
- * element is null.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function decryptAndVerifyFile($encryptedFile, $decryptedFile = null)
- {
- return $this->_decryptAndVerify($encryptedFile, true, $decryptedFile);
- }
-
- // }}}
- // {{{ sign()
-
- /**
- * Signs data
- *
- * Data may be signed using any one of the three available signing modes:
- * - {@link Crypt_GPG::SIGN_MODE_NORMAL}
- * - {@link Crypt_GPG::SIGN_MODE_CLEAR}
- * - {@link Crypt_GPG::SIGN_MODE_DETACHED}
- *
- * @param string $data the data to be signed.
- * @param boolean $mode optional. The data signing mode to use. Should
- * be one of {@link Crypt_GPG::SIGN_MODE_NORMAL},
- * {@link Crypt_GPG::SIGN_MODE_CLEAR} or
- * {@link Crypt_GPG::SIGN_MODE_DETACHED}. If not
- * specified, defaults to
- * <kbd>Crypt_GPG::SIGN_MODE_NORMAL</kbd>.
- * @param boolean $armor optional. If true, ASCII armored data is
- * returned; otherwise, binary data is returned.
- * Defaults to true. This has no effect if the
- * mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used.
- * @param boolean $textmode optional. If true, line-breaks in signed data
- * are normalized. Use this option when signing
- * e-mail, or for greater compatibility between
- * systems with different line-break formats.
- * Defaults to false. This has no effect if the
- * mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used as clear-signing always uses textmode.
- *
- * @return string the signed data, or the signature data if a detached
- * signature is requested.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no signing key is specified.
- * See {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function sign($data, $mode = Crypt_GPG::SIGN_MODE_NORMAL,
- $armor = true, $textmode = false
- ) {
- return $this->_sign($data, false, null, $mode, $armor, $textmode);
- }
-
- // }}}
- // {{{ signFile()
-
- /**
- * Signs a file
- *
- * The file may be signed using any one of the three available signing
- * modes:
- * - {@link Crypt_GPG::SIGN_MODE_NORMAL}
- * - {@link Crypt_GPG::SIGN_MODE_CLEAR}
- * - {@link Crypt_GPG::SIGN_MODE_DETACHED}
- *
- * @param string $filename the name of the file containing the data to
- * be signed.
- * @param string $signedFile optional. The name of the file in which the
- * signed data should be stored. If null or
- * unspecified, the signed data is returned as a
- * string.
- * @param boolean $mode optional. The data signing mode to use. Should
- * be one of {@link Crypt_GPG::SIGN_MODE_NORMAL},
- * {@link Crypt_GPG::SIGN_MODE_CLEAR} or
- * {@link Crypt_GPG::SIGN_MODE_DETACHED}. If not
- * specified, defaults to
- * <kbd>Crypt_GPG::SIGN_MODE_NORMAL</kbd>.
- * @param boolean $armor optional. If true, ASCII armored data is
- * returned; otherwise, binary data is returned.
- * Defaults to true. This has no effect if the
- * mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used.
- * @param boolean $textmode optional. If true, line-breaks in signed data
- * are normalized. Use this option when signing
- * e-mail, or for greater compatibility between
- * systems with different line-break formats.
- * Defaults to false. This has no effect if the
- * mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used as clear-signing always uses textmode.
- *
- * @return void|string if the <kbd>$signedFile</kbd> parameter is null, a
- * string containing the signed data (or the signature
- * data if a detached signature is requested) is
- * returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no signing key is specified.
- * See {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- public function signFile($filename, $signedFile = null,
- $mode = Crypt_GPG::SIGN_MODE_NORMAL, $armor = true, $textmode = false
- ) {
- return $this->_sign(
- $filename,
- true,
- $signedFile,
- $mode,
- $armor,
- $textmode
- );
- }
-
- // }}}
- // {{{ verify()
-
- /**
- * Verifies signed data
- *
- * The {@link Crypt_GPG::decrypt()} method may be used to get the original
- * message if the signed data is not clearsigned and does not use a
- * detached signature.
- *
- * @param string $signedData the signed data to be verified.
- * @param string $signature optional. If verifying data signed using a
- * detached signature, this must be the detached
- * signature data. The data that was signed is
- * specified in <kbd>$signedData</kbd>.
- *
- * @return array an array of {@link Crypt_GPG_Signature} objects for the
- * signed data. For each signature that is valid, the
- * {@link Crypt_GPG_Signature::isValid()} will return true.
- *
- * @throws Crypt_GPG_NoDataException if the provided data is not signed
- * data.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG_Signature
- */
- public function verify($signedData, $signature = '')
- {
- return $this->_verify($signedData, false, $signature);
- }
-
- // }}}
- // {{{ verifyFile()
-
- /**
- * Verifies a signed file
- *
- * The {@link Crypt_GPG::decryptFile()} method may be used to get the
- * original message if the signed data is not clearsigned and does not use
- * a detached signature.
- *
- * @param string $filename the signed file to be verified.
- * @param string $signature optional. If verifying a file signed using a
- * detached signature, this must be the detached
- * signature data. The file that was signed is
- * specified in <kbd>$filename</kbd>.
- *
- * @return array an array of {@link Crypt_GPG_Signature} objects for the
- * signed data. For each signature that is valid, the
- * {@link Crypt_GPG_Signature::isValid()} will return true.
- *
- * @throws Crypt_GPG_NoDataException if the provided data is not signed
- * data.
- *
- * @throws Crypt_GPG_FileException if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG_Signature
- */
- public function verifyFile($filename, $signature = '')
- {
- return $this->_verify($filename, true, $signature);
- }
-
- // }}}
- // {{{ addDecryptKey()
-
- /**
- * Adds a key to use for decryption
- *
- * @param mixed $key the key to use. This may be a key identifier,
- * user id, fingerprint, {@link Crypt_GPG_Key} or
- * {@link Crypt_GPG_SubKey}. The key must be able
- * to encrypt.
- * @param string $passphrase optional. The passphrase of the key required
- * for decryption.
- *
- * @return void
- *
- * @see Crypt_GPG::decrypt()
- * @see Crypt_GPG::decryptFile()
- * @see Crypt_GPG::clearDecryptKeys()
- * @see Crypt_GPG::_addKey()
- * @see Crypt_GPG_DecryptStatusHandler
- *
- * @sensitive $passphrase
- */
- public function addDecryptKey($key, $passphrase = null)
- {
- $this->_addKey($this->decryptKeys, true, false, $key, $passphrase);
- }
-
- // }}}
- // {{{ addEncryptKey()
-
- /**
- * Adds a key to use for encryption
- *
- * @param mixed $key the key to use. This may be a key identifier, user id
- * user id, fingerprint, {@link Crypt_GPG_Key} or
- * {@link Crypt_GPG_SubKey}. The key must be able to
- * encrypt.
- *
- * @return void
- *
- * @see Crypt_GPG::encrypt()
- * @see Crypt_GPG::encryptFile()
- * @see Crypt_GPG::clearEncryptKeys()
- * @see Crypt_GPG::_addKey()
- */
- public function addEncryptKey($key)
- {
- $this->_addKey($this->encryptKeys, true, false, $key);
- }
-
- // }}}
- // {{{ addSignKey()
-
- /**
- * Adds a key to use for signing
- *
- * @param mixed $key the key to use. This may be a key identifier,
- * user id, fingerprint, {@link Crypt_GPG_Key} or
- * {@link Crypt_GPG_SubKey}. The key must be able
- * to sign.
- * @param string $passphrase optional. The passphrase of the key required
- * for signing.
- *
- * @return void
- *
- * @see Crypt_GPG::sign()
- * @see Crypt_GPG::signFile()
- * @see Crypt_GPG::clearSignKeys()
- * @see Crypt_GPG::handleSignStatus()
- * @see Crypt_GPG::_addKey()
- *
- * @sensitive $passphrase
- */
- public function addSignKey($key, $passphrase = null)
- {
- $this->_addKey($this->signKeys, false, true, $key, $passphrase);
- }
-
- // }}}
- // {{{ clearDecryptKeys()
-
- /**
- * Clears all decryption keys
- *
- * @return void
- *
- * @see Crypt_GPG::decrypt()
- * @see Crypt_GPG::addDecryptKey()
- */
- public function clearDecryptKeys()
- {
- $this->decryptKeys = array();
- }
-
- // }}}
- // {{{ clearEncryptKeys()
-
- /**
- * Clears all encryption keys
- *
- * @return void
- *
- * @see Crypt_GPG::encrypt()
- * @see Crypt_GPG::addEncryptKey()
- */
- public function clearEncryptKeys()
- {
- $this->encryptKeys = array();
- }
-
- // }}}
- // {{{ clearSignKeys()
-
- /**
- * Clears all signing keys
- *
- * @return void
- *
- * @see Crypt_GPG::sign()
- * @see Crypt_GPG::addSignKey()
- */
- public function clearSignKeys()
- {
- $this->signKeys = array();
- }
-
- // }}}
- // {{{ handleSignStatus()
-
- /**
- * Handles the status output from GPG for the sign operation
- *
- * This method is responsible for sending the passphrase commands when
- * required by the {@link Crypt_GPG::sign()} method. See <b>doc/DETAILS</b>
- * in the {@link http://www.gnupg.org/download/ GPG distribution} for
- * detailed information on GPG's status output.
- *
- * @param string $line the status line to handle.
- *
- * @return void
- *
- * @see Crypt_GPG::sign()
- */
- public function handleSignStatus($line)
- {
- $tokens = explode(' ', $line);
- switch ($tokens[0]) {
- case 'NEED_PASSPHRASE':
- $subKeyId = $tokens[1];
- if (array_key_exists($subKeyId, $this->signKeys)) {
- $passphrase = $this->signKeys[$subKeyId]['passphrase'];
- $this->engine->sendCommand($passphrase);
- } else {
- $this->engine->sendCommand('');
- }
- break;
- }
- }
-
- // }}}
- // {{{ handleImportKeyStatus()
-
- /**
- * Handles the status output from GPG for the import operation
- *
- * This method is responsible for building the result array that is
- * returned from the {@link Crypt_GPG::importKey()} method. See
- * <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG distribution} for detailed
- * information on GPG's status output.
- *
- * @param string $line the status line to handle.
- * @param array &$result the current result array being processed.
- *
- * @return void
- *
- * @see Crypt_GPG::importKey()
- * @see Crypt_GPG::importKeyFile()
- * @see Crypt_GPG_Engine::addStatusHandler()
- */
- public function handleImportKeyStatus($line, array &$result)
- {
- $tokens = explode(' ', $line);
- switch ($tokens[0]) {
- case 'IMPORT_OK':
- $result['fingerprint'] = $tokens[2];
- break;
-
- case 'IMPORT_RES':
- $result['public_imported'] = intval($tokens[3]);
- $result['public_unchanged'] = intval($tokens[5]);
- $result['private_imported'] = intval($tokens[11]);
- $result['private_unchanged'] = intval($tokens[12]);
- break;
- }
- }
-
- // }}}
- // {{{ setEngine()
-
- /**
- * Sets the I/O engine to use for GnuPG operations
- *
- * Normally this method does not need to be used. It provides a means for
- * dependency injection.
- *
- * @param Crypt_GPG_Engine $engine the engine to use.
- *
- * @return void
- */
- public function setEngine(Crypt_GPG_Engine $engine)
- {
- $this->engine = $engine;
- }
-
- // }}}
- // {{{ _addKey()
-
- /**
- * Adds a key to one of the internal key arrays
- *
- * This handles resolving full key objects from the provided
- * <kbd>$key</kbd> value.
- *
- * @param array &$array the array to which the key should be added.
- * @param boolean $encrypt whether or not the key must be able to
- * encrypt.
- * @param boolean $sign whether or not the key must be able to sign.
- * @param mixed $key the key to add. This may be a key identifier,
- * user id, fingerprint, {@link Crypt_GPG_Key} or
- * {@link Crypt_GPG_SubKey}.
- * @param string $passphrase optional. The passphrase associated with the
- * key.
- *
- * @return void
- *
- * @sensitive $passphrase
- */
- private function _addKey(array &$array, $encrypt, $sign, $key,
- $passphrase = null
- ) {
- $subKeys = array();
-
- if (is_scalar($key)) {
- $keys = $this->getKeys($key);
- if (count($keys) == 0) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'Key "' . $key . '" not found.', 0, $key);
- }
- $key = $keys[0];
- }
-
- if ($key instanceof Crypt_GPG_Key) {
- if ($encrypt && !$key->canEncrypt()) {
- throw new InvalidArgumentException(
- 'Key "' . $key . '" cannot encrypt.');
- }
-
- if ($sign && !$key->canSign()) {
- throw new InvalidArgumentException(
- 'Key "' . $key . '" cannot sign.');
- }
-
- foreach ($key->getSubKeys() as $subKey) {
- $canEncrypt = $subKey->canEncrypt();
- $canSign = $subKey->canSign();
- if ( ($encrypt && $sign && $canEncrypt && $canSign)
- || ($encrypt && !$sign && $canEncrypt)
- || (!$encrypt && $sign && $canSign)
- ) {
- // We add all subkeys that meet the requirements because we
- // were not told which subkey is required.
- $subKeys[] = $subKey;
- }
- }
- } elseif ($key instanceof Crypt_GPG_SubKey) {
- $subKeys[] = $key;
- }
-
- if (count($subKeys) === 0) {
- throw new InvalidArgumentException(
- 'Key "' . $key . '" is not in a recognized format.');
- }
-
- foreach ($subKeys as $subKey) {
- if ($encrypt && !$subKey->canEncrypt()) {
- throw new InvalidArgumentException(
- 'Key "' . $key . '" cannot encrypt.');
- }
-
- if ($sign && !$subKey->canSign()) {
- throw new InvalidArgumentException(
- 'Key "' . $key . '" cannot sign.');
- }
-
- $array[$subKey->getId()] = array(
- 'fingerprint' => $subKey->getFingerprint(),
- 'passphrase' => $passphrase
- );
- }
- }
-
- // }}}
- // {{{ _importKey()
-
- /**
- * Imports a public or private key into the keyring
- *
- * @param string $key the key to be imported.
- * @param boolean $isFile whether or not the input is a filename.
- *
- * @return array an associative array containing the following elements:
- * - <kbd>fingerprint</kbd> - the fingerprint of the
- * imported key,
- * - <kbd>public_imported</kbd> - the number of public
- * keys imported,
- * - <kbd>public_unchanged</kbd> - the number of unchanged
- * public keys,
- * - <kbd>private_imported</kbd> - the number of private
- * keys imported,
- * - <kbd>private_unchanged</kbd> - the number of unchanged
- * private keys.
- *
- * @throws Crypt_GPG_NoDataException if the key data is missing or if the
- * data is is not valid key data.
- *
- * @throws Crypt_GPG_FileException if the key file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- private function _importKey($key, $isFile)
- {
- $result = array();
-
- if ($isFile) {
- $input = @fopen($key, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open key file "' .
- $key . '" for importing.', 0, $key);
- }
- } else {
- $input = strval($key);
- if ($input == '') {
- throw new Crypt_GPG_NoDataException(
- 'No valid GPG key data found.', Crypt_GPG::ERROR_NO_DATA);
- }
- }
-
- $arguments = array();
- $version = $this->engine->getVersion();
-
- if ( version_compare($version, '1.0.5', 'ge')
- && version_compare($version, '1.0.7', 'lt')
- ) {
- $arguments[] = '--allow-secret-key-import';
- }
-
- $this->engine->reset();
- $this->engine->addStatusHandler(
- array($this, 'handleImportKeyStatus'),
- array(&$result)
- );
-
- $this->engine->setOperation('--import', $arguments);
- $this->engine->setInput($input);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_DUPLICATE_KEY:
- case Crypt_GPG::ERROR_NONE:
- // ignore duplicate key import errors
- break;
- case Crypt_GPG::ERROR_NO_DATA:
- throw new Crypt_GPG_NoDataException(
- 'No valid GPG key data found.', $code);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error importing GPG key. Please use the \'debug\' ' .
- 'option when creating the Crypt_GPG object, and file a bug ' .
- 'report at ' . self::BUG_URI, $code);
- }
-
- return $result;
- }
-
- // }}}
- // {{{ _encrypt()
-
- /**
- * Encrypts data
- *
- * @param string $data the data to encrypt.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $outputFile the filename of the file in which to store
- * the encrypted data. If null, the encrypted
- * data is returned as a string.
- * @param boolean $armor if true, ASCII armored data is returned;
- * otherwise, binary data is returned.
- *
- * @return void|string if the <kbd>$outputFile</kbd> parameter is null, a
- * string containing the encrypted data is returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified.
- * See {@link Crypt_GPG::addEncryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- private function _encrypt($data, $isFile, $outputFile, $armor)
- {
- if (count($this->encryptKeys) === 0) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'No encryption keys specified.');
- }
-
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input file "' .
- $data . '" for encryption.', 0, $data);
- }
- } else {
- $input = strval($data);
- }
-
- if ($outputFile === null) {
- $output = '';
- } else {
- $output = @fopen($outputFile, 'wb');
- if ($output === false) {
- if ($isFile) {
- fclose($input);
- }
- throw new Crypt_GPG_FileException('Could not open output ' .
- 'file "' . $outputFile . '" for storing encrypted data.',
- 0, $outputFile);
- }
- }
-
- $arguments = ($armor) ? array('--armor') : array();
- foreach ($this->encryptKeys as $key) {
- $arguments[] = '--recipient ' . escapeshellarg($key['fingerprint']);
- }
-
- $this->engine->reset();
- $this->engine->setInput($input);
- $this->engine->setOutput($output);
- $this->engine->setOperation('--encrypt', $arguments);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- if ($outputFile !== null) {
- fclose($output);
- }
-
- $code = $this->engine->getErrorCode();
-
- if ($code !== Crypt_GPG::ERROR_NONE) {
- throw new Crypt_GPG_Exception(
- 'Unknown error encrypting data. Please use the \'debug\' ' .
- 'option when creating the Crypt_GPG object, and file a bug ' .
- 'report at ' . self::BUG_URI, $code);
- }
-
- if ($outputFile === null) {
- return $output;
- }
- }
-
- // }}}
- // {{{ _decrypt()
-
- /**
- * Decrypts data
- *
- * @param string $data the data to be decrypted.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $outputFile the name of the file to which the decrypted
- * data should be written. If null, the decrypted
- * data is returned as a string.
- *
- * @return void|string if the <kbd>$outputFile</kbd> parameter is null, a
- * string containing the decrypted data is returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- private function _decrypt($data, $isFile, $outputFile)
- {
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input file "' .
- $data . '" for decryption.', 0, $data);
- }
- } else {
- $input = strval($data);
- if ($input == '') {
- throw new Crypt_GPG_NoDataException(
- 'Cannot decrypt data. No PGP encrypted data was found in '.
- 'the provided data.', Crypt_GPG::ERROR_NO_DATA);
- }
- }
-
- if ($outputFile === null) {
- $output = '';
- } else {
- $output = @fopen($outputFile, 'wb');
- if ($output === false) {
- if ($isFile) {
- fclose($input);
- }
- throw new Crypt_GPG_FileException('Could not open output ' .
- 'file "' . $outputFile . '" for storing decrypted data.',
- 0, $outputFile);
- }
- }
-
- $handler = new Crypt_GPG_DecryptStatusHandler($this->engine,
- $this->decryptKeys);
-
- $this->engine->reset();
- $this->engine->addStatusHandler(array($handler, 'handle'));
- $this->engine->setOperation('--decrypt');
- $this->engine->setInput($input);
- $this->engine->setOutput($output);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- if ($outputFile !== null) {
- fclose($output);
- }
-
- // if there was any problem decrypting the data, the handler will
- // deal with it here.
- $handler->throwException();
-
- if ($outputFile === null) {
- return $output;
- }
- }
-
- // }}}
- // {{{ _sign()
-
- /**
- * Signs data
- *
- * @param string $data the data to be signed.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $outputFile the name of the file in which the signed data
- * should be stored. If null, the signed data is
- * returned as a string.
- * @param boolean $mode the data signing mode to use. Should be one of
- * {@link Crypt_GPG::SIGN_MODE_NORMAL},
- * {@link Crypt_GPG::SIGN_MODE_CLEAR} or
- * {@link Crypt_GPG::SIGN_MODE_DETACHED}.
- * @param boolean $armor if true, ASCII armored data is returned;
- * otherwise, binary data is returned. This has
- * no effect if the mode
- * <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used.
- * @param boolean $textmode if true, line-breaks in signed data be
- * normalized. Use this option when signing
- * e-mail, or for greater compatibility between
- * systems with different line-break formats.
- * Defaults to false. This has no effect if the
- * mode <kbd>Crypt_GPG::SIGN_MODE_CLEAR</kbd> is
- * used as clear-signing always uses textmode.
- *
- * @return void|string if the <kbd>$outputFile</kbd> parameter is null, a
- * string containing the signed data (or the signature
- * data if a detached signature is requested) is
- * returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no signing key is specified.
- * See {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- private function _sign($data, $isFile, $outputFile, $mode, $armor,
- $textmode
- ) {
- if (count($this->signKeys) === 0) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'No signing keys specified.');
- }
-
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input ' .
- 'file "' . $data . '" for signing.', 0, $data);
- }
- } else {
- $input = strval($data);
- }
-
- if ($outputFile === null) {
- $output = '';
- } else {
- $output = @fopen($outputFile, 'wb');
- if ($output === false) {
- if ($isFile) {
- fclose($input);
- }
- throw new Crypt_GPG_FileException('Could not open output ' .
- 'file "' . $outputFile . '" for storing signed ' .
- 'data.', 0, $outputFile);
- }
- }
-
- switch ($mode) {
- case Crypt_GPG::SIGN_MODE_DETACHED:
- $operation = '--detach-sign';
- break;
- case Crypt_GPG::SIGN_MODE_CLEAR:
- $operation = '--clearsign';
- break;
- case Crypt_GPG::SIGN_MODE_NORMAL:
- default:
- $operation = '--sign';
- break;
- }
-
- $arguments = array();
-
- if ($armor) {
- $arguments[] = '--armor';
- }
- if ($textmode) {
- $arguments[] = '--textmode';
- }
-
- foreach ($this->signKeys as $key) {
- $arguments[] = '--local-user ' .
- escapeshellarg($key['fingerprint']);
- }
-
- $this->engine->reset();
- $this->engine->addStatusHandler(array($this, 'handleSignStatus'));
- $this->engine->setInput($input);
- $this->engine->setOutput($output);
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- if ($outputFile !== null) {
- fclose($output);
- }
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- break;
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- throw new Crypt_GPG_KeyNotFoundException(
- 'Cannot sign data. Private key not found. Import the '.
- 'private key before trying to sign data.', $code,
- $this->engine->getErrorKeyId());
- case Crypt_GPG::ERROR_BAD_PASSPHRASE:
- throw new Crypt_GPG_BadPassphraseException(
- 'Cannot sign data. Incorrect passphrase provided.', $code);
- case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
- throw new Crypt_GPG_BadPassphraseException(
- 'Cannot sign data. No passphrase provided.', $code);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error signing data. Please use the \'debug\' option ' .
- 'when creating the Crypt_GPG object, and file a bug report ' .
- 'at ' . self::BUG_URI, $code);
- }
-
- if ($outputFile === null) {
- return $output;
- }
- }
-
- // }}}
- // {{{ _encryptAndSign()
-
- /**
- * Encrypts and signs data
- *
- * @param string $data the data to be encrypted and signed.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $outputFile the name of the file in which the encrypted,
- * signed data should be stored. If null, the
- * encrypted, signed data is returned as a
- * string.
- * @param boolean $armor if true, ASCII armored data is returned;
- * otherwise, binary data is returned.
- *
- * @return void|string if the <kbd>$outputFile</kbd> parameter is null, a
- * string containing the encrypted, signed data is
- * returned.
- *
- * @throws Crypt_GPG_KeyNotFoundException if no encryption key is specified
- * or if no signing key is specified. See
- * {@link Crypt_GPG::addEncryptKey()} and
- * {@link Crypt_GPG::addSignKey()}.
- *
- * @throws Crypt_GPG_BadPassphraseException if a specified passphrase is
- * incorrect or if a required passphrase is not specified.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- */
- private function _encryptAndSign($data, $isFile, $outputFile, $armor)
- {
- if (count($this->signKeys) === 0) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'No signing keys specified.');
- }
-
- if (count($this->encryptKeys) === 0) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'No encryption keys specified.');
- }
-
-
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input ' .
- 'file "' . $data . '" for encrypting and signing.', 0,
- $data);
- }
- } else {
- $input = strval($data);
- }
-
- if ($outputFile === null) {
- $output = '';
- } else {
- $output = @fopen($outputFile, 'wb');
- if ($output === false) {
- if ($isFile) {
- fclose($input);
- }
- throw new Crypt_GPG_FileException('Could not open output ' .
- 'file "' . $outputFile . '" for storing encrypted, ' .
- 'signed data.', 0, $outputFile);
- }
- }
-
- $arguments = ($armor) ? array('--armor') : array();
-
- foreach ($this->signKeys as $key) {
- $arguments[] = '--local-user ' .
- escapeshellarg($key['fingerprint']);
- }
-
- foreach ($this->encryptKeys as $key) {
- $arguments[] = '--recipient ' . escapeshellarg($key['fingerprint']);
- }
-
- $this->engine->reset();
- $this->engine->addStatusHandler(array($this, 'handleSignStatus'));
- $this->engine->setInput($input);
- $this->engine->setOutput($output);
- $this->engine->setOperation('--encrypt --sign', $arguments);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- if ($outputFile !== null) {
- fclose($output);
- }
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- break;
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- throw new Crypt_GPG_KeyNotFoundException(
- 'Cannot sign encrypted data. Private key not found. Import '.
- 'the private key before trying to sign the encrypted data.',
- $code, $this->engine->getErrorKeyId());
- case Crypt_GPG::ERROR_BAD_PASSPHRASE:
- throw new Crypt_GPG_BadPassphraseException(
- 'Cannot sign encrypted data. Incorrect passphrase provided.',
- $code);
- case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
- throw new Crypt_GPG_BadPassphraseException(
- 'Cannot sign encrypted data. No passphrase provided.', $code);
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error encrypting and signing data. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
-
- if ($outputFile === null) {
- return $output;
- }
- }
-
- // }}}
- // {{{ _verify()
-
- /**
- * Verifies data
- *
- * @param string $data the signed data to be verified.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $signature if verifying a file signed using a detached
- * signature, this must be the detached signature
- * data. Otherwise, specify ''.
- *
- * @return array an array of {@link Crypt_GPG_Signature} objects for the
- * signed data.
- *
- * @throws Crypt_GPG_NoDataException if the provided data is not signed
- * data.
- *
- * @throws Crypt_GPG_FileException if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG_Signature
- */
- private function _verify($data, $isFile, $signature)
- {
- if ($signature == '') {
- $operation = '--verify';
- $arguments = array();
- } else {
- // Signed data goes in FD_MESSAGE, detached signature data goes in
- // FD_INPUT.
- $operation = '--verify - "-&' . Crypt_GPG_Engine::FD_MESSAGE. '"';
- $arguments = array('--enable-special-filenames');
- }
-
- $handler = new Crypt_GPG_VerifyStatusHandler();
-
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input ' .
- 'file "' . $data . '" for verifying.', 0, $data);
- }
- } else {
- $input = strval($data);
- if ($input == '') {
- throw new Crypt_GPG_NoDataException(
- 'No valid signature data found.', Crypt_GPG::ERROR_NO_DATA);
- }
- }
-
- $this->engine->reset();
- $this->engine->addStatusHandler(array($handler, 'handle'));
-
- if ($signature == '') {
- // signed or clearsigned data
- $this->engine->setInput($input);
- } else {
- // detached signature
- $this->engine->setInput($signature);
- $this->engine->setMessage($input);
- }
-
- $this->engine->setOperation($operation, $arguments);
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- $code = $this->engine->getErrorCode();
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- case Crypt_GPG::ERROR_BAD_SIGNATURE:
- break;
- case Crypt_GPG::ERROR_NO_DATA:
- throw new Crypt_GPG_NoDataException(
- 'No valid signature data found.', $code);
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- throw new Crypt_GPG_KeyNotFoundException(
- 'Public key required for data verification not in keyring.',
- $code, $this->engine->getErrorKeyId());
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error validating signature details. Please use the ' .
- '\'debug\' option when creating the Crypt_GPG object, and ' .
- 'file a bug report at ' . self::BUG_URI, $code);
- }
-
- return $handler->getSignatures();
- }
-
- // }}}
- // {{{ _decryptAndVerify()
-
- /**
- * Decrypts and verifies encrypted, signed data
- *
- * @param string $data the encrypted signed data to be decrypted and
- * verified.
- * @param boolean $isFile whether or not the data is a filename.
- * @param string $outputFile the name of the file to which the decrypted
- * data should be written. If null, the decrypted
- * data is returned in the results array.
- *
- * @return array two element array. The array has an element 'data'
- * containing the decrypted data and an element
- * 'signatures' containing an array of
- * {@link Crypt_GPG_Signature} objects for the signed data.
- * If the decrypted data is written to a file, the 'data'
- * element is null.
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring or it the public
- * key needed for verification is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG signed, encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_FileException if the output file is not writeable or
- * if the input file is not readable.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @see Crypt_GPG_Signature
- */
- private function _decryptAndVerify($data, $isFile, $outputFile)
- {
- if ($isFile) {
- $input = @fopen($data, 'rb');
- if ($input === false) {
- throw new Crypt_GPG_FileException('Could not open input ' .
- 'file "' . $data . '" for decrypting and verifying.', 0,
- $data);
- }
- } else {
- $input = strval($data);
- if ($input == '') {
- throw new Crypt_GPG_NoDataException(
- 'No valid encrypted signed data found.',
- Crypt_GPG::ERROR_NO_DATA);
- }
- }
-
- if ($outputFile === null) {
- $output = '';
- } else {
- $output = @fopen($outputFile, 'wb');
- if ($output === false) {
- if ($isFile) {
- fclose($input);
- }
- throw new Crypt_GPG_FileException('Could not open output ' .
- 'file "' . $outputFile . '" for storing decrypted data.',
- 0, $outputFile);
- }
- }
-
- $verifyHandler = new Crypt_GPG_VerifyStatusHandler();
-
- $decryptHandler = new Crypt_GPG_DecryptStatusHandler($this->engine,
- $this->decryptKeys);
-
- $this->engine->reset();
- $this->engine->addStatusHandler(array($verifyHandler, 'handle'));
- $this->engine->addStatusHandler(array($decryptHandler, 'handle'));
- $this->engine->setInput($input);
- $this->engine->setOutput($output);
- $this->engine->setOperation('--decrypt');
- $this->engine->run();
-
- if ($isFile) {
- fclose($input);
- }
-
- if ($outputFile !== null) {
- fclose($output);
- }
-
- $return = array(
- 'data' => null,
- 'signatures' => $verifyHandler->getSignatures()
- );
-
- // if there was any problem decrypting the data, the handler will
- // deal with it here.
- try {
- $decryptHandler->throwException();
- } catch (Exception $e) {
- if ($e instanceof Crypt_GPG_KeyNotFoundException) {
- throw new Crypt_GPG_KeyNotFoundException(
- 'Public key required for data verification not in ',
- 'the keyring. Either no suitable private decryption key ' .
- 'is in the keyring or the public key required for data ' .
- 'verification is not in the keyring. Import a suitable ' .
- 'key before trying to decrypt and verify this data.',
- self::ERROR_KEY_NOT_FOUND, $this->engine->getErrorKeyId());
- }
-
- if ($e instanceof Crypt_GPG_NoDataException) {
- throw new Crypt_GPG_NoDataException(
- 'Cannot decrypt and verify data. No PGP encrypted data ' .
- 'was found in the provided data.', self::ERROR_NO_DATA);
- }
-
- throw $e;
- }
-
- if ($outputFile === null) {
- $return['data'] = $output;
- }
-
- return $return;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/DecryptStatusHandler.php b/plugins/enigma/lib/Crypt/GPG/DecryptStatusHandler.php
deleted file mode 100644
index 40e8d50ed..000000000
--- a/plugins/enigma/lib/Crypt/GPG/DecryptStatusHandler.php
+++ /dev/null
@@ -1,336 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Crypt_GPG is a package to use GPG from PHP
- *
- * This file contains an object that handles GPG's status output for the
- * decrypt operation.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2009 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: DecryptStatusHandler.php 302814 2010-08-26 15:43:07Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-
-/**
- * Crypt_GPG base class
- */
-require_once 'Crypt/GPG.php';
-
-/**
- * GPG exception classes
- */
-require_once 'Crypt/GPG/Exceptions.php';
-
-
-/**
- * Status line handler for the decrypt operation
- *
- * This class is used internally by Crypt_GPG and does not need be used
- * directly. See the {@link Crypt_GPG} class for end-user API.
- *
- * This class is responsible for sending the passphrase commands when required
- * by the {@link Crypt_GPG::decrypt()} method. See <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG distribution} for detailed
- * information on GPG's status output for the decrypt operation.
- *
- * This class is also responsible for parsing error status and throwing a
- * meaningful exception in the event that decryption fails.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-class Crypt_GPG_DecryptStatusHandler
-{
- // {{{ protected properties
-
- /**
- * Keys used to decrypt
- *
- * The array is of the form:
- * <code>
- * array(
- * $key_id => array(
- * 'fingerprint' => $fingerprint,
- * 'passphrase' => $passphrase
- * )
- * );
- * </code>
- *
- * @var array
- */
- protected $keys = array();
-
- /**
- * Engine used to which passphrases are passed
- *
- * @var Crypt_GPG_Engine
- */
- protected $engine = null;
-
- /**
- * The id of the current sub-key used for decryption
- *
- * @var string
- */
- protected $currentSubKey = '';
-
- /**
- * Whether or not decryption succeeded
- *
- * If the message is only signed (compressed) and not encrypted, this is
- * always true. If the message is encrypted, this flag is set to false
- * until we know the decryption succeeded.
- *
- * @var boolean
- */
- protected $decryptionOkay = true;
-
- /**
- * Whether or not there was no data for decryption
- *
- * @var boolean
- */
- protected $noData = false;
-
- /**
- * Keys for which the passhprase is missing
- *
- * This contains primary user ids indexed by sub-key id and is used to
- * create helpful exception messages.
- *
- * @var array
- */
- protected $missingPassphrases = array();
-
- /**
- * Keys for which the passhprase is incorrect
- *
- * This contains primary user ids indexed by sub-key id and is used to
- * create helpful exception messages.
- *
- * @var array
- */
- protected $badPassphrases = array();
-
- /**
- * Keys that can be used to decrypt the data but are missing from the
- * keychain
- *
- * This is an array with both the key and value being the sub-key id of
- * the missing keys.
- *
- * @var array
- */
- protected $missingKeys = array();
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new decryption status handler
- *
- * @param Crypt_GPG_Engine $engine the GPG engine to which passphrases are
- * passed.
- * @param array $keys the decryption keys to use.
- */
- public function __construct(Crypt_GPG_Engine $engine, array $keys)
- {
- $this->engine = $engine;
- $this->keys = $keys;
- }
-
- // }}}
- // {{{ handle()
-
- /**
- * Handles a status line
- *
- * @param string $line the status line to handle.
- *
- * @return void
- */
- public function handle($line)
- {
- $tokens = explode(' ', $line);
- switch ($tokens[0]) {
- case 'ENC_TO':
- // Now we know the message is encrypted. Set flag to check if
- // decryption succeeded.
- $this->decryptionOkay = false;
-
- // this is the new key message
- $this->currentSubKeyId = $tokens[1];
- break;
-
- case 'NEED_PASSPHRASE':
- // send passphrase to the GPG engine
- $subKeyId = $tokens[1];
- if (array_key_exists($subKeyId, $this->keys)) {
- $passphrase = $this->keys[$subKeyId]['passphrase'];
- $this->engine->sendCommand($passphrase);
- } else {
- $this->engine->sendCommand('');
- }
- break;
-
- case 'USERID_HINT':
- // remember the user id for pretty exception messages
- $this->badPassphrases[$tokens[1]]
- = implode(' ', array_splice($tokens, 2));
-
- break;
-
- case 'GOOD_PASSPHRASE':
- // if we got a good passphrase, remove the key from the list of
- // bad passphrases.
- unset($this->badPassphrases[$this->currentSubKeyId]);
- break;
-
- case 'MISSING_PASSPHRASE':
- $this->missingPassphrases[$this->currentSubKeyId]
- = $this->currentSubKeyId;
-
- break;
-
- case 'NO_SECKEY':
- // note: this message is also received if there are multiple
- // recipients and a previous key had a correct passphrase.
- $this->missingKeys[$tokens[1]] = $tokens[1];
- break;
-
- case 'NODATA':
- $this->noData = true;
- break;
-
- case 'DECRYPTION_OKAY':
- // If the message is encrypted, this is the all-clear signal.
- $this->decryptionOkay = true;
- break;
- }
- }
-
- // }}}
- // {{{ throwException()
-
- /**
- * Takes the final status of the decrypt operation and throws an
- * appropriate exception
- *
- * If decryption was successful, no exception is thrown.
- *
- * @return void
- *
- * @throws Crypt_GPG_KeyNotFoundException if the private key needed to
- * decrypt the data is not in the user's keyring.
- *
- * @throws Crypt_GPG_NoDataException if specified data does not contain
- * GPG encrypted data.
- *
- * @throws Crypt_GPG_BadPassphraseException if a required passphrase is
- * incorrect or if a required passphrase is not specified. See
- * {@link Crypt_GPG::addDecryptKey()}.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <i>debug</i> option and file a bug report if these
- * exceptions occur.
- */
- public function throwException()
- {
- $code = Crypt_GPG::ERROR_NONE;
-
- if (!$this->decryptionOkay) {
- if (count($this->badPassphrases) > 0) {
- $code = Crypt_GPG::ERROR_BAD_PASSPHRASE;
- } elseif (count($this->missingKeys) > 0) {
- $code = Crypt_GPG::ERROR_KEY_NOT_FOUND;
- } else {
- $code = Crypt_GPG::ERROR_UNKNOWN;
- }
- } elseif ($this->noData) {
- $code = Crypt_GPG::ERROR_NO_DATA;
- }
-
- switch ($code) {
- case Crypt_GPG::ERROR_NONE:
- break;
-
- case Crypt_GPG::ERROR_KEY_NOT_FOUND:
- if (count($this->missingKeys) > 0) {
- $keyId = reset($this->missingKeys);
- } else {
- $keyId = '';
- }
- throw new Crypt_GPG_KeyNotFoundException(
- 'Cannot decrypt data. No suitable private key is in the ' .
- 'keyring. Import a suitable private key before trying to ' .
- 'decrypt this data.', $code, $keyId);
-
- case Crypt_GPG::ERROR_BAD_PASSPHRASE:
- $badPassphrases = array_diff_key(
- $this->badPassphrases,
- $this->missingPassphrases
- );
-
- $missingPassphrases = array_intersect_key(
- $this->badPassphrases,
- $this->missingPassphrases
- );
-
- $message = 'Cannot decrypt data.';
- if (count($badPassphrases) > 0) {
- $message = ' Incorrect passphrase provided for keys: "' .
- implode('", "', $badPassphrases) . '".';
- }
- if (count($missingPassphrases) > 0) {
- $message = ' No passphrase provided for keys: "' .
- implode('", "', $badPassphrases) . '".';
- }
-
- throw new Crypt_GPG_BadPassphraseException($message, $code,
- $badPassphrases, $missingPassphrases);
-
- case Crypt_GPG::ERROR_NO_DATA:
- throw new Crypt_GPG_NoDataException(
- 'Cannot decrypt data. No PGP encrypted data was found in '.
- 'the provided data.', $code);
-
- default:
- throw new Crypt_GPG_Exception(
- 'Unknown error decrypting data.', $code);
- }
- }
-
- // }}}
-}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/Engine.php b/plugins/enigma/lib/Crypt/GPG/Engine.php
deleted file mode 100644
index 081be8e21..000000000
--- a/plugins/enigma/lib/Crypt/GPG/Engine.php
+++ /dev/null
@@ -1,1758 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Crypt_GPG is a package to use GPG from PHP
- *
- * This file contains an engine that handles GPG subprocess control and I/O.
- * PHP's process manipulation functions are used to handle the GPG subprocess.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: Engine.php 302822 2010-08-26 17:30:57Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-
-/**
- * Crypt_GPG base class.
- */
-require_once 'Crypt/GPG.php';
-
-/**
- * GPG exception classes.
- */
-require_once 'Crypt/GPG/Exceptions.php';
-
-/**
- * Standard PEAR exception is used if GPG binary is not found.
- */
-require_once 'PEAR/Exception.php';
-
-// {{{ class Crypt_GPG_Engine
-
-/**
- * Native PHP Crypt_GPG I/O engine
- *
- * This class is used internally by Crypt_GPG and does not need be used
- * directly. See the {@link Crypt_GPG} class for end-user API.
- *
- * This engine uses PHP's native process control functions to directly control
- * the GPG process. The GPG executable is required to be on the system.
- *
- * All data is passed to the GPG subprocess using file descriptors. This is the
- * most secure method of passing data to the GPG subprocess.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-class Crypt_GPG_Engine
-{
- // {{{ constants
-
- /**
- * Size of data chunks that are sent to and retrieved from the IPC pipes.
- *
- * PHP reads 8192 bytes. If this is set to less than 8192, PHP reads 8192
- * and buffers the rest so we might as well just read 8192.
- *
- * Using values other than 8192 also triggers PHP bugs.
- *
- * @see http://bugs.php.net/bug.php?id=35224
- */
- const CHUNK_SIZE = 8192;
-
- /**
- * Standard input file descriptor. This is used to pass data to the GPG
- * process.
- */
- const FD_INPUT = 0;
-
- /**
- * Standard output file descriptor. This is used to receive normal output
- * from the GPG process.
- */
- const FD_OUTPUT = 1;
-
- /**
- * Standard output file descriptor. This is used to receive error output
- * from the GPG process.
- */
- const FD_ERROR = 2;
-
- /**
- * GPG status output file descriptor. The status file descriptor outputs
- * detailed information for many GPG commands. See the second section of
- * the file <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG package} for a detailed
- * description of GPG's status output.
- */
- const FD_STATUS = 3;
-
- /**
- * Command input file descriptor. This is used for methods requiring
- * passphrases.
- */
- const FD_COMMAND = 4;
-
- /**
- * Extra message input file descriptor. This is used for passing signed
- * data when verifying a detached signature.
- */
- const FD_MESSAGE = 5;
-
- /**
- * Minimum version of GnuPG that is supported.
- */
- const MIN_VERSION = '1.0.2';
-
- // }}}
- // {{{ private class properties
-
- /**
- * Whether or not to use debugging mode
- *
- * When set to true, every GPG command is echoed before it is run. Sensitive
- * data is always handled using pipes and is not specified as part of the
- * command. As a result, sensitive data is never displayed when debug is
- * enabled. Sensitive data includes private key data and passphrases.
- *
- * Debugging is off by default.
- *
- * @var boolean
- * @see Crypt_GPG_Engine::__construct()
- */
- private $_debug = false;
-
- /**
- * Location of GPG binary
- *
- * @var string
- * @see Crypt_GPG_Engine::__construct()
- * @see Crypt_GPG_Engine::_getBinary()
- */
- private $_binary = '';
-
- /**
- * Directory containing the GPG key files
- *
- * This property only contains the path when the <i>homedir</i> option
- * is specified in the constructor.
- *
- * @var string
- * @see Crypt_GPG_Engine::__construct()
- */
- private $_homedir = '';
-
- /**
- * File path of the public keyring
- *
- * This property only contains the file path when the <i>public_keyring</i>
- * option is specified in the constructor.
- *
- * If the specified file path starts with <kbd>~/</kbd>, the path is
- * relative to the <i>homedir</i> if specified, otherwise to
- * <kbd>~/.gnupg</kbd>.
- *
- * @var string
- * @see Crypt_GPG_Engine::__construct()
- */
- private $_publicKeyring = '';
-
- /**
- * File path of the private (secret) keyring
- *
- * This property only contains the file path when the <i>private_keyring</i>
- * option is specified in the constructor.
- *
- * If the specified file path starts with <kbd>~/</kbd>, the path is
- * relative to the <i>homedir</i> if specified, otherwise to
- * <kbd>~/.gnupg</kbd>.
- *
- * @var string
- * @see Crypt_GPG_Engine::__construct()
- */
- private $_privateKeyring = '';
-
- /**
- * File path of the trust database
- *
- * This property only contains the file path when the <i>trust_db</i>
- * option is specified in the constructor.
- *
- * If the specified file path starts with <kbd>~/</kbd>, the path is
- * relative to the <i>homedir</i> if specified, otherwise to
- * <kbd>~/.gnupg</kbd>.
- *
- * @var string
- * @see Crypt_GPG_Engine::__construct()
- */
- private $_trustDb = '';
-
- /**
- * Array of pipes used for communication with the GPG binary
- *
- * This is an array of file descriptor resources.
- *
- * @var array
- */
- private $_pipes = array();
-
- /**
- * Array of currently opened pipes
- *
- * This array is used to keep track of remaining opened pipes so they can
- * be closed when the GPG subprocess is finished. This array is a subset of
- * the {@link Crypt_GPG_Engine::$_pipes} array and contains opened file
- * descriptor resources.
- *
- * @var array
- * @see Crypt_GPG_Engine::_closePipe()
- */
- private $_openPipes = array();
-
- /**
- * A handle for the GPG process
- *
- * @var resource
- */
- private $_process = null;
-
- /**
- * Whether or not the operating system is Darwin (OS X)
- *
- * @var boolean
- */
- private $_isDarwin = false;
-
- /**
- * Commands to be sent to GPG's command input stream
- *
- * @var string
- * @see Crypt_GPG_Engine::sendCommand()
- */
- private $_commandBuffer = '';
-
- /**
- * Array of status line handlers
- *
- * @var array
- * @see Crypt_GPG_Engine::addStatusHandler()
- */
- private $_statusHandlers = array();
-
- /**
- * Array of error line handlers
- *
- * @var array
- * @see Crypt_GPG_Engine::addErrorHandler()
- */
- private $_errorHandlers = array();
-
- /**
- * The error code of the current operation
- *
- * @var integer
- * @see Crypt_GPG_Engine::getErrorCode()
- */
- private $_errorCode = Crypt_GPG::ERROR_NONE;
-
- /**
- * File related to the error code of the current operation
- *
- * @var string
- * @see Crypt_GPG_Engine::getErrorFilename()
- */
- private $_errorFilename = '';
-
- /**
- * Key id related to the error code of the current operation
- *
- * @var string
- * @see Crypt_GPG_Engine::getErrorKeyId()
- */
- private $_errorkeyId = '';
-
- /**
- * The number of currently needed passphrases
- *
- * If this is not zero when the GPG command is completed, the error code is
- * set to {@link Crypt_GPG::ERROR_MISSING_PASSPHRASE}.
- *
- * @var integer
- */
- private $_needPassphrase = 0;
-
- /**
- * The input source
- *
- * This is data to send to GPG. Either a string or a stream resource.
- *
- * @var string|resource
- * @see Crypt_GPG_Engine::setInput()
- */
- private $_input = null;
-
- /**
- * The extra message input source
- *
- * Either a string or a stream resource.
- *
- * @var string|resource
- * @see Crypt_GPG_Engine::setMessage()
- */
- private $_message = null;
-
- /**
- * The output location
- *
- * This is where the output from GPG is sent. Either a string or a stream
- * resource.
- *
- * @var string|resource
- * @see Crypt_GPG_Engine::setOutput()
- */
- private $_output = '';
-
- /**
- * The GPG operation to execute
- *
- * @var string
- * @see Crypt_GPG_Engine::setOperation()
- */
- private $_operation;
-
- /**
- * Arguments for the current operation
- *
- * @var array
- * @see Crypt_GPG_Engine::setOperation()
- */
- private $_arguments = array();
-
- /**
- * The version number of the GPG binary
- *
- * @var string
- * @see Crypt_GPG_Engine::getVersion()
- */
- private $_version = '';
-
- /**
- * Cached value indicating whether or not mbstring function overloading is
- * on for strlen
- *
- * This is cached for optimal performance inside the I/O loop.
- *
- * @var boolean
- * @see Crypt_GPG_Engine::_byteLength()
- * @see Crypt_GPG_Engine::_byteSubstring()
- */
- private static $_mbStringOverload = null;
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new GPG engine
- *
- * Available options are:
- *
- * - <kbd>string homedir</kbd> - the directory where the GPG
- * keyring files are stored. If not
- * specified, Crypt_GPG uses the
- * default of <kbd>~/.gnupg</kbd>.
- * - <kbd>string publicKeyring</kbd> - the file path of the public
- * keyring. Use this if the public
- * keyring is not in the homedir, or
- * if the keyring is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * keyring with this option
- * (/foo/bar/pubring.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string privateKeyring</kbd> - the file path of the private
- * keyring. Use this if the private
- * keyring is not in the homedir, or
- * if the keyring is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * keyring with this option
- * (/foo/bar/secring.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string trustDb</kbd> - the file path of the web-of-trust
- * database. Use this if the trust
- * database is not in the homedir, or
- * if the database is in a directory
- * not writable by the process
- * invoking GPG (like Apache). Then
- * you can specify the path to the
- * trust database with this option
- * (/foo/bar/trustdb.gpg), and specify
- * a writable directory (like /tmp)
- * using the <i>homedir</i> option.
- * - <kbd>string binary</kbd> - the location of the GPG binary. If
- * not specified, the driver attempts
- * to auto-detect the GPG binary
- * location using a list of known
- * default locations for the current
- * operating system. The option
- * <kbd>gpgBinary</kbd> is a
- * deprecated alias for this option.
- * - <kbd>boolean debug</kbd> - whether or not to use debug mode.
- * When debug mode is on, all
- * communication to and from the GPG
- * subprocess is logged. This can be
- * useful to diagnose errors when
- * using Crypt_GPG.
- *
- * @param array $options optional. An array of options used to create the
- * GPG object. All options are optional and are
- * represented as key-value pairs.
- *
- * @throws Crypt_GPG_FileException if the <kbd>homedir</kbd> does not exist
- * and cannot be created. This can happen if <kbd>homedir</kbd> is
- * not specified, Crypt_GPG is run as the web user, and the web
- * user has no home directory. This exception is also thrown if any
- * of the options <kbd>publicKeyring</kbd>,
- * <kbd>privateKeyring</kbd> or <kbd>trustDb</kbd> options are
- * specified but the files do not exist or are are not readable.
- * This can happen if the user running the Crypt_GPG process (for
- * example, the Apache user) does not have permission to read the
- * files.
- *
- * @throws PEAR_Exception if the provided <kbd>binary</kbd> is invalid, or
- * if no <kbd>binary</kbd> is provided and no suitable binary could
- * be found.
- */
- public function __construct(array $options = array())
- {
- $this->_isDarwin = (strncmp(strtoupper(PHP_OS), 'DARWIN', 6) === 0);
-
- // populate mbstring overloading cache if not set
- if (self::$_mbStringOverload === null) {
- self::$_mbStringOverload = (extension_loaded('mbstring')
- && (ini_get('mbstring.func_overload') & 0x02) === 0x02);
- }
-
- // get homedir
- if (array_key_exists('homedir', $options)) {
- $this->_homedir = (string)$options['homedir'];
- } else {
- // note: this requires the package OS dep exclude 'windows'
- $info = posix_getpwuid(posix_getuid());
- $this->_homedir = $info['dir'].'/.gnupg';
- }
-
- // attempt to create homedir if it does not exist
- if (!is_dir($this->_homedir)) {
- if (@mkdir($this->_homedir, 0777, true)) {
- // Set permissions on homedir. Parent directories are created
- // with 0777, homedir is set to 0700.
- chmod($this->_homedir, 0700);
- } else {
- throw new Crypt_GPG_FileException('The \'homedir\' "' .
- $this->_homedir . '" is not readable or does not exist '.
- 'and cannot be created. This can happen if \'homedir\' '.
- 'is not specified in the Crypt_GPG options, Crypt_GPG is '.
- 'run as the web user, and the web user has no home '.
- 'directory.',
- 0, $this->_homedir);
- }
- }
-
- // get binary
- if (array_key_exists('binary', $options)) {
- $this->_binary = (string)$options['binary'];
- } elseif (array_key_exists('gpgBinary', $options)) {
- // deprecated alias
- $this->_binary = (string)$options['gpgBinary'];
- } else {
- $this->_binary = $this->_getBinary();
- }
-
- if ($this->_binary == '' || !is_executable($this->_binary)) {
- throw new PEAR_Exception('GPG binary not found. If you are sure '.
- 'the GPG binary is installed, please specify the location of '.
- 'the GPG binary using the \'binary\' driver option.');
- }
-
- /*
- * Note:
- *
- * Normally, GnuPG expects keyrings to be in the homedir and expects
- * to be able to write temporary files in the homedir. Sometimes,
- * keyrings are not in the homedir, or location of the keyrings does
- * not allow writing temporary files. In this case, the <i>homedir</i>
- * option by itself is not enough to specify the keyrings because GnuPG
- * can not write required temporary files. Additional options are
- * provided so you can specify the location of the keyrings separately
- * from the homedir.
- */
-
- // get public keyring
- if (array_key_exists('publicKeyring', $options)) {
- $this->_publicKeyring = (string)$options['publicKeyring'];
- if (!is_readable($this->_publicKeyring)) {
- throw new Crypt_GPG_FileException('The \'publicKeyring\' "' .
- $this->_publicKeyring . '" does not exist or is ' .
- 'not readable. Check the location and ensure the file ' .
- 'permissions are correct.', 0, $this->_publicKeyring);
- }
- }
-
- // get private keyring
- if (array_key_exists('privateKeyring', $options)) {
- $this->_privateKeyring = (string)$options['privateKeyring'];
- if (!is_readable($this->_privateKeyring)) {
- throw new Crypt_GPG_FileException('The \'privateKeyring\' "' .
- $this->_privateKeyring . '" does not exist or is ' .
- 'not readable. Check the location and ensure the file ' .
- 'permissions are correct.', 0, $this->_privateKeyring);
- }
- }
-
- // get trust database
- if (array_key_exists('trustDb', $options)) {
- $this->_trustDb = (string)$options['trustDb'];
- if (!is_readable($this->_trustDb)) {
- throw new Crypt_GPG_FileException('The \'trustDb\' "' .
- $this->_trustDb . '" does not exist or is not readable. ' .
- 'Check the location and ensure the file permissions are ' .
- 'correct.', 0, $this->_trustDb);
- }
- }
-
- if (array_key_exists('debug', $options)) {
- $this->_debug = (boolean)$options['debug'];
- }
- }
-
- // }}}
- // {{{ __destruct()
-
- /**
- * Closes open GPG subprocesses when this object is destroyed
- *
- * Subprocesses should never be left open by this class unless there is
- * an unknown error and unexpected script termination occurs.
- */
- public function __destruct()
- {
- $this->_closeSubprocess();
- }
-
- // }}}
- // {{{ addErrorHandler()
-
- /**
- * Adds an error handler method
- *
- * The method is run every time a new error line is received from the GPG
- * subprocess. The handler method must accept the error line to be handled
- * as its first parameter.
- *
- * @param callback $callback the callback method to use.
- * @param array $args optional. Additional arguments to pass as
- * parameters to the callback method.
- *
- * @return void
- */
- public function addErrorHandler($callback, array $args = array())
- {
- $this->_errorHandlers[] = array(
- 'callback' => $callback,
- 'args' => $args
- );
- }
-
- // }}}
- // {{{ addStatusHandler()
-
- /**
- * Adds a status handler method
- *
- * The method is run every time a new status line is received from the
- * GPG subprocess. The handler method must accept the status line to be
- * handled as its first parameter.
- *
- * @param callback $callback the callback method to use.
- * @param array $args optional. Additional arguments to pass as
- * parameters to the callback method.
- *
- * @return void
- */
- public function addStatusHandler($callback, array $args = array())
- {
- $this->_statusHandlers[] = array(
- 'callback' => $callback,
- 'args' => $args
- );
- }
-
- // }}}
- // {{{ sendCommand()
-
- /**
- * Sends a command to the GPG subprocess over the command file-descriptor
- * pipe
- *
- * @param string $command the command to send.
- *
- * @return void
- *
- * @sensitive $command
- */
- public function sendCommand($command)
- {
- if (array_key_exists(self::FD_COMMAND, $this->_openPipes)) {
- $this->_commandBuffer .= $command . PHP_EOL;
- }
- }
-
- // }}}
- // {{{ reset()
-
- /**
- * Resets the GPG engine, preparing it for a new operation
- *
- * @return void
- *
- * @see Crypt_GPG_Engine::run()
- * @see Crypt_GPG_Engine::setOperation()
- */
- public function reset()
- {
- $this->_operation = '';
- $this->_arguments = array();
- $this->_input = null;
- $this->_message = null;
- $this->_output = '';
- $this->_errorCode = Crypt_GPG::ERROR_NONE;
- $this->_needPassphrase = 0;
- $this->_commandBuffer = '';
-
- $this->_statusHandlers = array();
- $this->_errorHandlers = array();
-
- $this->addStatusHandler(array($this, '_handleErrorStatus'));
- $this->addErrorHandler(array($this, '_handleErrorError'));
-
- if ($this->_debug) {
- $this->addStatusHandler(array($this, '_handleDebugStatus'));
- $this->addErrorHandler(array($this, '_handleDebugError'));
- }
- }
-
- // }}}
- // {{{ run()
-
- /**
- * Runs the current GPG operation
- *
- * This creates and manages the GPG subprocess.
- *
- * The operation must be set with {@link Crypt_GPG_Engine::setOperation()}
- * before this method is called.
- *
- * @return void
- *
- * @throws Crypt_GPG_InvalidOperationException if no operation is specified.
- *
- * @see Crypt_GPG_Engine::reset()
- * @see Crypt_GPG_Engine::setOperation()
- */
- public function run()
- {
- if ($this->_operation === '') {
- throw new Crypt_GPG_InvalidOperationException('No GPG operation ' .
- 'specified. Use Crypt_GPG_Engine::setOperation() before ' .
- 'calling Crypt_GPG_Engine::run().');
- }
-
- $this->_openSubprocess();
- $this->_process();
- $this->_closeSubprocess();
- }
-
- // }}}
- // {{{ getErrorCode()
-
- /**
- * Gets the error code of the last executed operation
- *
- * This value is only meaningful after {@link Crypt_GPG_Engine::run()} has
- * been executed.
- *
- * @return integer the error code of the last executed operation.
- */
- public function getErrorCode()
- {
- return $this->_errorCode;
- }
-
- // }}}
- // {{{ getErrorFilename()
-
- /**
- * Gets the file related to the error code of the last executed operation
- *
- * This value is only meaningful after {@link Crypt_GPG_Engine::run()} has
- * been executed. If there is no file related to the error, an empty string
- * is returned.
- *
- * @return string the file related to the error code of the last executed
- * operation.
- */
- public function getErrorFilename()
- {
- return $this->_errorFilename;
- }
-
- // }}}
- // {{{ getErrorKeyId()
-
- /**
- * Gets the key id related to the error code of the last executed operation
- *
- * This value is only meaningful after {@link Crypt_GPG_Engine::run()} has
- * been executed. If there is no key id related to the error, an empty
- * string is returned.
- *
- * @return string the key id related to the error code of the last executed
- * operation.
- */
- public function getErrorKeyId()
- {
- return $this->_errorKeyId;
- }
-
- // }}}
- // {{{ setInput()
-
- /**
- * Sets the input source for the current GPG operation
- *
- * @param string|resource &$input either a reference to the string
- * containing the input data or an open
- * stream resource containing the input
- * data.
- *
- * @return void
- */
- public function setInput(&$input)
- {
- $this->_input =& $input;
- }
-
- // }}}
- // {{{ setMessage()
-
- /**
- * Sets the message source for the current GPG operation
- *
- * Detached signature data should be specified here.
- *
- * @param string|resource &$message either a reference to the string
- * containing the message data or an open
- * stream resource containing the message
- * data.
- *
- * @return void
- */
- public function setMessage(&$message)
- {
- $this->_message =& $message;
- }
-
- // }}}
- // {{{ setOutput()
-
- /**
- * Sets the output destination for the current GPG operation
- *
- * @param string|resource &$output either a reference to the string in
- * which to store GPG output or an open
- * stream resource to which the output data
- * should be written.
- *
- * @return void
- */
- public function setOutput(&$output)
- {
- $this->_output =& $output;
- }
-
- // }}}
- // {{{ setOperation()
-
- /**
- * Sets the operation to perform
- *
- * @param string $operation the operation to perform. This should be one
- * of GPG's operations. For example,
- * <kbd>--encrypt</kbd>, <kbd>--decrypt</kbd>,
- * <kbd>--sign</kbd>, etc.
- * @param array $arguments optional. Additional arguments for the GPG
- * subprocess. See the GPG manual for specific
- * values.
- *
- * @return void
- *
- * @see Crypt_GPG_Engine::reset()
- * @see Crypt_GPG_Engine::run()
- */
- public function setOperation($operation, array $arguments = array())
- {
- $this->_operation = $operation;
- $this->_arguments = $arguments;
- }
-
- // }}}
- // {{{ getVersion()
-
- /**
- * Gets the version of the GnuPG binary
- *
- * @return string a version number string containing the version of GnuPG
- * being used. This value is suitable to use with PHP's
- * version_compare() function.
- *
- * @throws Crypt_GPG_Exception if an unknown or unexpected error occurs.
- * Use the <kbd>debug</kbd> option and file a bug report if these
- * exceptions occur.
- *
- * @throws Crypt_GPG_UnsupportedException if the provided binary is not
- * GnuPG or if the GnuPG version is less than 1.0.2.
- */
- public function getVersion()
- {
- if ($this->_version == '') {
-
- $options = array(
- 'homedir' => $this->_homedir,
- 'binary' => $this->_binary,
- 'debug' => $this->_debug
- );
-
- $engine = new self($options);
- $info = '';
-
- // Set a garbage version so we do not end up looking up the version
- // recursively.
- $engine->_version = '1.0.0';
-
- $engine->reset();
- $engine->setOutput($info);
- $engine->setOperation('--version');
- $engine->run();
-
- $code = $this->getErrorCode();
-
- if ($code !== Crypt_GPG::ERROR_NONE) {
- throw new Crypt_GPG_Exception(
- 'Unknown error getting GnuPG version information. Please ' .
- 'use the \'debug\' option when creating the Crypt_GPG ' .
- 'object, and file a bug report at ' . Crypt_GPG::BUG_URI,
- $code);
- }
-
- $matches = array();
- $expression = '/gpg \(GnuPG\) (\S+)/';
-
- if (preg_match($expression, $info, $matches) === 1) {
- $this->_version = $matches[1];
- } else {
- throw new Crypt_GPG_Exception(
- 'No GnuPG version information provided by the binary "' .
- $this->_binary . '". Are you sure it is GnuPG?');
- }
-
- if (version_compare($this->_version, self::MIN_VERSION, 'lt')) {
- throw new Crypt_GPG_Exception(
- 'The version of GnuPG being used (' . $this->_version .
- ') is not supported by Crypt_GPG. The minimum version ' .
- 'required by Crypt_GPG is ' . self::MIN_VERSION);
- }
- }
-
-
- return $this->_version;
- }
-
- // }}}
- // {{{ _handleErrorStatus()
-
- /**
- * Handles error values in the status output from GPG
- *
- * This method is responsible for setting the
- * {@link Crypt_GPG_Engine::$_errorCode}. See <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG distribution} for detailed
- * information on GPG's status output.
- *
- * @param string $line the status line to handle.
- *
- * @return void
- */
- private function _handleErrorStatus($line)
- {
- $tokens = explode(' ', $line);
- switch ($tokens[0]) {
- case 'BAD_PASSPHRASE':
- $this->_errorCode = Crypt_GPG::ERROR_BAD_PASSPHRASE;
- break;
-
- case 'MISSING_PASSPHRASE':
- $this->_errorCode = Crypt_GPG::ERROR_MISSING_PASSPHRASE;
- break;
-
- case 'NODATA':
- $this->_errorCode = Crypt_GPG::ERROR_NO_DATA;
- break;
-
- case 'DELETE_PROBLEM':
- if ($tokens[1] == '1') {
- $this->_errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
- break;
- } elseif ($tokens[1] == '2') {
- $this->_errorCode = Crypt_GPG::ERROR_DELETE_PRIVATE_KEY;
- break;
- }
- break;
-
- case 'IMPORT_RES':
- if ($tokens[12] > 0) {
- $this->_errorCode = Crypt_GPG::ERROR_DUPLICATE_KEY;
- }
- break;
-
- case 'NO_PUBKEY':
- case 'NO_SECKEY':
- $this->_errorKeyId = $tokens[1];
- $this->_errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
- break;
-
- case 'NEED_PASSPHRASE':
- $this->_needPassphrase++;
- break;
-
- case 'GOOD_PASSPHRASE':
- $this->_needPassphrase--;
- break;
-
- case 'EXPSIG':
- case 'EXPKEYSIG':
- case 'REVKEYSIG':
- case 'BADSIG':
- $this->_errorCode = Crypt_GPG::ERROR_BAD_SIGNATURE;
- break;
-
- }
- }
-
- // }}}
- // {{{ _handleErrorError()
-
- /**
- * Handles error values in the error output from GPG
- *
- * This method is responsible for setting the
- * {@link Crypt_GPG_Engine::$_errorCode}.
- *
- * @param string $line the error line to handle.
- *
- * @return void
- */
- private function _handleErrorError($line)
- {
- if ($this->_errorCode === Crypt_GPG::ERROR_NONE) {
- $pattern = '/no valid OpenPGP data found/';
- if (preg_match($pattern, $line) === 1) {
- $this->_errorCode = Crypt_GPG::ERROR_NO_DATA;
- }
- }
-
- if ($this->_errorCode === Crypt_GPG::ERROR_NONE) {
- $pattern = '/No secret key|secret key not available/';
- if (preg_match($pattern, $line) === 1) {
- $this->_errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
- }
- }
-
- if ($this->_errorCode === Crypt_GPG::ERROR_NONE) {
- $pattern = '/No public key|public key not found/';
- if (preg_match($pattern, $line) === 1) {
- $this->_errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
- }
- }
-
- if ($this->_errorCode === Crypt_GPG::ERROR_NONE) {
- $matches = array();
- $pattern = '/can\'t (?:access|open) `(.*?)\'/';
- if (preg_match($pattern, $line, $matches) === 1) {
- $this->_errorFilename = $matches[1];
- $this->_errorCode = Crypt_GPG::ERROR_FILE_PERMISSIONS;
- }
- }
- }
-
- // }}}
- // {{{ _handleDebugStatus()
-
- /**
- * Displays debug output for status lines
- *
- * @param string $line the status line to handle.
- *
- * @return void
- */
- private function _handleDebugStatus($line)
- {
- $this->_debug('STATUS: ' . $line);
- }
-
- // }}}
- // {{{ _handleDebugError()
-
- /**
- * Displays debug output for error lines
- *
- * @param string $line the error line to handle.
- *
- * @return void
- */
- private function _handleDebugError($line)
- {
- $this->_debug('ERROR: ' . $line);
- }
-
- // }}}
- // {{{ _process()
-
- /**
- * Performs internal streaming operations for the subprocess using either
- * strings or streams as input / output points
- *
- * This is the main I/O loop for streaming to and from the GPG subprocess.
- *
- * The implementation of this method is verbose mainly for performance
- * reasons. Adding streams to a lookup array and looping the array inside
- * the main I/O loop would be siginficantly slower for large streams.
- *
- * @return void
- *
- * @throws Crypt_GPG_Exception if there is an error selecting streams for
- * reading or writing. If this occurs, please file a bug report at
- * http://pear.php.net/bugs/report.php?package=Crypt_GPG.
- */
- private function _process()
- {
- $this->_debug('BEGIN PROCESSING');
-
- $this->_commandBuffer = ''; // buffers input to GPG
- $messageBuffer = ''; // buffers input to GPG
- $inputBuffer = ''; // buffers input to GPG
- $outputBuffer = ''; // buffers output from GPG
- $statusBuffer = ''; // buffers output from GPG
- $errorBuffer = ''; // buffers output from GPG
- $inputComplete = false; // input stream is completely buffered
- $messageComplete = false; // message stream is completely buffered
-
- if (is_string($this->_input)) {
- $inputBuffer = $this->_input;
- $inputComplete = true;
- }
-
- if (is_string($this->_message)) {
- $messageBuffer = $this->_message;
- $messageComplete = true;
- }
-
- if (is_string($this->_output)) {
- $outputBuffer =& $this->_output;
- }
-
- // convenience variables
- $fdInput = $this->_pipes[self::FD_INPUT];
- $fdOutput = $this->_pipes[self::FD_OUTPUT];
- $fdError = $this->_pipes[self::FD_ERROR];
- $fdStatus = $this->_pipes[self::FD_STATUS];
- $fdCommand = $this->_pipes[self::FD_COMMAND];
- $fdMessage = $this->_pipes[self::FD_MESSAGE];
-
- while (true) {
-
- $inputStreams = array();
- $outputStreams = array();
- $exceptionStreams = array();
-
- // set up input streams
- if (is_resource($this->_input) && !$inputComplete) {
- if (feof($this->_input)) {
- $inputComplete = true;
- } else {
- $inputStreams[] = $this->_input;
- }
- }
-
- // close GPG input pipe if there is no more data
- if ($inputBuffer == '' && $inputComplete) {
- $this->_debug('=> closing GPG input pipe');
- $this->_closePipe(self::FD_INPUT);
- }
-
- if (is_resource($this->_message) && !$messageComplete) {
- if (feof($this->_message)) {
- $messageComplete = true;
- } else {
- $inputStreams[] = $this->_message;
- }
- }
-
- // close GPG message pipe if there is no more data
- if ($messageBuffer == '' && $messageComplete) {
- $this->_debug('=> closing GPG message pipe');
- $this->_closePipe(self::FD_MESSAGE);
- }
-
- if (!feof($fdOutput)) {
- $inputStreams[] = $fdOutput;
- }
-
- if (!feof($fdStatus)) {
- $inputStreams[] = $fdStatus;
- }
-
- if (!feof($fdError)) {
- $inputStreams[] = $fdError;
- }
-
- // set up output streams
- if ($outputBuffer != '' && is_resource($this->_output)) {
- $outputStreams[] = $this->_output;
- }
-
- if ($this->_commandBuffer != '') {
- $outputStreams[] = $fdCommand;
- }
-
- if ($messageBuffer != '') {
- $outputStreams[] = $fdMessage;
- }
-
- if ($inputBuffer != '') {
- $outputStreams[] = $fdInput;
- }
-
- // no streams left to read or write, we're all done
- if (count($inputStreams) === 0 && count($outputStreams) === 0) {
- break;
- }
-
- $this->_debug('selecting streams');
-
- $ready = stream_select(
- $inputStreams,
- $outputStreams,
- $exceptionStreams,
- null
- );
-
- $this->_debug('=> got ' . $ready);
-
- if ($ready === false) {
- throw new Crypt_GPG_Exception(
- 'Error selecting stream for communication with GPG ' .
- 'subprocess. Please file a bug report at: ' .
- 'http://pear.php.net/bugs/report.php?package=Crypt_GPG');
- }
-
- if ($ready === 0) {
- throw new Crypt_GPG_Exception(
- 'stream_select() returned 0. This can not happen! Please ' .
- 'file a bug report at: ' .
- 'http://pear.php.net/bugs/report.php?package=Crypt_GPG');
- }
-
- // write input (to GPG)
- if (in_array($fdInput, $outputStreams)) {
- $this->_debug('GPG is ready for input');
-
- $chunk = self::_byteSubstring(
- $inputBuffer,
- 0,
- self::CHUNK_SIZE
- );
-
- $length = self::_byteLength($chunk);
-
- $this->_debug(
- '=> about to write ' . $length . ' bytes to GPG input'
- );
-
- $length = fwrite($fdInput, $chunk, $length);
-
- $this->_debug('=> wrote ' . $length . ' bytes');
-
- $inputBuffer = self::_byteSubstring(
- $inputBuffer,
- $length
- );
- }
-
- // read input (from PHP stream)
- if (in_array($this->_input, $inputStreams)) {
- $this->_debug('input stream is ready for reading');
- $this->_debug(
- '=> about to read ' . self::CHUNK_SIZE .
- ' bytes from input stream'
- );
-
- $chunk = fread($this->_input, self::CHUNK_SIZE);
- $length = self::_byteLength($chunk);
- $inputBuffer .= $chunk;
-
- $this->_debug('=> read ' . $length . ' bytes');
- }
-
- // write message (to GPG)
- if (in_array($fdMessage, $outputStreams)) {
- $this->_debug('GPG is ready for message data');
-
- $chunk = self::_byteSubstring(
- $messageBuffer,
- 0,
- self::CHUNK_SIZE
- );
-
- $length = self::_byteLength($chunk);
-
- $this->_debug(
- '=> about to write ' . $length . ' bytes to GPG message'
- );
-
- $length = fwrite($fdMessage, $chunk, $length);
- $this->_debug('=> wrote ' . $length . ' bytes');
-
- $messageBuffer = self::_byteSubstring($messageBuffer, $length);
- }
-
- // read message (from PHP stream)
- if (in_array($this->_message, $inputStreams)) {
- $this->_debug('message stream is ready for reading');
- $this->_debug(
- '=> about to read ' . self::CHUNK_SIZE .
- ' bytes from message stream'
- );
-
- $chunk = fread($this->_message, self::CHUNK_SIZE);
- $length = self::_byteLength($chunk);
- $messageBuffer .= $chunk;
-
- $this->_debug('=> read ' . $length . ' bytes');
- }
-
- // read output (from GPG)
- if (in_array($fdOutput, $inputStreams)) {
- $this->_debug('GPG output stream ready for reading');
- $this->_debug(
- '=> about to read ' . self::CHUNK_SIZE .
- ' bytes from GPG output'
- );
-
- $chunk = fread($fdOutput, self::CHUNK_SIZE);
- $length = self::_byteLength($chunk);
- $outputBuffer .= $chunk;
-
- $this->_debug('=> read ' . $length . ' bytes');
- }
-
- // write output (to PHP stream)
- if (in_array($this->_output, $outputStreams)) {
- $this->_debug('output stream is ready for data');
-
- $chunk = self::_byteSubstring(
- $outputBuffer,
- 0,
- self::CHUNK_SIZE
- );
-
- $length = self::_byteLength($chunk);
-
- $this->_debug(
- '=> about to write ' . $length . ' bytes to output stream'
- );
-
- $length = fwrite($this->_output, $chunk, $length);
-
- $this->_debug('=> wrote ' . $length . ' bytes');
-
- $outputBuffer = self::_byteSubstring($outputBuffer, $length);
- }
-
- // read error (from GPG)
- if (in_array($fdError, $inputStreams)) {
- $this->_debug('GPG error stream ready for reading');
- $this->_debug(
- '=> about to read ' . self::CHUNK_SIZE .
- ' bytes from GPG error'
- );
-
- $chunk = fread($fdError, self::CHUNK_SIZE);
- $length = self::_byteLength($chunk);
- $errorBuffer .= $chunk;
-
- $this->_debug('=> read ' . $length . ' bytes');
-
- // pass lines to error handlers
- while (($pos = strpos($errorBuffer, PHP_EOL)) !== false) {
- $line = self::_byteSubstring($errorBuffer, 0, $pos);
- foreach ($this->_errorHandlers as $handler) {
- array_unshift($handler['args'], $line);
- call_user_func_array(
- $handler['callback'],
- $handler['args']
- );
-
- array_shift($handler['args']);
- }
- $errorBuffer = self::_byteSubString(
- $errorBuffer,
- $pos + self::_byteLength(PHP_EOL)
- );
- }
- }
-
- // read status (from GPG)
- if (in_array($fdStatus, $inputStreams)) {
- $this->_debug('GPG status stream ready for reading');
- $this->_debug(
- '=> about to read ' . self::CHUNK_SIZE .
- ' bytes from GPG status'
- );
-
- $chunk = fread($fdStatus, self::CHUNK_SIZE);
- $length = self::_byteLength($chunk);
- $statusBuffer .= $chunk;
-
- $this->_debug('=> read ' . $length . ' bytes');
-
- // pass lines to status handlers
- while (($pos = strpos($statusBuffer, PHP_EOL)) !== false) {
- $line = self::_byteSubstring($statusBuffer, 0, $pos);
- // only pass lines beginning with magic prefix
- if (self::_byteSubstring($line, 0, 9) == '[GNUPG:] ') {
- $line = self::_byteSubstring($line, 9);
- foreach ($this->_statusHandlers as $handler) {
- array_unshift($handler['args'], $line);
- call_user_func_array(
- $handler['callback'],
- $handler['args']
- );
-
- array_shift($handler['args']);
- }
- }
- $statusBuffer = self::_byteSubString(
- $statusBuffer,
- $pos + self::_byteLength(PHP_EOL)
- );
- }
- }
-
- // write command (to GPG)
- if (in_array($fdCommand, $outputStreams)) {
- $this->_debug('GPG is ready for command data');
-
- // send commands
- $chunk = self::_byteSubstring(
- $this->_commandBuffer,
- 0,
- self::CHUNK_SIZE
- );
-
- $length = self::_byteLength($chunk);
-
- $this->_debug(
- '=> about to write ' . $length . ' bytes to GPG command'
- );
-
- $length = fwrite($fdCommand, $chunk, $length);
-
- $this->_debug('=> wrote ' . $length);
-
- $this->_commandBuffer = self::_byteSubstring(
- $this->_commandBuffer,
- $length
- );
- }
-
- } // end loop while streams are open
-
- $this->_debug('END PROCESSING');
- }
-
- // }}}
- // {{{ _openSubprocess()
-
- /**
- * Opens an internal GPG subprocess for the current operation
- *
- * Opens a GPG subprocess, then connects the subprocess to some pipes. Sets
- * the private class property {@link Crypt_GPG_Engine::$_process} to
- * the new subprocess.
- *
- * @return void
- *
- * @throws Crypt_GPG_OpenSubprocessException if the subprocess could not be
- * opened.
- *
- * @see Crypt_GPG_Engine::setOperation()
- * @see Crypt_GPG_Engine::_closeSubprocess()
- * @see Crypt_GPG_Engine::$_process
- */
- private function _openSubprocess()
- {
- $version = $this->getVersion();
-
- $env = $_ENV;
-
- // Newer versions of GnuPG return localized results. Crypt_GPG only
- // works with English, so set the locale to 'C' for the subprocess.
- $env['LC_ALL'] = 'C';
-
- $commandLine = $this->_binary;
-
- $defaultArguments = array(
- '--status-fd ' . escapeshellarg(self::FD_STATUS),
- '--command-fd ' . escapeshellarg(self::FD_COMMAND),
- '--no-secmem-warning',
- '--no-tty',
- '--no-default-keyring', // ignored if keying files are not specified
- '--no-options' // prevent creation of ~/.gnupg directory
- );
-
- if (version_compare($version, '1.0.7', 'ge')) {
- if (version_compare($version, '2.0.0', 'lt')) {
- $defaultArguments[] = '--no-use-agent';
- }
- $defaultArguments[] = '--no-permission-warning';
- }
-
- if (version_compare($version, '1.4.2', 'ge')) {
- $defaultArguments[] = '--exit-on-status-write-error';
- }
-
- if (version_compare($version, '1.3.2', 'ge')) {
- $defaultArguments[] = '--trust-model always';
- } else {
- $defaultArguments[] = '--always-trust';
- }
-
- $arguments = array_merge($defaultArguments, $this->_arguments);
-
- if ($this->_homedir) {
- $arguments[] = '--homedir ' . escapeshellarg($this->_homedir);
-
- // the random seed file makes subsequent actions faster so only
- // disable it if we have to.
- if (!is_writeable($this->_homedir)) {
- $arguments[] = '--no-random-seed-file';
- }
- }
-
- if ($this->_publicKeyring) {
- $arguments[] = '--keyring ' . escapeshellarg($this->_publicKeyring);
- }
-
- if ($this->_privateKeyring) {
- $arguments[] = '--secret-keyring ' .
- escapeshellarg($this->_privateKeyring);
- }
-
- if ($this->_trustDb) {
- $arguments[] = '--trustdb-name ' . escapeshellarg($this->_trustDb);
- }
-
- $commandLine .= ' ' . implode(' ', $arguments) . ' ' .
- $this->_operation;
-
- // Binary operations will not work on Windows with PHP < 5.2.6. This is
- // in case stream_select() ever works on Windows.
- $rb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'r' : 'rb';
- $wb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'w' : 'wb';
-
- $descriptorSpec = array(
- self::FD_INPUT => array('pipe', $rb), // stdin
- self::FD_OUTPUT => array('pipe', $wb), // stdout
- self::FD_ERROR => array('pipe', $wb), // stderr
- self::FD_STATUS => array('pipe', $wb), // status
- self::FD_COMMAND => array('pipe', $rb), // command
- self::FD_MESSAGE => array('pipe', $rb) // message
- );
-
- $this->_debug('OPENING SUBPROCESS WITH THE FOLLOWING COMMAND:');
- $this->_debug($commandLine);
-
- $this->_process = proc_open(
- $commandLine,
- $descriptorSpec,
- $this->_pipes,
- null,
- $env,
- array('binary_pipes' => true)
- );
-
- if (!is_resource($this->_process)) {
- throw new Crypt_GPG_OpenSubprocessException(
- 'Unable to open GPG subprocess.', 0, $commandLine);
- }
-
- $this->_openPipes = $this->_pipes;
- $this->_errorCode = Crypt_GPG::ERROR_NONE;
- }
-
- // }}}
- // {{{ _closeSubprocess()
-
- /**
- * Closes a the internal GPG subprocess
- *
- * Closes the internal GPG subprocess. Sets the private class property
- * {@link Crypt_GPG_Engine::$_process} to null.
- *
- * @return void
- *
- * @see Crypt_GPG_Engine::_openSubprocess()
- * @see Crypt_GPG_Engine::$_process
- */
- private function _closeSubprocess()
- {
- if (is_resource($this->_process)) {
- $this->_debug('CLOSING SUBPROCESS');
-
- // close remaining open pipes
- foreach (array_keys($this->_openPipes) as $pipeNumber) {
- $this->_closePipe($pipeNumber);
- }
-
- $exitCode = proc_close($this->_process);
-
- if ($exitCode != 0) {
- $this->_debug(
- '=> subprocess returned an unexpected exit code: ' .
- $exitCode
- );
-
- if ($this->_errorCode === Crypt_GPG::ERROR_NONE) {
- if ($this->_needPassphrase > 0) {
- $this->_errorCode = Crypt_GPG::ERROR_MISSING_PASSPHRASE;
- } else {
- $this->_errorCode = Crypt_GPG::ERROR_UNKNOWN;
- }
- }
- }
-
- $this->_process = null;
- $this->_pipes = array();
- }
- }
-
- // }}}
- // {{{ _closePipe()
-
- /**
- * Closes an opened pipe used to communicate with the GPG subprocess
- *
- * If the pipe is already closed, it is ignored. If the pipe is open, it
- * is flushed and then closed.
- *
- * @param integer $pipeNumber the file descriptor number of the pipe to
- * close.
- *
- * @return void
- */
- private function _closePipe($pipeNumber)
- {
- $pipeNumber = intval($pipeNumber);
- if (array_key_exists($pipeNumber, $this->_openPipes)) {
- fflush($this->_openPipes[$pipeNumber]);
- fclose($this->_openPipes[$pipeNumber]);
- unset($this->_openPipes[$pipeNumber]);
- }
- }
-
- // }}}
- // {{{ _getBinary()
-
- /**
- * Gets the name of the GPG binary for the current operating system
- *
- * This method is called if the '<kbd>binary</kbd>' option is <i>not</i>
- * specified when creating this driver.
- *
- * @return string the name of the GPG binary for the current operating
- * system. If no suitable binary could be found, an empty
- * string is returned.
- */
- private function _getBinary()
- {
- $binary = '';
-
- if ($this->_isDarwin) {
- $binaryFiles = array(
- '/opt/local/bin/gpg', // MacPorts
- '/usr/local/bin/gpg', // Mac GPG
- '/sw/bin/gpg', // Fink
- '/usr/bin/gpg'
- );
- } else {
- $binaryFiles = array(
- '/usr/bin/gpg',
- '/usr/local/bin/gpg'
- );
- }
-
- foreach ($binaryFiles as $binaryFile) {
- if (is_executable($binaryFile)) {
- $binary = $binaryFile;
- break;
- }
- }
-
- return $binary;
- }
-
- // }}}
- // {{{ _debug()
-
- /**
- * Displays debug text if debugging is turned on
- *
- * Debugging text is prepended with a debug identifier and echoed to stdout.
- *
- * @param string $text the debugging text to display.
- *
- * @return void
- */
- private function _debug($text)
- {
- if ($this->_debug) {
- if (array_key_exists('SHELL', $_ENV)) {
- foreach (explode(PHP_EOL, $text) as $line) {
- echo "Crypt_GPG DEBUG: ", $line, PHP_EOL;
- }
- } else {
- // running on a web server, format debug output nicely
- foreach (explode(PHP_EOL, $text) as $line) {
- echo "Crypt_GPG DEBUG: <strong>", $line,
- '</strong><br />', PHP_EOL;
- }
- }
- }
- }
-
- // }}}
- // {{{ _byteLength()
-
- /**
- * Gets the length of a string in bytes even if mbstring function
- * overloading is turned on
- *
- * This is used for stream-based communication with the GPG subprocess.
- *
- * @param string $string the string for which to get the length.
- *
- * @return integer the length of the string in bytes.
- *
- * @see Crypt_GPG_Engine::$_mbStringOverload
- */
- private static function _byteLength($string)
- {
- if (self::$_mbStringOverload) {
- return mb_strlen($string, '8bit');
- }
-
- return strlen((binary)$string);
- }
-
- // }}}
- // {{{ _byteSubstring()
-
- /**
- * Gets the substring of a string in bytes even if mbstring function
- * overloading is turned on
- *
- * This is used for stream-based communication with the GPG subprocess.
- *
- * @param string $string the input string.
- * @param integer $start the starting point at which to get the substring.
- * @param integer $length optional. The length of the substring.
- *
- * @return string the extracted part of the string. Unlike the default PHP
- * <kbd>substr()</kbd> function, the returned value is
- * always a string and never false.
- *
- * @see Crypt_GPG_Engine::$_mbStringOverload
- */
- private static function _byteSubstring($string, $start, $length = null)
- {
- if (self::$_mbStringOverload) {
- if ($length === null) {
- return mb_substr(
- $string,
- $start,
- self::_byteLength($string) - $start, '8bit'
- );
- }
-
- return mb_substr($string, $start, $length, '8bit');
- }
-
- if ($length === null) {
- return (string)substr((binary)$string, $start);
- }
-
- return (string)substr((binary)$string, $start, $length);
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/Exceptions.php b/plugins/enigma/lib/Crypt/GPG/Exceptions.php
deleted file mode 100644
index 744acf5d4..000000000
--- a/plugins/enigma/lib/Crypt/GPG/Exceptions.php
+++ /dev/null
@@ -1,473 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Various exception handling classes for Crypt_GPG
- *
- * Crypt_GPG provides an object oriented interface to GNU Privacy
- * Guard (GPG). It requires the GPG executable to be on the system.
- *
- * This file contains various exception classes used by the Crypt_GPG package.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: Exceptions.php 273745 2009-01-18 05:24:25Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- */
-
-/**
- * PEAR Exception handler and base class
- */
-require_once 'PEAR/Exception.php';
-
-// {{{ class Crypt_GPG_Exception
-
-/**
- * An exception thrown by the Crypt_GPG package
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_Exception extends PEAR_Exception
-{
-}
-
-// }}}
-// {{{ class Crypt_GPG_FileException
-
-/**
- * An exception thrown when a file is used in ways it cannot be used
- *
- * For example, if an output file is specified and the file is not writeable, or
- * if an input file is specified and the file is not readable, this exception
- * is thrown.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2007-2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_FileException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * The name of the file that caused this exception
- *
- * @var string
- */
- private $_filename = '';
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_FileException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $filename the name of the file that caused this exception.
- */
- public function __construct($message, $code = 0, $filename = '')
- {
- $this->_filename = $filename;
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getFilename()
-
- /**
- * Returns the filename of the file that caused this exception
- *
- * @return string the filename of the file that caused this exception.
- *
- * @see Crypt_GPG_FileException::$_filename
- */
- public function getFilename()
- {
- return $this->_filename;
- }
-
- // }}}
-}
-
-// }}}
-// {{{ class Crypt_GPG_OpenSubprocessException
-
-/**
- * An exception thrown when the GPG subprocess cannot be opened
- *
- * This exception is thrown when the {@link Crypt_GPG_Engine} tries to open a
- * new subprocess and fails.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_OpenSubprocessException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * The command used to try to open the subprocess
- *
- * @var string
- */
- private $_command = '';
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_OpenSubprocessException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $command the command that was called to open the
- * new subprocess.
- *
- * @see Crypt_GPG::_openSubprocess()
- */
- public function __construct($message, $code = 0, $command = '')
- {
- $this->_command = $command;
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getCommand()
-
- /**
- * Returns the contents of the internal _command property
- *
- * @return string the command used to open the subprocess.
- *
- * @see Crypt_GPG_OpenSubprocessException::$_command
- */
- public function getCommand()
- {
- return $this->_command;
- }
-
- // }}}
-}
-
-// }}}
-// {{{ class Crypt_GPG_InvalidOperationException
-
-/**
- * An exception thrown when an invalid GPG operation is attempted
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_InvalidOperationException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * The attempted operation
- *
- * @var string
- */
- private $_operation = '';
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_OpenSubprocessException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $operation the operation.
- */
- public function __construct($message, $code = 0, $operation = '')
- {
- $this->_operation = $operation;
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getOperation()
-
- /**
- * Returns the contents of the internal _operation property
- *
- * @return string the attempted operation.
- *
- * @see Crypt_GPG_InvalidOperationException::$_operation
- */
- public function getOperation()
- {
- return $this->_operation;
- }
-
- // }}}
-}
-
-// }}}
-// {{{ class Crypt_GPG_KeyNotFoundException
-
-/**
- * An exception thrown when Crypt_GPG fails to find the key for various
- * operations
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_KeyNotFoundException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * The key identifier that was searched for
- *
- * @var string
- */
- private $_keyId = '';
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_KeyNotFoundException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $keyId the key identifier of the key.
- */
- public function __construct($message, $code = 0, $keyId= '')
- {
- $this->_keyId = $keyId;
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getKeyId()
-
- /**
- * Gets the key identifier of the key that was not found
- *
- * @return string the key identifier of the key that was not found.
- */
- public function getKeyId()
- {
- return $this->_keyId;
- }
-
- // }}}
-}
-
-// }}}
-// {{{ class Crypt_GPG_NoDataException
-
-/**
- * An exception thrown when Crypt_GPG cannot find valid data for various
- * operations
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2006 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_NoDataException extends Crypt_GPG_Exception
-{
-}
-
-// }}}
-// {{{ class Crypt_GPG_BadPassphraseException
-
-/**
- * An exception thrown when a required passphrase is incorrect or missing
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2006-2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_BadPassphraseException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * Keys for which the passhprase is missing
- *
- * This contains primary user ids indexed by sub-key id.
- *
- * @var array
- */
- private $_missingPassphrases = array();
-
- /**
- * Keys for which the passhprase is incorrect
- *
- * This contains primary user ids indexed by sub-key id.
- *
- * @var array
- */
- private $_badPassphrases = array();
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_BadPassphraseException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $badPassphrases an array containing user ids of keys
- * for which the passphrase is incorrect.
- * @param string $missingPassphrases an array containing user ids of keys
- * for which the passphrase is missing.
- */
- public function __construct($message, $code = 0,
- array $badPassphrases = array(), array $missingPassphrases = array()
- ) {
- $this->_badPassphrases = $badPassphrases;
- $this->_missingPassphrases = $missingPassphrases;
-
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getBadPassphrases()
-
- /**
- * Gets keys for which the passhprase is incorrect
- *
- * @return array an array of keys for which the passphrase is incorrect.
- * The array contains primary user ids indexed by the sub-key
- * id.
- */
- public function getBadPassphrases()
- {
- return $this->_badPassphrases;
- }
-
- // }}}
- // {{{ getMissingPassphrases()
-
- /**
- * Gets keys for which the passhprase is missing
- *
- * @return array an array of keys for which the passphrase is missing.
- * The array contains primary user ids indexed by the sub-key
- * id.
- */
- public function getMissingPassphrases()
- {
- return $this->_missingPassphrases;
- }
-
- // }}}
-}
-
-// }}}
-// {{{ class Crypt_GPG_DeletePrivateKeyException
-
-/**
- * An exception thrown when an attempt is made to delete public key that has an
- * associated private key on the keyring
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- */
-class Crypt_GPG_DeletePrivateKeyException extends Crypt_GPG_Exception
-{
- // {{{ private class properties
-
- /**
- * The key identifier the deletion attempt was made upon
- *
- * @var string
- */
- private $_keyId = '';
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new Crypt_GPG_DeletePrivateKeyException
- *
- * @param string $message an error message.
- * @param integer $code a user defined error code.
- * @param string $keyId the key identifier of the public key that was
- * attempted to delete.
- *
- * @see Crypt_GPG::deletePublicKey()
- */
- public function __construct($message, $code = 0, $keyId = '')
- {
- $this->_keyId = $keyId;
- parent::__construct($message, $code);
- }
-
- // }}}
- // {{{ getKeyId()
-
- /**
- * Gets the key identifier of the key that was not found
- *
- * @return string the key identifier of the key that was not found.
- */
- public function getKeyId()
- {
- return $this->_keyId;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/Key.php b/plugins/enigma/lib/Crypt/GPG/Key.php
deleted file mode 100644
index 67a4b9c7d..000000000
--- a/plugins/enigma/lib/Crypt/GPG/Key.php
+++ /dev/null
@@ -1,223 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Contains a class representing GPG keys
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: Key.php 295621 2010-03-01 04:18:54Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- */
-
-/**
- * Sub-key class definition
- */
-require_once 'Crypt/GPG/SubKey.php';
-
-/**
- * User id class definition
- */
-require_once 'Crypt/GPG/UserId.php';
-
-// {{{ class Crypt_GPG_Key
-
-/**
- * A data class for GPG key information
- *
- * This class is used to store the results of the {@link Crypt_GPG::getKeys()}
- * method.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @see Crypt_GPG::getKeys()
- */
-class Crypt_GPG_Key
-{
- // {{{ class properties
-
- /**
- * The user ids associated with this key
- *
- * This is an array of {@link Crypt_GPG_UserId} objects.
- *
- * @var array
- *
- * @see Crypt_GPG_Key::addUserId()
- * @see Crypt_GPG_Key::getUserIds()
- */
- private $_userIds = array();
-
- /**
- * The subkeys of this key
- *
- * This is an array of {@link Crypt_GPG_SubKey} objects.
- *
- * @var array
- *
- * @see Crypt_GPG_Key::addSubKey()
- * @see Crypt_GPG_Key::getSubKeys()
- */
- private $_subKeys = array();
-
- // }}}
- // {{{ getSubKeys()
-
- /**
- * Gets the sub-keys of this key
- *
- * @return array the sub-keys of this key.
- *
- * @see Crypt_GPG_Key::addSubKey()
- */
- public function getSubKeys()
- {
- return $this->_subKeys;
- }
-
- // }}}
- // {{{ getUserIds()
-
- /**
- * Gets the user ids of this key
- *
- * @return array the user ids of this key.
- *
- * @see Crypt_GPG_Key::addUserId()
- */
- public function getUserIds()
- {
- return $this->_userIds;
- }
-
- // }}}
- // {{{ getPrimaryKey()
-
- /**
- * Gets the primary sub-key of this key
- *
- * The primary key is the first added sub-key.
- *
- * @return Crypt_GPG_SubKey the primary sub-key of this key.
- */
- public function getPrimaryKey()
- {
- $primary_key = null;
- if (count($this->_subKeys) > 0) {
- $primary_key = $this->_subKeys[0];
- }
- return $primary_key;
- }
-
- // }}}
- // {{{ canSign()
-
- /**
- * Gets whether or not this key can sign data
- *
- * This key can sign data if any sub-key of this key can sign data.
- *
- * @return boolean true if this key can sign data and false if this key
- * cannot sign data.
- */
- public function canSign()
- {
- $canSign = false;
- foreach ($this->_subKeys as $subKey) {
- if ($subKey->canSign()) {
- $canSign = true;
- break;
- }
- }
- return $canSign;
- }
-
- // }}}
- // {{{ canEncrypt()
-
- /**
- * Gets whether or not this key can encrypt data
- *
- * This key can encrypt data if any sub-key of this key can encrypt data.
- *
- * @return boolean true if this key can encrypt data and false if this
- * key cannot encrypt data.
- */
- public function canEncrypt()
- {
- $canEncrypt = false;
- foreach ($this->_subKeys as $subKey) {
- if ($subKey->canEncrypt()) {
- $canEncrypt = true;
- break;
- }
- }
- return $canEncrypt;
- }
-
- // }}}
- // {{{ addSubKey()
-
- /**
- * Adds a sub-key to this key
- *
- * The first added sub-key will be the primary key of this key.
- *
- * @param Crypt_GPG_SubKey $subKey the sub-key to add.
- *
- * @return Crypt_GPG_Key the current object, for fluent interface.
- */
- public function addSubKey(Crypt_GPG_SubKey $subKey)
- {
- $this->_subKeys[] = $subKey;
- return $this;
- }
-
- // }}}
- // {{{ addUserId()
-
- /**
- * Adds a user id to this key
- *
- * @param Crypt_GPG_UserId $userId the user id to add.
- *
- * @return Crypt_GPG_Key the current object, for fluent interface.
- */
- public function addUserId(Crypt_GPG_UserId $userId)
- {
- $this->_userIds[] = $userId;
- return $this;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/Signature.php b/plugins/enigma/lib/Crypt/GPG/Signature.php
deleted file mode 100644
index 03ab44c53..000000000
--- a/plugins/enigma/lib/Crypt/GPG/Signature.php
+++ /dev/null
@@ -1,428 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * A class representing GPG signatures
- *
- * This file contains a data class representing a GPG signature.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: Signature.php 302773 2010-08-25 14:16:28Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- */
-
-/**
- * User id class definition
- */
-require_once 'Crypt/GPG/UserId.php';
-
-// {{{ class Crypt_GPG_Signature
-
-/**
- * A class for GPG signature information
- *
- * This class is used to store the results of the Crypt_GPG::verify() method.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @see Crypt_GPG::verify()
- */
-class Crypt_GPG_Signature
-{
- // {{{ class properties
-
- /**
- * A base64-encoded string containing a unique id for this signature if
- * this signature has been verified as ok
- *
- * This id is used to prevent replay attacks and is not present for all
- * types of signatures.
- *
- * @var string
- */
- private $_id = '';
-
- /**
- * The fingerprint of the key used to create the signature
- *
- * @var string
- */
- private $_keyFingerprint = '';
-
- /**
- * The id of the key used to create the signature
- *
- * @var string
- */
- private $_keyId = '';
-
- /**
- * The creation date of this signature
- *
- * This is a Unix timestamp.
- *
- * @var integer
- */
- private $_creationDate = 0;
-
- /**
- * The expiration date of the signature
- *
- * This is a Unix timestamp. If this signature does not expire, this will
- * be zero.
- *
- * @var integer
- */
- private $_expirationDate = 0;
-
- /**
- * The user id associated with this signature
- *
- * @var Crypt_GPG_UserId
- */
- private $_userId = null;
-
- /**
- * Whether or not this signature is valid
- *
- * @var boolean
- */
- private $_isValid = false;
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new signature
- *
- * Signatures can be initialized from an array of named values. Available
- * names are:
- *
- * - <kbd>string id</kbd> - the unique id of this signature.
- * - <kbd>string fingerprint</kbd> - the fingerprint of the key used to
- * create the signature. The fingerprint
- * should not contain formatting
- * characters.
- * - <kbd>string keyId</kbd> - the id of the key used to create the
- * the signature.
- * - <kbd>integer creation</kbd> - the date the signature was created.
- * This is a UNIX timestamp.
- * - <kbd>integer expiration</kbd> - the date the signature expired. This
- * is a UNIX timestamp. If the signature
- * does not expire, use 0.
- * - <kbd>boolean valid</kbd> - whether or not the signature is valid.
- * - <kbd>string userId</kbd> - the user id associated with the
- * signature. This may also be a
- * {@link Crypt_GPG_UserId} object.
- *
- * @param Crypt_GPG_Signature|array $signature optional. Either an existing
- * signature object, which is copied; or an array of initial values.
- */
- public function __construct($signature = null)
- {
- // copy from object
- if ($signature instanceof Crypt_GPG_Signature) {
- $this->_id = $signature->_id;
- $this->_keyFingerprint = $signature->_keyFingerprint;
- $this->_keyId = $signature->_keyId;
- $this->_creationDate = $signature->_creationDate;
- $this->_expirationDate = $signature->_expirationDate;
- $this->_isValid = $signature->_isValid;
-
- if ($signature->_userId instanceof Crypt_GPG_UserId) {
- $this->_userId = clone $signature->_userId;
- } else {
- $this->_userId = $signature->_userId;
- }
- }
-
- // initialize from array
- if (is_array($signature)) {
- if (array_key_exists('id', $signature)) {
- $this->setId($signature['id']);
- }
-
- if (array_key_exists('fingerprint', $signature)) {
- $this->setKeyFingerprint($signature['fingerprint']);
- }
-
- if (array_key_exists('keyId', $signature)) {
- $this->setKeyId($signature['keyId']);
- }
-
- if (array_key_exists('creation', $signature)) {
- $this->setCreationDate($signature['creation']);
- }
-
- if (array_key_exists('expiration', $signature)) {
- $this->setExpirationDate($signature['expiration']);
- }
-
- if (array_key_exists('valid', $signature)) {
- $this->setValid($signature['valid']);
- }
-
- if (array_key_exists('userId', $signature)) {
- $userId = new Crypt_GPG_UserId($signature['userId']);
- $this->setUserId($userId);
- }
- }
- }
-
- // }}}
- // {{{ getId()
-
- /**
- * Gets the id of this signature
- *
- * @return string a base64-encoded string containing a unique id for this
- * signature. This id is used to prevent replay attacks and
- * is not present for all types of signatures.
- */
- public function getId()
- {
- return $this->_id;
- }
-
- // }}}
- // {{{ getKeyFingerprint()
-
- /**
- * Gets the fingerprint of the key used to create this signature
- *
- * @return string the fingerprint of the key used to create this signature.
- */
- public function getKeyFingerprint()
- {
- return $this->_keyFingerprint;
- }
-
- // }}}
- // {{{ getKeyId()
-
- /**
- * Gets the id of the key used to create this signature
- *
- * Whereas the fingerprint of the signing key may not always be available
- * (for example if the signature is bad), the id should always be
- * available.
- *
- * @return string the id of the key used to create this signature.
- */
- public function getKeyId()
- {
- return $this->_keyId;
- }
-
- // }}}
- // {{{ getCreationDate()
-
- /**
- * Gets the creation date of this signature
- *
- * @return integer the creation date of this signature. This is a Unix
- * timestamp.
- */
- public function getCreationDate()
- {
- return $this->_creationDate;
- }
-
- // }}}
- // {{{ getExpirationDate()
-
- /**
- * Gets the expiration date of the signature
- *
- * @return integer the expiration date of this signature. This is a Unix
- * timestamp. If this signature does not expire, this will
- * be zero.
- */
- public function getExpirationDate()
- {
- return $this->_expirationDate;
- }
-
- // }}}
- // {{{ getUserId()
-
- /**
- * Gets the user id associated with this signature
- *
- * @return Crypt_GPG_UserId the user id associated with this signature.
- */
- public function getUserId()
- {
- return $this->_userId;
- }
-
- // }}}
- // {{{ isValid()
-
- /**
- * Gets whether or no this signature is valid
- *
- * @return boolean true if this signature is valid and false if it is not.
- */
- public function isValid()
- {
- return $this->_isValid;
- }
-
- // }}}
- // {{{ setId()
-
- /**
- * Sets the id of this signature
- *
- * @param string $id a base64-encoded string containing a unique id for
- * this signature.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- *
- * @see Crypt_GPG_Signature::getId()
- */
- public function setId($id)
- {
- $this->_id = strval($id);
- return $this;
- }
-
- // }}}
- // {{{ setKeyFingerprint()
-
- /**
- * Sets the key fingerprint of this signature
- *
- * @param string $fingerprint the key fingerprint of this signature. This
- * is the fingerprint of the primary key used to
- * create this signature.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setKeyFingerprint($fingerprint)
- {
- $this->_keyFingerprint = strval($fingerprint);
- return $this;
- }
-
- // }}}
- // {{{ setKeyId()
-
- /**
- * Sets the key id of this signature
- *
- * @param string $id the key id of this signature. This is the id of the
- * primary key used to create this signature.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setKeyId($id)
- {
- $this->_keyId = strval($id);
- return $this;
- }
-
- // }}}
- // {{{ setCreationDate()
-
- /**
- * Sets the creation date of this signature
- *
- * @param integer $creationDate the creation date of this signature. This
- * is a Unix timestamp.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setCreationDate($creationDate)
- {
- $this->_creationDate = intval($creationDate);
- return $this;
- }
-
- // }}}
- // {{{ setExpirationDate()
-
- /**
- * Sets the expiration date of this signature
- *
- * @param integer $expirationDate the expiration date of this signature.
- * This is a Unix timestamp. Specify zero if
- * this signature does not expire.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setExpirationDate($expirationDate)
- {
- $this->_expirationDate = intval($expirationDate);
- return $this;
- }
-
- // }}}
- // {{{ setUserId()
-
- /**
- * Sets the user id associated with this signature
- *
- * @param Crypt_GPG_UserId $userId the user id associated with this
- * signature.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setUserId(Crypt_GPG_UserId $userId)
- {
- $this->_userId = $userId;
- return $this;
- }
-
- // }}}
- // {{{ setValid()
-
- /**
- * Sets whether or not this signature is valid
- *
- * @param boolean $isValid true if this signature is valid and false if it
- * is not.
- *
- * @return Crypt_GPG_Signature the current object, for fluent interface.
- */
- public function setValid($isValid)
- {
- $this->_isValid = ($isValid) ? true : false;
- return $this;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/SubKey.php b/plugins/enigma/lib/Crypt/GPG/SubKey.php
deleted file mode 100644
index b6316e99f..000000000
--- a/plugins/enigma/lib/Crypt/GPG/SubKey.php
+++ /dev/null
@@ -1,649 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Contains a class representing GPG sub-keys and constants for GPG algorithms
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: SubKey.php 302768 2010-08-25 13:45:52Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- */
-
-// {{{ class Crypt_GPG_SubKey
-
-/**
- * A class for GPG sub-key information
- *
- * This class is used to store the results of the {@link Crypt_GPG::getKeys()}
- * method. Sub-key objects are members of a {@link Crypt_GPG_Key} object.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @author Nathan Fredrickson <nathan@silverorange.com>
- * @copyright 2005-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @see Crypt_GPG::getKeys()
- * @see Crypt_GPG_Key::getSubKeys()
- */
-class Crypt_GPG_SubKey
-{
- // {{{ class constants
-
- /**
- * RSA encryption algorithm.
- */
- const ALGORITHM_RSA = 1;
-
- /**
- * Elgamal encryption algorithm (encryption only).
- */
- const ALGORITHM_ELGAMAL_ENC = 16;
-
- /**
- * DSA encryption algorithm (sometimes called DH, sign only).
- */
- const ALGORITHM_DSA = 17;
-
- /**
- * Elgamal encryption algorithm (signage and encryption - should not be
- * used).
- */
- const ALGORITHM_ELGAMAL_ENC_SGN = 20;
-
- // }}}
- // {{{ class properties
-
- /**
- * The id of this sub-key
- *
- * @var string
- */
- private $_id = '';
-
- /**
- * The algorithm used to create this sub-key
- *
- * The value is one of the Crypt_GPG_SubKey::ALGORITHM_* constants.
- *
- * @var integer
- */
- private $_algorithm = 0;
-
- /**
- * The fingerprint of this sub-key
- *
- * @var string
- */
- private $_fingerprint = '';
-
- /**
- * Length of this sub-key in bits
- *
- * @var integer
- */
- private $_length = 0;
-
- /**
- * Date this sub-key was created
- *
- * This is a Unix timestamp.
- *
- * @var integer
- */
- private $_creationDate = 0;
-
- /**
- * Date this sub-key expires
- *
- * This is a Unix timestamp. If this sub-key does not expire, this will be
- * zero.
- *
- * @var integer
- */
- private $_expirationDate = 0;
-
- /**
- * Whether or not this sub-key can sign data
- *
- * @var boolean
- */
- private $_canSign = false;
-
- /**
- * Whether or not this sub-key can encrypt data
- *
- * @var boolean
- */
- private $_canEncrypt = false;
-
- /**
- * Whether or not the private key for this sub-key exists in the keyring
- *
- * @var boolean
- */
- private $_hasPrivate = false;
-
- /**
- * Whether or not this sub-key is revoked
- *
- * @var boolean
- */
- private $_isRevoked = false;
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new sub-key object
- *
- * Sub-keys can be initialized from an array of named values. Available
- * names are:
- *
- * - <kbd>string id</kbd> - the key id of the sub-key.
- * - <kbd>integer algorithm</kbd> - the encryption algorithm of the
- * sub-key.
- * - <kbd>string fingerprint</kbd> - the fingerprint of the sub-key. The
- * fingerprint should not contain
- * formatting characters.
- * - <kbd>integer length</kbd> - the length of the sub-key in bits.
- * - <kbd>integer creation</kbd> - the date the sub-key was created.
- * This is a UNIX timestamp.
- * - <kbd>integer expiration</kbd> - the date the sub-key expires. This
- * is a UNIX timestamp. If the sub-key
- * does not expire, use 0.
- * - <kbd>boolean canSign</kbd> - whether or not the sub-key can be
- * used to sign data.
- * - <kbd>boolean canEncrypt</kbd> - whether or not the sub-key can be
- * used to encrypt data.
- * - <kbd>boolean hasPrivate</kbd> - whether or not the private key for
- * the sub-key exists in the keyring.
- * - <kbd>boolean isRevoked</kbd> - whether or not this sub-key is
- * revoked.
- *
- * @param Crypt_GPG_SubKey|string|array $key optional. Either an existing
- * sub-key object, which is copied; a sub-key string, which is
- * parsed; or an array of initial values.
- */
- public function __construct($key = null)
- {
- // parse from string
- if (is_string($key)) {
- $key = self::parse($key);
- }
-
- // copy from object
- if ($key instanceof Crypt_GPG_SubKey) {
- $this->_id = $key->_id;
- $this->_algorithm = $key->_algorithm;
- $this->_fingerprint = $key->_fingerprint;
- $this->_length = $key->_length;
- $this->_creationDate = $key->_creationDate;
- $this->_expirationDate = $key->_expirationDate;
- $this->_canSign = $key->_canSign;
- $this->_canEncrypt = $key->_canEncrypt;
- $this->_hasPrivate = $key->_hasPrivate;
- $this->_isRevoked = $key->_isRevoked;
- }
-
- // initialize from array
- if (is_array($key)) {
- if (array_key_exists('id', $key)) {
- $this->setId($key['id']);
- }
-
- if (array_key_exists('algorithm', $key)) {
- $this->setAlgorithm($key['algorithm']);
- }
-
- if (array_key_exists('fingerprint', $key)) {
- $this->setFingerprint($key['fingerprint']);
- }
-
- if (array_key_exists('length', $key)) {
- $this->setLength($key['length']);
- }
-
- if (array_key_exists('creation', $key)) {
- $this->setCreationDate($key['creation']);
- }
-
- if (array_key_exists('expiration', $key)) {
- $this->setExpirationDate($key['expiration']);
- }
-
- if (array_key_exists('canSign', $key)) {
- $this->setCanSign($key['canSign']);
- }
-
- if (array_key_exists('canEncrypt', $key)) {
- $this->setCanEncrypt($key['canEncrypt']);
- }
-
- if (array_key_exists('hasPrivate', $key)) {
- $this->setHasPrivate($key['hasPrivate']);
- }
-
- if (array_key_exists('isRevoked', $key)) {
- $this->setRevoked($key['isRevoked']);
- }
- }
- }
-
- // }}}
- // {{{ getId()
-
- /**
- * Gets the id of this sub-key
- *
- * @return string the id of this sub-key.
- */
- public function getId()
- {
- return $this->_id;
- }
-
- // }}}
- // {{{ getAlgorithm()
-
- /**
- * Gets the algorithm used by this sub-key
- *
- * The algorithm should be one of the Crypt_GPG_SubKey::ALGORITHM_*
- * constants.
- *
- * @return integer the algorithm used by this sub-key.
- */
- public function getAlgorithm()
- {
- return $this->_algorithm;
- }
-
- // }}}
- // {{{ getCreationDate()
-
- /**
- * Gets the creation date of this sub-key
- *
- * This is a Unix timestamp.
- *
- * @return integer the creation date of this sub-key.
- */
- public function getCreationDate()
- {
- return $this->_creationDate;
- }
-
- // }}}
- // {{{ getExpirationDate()
-
- /**
- * Gets the date this sub-key expires
- *
- * This is a Unix timestamp. If this sub-key does not expire, this will be
- * zero.
- *
- * @return integer the date this sub-key expires.
- */
- public function getExpirationDate()
- {
- return $this->_expirationDate;
- }
-
- // }}}
- // {{{ getFingerprint()
-
- /**
- * Gets the fingerprint of this sub-key
- *
- * @return string the fingerprint of this sub-key.
- */
- public function getFingerprint()
- {
- return $this->_fingerprint;
- }
-
- // }}}
- // {{{ getLength()
-
- /**
- * Gets the length of this sub-key in bits
- *
- * @return integer the length of this sub-key in bits.
- */
- public function getLength()
- {
- return $this->_length;
- }
-
- // }}}
- // {{{ canSign()
-
- /**
- * Gets whether or not this sub-key can sign data
- *
- * @return boolean true if this sub-key can sign data and false if this
- * sub-key can not sign data.
- */
- public function canSign()
- {
- return $this->_canSign;
- }
-
- // }}}
- // {{{ canEncrypt()
-
- /**
- * Gets whether or not this sub-key can encrypt data
- *
- * @return boolean true if this sub-key can encrypt data and false if this
- * sub-key can not encrypt data.
- */
- public function canEncrypt()
- {
- return $this->_canEncrypt;
- }
-
- // }}}
- // {{{ hasPrivate()
-
- /**
- * Gets whether or not the private key for this sub-key exists in the
- * keyring
- *
- * @return boolean true the private key for this sub-key exists in the
- * keyring and false if it does not.
- */
- public function hasPrivate()
- {
- return $this->_hasPrivate;
- }
-
- // }}}
- // {{{ isRevoked()
-
- /**
- * Gets whether or not this sub-key is revoked
- *
- * @return boolean true if this sub-key is revoked and false if it is not.
- */
- public function isRevoked()
- {
- return $this->_isRevoked;
- }
-
- // }}}
- // {{{ setCreationDate()
-
- /**
- * Sets the creation date of this sub-key
- *
- * The creation date is a Unix timestamp.
- *
- * @param integer $creationDate the creation date of this sub-key.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setCreationDate($creationDate)
- {
- $this->_creationDate = intval($creationDate);
- return $this;
- }
-
- // }}}
- // {{{ setExpirationDate()
-
- /**
- * Sets the expiration date of this sub-key
- *
- * The expiration date is a Unix timestamp. Specify zero if this sub-key
- * does not expire.
- *
- * @param integer $expirationDate the expiration date of this sub-key.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setExpirationDate($expirationDate)
- {
- $this->_expirationDate = intval($expirationDate);
- return $this;
- }
-
- // }}}
- // {{{ setId()
-
- /**
- * Sets the id of this sub-key
- *
- * @param string $id the id of this sub-key.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setId($id)
- {
- $this->_id = strval($id);
- return $this;
- }
-
- // }}}
- // {{{ setAlgorithm()
-
- /**
- * Sets the algorithm used by this sub-key
- *
- * @param integer $algorithm the algorithm used by this sub-key.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setAlgorithm($algorithm)
- {
- $this->_algorithm = intval($algorithm);
- return $this;
- }
-
- // }}}
- // {{{ setFingerprint()
-
- /**
- * Sets the fingerprint of this sub-key
- *
- * @param string $fingerprint the fingerprint of this sub-key.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setFingerprint($fingerprint)
- {
- $this->_fingerprint = strval($fingerprint);
- return $this;
- }
-
- // }}}
- // {{{ setLength()
-
- /**
- * Sets the length of this sub-key in bits
- *
- * @param integer $length the length of this sub-key in bits.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setLength($length)
- {
- $this->_length = intval($length);
- return $this;
- }
-
- // }}}
- // {{{ setCanSign()
-
- /**
- * Sets whether of not this sub-key can sign data
- *
- * @param boolean $canSign true if this sub-key can sign data and false if
- * it can not.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setCanSign($canSign)
- {
- $this->_canSign = ($canSign) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ setCanEncrypt()
-
- /**
- * Sets whether of not this sub-key can encrypt data
- *
- * @param boolean $canEncrypt true if this sub-key can encrypt data and
- * false if it can not.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setCanEncrypt($canEncrypt)
- {
- $this->_canEncrypt = ($canEncrypt) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ setHasPrivate()
-
- /**
- * Sets whether of not the private key for this sub-key exists in the
- * keyring
- *
- * @param boolean $hasPrivate true if the private key for this sub-key
- * exists in the keyring and false if it does
- * not.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setHasPrivate($hasPrivate)
- {
- $this->_hasPrivate = ($hasPrivate) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ setRevoked()
-
- /**
- * Sets whether or not this sub-key is revoked
- *
- * @param boolean $isRevoked whether or not this sub-key is revoked.
- *
- * @return Crypt_GPG_SubKey the current object, for fluent interface.
- */
- public function setRevoked($isRevoked)
- {
- $this->_isRevoked = ($isRevoked) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ parse()
-
- /**
- * Parses a sub-key object from a sub-key string
- *
- * See <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG distribution} for information
- * on how the sub-key string is parsed.
- *
- * @param string $string the string containing the sub-key.
- *
- * @return Crypt_GPG_SubKey the sub-key object parsed from the string.
- */
- public static function parse($string)
- {
- $tokens = explode(':', $string);
-
- $subKey = new Crypt_GPG_SubKey();
-
- $subKey->setId($tokens[4]);
- $subKey->setLength($tokens[2]);
- $subKey->setAlgorithm($tokens[3]);
- $subKey->setCreationDate(self::_parseDate($tokens[5]));
- $subKey->setExpirationDate(self::_parseDate($tokens[6]));
-
- if ($tokens[1] == 'r') {
- $subKey->setRevoked(true);
- }
-
- if (strpos($tokens[11], 's') !== false) {
- $subKey->setCanSign(true);
- }
-
- if (strpos($tokens[11], 'e') !== false) {
- $subKey->setCanEncrypt(true);
- }
-
- return $subKey;
- }
-
- // }}}
- // {{{ _parseDate()
-
- /**
- * Parses a date string as provided by GPG into a UNIX timestamp
- *
- * @param string $string the date string.
- *
- * @return integer the UNIX timestamp corresponding to the provided date
- * string.
- */
- private static function _parseDate($string)
- {
- if ($string == '') {
- $timestamp = 0;
- } else {
- // all times are in UTC according to GPG documentation
- $timeZone = new DateTimeZone('UTC');
-
- if (strpos($string, 'T') === false) {
- // interpret as UNIX timestamp
- $string = '@' . $string;
- }
-
- $date = new DateTime($string, $timeZone);
-
- // convert to UNIX timestamp
- $timestamp = intval($date->format('U'));
- }
-
- return $timestamp;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/UserId.php b/plugins/enigma/lib/Crypt/GPG/UserId.php
deleted file mode 100644
index 04435708c..000000000
--- a/plugins/enigma/lib/Crypt/GPG/UserId.php
+++ /dev/null
@@ -1,373 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Contains a data class representing a GPG user id
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: UserId.php 295621 2010-03-01 04:18:54Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- */
-
-// {{{ class Crypt_GPG_UserId
-
-/**
- * A class for GPG user id information
- *
- * This class is used to store the results of the {@link Crypt_GPG::getKeys()}
- * method. User id objects are members of a {@link Crypt_GPG_Key} object.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2010 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @see Crypt_GPG::getKeys()
- * @see Crypt_GPG_Key::getUserIds()
- */
-class Crypt_GPG_UserId
-{
- // {{{ class properties
-
- /**
- * The name field of this user id
- *
- * @var string
- */
- private $_name = '';
-
- /**
- * The comment field of this user id
- *
- * @var string
- */
- private $_comment = '';
-
- /**
- * The email field of this user id
- *
- * @var string
- */
- private $_email = '';
-
- /**
- * Whether or not this user id is revoked
- *
- * @var boolean
- */
- private $_isRevoked = false;
-
- /**
- * Whether or not this user id is valid
- *
- * @var boolean
- */
- private $_isValid = true;
-
- // }}}
- // {{{ __construct()
-
- /**
- * Creates a new user id
- *
- * User ids can be initialized from an array of named values. Available
- * names are:
- *
- * - <kbd>string name</kbd> - the name field of the user id.
- * - <kbd>string comment</kbd> - the comment field of the user id.
- * - <kbd>string email</kbd> - the email field of the user id.
- * - <kbd>boolean valid</kbd> - whether or not the user id is valid.
- * - <kbd>boolean revoked</kbd> - whether or not the user id is revoked.
- *
- * @param Crypt_GPG_UserId|string|array $userId optional. Either an
- * existing user id object, which is copied; a user id string, which
- * is parsed; or an array of initial values.
- */
- public function __construct($userId = null)
- {
- // parse from string
- if (is_string($userId)) {
- $userId = self::parse($userId);
- }
-
- // copy from object
- if ($userId instanceof Crypt_GPG_UserId) {
- $this->_name = $userId->_name;
- $this->_comment = $userId->_comment;
- $this->_email = $userId->_email;
- $this->_isRevoked = $userId->_isRevoked;
- $this->_isValid = $userId->_isValid;
- }
-
- // initialize from array
- if (is_array($userId)) {
- if (array_key_exists('name', $userId)) {
- $this->setName($userId['name']);
- }
-
- if (array_key_exists('comment', $userId)) {
- $this->setComment($userId['comment']);
- }
-
- if (array_key_exists('email', $userId)) {
- $this->setEmail($userId['email']);
- }
-
- if (array_key_exists('revoked', $userId)) {
- $this->setRevoked($userId['revoked']);
- }
-
- if (array_key_exists('valid', $userId)) {
- $this->setValid($userId['valid']);
- }
- }
- }
-
- // }}}
- // {{{ getName()
-
- /**
- * Gets the name field of this user id
- *
- * @return string the name field of this user id.
- */
- public function getName()
- {
- return $this->_name;
- }
-
- // }}}
- // {{{ getComment()
-
- /**
- * Gets the comments field of this user id
- *
- * @return string the comments field of this user id.
- */
- public function getComment()
- {
- return $this->_comment;
- }
-
- // }}}
- // {{{ getEmail()
-
- /**
- * Gets the email field of this user id
- *
- * @return string the email field of this user id.
- */
- public function getEmail()
- {
- return $this->_email;
- }
-
- // }}}
- // {{{ isRevoked()
-
- /**
- * Gets whether or not this user id is revoked
- *
- * @return boolean true if this user id is revoked and false if it is not.
- */
- public function isRevoked()
- {
- return $this->_isRevoked;
- }
-
- // }}}
- // {{{ isValid()
-
- /**
- * Gets whether or not this user id is valid
- *
- * @return boolean true if this user id is valid and false if it is not.
- */
- public function isValid()
- {
- return $this->_isValid;
- }
-
- // }}}
- // {{{ __toString()
-
- /**
- * Gets a string representation of this user id
- *
- * The string is formatted as:
- * <b><kbd>name (comment) <email-address></kbd></b>.
- *
- * @return string a string representation of this user id.
- */
- public function __toString()
- {
- $components = array();
-
- if (strlen($this->_name) > 0) {
- $components[] = $this->_name;
- }
-
- if (strlen($this->_comment) > 0) {
- $components[] = '(' . $this->_comment . ')';
- }
-
- if (strlen($this->_email) > 0) {
- $components[] = '<' . $this->_email. '>';
- }
-
- return implode(' ', $components);
- }
-
- // }}}
- // {{{ setName()
-
- /**
- * Sets the name field of this user id
- *
- * @param string $name the name field of this user id.
- *
- * @return Crypt_GPG_UserId the current object, for fluent interface.
- */
- public function setName($name)
- {
- $this->_name = strval($name);
- return $this;
- }
-
- // }}}
- // {{{ setComment()
-
- /**
- * Sets the comment field of this user id
- *
- * @param string $comment the comment field of this user id.
- *
- * @return Crypt_GPG_UserId the current object, for fluent interface.
- */
- public function setComment($comment)
- {
- $this->_comment = strval($comment);
- return $this;
- }
-
- // }}}
- // {{{ setEmail()
-
- /**
- * Sets the email field of this user id
- *
- * @param string $email the email field of this user id.
- *
- * @return Crypt_GPG_UserId the current object, for fluent interface.
- */
- public function setEmail($email)
- {
- $this->_email = strval($email);
- return $this;
- }
-
- // }}}
- // {{{ setRevoked()
-
- /**
- * Sets whether or not this user id is revoked
- *
- * @param boolean $isRevoked whether or not this user id is revoked.
- *
- * @return Crypt_GPG_UserId the current object, for fluent interface.
- */
- public function setRevoked($isRevoked)
- {
- $this->_isRevoked = ($isRevoked) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ setValid()
-
- /**
- * Sets whether or not this user id is valid
- *
- * @param boolean $isValid whether or not this user id is valid.
- *
- * @return Crypt_GPG_UserId the current object, for fluent interface.
- */
- public function setValid($isValid)
- {
- $this->_isValid = ($isValid) ? true : false;
- return $this;
- }
-
- // }}}
- // {{{ parse()
-
- /**
- * Parses a user id object from a user id string
- *
- * A user id string is of the form:
- * <b><kbd>name (comment) <email-address></kbd></b> with the <i>comment</i>
- * and <i>email-address</i> fields being optional.
- *
- * @param string $string the user id string to parse.
- *
- * @return Crypt_GPG_UserId the user id object parsed from the string.
- */
- public static function parse($string)
- {
- $userId = new Crypt_GPG_UserId();
- $email = '';
- $comment = '';
-
- // get email address from end of string if it exists
- $matches = array();
- if (preg_match('/^(.+?) <([^>]+)>$/', $string, $matches) === 1) {
- $string = $matches[1];
- $email = $matches[2];
- }
-
- // get comment from end of string if it exists
- $matches = array();
- if (preg_match('/^(.+?) \(([^\)]+)\)$/', $string, $matches) === 1) {
- $string = $matches[1];
- $comment = $matches[2];
- }
-
- $name = $string;
-
- $userId->setName($name);
- $userId->setComment($comment);
- $userId->setEmail($email);
-
- return $userId;
- }
-
- // }}}
-}
-
-// }}}
-
-?>
diff --git a/plugins/enigma/lib/Crypt/GPG/VerifyStatusHandler.php b/plugins/enigma/lib/Crypt/GPG/VerifyStatusHandler.php
deleted file mode 100644
index 083bd3012..000000000
--- a/plugins/enigma/lib/Crypt/GPG/VerifyStatusHandler.php
+++ /dev/null
@@ -1,216 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Crypt_GPG is a package to use GPG from PHP
- *
- * This file contains an object that handles GPG's status output for the verify
- * operation.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: VerifyStatusHandler.php 302908 2010-08-31 03:56:54Z gauthierm $
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-
-/**
- * Signature object class definition
- */
-require_once 'Crypt/GPG/Signature.php';
-
-/**
- * Status line handler for the verify operation
- *
- * This class is used internally by Crypt_GPG and does not need be used
- * directly. See the {@link Crypt_GPG} class for end-user API.
- *
- * This class is responsible for building signature objects that are returned
- * by the {@link Crypt_GPG::verify()} method. See <b>doc/DETAILS</b> in the
- * {@link http://www.gnupg.org/download/ GPG distribution} for detailed
- * information on GPG's status output for the verify operation.
- *
- * @category Encryption
- * @package Crypt_GPG
- * @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008 silverorange
- * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @link http://pear.php.net/package/Crypt_GPG
- * @link http://www.gnupg.org/
- */
-class Crypt_GPG_VerifyStatusHandler
-{
- // {{{ protected properties
-
- /**
- * The current signature id
- *
- * Ths signature id is emitted by GPG before the new signature line so we
- * must remember it temporarily.
- *
- * @var string
- */
- protected $signatureId = '';
-
- /**
- * List of parsed {@link Crypt_GPG_Signature} objects
- *
- * @var array
- */
- protected $signatures = array();
-
- /**
- * Array index of the current signature
- *
- * @var integer
- */
- protected $index = -1;
-
- // }}}
- // {{{ handle()
-
- /**
- * Handles a status line
- *
- * @param string $line the status line to handle.
- *
- * @return void
- */
- public function handle($line)
- {
- $tokens = explode(' ', $line);
- switch ($tokens[0]) {
- case 'GOODSIG':
- case 'EXPSIG':
- case 'EXPKEYSIG':
- case 'REVKEYSIG':
- case 'BADSIG':
- $signature = new Crypt_GPG_Signature();
-
- // if there was a signature id, set it on the new signature
- if ($this->signatureId != '') {
- $signature->setId($this->signatureId);
- $this->signatureId = '';
- }
-
- // Detect whether fingerprint or key id was returned and set
- // signature values appropriately. Key ids are strings of either
- // 16 or 8 hexadecimal characters. Fingerprints are strings of 40
- // hexadecimal characters. The key id is the last 16 characters of
- // the key fingerprint.
- if (strlen($tokens[1]) > 16) {
- $signature->setKeyFingerprint($tokens[1]);
- $signature->setKeyId(substr($tokens[1], -16));
- } else {
- $signature->setKeyId($tokens[1]);
- }
-
- // get user id string
- $string = implode(' ', array_splice($tokens, 2));
- $string = rawurldecode($string);
-
- $signature->setUserId(Crypt_GPG_UserId::parse($string));
-
- $this->index++;
- $this->signatures[$this->index] = $signature;
- break;
-
- case 'ERRSIG':
- $signature = new Crypt_GPG_Signature();
-
- // if there was a signature id, set it on the new signature
- if ($this->signatureId != '') {
- $signature->setId($this->signatureId);
- $this->signatureId = '';
- }
-
- // Detect whether fingerprint or key id was returned and set
- // signature values appropriately. Key ids are strings of either
- // 16 or 8 hexadecimal characters. Fingerprints are strings of 40
- // hexadecimal characters. The key id is the last 16 characters of
- // the key fingerprint.
- if (strlen($tokens[1]) > 16) {
- $signature->setKeyFingerprint($tokens[1]);
- $signature->setKeyId(substr($tokens[1], -16));
- } else {
- $signature->setKeyId($tokens[1]);
- }
-
- $this->index++;
- $this->signatures[$this->index] = $signature;
-
- break;
-
- case 'VALIDSIG':
- if (!array_key_exists($this->index, $this->signatures)) {
- break;
- }
-
- $signature = $this->signatures[$this->index];
-
- $signature->setValid(true);
- $signature->setKeyFingerprint($tokens[1]);
-
- if (strpos($tokens[3], 'T') === false) {
- $signature->setCreationDate($tokens[3]);
- } else {
- $signature->setCreationDate(strtotime($tokens[3]));
- }
-
- if (array_key_exists(4, $tokens)) {
- if (strpos($tokens[4], 'T') === false) {
- $signature->setExpirationDate($tokens[4]);
- } else {
- $signature->setExpirationDate(strtotime($tokens[4]));
- }
- }
-
- break;
-
- case 'SIG_ID':
- // note: signature id comes before new signature line and may not
- // exist for some signature types
- $this->signatureId = $tokens[1];
- break;
- }
- }
-
- // }}}
- // {{{ getSignatures()
-
- /**
- * Gets the {@link Crypt_GPG_Signature} objects parsed by this handler
- *
- * @return array the signature objects parsed by this handler.
- */
- public function getSignatures()
- {
- return $this->signatures;
- }
-
- // }}}
-}
-
-?>
diff --git a/plugins/enigma/lib/enigma_driver.php b/plugins/enigma/lib/enigma_driver.php
deleted file mode 100644
index a9a3e4715..000000000
--- a/plugins/enigma/lib/enigma_driver.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Abstract driver for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-abstract class enigma_driver
-{
- /**
- * Class constructor.
- *
- * @param string User name (email address)
- */
- abstract function __construct($user);
-
- /**
- * Driver initialization.
- *
- * @return mixed NULL on success, enigma_error on failure
- */
- abstract function init();
-
- /**
- * Encryption.
- */
- abstract function encrypt($text, $keys);
-
- /**
- * Decryption..
- */
- abstract function decrypt($text, $key, $passwd);
-
- /**
- * Signing.
- */
- abstract function sign($text, $key, $passwd);
-
- /**
- * Signature verification.
- *
- * @param string Message body
- * @param string Signature, if message is of type PGP/MIME and body doesn't contain it
- *
- * @return mixed Signature information (enigma_signature) or enigma_error
- */
- abstract function verify($text, $signature);
-
- /**
- * Key/Cert file import.
- *
- * @param string File name or file content
- * @param bollean True if first argument is a filename
- *
- * @return mixed Import status array or enigma_error
- */
- abstract function import($content, $isfile=false);
-
- /**
- * Keys listing.
- *
- * @param string Optional pattern for key ID, user ID or fingerprint
- *
- * @return mixed Array of enigma_key objects or enigma_error
- */
- abstract function list_keys($pattern='');
-
- /**
- * Single key information.
- *
- * @param string Key ID, user ID or fingerprint
- *
- * @return mixed Key (enigma_key) object or enigma_error
- */
- abstract function get_key($keyid);
-
- /**
- * Key pair generation.
- *
- * @param array Key/User data
- *
- * @return mixed Key (enigma_key) object or enigma_error
- */
- abstract function gen_key($data);
-
- /**
- * Key deletion.
- */
- abstract function del_key($keyid);
-}
diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php
deleted file mode 100644
index 5aa32217e..000000000
--- a/plugins/enigma/lib/enigma_driver_gnupg.php
+++ /dev/null
@@ -1,305 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | GnuPG (PGP) driver for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-require_once 'Crypt/GPG.php';
-
-class enigma_driver_gnupg extends enigma_driver
-{
- private $rc;
- private $gpg;
- private $homedir;
- private $user;
-
- function __construct($user)
- {
- $rcmail = rcmail::get_instance();
- $this->rc = $rcmail;
- $this->user = $user;
- }
-
- /**
- * Driver initialization and environment checking.
- * Should only return critical errors.
- *
- * @return mixed NULL on success, enigma_error on failure
- */
- function init()
- {
- $homedir = $this->rc->config->get('enigma_pgp_homedir', INSTALL_PATH . '/plugins/enigma/home');
-
- if (!$homedir)
- return new enigma_error(enigma_error::E_INTERNAL,
- "Option 'enigma_pgp_homedir' not specified");
-
- // check if homedir exists (create it if not) and is readable
- if (!file_exists($homedir))
- return new enigma_error(enigma_error::E_INTERNAL,
- "Keys directory doesn't exists: $homedir");
- if (!is_writable($homedir))
- return new enigma_error(enigma_error::E_INTERNAL,
- "Keys directory isn't writeable: $homedir");
-
- $homedir = $homedir . '/' . $this->user;
-
- // check if user's homedir exists (create it if not) and is readable
- if (!file_exists($homedir))
- mkdir($homedir, 0700);
-
- if (!file_exists($homedir))
- return new enigma_error(enigma_error::E_INTERNAL,
- "Unable to create keys directory: $homedir");
- if (!is_writable($homedir))
- return new enigma_error(enigma_error::E_INTERNAL,
- "Unable to write to keys directory: $homedir");
-
- $this->homedir = $homedir;
-
- // Create Crypt_GPG object
- try {
- $this->gpg = new Crypt_GPG(array(
- 'homedir' => $this->homedir,
-// 'debug' => true,
- ));
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- function encrypt($text, $keys)
- {
-/*
- foreach ($keys as $key) {
- $this->gpg->addEncryptKey($key);
- }
- $enc = $this->gpg->encrypt($text);
- return $enc;
-*/
- }
-
- function decrypt($text, $key, $passwd)
- {
-// $this->gpg->addDecryptKey($key, $passwd);
- try {
- $dec = $this->gpg->decrypt($text);
- return $dec;
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- function sign($text, $key, $passwd)
- {
-/*
- $this->gpg->addSignKey($key, $passwd);
- $signed = $this->gpg->sign($text, Crypt_GPG::SIGN_MODE_DETACHED);
- return $signed;
-*/
- }
-
- function verify($text, $signature)
- {
- try {
- $verified = $this->gpg->verify($text, $signature);
- return $this->parse_signature($verified[0]);
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- public function import($content, $isfile=false)
- {
- try {
- if ($isfile)
- return $this->gpg->importKeyFile($content);
- else
- return $this->gpg->importKey($content);
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- public function list_keys($pattern='')
- {
- try {
- $keys = $this->gpg->getKeys($pattern);
- $result = array();
-//print_r($keys);
- foreach ($keys as $idx => $key) {
- $result[] = $this->parse_key($key);
- unset($keys[$idx]);
- }
-//print_r($result);
- return $result;
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- public function get_key($keyid)
- {
- $list = $this->list_keys($keyid);
-
- if (is_array($list))
- return array_shift($list);
-
- // error
- return $list;
- }
-
- public function gen_key($data)
- {
- }
-
- public function del_key($keyid)
- {
-// $this->get_key($keyid);
-
-
- }
-
- public function del_privkey($keyid)
- {
- try {
- $this->gpg->deletePrivateKey($keyid);
- return true;
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- public function del_pubkey($keyid)
- {
- try {
- $this->gpg->deletePublicKey($keyid);
- return true;
- }
- catch (Exception $e) {
- return $this->get_error_from_exception($e);
- }
- }
-
- /**
- * Converts Crypt_GPG exception into Enigma's error object
- *
- * @param mixed Exception object
- *
- * @return enigma_error Error object
- */
- private function get_error_from_exception($e)
- {
- $data = array();
-
- if ($e instanceof Crypt_GPG_KeyNotFoundException) {
- $error = enigma_error::E_KEYNOTFOUND;
- $data['id'] = $e->getKeyId();
- }
- else if ($e instanceof Crypt_GPG_BadPassphraseException) {
- $error = enigma_error::E_BADPASS;
- $data['bad'] = $e->getBadPassphrases();
- $data['missing'] = $e->getMissingPassphrases();
- }
- else if ($e instanceof Crypt_GPG_NoDataException)
- $error = enigma_error::E_NODATA;
- else if ($e instanceof Crypt_GPG_DeletePrivateKeyException)
- $error = enigma_error::E_DELKEY;
- else
- $error = enigma_error::E_INTERNAL;
-
- $msg = $e->getMessage();
-
- return new enigma_error($error, $msg, $data);
- }
-
- /**
- * Converts Crypt_GPG_Signature object into Enigma's signature object
- *
- * @param Crypt_GPG_Signature Signature object
- *
- * @return enigma_signature Signature object
- */
- private function parse_signature($sig)
- {
- $user = $sig->getUserId();
-
- $data = new enigma_signature();
- $data->id = $sig->getId();
- $data->valid = $sig->isValid();
- $data->fingerprint = $sig->getKeyFingerprint();
- $data->created = $sig->getCreationDate();
- $data->expires = $sig->getExpirationDate();
- $data->name = $user->getName();
- $data->comment = $user->getComment();
- $data->email = $user->getEmail();
-
- return $data;
- }
-
- /**
- * Converts Crypt_GPG_Key object into Enigma's key object
- *
- * @param Crypt_GPG_Key Key object
- *
- * @return enigma_key Key object
- */
- private function parse_key($key)
- {
- $ekey = new enigma_key();
-
- foreach ($key->getUserIds() as $idx => $user) {
- $id = new enigma_userid();
- $id->name = $user->getName();
- $id->comment = $user->getComment();
- $id->email = $user->getEmail();
- $id->valid = $user->isValid();
- $id->revoked = $user->isRevoked();
-
- $ekey->users[$idx] = $id;
- }
-
- $ekey->name = trim($ekey->users[0]->name . ' <' . $ekey->users[0]->email . '>');
-
- foreach ($key->getSubKeys() as $idx => $subkey) {
- $skey = new enigma_subkey();
- $skey->id = $subkey->getId();
- $skey->revoked = $subkey->isRevoked();
- $skey->created = $subkey->getCreationDate();
- $skey->expires = $subkey->getExpirationDate();
- $skey->fingerprint = $subkey->getFingerprint();
- $skey->has_private = $subkey->hasPrivate();
- $skey->can_sign = $subkey->canSign();
- $skey->can_encrypt = $subkey->canEncrypt();
-
- $ekey->subkeys[$idx] = $skey;
- };
-
- $ekey->id = $ekey->subkeys[0]->id;
-
- return $ekey;
- }
-}
diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php
deleted file mode 100644
index 59ae1202c..000000000
--- a/plugins/enigma/lib/enigma_engine.php
+++ /dev/null
@@ -1,547 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Engine of the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-
-*/
-
-/*
- RFC2440: OpenPGP Message Format
- RFC3156: MIME Security with OpenPGP
- RFC3851: S/MIME
-*/
-
-class enigma_engine
-{
- private $rc;
- private $enigma;
- private $pgp_driver;
- private $smime_driver;
-
- public $decryptions = array();
- public $signatures = array();
- public $signed_parts = array();
-
-
- /**
- * Plugin initialization.
- */
- function __construct($enigma)
- {
- $rcmail = rcmail::get_instance();
- $this->rc = $rcmail;
- $this->enigma = $enigma;
- }
-
- /**
- * PGP driver initialization.
- */
- function load_pgp_driver()
- {
- if ($this->pgp_driver)
- return;
-
- $driver = 'enigma_driver_' . $this->rc->config->get('enigma_pgp_driver', 'gnupg');
- $username = $this->rc->user->get_username();
-
- // Load driver
- $this->pgp_driver = new $driver($username);
-
- if (!$this->pgp_driver) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: Unable to load PGP driver: $driver"
- ), true, true);
- }
-
- // Initialise driver
- $result = $this->pgp_driver->init();
-
- if ($result instanceof enigma_error) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: ".$result->getMessage()
- ), true, true);
- }
- }
-
- /**
- * S/MIME driver initialization.
- */
- function load_smime_driver()
- {
- if ($this->smime_driver)
- return;
-
- // NOT IMPLEMENTED!
- return;
-
- $driver = 'enigma_driver_' . $this->rc->config->get('enigma_smime_driver', 'phpssl');
- $username = $this->rc->user->get_username();
-
- // Load driver
- $this->smime_driver = new $driver($username);
-
- if (!$this->smime_driver) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: Unable to load S/MIME driver: $driver"
- ), true, true);
- }
-
- // Initialise driver
- $result = $this->smime_driver->init();
-
- if ($result instanceof enigma_error) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: ".$result->getMessage()
- ), true, true);
- }
- }
-
- /**
- * Handler for plain/text message.
- *
- * @param array Reference to hook's parameters
- */
- function parse_plain(&$p)
- {
- $part = $p['structure'];
-
- // Get message body from IMAP server
- $this->set_part_body($part, $p['object']->uid);
-
- // @TODO: big message body can be a file resource
- // PGP signed message
- if (preg_match('/^-----BEGIN PGP SIGNED MESSAGE-----/', $part->body)) {
- $this->parse_plain_signed($p);
- }
- // PGP encrypted message
- else if (preg_match('/^-----BEGIN PGP MESSAGE-----/', $part->body)) {
- $this->parse_plain_encrypted($p);
- }
- }
-
- /**
- * Handler for multipart/signed message.
- *
- * @param array Reference to hook's parameters
- */
- function parse_signed(&$p)
- {
- $struct = $p['structure'];
-
- // S/MIME
- if ($struct->parts[1] && $struct->parts[1]->mimetype == 'application/pkcs7-signature') {
- $this->parse_smime_signed($p);
- }
- // PGP/MIME:
- // The multipart/signed body MUST consist of exactly two parts.
- // The first part contains the signed data in MIME canonical format,
- // including a set of appropriate content headers describing the data.
- // The second body MUST contain the PGP digital signature. It MUST be
- // labeled with a content type of "application/pgp-signature".
- else if ($struct->parts[1] && $struct->parts[1]->mimetype == 'application/pgp-signature') {
- $this->parse_pgp_signed($p);
- }
- }
-
- /**
- * Handler for multipart/encrypted message.
- *
- * @param array Reference to hook's parameters
- */
- function parse_encrypted(&$p)
- {
- $struct = $p['structure'];
-
- // S/MIME
- if ($struct->mimetype == 'application/pkcs7-mime') {
- $this->parse_smime_encrypted($p);
- }
- // PGP/MIME:
- // The multipart/encrypted MUST consist of exactly two parts. The first
- // MIME body part must have a content type of "application/pgp-encrypted".
- // This body contains the control information.
- // The second MIME body part MUST contain the actual encrypted data. It
- // must be labeled with a content type of "application/octet-stream".
- else if ($struct->parts[0] && $struct->parts[0]->mimetype == 'application/pgp-encrypted' &&
- $struct->parts[1] && $struct->parts[1]->mimetype == 'application/octet-stream'
- ) {
- $this->parse_pgp_encrypted($p);
- }
- }
-
- /**
- * Handler for plain signed message.
- * Excludes message and signature bodies and verifies signature.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_plain_signed(&$p)
- {
- $this->load_pgp_driver();
- $part = $p['structure'];
-
- // Verify signature
- if ($this->rc->action == 'show' || $this->rc->action == 'preview') {
- $sig = $this->pgp_verify($part->body);
- }
-
- // @TODO: Handle big bodies using (temp) files
-
- // In this way we can use fgets on string as on file handle
- $fh = fopen('php://memory', 'br+');
- // @TODO: fopen/fwrite errors handling
- if ($fh) {
- fwrite($fh, $part->body);
- rewind($fh);
- }
- $part->body = null;
-
- // Extract body (and signature?)
- while (!feof($fh)) {
- $line = fgets($fh, 1024);
-
- if ($part->body === null)
- $part->body = '';
- else if (preg_match('/^-----BEGIN PGP SIGNATURE-----/', $line))
- break;
- else
- $part->body .= $line;
- }
-
- // Remove "Hash" Armor Headers
- $part->body = preg_replace('/^.*\r*\n\r*\n/', '', $part->body);
- // de-Dash-Escape (RFC2440)
- $part->body = preg_replace('/(^|\n)- -/', '\\1-', $part->body);
-
- // Store signature data for display
- if (!empty($sig)) {
- $this->signed_parts[$part->mime_id] = $part->mime_id;
- $this->signatures[$part->mime_id] = $sig;
- }
-
- fclose($fh);
- }
-
- /**
- * Handler for PGP/MIME signed message.
- * Verifies signature.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_pgp_signed(&$p)
- {
- $this->load_pgp_driver();
- $struct = $p['structure'];
-
- // Verify signature
- if ($this->rc->action == 'show' || $this->rc->action == 'preview') {
- $msg_part = $struct->parts[0];
- $sig_part = $struct->parts[1];
-
- // Get bodies
- $this->set_part_body($msg_part, $p['object']->uid);
- $this->set_part_body($sig_part, $p['object']->uid);
-
- // Verify
- $sig = $this->pgp_verify($msg_part->body, $sig_part->body);
-
- // Store signature data for display
- $this->signatures[$struct->mime_id] = $sig;
-
- // Message can be multipart (assign signature to each subpart)
- if (!empty($msg_part->parts)) {
- foreach ($msg_part->parts as $part)
- $this->signed_parts[$part->mime_id] = $struct->mime_id;
- }
- else
- $this->signed_parts[$msg_part->mime_id] = $struct->mime_id;
-
- // Remove signature file from attachments list
- unset($struct->parts[1]);
- }
- }
-
- /**
- * Handler for S/MIME signed message.
- * Verifies signature.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_smime_signed(&$p)
- {
- $this->load_smime_driver();
- }
-
- /**
- * Handler for plain encrypted message.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_plain_encrypted(&$p)
- {
- $this->load_pgp_driver();
- $part = $p['structure'];
-
- // Get body
- $this->set_part_body($part, $p['object']->uid);
-
- // Decrypt
- $result = $this->pgp_decrypt($part->body);
-
- // Store decryption status
- $this->decryptions[$part->mime_id] = $result;
-
- // Parse decrypted message
- if ($result === true) {
- // @TODO
- }
- }
-
- /**
- * Handler for PGP/MIME encrypted message.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_pgp_encrypted(&$p)
- {
- $this->load_pgp_driver();
- $struct = $p['structure'];
- $part = $struct->parts[1];
-
- // Get body
- $this->set_part_body($part, $p['object']->uid);
-
- // Decrypt
- $result = $this->pgp_decrypt($part->body);
-
- $this->decryptions[$part->mime_id] = $result;
-//print_r($part);
- // Parse decrypted message
- if ($result === true) {
- // @TODO
- }
- else {
- // Make sure decryption status message will be displayed
- $part->type = 'content';
- $p['object']->parts[] = $part;
- }
- }
-
- /**
- * Handler for S/MIME encrypted message.
- *
- * @param array Reference to hook's parameters
- */
- private function parse_smime_encrypted(&$p)
- {
- $this->load_smime_driver();
- }
-
- /**
- * PGP signature verification.
- *
- * @param mixed Message body
- * @param mixed Signature body (for MIME messages)
- *
- * @return mixed enigma_signature or enigma_error
- */
- private function pgp_verify(&$msg_body, $sig_body=null)
- {
- // @TODO: Handle big bodies using (temp) files
- // @TODO: caching of verification result
-
- $sig = $this->pgp_driver->verify($msg_body, $sig_body);
-
- if (($sig instanceof enigma_error) && $sig->getCode() != enigma_error::E_KEYNOTFOUND)
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: " . $error->getMessage()
- ), true, false);
-
-//print_r($sig);
- return $sig;
- }
-
- /**
- * PGP message decryption.
- *
- * @param mixed Message body
- *
- * @return mixed True or enigma_error
- */
- private function pgp_decrypt(&$msg_body)
- {
- // @TODO: Handle big bodies using (temp) files
- // @TODO: caching of verification result
-
- $result = $this->pgp_driver->decrypt($msg_body, $key, $pass);
-
-//print_r($result);
-
- if ($result instanceof enigma_error) {
- $err_code = $result->getCode();
- if (!in_array($err_code, array(enigma_error::E_KEYNOTFOUND, enigma_error::E_BADPASS)))
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: " . $result->getMessage()
- ), true, false);
- return $result;
- }
-
-// $msg_body = $result;
- return true;
- }
-
- /**
- * PGP keys listing.
- *
- * @param mixed Key ID/Name pattern
- *
- * @return mixed Array of keys or enigma_error
- */
- function list_keys($pattern='')
- {
- $this->load_pgp_driver();
- $result = $this->pgp_driver->list_keys($pattern);
-
- if ($result instanceof enigma_error) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: " . $result->getMessage()
- ), true, false);
- }
-
- return $result;
- }
-
- /**
- * PGP key details.
- *
- * @param mixed Key ID
- *
- * @return mixed enigma_key or enigma_error
- */
- function get_key($keyid)
- {
- $this->load_pgp_driver();
- $result = $this->pgp_driver->get_key($keyid);
-
- if ($result instanceof enigma_error) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: " . $result->getMessage()
- ), true, false);
- }
-
- return $result;
- }
-
- /**
- * PGP keys/certs importing.
- *
- * @param mixed Import file name or content
- * @param boolean True if first argument is a filename
- *
- * @return mixed Import status data array or enigma_error
- */
- function import_key($content, $isfile=false)
- {
- $this->load_pgp_driver();
- $result = $this->pgp_driver->import($content, $isfile);
-
- if ($result instanceof enigma_error) {
- raise_error(array(
- 'code' => 600, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Enigma plugin: " . $result->getMessage()
- ), true, false);
- }
- else {
- $result['imported'] = $result['public_imported'] + $result['private_imported'];
- $result['unchanged'] = $result['public_unchanged'] + $result['private_unchanged'];
- }
-
- return $result;
- }
-
- /**
- * Handler for keys/certs import request action
- */
- function import_file()
- {
- $uid = get_input_value('_uid', RCUBE_INPUT_POST);
- $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
- $mime_id = get_input_value('_part', RCUBE_INPUT_POST);
-
- if ($uid && $mime_id) {
- $part = $this->rc->imap->get_message_part($uid, $mime_id);
- }
-
- if ($part && is_array($result = $this->import_key($part))) {
- $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation',
- array('new' => $result['imported'], 'old' => $result['unchanged']));
- }
- else
- $this->rc->output->show_message('enigma.keysimportfailed', 'error');
-
- $this->rc->output->send();
- }
-
- /**
- * Checks if specified message part contains body data.
- * If body is not set it will be fetched from IMAP server.
- *
- * @param rcube_message_part Message part object
- * @param integer Message UID
- */
- private function set_part_body($part, $uid)
- {
- // @TODO: Create such function in core
- // @TODO: Handle big bodies using file handles
- if (!isset($part->body)) {
- $part->body = $this->rc->imap->get_message_part(
- $uid, $part->mime_id, $part);
- }
- }
-
- /**
- * Adds CSS style file to the page header.
- */
- private function add_css()
- {
- $skin = $this->rc->config->get('skin');
- if (!file_exists($this->home . "/skins/$skin/enigma.css"))
- $skin = 'default';
-
- $this->include_stylesheet("skins/$skin/enigma.css");
- }
-}
diff --git a/plugins/enigma/lib/enigma_error.php b/plugins/enigma/lib/enigma_error.php
deleted file mode 100644
index 9f424dc2b..000000000
--- a/plugins/enigma/lib/enigma_error.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Error class for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_error
-{
- private $code;
- private $message;
- private $data = array();
-
- // error codes
- const E_OK = 0;
- const E_INTERNAL = 1;
- const E_NODATA = 2;
- const E_KEYNOTFOUND = 3;
- const E_DELKEY = 4;
- const E_BADPASS = 5;
-
- function __construct($code = null, $message = '', $data = array())
- {
- $this->code = $code;
- $this->message = $message;
- $this->data = $data;
- }
-
- function getCode()
- {
- return $this->code;
- }
-
- function getMessage()
- {
- return $this->message;
- }
-
- function getData($name)
- {
- if ($name)
- return $this->data[$name];
- else
- return $this->data;
- }
-}
diff --git a/plugins/enigma/lib/enigma_key.php b/plugins/enigma/lib/enigma_key.php
deleted file mode 100644
index 520c36b0b..000000000
--- a/plugins/enigma/lib/enigma_key.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Key class for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_key
-{
- public $id;
- public $name;
- public $users = array();
- public $subkeys = array();
-
- const TYPE_UNKNOWN = 0;
- const TYPE_KEYPAIR = 1;
- const TYPE_PUBLIC = 2;
-
- /**
- * Keys list sorting callback for usort()
- */
- static function cmp($a, $b)
- {
- return strcmp($a->name, $b->name);
- }
-
- /**
- * Returns key type
- */
- function get_type()
- {
- if ($this->subkeys[0]->has_private)
- return enigma_key::TYPE_KEYPAIR;
- else if (!empty($this->subkeys[0]))
- return enigma_key::TYPE_PUBLIC;
-
- return enigma_key::TYPE_UNKNOWN;
- }
-
- /**
- * Returns true if all user IDs are revoked
- */
- function is_revoked()
- {
- foreach ($this->subkeys as $subkey)
- if (!$subkey->revoked)
- return false;
-
- return true;
- }
-
- /**
- * Returns true if any user ID is valid
- */
- function is_valid()
- {
- foreach ($this->users as $user)
- if ($user->valid)
- return true;
-
- return false;
- }
-
- /**
- * Returns true if any of subkeys is not expired
- */
- function is_expired()
- {
- $now = time();
-
- foreach ($this->subkeys as $subkey)
- if (!$subkey->expires || $subkey->expires > $now)
- return true;
-
- return false;
- }
-
- /**
- * Converts long ID or Fingerprint to short ID
- * Crypt_GPG uses internal, but e.g. Thunderbird's Enigmail displays short ID
- *
- * @param string Key ID or fingerprint
- * @return string Key short ID
- */
- static function format_id($id)
- {
- // E.g. 04622F2089E037A5 => 89E037A5
-
- return substr($id, -8);
- }
-
- /**
- * Formats fingerprint string
- *
- * @param string Key fingerprint
- *
- * @return string Formatted fingerprint (with spaces)
- */
- static function format_fingerprint($fingerprint)
- {
- if (!$fingerprint)
- return '';
-
- $result = '';
- for ($i=0; $i<40; $i++) {
- if ($i % 4 == 0)
- $result .= ' ';
- $result .= $fingerprint[$i];
- }
- return $result;
- }
-
-}
diff --git a/plugins/enigma/lib/enigma_signature.php b/plugins/enigma/lib/enigma_signature.php
deleted file mode 100644
index 65990903b..000000000
--- a/plugins/enigma/lib/enigma_signature.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | Signature class for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_signature
-{
- public $id;
- public $valid;
- public $fingerprint;
- public $created;
- public $expires;
- public $name;
- public $comment;
- public $email;
-}
diff --git a/plugins/enigma/lib/enigma_subkey.php b/plugins/enigma/lib/enigma_subkey.php
deleted file mode 100644
index 1b9fb95ad..000000000
--- a/plugins/enigma/lib/enigma_subkey.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | SubKey class for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_subkey
-{
- public $id;
- public $fingerprint;
- public $expires;
- public $created;
- public $revoked;
- public $has_private;
- public $can_sign;
- public $can_encrypt;
-
- /**
- * Converts internal ID to short ID
- * Crypt_GPG uses internal, but e.g. Thunderbird's Enigmail displays short ID
- *
- * @return string Key ID
- */
- function get_short_id()
- {
- // E.g. 04622F2089E037A5 => 89E037A5
- return enigma_key::format_id($this->id);
- }
-
- /**
- * Getter for formatted fingerprint
- *
- * @return string Formatted fingerprint
- */
- function get_fingerprint()
- {
- return enigma_key::format_fingerprint($this->fingerprint);
- }
-
-}
diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php
deleted file mode 100644
index 552d865be..000000000
--- a/plugins/enigma/lib/enigma_ui.php
+++ /dev/null
@@ -1,410 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | User Interface for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_ui
-{
- private $rc;
- private $enigma;
- private $home;
- private $css_added;
- private $data;
-
-
- function __construct($enigma_plugin, $home='')
- {
- $this->enigma = $enigma_plugin;
- $this->rc = $enigma_plugin->rc;
- // we cannot use $enigma_plugin->home here
- $this->home = $home;
- }
-
- /**
- * UI initialization and requests handlers.
- *
- * @param string Preferences section
- */
- function init($section='')
- {
- $this->enigma->include_script('enigma.js');
-
- // Enigma actions
- if ($this->rc->action == 'plugin.enigma') {
- $action = get_input_value('_a', RCUBE_INPUT_GPC);
-
- switch ($action) {
- case 'keyedit':
- $this->key_edit();
- break;
- case 'keyimport':
- $this->key_import();
- break;
- case 'keysearch':
- case 'keylist':
- $this->key_list();
- break;
- case 'keyinfo':
- default:
- $this->key_info();
- }
- }
- // Preferences UI
- else { // if ($this->rc->action == 'edit-prefs') {
- if ($section == 'enigmacerts') {
- $this->rc->output->add_handlers(array(
- 'keyslist' => array($this, 'tpl_certs_list'),
- 'keyframe' => array($this, 'tpl_cert_frame'),
- 'countdisplay' => array($this, 'tpl_certs_rowcount'),
- 'searchform' => array($this->rc->output, 'search_form'),
- ));
- $this->rc->output->set_pagetitle($this->enigma->gettext('enigmacerts'));
- $this->rc->output->send('enigma.certs');
- }
- else {
- $this->rc->output->add_handlers(array(
- 'keyslist' => array($this, 'tpl_keys_list'),
- 'keyframe' => array($this, 'tpl_key_frame'),
- 'countdisplay' => array($this, 'tpl_keys_rowcount'),
- 'searchform' => array($this->rc->output, 'search_form'),
- ));
- $this->rc->output->set_pagetitle($this->enigma->gettext('enigmakeys'));
- $this->rc->output->send('enigma.keys');
- }
- }
- }
-
- /**
- * Adds CSS style file to the page header.
- */
- function add_css()
- {
- if ($this->css_loaded)
- return;
-
- $skin = $this->rc->config->get('skin');
- if (!file_exists($this->home . "/skins/$skin/enigma.css"))
- $skin = 'default';
-
- $this->enigma->include_stylesheet("skins/$skin/enigma.css");
- $this->css_added = true;
- }
-
- /**
- * Template object for key info/edit frame.
- *
- * @param array Object attributes
- *
- * @return string HTML output
- */
- function tpl_key_frame($attrib)
- {
- if (!$attrib['id']) {
- $attrib['id'] = 'rcmkeysframe';
- }
-
- $attrib['name'] = $attrib['id'];
-
- $this->rc->output->set_env('contentframe', $attrib['name']);
- $this->rc->output->set_env('blankpage', $attrib['src'] ?
- $this->rc->output->abs_url($attrib['src']) : 'program/blank.gif');
-
- return html::tag('iframe', $attrib);
- }
-
- /**
- * Template object for list of keys.
- *
- * @param array Object attributes
- *
- * @return string HTML content
- */
- function tpl_keys_list($attrib)
- {
- // add id to message list table if not specified
- if (!strlen($attrib['id'])) {
- $attrib['id'] = 'rcmenigmakeyslist';
- }
-
- // define list of cols to be displayed
- $a_show_cols = array('name');
-
- // create XHTML table
- $out = rcube_table_output($attrib, array(), $a_show_cols, 'id');
-
- // set client env
- $this->rc->output->add_gui_object('keyslist', $attrib['id']);
- $this->rc->output->include_script('list.js');
-
- // add some labels to client
- $this->rc->output->add_label('enigma.keyconfirmdelete');
-
- return $out;
- }
-
- /**
- * Key listing (and searching) request handler
- */
- private function key_list()
- {
- $this->enigma->load_engine();
-
- $pagesize = $this->rc->config->get('pagesize', 100);
- $page = max(intval(get_input_value('_p', RCUBE_INPUT_GPC)), 1);
- $search = get_input_value('_q', RCUBE_INPUT_GPC);
-
- // define list of cols to be displayed
- $a_show_cols = array('name');
- $result = array();
-
- // Get the list
- $list = $this->enigma->engine->list_keys($search);
-
- if ($list && ($list instanceof enigma_error))
- $this->rc->output->show_message('enigma.keylisterror', 'error');
- else if (empty($list))
- $this->rc->output->show_message('enigma.nokeysfound', 'notice');
- else {
- if (is_array($list)) {
- // Save the size
- $listsize = count($list);
-
- // Sort the list by key (user) name
- usort($list, array('enigma_key', 'cmp'));
-
- // Slice current page
- $list = array_slice($list, ($page - 1) * $pagesize, $pagesize);
-
- $size = count($list);
-
- // Add rows
- foreach($list as $idx => $key) {
- $this->rc->output->command('enigma_add_list_row',
- array('name' => Q($key->name), 'id' => $key->id));
- }
- }
- }
-
- $this->rc->output->set_env('search_request', $search);
- $this->rc->output->set_env('pagecount', ceil($listsize/$pagesize));
- $this->rc->output->set_env('current_page', $page);
- $this->rc->output->command('set_rowcount',
- $this->get_rowcount_text($listsize, $size, $page));
-
- $this->rc->output->send();
- }
-
- /**
- * Template object for list records counter.
- *
- * @param array Object attributes
- *
- * @return string HTML output
- */
- function tpl_keys_rowcount($attrib)
- {
- if (!$attrib['id'])
- $attrib['id'] = 'rcmcountdisplay';
-
- $this->rc->output->add_gui_object('countdisplay', $attrib['id']);
-
- return html::span($attrib, $this->get_rowcount_text());
- }
-
- /**
- * Returns text representation of list records counter
- */
- private function get_rowcount_text($all=0, $curr_count=0, $page=1)
- {
- if (!$curr_count)
- $out = $this->enigma->gettext('nokeysfound');
- else {
- $pagesize = $this->rc->config->get('pagesize', 100);
- $first = ($page - 1) * $pagesize;
-
- $out = $this->enigma->gettext(array(
- 'name' => 'keysfromto',
- 'vars' => array(
- 'from' => $first + 1,
- 'to' => $first + $curr_count,
- 'count' => $all)
- ));
- }
-
- return $out;
- }
-
- /**
- * Key information page handler
- */
- private function key_info()
- {
- $id = get_input_value('_id', RCUBE_INPUT_GET);
-
- $this->enigma->load_engine();
- $res = $this->enigma->engine->get_key($id);
-
- if ($res instanceof enigma_key)
- $this->data = $res;
- else { // error
- $this->rc->output->show_message('enigma.keyopenerror', 'error');
- $this->rc->output->command('parent.enigma_loadframe');
- $this->rc->output->send('iframe');
- }
-
- $this->rc->output->add_handlers(array(
- 'keyname' => array($this, 'tpl_key_name'),
- 'keydata' => array($this, 'tpl_key_data'),
- ));
-
- $this->rc->output->set_pagetitle($this->enigma->gettext('keyinfo'));
- $this->rc->output->send('enigma.keyinfo');
- }
-
- /**
- * Template object for key name
- */
- function tpl_key_name($attrib)
- {
- return Q($this->data->name);
- }
-
- /**
- * Template object for key information page content
- */
- function tpl_key_data($attrib)
- {
- $out = '';
- $table = new html_table(array('cols' => 2));
-
- // Key user ID
- $table->add('title', $this->enigma->gettext('keyuserid'));
- $table->add(null, Q($this->data->name));
- // Key ID
- $table->add('title', $this->enigma->gettext('keyid'));
- $table->add(null, $this->data->subkeys[0]->get_short_id());
- // Key type
- $keytype = $this->data->get_type();
- if ($keytype == enigma_key::TYPE_KEYPAIR)
- $type = $this->enigma->gettext('typekeypair');
- else if ($keytype == enigma_key::TYPE_PUBLIC)
- $type = $this->enigma->gettext('typepublickey');
- $table->add('title', $this->enigma->gettext('keytype'));
- $table->add(null, $type);
- // Key fingerprint
- $table->add('title', $this->enigma->gettext('fingerprint'));
- $table->add(null, $this->data->subkeys[0]->get_fingerprint());
-
- $out .= html::tag('fieldset', null,
- html::tag('legend', null,
- $this->enigma->gettext('basicinfo')) . $table->show($attrib));
-
- // Subkeys
- $table = new html_table(array('cols' => 6));
- // Columns: Type, ID, Algorithm, Size, Created, Expires
-
- $out .= html::tag('fieldset', null,
- html::tag('legend', null,
- $this->enigma->gettext('subkeys')) . $table->show($attrib));
-
- // Additional user IDs
- $table = new html_table(array('cols' => 2));
- // Columns: User ID, Validity
-
- $out .= html::tag('fieldset', null,
- html::tag('legend', null,
- $this->enigma->gettext('userids')) . $table->show($attrib));
-
- return $out;
- }
-
- /**
- * Key import page handler
- */
- private function key_import()
- {
- // Import process
- if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name'])) {
- $this->enigma->load_engine();
- $result = $this->enigma->engine->import_key($_FILES['_file']['tmp_name'], true);
-
- if (is_array($result)) {
- // reload list if any keys has been added
- if ($result['imported']) {
- $this->rc->output->command('parent.enigma_list', 1);
- }
- else
- $this->rc->output->command('parent.enigma_loadframe');
-
- $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation',
- array('new' => $result['imported'], 'old' => $result['unchanged']));
-
- $this->rc->output->send('iframe');
- }
- else
- $this->rc->output->show_message('enigma.keysimportfailed', 'error');
- }
- else if ($err = $_FILES['_file']['error']) {
- if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
- $this->rc->output->show_message('filesizeerror', 'error',
- array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize')))));
- } else {
- $this->rc->output->show_message('fileuploaderror', 'error');
- }
- }
-
- $this->rc->output->add_handlers(array(
- 'importform' => array($this, 'tpl_key_import_form'),
- ));
-
- $this->rc->output->set_pagetitle($this->enigma->gettext('keyimport'));
- $this->rc->output->send('enigma.keyimport');
- }
-
- /**
- * Template object for key import (upload) form
- */
- function tpl_key_import_form($attrib)
- {
- $attrib += array('id' => 'rcmKeyImportForm');
-
- $upload = new html_inputfield(array('type' => 'file', 'name' => '_file',
- 'id' => 'rcmimportfile', 'size' => 30));
-
- $form = html::p(null,
- Q($this->enigma->gettext('keyimporttext'), 'show')
- . html::br() . html::br() . $upload->show()
- );
-
- $this->rc->output->add_label('selectimportfile', 'importwait');
- $this->rc->output->add_gui_object('importform', $attrib['id']);
-
- $out = $this->rc->output->form_tag(array(
- 'action' => $this->rc->url(array('action' => 'plugin.enigma', 'a' => 'keyimport')),
- 'method' => 'post',
- 'enctype' => 'multipart/form-data') + $attrib,
- $form);
-
- return $out;
- }
-
-
-}
diff --git a/plugins/enigma/lib/enigma_userid.php b/plugins/enigma/lib/enigma_userid.php
deleted file mode 100644
index 36185e718..000000000
--- a/plugins/enigma/lib/enigma_userid.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/*
- +-------------------------------------------------------------------------+
- | User ID class for the Enigma Plugin |
- | |
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of the GNU General Public License version 2 |
- | as published by the Free Software Foundation. |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of the GNU General Public License along |
- | with this program; if not, write to the Free Software Foundation, Inc., |
- | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
- | |
- +-------------------------------------------------------------------------+
- | Author: Aleksander Machniak <alec@alec.pl> |
- +-------------------------------------------------------------------------+
-*/
-
-class enigma_userid
-{
- public $revoked;
- public $valid;
- public $name;
- public $comment;
- public $email;
-}
diff --git a/plugins/enigma/localization/en_US.inc b/plugins/enigma/localization/en_US.inc
deleted file mode 100644
index eb0f18d3c..000000000
--- a/plugins/enigma/localization/en_US.inc
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-$labels = array();
-$labels['enigmasettings'] = 'Enigma: Settings';
-$labels['enigmacerts'] = 'Enigma: Certificates (S/MIME)';
-$labels['enigmakeys'] = 'Enigma: Keys (PGP)';
-$labels['keysfromto'] = 'Keys $from to $to of $count';
-$labels['keyname'] = 'Name';
-$labels['keyid'] = 'Key ID';
-$labels['keyuserid'] = 'User ID';
-$labels['keytype'] = 'Key type';
-$labels['fingerprint'] = 'Fingerprint';
-$labels['subkeys'] = 'Subkeys';
-$labels['basicinfo'] = 'Basic Information';
-$labels['userids'] = 'Additional User IDs';
-$labels['typepublickey'] = 'public key';
-$labels['typekeypair'] = 'key pair';
-$labels['keyattfound'] = 'This message contains attached PGP key(s).';
-$labels['keyattimport'] = 'Import key(s)';
-
-$labels['createkeys'] = 'Create a new key pair';
-$labels['importkeys'] = 'Import key(s)';
-$labels['exportkeys'] = 'Export key(s)';
-$labels['deletekeys'] = 'Delete key(s)';
-$labels['keyactions'] = 'Key actions...';
-$labels['keydisable'] = 'Disable key';
-$labels['keyrevoke'] = 'Revoke key';
-$labels['keysend'] = 'Send public key in a message';
-$labels['keychpass'] = 'Change password';
-
-$messages = array();
-$messages['sigvalid'] = 'Verified signature from $sender.';
-$messages['siginvalid'] = 'Invalid signature from $sender.';
-$messages['signokey'] = 'Unverified signature. Public key not found. Key ID: $keyid.';
-$messages['sigerror'] = 'Unverified signature. Internal error.';
-$messages['decryptok'] = 'Message decrypted.';
-$messages['decrypterror'] = 'Decryption failed.';
-$messages['decryptnokey'] = 'Decryption failed. Private key not found. Key ID: $keyid.';
-$messages['decryptbadpass'] = 'Decryption failed. Bad password.';
-$messages['nokeysfound'] = 'No keys found';
-$messages['keyopenerror'] = 'Unable to get key information! Internal error.';
-$messages['keylisterror'] = 'Unable to list keys! Internal error.';
-$messages['keysimportfailed'] = 'Unable to import key(s)! Internal error.';
-$messages['keysimportsuccess'] = 'Key(s) imported successfully. Imported: $new, unchanged: $old.';
-$messages['keyconfirmdelete'] = 'Are you sure, you want to delete selected key(s)?';
-$messages['keyimporttext'] = 'You can import private and public key(s) or revocation signatures in ASCII-Armor format.';
-
-?>
diff --git a/plugins/enigma/skins/default/enigma.css b/plugins/enigma/skins/default/enigma.css
deleted file mode 100644
index b1c656f82..000000000
--- a/plugins/enigma/skins/default/enigma.css
+++ /dev/null
@@ -1,182 +0,0 @@
-/*** Style for Enigma plugin ***/
-
-/***** Messages displaying *****/
-
-#enigma-message,
-/* fixes border-top */
-#messagebody div #enigma-message
-{
- margin: 0;
- margin-bottom: 5px;
- min-height: 20px;
- padding: 10px 10px 6px 46px;
-}
-
-div.enigmaerror,
-/* fixes border-top */
-#messagebody div.enigmaerror
-{
- background: url(enigma_error.png) 6px 1px no-repeat;
- background-color: #EF9398;
- border: 1px solid #DC5757;
-}
-
-div.enigmanotice,
-/* fixes border-top */
-#messagebody div.enigmanotice
-{
- background: url(enigma.png) 6px 1px no-repeat;
- background-color: #A6EF7B;
- border: 1px solid #76C83F;
-}
-
-div.enigmawarning,
-/* fixes border-top */
-#messagebody div.enigmawarning
-{
- background: url(enigma.png) 6px 1px no-repeat;
- background-color: #F7FDCB;
- border: 1px solid #C2D071;
-}
-
-#enigma-message a
-{
- color: #666666;
- padding-left: 10px;
-}
-
-#enigma-message a:hover
-{
- color: #333333;
-}
-
-/***** Keys/Certs Management *****/
-
-div.enigmascreen
-{
- position: absolute;
- top: 65px;
- right: 10px;
- bottom: 10px;
- left: 10px;
-}
-
-#enigmacontent-box
-{
- position: absolute;
- top: 0px;
- left: 290px;
- right: 0px;
- bottom: 0px;
- border: 1px solid #999999;
- overflow: hidden;
-}
-
-#enigmakeyslist
-{
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- border: 1px solid #999999;
- background-color: #F9F9F9;
- overflow: hidden;
-}
-
-#keylistcountbar
-{
- margin-top: 4px;
- margin-left: 4px;
-}
-
-#keys-table
-{
- width: 100%;
- table-layout: fixed;
-}
-
-#keys-table td
-{
- cursor: default;
- text-overflow: ellipsis;
- -o-text-overflow: ellipsis;
-}
-
-#key-details table td.title
-{
- font-weight: bold;
- text-align: right;
-}
-
-#keystoolbar
-{
- position: absolute;
- top: 30px;
- left: 10px;
- height: 35px;
-}
-
-#keystoolbar a
-{
- padding-right: 10px;
-}
-
-#keystoolbar a.button,
-#keystoolbar a.buttonPas,
-#keystoolbar span.separator {
- display: block;
- float: left;
- width: 32px;
- height: 32px;
- padding: 0;
- margin-right: 10px;
- overflow: hidden;
- background: url(keys_toolbar.png) 0 0 no-repeat transparent;
- opacity: 0.99; /* this is needed to make buttons appear correctly in Chrome */
-}
-
-#keystoolbar a.buttonPas {
- opacity: 0.35;
-}
-
-#keystoolbar a.createSel {
- background-position: 0 -32px;
-}
-
-#keystoolbar a.create {
- background-position: 0 0;
-}
-
-#keystoolbar a.deleteSel {
- background-position: -32px -32px;
-}
-
-#keystoolbar a.delete {
- background-position: -32px 0;
-}
-
-#keystoolbar a.importSel {
- background-position: -64px -32px;
-}
-
-#keystoolbar a.import {
- background-position: -64px 0;
-}
-
-#keystoolbar a.exportSel {
- background-position: -96px -32px;
-}
-
-#keystoolbar a.export {
- background-position: -96px 0;
-}
-
-#keystoolbar a.keymenu {
- background-position: -128px 0;
- width: 36px;
-}
-
-#keystoolbar span.separator {
- width: 5px;
- background-position: -166px 0;
-}
diff --git a/plugins/enigma/skins/default/enigma.png b/plugins/enigma/skins/default/enigma.png
deleted file mode 100644
index 3ef106e2a..000000000
--- a/plugins/enigma/skins/default/enigma.png
+++ /dev/null
Binary files differ
diff --git a/plugins/enigma/skins/default/enigma_error.png b/plugins/enigma/skins/default/enigma_error.png
deleted file mode 100644
index 9bf100efd..000000000
--- a/plugins/enigma/skins/default/enigma_error.png
+++ /dev/null
Binary files differ
diff --git a/plugins/enigma/skins/default/key.png b/plugins/enigma/skins/default/key.png
deleted file mode 100644
index ea1cbd11c..000000000
--- a/plugins/enigma/skins/default/key.png
+++ /dev/null
Binary files differ
diff --git a/plugins/enigma/skins/default/key_add.png b/plugins/enigma/skins/default/key_add.png
deleted file mode 100644
index f22cc870a..000000000
--- a/plugins/enigma/skins/default/key_add.png
+++ /dev/null
Binary files differ
diff --git a/plugins/enigma/skins/default/keys_toolbar.png b/plugins/enigma/skins/default/keys_toolbar.png
deleted file mode 100644
index 7cc258cc8..000000000
--- a/plugins/enigma/skins/default/keys_toolbar.png
+++ /dev/null
Binary files differ
diff --git a/plugins/enigma/skins/default/templates/keyimport.html b/plugins/enigma/skins/default/templates/keyimport.html
deleted file mode 100644
index 4e0b304a5..000000000
--- a/plugins/enigma/skins/default/templates/keyimport.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title><roundcube:object name="pagetitle" /></title>
-<roundcube:include file="/includes/links.html" />
-<link rel="stylesheet" type="text/css" href="/this/enigma.css" />
-</head>
-<body class="iframe">
-
-<div id="keyimport-title" class="boxtitle"><roundcube:label name="enigma.importkeys" /></div>
-
-<div id="import-form" class="boxcontent">
- <roundcube:object name="importform" />
- <p>
- <br /><roundcube:button command="plugin.enigma-import" type="input" class="button mainaction" label="import" />
- </p>
-</div>
-
-</body>
-</html>
diff --git a/plugins/enigma/skins/default/templates/keyinfo.html b/plugins/enigma/skins/default/templates/keyinfo.html
deleted file mode 100644
index 2e8ed61db..000000000
--- a/plugins/enigma/skins/default/templates/keyinfo.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title><roundcube:object name="pagetitle" /></title>
-<roundcube:include file="/includes/links.html" />
-<link rel="stylesheet" type="text/css" href="/this/enigma.css" />
-</head>
-<body class="iframe">
-
-<div id="keyinfo-title" class="boxtitle"><roundcube:object name="keyname" part="name" /></div>
-
-<div id="key-details" class="boxcontent">
- <roundcube:object name="keydata" />
-</div>
-
-</body>
-</html>
diff --git a/plugins/enigma/skins/default/templates/keys.html b/plugins/enigma/skins/default/templates/keys.html
deleted file mode 100644
index 810c4a211..000000000
--- a/plugins/enigma/skins/default/templates/keys.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title><roundcube:object name="pagetitle" /></title>
-<roundcube:include file="/includes/links.html" />
-<link rel="stylesheet" type="text/css" href="/this/enigma.css" />
-<script type="text/javascript" src="/functions.js"></script>
-<script type="text/javascript" src="/splitter.js"></script>
-<style type="text/css">
-#enigmakeyslist { width: <roundcube:exp expression="!empty(cookie:enigmaviewsplitter) ? cookie:enigmaviewsplitter-5 : 210" />px; }
-#enigmacontent-box { left: <roundcube:exp expression="!empty(cookie:enigmaviewsplitter) ? cookie:enigmaviewsplitter+5 : 220" />px;
-<roundcube:exp expression="browser:ie ? ('width:expression((parseInt(this.parentNode.offsetWidth)-'.(!empty(cookie:enigmaeviewsplitter) ? cookie:enigmaviewsplitter+5 : 220).')+\\'px\\');') : ''" />
-}
-</style>
-</head>
-<body class="iframe" onload="rcube_init_mail_ui()">
-
-<div id="prefs-title" class="boxtitle"><roundcube:label name="enigma.enigmakeys" /></div>
-<div id="prefs-details" class="boxcontent">
-
-<div id="keystoolbar">
- <roundcube:button command="plugin.enigma-key-create" type="link" class="buttonPas create" classAct="button create" classSel="button createSel" title="enigma.createkeys" content=" " />
- <roundcube:button command="plugin.enigma-key-delete" type="link" class="buttonPas delete" classAct="button delete" classSel="button deleteSel" title="enigma.deletekeys" content=" " />
- <span class="separator">&nbsp;</span>
- <roundcube:button command="plugin.enigma-key-import" type="link" class="buttonPas import" classAct="button import" classSel="button importSel" title="enigma.importkeys" content=" " />
- <roundcube:button command="plugin.enigma-key-export" type="link" class="buttonPas export" classAct="button export" classSel="button exportSel" title="enigma.exportkeys" content=" " />
- <roundcube:button name="messagemenulink" id="messagemenulink" type="link" class="button keymenu" title="enigma.keyactions" onclick="rcmail_ui.show_popup('messagemenu');return false" content=" " />
-</div>
-
-<div id="quicksearchbar" style="top: 35px; right: 10px;">
- <roundcube:button name="searchmenulink" id="searchmenulink" image="/images/icons/glass.png" />
- <roundcube:object name="searchform" id="quicksearchbox" />
- <roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" />
-</div>
-
-<div class="enigmascreen">
-
-<div id="enigmakeyslist">
-<div class="boxtitle"><roundcube:label name="enigma.keyname" /></div>
-<div class="boxlistcontent">
- <roundcube:object name="keyslist" id="keys-table" class="records-table" cellspacing="0" noheader="true" />
-</div>
-<div class="boxfooter">
-<div id="keylistcountbar" class="pagenav">
- <roundcube:button command="firstpage" type="link" class="buttonPas firstpage" classAct="button firstpage" classSel="button firstpageSel" title="firstpage" content=" " />
- <roundcube:button command="previouspage" type="link" class="buttonPas prevpage" classAct="button prevpage" classSel="button prevpageSel" title="previouspage" content=" " />
- <roundcube:object name="countdisplay" style="padding:0 .5em; float:left" />
- <roundcube:button command="nextpage" type="link" class="buttonPas nextpage" classAct="button nextpage" classSel="button nextpageSel" title="nextpage" content=" " />
- <roundcube:button command="lastpage" type="link" class="buttonPas lastpage" classAct="button lastpage" classSel="button lastpageSel" title="lastpage" content=" " />
-</div>
-</div>
-</div>
-
-<script type="text/javascript">
- var enigmaviewsplit = new rcube_splitter({id:'enigmaviewsplitter', p1: 'enigmakeyslist', p2: 'enigmacontent-box', orientation: 'v', relative: true, start: 215});
- rcmail.add_onload('enigmaviewsplit.init()');
-</script>
-
-<div id="enigmacontent-box">
- <roundcube:object name="keyframe" id="keyframe" width="100%" height="100%" frameborder="0" src="/watermark.html" />
-</div>
-
-</div>
-</div>
-
-<div id="messagemenu" class="popupmenu">
- <ul class="toolbarmenu">
- <li><roundcube:button class="disablelink" command="enigma.key-disable" label="enigma.keydisable" target="_blank" classAct="disablelink active" /></li>
- <li><roundcube:button class="revokelink" command="enigma.key-revoke" label="enigma.keyrevoke" classAct="revokelink active" /></li>
- <li class="separator_below"><roundcube:button class="sendlink" command="enigma.key-send" label="enigma.keysend" classAct="sendlink active" /></li>
- <li><roundcube:button class="chpasslink" command="enigma.key-chpass" label="enigma.keychpass" classAct="chpasslink active" /></li>
- </ul>
-</div>
-
-</body>
-</html>
diff --git a/program/include/iniset.php b/program/include/iniset.php
index 46a76a4bd..b4027ecbd 100755
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -36,7 +36,7 @@ foreach ($crit_opts as $optname => $optval) {
}
// application constants
-define('RCMAIL_VERSION', '0.4-trunk');
+define('RCMAIL_VERSION', '0.4.1');
define('RCMAIL_CHARSET', 'UTF-8');
define('JS_OBJECT_NAME', 'rcmail');
define('RCMAIL_START', microtime(true));
diff --git a/tests/mailfunc.php b/tests/mailfunc.php
deleted file mode 100644
index a3008a646..000000000
--- a/tests/mailfunc.php
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-
-/**
- * Test class to test steps/mail/func.inc functions
- *
- * @package Tests
- */
-class rcube_test_mailfunc extends UnitTestCase
-{
-
- function __construct()
- {
- $this->UnitTestCase('Mail body rendering tests');
-
- // simulate environment to successfully include func.inc
- $GLOBALS['RCMAIL'] = $RCMAIL = rcmail::get_instance();
- $GLOBALS['OUTPUT'] = $OUTPUT = $RCMAIL->load_gui();
- $RCMAIL->action = 'autocomplete';
- $RCMAIL->imap_init(false);
- $IMAP = $RCMAIL->imap;
-
- require_once 'steps/mail/func.inc';
-
- $GLOBALS['EMAIL_ADDRESS_PATTERN'] = $EMAIL_ADDRESS_PATTERN;
- }
-
- /**
- * Helper method to create a HTML message part object
- */
- function get_html_part($body)
- {
- $part = new rcube_message_part;
- $part->ctype_primary = 'text';
- $part->ctype_secondary = 'html';
- $part->body = file_get_contents(TESTS_DIR . $body);
- $part->replaces = array();
- return $part;
- }
-
- /**
- * Test sanitization of a "normal" html message
- */
- function test_html()
- {
- $part = $this->get_html_part('src/htmlbody.txt');
- $part->replaces = array('ex1.jpg' => 'part_1.2.jpg', 'ex2.jpg' => 'part_1.2.jpg');
-
- // render HTML in normal mode
- $html = rcmail_html4inline(rcmail_print_body($part, array('safe' => false)), 'foo');
-
- $this->assertPattern('/src="'.$part->replaces['ex1.jpg'].'"/', $html, "Replace reference to inline image");
- $this->assertPattern('#background="./program/blocked.gif"#', $html, "Replace external background image");
- $this->assertNoPattern('/ex3.jpg/', $html, "No references to external images");
- $this->assertNoPattern('/<meta [^>]+>/', $html, "No meta tags allowed");
- //$this->assertNoPattern('/<style [^>]+>/', $html, "No style tags allowed");
- $this->assertNoPattern('/<form [^>]+>/', $html, "No form tags allowed");
- $this->assertPattern('/Subscription form/', $html, "Include <form> contents");
- $this->assertPattern('/<!-- input ignored -->/', $html, "No input elements allowed");
- $this->assertPattern('/<!-- link ignored -->/', $html, "No external links allowed");
- $this->assertPattern('/<a[^>]+ target="_blank">/', $html, "Set target to _blank");
- $this->assertTrue($GLOBALS['REMOTE_OBJECTS'], "Remote object detected");
-
- // render HTML in safe mode
- $html2 = rcmail_html4inline(rcmail_print_body($part, array('safe' => true)), 'foo');
-
- $this->assertPattern('/<style [^>]+>/', $html2, "Allow styles in safe mode");
- $this->assertPattern('#src="http://evilsite.net/mailings/ex3.jpg"#', $html2, "Allow external images in HTML (safe mode)");
- $this->assertPattern("#url\('?http://evilsite.net/newsletter/image/bg/bg-64.jpg'?\)#", $html2, "Allow external images in CSS (safe mode)");
-
- $css = '<link rel="stylesheet" type="text/css" href="?_task=utils&amp;_action=modcss&amp;u='.urlencode('http://anysite.net/styles/mail.css').'&amp;c=foo"';
- $this->assertPattern('#'.preg_quote($css).'#', $html2, "Filter external styleseehts with bin/modcss.php");
- }
-
- /**
- * Test the elimination of some trivial XSS vulnerabilities
- */
- function test_html_xss()
- {
- $part = $this->get_html_part('src/htmlxss.txt');
- $washed = rcmail_print_body($part, array('safe' => true));
-
- $this->assertNoPattern('/src="skins/', $washed, "Remove local references");
- $this->assertNoPattern('/\son[a-z]+/', $washed, "Remove on* attributes");
-
- $html = rcmail_html4inline($washed, 'foo');
- $this->assertNoPattern('/onclick="return rcmail.command(\'compose\',\'xss@somehost.net\',this)"/', $html, "Clean mailto links");
- $this->assertNoPattern('/alert/', $html, "Remove alerts");
- }
-
- /**
- * Test HTML sanitization to fix the CSS Expression Input Validation Vulnerability
- * reported at http://www.securityfocus.com/bid/26800/
- */
- function test_html_xss2()
- {
- $part = $this->get_html_part('src/BID-26800.txt');
- $washed = rcmail_print_body($part, array('safe' => true));
-
- $this->assertNoPattern('/alert|expression|javascript|xss/', $washed, "Remove evil style blocks");
- $this->assertNoPattern('/font-style:italic/', $washed, "Allow valid styles");
- }
-
- /**
- * Test links pattern replacements in plaintext messages
- */
- function test_plaintext()
- {
- $part = new rcube_message_part;
- $part->ctype_primary = 'text';
- $part->ctype_secondary = 'plain';
- $part->body = quoted_printable_decode(file_get_contents(TESTS_DIR . 'src/plainbody.txt'));
- $html = rcmail_print_body($part, array('safe' => true));
-
- $this->assertPattern('/<a href="mailto:nobody@roundcube.net" onclick="return rcmail.command\(\'compose\',\'nobody@roundcube.net\',this\)">nobody@roundcube.net<\/a>/', $html, "Mailto links with onclick");
- $this->assertPattern('#<a href="http://www.apple.com/legal/privacy/" target="_blank">http://www.apple.com/legal/privacy/</a>#', $html, "Links with target=_blank");
- }
-
- /**
- * Test mailto links in html messages
- */
- function test_mailto()
- {
- $part = $this->get_html_part('src/mailto.txt');
-
- // render HTML in normal mode
- $html = rcmail_html4inline(rcmail_print_body($part, array('safe' => false)), 'foo');
-
- $mailto = '<a href="mailto:me@me.com?subject=this is the subject&amp;body=this is the body"'
- .' onclick="return rcmail.command(\'compose\',\'me@me.com?subject=this is the subject&amp;body=this is the body\',this)">e-mail</a>';
-
- $this->assertPattern('|'.preg_quote($mailto, '|').'|', $html, "Extended mailto links");
- }
-
-}
-
-?> \ No newline at end of file
diff --git a/tests/modcss.php b/tests/modcss.php
deleted file mode 100644
index 3ff5c4895..000000000
--- a/tests/modcss.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * Test class to test rcmail_mod_css_styles and XSS vulnerabilites
- *
- * @package Tests
- */
-class rcube_test_modcss extends UnitTestCase
-{
-
- function __construct()
- {
- $this->UnitTestCase('CSS modification and vulnerability tests');
- }
-
- function test_modcss()
- {
- $css = file_get_contents(TESTS_DIR . 'src/valid.css');
- $mod = rcmail_mod_css_styles($css, 'rcmbody');
-
- $this->assertPattern('/#rcmbody\s+\{/', $mod, "Replace body style definition");
- $this->assertPattern('/#rcmbody h1\s\{/', $mod, "Prefix tag styles (single)");
- $this->assertPattern('/#rcmbody h1, #rcmbody h2, #rcmbody h3, #rcmbody textarea\s+\{/', $mod, "Prefix tag styles (multiple)");
- $this->assertPattern('/#rcmbody \.noscript\s+\{/', $mod, "Prefix class styles");
- }
-
- function test_xss()
- {
- $mod = rcmail_mod_css_styles("body.main2cols { background-image: url('../images/leftcol.png'); }", 'rcmbody');
- $this->assertEqual("/* evil! */", $mod, "No url() values allowed");
-
- $mod = rcmail_mod_css_styles("@import url('http://localhost/somestuff/css/master.css');", 'rcmbody');
- $this->assertEqual("/* evil! */", $mod, "No import statements");
-
- $mod = rcmail_mod_css_styles("left:expression(document.body.offsetWidth-20)", 'rcmbody');
- $this->assertEqual("/* evil! */", $mod, "No expression properties");
-
- $mod = rcmail_mod_css_styles("left:exp/* */ression( alert(&#039;xss3&#039;) )", 'rcmbody');
- $this->assertEqual("/* evil! */", $mod, "Don't allow encoding quirks");
-
- $mod = rcmail_mod_css_styles("background:\\0075\\0072\\006c( javascript:alert(&#039;xss&#039;) )", 'rcmbody');
- $this->assertEqual("/* evil! */", $mod, "Don't allow encoding quirks (2)");
- }
-
-} \ No newline at end of file
diff --git a/tests/runtests.sh b/tests/runtests.sh
deleted file mode 100755
index daa88140b..000000000
--- a/tests/runtests.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/*
- +-----------------------------------------------------------------------+
- | tests/runtests.sh |
- | |
- | This file is part of the Roundcube Webmail client |
- | Copyright (C) 2009, Roundcube Dev. - Switzerland |
- | Licensed under the GNU GPL |
- | |
- | PURPOSE: |
- | Run-script for unit tests based on http://simpletest.org |
- | All .php files in this folder will be treated as tests |
- +-----------------------------------------------------------------------+
- | Author: Thomas Bruederli <roundcube@gmail.com> |
- +-----------------------------------------------------------------------+
-
- $Id: $
-
-*/
-
-if (php_sapi_name() != 'cli')
- die("Not in shell mode (php-cli)");
-
-if (!defined('SIMPLETEST')) define('SIMPLETEST', '/www/simpletest/');
-if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
-
-define('TESTS_DIR', dirname(__FILE__) . '/');
-define('RCMAIL_CONFIG_DIR', TESTS_DIR . 'config');
-
-require_once(SIMPLETEST . 'unit_tester.php');
-require_once(SIMPLETEST . 'reporter.php');
-require_once(INSTALL_PATH . 'program/include/iniset.php');
-
-if (count($_SERVER['argv']) > 1) {
- $testfiles = array();
- for ($i=1; $i < count($_SERVER['argv']); $i++)
- $testfiles[] = realpath('./' . $_SERVER['argv'][$i]);
-}
-else {
- $testfiles = glob(TESTS_DIR . '*.php');
-}
-
-$test = new TestSuite('Roundcube unit tests');
-$reporter = new TextReporter();
-
-foreach ($testfiles as $fn) {
- $test->addTestFile($fn);
-}
-
-$test->run($reporter);
-
-?> \ No newline at end of file
diff --git a/tests/src/BID-26800.txt b/tests/src/BID-26800.txt
deleted file mode 100644
index 513516c09..000000000
--- a/tests/src/BID-26800.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-<h1>1 test</h1>
-<p>&lt;style&gt; block</p>
-<style>input { left:expression( alert(&#039;expression!&#039;) ) }</style>
-<style>div { background:url(alert(&#039;URL!&#039;) ) }</style>
-
-<h1>2 test</h1>
-<p>&lt;div&gt; block</p>
-<div style="font-style:italic">valid css</div>
-<div style="{ left:expression( alert(&#039;expression!&#039;) ) }">
-<div style="{ background:url( alert(&#039;URL!&#039;) ) }">
-
-<h1>3 test</h1>
-<p>Inject comment text</p>
-<div style="{ left:exp/* */ression( alert(&#039;xss3&#039;) ) }">
-<div style="{ background:u/* */rl( alert(&#039;xssurl3&#039;) ) }">
-
-<h1>4 test</h1>
-<p>Using reverse solid to directe the codepoint</p>
-<div style="{ left:\0065\0078pression( alert(&#039;xss4&#039;) ) }">
-<div style="{ background:\0075rl( alert(&#039;xssurl4&#039;) ) }">
-
-<h1>5 test</h1>
-<p>Character entity references</p>
-<p>Character entity references is acceptable in "inline styles"</p>
-<div style="{ left:&#x0065;xpression( alert(&#039;xss&#039;) ) }">
-<div style="{ left:&#101;xpression( alert(&#039;xss&#039;) ) }">
-<div style="{ background:&#x0075;rl( alert(&#039;URL!&#039;) ) }">
-<div style="{ background:&#117;rl( alert(&#039;URL!&#039;) ) }">
-<div style="{ left:&#x0065xpression( alert(&#039;xss&#039;) ) }">
-
-<div style="{ left:..p.....o.( alert(&#039;xss&#039;) ) }">
-<div style="{ left:..&#x2f;**/pression( alert(&#039;xss&#039;) ) }">
-<div style="{ left:exp&#x0280;essio&#x0274;( alert(&#039;xss&#039;) ) }">
-<div style="{ left:&#x5c;0065&#x5c;0078pression( alert(&#039;xss&#039;) ) }">
-<div style="{ left:ex p ression( alert(&#039;xss&#039;) ) }">
-
-<div style="{ background:...( javascript:alert(&#039;xss&#039;) ) }">
-<div style="{ background:&#x0075;/**/rl( javascript:alert(&#039;xss&#039;) ) }">
-<div style="{ background:\0075\0072\006c( javascript:alert(&#039;xss&#039;) ) }">
-<div style="{ background:u&#x0280;&#x029F;( javascript:alert(&#039;xss&#039;) )
-}">
-<div style="{ background:&#x5c;0075&#x5c;0280l( javascript:alert(&#039;xss&#039;)
-) }">
-<div style="{ background:u r l( javascript:alert(&#039;xss&#039;) ) }">
-
-</body>
-</html>
-
diff --git a/tests/src/apple.vcf b/tests/src/apple.vcf
deleted file mode 100644
index 856eaf328..000000000
--- a/tests/src/apple.vcf
+++ /dev/null
@@ -1,49 +0,0 @@
-BEGIN:VCARD
-VERSION:3.0
-N:;;;;
-FN:Apple Computer AG
-ORG:Apple Computer AG;
-item1.ADR;type=WORK;type=pref:;;Birgistrasse 4a;Wallisellen-Zürich;;8304;Switzerland
-item1.X-ABADR:ch
-item2.URL;type=pref:http\://www.apple.ch
-item2.X-ABLabel:_$!<HomePage>!$_
-PHOTO;BASE64:
- /9j/4AAQSkZJRgABAQAAAQABAAD/7QAcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAD/2wBDAAEB
- AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
- AQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
- AQEBAQEBAQEBAQEBAQEBAQH/wAARCAAwADADAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAA
- AAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEI
- I0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlq
- c3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW
- 19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL
- /8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLR
- ChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
- hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn
- 6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/igAoAKAPmH43ftT+CfgzqNt4bNjeeLvGV2IHXw7
- pVxDbLZx3LBbdtU1GVLhbN7jIMFvHa3VzIpWRoY4mWQ9dDCTrrmuoQ/mavfvZXV7dW2jkr4ynQfL
- Zzn1inZL1lZ6+ST87H0lp1zLe6fY3k9s1nNd2dtczWjv5j2ss8KSyWzybU3tA7mJn2JuKk7Vzgcr
- Vm1e9m1fvrv8zqi+aKbVm0nbtdXt8i5SGFAHHeOfH3hH4b6DP4k8Z61a6JpUBCCW4LPNdTsCUtbK
- 1iD3F5dSYO2C3jd8AuwVFZhdOnOrLlhFyf4Lzb6IzqVYUo81SSiundvslu3/AEz5i0n9u74Fanqo
- 064m8UaNbvII49X1TRUGnnORvmFje3t5BGTjDtatwcyCPBrreArpX9xvqlJ3/FJP7zlWYUHKzVRL
- +ZxVvnaTa+4+QLvVPgJ4U+LutfFXx78QJfi3q954iuvEOieHvBmkyzaVbO1x5ulPruq6pLawTvp1
- uLdIrK08xFmgXzl2oI67LV50o0qdP2K5VGUptKXnyxi29XfVtb6HDehGtKpUm6zcnNKCfK9brnlK
- 3pZJ37pH3/8ACj9qb4T/ABd1FdD0TUr3SPETozwaJ4ht47C5vQgLONOnjnuLS8dVBYwJOt1tDMIN
- oLV51XCVqK5pJSj1cW3b1uk1vvqvM9Kji6VZ8qbjJ7KVlf0abTf4n0dXMdQUAfhf+2J8UNW8ffFz
- W9Cnlki0XwDqOp+GdNsFdhB9qsr6a31DUDHu2tcXbwojSEbhFCka4Uc+9hKUadGMl8VRKcn11V0v
- RJng4urKpWkntTlKCXTRtN+re58n11HKFAH6PfsGfBvQfEl3rHxR8Q2y38vhrUrfT/DNpIT5FvqY
- iF1carIgI8ye2R4Y7RXykbySTbS6xlfOx9aUVGlF2503N+W1vnrc9HAUYzlKrJX5GuVf3t7+dvu3
- vc/WKvIPXCgD8FP2s/BF/wCC/jd4wlu0It/Fmp6h4usJf4JINZ1G7ndVbu0UpZZBztY446V9BhZq
- dCnZ/DFQfrFJHz+Kg4V6l/tSc15qTb/rzPmqug5woA++v2J/j74d+HN9rHgLxndrpmjeJr62vtJ1
- mbP2Sw1dY/s0ltfOM+Rb30Yh8u5ZTHFPEFlZEk3Dgx2HlVUZw1lBNOPVp9vNa6X22137sFiI0ZSh
- N2jNpqXSLSe/k+/R+p+w1eMe0FAHxz+2P8DLr4r+CIPEPhy2Nx4y8FJdXVnaxrmfWdGlAk1DSosK
- WkuozEt5p8fHmTLNADuuQR24KuqU3GTtCpbXtLo32T2b9GcWNw7qwU4q84X06yi9Wl531XfXyPxK
- ME4nNsYZRciUwG3MbicTh/LMJix5glD/ACGPbv3/AC4zxXtniFvUNJ1XSmjXVNM1DTWmUvCuoWVz
- ZtKgxloxcRxmRRkZZcgZGTzSTT2afo7hqtz6w/ZB+BV78UPHtl4n1eykHgfwdewajfXE0bCDVtVt
- mE+n6PAzAJOBOkdxqAUssdsnlSDNwoPLi66pU3FP95NNJdk95P06d35XOvCUHWqJtfu4NOT7vdR8
- 7vfsvVH7gV4R7oUAFAHKReA/A8Gsy+IofBnhSHxBO7ST67F4d0iPWZnb7zy6mlmL2R2/iZ5yT3NX
- 7Spbl9pPl/l55W+69iPZUubm9nDmvfm5I81+97XuX9a8MeGvEtsLLxF4e0PX7MMGFprWk2Gq2wZe
- jCC+t54tw7HZkdqUZzg7wlKL7xk4v700OUIT0lCMl2lFS/NMuaXpOlaHZQ6Zoumafo+nW4It9P0u
- yttPsoATkiG1tI4oIgTyQkagnmk5Sk7ybk+7bb+96jjGMVaMVFdopJfcjQpDP//Z
-X-ABShowAs:COMPANY
-X-ABUID:2E4CB084-4767-4C85-BBCA-805B1DCB1C8E\:ABPerson
-END:VCARD
diff --git a/tests/src/htmlbody.txt b/tests/src/htmlbody.txt
deleted file mode 100644
index 66286e61d..000000000
--- a/tests/src/htmlbody.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
-<title>Roundcube Test Message</title>
-<link rel="stylesheet" type="text/css" href="http://anysite.net/styles/mail.css">
-<style type="text/css">
-
-p, a {
- font-family: Arial, 'Bitstream Vera Sans', Helvetica;
- margin-top: 0px;
- margin-bottom: 0px;
- padding-top: 0px;
- padding-bottom: 0px;
-}
-
-</style>
-</head>
-<body style="margin: 0 0 0 0;">
-
-<table width="100%" cellpadding="0" cellspacing="20" style="background-image:url(http://evilsite.net/newsletter/image/bg/bg-64.jpg);background-attachment:fixed;" background="http://evilsite.net/newsletter/image/bg/bg-64.jpg" border="0">
-<tr>
-<td>
-
-<h1>This is a HTML message</h1>
-
-<p>See nice pictures like the following:</p>
-
-<div>
- <img src="ex1.jpg" width="320" height="320" alt="Example 1">
- <img src="ex2.jpg" width="320" height="320" alt="Example 2">
- <img src="http://evilsite.net/mailings/ex3.jpg" width="320" height="320" alt="Example 3">
-</div>
-
-<form action="http://evilsite.net/subscribe.php">
- <p>Subscription form</p>
-
- E-Mail: <input type="text" name="mail" value=""><br/>
- <input type="submit" value="Subscribe">
-
-</form>
-
-<p>To unsubscribe click here <a href="http://evilsite.net/unsubscribe.php?mail=foo@bar.com"> or
- send a mail to <a href="mailto:unsubscribe@evilsite.net">unsubscribe@evilsite.net</a></p>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html> \ No newline at end of file
diff --git a/tests/src/htmlxss.txt b/tests/src/htmlxss.txt
deleted file mode 100644
index f6c43e353..000000000
--- a/tests/src/htmlxss.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-<html>
-<body>
-
-<p><img onLoad.="alert(document.cookie)" src="skins/default/images/roundcube_logo.png" /></p>
-
-<p><a href="mailto:xss@somehost.net') && alert(document.cookie) || ignore('">mail me!</a>
-<a href="http://roundcube.net" target="_self">roundcube.net</a>
-<a href="http://roundcube.net" \onmouseover="alert('XSS')">roundcube.net (2)</a>
-
-</p>
-
-<div>Brilliant!</div>
-
-<table><tbody><tr><td background="javascript:alert('XSS')">BBBBBB</td></tr></tbody></table>
-
-<p>
-Have a nice Christmas time.<br />
-Thomas
-</p>
-
-</body>
-</html>
diff --git a/tests/src/johndoe.vcf b/tests/src/johndoe.vcf
deleted file mode 100644
index 67b649df3..000000000
--- a/tests/src/johndoe.vcf
+++ /dev/null
@@ -1,11 +0,0 @@
-BEGIN:VCARD
-VERSION:2.1
-N;CHARSET=windows-1252:Do;John;;;
-FN;CHARSET=windows-1252:John Do
-ORG:roundcube.net;
-EMAIL;INTERNET;WORK:inbox@roundcube.net
-EMAIL;INTERNET;HOME;TYPE=pref:roundcube@gmail.com
-TEL;WORK:+123456789
-ADR;WORK:;;The street;Hometown;;5555;Cayman Islands
-NOTE:The notes...
-END:VCARD
diff --git a/tests/src/mailto.txt b/tests/src/mailto.txt
deleted file mode 100644
index e70b12de8..000000000
--- a/tests/src/mailto.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-<head></head>
-<body>
-
-<a href="mailto:me@me.com?subject=this is the subject&body=this is the body">e-mail</a>
-
-</body>
-</html> \ No newline at end of file
diff --git a/tests/src/plainbody.txt b/tests/src/plainbody.txt
deleted file mode 100644
index 7ebfe429b..000000000
--- a/tests/src/plainbody.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-From: iPhone Developer Program <noreply-iphonedev@apple.com>
-To: nobody@roundcube.net
-
-*iPhone Developer Program*
-
------------------------------------
-iPhone SDK 2.2.1 is now available
-https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=3D=
-D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620&path=3D//i=
-phone/login.action
-
-Log in to the iPhone Dev Center to download iPhone SDK for iPhone OS 2.2.1.=
- Installation of iPhone SDK 2.2.1 is required for development with devices =
-updated to iPhone OS 2.2.1. Please view the Read Me before installing the n=
-ew version of the iPhone SDK.
-
-Log in now
-https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=3D=
-D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620&path=3D//i=
-phone/login.action
-
------------------------------------
-Copyright (c) 2009 Apple Inc. 1 Infinite Loop, MS 303-3DM, Cupertino, CA 95=
-014.
-
-All Rights Reserved
-http://www.apple.com/legal/default.html
-
-Keep Informed
-http://www.apple.com/enews/subscribe/
-
-Privacy Policy
-http://www.apple.com/legal/privacy/
-
-My Info
-https://myinfo.apple.com/cgi-bin/WebObjects/MyInfo
-
diff --git a/tests/src/valid.css b/tests/src/valid.css
deleted file mode 100644
index 340fa9a87..000000000
--- a/tests/src/valid.css
+++ /dev/null
@@ -1,30 +0,0 @@
-/** Master style definitions **/
-
-body, p, div, h1, h2, h3, textarea {
- font-family: "Lucida Grande", Helvetica, sans-serif;
- font-size: 8.8pt;
- color: #333;
-}
-
-body {
- background-color: white;
- margin: 0;
-}
-
-h1 {
- color: #1F519A;
- font-size: 1.7em;
- font-weight: normal;
- margin-top: 0;
- margin-bottom: 1em;
-}
-
-.noscript {
- display: none;
-}
-
-.hint, .username {
- color: #999;
-}
-
-
diff --git a/tests/vcards.php b/tests/vcards.php
deleted file mode 100644
index 72c687484..000000000
--- a/tests/vcards.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-/**
- * Unit tests for class rcube_vcard
- *
- * @package Tests
- */
-class rcube_test_vcards extends UnitTestCase
-{
-
- function __construct()
- {
- $this->UnitTestCase('Vcard encoding/decoding tests');
- }
-
- function _srcpath($fn)
- {
- return realpath(dirname(__FILE__) . '/src/' . $fn);
- }
-
- function test_parse_one()
- {
- $vcard = new rcube_vcard(file_get_contents($this->_srcpath('apple.vcf')));
-
- $this->assertEqual(true, $vcard->business, "Identify as business record");
- $this->assertEqual("Apple Computer AG", $vcard->displayname, "FN => displayname");
- $this->assertEqual("", $vcard->firstname, "No person name set");
- }
-
- function test_parse_two()
- {
- $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
-
- $this->assertEqual(false, $vcard->business, "Identify as private record");
- $this->assertEqual("John Doë", $vcard->displayname, "Decode according to charset attribute");
- $this->assertEqual("roundcube.net", $vcard->organization, "Test organization field");
- $this->assertEqual(2, count($vcard->email), "List two e-mail addresses");
- $this->assertEqual("roundcube@gmail.com", $vcard->email[0], "Use PREF e-mail as primary");
- }
-
- function test_import()
- {
- $input = file_get_contents($this->_srcpath('apple.vcf'));
- $input .= file_get_contents($this->_srcpath('johndoe.vcf'));
-
- $vcards = rcube_vcard::import($input);
-
- $this->assertEqual(2, count($vcards), "Detected 2 vcards");
- $this->assertEqual("Apple Computer AG", $vcards[0]->displayname, "FN => displayname");
- $this->assertEqual("John Doë", $vcards[1]->displayname, "Displayname with correct charset");
- }
-
-}