Source for file functions.php

Documentation is available at functions.php

  1. <?php
  2.  
  3. /**
  4.  **  mail_fetch/functions.php
  5.  *
  6.  **  Copyright (c) 1999-2006 The SquirrelMail Project Team
  7.  **  Licensed under the GNU GPL. For full terms see the file COPYING.
  8.  *
  9.  **  Functions for the mailfetch plugin.
  10.  *
  11.  **  Original code from LexZEUS <[email protected]>
  12.  **  and [email protected] (extracted from php manual)
  13.  **  Adapted for MailFetch by Philippe Mingo <[email protected]>
  14.  *
  15.  **  $Id: functions.php,v 1.5.2.5 2006/02/03 22:27:52 jervfors Exp $
  16.  **/
  17.  
  18.  
  19. /** declare plugin globals */
  20. global $mail_fetch_allow_unsubscribed;
  21.  
  22. /**
  23.  * Controls use of unsubscribed folders in plugin
  24.  * @global boolean $mail_fetch_allow_unsubscribed 
  25.  * @since 1.5.1 and 1.4.5
  26.  */
  27. $mail_fetch_allow_unsubscribed false;
  28.  
  29. function hex2bin$data {
  30.     /* Original code by [email protected] */
  31.  
  32.     $len strlen($data);
  33.     $newdata '';
  34.     for$i=0$i $len$i += {
  35.         $newdata .= pack"C"hexdecsubstr$data$i2) ) );
  36.     }
  37.     return $newdata;
  38. }
  39.  
  40. function mf_keyED$txt {
  41.     global $MF_TIT;
  42.  
  43.     if!isset$MF_TIT ) ) {
  44.         $MF_TIT "MailFetch Secure for SquirrelMail 1.x";
  45.     }
  46.  
  47.     $encrypt_key md5$MF_TIT );
  48.     $ctr 0;
  49.     $tmp "";
  50.     for$i 0$i strlen$txt )$i++ {
  51.         if$ctr == strlen$encrypt_key ) ) $ctr=0;
  52.         $tmp.= substr$txt$isubstr$encrypt_key$ctr);
  53.         $ctr++;
  54.     }
  55.     return $tmp;
  56. }
  57.  
  58. function encrypt$txt {
  59.     srand(double) microtime(1000000 );
  60.     $encrypt_key md5rand032000 ) );
  61.     $ctr 0;
  62.     $tmp "";
  63.     for$i 0$i strlen$txt )$i++ {
  64.         if ($ctr==strlen($encrypt_key)) $ctr=0;
  65.         $tmp.= substr($encrypt_key,$ctr,1.
  66.             (substr($txt,$i,1substr($encrypt_key,$ctr,1));
  67.         $ctr++;
  68.     }
  69.     return bin2hexmf_keyED$tmp ) );
  70. }
  71.  
  72. function decrypt$txt {
  73.     $txt mf_keyEDhex2bin$txt ) );
  74.     $tmp '';
  75.     for $i=0$i strlen$txt )$i++ {
  76.         $md5 substr$txt$i);
  77.         $i++;
  78.         $tmp.= substr$txt$i$md5 );
  79.     }
  80.     return $tmp;
  81. }
  82.  
  83. /**
  84.  * check mail folder
  85.  * @param stream $imap_stream imap connection resource
  86.  * @param string $imap_folder imap folder name
  87.  * @return boolean true, when folder can be used to store messages.
  88.  * @since 1.5.1 and 1.4.5
  89.  */
  90. function mail_fetch_check_folder($imap_stream,$imap_folder{
  91.  
  92.     // check if folder is subscribed or only exists.
  93.     if (sqimap_mailbox_is_subscribed($imap_stream,$imap_folder)) {
  94.         $ret true;
  95.     elseif ($mail_fetch_allow_unsubscribed && sqimap_mailbox_exists($imap_stream,$imap_folder)) {
  96.         $ret true;
  97.     else {
  98.         $ret false;
  99.     }
  100.  
  101.     // make sure that folder can store messages
  102.     if ($ret && mail_fetch_check_noselect($imap_stream,$imap_folder)) {
  103.         $ret false;
  104.     }
  105.  
  106.     return $ret;
  107. }
  108.  
  109. /**
  110.  * Checks if folder is noselect (can't store messages)
  111.  * 
  112.  * Function does not check if folder subscribed.
  113.  * @param stream $imap_stream imap connection resource
  114.  * @param string $imap_folder imap folder name
  115.  * @return boolean true, when folder has noselect flag. false in any other case.
  116.  * @since 1.5.1 and 1.4.5
  117.  */
  118. function mail_fetch_check_noselect($imap_stream,$imap_folder{
  119.     $boxes=sqimap_mailbox_list($imap_stream);
  120.     foreach($boxes as $box{
  121.         if ($box['unformatted']==$imap_folder{
  122.             return (bool) check_is_noselect($box['raw']);
  123.         }
  124.     }
  125.     return false;
  126. }
  127. ?>

Documentation generated on Sat, 07 Oct 2006 16:31:24 +0300 by phpDocumentor 1.3.0RC6