Beispiel #1
0
function process_new_cache($notify)
{
    global $debug, $debug_mailto, $rootpath;
    global $mailfrom, $new_cache_subject, $new_oconly_subject;
    //echo "process_new_cache(".$notify['id'].")\n";
    $error = false;
    // mail-template lesen
    switch ($notify['type']) {
        case notify_new_cache:
            // Type: new cache
            $mailbody = read_file($rootpath . 'util/notification/notify_newcache.email');
            $mailsubject = $new_cache_subject;
            break;
        case notify_new_oconly:
            // Type: new OConly flag
            $mailbody = read_file($rootpath . 'util/notification/notify_newoconly.email');
            $mailsubject = $new_oconly_subject;
            break;
        default:
            $error = true;
            break;
    }
    if (!$error) {
        $mailbody = mb_ereg_replace('{username}', $notify['recpname'], $mailbody);
        $mailbody = mb_ereg_replace('{date}', date('d.m.Y', strtotime($notify['date_hidden'])), $mailbody);
        $mailbody = mb_ereg_replace('{cacheid}', $notify['cache_id'], $mailbody);
        $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
        $mailbody = mb_ereg_replace('{user}', $notify['username'], $mailbody);
        $mailbody = mb_ereg_replace('{cachename}', $notify['cachename'], $mailbody);
        $mailbody = mb_ereg_replace('{distance}', round(calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
        $mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
        $mailbody = mb_ereg_replace('{bearing}', Bearing2Text(calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'])), $mailbody);
        $mailbody = mb_ereg_replace('{cachetype}', $notify['cachetype'], $mailbody);
        $mailbody = mb_ereg_replace('{cachesize}', $notify['cachesize'], $mailbody);
        $mailbody = mb_ereg_replace('{oconly}', $notify['oconly'] ? 'OConly-' : '', $mailbody);
        $subject = mb_ereg_replace('{cachename}', $notify['cachename'], $mailsubject);
        $subject = mb_ereg_replace('{oconly}', $notify['oconly'] ? 'OConly-' : '', $subject);
        /* begin send out everything that has to be sent */
        $email_headers = 'From: "' . $mailfrom . '" <' . $mailfrom . '>';
        // mail versenden
        if ($debug == true) {
            $mailadr = $debug_mailto;
        } else {
            $mailadr = $notify['email'];
        }
        if (is_existent_maildomain(getToMailDomain($mailadr))) {
            mb_send_mail($mailadr, $subject, $mailbody, $email_headers);
        }
    } else {
        echo "Unbekannter Notification-Typ: " . $notify['type'] . "<br />";
    }
    // logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
    logentry('notify_newcache', 8, $notify['recid'], $notify['cache_id'], 0, 'Sending mail to ' . $mailadr, array());
    return 0;
}
Beispiel #2
0
function process_new_cache($notify)
{
    global $opt, $debug, $debug_mailto, $rootpath, $translate;
    global $maildomain, $mailfrom;
    //echo "process_new_cache(".$notify['id'].")\n";
    $error = false;
    // fetch email template
    switch ($notify['type']) {
        case notify_new_cache:
            // Type: new cache
            $mailbody = fetch_email_template('notify_newcache', $notify['recp_lang'], $notify['recp_domain']);
            $mailsubject = '[' . $maildomain . '] ' . $translate->t($notify['oconly'] ? 'New OConly cache:' : 'New cache:', '', basename(__FILE__), __LINE__, '', 1, $notify['recp_lang']) . ' ' . $notify['cachename'];
            break;
        case notify_new_oconly:
            // Type: new OConly flag
            $mailbody = fetch_email_template('notify_newoconly', $notify['recp_lang'], $notify['recp_domain']);
            $mailsubject = '[' . $maildomain . '] ' . $translate->t('Cache was marked as OConly:', '', basename(__FILE__), __LINE__, '', 1, $notify['recp_lang']) . ' ' . $notify['cachename'];
            break;
        default:
            $error = true;
            break;
    }
    if (!$error) {
        $mailbody = mb_ereg_replace('{username}', $notify['recpname'], $mailbody);
        $mailbody = mb_ereg_replace('{date}', date($opt['locale'][$notify['recp_lang']]['format']['phpdate'], strtotime($notify['date_hidden'])), $mailbody);
        $mailbody = mb_ereg_replace('{cacheid}', $notify['cache_id'], $mailbody);
        $mailbody = mb_ereg_replace('{wp_oc}', $notify['wp_oc'], $mailbody);
        $mailbody = mb_ereg_replace('{user}', $notify['username'], $mailbody);
        $mailbody = mb_ereg_replace('{cachename}', $notify['cachename'], $mailbody);
        $mailbody = mb_ereg_replace('{distance}', round(geomath::calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
        $mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
        $mailbody = mb_ereg_replace('{bearing}', geomath::Bearing2Text(geomath::calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2']), 0, $notify['recp_lang']), $mailbody);
        $mailbody = mb_ereg_replace('{cachetype}', get_cachetype_name($notify['cachetype'], $notify['recp_lang']), $mailbody);
        $mailbody = mb_ereg_replace('{cachesize}', get_cachesize_name($notify['cachesize'], $notify['recp_lang']), $mailbody);
        $mailbody = mb_ereg_replace('{oconly-}', $notify['oconly'] ? $translate->t('OConly-', '', basename(__FILE__), __LINE__, '', 1, $notify['recp_lang']) : '', $mailbody);
        /* begin send out everything that has to be sent */
        $email_headers = 'From: "' . $mailfrom . '" <' . $mailfrom . '>';
        // send email
        if ($debug == true) {
            $mailadr = $debug_mailto;
        } else {
            $mailadr = $notify['email'];
        }
        if (is_existent_maildomain(getToMailDomain($mailadr))) {
            mb_send_mail($mailadr, $mailsubject, $mailbody, $email_headers);
        }
    } else {
        echo "Unknown notification type: " . $notify['type'] . "<br />";
    }
    // logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
    logentry('notify_newcache', 8, $notify['recid'], $notify['cache_id'], 0, 'Sending mail to ' . $mailadr, []);
    return 0;
}
Beispiel #3
0
                 while (mb_substr($logtexts, -1) == "\n" || mb_substr($logtexts, -1) == "\r") {
                     $logtexts = mb_substr($logtexts, 0, mb_strlen($logtexts) - 1);
                 }
                 $mailbody = mb_ereg_replace('{watchlogs}', $logtexts, $mailbody);
             } else {
                 $mailbody = mb_ereg_replace('{watchlogs}', $nologs, $mailbody);
             }
             mysql_free_result($rsWatchesLog);
             // mail versenden
             if ($debug == true) {
                 $mailadr = $debug_mailto;
             } else {
                 $mailadr = $rUser['email'];
             }
             if ($mailadr != '') {
                 if (is_existent_maildomain(getToMailDomain($mailadr))) {
                     mb_send_mail($mailadr, $mailsubject, $mailbody, $email_headers);
                     // logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
                     logentry('watchlist', 2, $rUser['user_id'], 0, 0, 'Sending mail to ' . $mailadr, array());
                 }
             }
             // entries entfernen
             sql("DELETE FROM watches_waiting WHERE user_id='&1' AND watchtype IN (1, 2)", $rUser['user_id']);
         }
     }
 }
 // Zeitpunkt der nästen Mail berechnen
 if ($rUser['watchmail_mode'] == 0) {
     $nextmail = date($sDateformat);
 } elseif ($rUser['watchmail_mode'] == 1) {
     $nextmail = date($sDateformat, mktime($rUser['watchmail_hour'], 0, 0, date('n'), date('j') + 1, date('Y')));