phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: email/inc class.bofilters.inc.php,1.11,1.12 clas


From: Angelo Tony Puglisi <address@hidden>
Subject: [Phpgroupware-cvs] CVS: email/inc class.bofilters.inc.php,1.11,1.12 class.bosend.inc.php,1.7,1.8 class.uifilters.inc.php,1.9,1.10
Date: Fri, 01 Feb 2002 18:07:06 -0500

Update of /cvsroot/phpgroupware/email/inc
In directory subversions:/tmp/cvs-serv13092/email/inc

Modified Files:
        class.bofilters.inc.php class.bosend.inc.php 
        class.uifilters.inc.php 
Log Message:
add header X-Originating-IP to outgoing mail, feeble but working reports on 
filter tests and filter apply actions

Index: class.bofilters.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/email/inc/class.bofilters.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** class.bofilters.inc.php     1 Feb 2002 00:09:59 -0000       1.11
--- class.bofilters.inc.php     1 Feb 2002 23:07:02 -0000       1.12
***************
*** 601,606 ****
                                        if ($this->debug > 1) { echo 
'bofilters.do_filter: run_all_finters_mode: calling 
$this->run_single_filter['.$filter_idx.']<br>'; }
                                        
$this->run_single_filter((int)$filter_idx);
!                                       // keep a report
!                                       
$this->make_filter_match_report((int)$filter_idx);
                                }
                        }
--- 601,609 ----
                                        if ($this->debug > 1) { echo 
'bofilters.do_filter: run_all_finters_mode: calling 
$this->run_single_filter['.$filter_idx.']<br>'; }
                                        
$this->run_single_filter((int)$filter_idx);
!                                       if ($this->just_testing())
!                                       {
!                                               // add this message to the 
report
!                                               
$this->make_filter_match_report((int)$filter_idx);
!                                       }
                                }
                        }
***************
*** 611,616 ****
                                if ($this->debug > 1) { echo 
'bofilters.do_filter: run_single_filter mode: calling 
$this->run_single_filter['.$found_filter_num.']<br>'; }
                                
$this->run_single_filter((int)$found_filter_num);
!                               // keep a report
!                               
$this->make_filter_match_report((int)$found_filter_num);
                        }
                        
--- 614,622 ----
                                if ($this->debug > 1) { echo 
'bofilters.do_filter: run_single_filter mode: calling 
$this->run_single_filter['.$found_filter_num.']<br>'; }
                                
$this->run_single_filter((int)$found_filter_num);
!                               if ($this->just_testing())
!                               {
!                                       // add this message to the report
!                                       
$this->make_filter_match_report((int)$found_filter_num);
!                               }
                        }
                        
