function fetch_email_template($filename, $language, $domain)
{
    global $opt, $rootpath;
    if (!$language) {
        $language = $opt['template']['default']['locale'];
    }
    $language = strtolower($language);
    if (!file_exists($rootpath . '/lang/de/ocstyle/email/' . $language . '/' . $filename . '.email')) {
        $language = 'en';
    }
    $mailtext = read_file($rootpath . '/lang/de/ocstyle/email/' . $language . '/' . $filename . '.email');
    $urls = get_site_urls($domain);
    $mailtext = mb_ereg_replace("{site_url}", $urls['site_url'], $mailtext);
    if ($urls['shortlink_url']) {
        $mailtext = mb_ereg_replace("{shortlink_url}", $urls['shortlink_url'], $mailtext);
    } else {
        $mailtext = mb_ereg_replace("{shortlink_url}", $urls['site_url'], $mailtext);
    }
    $mailtext = mb_ereg_replace("{email_contact}", $opt['mail']['contact'], $mailtext);
    return $mailtext;
}
Пример #2
0
function process_log_watch($user_id, $log_id)
{
    global $opt, $dblink, $logwatch_text, $translate;
    //	echo "process_log_watch($user_id, $log_id)\n";
    $rsLog = sql("SELECT\n\t\t\t`cache_logs`.`cache_id`,\n\t\t\t`cache_logs`.`type`,\n\t\t\t`cache_logs`.`text`,\n\t\t\t`cache_logs`.`text_html`,\n\t\t\t`cache_logs`.`date` `logdate`,\n\t\t\t`cache_logs`.`needs_maintenance`,\n\t\t\t`cache_logs`.`listing_outdated`,\n\t\t\t`user`.`username`,\n\t\t\t`caches`.`name` `cachename`,\n\t\t\t`caches`.`wp_oc`\n\t\tFROM\n\t\t\t`cache_logs`,\n\t\t\t`user`,\n\t\t\t`caches`\n\t\tWHERE\n\t\t\t`cache_logs`.`user_id`=`user`.`user_id` AND\n\t\t\t`cache_logs`.`cache_id`=`caches`.`cache_id` AND\n\t\t\t`cache_logs`.`id` = '&1'", $log_id);
    $rLog = sql_fetch_array($rsLog);
    mysql_free_result($rsLog);
    $logtext = html2plaintext($rLog['text'], $rLog['text_html'] == 0, EMAIL_LINEWRAP);
    $language = sqlValue("SELECT `language` FROM `user` WHERE `user_id`='" . sql_escape($user_id) . "'", null);
    if (!$language) {
        $language = $opt['template']['default']['locale'];
    }
    if (strpos($rLog['logdate'], '00:00:00') > 0) {
        $dateformat = $opt['locale'][$language]['format']['phpdate'];
    } else {
        $dateformat = $opt['locale'][$language]['format']['phpdatetime'];
    }
    $watchtext = '{date} ' . $translate->t('{user} has logged the cache "{cachename}":', '', basename(__FILE__), __LINE__, '', 1, $language) . ' {action}{maintenance_flags}' . "\n" . '{shortlink_url}{wp_oc}' . "\n{cachelists}\n" . '{text}' . "\n\n\n\n";
    $watchtext = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp_oc}', $rLog['wp_oc'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{action}', get_logtype_name($rLog['type'], $language), $watchtext);
    $watchtext = insert_maintenance_flags($rLog, $language, $watchtext);
    $rsLists = sql("SELECT `name` FROM `cache_lists` cl\n\t\tJOIN `cache_list_watches` clw ON clw.`cache_list_id`=cl.`id` AND clw.`user_id`='&1'\n\t\tJOIN `cache_list_items` cli ON cli.`cache_list_id`=cl.`id` AND cli.`cache_id`='&2'\n\t\tORDER BY `name`", $user_id, $rLog['cache_id']);
    $cachelist_names = sql_fetch_column($rsLists);
    switch (count($cachelist_names)) {
        case 0:
            $cachelists = '';
            break;
        case 1:
            $cachelists = $translate->t('Cache list:', '', basename(__FILE__), __LINE__, '', 1, $language) . ' ' . $cachelist_names[0] . "\n";
            break;
        default:
            $cachelists = $translate->t('Cache lists:', '', basename(__FILE__), __LINE__, '', 1, $language) . ' ' . implode(', ', $cachelist_names) . "\n";
    }
    $watchtext = mb_ereg_replace('{cachelists}', $cachelists, $watchtext);
    $domain = sqlValue("SELECT `domain` FROM `user` WHERE `user_id`='" . sql_escape($user_id) . "'", null);
    $urls = get_site_urls($domain);
    if ($urls['shortlink_url']) {
        $watchtext = mb_ereg_replace("{shortlink_url}", $urls['shortlink_url'], $watchtext);
    } else {
        $watchtext = mb_ereg_replace("{shortlink_url}", $urls['site_url'], $watchtext);
    }
    sql("INSERT IGNORE INTO watches_waiting \n            (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) \n            VALUES ('&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}
Пример #3
0
function process_log_watch($user_id, $log_id)
{
    global $opt, $dblink, $logwatch_text, $translate;
    //	echo "process_log_watch($user_id, $log_id)\n";
    $rsLog = sql("SELECT cache_logs.cache_id cache_id, cache_logs.type, cache_logs.text text, cache_logs.text_html text_html, cache_logs.date logdate, user.username username, caches.name cachename, caches.wp_oc wp_oc FROM `cache_logs`, `user`, `caches` WHERE (cache_logs.user_id = user.user_id) AND (cache_logs.cache_id = caches.cache_id) AND (cache_logs.id = '&1')", $log_id);
    $rLog = sql_fetch_array($rsLog);
    mysql_free_result($rsLog);
    $logtext = html2plaintext($rLog['text'], $rLog['text_html'] == 0, EMAIL_LINEWRAP);
    $language = sqlValue("SELECT `language` FROM `user` WHERE `user_id`='" . sql_escape($user_id) . "'", null);
    if (!$language) {
        $language = $opt['template']['default']['locale'];
    }
    if (strpos($rLog['logdate'], '00:00:00') > 0) {
        $dateformat = $opt['locale'][$language]['format']['phpdate'];
    } else {
        $dateformat = $opt['locale'][$language]['format']['phpdatetime'];
    }
    $watchtext = '{date} ' . $translate->t('{user} has logged the cache "{cachename}":', '', basename(__FILE__), __LINE__, '', 1, $language) . ' {action}' . "\n" . '{shortlink_url}{wp_oc}' . "\n\n" . '{text}' . "\n\n\n\n";
    $watchtext = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp_oc}', $rLog['wp_oc'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{action}', get_logtype_name($rLog['type'], $language), $watchtext);
    $domain = sqlValue("SELECT `domain` FROM `user` WHERE `user_id`='" . sql_escape($user_id) . "'", null);
    $urls = get_site_urls($domain);
    if ($urls['shortlink_url']) {
        $watchtext = mb_ereg_replace("{shortlink_url}", $urls['shortlink_url'], $watchtext);
    } else {
        $watchtext = mb_ereg_replace("{shortlink_url}", $urls['site_url'], $watchtext);
    }
    sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}