Ejemplo n.º 1
0
/**
 * Do all the conversions needed to process HTML or plain text editor input,
 * for either storing it into the database or (when swiching modes)
 * re-displaying it in another editor mode.
 *
 * oldDescMode is the mode in which the editor was running which output the $text,
 * or 0 if the text came from the database with `htm_text` = 0.
 *
 * descMode    is == descMode if the user hit the editor's "save" button,
 * or the new mode if the user hit another mode button
 */
function processEditorInput($oldDescMode, $descMode, $text)
{
    global $opt, $smiley;
    if ($descMode != 1) {
        if ($oldDescMode == 1) {
            // mode switch from plain text to HTML editor => convert HTML special chars
            $text = nl2br(htmlspecialchars($text));
            // .. and smilies
            $text = str_replace($smiley['text'], $smiley['spaced_image'], $text);
        } else {
            // save HTML input => verify / tidy / filter;
            // also implemented in okapi/services/logs/submit.php
            $purifier = new OcHTMLPurifier($opt);
            $text = $purifier->purify($text);
        }
    } else {
        if ($oldDescMode == 1) {
            // save plain text input => convert to HTML;
            // also implemented in okapi/services/logs/submit.php
            $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8'));
        } else {
            // mode switch from HTML editor to plain text, or decode HTML-encoded plain text
            $text = html2plaintext($text, $oldDescMode = 0, 0);
        }
    }
    return $text;
}
Ejemplo n.º 2
0
function processEditorInput($oldDescMode, $descMode, $text)
{
    global $opt, $smiley;
    if ($descMode != 1) {
        if ($oldDescMode == 1) {
            // mode switch from plain text to HTML editor => convert HTML special chars
            $text = nl2br(htmlspecialchars($text));
            // .. and smilies
            $text = str_replace($smiley['text'], $smiley['spaced_image'], $text);
        } else {
            // save HTML input => verify / tidy / filter;
            // also implemented in okapi/services/logs/submit.php
            $purifier = new OcHTMLPurifier($opt);
            $text = $purifier->purify($text);
        }
    } else {
        if ($oldDescMode == 1) {
            // save plain text input => convert to HTML;
            // also implemented in okapi/services/logs/submit.php
            $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8'));
        } else {
            // mode switch from HTML editor to plain text, or decode HTML-encoded plain text
            // convert smilies ...
            for ($n = 0; $n < count($smiley['image']); $n++) {
                do {
                    $logtext0 = $text;
                    $text = mb_ereg_replace("<img [^>]*?src=[^>]+?" . str_replace('.', '\\.', $smiley['file'][$n]) . "[^>]+?>", "[s![" . $smiley['text'][$n] . "]!s]", $text);
                    // the [s[ ]s] is needed to protect the spaces around the smileys
                } while ($text != $logtext0);
            }
            // ... and HTML to plain text
            $text = html2plaintext($text, $oldDescMode = 0, 0);
            $text = str_replace(array('[s![', ']!s]'), '', $text);
        }
    }
    return $text;
}
Ejemplo n.º 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\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);
}
Ejemplo n.º 4
0
     // 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
         $email_content = mb_ereg_replace('%log_owner%', $log_user_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_owner%', $cache_owner_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_owner_id%', $log_record['cache_owner_id'], $email_content);
         $email_content = mb_ereg_replace('%cache_name%', $log_record['cache_name'], $email_content);
         $email_content = mb_ereg_replace('%cache_wp%', $log_record['wp_oc'], $email_content);
         $email_content = mb_ereg_replace('%log_date%', date($opt['locale'][$locale]['format']['phpdate'], strtotime($log_record['log_date'])), $email_content);
Ejemplo n.º 5
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);
    $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" . 'http://opencaching.de/{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);
    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);
}
Ejemplo n.º 6
0
     // 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']);
         $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);
         //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
         $email_content = mb_ereg_replace('%log_owner%', $log_user_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_owner%', $cache_owner_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_owner_id%', $log_record['cache_owner_id'], $email_content);
         $email_content = mb_ereg_replace('%cache_name%', $log_record['cache_name'], $email_content);
         $email_content = mb_ereg_replace('%cache_wp%', $log_record['wp_oc'], $email_content);
         $email_content = mb_ereg_replace('%log_date%', date($opt['locale'][$locale]['format']['phpdate'], strtotime($log_record['log_date'])), $email_content);