Source for file functions.php
Documentation is available at functions.php
* mail_fetch/functions.php
* Functions for the mailfetch plugin.
* @copyright 1999-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: functions.php 14840 2020-01-07 07:42:38Z pdontthink $
/** declare plugin globals */
global $mail_fetch_allow_unsubscribed;
* Controls use of unsubscribed folders in plugin
* @global boolean $mail_fetch_allow_unsubscribed
$mail_fetch_allow_unsubscribed =
false;
* Validate a requested POP3 port number
* Allowable port numbers are configured in config.php
* (see config_example.php for an example and more
* rules about how the list of allowable port numbers
* @param int $requested_port The port number given by the user
* @return string An error string is returned if the port
* number is not allowable, otherwise an
* empty string is returned.
global $mail_fetch_allowable_ports;
@include_once(SM_PATH .
'plugins/mail_fetch/config.php');
if (empty($mail_fetch_allowable_ports))
$mail_fetch_allowable_ports =
array(110, 995);
if (in_array('ALL', $mail_fetch_allowable_ports))
if (!in_array($requested_port, $mail_fetch_allowable_ports)) {
$error =
_("Sorry, that port number is not allowed");
* Validate a requested POP3 server address
* Blocked server addresses are configured in config.php
* (see config_example.php for more details)
* @param int $requested_address The server address given by the user
* @return string An error string is returned if the server
* address is not allowable, otherwise an
* empty string is returned.
global $mail_fetch_block_server_pattern;
@include_once(SM_PATH .
'plugins/mail_fetch/config.php');
if (empty($mail_fetch_block_server_pattern))
$mail_fetch_block_server_pattern =
'/(^10\.)|(^192\.)|(^127\.)|(^localhost)/';
if ($mail_fetch_block_server_pattern ==
'UNRESTRICTED')
if (preg_match($mail_fetch_block_server_pattern, $requested_address)) {
$error =
_("Sorry, that server address is not allowed");
* hex2bin() only exists since PHP 5.4
for( $i=
0; $i <
$len; $i +=
2 ) {
if( !isset
( $MF_TIT ) ) {
$MF_TIT =
"MailFetch Secure for SquirrelMail 1.x";
$encrypt_key =
md5( $MF_TIT );
for( $i =
0; $i <
strlen( $txt ); $i++
) {
if( $ctr ==
strlen( $encrypt_key ) ) $ctr=
0;
$tmp.=
substr( $txt, $i, 1 ) ^
substr( $encrypt_key, $ctr, 1 );
$encrypt_key =
md5( rand( 0, 32000 ) );
for( $i =
0; $i <
strlen( $txt ); $i++
) {
if ($ctr==
strlen($encrypt_key)) $ctr=
0;
$tmp.=
substr($encrypt_key,$ctr,1) .
for ( $i=
0; $i <
strlen( $txt ); $i++
) {
$tmp.=
( substr( $txt, $i, 1 ) ^
$md5 );
* @param stream $imap_stream imap connection resource
* @param string $imap_folder imap folder name
* @return boolean true, when folder can be used to store messages.
// check if folder is subscribed or only exists.
// make sure that folder can store messages
* Checks if folder is noselect (can't store messages)
* Function does not check if folder subscribed.
* @param stream $imap_stream imap connection resource
* @param string $imap_folder imap folder name
* @return boolean true, when folder has noselect flag. false in any other case.
foreach($boxes as $box) {
if ($box['unformatted']==
$imap_folder) {
Documentation generated on Mon, 13 Jan 2020 04:24:39 +0100 by phpDocumentor 1.4.3