phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgroupware mailpipe.php


From: Dave Hall
Subject: [Phpgroupware-cvs] phpgroupware mailpipe.php
Date: Wed, 27 Dec 2006 12:25:03 +0000

CVSROOT:        /sources/phpgroupware
Module name:    phpgroupware
Changes by:     Dave Hall <skwashd>     06/12/27 12:25:03

Modified files:
        .              : mailpipe.php 

Log message:
        more changes to make it work

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/mailpipe.php?cvsroot=phpgroupware&r1=1.2&r2=1.3

Patches:
Index: mailpipe.php
===================================================================
RCS file: /sources/phpgroupware/phpgroupware/mailpipe.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- mailpipe.php        27 Dec 2006 03:03:04 -0000      1.2
+++ mailpipe.php        27 Dec 2006 12:25:03 -0000      1.3
@@ -22,10 +22,10 @@
                || !isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] != 
'--email'
                || !isset($_SERVER['argv'][2]) || !strlen($_SERVER['argv'][2]) )
        {
-               fwrite(STDERR, "ERROR: TTS mailpipe called improperly!\n");
+               fwrite(STDERR, "ERROR: phpGroupWare mailpipe called 
improperly!\n");
                fwrite(STDERR, "Usage: mailpipe.php --email address@hidden");
                fwrite(STDERR, "Exiting.\n");
-               fwrite(STDERR, print_r($_SERVER['argv']) . "\nExiting.\n");
+               fwrite(STDERR, print_r($_SERVER['argv'], true) . 
"\nExiting.\n");
                exit(1);
        }
        $email_to = $_SERVER['argv'][2];
@@ -41,18 +41,24 @@
                'currentapp'                            => 'login',
                'noheader'                                      => true
        );
-       $phpgw_root = dirname($_SERVER['PHP_SELF']);
+       $phpgw_root = dirname(__FILE__);
        include_once($phpgw_root . '/header.inc.php');
-       
+       error_reporting(E_ALL);
+       ini_set('display_errors', true);
 
        $msg = createObject('phpgwapi.mail2array');
        $msg->parse_input(file_get_contents('php://stdin'));
+       $msg->fetch_useful_headers();
 
-       $login = sender2phpgw_id($msg->from_email);
+       $login = '';
+       if ( $msg->from_email )
+       {
+               $login = sender2phpgw_lid($msg->from_email);
+       }
 
        if ( !$login )
        {
-               echo "ERROR: Sender's email address [{$msg->from_email}] does 
not match any user's account, rejecting message\n";
+               fwrite(STDERR, "ERROR: Sender's email address 
[{$msg->from_email}] does not match any user's account, rejecting message\n");
                $error = true;
        }
        else
@@ -60,27 +66,36 @@
                // This is a hack and the data is a little dodgy, but it works, 
so we have a more accurate source IP address
                $_SERVER['HTTP_HOST'] = $msg->ip;
 
-               $sessionid = $GLOBALS['phpgw']->session->create($login, '', 
'known'); //assume email is legit - possible DDoS vector ?
-
+               if ( $GLOBALS['phpgw']->session->create($login, '', 'known') ) 
//assume email is legit - possible DDoS vector ?
+               {
                $mail_handlers = createObject('phpgwapi.mail_handlers');
                $handler = $mail_handlers->get_handler($email_to);
+                       
                if ( count($handler) )
                {
-                       $error = execMethod($handler['handler'], $msg, 
$handler['handler_id']);
+                               $msg->handler_id = $handler['handler_id'];
+                               $error = execMethod($handler['handler'], $msg);
                }
                else
                {
-                       echo "ERROR: No handler found for $email_to, rejecting 
message\n";
+                               fwrite(STDERR, "ERROR: No handler found for 
$email_to, rejecting message\n");
                        $error = true;
                }
 
-               $GLOBALS['phpgw']->session->destroy($sessionid, 
$GLOBALS['phpgw']->session->kp3);
+                       
$GLOBALS['phpgw']->session->destroy($GLOBALS['phpgw_info']['user']['sessionid'],
 $GLOBALS['phpgw']->session->kp3);
+               }
+               else
+               {
+                       fwrite(STDERR, "ERROR: Unable to create session for 
{$login} (reason: {$GLOBALS['phpgw']->session->cd_reason})\n");
+                       $error = true;
+               }
        }
 
        if ( $error )
        {
                exit(1);
        }
+       exit;
 
        function sender2phpgw_lid($sender_email)
        {
@@ -89,7 +104,7 @@
                unset($contacts);
                if ( is_array($contact_id) && count($contact_id) )
                {
-                       $userid = (int) 
ExecMethod('phpgwapi.accounts.search_person', $contact_id);
+                       $userid = 
$GLOBALS['phpgw']->accounts->search_person($contact_id[0]);
                        if ( $userid )
                        {
                                return 
$GLOBALS['phpgw']->accounts->id2lid($userid);




reply via email to

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