Пример #1
0
    foreach ($plugins as $name) {
        use_plugin($name);
    }
    // get output and remove whitespace
    $output = trim(ob_get_contents());
    ob_end_clean();
    // if plugins output more than newlines and spacing, stop script execution.
    if (!empty($output)) {
        $plugin_load_error = 'Some output is produced when plugins are loaded. Usually this means there is an error in one of the plugin setup or configuration files. The output was: ' . htmlspecialchars($output);
        do_err($plugin_load_error);
    }
    /**
     * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
     * message and return TRUE if there are any errors in its setup/configuration.
     */
    $plugin_err = boolean_hook_function('configtest', NULL, 1);
    if ($plugin_err) {
        do_err('Some plugin tests failed.');
    } else {
        echo $IND . "Plugins OK.<br />\n";
    }
} else {
    echo $IND . "Plugins are not enabled in config.<br />\n";
}
foreach ($theme as $thm) {
    if (!file_exists($thm['PATH'])) {
        do_err('You have enabled the <i>' . $thm['NAME'] . '</i> theme but I cannot find it (' . $thm['PATH'] . ').', FALSE);
    } elseif (!is_readable($thm['PATH'])) {
        do_err('You have enabled the <i>' . $thm['NAME'] . '</i> theme but I cannot read it (' . $thm['PATH'] . ').', FALSE);
    }
}
Пример #2
0
/**
 * Defines special mailboxes: given a mailbox name, it checks if this is a
 * "special" one: INBOX, Trash, Sent or Draft.
 *
 * Since 1.2.5 function includes special_mailbox hook.<br>
 * Since 1.4.3 hook supports more than one plugin.
 * @param string $box mailbox name
 * @param boolean $include_subs (since 1.5.2 and 1.4.9) if true, subfolders of 
 *  system folders are special. if false, subfolders are not special mailboxes 
 *  unless they are tagged as special in 'special_mailbox' hook.
 * @return boolean
 * @since 1.2.3
 */
function isSpecialMailbox($box, $include_subs = true)
{
    $ret = strtolower($box) == 'inbox' || isTrashMailbox($box, $include_subs) || isSentMailbox($box, $include_subs) || isDraftMailbox($box, $include_subs);
    if (!$ret) {
        $ret = boolean_hook_function('special_mailbox', $box, 1);
    }
    return $ret;
}
Пример #3
0
/**
 * Process messages list form and handle the cache gracefully. If $sButton and
 * $aUid are provided as argument then you can fake a message list submit and
 * use it i.e. in read_body.php for del move next and update the cache
 *
 * @param  resource $imapConnection imap connection
 * @param  array    $aMailbox       (reference) cached mailbox
 * @param  string   $sButton        fake a submit button
 * @param  array    $aUid           fake the $msg array
 * @param  string   $targetMailbox  fake the target mailbox for move operations
 * @param  boolean  $bypass_trash   fake the bypass trash checkbox for delete operations
 * @return string $sError error string in case of an error
 * @since 1.5.1
 * @author Marc Groot Koerkamp
 */
