Ejemplo n.º 1
0
#=============================
if (!$trellis->cache->data['settings']['tickets']['new_tickets']) {
    exit;
}
#=============================
# Grab Incoming Email
#=============================
$raw_email = "";
$email = array();
if ($fd = @fopen("php://stdin", 'r')) {
    while (!feof($fd)) {
        $raw_email .= fread($fd, 1024);
    }
    @fclose($fd);
} else {
    $trellis->log('error', "Unable to Open Connection to Stdin");
    exit;
}
#=============================
# Now the Fun Begins :D
#=============================
$lines = explode("\n", $raw_email);
$headers_complete = 0;
$boundary_active = 0;
$boundary_count = 0;
while (list(, $line) = each($lines)) {
    if (!$headers_complete) {
        // From
        if (preg_match("/^From:\\s*(.*)\$/", $line, $matches)) {
            $email['from'] = $matches[1];
            if (strpos($email['from'], '<') !== false) {
Ejemplo n.º 2
0
 #=============================
 $trellis->core->db->construct(array('select' => array('m' => array('id', 'name'), 'g' => array('g_m_depart_perm')), 'from' => array('m' => 'users'), 'join' => array(array('from' => array('g' => 'groups'), 'where' => array('g' => 'g_id', '=', 'm' => 'ugroup'))), 'where' => array(array('m' => 'email'), '=', $email['from']), 'limit' => array(0, 1)));
 $trellis->core->db->execute();
 if ($trellis->core->db->get_num_rows()) {
     $m = $trellis->core->db->fetch_row();
 } else {
     if (!$d['guest_pipe']) {
         $replace = array();
         // Initialize for Security
         if ($m['id']) {
             $trellis->send_email($m['id'], 'ticket_pipe_rejected', $replace, array('from_email' => $d['incoming_email']));
         } else {
             $replace['MEM_NAME'] = $email['nickname'];
             $trellis->send_guest_email($email['from'], 'ticket_pipe_rejected', $replace, array('from_email' => $d['incoming_email']));
         }
         $trellis->log('security', "Guest Piping Not Allowed: " . $d['name']);
         continue;
     }
     $trellis->core->db->construct(array('select' => array('g_m_depart_perm'), 'from' => 'groups', 'where' => array('g_id', '=', 2), 'limit' => array(0, 1)));
     $trellis->core->db->execute();
     $m = $trellis->core->db->fetch_row();
 }
 #=============================
 # Detect Type
 #=============================
 $ticket_found = 0;
 if (preg_match_all('/Ticket ID #([0-9]+)/i', $email['subject'], $matches, PREG_PATTERN_ORDER)) {
     while (list(, $ptid) = each($matches[1])) {
         $trellis->core->db->construct(array('select' => 'all', 'from' => 'tickets', 'where' => array(array('id', '=', intval($ptid)), array('email', '=', $email['from'], 'and')), 'limit' => array(0, 1)));
         $trellis->core->db->execute();
         if ($trellis->core->db->get_num_rows()) {