***************
*** 618,622 ****
                        if ($this->just_testing())
                        {
!                               echo 
'<html>'.$this->html_matches_table.'</html>';
                        }
                        if ($this->debug > 1) { echo 'bofilters.do_filter: 
calling end_request<br>'; }
--- 624,659 ----
                        if ($this->just_testing())
                        {
!                               //echo 
'<html>'.$this->html_matches_table.'</html>';
!                               
unset($GLOBALS['phpgw_info']['flags']['noheader']);
!                               
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
!                               $GLOBALS['phpgw_info']['flags']['noappheader'] 
= True;
!                               $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
!                               $GLOBALS['phpgw']->common->phpgw_header();
!                               echo '<p>&nbsp</p>'."\r\n";
!                               echo $this->html_matches_table;
!                       }
!                       else
!                       {
!                               // FIX ME - make a better report
!                               
unset($GLOBALS['phpgw_info']['flags']['noheader']);
!                               
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
!                               $GLOBALS['phpgw_info']['flags']['noappheader'] 
= True;
!                               $GLOBALS['phpgw_info']['flags']['noappfooter'] 
= True;
!                               $GLOBALS['phpgw']->common->phpgw_header();
! 
!                               echo '<h4>Apply Filters Report:</h4>'."\r\n";
!                               for ($filter_idx=0; $filter_idx < 
count($this->all_filters); $filter_idx++)
!                               {
!                                       $this_filter = 
$this->all_filters[$filter_idx];
!                                       $num_matches = 
count($this->each_filter_mball_list[$filter_idx]);
!                                       
parse_str($this_filter['actions'][0]['folder'], $target_folder);
!                                       echo '<p>'."\r\n"
!                                       .'<strong>Filter number 
'.(string)$filter_idx.':</strong>'.'<br>'."\r\n"
!                                       .'&nbsp;&nbsp;&nbsp;'.'filter name: 
['.$this_filter['filtername'].']<br>'."\r\n"
!                                       .'&nbsp;&nbsp;&nbsp;'.'number of 
matches: ['.(string)$num_matches.']'.'<br>'."\r\n"
!                                       .'&nbsp;&nbsp;&nbsp;'.'requested filter 
action: ['.$this_filter['actions'][0]['judgement'].'] ; Acctnum 
['.(string)$target_folder['acctnum'].'] ;  Folder: 
['.htmlspecialchars($target_folder['folder']).']<br>'."\r\n"
!                                       .'</p>'."\r\n"
!                                       .'<p>&nbsp;</p>'."\r\n";
!                               }
                        }
                        if ($this->debug > 1) { echo 'bofilters.do_filter: 
calling end_request<br>'; }
***************
*** 628,632 ****
                        $take_me_to_href = '<a href="'.$take_me_to_url.'"> Go 
Back </a>';
                        //Header('Location: ' . $take_me_to_url);
!                       echo '<p>&nbsp;</p><br><p>'.$take_me_to_href.'</p>';
  
                        if ($this->debug > 0) { echo 'bofilters.do_filter: 
LEAVING<br>'; }
--- 665,669 ----
                        $take_me_to_href = '<a href="'.$take_me_to_url.'"> Go 
Back </a>';
                        //Header('Location: ' . $take_me_to_url);
!                       echo 
'<br><p>'.'&nbsp;&nbsp;&nbsp;'.$take_me_to_href.'</p>';
  
                        if ($this->debug > 0) { echo 'bofilters.do_filter: 
LEAVING<br>'; }
***************
*** 1104,1108 ****
                                $this->html_matches_table .= 
                                        //'<h3>Results: 
['.$fake_folder_info['number_all'].'] matches for Filter number 
['.$filter_num.'] named: '.$this_filter['filtername'].'</h3>'."\r\n"
!                                       '<h3>Results: Filter ['.$filter_num.'] 
had ['.$fake_folder_info['number_all'].'] matches. Filter named: 
'.$this_filter['filtername'].'</h3>'."\r\n"
                                        .'Action: 
['.$this_filter['actions'][0]['judgement'].'] ; Acctnum 
['.(string)$target_folder['acctnum'].'] ;  Folder: 
'.htmlspecialchars($target_folder['folder'])
                                        .'<table>'
--- 1141,1145 ----
                                $this->html_matches_table .= 
                                        //'<h3>Results: 
['.$fake_folder_info['number_all'].'] matches for Filter number 
['.$filter_num.'] named: '.$this_filter['filtername'].'</h3>'."\r\n"
!                                       '<h4>Test Results: Filter 
['.$filter_num.'] had ['.$fake_folder_info['number_all'].'] matches. Filter 
named: '.$this_filter['filtername'].'</h4>'."\r\n"
                                        .'Action: 
['.$this_filter['actions'][0]['judgement'].'] ; Acctnum 
['.(string)$target_folder['acctnum'].'] ;  Folder: 
'.htmlspecialchars($target_folder['folder'])
                                        .'<table>'

Index: class.bosend.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/email/inc/class.bosend.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.bosend.inc.php        14 Jan 2002 20:51:37 -0000      1.7
--- class.bosend.inc.php        1 Feb 2002 23:07:02 -0000       1.8
***************
*** 16,45 ****
        {
                var $public_functions = array(
-                       'get_langed_labels'     => True,
                        'send'          => True
                );
                var $nextmatchs;
                var $mail_out = array();
!               //var $debug = True;
!               var $debug = False;
                var $xi;
-               var $xml_functions = array();
-               
-               var $soap_functions = array(
-                       'get_langed_labels' => array(
-                               'in'  => array('int'),
-                               'out' => array('array')
-                       ),
-                       'send' => array(
-                               'in'  => array('array'),
-                               'out' => array('int')
-                       )
-               );
                
                function bosend()
                {
                        
                }
                
                //  -------  This will be called just before leaving this page, 
to clear / unset variables / objects -----------
                function send_message_cleanup()
--- 16,93 ----
        {
                var $public_functions = array(
                        'send'          => True
                );
                var $nextmatchs;
+               var $not_set='-1';
                var $mail_out = array();
!               var $debug = 0;
                var $xi;
                
                function bosend()
                {
+                       if ($this->debug > 0) { echo 'email.bosend 
*constructor*: ENTERING<br>'; }
+                       if (is_object($GLOBALS['phpgw']->msg))
+                       {
+                               if ($this->debug > 1) { echo 'email.bosend 
*constructor*: is_object test: $GLOBALS[phpgw]->msg is already set, do not 
create again<br>'; }
+                       }
+                       else
+                       {
+                               if ($this->debug > 1) { echo 'email.bosend 
*constructor*: is_object: $GLOBALS[phpgw]->msg is NOT set, creating mail_msg 
object<br>'; }
+                               $GLOBALS['phpgw']->msg = 
CreateObject("email.mail_msg");
+                       }
+                       $this->not_set = $GLOBALS['phpgw']->msg->not_set;
+                       if 
($GLOBALS['phpgw']->msg->get_isset_arg('already_grab_class_args_gpc'))
+                       {
+                               if ($this->debug > 0) { echo 'email.bosend 
*constructor*: LEAVING , msg object already initialized<br>'; }
+                               return True;
+                       }
+                               
+                       if ($this->debug > 1) { echo 'email.bosend 
*constructor*: msg object NOT yet initialized<br>'; }
+                       $args_array = Array();
+                       // should we log in or not, no, we only need prefs 
initialized
+                       // if any data is needed mail_msg will open stream for 
us
+                       $args_array['do_login'] = True;
+                       if ($this->debug > 1) { echo 'email.bosend 
*constructor*: call msg->begin_request with args 
array:'.serialize($args_array).'<br>'; }
+                       $some_stream = 
$GLOBALS['phpgw']->msg->begin_request($args_array);
+                       // error if login failed
+                       if (($args_array['do_login'] == True)
+                       && (!$some_stream))
+                       {
+                               
$GLOBALS['phpgw']->msg->login_error($GLOBALS['PHP_SELF'].', constructor()');
+                               // is this needed?
+                               return False;
+                       }
+                       if ($this->debug > 0) { echo 'email.bosend 
*constructor*: LEAVING<br>'; }
+               }
+               
+               /*!
+               @function get_originating_ip
+               @abstract the client IP for this phpgw user at the time the 
send button was clicked
+               @discussion Gets the value for the "X-Originating-IP" header. 
That header  is used
+               by hotmail, for example, it looked like a "good thing" and was 
a feature request, so we 
+               use it here too. Even if the IP private (such as on a LAN), 
this can still be useful for the admin.
+               */
+               function get_originating_ip()
+               {
+                       $got_ip = '';
+                       if (is_object($GLOBALS['phpgw']->session))
+                       {
+                               $got_ip = 
$GLOBALS['phpgw']->session->getuser_ip();
+                       }
+                       elseif 
(isset($GLOBALS['HTTP_SERVER_VARS']['REMOTE_ADDR']))
+                       {
+                               $got_ip = 
$GLOBALS['HTTP_SERVER_VARS']['REMOTE_ADDR'];
+                       }
                        
+                       // did we get anything useful ?
+                       if (trim((string)$got_ip) == '')
+                       {
+                               $got_ip = 'not available';
+                       }
+                       return $got_ip;
                }
                
+               
+               
                //  -------  This will be called just before leaving this page, 
to clear / unset variables / objects -----------
                function send_message_cleanup()
***************
*** 56,64 ****
                function send()
                {
                        // attempt (or not) to reuse an existing mail_msg 
object, i.e. if one ALREADY exists before entering
                        //$attempt_reuse = True;
                        $attempt_reuse = False;
                        
-                       if ($this->debug) { echo 'ENTERING: 
email.bosend.send'.'<br>'; }
                        if ($this->debug) { echo 'email.bosend.send: local var 
attempt_reuse=['.serialize($attempt_reuse).'] ; reuse_feed_args[] dump<pre>'; 
print_r($reuse_feed_args); echo '</pre>'; }
                        // create class objects
--- 104,113 ----
                function send()
                {
+                       if ($this->debug) { echo 'ENTERING: 
email.bosend.send'.'<br>'; }
+                       /*
                        // attempt (or not) to reuse an existing mail_msg 
object, i.e. if one ALREADY exists before entering
                        //$attempt_reuse = True;
                        $attempt_reuse = False;
                        
                        if ($this->debug) { echo 'email.bosend.send: local var 
attempt_reuse=['.serialize($attempt_reuse).'] ; reuse_feed_args[] dump<pre>'; 
print_r($reuse_feed_args); echo '</pre>'; }
                        // create class objects
***************
*** 74,78 ****
                                $GLOBALS['phpgw']->msg = 
CreateObject("email.mail_msg");
                        }
-                       
                        // do we attempt to reuse the existing msg object?
                        if ($attempt_reuse)
--- 123,126 ----
***************
*** 94,98 ****
                                $args_array['do_login'] = True;
                        }
-                       
                        // "start your engines"
                        if ($this->debug == True) { echo 'email.bosend.send: 
call msg->begin_request with args array:<pre>'; print_r($args_array); echo 
'</pre>'; }
--- 142,145 ----
***************
*** 104,107 ****
--- 151,155 ----
                                
$GLOBALS['phpgw']->msg->login_error($GLOBALS['PHP_SELF'].', send()');
                        }
+                       */
                        
                        // ---- BEGIN BO SEND LOGIC
***************
*** 121,124 ****
--- 169,173 ----
                        $this->mail_out['boundary'] = 
$GLOBALS['phpgw']->msg->make_boundary();
                        $this->mail_out['date'] = '';
+                       $this->mail_out['originating_ip'] = 
'['.$this->get_originating_ip().']';
                        $this->mail_out['main_headers'] = Array();
                        $this->mail_out['body'] = Array();
***************
*** 750,753 ****
--- 799,804 ----
                        // --- MAIN HEADERS  -------
                        $hdr_line = 0;
+                       $this->mail_out['main_headers'][$hdr_line] =            
'X-Originating-IP: '.$this->mail_out['originating_ip'];
+                       $hdr_line++;
                        $this->mail_out['main_headers'][$hdr_line] =            
'From: '.$GLOBALS['phpgw']->msg->addy_array_to_str($this->mail_out['from']);
                        $hdr_line++;

Index: class.uifilters.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/email/inc/class.uifilters.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.uifilters.inc.php     1 Feb 2002 00:09:59 -0000       1.9
--- class.uifilters.inc.php     1 Feb 2002 23:07:02 -0000       1.10
***************
*** 61,70 ****
                        
$GLOBALS['phpgw']->template->set_var('lang_inbox_for_account',lang('Filter 
INBOX for accounts'));
                        $not_available_yet = ' &#040;NA&#041;';
!                       
$GLOBALS['phpgw']->template->set_var('lang_from',lang('From Address'));
!                       $GLOBALS['phpgw']->template->set_var('lang_to',lang('To 
Address'));
!                       $GLOBALS['phpgw']->template->set_var('lang_cc',lang('CC 
Address'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_bcc',lang('Bcc Address'));
                        
$GLOBALS['phpgw']->template->set_var('lang_recipient',lang('Recipient').' 
&#040;to,cc,bcc&#041;');
!                       
$GLOBALS['phpgw']->template->set_var('lang_sender',lang('Sender').$not_available_yet);
                        
$GLOBALS['phpgw']->template->set_var('lang_subject',lang('Subject'));
                        
$GLOBALS['phpgw']->template->set_var('lang_received_headers',lang('Received 
Headers'));
--- 61,74 ----
                        
$GLOBALS['phpgw']->template->set_var('lang_inbox_for_account',lang('Filter 
INBOX for accounts'));
                        $not_available_yet = ' &#040;NA&#041;';
!                       
//$GLOBALS['phpgw']->template->set_var('lang_from',lang('From Address'));
!                       
//$GLOBALS['phpgw']->template->set_var('lang_to',lang('To Address'));
!                       
//$GLOBALS['phpgw']->template->set_var('lang_cc',lang('CC Address'));
!                       
//$GLOBALS['phpgw']->template->set_var('lang_bcc',lang('Bcc Address'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_from',lang('From'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_to',lang('To'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_cc',lang('CC'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_bcc',lang('Bcc'));
                        
$GLOBALS['phpgw']->template->set_var('lang_recipient',lang('Recipient').' 
&#040;to,cc,bcc&#041;');
!                       
$GLOBALS['phpgw']->template->set_var('lang_sender',lang('Sender'));
                        
$GLOBALS['phpgw']->template->set_var('lang_subject',lang('Subject'));
                        
$GLOBALS['phpgw']->template->set_var('lang_received_headers',lang('Received 
Headers'));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]