Example #1
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;
}
Example #2
0
}
mysql_free_result($rscw);
/* end cache_watches */
/* begin send out everything that has to be sent */
$email_headers = 'From: "' . $mailfrom . '" <' . $mailfrom . '>';
$rsUsers = sql("SELECT\n        `user`.`user_id`,\n        `user`.`username`,\n        `user`.`email`,\n        `user`.`watchmail_mode`, \n        `user`.`watchmail_hour`,\n        `user`.`watchmail_day`,\n        `user`.`watchmail_nextmail`,\n        IFNULL(`user`.`language`,'&1') `language`,\n        `domain`\n    FROM `user`\n    INNER JOIN `watches_waiting`\n        ON `user`.`user_id`=`watches_waiting`.`user_id`\n    WHERE `user`.`watchmail_nextmail`<NOW()", $opt['template']['default']['locale']);
for ($i = 0; $i < mysql_num_rows($rsUsers); $i++) {
    $rUser = sql_fetch_array($rsUsers);
    if ($rUser['watchmail_nextmail'] != '0000-00-00 00:00:00') {
        $nologs = $translate->t('No new log entries.', '', basename(__FILE__), __LINE__, '', 1, $rUser['language']);
        $rsWatches = sql("SELECT COUNT(*) count FROM watches_waiting WHERE user_id='&1'", $rUser['user_id']);
        if (mysql_num_rows($rsWatches) > 0) {
            $r = sql_fetch_array($rsWatches);
            if ($r['count'] > 0) {
                // ok, eine mail ist fäig
                $mailbody = fetch_email_template('watchlist', $rUser['language'], $rUser['domain']);
                $mailbody = mb_ereg_replace('{username}', $rUser['username'], $mailbody);
                $rsWatchesOwner = sql("SELECT id, watchtext\n                    FROM watches_waiting\n                    WHERE user_id='&1'\n                    AND watchtype=1\n                    ORDER BY id DESC", $rUser['user_id']);
                if (mysql_num_rows($rsWatchesOwner) > 0) {
                    $logtexts = '';
                    for ($j = 0; $j < mysql_num_rows($rsWatchesOwner); $j++) {
                        $rWatch = sql_fetch_array($rsWatchesOwner);
                        $logtexts .= $rWatch['watchtext'];
                    }
                    while (mb_substr($logtexts, -1) == "\n" || mb_substr($logtexts, -1) == "\r") {
                        $logtexts = mb_substr($logtexts, 0, mb_strlen($logtexts) - 1);
                    }
                    $mailbody = mb_ereg_replace('{ownerlogs}', $logtexts, $mailbody);
                } else {
                    $mailbody = mb_ereg_replace('{ownerlogs}', $nologs, $mailbody);
                }
Example #3
0
 }
 // deleted allowed by cache-owner or log-owner
 if ($log_record['log_user_id'] == $usr['userid'] || $log_record['cache_owner_id'] == $usr['userid']) {
     $commit = isset($_REQUEST['commit']) ? $_REQUEST['commit'] : 0;
     $ownlog = $log_record['log_user_id'] == $usr['userid'];
     if ($ownlog) {
         // we are the log-owner
         $tplname = 'removelog_logowner';
     } else {
         // we are the cache-owner
         $tplname = 'removelog_cacheowner';
         if ($commit == 1) {
             //send email to logger
             $removed_log_subject = removed_log_subject($log_record['log_user_language']);
             $removed_message_title = removed_message_title($log_record['log_user_language']);
             $email_content = fetch_email_template('removed_log', $log_record['log_user_language'], $log_record['log_user_domain']);
             $message = isset($_POST['logowner_message']) ? $_POST['logowner_message'] : '';
             if ($message != '') {
                 //message to logger
                 $message = $removed_message_title . "\n" . $message . "\n" . $removed_message_end;
             }
             $logtext = html2plaintext($log_record['log_text'], $log_record['text_html'] == 0, EMAIL_LINEWRAP);
             //get cache owner name
             $cache_owner_rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $log_record['cache_owner_id']);
             $cache_owner_record = sql_fetch_array($cache_owner_rs);
             mysql_free_result($cache_owner_rs);
             //get email address of logowner
             $log_user_rs = sql("SELECT `email`, `username` FROM `user` WHERE `user_id`='&1'", $log_record['log_user_id']);
             $log_user_record = sql_fetch_array($log_user_rs);
             mysql_free_result($log_user_rs);
             // insert log data