squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

functions.php
Go to the documentation of this file.
1 <?php
2 
21 
28 
44 function validate_mail_fetch_port_number($requested_port) {
46  @include_once(SM_PATH . 'plugins/mail_fetch/config.php');
47  if (empty($mail_fetch_allowable_ports))
48  $mail_fetch_allowable_ports = array(110, 995);
49 
50  if (in_array('ALL', $mail_fetch_allowable_ports))
51  return '';
52 
53  if (!in_array($requested_port, $mail_fetch_allowable_ports)) {
54  sq_change_text_domain('mail_fetch');
55  $error = _("Sorry, that port number is not allowed");
56  sq_change_text_domain('squirrelmail');
57  return $error;
58  }
59 
60  return '';
61 }
62 
76 function validate_mail_fetch_server_address($requested_address) {
78  @include_once(SM_PATH . 'plugins/mail_fetch/config.php');
80  $mail_fetch_block_server_pattern = '/(^10\.)|(^192\.)|(^127\.)|(^localhost)/';
81 
82  if ($mail_fetch_block_server_pattern == 'UNRESTRICTED')
83  return '';
84 
85  if (preg_match($mail_fetch_block_server_pattern, $requested_address)) {
86  sq_change_text_domain('mail_fetch');
87  $error = _("Sorry, that server address is not allowed");
88  sq_change_text_domain('squirrelmail');
89  return $error;
90  }
91 
92  return '';
93 }
94 
95 function hex2bin( $data ) {
96  /* Original code by josh@superfork.com */
97 
98  $len = strlen($data);
99  $newdata = '';
100  for( $i=0; $i < $len; $i += 2 ) {
101  $newdata .= pack( "C", hexdec( substr( $data, $i, 2) ) );
102  }
103  return $newdata;
104 }
105 
106 function mf_keyED( $txt ) {
107  global $MF_TIT;
108 
109  if( !isset( $MF_TIT ) ) {
110  $MF_TIT = "MailFetch Secure for SquirrelMail 1.x";
111  }
112 
113  $encrypt_key = md5( $MF_TIT );
114  $ctr = 0;
115  $tmp = "";
116  for( $i = 0; $i < strlen( $txt ); $i++ ) {
117  if( $ctr == strlen( $encrypt_key ) ) $ctr=0;
118  $tmp.= substr( $txt, $i, 1 ) ^ substr( $encrypt_key, $ctr, 1 );
119  $ctr++;
120  }
121  return $tmp;
122 }
123 
124 function encrypt( $txt ) {
125  srand( (double) microtime() * 1000000 );
126  $encrypt_key = md5( rand( 0, 32000 ) );
127  $ctr = 0;
128  $tmp = "";
129  for( $i = 0; $i < strlen( $txt ); $i++ ) {
130  if ($ctr==strlen($encrypt_key)) $ctr=0;
131  $tmp.= substr($encrypt_key,$ctr,1) .
132  (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
133  $ctr++;
134  }
135  return bin2hex( mf_keyED( $tmp ) );
136 }
137 
138 function decrypt( $txt ) {
139  $txt = mf_keyED( hex2bin( $txt ) );
140  $tmp = '';
141  for ( $i=0; $i < strlen( $txt ); $i++ ) {
142  $md5 = substr( $txt, $i, 1 );
143  $i++;
144  $tmp.= ( substr( $txt, $i, 1 ) ^ $md5 );
145  }
146  return $tmp;
147 }
148 
156 function mail_fetch_check_folder($imap_stream,$imap_folder) {
158 
159  // check if folder is subscribed or only exists.
160  if (sqimap_mailbox_is_subscribed($imap_stream,$imap_folder)) {
161  $ret = true;
163  $ret = true;
164  } else {
165  $ret = false;
166  }
167 
168  // make sure that folder can store messages
169  if ($ret && mail_fetch_check_noselect($imap_stream,$imap_folder)) {
170  $ret = false;
171  }
172 
173  return $ret;
174 }
175 
185 function mail_fetch_check_noselect($imap_stream,$imap_folder) {
187  foreach($boxes as $box) {
188  if ($box['unformatted']==$imap_folder) {
189  return (bool) check_is_noselect($box['raw']);
190  }
191  }
192  return false;
193 }
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
$ret
$ret
Definition: webmail.php:172
$mail_fetch_allow_unsubscribed
global $mail_fetch_allow_unsubscribed
Definition: functions.php:20
$imap_stream
$imap_stream
Definition: bug_report.php:119
sqimap_mailbox_exists
sqimap_mailbox_exists($imap_stream, $mailbox)
Definition: imap_mailbox.php:226
encrypt
encrypt( $txt)
Definition: functions.php:124
mail_fetch_check_noselect
mail_fetch_check_noselect($imap_stream, $imap_folder)
Definition: functions.php:185
$boxes
$boxes
Definition: empty_trash.php:49
mf_keyED
mf_keyED( $txt)
Definition: functions.php:106
$mail_fetch_block_server_pattern
global $mail_fetch_block_server_pattern
Definition: config_example.php:15
mail_fetch_check_folder
mail_fetch_check_folder($imap_stream, $imap_folder)
Definition: functions.php:156
decrypt
decrypt( $txt)
Definition: functions.php:138
hex2bin
hex2bin( $data)
Definition: functions.php:95
$data
$data
Definition: mailto.php:83
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
validate_mail_fetch_port_number
validate_mail_fetch_port_number($requested_port)
Definition: functions.php:44
_
_($str)
Definition: gettext.php:160
$mail_fetch_allowable_ports
global $mail_fetch_allowable_ports
Definition: config_example.php:15
sqimap_mailbox_is_subscribed
sqimap_mailbox_is_subscribed($imap_stream, $folder)
Definition: imap_mailbox.php:348
sq_change_text_domain
sq_change_text_domain($domain_name, $directory='')
Definition: i18n.php:49
validate_mail_fetch_server_address
validate_mail_fetch_server_address($requested_address)
Definition: functions.php:76
sqimap_mailbox_list
sqimap_mailbox_list($imap_stream, $force=false)
Definition: imap_mailbox.php:597
check_is_noselect
check_is_noselect($lsub_line)
Definition: imap_mailbox.php:51