[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.msg.inc.php,NONE,1.1 class.ms
From: |
Dan Kuykendall <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.msg.inc.php,NONE,1.1 class.msg_base.inc.php,NONE,1.1 class.msg_base_sock.inc.php,NONE,1.1 class.msg_imap.inc.php,NONE,1.1 class.msg_imap_sock.inc.php,NONE,1.1 class.msg_nntp.inc.php,NONE,1.1 class.msg_nntp_sock.inc.php,NONE,1.1 class.msg_pop3.inc.php,NONE,1.1 class.msg_pop3_sock.inc.php,NONE,1.1 functions.inc.php,1.134,1.135 |
Date: |
Mon, 06 May 2002 05:05:46 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv25060
Modified Files:
functions.inc.php
Added Files:
class.msg.inc.php class.msg_base.inc.php
class.msg_base_sock.inc.php class.msg_imap.inc.php
class.msg_imap_sock.inc.php class.msg_nntp.inc.php
class.msg_nntp_sock.inc.php class.msg_pop3.inc.php
class.msg_pop3_sock.inc.php
Log Message:
adding msg classes. Still need additional cleanup work on the _sock classes,
but they are good enough to toss in here for now
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare API - php IMAP SO access object constructor
*
* This file written by Mark Peters <address@hidden>
*
* and Angelo Tony Puglisi (Angles) <address@hidden> *
* Handles initializing the appropriate class dcom object
*
* Copyright (C) 2001 Mark Peters
*
*
-------------------------------------------------------------------------
*
* This library is part of the phpGroupWare API
*
* http://www.phpgroupware.org/api
*
*
------------------------------------------------------------------------
*
* 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 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
*
\**************************************************************************/
if (isset($p1) && ($p1) && ( (stristr($p1, 'imap') || stristr($p1,
'pop') || stristr($p1, 'nntp'))))
{
$msg_server_type = $p1;
}
else
{
$msg_server_type =
$GLOBALS['phpgw_info']['user']['preferences']['email']['msg_server_type'];
}
print_debug('msg class constructor, param $p1', $p1);
print_debug('msg class constructor, $msg_server_type',
$msg_server_type);
if (extension_loaded('imap') || function_exists('imap_open'))
{
$imap_builtin = True;
$sock_fname = '';
print_debug('imap builtin extension is available');
}
else
{
$imap_builtin = False;
$sock_fname = '_sock';
print_debug('imap builtin extension NOT available, using socket
class');
}
// ----- include SOCKET or PHP-BUILTIN classes as necessary
if ($imap_builtin == False)
{
CreateObject('phpgwapi.network');
print_debug('created phpgwapi network class used with sockets');
}
//CreateObject('phpgwapi.msg_base'.$sock_fname);
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_base'.$sock_fname.'.inc.php');
if (($msg_server_type == 'imap') || ($msg_server_type ==
'imaps'))
{
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_imap'.$sock_fname.'.inc.php');
}
elseif (($msg_server_type == 'pop3') || ($msg_server_type ==
'pop3s'))
{
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_pop3'.$sock_fname.'.inc.php');
}
elseif ($msg_server_type == 'nntp')
{
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_nntp'.$sock_fname.'.inc.php');
}
elseif ((isset($msg_server_type)) && ($msg_server_type != ''))
{
// educated guess based on info being available:
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_'.$GLOBALS['phpgw_info']['user']['preferences']['email']['msg_server_type'].$sock_fname.'.inc.php');
}
else
{
// DEFAULT FALL BACK:
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.msg_imap.inc.php');
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.msg_base.inc.php'
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare API - MAIL *
* This file written by Mark Peters <address@hidden> *
* Handles general functionality for mail/mail structures *
* Copyright (C) 2001 Mark Peters *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* 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 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 *
[...1065 lines suppressed...]
{
$c0=(ord(substr($str[$i],$pos ,1)) ^
0x20);
$c1=(ord(substr($str[$i],$pos+1,1)) ^
0x20);
$c2=(ord(substr($str[$i],$pos+2,1)) ^
0x20);
$file .= chr(((($c0 - ' ') & 077) << 2)
| ((($c1 - ' ') & 077) >> 4));
$file .= chr(((($c1 - ' ') & 077) << 4)
| ((($c2 - ' ') & 077) >> 2));
$pos+=3;
$d+=2;
}
if (($d+1<=$len) && ($pos+2<=strlen($str[$i])))
{
$c0=(ord(substr($str[$i],$pos ,1)) ^
0x20);
$c1=(ord(substr($str[$i],$pos+1,1)) ^
0x20);
$file .= chr(((($c0 - ' ') & 077) << 2)
| ((($c1 - ' ') & 077) >> 4));
}
}
return $file;
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.msg_imap.inc.php'
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare API - NNTP *
* This file written by Mark Peters <address@hidden> *
* Handles specific operations in dealing with NNTP *
* Copyright (C) 2001 Mark Peters *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* 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 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 *
[...1177 lines suppressed...]
function
fetchbody($stream_notused,$msg_num,$part_num="",$flags="")
{
if ($this->debug >= 1) { echo 'imap: fetchbody<br>'; }
return False;
}
/*!
@function get_body
@abstract implements IMAP_BODY
*/
function
get_body($stream_notused,$msg_num,$flags='',$phpgw_include_header=True)
{
// NEEDED: code for flags: FT_UID; maybe FT_INTERNAL;
FT_NOT; flag FT_PEEK has no effect on POP3
if ($this->debug >= 1) { echo 'imap: get_body<br>'; }
return False;
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.msg_nntp.inc.php'
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare API - NNTP *
* This file written by Mark Peters <address@hidden> *
* Handles specific operations in dealing with NNTP *
* Copyright (C) 2001 Mark Peters *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* 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 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 *
\**************************************************************************/
class msg extends msg_base
{
var $db;
var $folder;
var $start_msg;
var $end_msg;
function mode_reader()
{
return $this->msg2socket('mode reader','^20[01]',&$response);
}
function login ($user,$passwd,$server,$port,$folder = '')
{
global $phpgw;
$this->db = $phpgw->db;
if(@!$server)
{
echo 'Error: Configuration Error! The administrator has
not configured the NNTP Server.';
}
if(@!$port)
{
$port = 119;
}
if (!$this->open_port($server,$port,15))
{
$this->error();
}
$this->read_port();
if ($user <> '' && $passwd <> '')
{
if (!$this->msg2socket('authinfo user
'.$user,'^381',&$response))
{
$this->error();
}
if (!$this->msg2socket('authinfo pass
'.$passwd,'^281',&$response))
{
$this->error();
}
}
if (!$this->mode_reader())
{
$this->error();
}
if(!$folder)
{
$folder = $this->get_first_folder();
if(!$folder)
{
$this->error();
}
}
$this->folder = $folder;
$this->mailbox = $this->get_mailbox_name($folder);
$this->num_msgs = $this->num_msg($this->mailbox);
$this->start_msg = $this->first_message($this->mailbox);
$this->end_msg = $this->last_message($this->mailbox);
echo 'Successful connection to '.$this->mailbox."<br>\n";
}
function fix_folder($folder='')
{
if($folder=='')
{
$mailbox = $this->mailbox;
}
elseif(is_int($folder))
{
$mailbox = $this->get_mailbox_name($folder);
}
else
{
$mailbox = $folder;
}
return $mailbox;
}
function get_first_folder()
{
if(@!$GLOBALS['phpgw_info']['user']['preferences']['nntp'])
{
$this->set_error('Configuration','User
Preferences','You have not set your user preferences in NNTP.');
$this->error();
}
else
{
$pref =
@each($GLOBALS['phpgw_info']['user']['preferences']['nntp']);
return $pref[0];
}
}
function get_mailbox_name($folder)
{
$active = False;
$this->db->query('SELECT name,active FROM newsgroups WHERE
con='.$folder,_LINE__,__FILE__);
if ($this->db->num_rows() > 0)
{
$this->db->next_record();
$mailbox = $this->db->f('name');
}
if ($this->db->f('active') != 'Y')
{
$GLOBALS['phpgw']->preferences->delete('nntp',$folder);
$GLOBALS['phpgw']->preferences->save_repository();
$this->set_error('Administration','Automatic
Disabling','The newsgroup '.$mailbox.' is not activated by the Administrator.');
$this->error();
}
return $mailbox;
}
function get_mailbox_counts($folder='',$index=1)
{
$mailbox = $this->fix_folder($folder);
if (!$this->msg2socket('group '.$mailbox,'^211',&$response))
{
$this->error();
}
$temp_array = explode(' ',$response);
return $temp_array[$index];
}
function num_msg($folder='')
{
if(($folder == '' || $folder == $this->mailbox) &&
isset($this->num_msgs))
{
return $this->num_msgs;
}
return $this->get_mailbox_counts($folder,1);
}
function first_message($folder='')
{
if(($folder == '' || $folder == $this->mailbox) &&
isset($this->start_msg))
{
return $this->start_msg;
}
return $this->get_mailbox_counts($folder,2);
}
function last_message($folder='')
{
if(($folder == '' || $folder == $this->mailbox) &&
isset($this->end_msg))
{
return $this->end_msg;
}
return $this->get_mailbox_counts($folder,3);
}
function mailboxmsginfo($folder='')
{
$info = new msg_mb_info;
if($folder=='' || $folder==$this->mailbox ||
$folder==$this->folder)
{
if(isset($this->num_msgs))
{
$info->messages = $this->num_msgs;
}
else
{
if($folder==$this->folder)
{
$this->mailbox =
$this->get_mailbox_name($folder);
}
$info->messages =
$this->num_msg($this->mailbox);
}
$info->size = 0;
if ($info->messages)
{
return $info;
}
else
{
return False;
}
}
else
{
$mailbox = $this->fix_folder($folder);
}
$info->messages = $this->num_msgs($mailbox);
$info->size = 0;
$this->num_msgs($this->mailbox);
if ($info->messages)
{
return $info;
}
else
{
return False;
}
}
function fetch_field($start,$stop,$element)
{
if (!$this->msg2socket('XHDR '.$element.'
'.$start.'-'.$stop,'^221',&$response))
{
$this->error();
}
$field_element = Array();
while ($line = $this->read_port())
{
$line = chop($line);
if ($line == '.')
{
break;
}
$breakpos = strpos($line,' ');
$field_element[intval(substr($line,0,$breakpos-1))] =
$this->phpGW_quoted_printable_decode2(substr($line,$breakpos+1));
}
return $field_element;
}
function status($folder='',$options=SA_ALL)
{
$info = new mailbox_status;
$info->messages = $this->num_msg($folder);
return $info;
}
function sort($folder='',$criteria=SORTDATE,$reverse=False,$options='')
{
if($folder == '' || $folder == $this->mailbox)
{
$mailbox = $this->mailbox;
$start_msg = $this->start_msg;
$end_msg = $this->end_msg;
}
else
{
$mailbox = $this->fix_folder($folder);
$start_msg = $this->first_message($mailbox);
$end_msg = $this->last_message($mailbox);
}
switch($criteria)
{
case SORTDATE:
$old_list =
$this->fetch_field($start_msg,$end_msg,'Date');
$field_list =
$this->convert_date_array($old_list);
break;
case SORTARRIVAL:
break;
case SORTFROM:
$field_list =
$this->fetch_field($start_msg,$end_msg,'From');
break;
case SORTSUBJECT:
$field_list =
$this->fetch_field($start_msg,$end_msg,'Subject');
break;
case SORTTO:
$field_list =
$this->fetch_field($start_msg,$end_msg,'To');
break;
case SORTCC:
$field_list =
$this->fetch_field($start_msg,$end_msg,'cc');
break;
case SORTSIZE:
break;
}
@reset($field_list);
if($criteria == SORTSUBJECT)
{
if(!$reverse)
{
uasort($field_list,array($this,"ssort_ascending"));
}
else
{
uasort($field_list,array($this,"ssort_decending"));
}
}
elseif(!$reverse)
{
asort($field_list);
}
else
{
arsort($field_list);
}
$return_array = Array();
@reset($field_list);
$i = 1;
while(list($key,$value) = each($field_list))
{
$return_array[] = $key;
echo '('.$i++.') Field: <b>'.$value."</b>\t\tMsg Num:
<b>".$key."</b><br>\n";
}
@reset($return_array);
return $return_array;
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.msg_pop3.inc.php'
--- NEW FILE ---
<?php
/**************************************************************************\
* phpGroupWare API - POP3 *
* This file written by Mark Peters <address@hidden> *
* Handles specific operations in dealing with POP3 *
* Copyright (C) 2001 Mark Peters and Angelo "Angles" Puglisi
*
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* 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 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 *
[...2074 lines suppressed...]
// --- Include Headers With Body Or Not ---
if (($flags == FT_NOT) || ($phpgw_include_header ==
True))
{
// we need to include the header here
$body_glob = $header_glob ."\r\n" .$body_glob;
}
/*
if ($this->debug >= 2)
{
echo 'pop3: get_body DUMP<br>= = = First DUMP:
header_glob<br>';
echo
'<pre>'.htmlspecialchars($header_glob).'</pre><br><br>';
echo 'pop3: get_body DUMP<br>= = = Second DUMP:
body_glob<br>';
echo
'<pre>'.htmlspecialchars($body_glob).'</pre><br><br>';
}
*/
if ($this->debug >= 1) { echo 'pop3: Leaving
get_body<br>'; }
return $body_glob;
}
}
?>
Index: functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/functions.inc.php,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -r1.134 -r1.135
*** functions.inc.php 30 Apr 2002 03:35:52 -0000 1.134
--- functions.inc.php 6 May 2002 09:05:44 -0000 1.135
***************
*** 5,9 ****
* and Joseph Engo <address@hidden> *
* Has a few functions, but primary role is to load the phpgwapi
*
! * Copyright (C) 2000, 2001 Dan Kuykendall
*
*
-------------------------------------------------------------------------*
* This library is part of the phpGroupWare API
*
--- 5,9 ----
* and Joseph Engo <address@hidden> *
* Has a few functions, but primary role is to load the phpgwapi
*
! * Copyright (C) 2000, 2001, 2002 Dan Kuykendall
*
*
-------------------------------------------------------------------------*
* This library is part of the phpGroupWare API
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.msg.inc.php,NONE,1.1 class.msg_base.inc.php,NONE,1.1 class.msg_base_sock.inc.php,NONE,1.1 class.msg_imap.inc.php,NONE,1.1 class.msg_imap_sock.inc.php,NONE,1.1 class.msg_nntp.inc.php,NONE,1.1 class.msg_nntp_sock.inc.php,NONE,1.1 class.msg_pop3.inc.php,NONE,1.1 class.msg_pop3_sock.inc.php,NONE,1.1 functions.inc.php,1.134,1.135,
Dan Kuykendall <address@hidden> <=