function get() { $status = strip_tags($_REQUEST['status']); $room_id = intval(\App::$data['chat']['room_id']); $stopped = x($_REQUEST, 'stopped') && intval($_REQUEST['stopped']) ? true : false; if ($status && $room_id) { $x = q("select channel_address from channel where channel_id = %d limit 1", intval(\App::$data['chat']['uid'])); $r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'", dbesc($status), dbesc(datetime_convert()), intval($room_id), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR'])); goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id); } if (!$stopped) { $lastseen = intval($_REQUEST['last']); $ret = array('success' => false); $sql_extra = permissions_sql(\App::$data['chat']['uid']); $r = q("select * from chatroom where cr_uid = %d and cr_id = %d {$sql_extra}", intval(\App::$data['chat']['uid']), intval(\App::$data['chat']['room_id'])); if (!$r) { json_return_and_die($ret); } $inroom = array(); $r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name", intval(\App::$data['chat']['room_id'])); if ($r) { foreach ($r as $rr) { switch ($rr['cp_status']) { case 'away': $status = t('Away'); $status_class = 'away'; break; case 'online': default: $status = t('Online'); $status_class = 'online'; break; } $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], 'status' => $status, 'status_class' => $status_class); } } $chats = array(); $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created", intval(\App::$data['chat']['room_id']), intval($lastseen)); if ($r) { foreach ($r as $rr) { $chats[] = array('id' => $rr['chat_id'], 'img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'r'), 'text' => smilies(bbcode($rr['chat_text'])), 'self' => get_observer_hash() == $rr['chat_xchan'] ? 'self' : ''); } } } $r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'", dbesc(datetime_convert()), intval(\App::$data['chat']['room_id']), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR'])); $ret['success'] = true; if (!$stopped) { $ret['inroom'] = $inroom; $ret['chats'] = $chats; } json_return_and_die($ret); }
function get() { if (\App::$argv[1] === "json") { $tmp = list_smilies(); $results = array(); for ($i = 0; $i < count($tmp['texts']); $i++) { $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); } json_return_and_die($results); } else { return smilies('', true); } }
function message_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_channel()) { notice(t('Permission denied.') . EOL); return login(); } $channel = $a->get_channel(); head_set_icon($channel['xchan_photo_s']); $cipher = get_pconfig(local_channel(), 'system', 'default_cipher'); if (!$cipher) { $cipher = 'aes256'; } $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content)); if (argc() == 3 && argv(1) === 'dropconv') { if (!intval(argv(2))) { return; } $cmd = argv(1); $r = private_messages_drop(local_channel(), argv(2), true); if ($r) { info(t('Conversation removed.') . EOL); } goaway($a->get_baseurl(true) . '/message'); } if (argc() == 1) { // list messages $o .= $header; // private_messages_list() can do other more complicated stuff, for now keep it simple $r = private_messages_list(local_channel(), '', $a->pager['start'], $a->pager['itemspage']); if (!$r) { info(t('No messages.') . EOL); return $o; } $tpl = get_markup_template('mail_list.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$id' => $rr['id'], '$from_name' => $rr['from']['xchan_name'], '$from_url' => chanlink_hash($rr['from_xchan']), '$from_photo' => $rr['from']['xchan_photo_s'], '$to_name' => $rr['to']['xchan_name'], '$to_url' => chanlink_hash($rr['to_xchan']), '$to_photo' => $rr['to']['xchan_photo_s'], '$subject' => $rr['seen'] ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>', '$delete' => t('Delete conversation'), '$body' => smilies(bbcode($rr['body'])), '$date' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], t('D, d M Y - g:i A')), '$seen' => $rr['seen'])); } $o .= alt_pager($a, count($r)); return $o; } }
/** * @brief Given a text string, convert from bbcode to html and add smilie icons. * * @param string $text * @param sting $content_type * @return string */ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { switch ($content_type) { case 'text/plain': $s = escape_tags($text); break; case 'text/html': $s = $text; break; case 'text/markdown': require_once 'library/markdown.php'; $s = Markdown($text); break; case 'application/x-pdl': $s = escape_tags($text); break; // No security checking is done here at display time - so we need to verify // that the author is allowed to use PHP before storing. We also cannot allow // importation of PHP text bodies from other sites. Therefore this content // type is only valid for web pages (and profile details). // It may be possible to provide a PHP message body which is evaluated on the // sender's site before sending it elsewhere. In that case we will have a // different content-type here. // No security checking is done here at display time - so we need to verify // that the author is allowed to use PHP before storing. We also cannot allow // importation of PHP text bodies from other sites. Therefore this content // type is only valid for web pages (and profile details). // It may be possible to provide a PHP message body which is evaluated on the // sender's site before sending it elsewhere. In that case we will have a // different content-type here. case 'application/x-php': ob_start(); eval($text); $s = ob_get_contents(); ob_end_clean(); break; case 'text/bbcode': case '': default: require_once 'include/bbcode.php'; if (stristr($text, '[nosmile]')) { $s = bbcode($text, false, true, $cache); } else { $s = smilies(bbcode($text, false, true, $cache)); } $s = zidify_links($s); break; } //logger('prepare_text: ' . $s); return $s; }
function prepare_page($item) { $a = get_app(); $naked = get_pconfig($item['uid'], 'system', 'nakedpage') ? 1 : 0; $observer = $a->get_observer(); //240 chars is the longest we can have before we start hitting problems with suhosin sites $preview = substr(urlencode($item['body']), 0, 240); $link = z_root() . '/' . $a->cmd; if (array_key_exists('webpage', $a->layout) && array_key_exists('authored', $a->layout['webpage'])) { if ($a->layout['webpage']['authored'] === 'none') { $naked = 1; } // ... other possible options } // prepare_body calls unobscure() as a side effect. Do it here so that // the template will get passed an unobscured title. $body = prepare_body($item, true); $tpl = get_pconfig($item['uid'], 'system', 'pagetemplate'); if (!$tpl) { $tpl = 'page_display.tpl'; } return replace_macros(get_markup_template($tpl), array('$author' => $naked ? '' : $item['author']['xchan_name'], '$auth_url' => $naked ? '' : zid($item['author']['xchan_url']), '$date' => $naked ? '' : datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'Y-m-d H:i'), '$title' => smilies(bbcode($item['title'])), '$body' => $body, '$preview' => $preview, '$link' => $link)); }
} $wert[5] = trim($wert[5]); if (!empty($wert[5])) { $wert[5] = "<a href=\"" . $wert[5] . "\" target=\"_blank\"><img src=\"guestbook/images/home.gif\" alt=\"Homepage\" border=\"0\" hspace=\"2\"></a>"; } if (!empty($wert[7])) { $wert[7] = _kommentar . $wert[7]; } if (empty($wert[7])) { $wert[7] = ""; } if ($enumbruch) { $wert[6] = umbrucheinfuegen($wert[6], $umbruch); } if ($ensmilies) { $wert[6] = smilies($wert[6], $smilies); } if (empty($wert[8])) { $wert[8] = ""; } $text6_mit_br = str_replace("\n", "<br>", $wert[6]); $text7_mit_br = str_replace("\n", "<br>", $wert[7]); if ($wert[8] != "1") { $table .= templateschreiben("guestbook/templates/tabelle.tpl", array("NAME" => $wert[2], "EMAIL" => $wert[3], "ICQ" => $wert[4], "HP" => $wert[5], "CONTENT" => $text6_mit_br, "COMMENT" => $text7_mit_br, "DATE" => date("d.m.Y", $wert[0]), "TIME" => date("H:i", $wert[0]), "NUMBER" => $eintr_anzahl - $i)); } if ($i == $eintr_proseite + $start - 1) { break; } } $i++; }
/** * Given a text string, convert from bbcode to html and add smilie icons. * * @param string $text * @return string */ function prepare_text($text) { require_once 'include/bbcode.php'; if (stristr($text, '[nosmile]')) { $s = bbcode($text); } else { $s = smilies(bbcode($text)); } return trim($s); }
function formattext ($text, $smilies, $smiliespath, $myBoardCodeTags, $html) { if($html == 'txt0' OR $html == 'com0' ) { $text = htmlspecialchars($text); $text = str_replace('<br>','<br>',$text); $text = str_replace('<br />','<br />',$text); } $text = Filter_myBoardCodeTags($text, $myBoardCodeTags); if ($smilies == 'yes') $text = smilies($smiliespath,$text); return $text; }
function mail_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_user()) { notice(t('Permission denied.') . EOL); return login(); } $channel = $a->get_channel(); head_set_icon($channel['xchan_photo_s']); $cipher = get_pconfig(local_user(), 'system', 'default_cipher'); if (!$cipher) { $cipher = 'aes256'; } $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content)); if (argc() == 3 && argv(1) === 'drop') { if (!intval(argv(2))) { return; } $cmd = argv(1); $r = private_messages_drop(local_user(), argv(2)); if ($r) { info(t('Message deleted.') . EOL); } goaway($a->get_baseurl(true) . '/message'); } if (argc() == 3 && argv(1) === 'recall') { if (!intval(argv(2))) { return; } $cmd = argv(1); $r = q("update mail set mail_flags = mail_flags | %d where id = %d and channel_id = %d limit 1", intval(MAIL_RECALLED), intval(argv(2)), intval(local_user())); proc_run('php', 'include/notifier.php', 'mail', intval(argv(2))); if ($r) { info(t('Message recalled.') . EOL); } goaway($a->get_baseurl(true) . '/message'); } if (argc() > 1 && argv(1) === 'new') { $o .= $header; $plaintext = true; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $channel['channel_address'], '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'))); $preselect = isset($a->argv[2]) ? array($a->argv[2]) : false; $prename = $preurl = $preid = ''; if (x($_REQUEST, 'hash')) { $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash\n\t\t\t\twhere abook_channel = %d and abook_xchan = '%s' limit 1", intval(local_user()), dbesc($_REQUEST['hash'])); if ($r) { $prename = $r[0]['xchan_name']; $preurl = $r[0]['xchan_url']; $preid = $r[0]['abook_id']; $preselect = array($preid); } } if ($preselect) { $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash\n\t\t\t\twhere abook_channel = %d and abook_id = %d limit 1", intval(local_user()), intval(argv(2))); if ($r) { $prename = $r[0]['xchan_name']; $preurl = $r[0]['xchan_url']; $preid = $r[0]['abook_id']; } } $prefill = $preselect ? $prename : ''; if (!$prefill) { if (array_key_exists('to', $_REQUEST)) { $prefill = $_REQUEST['to']; } } // the ugly select box $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10); $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$to' => t('To:'), '$showinputs' => 'true', '$prefill' => $prefill, '$autocomp' => $autocomp, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'), '$submit' => t('Send'), '$defexpire' => '', '$feature_expire' => feature_enabled(local_user(), 'content_expire') ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(local_user(), 'content_encrypt') ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher)); return $o; } if (argc() > 1 && intval(argv(1))) { $o .= $header; $plaintext = true; // if( local_user() && feature_enabled(local_user(),'richtext') ) // $plaintext = false; $messages = private_messages_fetch_conversation(local_user(), argv(1), true); if (!$messages) { info(t('Message not found.') . EOL); return $o; } if ($messages[0]['to_xchan'] === $channel['channel_hash']) { $a->poi = $messages[0]['from']; } else { $a->poi = $messages[0]['to']; } // require_once('include/Contact.php'); // $a->set_widget('mail_conversant',vcard_from_xchan($a->poi,$get_observer_hash,'mail')); $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$nickname' => $channel['channel_addr'], '$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'))); $mails = array(); $seen = 0; $unknown = false; foreach ($messages as $message) { $s = theme_attachments($message); $mails[] = array('id' => $message['id'], 'from_name' => $message['from']['xchan_name'], 'from_url' => chanlink_hash($message['from_xchan']), 'from_photo' => $message['from']['xchan_photo_m'], 'to_name' => $message['to']['xchan_name'], 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_m'], 'subject' => $message['title'], 'body' => smilies(bbcode($message['body']) . $s), 'delete' => t('Delete message'), 'recall' => t('Recall message'), 'can_recall' => $channel['channel_hash'] == $message['from_xchan'] ? true : false, 'is_recalled' => $message['mail_flags'] & MAIL_RECALLED ? t('Message has been recalled.') : '', 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A')); $seen = $message['seen']; } $recp = $message['from_xchan'] === $channel['channel_hash'] ? 'to' : 'from'; // FIXME - move this HTML to template $select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent_mid'] . '" />'; $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array('$prvmsg_header' => t('Private Conversation'), '$thread_id' => $a->argv[1], '$thread_subject' => $message['title'], '$thread_seen' => $seen, '$delete' => t('Delete conversation'), '$canreply' => $unknown ? false : '1', '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), '$mails' => $mails, '$header' => t('Send Reply'), '$to' => t('To:'), '$showinputs' => '', '$subject' => t('Subject:'), '$subjtxt' => $message['title'], '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$yourmessage' => t('Your message:'), '$text' => '', '$select' => $select, '$parent' => $parent, '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$submit' => t('Submit'), '$wait' => t('Please wait'), '$defexpire' => '', '$feature_expire' => feature_enabled(local_user(), 'content_expire') ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(local_user(), 'content_encrypt') ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher)); return $o; } }
?> " > <button name="delete_from_view_sent" onclick="return confirm('Do you confirm to delete messages ?');" class="btn blue reply-btn"> <i class="fa fa-trash-o"></i> Delete </button> </form> <?php } ?> </div> </div> </div> </div> <div class="inbox-view"> <p> <?php echo smilies($message["msg"]["message"]); ?> </p> </div> <hr> <div class="form-horizontal" id="replyform" style="display:none;"> <form method="post" action=""> <div class="form-group"> <label class="col-sm-2 control-label">Send to:</label> <div class="senderm col-sm-10"> <a href="viewprofile.php?<?php echo $message["to"]["username"]; ?>
function writepublicChat($gameID){ global $_SESSION, $MSG_LANG,$db,$db_prefix; $p = mysql_query("SELECT p.*, c.*, UNIX_TIMESTAMP(c.stamp) AS stamp from {$db_prefix}chat c LEFT JOIN {$db_prefix}players p ON p.player_id = c.from_id order BY c.stamp DESC LIMIT 15"); $chat = ""; while($row = mysql_fetch_array($p)) { if ($_SESSION['playerID'] == $row['from_id']) $cor="#0000FF"; else $cor="brown"; $zeit = $row['stamp']; $msg = strip_tags($row['message'], '<a><b><i><u>'); $msg = stripslashes($msg); $msg = smilies($msg); if ($row['from_id'] == 0) { $row['username'] = "******"; $msg = str_replace("event-enter", $MSG_LANG["entersthechat"], $msg); $msg = str_replace("event-leave", $MSG_LANG["leavesthechat"], $msg); $msg = "<b>" . $msg . "</b>"; } $chat .= "<font size=-10><font color=$cor><B>$row[username]</B>:</font><font color=green><br> " . $msg . "</font> <i><font size=-10><font color=silver>" . $zeit . "</font></font></i><BR>"; } return $chat; }
function message_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content)); if ($a->argc == 3 && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if (!intval($a->argv[2])) { return; } // Check if we should do HTML-based delete confirmation if ($_REQUEST['confirm']) { // <form> can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); $inputs = array(); foreach ($query['args'] as $arg) { if (strpos($arg, 'confirm=') === false) { $arg_parts = explode('=', $arg); $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); } } //$a->page['aside'] = ''; return replace_macros(get_markup_template('confirm.tpl'), array('$method' => 'get', '$message' => t('Do you really want to delete this message?'), '$extra_inputs' => $inputs, '$confirm' => t('Yes'), '$confirm_url' => $query['base'], '$confirm_name' => 'confirmed', '$cancel' => t('Cancel'))); } // Now check how the user responded to the confirmation query if ($_REQUEST['canceled']) { goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); } $cmd = $a->argv[1]; if ($cmd === 'drop') { $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if ($r) { info(t('Message deleted.') . EOL); } //goaway($a->get_baseurl(true) . '/message' ); goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if (count($r)) { $parent = $r[0]['parent-uri']; $convid = $r[0]['convid']; $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc($parent), intval(local_user())); // remove diaspora conversation pointer // Actually if we do this, we can never receive another reply to that conversation, // as we will never again have the info we need to re-create it. // We'll just have to orphan it. //if($convid) { // q("delete from conv where id = %d limit 1", // intval($convid) // ); //} if ($r) { info(t('Conversation removed.') . EOL); } } //goaway($a->get_baseurl(true) . '/message' ); goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); } } if ($a->argc > 1 && $a->argv[1] === 'new') { $o .= $header; /* $plaintext = false; if(intval(get_pconfig(local_user(),'system','plaintext'))) $plaintext = true;*/ $plaintext = true; if (local_user() && feature_enabled(local_user(), 'richtext')) { $plaintext = false; } $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $preselect = isset($a->argv[2]) ? array($a->argv[2]) : false; $prename = $preurl = $preid = ''; if ($preselect) { $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", intval(local_user()), intval($a->argv[2])); if (count($r)) { $prename = $r[0]['name']; $preurl = $r[0]['url']; $preid = $r[0]['id']; } } $prefill = $preselect ? $prename : ''; // the ugly select box $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10); $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$to' => t('To:'), '$showinputs' => 'true', '$prefill' => $prefill, '$autocomp' => $autocomp, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? escape_tags(htmlspecialchars($_REQUEST['body'])) : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'), '$submit' => t('Submit'))); return $o; } $_SESSION['return_url'] = $a->query_string; if ($a->argc == 1) { // list messages $o .= $header; $r = q("SELECT count(*) AS `total` FROM `mail`\n\t\t\tWHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()), dbesc($myprofile)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`,\n\t\t\t`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,\n\t\t\tcount( * ) as count\n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No messages.') . EOL); return $o; } $tpl = get_markup_template('mail_list.tpl'); foreach ($r as $rr) { if ($rr['unknown']) { $partecipants = sprintf(t("Unknown sender - %s"), $rr['from-name']); } elseif (link_compare($rr['from-url'], $myprofile)) { $partecipants = sprintf(t("You and %s"), $rr['name']); } else { $partecipants = sprintf(t("%s and You"), $rr['from-name']); } if ($a->theme['template_engine'] === 'internal') { $subject_e = template_escape($rr['mailseen'] ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'); $body_e = template_escape($rr['body']); $to_name_e = template_escape($rr['name']); } else { $subject_e = $rr['mailseen'] ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'; $body_e = $rr['body']; $to_name_e = $rr['name']; } $o .= replace_macros($tpl, array('$id' => $rr['id'], '$from_name' => $partecipants, '$from_url' => $rr['network'] === NETWORK_DFRN ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url'], '$sparkle' => ' sparkle', '$from_photo' => $rr['thumb'] ? $rr['thumb'] : $rr['from-photo'], '$subject' => $subject_e, '$delete' => t('Delete conversation'), '$body' => $body_e, '$to_name' => $to_name_e, '$date' => datetime_convert('UTC', date_default_timezone_get(), $rr['mailcreated'], t('D, d M Y - g:i A')), '$ago' => relative_date($rr['mailcreated']), '$seen' => $rr['mailseen'], '$count' => sprintf(tt('%d message', '%d messages', $rr['count']), $rr['count']))); } $o .= paginate($a); return $o; } if ($a->argc > 1 && intval($a->argv[1])) { $o .= $header; $plaintext = true; if (local_user() && feature_enabled(local_user(), 'richtext')) { $plaintext = false; } $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`\n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1", intval(local_user()), intval($a->argv[1])); if (count($r)) { $contact_id = $r[0]['contact-id']; $convid = $r[0]['convid']; $sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri'])); if ($convid) { $sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ", dbesc($r[0]['parent-uri']), intval($convid)); } $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`\n\t\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`\n\t\t\t\tWHERE `mail`.`uid` = %d {$sql_extra} ORDER BY `mail`.`created` ASC", intval(local_user())); } if (!count($messages)) { notice(t('Message not available.') . EOL); return $o; } $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d", dbesc($r[0]['parent-uri']), intval(local_user())); require_once "include/bbcode.php"; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $mails = array(); $seen = 0; $unknown = false; foreach ($messages as $message) { if ($message['unknown']) { $unknown = true; } if ($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; } else { $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id']; $sparkle = ' sparkle'; } $extracted = item_extract_images($message['body']); if ($extracted['images']) { $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']); } if ($a->theme['template_engine'] === 'internal') { $from_name_e = template_escape($message['from-name']); $subject_e = template_escape($message['title']); $body_e = template_escape(smilies(bbcode($message['body']))); $to_name_e = template_escape($message['name']); } else { $from_name_e = $message['from-name']; $subject_e = $message['title']; $body_e = smilies(bbcode($message['body'])); $to_name_e = $message['name']; } $mails[] = array('id' => $message['id'], 'from_name' => $from_name_e, 'from_url' => $from_url, 'sparkle' => $sparkle, 'from_photo' => $message['from-photo'], 'subject' => $subject_e, 'body' => $body_e, 'delete' => t('Delete message'), 'to_name' => $to_name_e, 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'), 'ago' => relative_date($message['created'])); $seen = $message['seen']; } $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />'; $tpl = get_markup_template('mail_display.tpl'); if ($a->theme['template_engine'] === 'internal') { $subjtxt_e = template_escape($message['title']); } else { $subjtxt_e = $message['title']; } $o = replace_macros($tpl, array('$thread_id' => $a->argv[1], '$thread_subject' => $message['title'], '$thread_seen' => $seen, '$delete' => t('Delete conversation'), '$canreply' => $unknown ? false : '1', '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), '$mails' => $mails, '$header' => t('Send Reply'), '$to' => t('To:'), '$showinputs' => '', '$subject' => t('Subject:'), '$subjtxt' => $subjtxt_e, '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$yourmessage' => t('Your message:'), '$text' => '', '$select' => $select, '$parent' => $parent, '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$submit' => t('Submit'), '$wait' => t('Please wait'))); return $o; } }
$i = 0; $page .= "</tr>\n"; } } if ($i != 0) { $page .= "</tr>\n"; } //Cierra los dos tables $page .= "</table>\n</td>\n</tr>\n<tr>\n<td class=\"c\" align=\"center\">"; $page .= "<a href=\"javascript:window.close();\">Cerrar Ventana</a>\n"; $page .= "</td>\n</tr>\n</table>\n</td>\n</tr>\n</table>"; display($page, 'Emoticons', false); die; } /* Foro!!! */ if (isset($f) && isset($new) && is_numeric($f) && $new == "thread") { newthread($f); } elseif (isset($t) && isset($new) && is_numeric($t) && $new == "reply") { reply($t); } elseif (isset($f) && is_numeric($f)) { showtopic($f); } elseif (isset($t) && is_numeric($t)) { showthread($t); } elseif (isset($mode) && $mode == 'smilies') { smilies(); } else { showcategories(); } // Created by Perberos. All rights reversed (C) 2006
function smilies_content(&$a) { return smilies('', true); }
function message_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $myprofile = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $tabs = array(array('label' => t('Inbox'), 'url' => $a->get_baseurl() . '/message', 'sel' => $a->argc == 1 ? 'active' : ''), array('label' => t('Outbox'), 'url' => $a->get_baseurl() . '/message/sent', 'sel' => $a->argv[1] == 'sent' ? 'active' : ''), array('label' => t('New Message'), 'url' => $a->get_baseurl() . '/message/new', 'sel' => $a->argv[1] == 'new' ? 'active' : '')); $tpl = get_markup_template('common_tabs.tpl'); $tab_content = replace_macros($tpl, array('$tabs' => $tabs)); $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content)); if ($a->argc == 3 && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if (!intval($a->argv[2])) { return; } $cmd = $a->argv[1]; if ($cmd === 'drop') { $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if ($r) { info(t('Message deleted.') . EOL); } goaway($a->get_baseurl() . '/message'); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if (count($r)) { $parent = $r[0]['parent-uri']; $convid = $r[0]['convid']; $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc($parent), intval(local_user())); // remove diaspora conversation pointer // Actually if we do this, we can never receive another reply to that conversation, // as we will never again have the info we need to re-create it. // We'll just have to orphan it. //if($convid) { // q("delete from conv where id = %d limit 1", // intval($convid) // ); //} if ($r) { info(t('Conversation removed.') . EOL); } } goaway($a->get_baseurl() . '/message'); } } if ($a->argc > 1 && $a->argv[1] === 'new') { $o .= $header; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $preselect = isset($a->argv[2]) ? array($a->argv[2]) : false; $select = contact_select('messageto', 'message-to-select', $preselect, 4, true); $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$to' => t('To:'), '$subject' => t('Subject:'), '$subjtxt' => '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'))); return $o; } if ($a->argc == 1 || $a->argc == 2 && $a->argv[1] === 'sent') { $o .= $header; if ($a->argc == 2) { $eq = '='; } else { $eq = '!='; } // or this. $r = q("SELECT count(*) AS `total` FROM `mail` \n\t\t\tWHERE `mail`.`uid` = %d AND `from-url` {$eq} '%s' GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()), dbesc($myprofile)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, \n\t\t\t`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` \n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\tWHERE `mail`.`uid` = %d AND `from-url` {$eq} '%s' GROUP BY `parent-uri` ORDER BY `created` DESC LIMIT %d , %d ", intval(local_user()), dbesc($myprofile), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No messages.') . EOL); return $o; } $tpl = get_markup_template('mail_list.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$id' => $rr['id'], '$from_name' => $rr['from-name'], '$from_url' => $rr['network'] === NETWORK_DFRN ? $a->get_baseurl() . '/redir/' . $rr['contact-id'] : $rr['url'], '$sparkle' => ' sparkle', '$from_photo' => $rr['thumb'], '$subject' => template_escape($rr['mailseen'] ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'), '$delete' => t('Delete conversation'), '$body' => template_escape($rr['body']), '$to_name' => template_escape($rr['name']), '$date' => datetime_convert('UTC', date_default_timezone_get(), $rr['mailcreated'], t('D, d M Y - g:i A')))); } $o .= paginate($a); return $o; } if ($a->argc > 1 && intval($a->argv[1])) { $o .= $header; $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` \n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\tWHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1", intval(local_user()), intval($a->argv[1])); if (count($r)) { $contact_id = $r[0]['contact-id']; $convid = $r[0]['convid']; $sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri'])); if ($convid) { $sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ", dbesc($r[0]['parent-uri']), intval($convid)); } $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` \n\t\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\t\tWHERE `mail`.`uid` = %d {$sql_extra} ORDER BY `mail`.`created` ASC", intval(local_user())); } if (!count($messages)) { notice(t('Message not available.') . EOL); return $o; } $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d", dbesc($r[0]['parent-uri']), intval(local_user())); require_once "include/bbcode.php"; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$nickname' => $a->user['nickname'], '$baseurl' => $a->get_baseurl())); $tpl = get_markup_template('mail_conv.tpl'); foreach ($messages as $message) { if ($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; } else { $from_url = $a->get_baseurl() . '/redir/' . $message['contact-id']; $sparkle = ' sparkle'; } $o .= replace_macros($tpl, array('$id' => $message['id'], '$from_name' => template_escape($message['from-name']), '$from_url' => $from_url, '$sparkle' => $sparkle, '$from_photo' => $message['from-photo'], '$subject' => template_escape($message['title']), '$body' => template_escape(smilies(bbcode($message['body']))), '$delete' => t('Delete message'), '$to_name' => template_escape($message['name']), '$date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'))); } $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />'; $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Reply'), '$to' => t('To:'), '$subject' => t('Subject:'), '$subjtxt' => template_escape($message['title']), '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => $parent, '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'))); return $o; } }
function prepare_text($text) { require_once 'include/bbcode.php'; $s = smilies(bbcode($text)); return $s; }
private function format_comment($string) { $string = htmlspecialchars($string); if ($this->remove_blank_lines == 1) { $string = preg_replace("/\r\n|\r|\n/", "\n", $string); $string_array = explode("\n", $string); $string = ''; foreach ($string_array as $string_line) { $string_line = trim($string_line); if ($string_line != '') { $string .= $string_line . "\n"; } } } $string = nl2br($string); if ($this->auto_link == 1) { $string = make_link($string); } if ($this->smilies == 1) { $string = smilies($string); } return $string; }
function mail_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_channel()) { notice(t('Permission denied.') . EOL); return login(); } $channel = $a->get_channel(); head_set_icon($channel['xchan_photo_s']); $cipher = get_pconfig(local_channel(), 'system', 'default_cipher'); if (!$cipher) { $cipher = 'aes256'; } $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$header' => t('Messages'))); if (argc() == 4 && argv(2) === 'drop') { if (!intval(argv(3))) { return; } $cmd = argv(2); $mailbox = argv(1); $r = private_messages_drop(local_channel(), argv(3)); if ($r) { //info( t('Message deleted.') . EOL ); } goaway($a->get_baseurl(true) . '/mail/' . $mailbox); } if (argc() == 4 && argv(2) === 'recall') { if (!intval(argv(3))) { return; } $cmd = argv(2); $mailbox = argv(1); $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d", intval(argv(3)), intval(local_channel())); $x = q("select * from mail where id = %d and channel_id = %d", intval(argv(3)), intval(local_channel())); if ($x) { build_sync_packet(local_channel(), array('mail' => encode_mail($x[0], true))); } proc_run('php', 'include/notifier.php', 'mail', intval(argv(3))); if ($r) { info(t('Message recalled.') . EOL); } goaway($a->get_baseurl(true) . '/mail/' . $mailbox . '/' . argv(3)); } if (argc() == 4 && argv(2) === 'dropconv') { if (!intval(argv(3))) { return; } $cmd = argv(2); $mailbox = argv(1); $r = private_messages_drop(local_channel(), argv(3), true); if ($r) { info(t('Conversation removed.') . EOL); } goaway($a->get_baseurl(true) . '/mail/' . $mailbox); } if (argc() > 1 && argv(1) === 'new') { $plaintext = true; $tpl = get_markup_template('msg-header.tpl'); $header = replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $channel['channel_address'], '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'))); $a->page['htmlhead'] .= $header; $prename = ''; $preid = ''; if (x($_REQUEST, 'hash')) { $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash\n\t\t\t\twhere abook_channel = %d and abook_xchan = '%s' limit 1", intval(local_channel()), dbesc($_REQUEST['hash'])); if (!$r) { $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1", dbesc($_REQUEST['hash'])); } if ($r) { $prename = $r[0]['abook_id'] ? $r[0]['xchan_name'] : $r[0]['xchan_addr']; $preurl = $r[0]['xchan_url']; $preid = $r[0]['abook_id'] ? $r[0]['xchan_hash'] : ''; } else { notice(t('Requested channel is not in this network') . EOL); } } $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$new' => true, '$header' => t('Send Private Message'), '$to' => t('To:'), '$prefill' => $prename, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : '', '$yourmessage' => t('Your message:'), '$parent' => '', '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$submit' => t('Send'), '$defexpire' => '', '$feature_expire' => feature_enabled(local_channel(), 'content_expire') ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(local_channel(), 'content_encrypt') ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher)); return $o; } switch (argv(1)) { case 'combined': $mailbox = 'combined'; break; case 'inbox': $mailbox = 'inbox'; break; case 'outbox': $mailbox = 'outbox'; break; default: $mailbox = 'combined'; break; } $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); $mid = argc() > 2 && intval(argv(2)) ? argv(2) : $last_message[0]['id']; $plaintext = true; // if( local_channel() && feature_enabled(local_channel(),'richtext') ) // $plaintext = false; if ($mailbox == 'combined') { $messages = private_messages_fetch_conversation(local_channel(), $mid, true); } else { $messages = private_messages_fetch_message(local_channel(), $mid, true); } if (!$messages) { //info( t('Message not found.') . EOL); return; } if ($messages[0]['to_xchan'] === $channel['channel_hash']) { $a->poi = $messages[0]['from']; } else { $a->poi = $messages[0]['to']; } // require_once('include/Contact.php'); // $a->set_widget('mail_conversant',vcard_from_xchan($a->poi,$get_observer_hash,'mail')); $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$nickname' => $channel['channel_address'], '$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'))); $mails = array(); $seen = 0; $unknown = false; foreach ($messages as $message) { $s = theme_attachments($message); $mails[] = array('mailbox' => $mailbox, 'id' => $message['id'], 'mid' => $message['mid'], 'from_name' => $message['from']['xchan_name'], 'from_url' => chanlink_hash($message['from_xchan']), 'from_photo' => $message['from']['xchan_photo_s'], 'to_name' => $message['to']['xchan_name'], 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_s'], 'subject' => $message['title'], 'body' => smilies(bbcode($message['body']) . $s), 'delete' => t('Delete message'), 'dreport' => t('Delivery report'), 'recall' => t('Recall message'), 'can_recall' => $channel['channel_hash'] == $message['from_xchan'] ? true : false, 'is_recalled' => intval($message['mail_recalled']) ? t('Message has been recalled.') : '', 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'c')); $seen = $message['seen']; } $recp = $message['from_xchan'] === $channel['channel_hash'] ? 'to' : 'from'; $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array('$mailbox' => $mailbox, '$prvmsg_header' => $message['title'], '$thread_id' => $mid, '$thread_subject' => $message['title'], '$thread_seen' => $seen, '$delete' => t('Delete Conversation'), '$canreply' => $unknown ? false : '1', '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), '$mails' => $mails, '$header' => t('Send Reply'), '$to' => t('To:'), '$reply' => true, '$subject' => t('Subject:'), '$subjtxt' => $message['title'], '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']), '$text' => '', '$parent' => $message['parent_mid'], '$recphash' => $message[$recp]['xchan_hash'], '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$submit' => t('Submit'), '$defexpire' => '', '$feature_expire' => feature_enabled(local_channel(), 'content_expire') ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(local_channel(), 'content_encrypt') ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher)); return $o; }
function smiliesX($var1, $var2, $var3) { $var1 = smilies($var1); $var3 = smilies($var3); return $vra1 . $var2 . $var3; }
function message_content(&$a) { $o = ''; nav_set_selected('messages'); if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content)); if ($a->argc == 3 && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if (!intval($a->argv[2])) { return; } $cmd = $a->argv[1]; if ($cmd === 'drop') { $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if ($r) { info(t('Message deleted.') . EOL); } goaway($a->get_baseurl(true) . '/message'); } else { $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user())); if (count($r)) { $parent = $r[0]['parent-uri']; $convid = $r[0]['convid']; $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc($parent), intval(local_user())); // remove diaspora conversation pointer // Actually if we do this, we can never receive another reply to that conversation, // as we will never again have the info we need to re-create it. // We'll just have to orphan it. //if($convid) { // q("delete from conv where id = %d limit 1", // intval($convid) // ); //} if ($r) { info(t('Conversation removed.') . EOL); } } goaway($a->get_baseurl(true) . '/message'); } } if ($a->argc > 1 && $a->argv[1] === 'new') { $o .= $header; $plaintext = false; if (intval(get_pconfig(local_user(), 'system', 'plaintext'))) { $plaintext = true; } $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $preselect = isset($a->argv[2]) ? array($a->argv[2]) : false; $prename = $preurl = $preid = ''; if ($preselect) { $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", intval(local_user()), intval($a->argv[2])); if (count($r)) { $prename = $r[0]['name']; $preurl = $r[0]['url']; $preid = $r[0]['id']; } } $prefill = $preselect ? $prename : ''; // the ugly select box $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10); $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$to' => t('To:'), '$showinputs' => 'true', '$prefill' => $prefill, '$autocomp' => $autocomp, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? escape_tags(htmlspecialchars($_REQUEST['body'])) : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'), '$submit' => t('Submit'))); return $o; } if ($a->argc == 1) { // list messages $o .= $header; $r = q("SELECT count(*) AS `total` FROM `mail` \n\t\t\tWHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()), dbesc($myprofile)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, \n\t\t\t`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,\n\t\t\tcount( * ) as count\n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\tWHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No messages.') . EOL); return $o; } $tpl = get_markup_template('mail_list.tpl'); foreach ($r as $rr) { if ($rr['unknown']) { $partecipants = sprintf(t("Unknown sender - %s"), $rr['from-name']); } elseif (link_compare($rr['from-url'], $myprofile)) { $partecipants = sprintf(t("You and %s"), $rr['name']); } else { $partecipants = sprintf(t("%s and You"), $rr['from-name']); } $o .= replace_macros($tpl, array('$id' => $rr['id'], '$from_name' => $partecipants, '$from_url' => $rr['network'] === NETWORK_DFRN ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url'], '$sparkle' => ' sparkle', '$from_photo' => $rr['thumb'] ? $rr['thumb'] : $rr['from-photo'], '$subject' => template_escape($rr['mailseen'] ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'), '$delete' => t('Delete conversation'), '$body' => template_escape($rr['body']), '$to_name' => template_escape($rr['name']), '$date' => datetime_convert('UTC', date_default_timezone_get(), $rr['mailcreated'], t('D, d M Y - g:i A')), '$seen' => $rr['mailseen'], '$count' => sprintf(tt('%d message', '%d messages', $rr['count']), $rr['count']))); } $o .= paginate($a); return $o; } if ($a->argc > 1 && intval($a->argv[1])) { $o .= $header; $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` \n\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\tWHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1", intval(local_user()), intval($a->argv[1])); if (count($r)) { $contact_id = $r[0]['contact-id']; $convid = $r[0]['convid']; $sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri'])); if ($convid) { $sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ", dbesc($r[0]['parent-uri']), intval($convid)); } $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` \n\t\t\t\tFROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` \n\t\t\t\tWHERE `mail`.`uid` = %d {$sql_extra} ORDER BY `mail`.`created` ASC", intval(local_user())); } if (!count($messages)) { notice(t('Message not available.') . EOL); return $o; } $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d", dbesc($r[0]['parent-uri']), intval(local_user())); require_once "include/bbcode.php"; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$nickname' => $a->user['nickname'], '$baseurl' => $a->get_baseurl(true))); $mails = array(); $seen = 0; $unknown = false; foreach ($messages as $message) { if ($message['unknown']) { $unknown = true; } if ($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; } else { $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id']; $sparkle = ' sparkle'; } $Text = $message['body']; $saved_image = ''; $img_start = strpos($Text, '[img]data:'); $img_end = strpos($Text, '[/img]'); if ($img_start !== false && $img_end !== false && $img_end > $img_start) { $start_fragment = substr($Text, 0, $img_start); $img_start += strlen('[img]'); $saved_image = substr($Text, $img_start, $img_end - $img_start); $end_fragment = substr($Text, $img_end + strlen('[/img]')); $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment; $search = '/\\[url\\=(.*?)\\]\\[!#saved_image#!\\]\\[\\/url\\]' . '/is'; $replace = '[url=' . z_path() . '/redir/' . $message['contact-id'] . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]'; $Text = preg_replace($search, $replace, $Text); if (strlen($saved_image)) { $message['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]', $Text); } } $mails[] = array('id' => $message['id'], 'from_name' => template_escape($message['from-name']), 'from_url' => $from_url, 'sparkle' => $sparkle, 'from_photo' => $message['from-photo'], 'subject' => template_escape($message['title']), 'body' => template_escape(smilies(bbcode($message['body']))), 'delete' => t('Delete message'), 'to_name' => template_escape($message['name']), 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A')); $seen = $message['seen']; } $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />'; $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array('$thread_id' => $a->argv[1], '$thread_subject' => $message['title'], '$thread_seen' => $seen, '$delete' => t('Delete conversation'), '$canreply' => $unknown ? false : '1', '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), '$mails' => $mails, '$header' => t('Send Reply'), '$to' => t('To:'), '$showinputs' => '', '$subject' => t('Subject:'), '$subjtxt' => template_escape($message['title']), '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$yourmessage' => t('Your message:'), '$text' => '', '$select' => $select, '$parent' => $parent, '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'))); return $o; } }