function process_log_watch($user_id, $log_id)
{
    global $dblink, $logwatch_text, $absolute_server_URI;
    //  echo "process_log_watch($user_id, $log_id)\n";
    $rsLog = sql("SELECT cache_logs.cache_id cache_id, cache_logs.text text, cache_logs.text_html text_html, cache_logs.date logdate, user.username username, user.hidden_count ch, user.founds_count cf, user.notfounds_count cn, caches.wp_oc wp,caches.name cachename, cache_logs.type type, IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended` FROM `cache_logs` LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`, `user`, `caches` WHERE `cache_logs`.`deleted`=0 AND (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);
    $logtypeParams = getLogtypeParams($rLog['type']);
    if (isset($logtypeParams['username'])) {
        $rLog['username'] = $logtypeParams['username'];
    }
    if ($rLog['recommended'] != 0 && $rLog['type'] == 1) {
        $recommended = ' + ' . tr('recommendation');
    } else {
        $recommended = '';
    }
    $watchtext = $logwatch_text;
    $logtext = $rLog['text'];
    /*
     if ($rLog['text_html'] != 0){
     $logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
     $logtext = mb_ereg_replace("\r", '', $logtext);
     $logtext = mb_ereg_replace("\n", '', $logtext);
     $logtext = mb_ereg_replace('</p>', "</p>\n", $logtext);
     $logtext = mb_ereg_replace('<br/>', "<br/>\n", $logtext);
     $logtext = mb_ereg_replace('<br />', "<br />\n", $logtext);
     $logtext = strip_tags($logtext);
     }
    */
    $logtext = preg_replace("/<img[^>]+\\>/i", "", $logtext);
    $watchtext = mb_ereg_replace('{date}', date('Y-m-d H:i', strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp}', $rLog['wp'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{logtype}', $logtypeParams['logtype'] . $recommended, $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{logtypeColor}', $logtypeParams['logtypeColor'], $watchtext);
    $watchtext = mb_ereg_replace('{runwatch02}', tr('runwatch02'), $watchtext);
    $watchtext = mb_ereg_replace('{absolute_server_URI}', $absolute_server_URI, $watchtext);
    $watchtext = mb_ereg_replace('{userActivity}', $userActivity, $watchtext);
    sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_added`, `watchtext`, `watchtype`) VALUES (\n                                                                        '&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}
Beispiel #2
0
/**
 * This function prepares message to text watcher about new log entry
 * @param unknown $user_id
 * @param unknown $log_id
 */
function process_log_watch($user_id, $log_id)
{
    global $absolute_server_URI;
    $rsLog = XDb::xSql("SELECT cache_logs.cache_id cache_id, cache_logs.text text, cache_logs.text_html text_html,\n                cache_logs.date logdate, user.username username, user.hidden_count ch, user.founds_count cf,\n                user.notfounds_count cn, caches.wp_oc wp,caches.name cachename, cache_logs.type type,\n                IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`\n        FROM `cache_logs`\n            LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id`\n            AND `cache_logs`.`user_id`=`cache_rating`.`user_id`, `user`, `caches`\n        WHERE `cache_logs`.`deleted`=0 AND (cache_logs.user_id = user.user_id)\n            AND (cache_logs.cache_id = caches.cache_id)\n            AND (cache_logs.id = ?)\n        LIMIT 1", $log_id);
    $rLog = XDb::xFetchArray($rsLog);
    XDb::xFreeResults($rsLog);
    $logtypeParams = getLogtypeParams($rLog['type']);
    if (isset($logtypeParams['username'])) {
        $rLog['username'] = $logtypeParams['username'];
    }
    if ($rLog['recommended'] != 0 && $rLog['type'] == 1) {
        $recommended = ' + ' . tr('recommendation');
    } else {
        $recommended = '';
    }
    $watchtext = file_get_contents(dirname(__FILE__) . '/item.email.html');
    $logtext = $rLog['text'];
    $logtext = preg_replace("/<img[^>]+\\>/i", "", $logtext);
    $watchtext = mb_ereg_replace('{date}', date('Y-m-d H:i', strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp}', $rLog['wp'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{logtype}', $logtypeParams['logtype'] . $recommended, $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{logtypeColor}', $logtypeParams['logtypeColor'], $watchtext);
    $watchtext = mb_ereg_replace('{runwatch02}', tr('runwatch02'), $watchtext);
    $watchtext = mb_ereg_replace('{absolute_server_URI}', $absolute_server_URI, $watchtext);
    $watchtext = mb_ereg_replace('{userActivity}', $userActivity, $watchtext);
    XDb::xSql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_added`, `watchtext`, `watchtype`)\n        VALUES (?, ?, 1, NOW(), ?, 2)", $user_id, $log_id, $watchtext);
}