function handleMessageListForm($imapConnection, &$aMailbox, $sButton = '', $aUid = array(), $targetMailbox = '', $bypass_trash = NULL)
{
    /* incoming formdata */
    $sButton = sqgetGlobalVar('moveButton', $sTmp, SQ_FORM) ? 'move' : $sButton;
    $sButton = sqgetGlobalVar('copyButton', $sTmp, SQ_FORM) ? 'copy' : $sButton;
    $sButton = sqgetGlobalVar('expungeButton', $sTmp, SQ_FORM) ? 'expunge' : $sButton;
    $sButton = sqgetGlobalVar('forward', $sTmp, SQ_FORM) ? 'forward' : $sButton;
    $sButton = sqgetGlobalVar('delete', $sTmp, SQ_FORM) ? 'setDeleted' : $sButton;
    $sButton = sqgetGlobalVar('undeleteButton', $sTmp, SQ_FORM) ? 'unsetDeleted' : $sButton;
    $sButton = sqgetGlobalVar('markRead', $sTmp, SQ_FORM) ? 'setSeen' : $sButton;
    $sButton = sqgetGlobalVar('markUnread', $sTmp, SQ_FORM) ? 'unsetSeen' : $sButton;
    $sButton = sqgetGlobalVar('markFlagged', $sTmp, SQ_FORM) ? 'setFlagged' : $sButton;
    $sButton = sqgetGlobalVar('markUnflagged', $sTmp, SQ_FORM) ? 'unsetFlagged' : $sButton;
    if (empty($targetMailbox)) {
        sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_FORM);
    }
    if (is_null($bypass_trash)) {
        sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM);
    }
    sqgetGlobalVar('msg', $msg, SQ_FORM);
    if (sqgetGlobalVar('account', $iAccount, SQ_FORM) === false) {
        $iAccount = 0;
    }
    $sError = '';
    $mailbox = $aMailbox['NAME'];
    /* retrieve the check boxes */
    $aUid = isset($msg) && is_array($msg) ? array_values($msg) : $aUid;
    if (count($aUid) && $sButton != 'expunge') {
        // don't do anything to any messages until we have done security check
        // FIXME: not sure this code really belongs here, but there's nowhere else to put it with this architecture
        sqgetGlobalVar('smtoken', $submitted_token, SQ_FORM, '');
        sm_validate_security_token($submitted_token, -1, TRUE);
        // make sure message UIDs are sanitized (BIGINT)
        foreach ($aUid as $i => $uid) {
            $aUid[$i] = preg_match('/^[0-9]+$/', $uid) ? $uid : '0';
        }
        $aUpdatedMsgs = false;
        $bExpunge = false;
        switch ($sButton) {
            case 'setDeleted':
                // check if id exists in case we come from read_body
                if (count($aUid) == 1 && is_array($aMailbox['UIDSET'][$aMailbox['SETINDEX']]) && !in_array($aUid[0], $aMailbox['UIDSET'][$aMailbox['SETINDEX']])) {
                    break;
                }
                $aUpdatedMsgs = sqimap_msgs_list_delete($imapConnection, $mailbox, $aUid, $bypass_trash);
                $bExpunge = true;
                //}
                break;
            case 'unsetDeleted':
            case 'setSeen':
            case 'unsetSeen':
            case 'setFlagged':
            case 'unsetFlagged':
                // get flag
                $sFlag = substr($sButton, 0, 3) == 'set' ? '\\' . substr($sButton, 3) : '\\' . substr($sButton, 5);
                $bSet = substr($sButton, 0, 3) == 'set' ? true : false;
                $aUpdatedMsgs = sqimap_toggle_flag($imapConnection, $aUid, $sFlag, $bSet, true);
                break;
            case 'move':
                $aUpdatedMsgs = sqimap_msgs_list_move($imapConnection, $aUid, $targetMailbox, true, $mailbox);
                sqsession_register($targetMailbox, 'lastTargetMailbox');
                $bExpunge = true;
                break;
            case 'copy':
                // sqimap_msgs_list_copy returns true or false.
                // If error happens - fourth argument handles it inside function.
                sqimap_msgs_list_copy($imapConnection, $aUid, $targetMailbox, true);
                sqsession_register($targetMailbox, 'lastTargetMailbox');
                break;
            case 'forward':
                $aMsgHeaders = array();
                foreach ($aUid as $iUid) {
                    $aMsgHeaders[$iUid] = $aMailbox['MSG_HEADERS'][$iUid];
                }
                if (count($aMsgHeaders)) {
                    $composesession = attachSelectedMessages($imapConnection, $aMsgHeaders);
                    // dirty hack, add info to $aMailbox
                    $aMailbox['FORWARD_SESSION']['SESSION_NUMBER'] = $composesession;
                    $aMailbox['FORWARD_SESSION']['UIDS'] = $aUid;
                }
                break;
            default:
                // Hook for plugin buttons
                $temp = array(&$sButton, &$aMailbox, $iAccount, $aMailbox['NAME'], &$aUid);
                do_hook('mailbox_display_button_action', $temp);
                break;
        }
        /**
         * $aUpdatedMsgs is an array containing the result of the untagged
         * fetch responses send by the imap server due to a flag change. That
         * response is parsed in an array with msg arrays by the parseFetch function
         */
        if ($aUpdatedMsgs) {
            // Update the message headers cache
            $aDeleted = array();
            foreach ($aUpdatedMsgs as $iUid => $aMsg) {
                if (isset($aMsg['FLAGS'])) {
                    /**
                     * Only update the cached headers if the header is
                     * cached.
                     */
                    if (isset($aMailbox['MSG_HEADERS'][$iUid])) {
                        $aMailbox['MSG_HEADERS'][$iUid]['FLAGS'] = $aMsg['FLAGS'];
                    }
                    /**
                     * Also update flags in message object
                     */
                    //FIXME: WHY are we keeping flags in TWO places?!?  This is error-prone and some core code uses the is_xxxx message object values while other code uses the flags array above.  That's a mess.
                    if (isset($aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'])) {
                        $message = $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'];
                        $message->is_seen = false;
                        $message->is_answered = false;
                        $message->is_forwarded = false;
                        $message->is_deleted = false;
                        $message->is_flagged = false;
                        $message->is_mdnsent = false;
                        foreach ($aMsg['FLAGS'] as $flag => $value) {
                            if (strtolower($flag) == '\\seen' && $value) {
                                $message->is_seen = true;
                            } else {
                                if (strtolower($flag) == '\\answered' && $value) {
                                    $message->is_answered = true;
                                } else {
                                    if (strtolower($flag) == '$forwarded' && $value) {
                                        $message->is_forwarded = true;
                                    } else {
                                        if (strtolower($flag) == '\\deleted' && $value) {
                                            $message->is_deleted = true;
                                        } else {
                                            if (strtolower($flag) == '\\flagged' && $value) {
                                                $message->is_flagged = true;
                                            } else {
                                                if (strtolower($flag) == '$mdnsent' && $value) {
                                                    $message->is_mdnsent = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'] = $message;
                    }
                    /**
                     * Count the messages with the \Delete flag set so we can determine
                     * if the number of expunged messages equals the number of flagged
                     * messages for deletion.
                     */
                    if (isset($aMsg['FLAGS']['\\deleted']) && $aMsg['FLAGS']['\\deleted']) {
                        $aDeleted[] = $iUid;
                    }
                }
            }
            if ($bExpunge && $aMailbox['AUTO_EXPUNGE'] && ($iExpungedMessages = sqimap_mailbox_expunge($imapConnection, $aMailbox['NAME'], true))) {
                if (count($aDeleted) != $iExpungedMessages) {
                    // there are more messages deleted permanently then we expected
                    // invalidate the cache
                    $aMailbox['UIDSET'][$aMailbox['SETINDEX']] = false;
                    $aMailbox['MSG_HEADERS'] = false;
                } else {
                    // remove expunged messages from cache
                    $aUidSet = $aMailbox['UIDSET'][$aMailbox['SETINDEX']];
                    if (is_array($aUidSet)) {
                        // create a UID => array index temp array
                        $aUidSetDummy = array_flip($aUidSet);
                        foreach ($aDeleted as $iUid) {
                            // get the id as well in case of SQM_SORT_NONE
                            if ($aMailbox['SORT'] == SQSORT_NONE) {
                                $aMailbox['ID'] = false;
                                //$iId = $aMailbox['MSG_HEADERS'][$iUid]['ID'];
                                //unset($aMailbox['ID'][$iId]);
                            }
                            // unset the UID and message header
                            unset($aUidSetDummy[$iUid]);
                            unset($aMailbox['MSG_HEADERS'][$iUid]);
                        }
                        $aMailbox['UIDSET'][$aMailbox['SETINDEX']] = array_keys($aUidSetDummy);
                    }
                }
                // update EXISTS info
                if ($iExpungedMessages) {
                    $aMailbox['EXISTS'] -= (int) $iExpungedMessages;
                    $aMailbox['TOTAL'][$aMailbox['SETINDEX']] -= (int) $iExpungedMessages;
                }
                if ($aMailbox['PAGEOFFSET'] - 1 >= $aMailbox['EXISTS']) {
                    $aMailbox['PAGEOFFSET'] = $aMailbox['PAGEOFFSET'] > $aMailbox['LIMIT'] ? $aMailbox['PAGEOFFSET'] - $aMailbox['LIMIT'] : 1;
                    $aMailbox['OFFSET'] = $aMailbox['PAGEOFFSET'] - 1;
                }
            }
        }
    } else {
        if ($sButton == 'expunge') {
            /**
             * on expunge we do not know which messages will be deleted
             * so it's useless to try to sync the cache
             *
             * Close the mailbox so we do not need to parse the untagged expunge
             * responses which do not contain uid info.
             * NB: Closing a mailbox is faster then expunge because the imap
             * server does not need to generate the untagged expunge responses
             */
            sqimap_run_command($imapConnection, 'CLOSE', false, $result, $message);
            $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $aMailbox['NAME'], array(), array());
        } else {
            // this is the same hook as above, but here it is called in the
            // context of not having had any messages selected and if any
            // plugin handles the situation, it should return TRUE so we
            // know this was not an erroneous user action
            //
            global $null;
            $temp = array(&$sButton, &$aMailbox, $iAccount, $aMailbox['NAME'], $null);
            if (!boolean_hook_function('mailbox_display_button_action', $temp, 1) && $sButton) {
                $sError = _("No messages were selected.");
            }
        }
    }
    return $sError;
}
Пример #4
0
 function initStream($message, $domain, $length = 0, $host = '', $port = '', $user = '', $pass = '', $authpop = false, $pop_host = '', $stream_options = array())
 {
     global $use_smtp_tls, $smtp_auth_mech;
     if ($authpop) {
         $this->authPop($pop_host, '', $user, $pass);
     }
     $rfc822_header = $message->rfc822_header;
     $from = $rfc822_header->from[0];
     $to = $rfc822_header->to;
     $cc = $rfc822_header->cc;
     $bcc = $rfc822_header->bcc;
     $content_type = $rfc822_header->content_type;
     // MAIL FROM: <from address> MUST be empty in cae of MDN (RFC2298)
     if ($content_type->type0 == 'multipart' && $content_type->type1 == 'report' && isset($content_type->properties['report-type']) && $content_type->properties['report-type'] == 'disposition-notification') {
         // reinitialize the from object because otherwise the from header somehow
         // is affected. This $from var is used for smtp command MAIL FROM which
         // is not the same as what we put in the rfc822 header.
         $from = new AddressStructure();
         $from->host = '';
         $from->mailbox = '';
     }
     // NB: Using "ssl://" ensures the highest possible TLS version
     // will be negotiated with the server (whereas "tls://" only
     // uses TLS version 1.0)
     //
     if ($use_smtp_tls == 1) {
         if (check_php_version(4, 3) && extension_loaded('openssl')) {
             if (function_exists('stream_socket_client')) {
                 $server_address = 'ssl://' . $host . ':' . $port;
                 $ssl_context = @stream_context_create($stream_options);
                 $connect_timeout = ini_get('default_socket_timeout');
                 // null timeout is broken
                 if ($connect_timeout == 0) {
                     $connect_timeout = 30;
                 }
                 $stream = @stream_socket_client($server_address, $errorNumber, $errorString, $connect_timeout, STREAM_CLIENT_CONNECT, $ssl_context);
             } else {
                 $stream = @fsockopen('ssl://' . $host, $port, $errorNumber, $errorString);
             }
             $this->tls_enabled = true;
         } else {
             /**
              * don't connect to server when user asks for smtps and 
              * PHP does not support it.
              */
             $errorNumber = '';
             $errorString = _("Secure SMTP (TLS) is enabled in SquirrelMail configuration, but used PHP version does not support it.");
         }
     } else {
         $stream = @fsockopen($host, $port, $errorNumber, $errorString);
     }
     if (!$stream) {
         // reset tls state var to default value, if connection fails
         $this->tls_enabled = false;
         // set error messages
         $this->dlv_msg = $errorString;
         $this->dlv_ret_nr = $errorNumber;
         $this->dlv_server_msg = _("Can't open SMTP stream.");
         return 0;
     }
     // get server greeting
     $tmp = fgets($stream, 1024);
     if ($this->errorCheck($tmp, $stream)) {
         return 0;
     }
     /*
      * If $_SERVER['HTTP_HOST'] is set, use that in our HELO to the SMTP
      * server.  This should fix the DNS issues some people have had
      */
     if (sqgetGlobalVar('HTTP_HOST', $HTTP_HOST, SQ_SERVER)) {
         // HTTP_HOST is set
         // optionally trim off port number
         if ($p = strrpos($HTTP_HOST, ':')) {
             $HTTP_HOST = substr($HTTP_HOST, 0, $p);
         }
         $helohost = $HTTP_HOST;
     } else {
         // For some reason, HTTP_HOST is not set - revert to old behavior
         $helohost = $domain;
     }
     // if the host is an IPv4 address, enclose it in brackets
     //
     if (preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', $helohost)) {
         $helohost = '[' . $helohost . ']';
     }
     $hook_result = do_hook('smtp_helo_override', $helohost);
     if (!empty($hook_result)) {
         $helohost = $hook_result;
     }
     /* Lets introduce ourselves */
     fputs($stream, "EHLO {$helohost}\r\n");
     // Read ehlo response
     $tmp = $this->parse_ehlo_response($stream);
     if ($this->errorCheck($tmp, $stream)) {
         // fall back to HELO if EHLO is not supported (error 5xx)
         if ($this->dlv_ret_nr[0] == '5') {
             fputs($stream, "HELO {$helohost}\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
         } else {
             return 0;
         }
     }
     /**
      * Implementing SMTP STARTTLS (rfc2487) in php 5.1.0+
      * http://www.php.net/stream-socket-enable-crypto
      */
     if ($use_smtp_tls === 2) {
         if (function_exists('stream_socket_enable_crypto')) {
             // don't try starting tls, when client thinks that it is already active
             if ($this->tls_enabled) {
                 $this->dlv_msg = _("TLS session is already activated.");
                 return 0;
             } elseif (!array_key_exists('STARTTLS', $this->ehlo)) {
                 // check for starttls in ehlo response
                 $this->dlv_msg = _("SMTP STARTTLS is enabled in SquirrelMail configuration, but used SMTP server does not support it");
                 return 0;
             }
             // issue starttls command
             fputs($stream, "STARTTLS\r\n");
             // get response
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
             // start crypto on connection. suppress function errors.
             if (@stream_socket_enable_crypto($stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
                 // starttls was successful (rfc2487 5.2 Result of the STARTTLS Command)
                 // get new EHLO response
                 fputs($stream, "EHLO {$helohost}\r\n");
                 // Read ehlo response
                 $tmp = $this->parse_ehlo_response($stream);
                 if ($this->errorCheck($tmp, $stream)) {
                     // don't revert to helo here. server must support ESMTP
                     return 0;
                 }
                 // set information about started tls
                 $this->tls_enabled = true;
             } else {
                 /**
                  * stream_socket_enable_crypto() call failed.
                  */
                 $this->dlv_msg = _("Unable to start TLS.");
                 return 0;
                 // Bug: can't get error message. See comments in sqimap_create_stream().
             }
         } else {
             // php install does not support stream_socket_enable_crypto() function
             $this->dlv_msg = _("SMTP STARTTLS is enabled in SquirrelMail configuration, but used PHP version does not support functions that allow to enable encryption on open socket.");
             return 0;
         }
     }
     // FIXME: check ehlo response before using authentication
     // Try authentication by a plugin
     //
     // NOTE: there is another hook in functions/auth.php called "smtp_auth"
     // that allows a plugin to specify a different set of login credentials
     // (so is slightly mis-named, but is too old to change), so be careful
     // that you do not confuse your hook names.
     //
     $smtp_auth_args = array('auth_mech' => $smtp_auth_mech, 'user' => $user, 'pass' => $pass, 'host' => $host, 'port' => $port, 'stream' => $stream);
     if (boolean_hook_function('smtp_authenticate', $smtp_auth_args, 1)) {
         // authentication succeeded
     } else {
         if ($smtp_auth_mech == 'cram-md5' or $smtp_auth_mech == 'digest-md5') {
             // Doing some form of non-plain auth
             if ($smtp_auth_mech == 'cram-md5') {
                 fputs($stream, "AUTH CRAM-MD5\r\n");
             } elseif ($smtp_auth_mech == 'digest-md5') {
                 fputs($stream, "AUTH DIGEST-MD5\r\n");
             }
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
             // At this point, $tmp should hold "334 <challenge string>"
             $chall = substr($tmp, 4);
             // Depending on mechanism, generate response string
             if ($smtp_auth_mech == 'cram-md5') {
                 $response = cram_md5_response($user, $pass, $chall);
             } elseif ($smtp_auth_mech == 'digest-md5') {
                 $response = digest_md5_response($user, $pass, $chall, 'smtp', $host);
             }
             fputs($stream, $response);
             // Let's see what the server had to say about that
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
             // CRAM-MD5 is done at this point.  If DIGEST-MD5, there's a bit more to go
             if ($smtp_auth_mech == 'digest-md5') {
                 // $tmp contains rspauth, but I don't store that yet. (No need yet)
                 fputs($stream, "\r\n");
                 $tmp = fgets($stream, 1024);
                 if ($this->errorCheck($tmp, $stream)) {
                     return 0;
                 }
             }
             // CRAM-MD5 and DIGEST-MD5 code ends here
         } elseif ($smtp_auth_mech == 'none') {
             // No auth at all, just send helo and then send the mail
             // We already said hi earlier, nothing more is needed.
         } elseif ($smtp_auth_mech == 'login') {
             // The LOGIN method
             fputs($stream, "AUTH LOGIN\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
             fputs($stream, base64_encode($user) . "\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
             fputs($stream, base64_encode($pass) . "\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
         } elseif ($smtp_auth_mech == "plain") {
             /* SASL Plain */
             $auth = base64_encode("{$user}{$user}{$pass}");
             $query = "AUTH PLAIN\r\n";
             fputs($stream, $query);
             $read = fgets($stream, 1024);
             if (substr($read, 0, 3) == '334') {
                 // OK so far..
                 fputs($stream, "{$auth}\r\n");
                 $read = fgets($stream, 1024);
             }
             $results = explode(" ", $read, 3);
             $response = $results[1];
             $message = $results[2];
         } else {
             /* Right here, they've reached an unsupported auth mechanism.
                This is the ugliest hack I've ever done, but it'll do till I can fix
                things up better tomorrow.  So tired... */
             if ($this->errorCheck("535 Unable to use this auth type", $stream)) {
                 return 0;
             }
         }
     }
     /* Ok, who is sending the message? */
     $fromaddress = strlen($from->mailbox) && $from->host ? $from->mailbox . '@' . $from->host : '';
     fputs($stream, 'MAIL FROM:<' . $fromaddress . ">\r\n");
     $tmp = fgets($stream, 1024);
     if ($this->errorCheck($tmp, $stream)) {
         return 0;
     }
     /* send who the recipients are */
     for ($i = 0, $cnt = count($to); $i < $cnt; $i++) {
         if (!$to[$i]->host) {
             $to[$i]->host = $domain;
         }
         if (strlen($to[$i]->mailbox)) {
             fputs($stream, 'RCPT TO:<' . $to[$i]->mailbox . '@' . $to[$i]->host . ">\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
         }
     }
     for ($i = 0, $cnt = count($cc); $i < $cnt; $i++) {
         if (!$cc[$i]->host) {
             $cc[$i]->host = $domain;
         }
         if (strlen($cc[$i]->mailbox)) {
             fputs($stream, 'RCPT TO:<' . $cc[$i]->mailbox . '@' . $cc[$i]->host . ">\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
         }
     }
     for ($i = 0, $cnt = count($bcc); $i < $cnt; $i++) {
         if (!$bcc[$i]->host) {
             $bcc[$i]->host = $domain;
         }
         if (strlen($bcc[$i]->mailbox)) {
             fputs($stream, 'RCPT TO:<' . $bcc[$i]->mailbox . '@' . $bcc[$i]->host . ">\r\n");
             $tmp = fgets($stream, 1024);
             if ($this->errorCheck($tmp, $stream)) {
                 return 0;
             }
         }
     }
     /* Lets start sending the actual message */
     fputs($stream, "DATA\r\n");
     $tmp = fgets($stream, 1024);
     if ($this->errorCheck($tmp, $stream)) {
         return 0;
     }
     return $stream;
 }
Пример #5
0
        // we have to redirect to the compose page
        $location = $base_uri . 'src/compose.php?mailbox=' . urlencode($mailbox) . '&session=' . $aMailbox['FORWARD_SESSION']['SESSION_NUMBER'] . '&smaction=forward_as_attachment' . '&fwduid=' . implode('_', $aMailbox['FORWARD_SESSION']['UIDS']);
        header("Location: {$location}");
        exit;
    }
}
// plugins can operate normally here (don't output anything, of course!),
// but can also return TRUE if they want to enable the MOTD display
// even when SM's MOTD is empty (there is plugin output that can
// be then hooked into in motd.tpl)
// NOTE a TRUE return value here will cause the display of the MOTD on
// *every* page view; if a plugin wants to support true MOTD (one-time
// message display upon login), it should also check the value of
// "just_logged_in" in the PHP session before returning TRUE.
//
$show_motd = boolean_hook_function('right_main_after_header', $null, 1);
// get "just_logged_in" from PHP session, save it in a temp variable
// for use below, and reset its value in PHP session
//
if (!sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION)) {
    $just_logged_in = false;
}
$temp_just_logged_in = $just_logged_in;
$just_logged_in = false;
sqsession_register($just_logged_in, 'just_logged_in');
// now we're done with the PHP session, can send output to browser
//
displayPageHeader($color, $mailbox, $onload);
/* display a message to the user that their mail has been sent */
if (isset($mail_sent) && $mail_sent == 'yes') {
    $note = _("Your mail has been sent.");
Пример #6
0
                    if ($depend_requirements['version'] == SQ_INCOMPATIBLE) {
                        $incompatible_plugins .= ', ' . $depend_name;
                    } else {
                        $missing_plugins .= ', ' . $depend_name . ' (version ' . $depend_requirements['version'] . ', ' . ($depend_requirements['activate'] ? 'must be activated' : 'need not be activated') . ')';
                    }
                }
                $error_string = (!empty($incompatible_plugins) ? $name . ' cannot be activated at the same time as the following plugins: ' . trim($incompatible_plugins, ', ') : '') . (!empty($missing_plugins) ? (!empty($incompatible_plugins) ? '.  ' . $name . ' is also ' : $name . ' is ') . 'missing some dependencies: ' . trim($missing_plugins, ', ') : '');
                do_err($error_string, FALSE);
            }
        }
    }
    /**
     * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
     * message and return TRUE if there are any errors in its setup/configuration.
     */
    $plugin_err = boolean_hook_function('configtest', $null, 1);
    if ($plugin_err) {
        do_err('Some plugin tests failed.');
    } else {
        echo $IND . "Plugins OK.<br />\n";
    }
} else {
    echo $IND . "Plugins are not enabled in config.<br />\n";
}
foreach ($theme as $thm) {
    if (!file_exists($thm['PATH'])) {
        do_err('You have enabled the <i>' . $thm['NAME'] . '</i> theme but I cannot find it (' . $thm['PATH'] . ').', FALSE);
    } elseif (!is_readable($thm['PATH'])) {
        do_err('You have enabled the <i>' . $thm['NAME'] . '</i> theme but I cannot read it (' . $thm['PATH'] . ').', FALSE);
    }
}
Пример #7
0
/**
 * Fills mailbox object
 *
 * Some code fragments are present in 1.3.0 - 1.4.4.
 * @param array $mbx_ary
 * @param $mbxs
 * @param stream $imap_stream imap connection resource
 * @return object see mailboxes class
 * @since 1.5.0
 */
function sqimap_fill_mailbox_tree($mbx_ary, $mbxs = false, $imap_stream)
{
    global $data_dir, $username, $list_special_folders_first, $folder_prefix, $trash_folder, $sent_folder, $draft_folder, $move_to_trash, $move_to_sent, $save_as_draft, $delimiter, $imap_server_type;
    // $special_folders = array ('INBOX', $sent_folder, $draft_folder, $trash_folder);
    /* create virtual root node */
    $mailboxes = new mailboxes();
    $mailboxes->is_root = true;
    $trail_del = false;
    $start = 0;
    if (isset($folder_prefix) && $folder_prefix != '') {
        $start = substr_count($folder_prefix, $delimiter);
        if (strrpos($folder_prefix, $delimiter) == strlen($folder_prefix) - 1) {
            $mailboxes->mailboxname_full = substr($folder_prefix, 0, strlen($folder_prefix) - 1);
        } else {
            $mailboxes->mailboxname_full = $folder_prefix;
            $start++;
        }
        $mailboxes->mailboxname_sub = $mailboxes->mailboxname_full;
    } else {
        $start = 0;
    }
    $cnt = count($mbx_ary);
    for ($i = 0; $i < $cnt; $i++) {
        if ($mbx_ary[$i]['mbx'] != '') {
            $mbx = new mailboxes();
            $mailbox = $mbx_ary[$i]['mbx'];
            /*
             * Set the is_special flag if it concerned a special mailbox.
             * Used for displaying the special folders on top in the mailbox
             * tree displaying code.
             */
            $mbx->is_special |= $mbx->is_inbox = strtoupper($mailbox) == 'INBOX';
            $mbx->is_special |= $mbx->is_trash = isTrashMailbox($mailbox);
            $mbx->is_special |= $mbx->is_sent = isSentMailbox($mailbox);
            $mbx->is_special |= $mbx->is_draft = isDraftMailbox($mailbox);
            if (!$mbx->is_special) {
                $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
            }
            if (isset($mbx_ary[$i]['unseen'])) {
                $mbx->unseen = $mbx_ary[$i]['unseen'];
            }
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
            $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            $mbx->is_noinferiors = $mbx_ary[$i]['noinferiors'];
            $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {
                $mbx->mailboxname_sub = substr($mbx_ary[$i]['mbx'], $r_del_pos + 1);
            } else {
                /* mailbox is root folder */
                $mbx->mailboxname_sub = $mbx_ary[$i]['mbx'];
            }
            $mbx->mailboxname_full = $mbx_ary[$i]['mbx'];
            $mailboxes->addMbx($mbx, $delimiter, $start, $list_special_folders_first);
        }
    }
    sqimap_utf7_decode_mbx_tree($mailboxes);
    sqimap_get_status_mbx_tree($imap_stream, $mailboxes);
    return $mailboxes;
}
Пример #8
0
function sqimap_fill_mailbox_tree($mbx_ary, $mbxs = false, $imap_stream)
{
    global $data_dir, $username, $list_special_folders_first, $folder_prefix, $trash_folder, $sent_folder, $draft_folder, $move_to_trash, $move_to_sent, $save_as_draft, $delimiter, $imap_server_type;
    $special_folders = array('INBOX', $sent_folder, $draft_folder, $trash_folder);
    /* create virtual root node */
    $mailboxes = new mailboxes();
    $mailboxes->is_root = true;
    $trail_del = false;
    $start = 0;
    if (isset($folder_prefix) && $folder_prefix != '') {
        $start = substr_count($folder_prefix, $delimiter);
        if (strrpos($folder_prefix, $delimiter) == strlen($folder_prefix) - 1) {
            $trail_del = true;
            $mailboxes->mailboxname_full = substr($folder_prefix, 0, strlen($folder_prefix) - 1);
        } else {
            $mailboxes->mailboxname_full = $folder_prefix;
            $start++;
        }
        $mailboxes->mailboxname_sub = $mailboxes->mailboxname_full;
    } else {
        $start = 0;
    }
    $cnt = count($mbx_ary);
    for ($i = 0; $i < $cnt; $i++) {
        if ($mbx_ary[$i]['mbx'] != '') {
            $mbx = new mailboxes();
            $mailbox = $mbx_ary[$i]['mbx'];
            /*
                sent subfolders messes up using existing code as subfolders
                were marked, but the parents were ordered somewhere else in
                the list, despite having "special folders at top" option set.
                Need a better method than this.
            */
            /*
                        if ($mailbox == 'INBOX') {
                            $mbx->is_special = true;
                        } elseif (stristr($trash_folder , $mailbox)) {
                            $mbx->is_special = true;
                        } elseif (stristr($sent_folder , $mailbox)) {
                            $mbx->is_special = true;
                        } elseif (stristr($draft_folder , $mailbox)) {
                            $mbx->is_special = true;
                        }
            
                        switch ($mailbox) {
                            case 'INBOX':
                                $mbx->is_inbox = true;
                                $mbx->is_special = true;
                                $mbx_ary[$i]['noselect'] = false;
                                break;
                            case $trash_folder:
                                $mbx->is_trash = true;
                                $mbx->is_special = true;
                                break;
                            case $sent_folder:
                                $mbx->is_sent = true;
                                $mbx->is_special = true;
                                break;
                            case $draft_folder:
                                $mbx->is_draft = true;
                                $mbx->is_special = true;
                                break;
                        }
            */
            $mbx->is_special |= $mbx->is_inbox = strtoupper($mailbox) == 'INBOX';
            $mbx->is_special |= $mbx->is_trash = isTrashMailbox($mailbox);
            $mbx->is_special |= $mbx->is_sent = isSentMailbox($mailbox);
            $mbx->is_special |= $mbx->is_draft = isDraftMailbox($mailbox);
            if (!$mbx->is_special) {
                $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
            }
            if (isset($mbx_ary[$i]['unseen'])) {
                $mbx->unseen = $mbx_ary[$i]['unseen'];
            }
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
            $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            $mbx->is_noinferiors = $mbx_ary[$i]['noinferiors'];
            $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {
                $mbx->mailboxname_sub = substr($mbx_ary[$i]['mbx'], $r_del_pos + 1);
            } else {
                /* mailbox is root folder */
                $mbx->mailboxname_sub = $mbx_ary[$i]['mbx'];
            }
            $mbx->mailboxname_full = $mbx_ary[$i]['mbx'];
            $mailboxes->addMbx($mbx, $delimiter, $start, $list_special_folders_first);
        }
    }
    sqimap_utf7_decode_mbx_tree($mailboxes);
    sqimap_get_status_mbx_tree($imap_stream, $mailboxes);
    return $mailboxes;
}
Пример #9
0
    $color[0] = '#dcdcdc';
    /* light gray    TitleBar               */
    $color[1] = '#800000';
    /* red                                  */
    $color[2] = '#cc0000';
    /* light red     Warning/Error Messages */
    $color[4] = '#ffffff';
    /* white         Normal Background      */
    $color[7] = '#0000cc';
    /* blue          Links                  */
    $color[8] = '#000000';
    /* black         Normal text            */
}
// if any plugin returns TRUE here, the standard page header will be skipped
$temp = array($header);
if (!boolean_hook_function('login_before_page_header', $temp, 1)) {
    displayHtmlHeader("{$org_name} - " . _("Login"), $header, FALSE);
}
/* If they don't have a logo, don't bother.. */
$logo_str = '';
if (isset($org_logo) && $org_logo) {
    if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width > 0) {
        $width = $org_logo_width;
    } else {
        $width = '';
    }
    if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height > 0) {
        $height = $org_logo_height;
    } else {
        $height = '';
    }
Пример #10
0
 * return TRUE to the hook so that it knows that
 * the action was handled and was not an unknown
 * action.  If the action was not handled, the plugin
 * should return FALSE to the hook.
 *
 * Developer note: the $rpc_action parameter is passed 
 * in an array in case we can think of more parameters 
 * to add in the future.
 *
 * Known users of this hook:
 *    empty_folders
 *    mark_read
 *
 */
$temp = array(&$rpc_action);
$handled_by_plugin = boolean_hook_function('squirrelmail_rpc', $temp, 1);
/**
 * Go take care of each RPC action (unless plugin already did)
 *
 */
if (!$handled_by_plugin) {
    switch (strtolower($rpc_action)) {
        /**
         * Delete Messages
         *
         */
        case 'delete_messages':
            require_once SM_PATH . 'functions/mailbox_display.php';
            require_once SM_PATH . 'functions/imap.php';
            if (!sqGetGlobalVar('delete_ids', $delete_ids, SQ_FORM)) {
                sm_rpc_return_error($rpc_action, 99, _("No deletion ID given"), 'client', 400, 'Bad Request');