function import_vcard($params) { include_once 'class.imap_functions.inc.php'; $objImap = new imap_functions(); $msg_number = $params['msg_number']; $idx_file = $params['idx_file']; $msg_part = $params['msg_part']; $msg_folder = $params['msg_folder']; $from_ajax = $params['from_ajax']; $encoding = strtolower($params['encoding']); $fileContent = ""; $cirus_delimiter = $params['cirus_delimiter']; $expFolder = explode($cirus_delimiter, $msg_folder); if ($msg_number != null && $msg_part != null && $msg_folder != null && intval($idx_file == '0' ? '1' : $idx_file)) { require_once PHPGW_INCLUDE_ROOT . '/expressoMail/inc/class.attachment.inc.php'; $attachmentObj = new attachment(); $attachmentObj->setStructureFromMail($msg_folder, $msg_number); $fileContent = $attachmentObj->getAttachment($msg_part); $info = $attachmentObj->getAttachmentInfo($msg_part); $filename = $info['name']; } else { $filename = $idx_file; } // It's necessary to access calendar method. $GLOBALS['phpgw_info']['flags']['noappheader'] = True; $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar'; if (isset($params['selected']) || isset($params['readable'])) { $_REQUEST['data'] = $fileContent; $_REQUEST['type'] = 'iCal'; $_REQUEST['params']['calendar'] = isset($params['selected']) ? $params['selected'] : false; $_REQUEST['readable'] = isset($params['readable']) && $params['readable'] ? true : false; $_REQUEST['analize'] = isset($params['analize']) ? true : false; $_REQUEST['params']['status'] = isset($params['status']) ? $params['status'] : false; $_REQUEST['params']['owner'] = $params['uidAccount']; if (isset($params['acceptedSuggestion'])) { $_REQUEST['params']['acceptedSuggestion'] = $params['acceptedSuggestion']; $_REQUEST['params']['from'] = $params['from']; } ob_start(); include_once PHPGW_INCLUDE_ROOT . '/prototype/converter.php'; $output = ob_get_clean(); $valid = json_decode($output, true); if ($_REQUEST['readable']) { if (!is_array($valid)) { $output = unserialize($output); foreach ($output as $key => $value) { return $value; } } return false; } if (empty($output)) { return "error"; } return "ok"; } include_once PHPGW_INCLUDE_ROOT . '/header.inc.php'; $uiicalendar = CreateObject("calendar.uiicalendar"); if (strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) { include_once 'class.ldap_functions.inc.php'; $ldap = new ldap_functions(); $account['uid'] = $expFolder[1]; $account['uidnumber'] = $ldap->uid2uidnumber($expFolder[1]); $account['mail'] = $ldap->getMailByUid($expFolder[1]); return $uiicalendar->import_from_mail($fileContent, $from_ajax, $account); } else { return $uiicalendar->import_from_mail($fileContent, $from_ajax); } }
/** * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @param $params */ function spam($params) { $mbox_stream = $this->open_mbox($params['folder']); $msgs_number = explode(',', $params['msgs_number']); $user = array(); if (substr($params['folder'], 0, 4) == 'user') { $ldapObject = new ldap_functions(); $folderArray = array(); $folderArray = explode($this->imap_delimiter, $params['folder']); $user['name'] = $folderArray[1]; $user['email'] = $ldapObject->getMailByUid($user['name']); } else { $user['name'] = $this->username; $user['email'] = $_SESSION['phpgw_info']['expressomail']['user']['email']; } foreach ($msgs_number as $msg_number) { $imap_msg_number = imap_msgno($mbox_stream, $msg_number); $header = imap_fetchheader($mbox_stream, $imap_msg_number); $body = imap_body($mbox_stream, $imap_msg_number); $msg = $header . $body; strtok($user['email'], '@'); $domain = strtok('@'); //Encontrar a assinatura do dspam no cabecalho $v = explode("\r\n", $header); foreach ($v as $linha) { if (preg_match('/^Message-ID/i', $linha)) { $args = explode(" ", $linha); $msg_id = "'{$args['1']}'"; } elseif (preg_match('/^X-DSPAM-Signature/i', $linha)) { $args = explode(" ", $linha); $signature = $args[1]; } } // Seleciona qual comando a ser executado switch ($params['spam']) { case 'true': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam']; break; case 'false': $cmd = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham']; break; } $tags = array('##EMAIL##', '##USERNAME##', '##DOMAIN##', '##SIGNATURE##', '##MSGID##', '##SMTP_SERVER##', '##SMTP_PORT##'); $smtpServer = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer']; $smtpPort = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort']; $cmd = str_replace($tags, array($user['email'], $user['name'], $domain, $signature, $msg_id, $smtpServer, $smtpPort), $cmd); $msg = system($cmd, $status); if ($status === 0) { Logger::info('expressomail', 'dspam', $cmd); } else { Logger::error('expressomail', 'dspam', $cmd . ' error:' . $msg); } } imap_close($mbox_stream); return false; }