/**
  * generate rss feed using any custom data fields
  * but you need to describe fields in $aFields array
  *
  * Required fileds:
  *  Link
  *  Title
  *  DateTimeUTS
  *  Desc
  * 
  * Optional fields:
  *  Photo
  */
 function GenRssByCustomData($aRssData, $sUnitTitleC, $sMainLink, $aFields, $sImage = '', $iPID = 0)
 {
     global $site;
     $sUnits = '';
     $sRSSLast = '';
     if (isset($aRssData[0])) {
         $sRSSLast = getLocaleDate($aRssData[0][$aFields['DateTimeUTS']], 6);
     }
     if ($iPID > 0) {
         $aPIDOwnerInfo = getProfileInfo($iPID);
     }
     $iUnitLimitChars = 2000;
     //(int)getParam('max_blog_preview');
     if ($aRssData) {
         foreach ($aRssData as $iUnitID => $aUnitInfo) {
             $sUnitUrl = $aUnitInfo[$aFields['Link']];
             $sUnitGuid = $aUnitInfo[$aFields['Guid']];
             $sUnitTitle = strmaxwordlen(strip_tags($aUnitInfo[$aFields['Title']]), 100);
             $sUnitDate = getLocaleDate($aUnitInfo[$aFields['DateTimeUTS']], 6);
             $sLinkMore = '';
             if (strlen($aUnitInfo[$aFields['Desc']]) > $iUnitLimitChars) {
                 $sLinkMore = "... <a href=\"" . $sUnitUrl . "\">" . _t('_Read more') . "</a>";
             }
             $sUnitDescVal = mb_substr(strip_tags($aUnitInfo[$aFields['Desc']]), 0, $iUnitLimitChars) . $sLinkMore;
             $sUnitDesc = $sUnitDescVal;
             $sUnitRSSFeed .= "<item><title><![CDATA[{$sUnitTitle}]]></title><link><![CDATA[{$sUnitUrl}]]></link><guid><![CDATA[{$sUnitGuid}]]></guid><description><![CDATA[{$sUnitDesc}]]></description><pubDate>{$sUnitDate}</pubDate></item>";
         }
     }
     $sRSSTitle = _t('_RSS_Feed_Title_Common', $sUnitTitleC);
     if ($iPID > 0) {
         $sRSSTitle = _t('_RSS_Feed_Title_Profile', $aPIDOwnerInfo['NickName'], $sUnitTitleC);
     }
     if (substr($sMainLink, 0, 7) != 'http://') {
         $sMainLink = BX_DOL_URL_ROOT . $sMainLink;
     }
     $sRSSImage = '';
     if ($sImage) {
         $sRSSImage = "<image><url>{$sImage}</url><title>{$sRSSTitle}</title><link>{$sMainLink}</link></image>";
     }
     return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"><channel><title>{$sRSSTitle}</title><link>{$sMainLink}</link><description>{$sRSSTitle}</description><lastBuildDate>{$sRSSLast}</lastBuildDate>{$sRSSImage}{$sUnitRSSFeed}</channel></rss>";
 }
Beispiel #2
0
function process_html_output($text, $maxwordlen = 100)
{
    return strmaxwordlen($text, $maxwordlen);
}
/**
 * Send message
 */
function MemberSendMessage($member, $recipient, $must_use_credits = false)
{
    global $site;
    $en_dest_choice = getParam("enable_msg_dest_choice");
    $max_message_size = getParam("max_inbox_message_size");
    $max_messages = getParam("max_inbox_messages");
    // Check if recipient is active
    if ('Active' != $recipient['Status']) {
        return 10;
    }
    // Check if member is blocked
    if (db_arr("SELECT `ID`, `Profile` FROM `BlockList` WHERE `Profile` = {$member['ID']} AND `ID` = '{$recipient['ID']}';")) {
        return 5;
    }
    // If must use credits then check for enough amount
    if ($must_use_credits && getProfileCredits($member['ID']) < (double) $msg_credits) {
        return 21;
    }
    // antispam ))
    if (db_arr("SELECT `ID` FROM `Messages` WHERE `Sender` = {$member[ID]} AND date_add(`Date`, INTERVAL 1 MINUTE) > Now()")) {
        return 3;
    }
    // Get sender info
    $sender = getProfileInfo($member['ID']);
    $aPlus = array();
    $aPlus['ProfileReference'] = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . $sender['NickName'] . '</a> (' . getProfileLink($member['ID']) . ') ' : '<b>' . _t("_Visitor") . '</b>';
    // Don't send notification if message is sending to email
    if ($_POST['notify'] && !($_POST['sendto'] == "email" || $_POST['sendto'] == "both")) {
        $message_text = getParam("t_Compose");
        $subject = getParam('t_Compose_subject');
        $aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor");
        $notify_res = sendMail($recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus);
        if (!$notify_res) {
            echo "<div class=\"err\">" . _t("_Notification send failed") . "</div><br />\n";
        }
    }
    // Send message to email
    if ($en_dest_choice && ($_POST['sendto'] == "email" || $_POST['sendto'] == "both")) {
        $message_text = getParam("t_Message");
        $subject = process_pass_data($_POST['mes_subject']);
        $aPlus['MessageText'] = strmaxtextlen(clear_xss(replace_full_uris(process_pass_data($_POST['text']))), $max_message_size);
        $result = sendMail($recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus);
    }
    // Send message to communicator
    if ($_POST['sendto'] == "lovemail" || $_POST['sendto'] == "both") {
        // Restrict with total messages count
        $messages_count = db_arr("SELECT COUNT(*) AS `mess_count` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}'");
        $messages_count = $messages_count['mess_count'];
        if ($messages_count - 1 > $max_messages) {
            $del_res = db_res("SELECT `ID` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}' ORDER BY `Date` ASC LIMIT " . ($messages_count - $max_messages + 1));
            while ($del_arr = mysql_fetch_array($del_res)) {
                db_res("DELETE FROM `Messages` WHERE `ID` = {$del_arr['ID']}");
            }
        }
        // Insert message into database
        $message_text = strmaxtextlen(addslashes(clear_xss(process_pass_data($_POST['text']))), $max_message_size);
        $message_subject = strmaxwordlen(process_db_input($_POST['mes_subject']), 30);
        $result = db_res("INSERT INTO `Messages` ( `Date`, `Sender`, `Recipient`, `Text`, `Subject`, `New` ) VALUES ( NOW(), {$member['ID']}, {$recipient['ID']}, '{$message_text}', '{$message_subject}', '1' )");
    }
    // If sending successful then mark as performed action
    if ($result) {
        checkAction($member['ID'], ACTION_ID_SEND_MESSAGE, true);
        if ($must_use_credits) {
            decProfileCredits($member['ID'], $msg_credits);
        }
    } else {
        return 1;
    }
    return 0;
}