******************************
----------------------------------------------------
Originally posted by / Author:
V@no----------------------------------------------------
------------| What's new in this version |------ 1) The structure is 90% different then in v1
2) Everything renamed to "pm" instead of "pms" (had to do that, because I was using "pm" from the beginning and every time I do some changes on my site, I'd have to do it twice to post it here...)
3) Admin can:
-turn on/off PM feature
-set limit of messages stored in inbox and sentbox, globaly or per user.
-alow/disalow use HTML, BBCode or [img] tags in messages.
4) No more members list dropdown menu in "New message" form. (member name search is avalable)
5) Advanced BBCode and Smiles are included in this mod. U'll need reinstall them if u have had installed it before separately.
------------| Versions history |------ 2.5.4 (22/04/05)
- Fixed a bug that displayed pm link for guests in comments (redo
Step 12.2)
2.5.3 (26/08/04)
- Fixed a bug that didnt display properly error page when visitor not authorised to use PM (pm.php)
- Fixed submit button didnt get disabled when its pressed. (pm_new.html)
2.5.2 (25/08/04)
Fixed a mini minor bug, no reason to explain what exactly...
2.5.1 (24/08/04)
Just updated pm_new.html template
2.5.1 (12/07/04)
Fixed a problem with "preview" button (just replace pm_new.html template or change in yours: name="Preview" to name="preview")
Added Step 18 witch redirect to index.php on logout from pm.php
2.5 (03/07/04)
Messages from administrators are not being count in alowed limit.
Changed files:
pm.php
2.4 Added new feature:
in view message mode is possible navigate to next/previous message without needed go back to inbox/sentbox/outbox.
Upgrade from v2.3 read here
-----------| Changed Files |-------------------- /member.php
/details.php
/includes/constants.php
/includes/page_header.php
/includes/functions.php
/includes/paging.php
/lang/<yourlanguage>/main.php
/lang/<yourlanguage>/admin.php
<templates of your choice>
/includes/db_field_definitions.php
/templates/<yourtemplate>/member_editprofile.html
/templates/<yourtemplate>/member_profile.html
/templates/<yourtemplate>/comment_bit.html
/templates/<yourtemplate>/header.html
/templates/<yourtemplate>/style.css
/logout.php -----------| New files |--------------------------- pm.php
smiles.php
bbcode2.js
-----------| New templates |-------------------
pm.html
pm_folder.html
pm_view.html
pm_new.html
pm_delete.html
pm_finduser.html
pm_perpage_dropdown_form.html
bbcode2.html
-----------| New email template |------------
pm_notify.html
-----------| New images |----------------------
asc_order.gif
desc_order.gif
pm.gif
scale.gif
scale-bar.gif
scale-end.gif
and
smiles pack
-----------| Installation |-----------------------
NOTE! - If u have installed the old PMS mod, then read next reply below before u make any changes! Remember: ALWAYS DO BACKUPS BEFORE YOU DO ANY CHANGES! Step 1 Download "
PM v2" package.
Extract files, preserve tree structure, and replace any already existing files - but dont forget do backup before overwriting!
/pm.php
/pm_install.php
/bbcode2.js
/includes/paging.php
/lang/<yourlanguage>/email/pm_notify.html
/templates/<yourtemplate>/pm.html
/templates/<yourtemplate>/pm_delete.html
/templates/<yourtemplate>/pm_folder.html
/templates/<yourtemplate>/pm_new.html
/templates/<yourtemplate>/pm_view.html
/templates/<yourtemplate>/pm_finduser.html
/templates/<yourtemplate>/pm_perpage_dropdown_form.html
/templates/<yourtemplate>/bbcode2.html
/templates/<yourtemplate>/images/asc_order.gif
/templates/<yourtemplate>/images/desc_order.gif
/templates/<yourtemplate>/images/scale.gif
/templates/<yourtemplate>/images/scale-bar.gif
/templates/<yourtemplate>/images/scale-end.gif
all files from smiles folder into: /templates/<yourtemplate>/smiles/
Step 2 Open
/includes/constants.php At the end of the file, just before closing ?> add this:
// Advanced BBCode can be only "bbcode" or "bbcode2" SETTING TO OTHER VALUES WILL CAUSE FATAL ERROR!!!
define('BBCODE', "bbcode2");
//PM
define('PM_TABLE', $table_prefix.'pm');
//do not modify next 6 lines!
define('PM_RDLT', 0); //Recipient deleted message (message only in: Sender's Setbox)
define('PM_SDLT', 1); //Sender deleted message (message only in: Recipient's Inbox)
define('PM_SENT', 2); //Recipient read message (message in: Sender's Sentbox and Recipient's Inbox)
define('PM_USDLT', 3); //Recipient has not read message (message only in: Recipient's Inbox)
define('PM_UNREAD', 5); //Recipient has not read message (message in: Sender's Outbox and Recipient's Inbox - New Message)
define('PM_UNLIMITED', -1);
Step 3 Open
/lang/<yourlanguage>/main.php At the end of the file, just before closing ?> add this:
//-----------------------------------------------------
//--- PM (Private Messenging) -------------------------
//-----------------------------------------------------
$lang['pm'] = "Private Messaging";
$lang['pm_inbox'] = "Inbox";
$lang['pm_outbox'] = "Outbox";
$lang['pm_sentbox'] = "Sentbox";
$lang['pm_link'] = " You have<br />» <b>{msg_new_count}</b> new message(s)<br /> in your <b>{inbox}</b>.";
$lang['pm_short'] = "PM";
$lang['pm_error'] = "Error";
$lang['pm_error_to'] = "You must select a recipient.";
$lang['pm_error_to_notfound'] = "Recipient not found.";
$lang['pm_error_subject'] = "You must enter a subject.";
$lang['pm_error_message'] = "You must enter a message.";
$lang['pm_error_folder'] = "No folder selected.";
$lang['pm_error_id'] = "Nothing to show.";
$lang['pm_error_delete'] = "Nothing to delete.";
$lang['pm_compose'] = "Compose";
$lang['pm_delete'] = "Delete";
$lang['pm_delete_selected'] = "Delete selected";
$lang['pm_delete_all'] = "Delete all";
$lang['pm_delete_success'] = "The messages where deleted successfuly";
$lang['pm_delete_confirm'] = "Are you sure you want to delete that message from <b>".$lang['pm_'.$mode]."</b>?";
$lang['pm_delete_confirm_select'] = "Are you sure you want to delete selected messages from <b>".$lang['pm_'.$mode]."</b>?";
$lang['pm_delete_confirm_all'] = "Are you sure you want to delete ALL messages from <b>".$lang['pm_'.$mode]."</b>?";
$lang['pm_new'] = "New message";
$lang['pm_new_messages'] = "New messages";
$lang['pm_new_is_one'] = "You have <b>{count}</b> new"; //You have xx new message(s)
$lang['pm_message_single'] = "message";
$lang['pm_message_plural'] = "messages";
$lang['pm_select_user'] = "Select a user";
$lang['pm_sent_success'] = "The message was send successfully";
$lang['pm_save_success'] = "The message was updated successfully";
$lang['pm_redirect'] = "Please wait a moment";
$lang['pm_empty'] = "No messages in this folder";
$lang['pm_reply'] = "Reply";
$lang['pm_view'] = "View message";
$lang['pm_mark'] = "Mark";
$lang['pm_edit'] = "Edit";
$lang['pm_subject'] = "Subject";
$lang['pm_message'] = "Message";
$lang['pm_to'] = "To";
$lang['pm_date'] = "Date";
$lang['pm_send'] = "Send";
$lang['pm_preview'] = "Preview";
$lang['pm_status'] = "Status";
$lang['pm_from'] = "From";
$lang['pm_html'] = "Enable HTML in this message";
$lang['pm_bbcode'] = "Enable BBCode in this message";
$lang['pm_smiles'] = "Enable emoticons (smiles) in this message";
$lang['pm_perpage'] = "Messages per page";
$lang['pm_user_pm'] = "PM";
$lang['pm_user_pm_alt'] = "Send Private Message";
$lang['pm_total'] = "Total messages";
$lang['pm_received'] = "Received";
$lang['pm_quote'] = "Quote";
$lang['pm_error_save'] = "Error saving message. (the message could has been received)";
$lang['pm_error_notfound'] = "Can't find message.";
$lang['pm_paging_stats'] = "You have {total_cat_images} message(s) {new} on {total_pages} page(s) in your {box}.<br />Displayed: massage {first_page} to {last_page}.";
$lang['pm_email'] = "Notify by email on new Private Messages";
$lang['pm_popup'] = "Pop up window on new Private Messages";
$lang['pm_popup_confirm'] = "You have a new private message. Click OK to view it, or cancel to hide this prompt.";
$lang['pm_popup_newwindow'] = "Open in new window?\\n\\n(Press cancel to open your Inbox in the current window.)";
$lang['pm_email_new'] = "New private message";
$lang['pm_comment_quote'] = "Comment posted by";
$lang['pm_mark_read'] = "Mark all messages read";
$lang['pm_storage'] = "Your {box} is {size}% full";
$lang['pm_storage_unlimited'] = "Your {box} is unlimited";
$lang['pm_user_limit_reached'] = "Sorry, {user}'s Inbox is full";
$lang['pm_inbox_limit'] = "Inbox messages limit";
$lang['pm_sentbox_limit'] = "Sentbox messages limit";
$lang['pm_finduser'] = "Find a username";
$lang['pm_finduser_notfound'] = "No username found";
$lang['pm_finduser_wildcards'] = "Use * as a wildcard for partial matches";
$lang['pm_select'] = "Select";
$lang['pm_finduser_many'] = "Found more then one member. Please select one.";
$lang['pm_user_id_priority'] = "User name <b>selection</b> has higher priority then user name <b>field</b>.";
$lang['pm_user_inbox'] = "Inbox limit<span class=\"smalltext\"><br />set to <font color=red><b>0</b></font> to use global settings<br>or <font color=red><b>-1</b></font> for unlimited</span>";
$lang['pm_user_sentbox'] = "Sentbox limit<span class=\"smalltext\"><br />set to <font color=red><b>0</b></font> to use global settings<br>or <font color=red><b>-1</b></font> for unlimited</span>";
$lang['pm_toosoon'] = "Sorry, you can not send messages so frequently";
$lang['pm_toosoon_user'] = "Sorry, you can not send messages to the same member so frequently";
$lang['pm_next'] = "Next »";
$lang['pm_prev'] = "« Previous";
//-----------------------------------------------------
//--- BBCode2 -----------------------------------------
//-----------------------------------------------------
$lang['code'] = "Code";
$lang['quote'] = "Quote";
$lang['wrote'] = "wrote";
$lang['close_tags'] = "Close all tags";
$lang['close_window'] = "Close window";
$lang['all_emoticons'] = "All emoticons";
$lang['all'] = "All";
$lang['bbc_help_default'] = "Tip: Styles can be applied quickly to selected text.";
$lang['bbc_help'] = array(
"b" => "Bold text: [b]text[/b] (alt+b)",
"i" => "Italic text: [i]text[/i] (alt+i)",
"u" => "Underline text: [u]text[/u] (alt+u)",
"q" => "Quote text: [quote]text[/quote] or [quote=name]text[/quote] (alt+q)",
"l" => "List: [list]text[/list] (alt+l)",
"o" => "Ordered list: [list=]text[/list] (alt+o)",
"p" => "Insert image: [img]http://image_url[/img] (alt+p)",
"w" => "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)",
"a" => "Close all open bbCode tags",
"s" => "Font color: [color=red]text[/color] Tip: you can also use color=#FF0000",
"f" => "Font size: [size=x-small]small text[/size]",
"sh" => "Shadow: [shadow=red,left,1]text[/shadow]",
"g" => "Glow: [glow=red,2,1]text[/glow]",
"al" => "Align: [align=center]text[/align]",
"t" => "Teletype: [tt]text[/tt]",
"ff" => "Font face: [font=verdana]text[/font]",
"h" => "Horisontal line: [hr]",
"m" => "Move: [move]text[/move]",
"fl" => "Flash: [flash=200,200]URL[/flash]",
"sb" => "Subscript: [sub]text[/sub]",
"sp" => "Superscript: [sup]text[/sup]",
"st" => "Line through: [s]text[/s] (alt+s)",
"e" => "Insert email: [email]name@domain[/email] or [email=name@domain]email text[/email] (alt+e)",
"sm" => "Emoticons"
);
Step 4 Open
/admin/settings.php Find the last set of code that starts with:
show_table_separator($setting_group
Look what is the number of the last set:
show_table_separator($setting_group[XX], 2, "#setting_group_XX");
Now, add 1 to that number and remember it, u'll need it 2 times during this installation!
(for example if u have
show_table_separator($setting_group[7], 2, "#setting_group_7");
then 7+1=8 so your number to remmeber is number 8 )
Step 4.2 Find:
show_form_footer($lang['save_changes'], "", 2);
Add before:
show_table_separator($setting_group[XX], 2, "#setting_group_XX");
show_setting_row("pm", "radio");
show_setting_row("pm_html", "radio");
show_setting_row("pm_bbcode", "radio");
show_setting_row("pm_img", "radio");
show_setting_row("pm_inbox");
show_setting_row("pm_sentbox");
Replace XX with the number u remmembered in Step 4.
Step 5 Open
/lang/<yourlanguage>/admin.php Add at the end, just before closing ?>:
/*-- Setting-Group XX --*/
$setting_group[XX]="Private Messaging";
$setting['pm'] = "Allow Private Messaging";
$setting['pm_html'] = "Allow using HTML in messages";
$setting['pm_bbcode'] = "Allow using BBCODE in messages";
$setting['pm_img'] = "Allow using [img] tags in messages";
$setting['pm_inbox'] = "Inbox MAX messages<span class=\"smalltext\"><br />set to <b>0</b> for unlimited</span>";
$setting['pm_sentbox'] = "Sentbox MAX messages<span class=\"smalltext\"><br />set to <b>0</b> for unlimited</span>";
Replace XX with the number from Step 4.
Step 6 Open
/includes/functions.php Find:
function format_text
just comment entire function by doing this:
Add before that line:
/*
and at the end of the function find (in default 4images it would be):
return replace_badwords($text);
}
add after that closing bracket } add this:
*/
Step 6.2 If u installed "Smiles" mod, comment it out too (do same thing as above, use /* at beginning of comment block and */ at the end.
Then add at the end of the file, just before closing ?>
//---Code added for PM MOD------
function strip_brackets($text){
global $lang;
$code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#');
$code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}');
return preg_replace($code_entities_match, $code_entities_replace, $text);
}
function thumb($id, $dim = 50, $align = "bottom") {
global $site_db, $user_info, $site_sess;
if (empty($dim)) $dim = 50;
if (empty($align)) $align = "bottom";
$text = "";
$sql = "SELECT image_name, image_id, image_media_file, image_thumb_file, cat_id
FROM ".IMAGES_TABLE."
WHERE image_id = ".$id;
if ($row = $site_db->query_firstrow($sql)) {
if (!get_file_path($row['image_thumb_file'], "thumb", $row['cat_id'], 0, 0)) {
$file_src = ICON_PATH."/".get_file_extension($row['image_media_file']).".gif";
}else{
$file_src = get_file_path($row['image_thumb_file'], "thumb", $row['cat_id'], 0, 1);
}
$image_info = @get_imagesize($file_src, $info);
$width = $image_info[0];
$height = $image_info[1];
$wh = get_resize($image_info[0], $image_info[1], $dim, $dim);
$text = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\"><img width = \"".$wh[0]."\" height=\"".$wh[1]."\" src=\"".$file_src."\" alt=\"".str_replace("\"", """, $row['image_name'])."\" align=\"".$align."\" border=\"1\" /></a>";
}
return $text;
}
function bb_code($text){
global $lang;
$text = strip_brackets($text);
$text = str_replace(" ", " ", $text);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$text = str_replace(" ", " ", $text);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$text = str_replace("\t", " ", $text);
$text = "<div class=\"codehead\"><b>".$lang['code'].":</b><div class=\"codeblock\">".stripslashes($text)."</div></div>";
return $text;
}
function format_text($text, $html = 0, $word_wrap = 0, $bbcode = 0, $bbcode_img = 0, $smiles = 0, $brackets = 1) {
global $site_template, $lang;
$text = trim($text);
$text = str_replace("\\", "\\\\", $text);
if ($html == 0 || $html == 2) {
$text = safe_htmlspecialchars($text);
}
// Replace { to prevent parsing in templates
$text = preg_replace(
'='.preg_quote($site_template->start).'([A-Z0-9_]+)'.preg_quote($site_template->end).'=Usi',
'{\1}',
$text
);
if ($html !== 2) {
$text = nl2br(trim($text));
$text = replace_url($text);
}
// $text = preg_replace("/(\[)(php)(])(\r\n)*(.*)(\[\/php\])/esiU", "phphighlite('\\5')", $text);
$text = ($smiles) ? smiles($text) : $text;
if ($bbcode == 1) {
$text = preg_replace("/\[php\](.*?)\[\/php\]/esi", "phphighlite('\\1')", $text);
$text = preg_replace("/\[code\](.*?)\[\/code\]/esi", "bb_code('\\1')", $text);
}
if ($brackets) {
$entities_match = array('{', '}');
$entities_replace = array('{', '}');
$text = str_replace($entities_match, $entities_replace, $text);
}
if ($bbcode == 1) {
$text = preg_replace("/\[thumb=([0-9]+)(,([0-9]+)?)?(,([a-zA-Z]+))?\]/esi","thumb('\\1','\\3','\\5')",$text);
$search_array = array(
"/\[b\](.*?)\[\/b\]/si",
"/\[i\](.*?)\[\/i\]/si",
"/\[u\](.*?)\[\/u\]/si",
"/\[email\](.*?)\[\/email\]/si",
"/\[email=(.*?)\](.*?)\[\/email\]/si",
"/\[quote=(.*?)\](.*?)/si",
"/\[quote\](.*?)/si",
"/\[\/quote\]/si",
"/\[url=(.*?)\](.*?)\[\/url\]/si",
"/\[url\](.*?)\[\/url\]/si",
"/\[urlb=(.*?)\](.*?)\[\/urlb\]/si",
"/\[urlb\](.*?)\[\/urlb\]/si",
"/\[sub\](.*?)\[\/sub\]/si",
"/\[sup\](.*?)\[\/sup\]/si",
"/\[color=(.*?)\](.*?)\[\/color\]/si",
"/\[size=(.*?)\](.*?)\[\/size\]/si",
"/\[tt\](.*?)\[\/tt\]/si",
"/\[s\](.*?)\[\/s\]/si",
"/\[move\](.*?)\[\/move\]/si",
// "/\[align=(.*?)\](.*?)\[\/align\]/si",
"/\[align=(.*?)\](.*?)\[\/align\](.<br \/>)?/si",
"/\[font=(.*?)\](.*?)\[\/font\]/si",
"/\[shadow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/shadow\]/si",
"/\[glow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/glow\]/si",
"/\[quote2=(.*?)\,(.*?)(\(.*?\))?\](.*?)/si",
"/\[\/quote2\]/si",
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU",
"/(\[)(list)(])(.*)(\[\/list\])/siU",
"/(\[\*\])/siU",
"/javascript:/si",
"/about:/si",
);
$replace_array = array(
"<b>\\1</b>",
"<i>\\1</i>",
"<u>\\1</u>",
"<a href=mailto:\\1>\\1</a>",
"<a href=mailto:\\1>\\2</a>",
"<div class=\"quotehead\"><b>\\1</b> ".$lang['wrote'].":<div class=\"quoteblock\">\\2",
"<div class=\"quotehead\"><b>".$lang['quote'].":</b><div class=\"quoteblock\">\\1",
"</div></div>",
"<a href=\"\\1\" target=_blank>\\2</a>",
"<a href=\\1 target=_blank>\\1</a>",
"<b><a href=\"\\1\" target=_blank>\\2</a></b>",
"<b><a href=\\1 target=_blank>\\1</a></b>",
"<sub>\\1</sub>",
"<sup>\\1</sup>",
"<font color=\"\\1\">\\2</font>",
"<font style=\"font-size: \\1px\">\\2</font>",
"<tt>\\1</tt>",
"<s>\\1</s>",
"<marquee>\\1</marquee>",
"<div align=\"\\1\">\\2</div>",
"<font face=\"\\1\">\\2</font>",
"<font style=\"Filter: Shadow(color=\\1, Direction=\\2); Width=\\3px;\">\\4</font>",
"<font style=\"Filter: Glow(color=\\1, Strength=\\2); Width=\\3px;\">\\4</font>",
"<div class=\"quotehead\">\\1<b>\\2</b>\\3:<div class=\"quoteblock\">\\4",
"</div></div>",
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"java script",
"about :",
);
preg_match_all("/(\[quote=(.+?)\])|(\[quote\])/", $text, $regs);
$quoteopen = count($regs[0]);
preg_match_all("/(\[\/quote\])/", $text, $regs);
$quoteclose = count($regs[0]);
if($quoteopen > $quoteclose) {
$toclose = $quoteopen - $quoteclose;
for($i = 0 ; $i < $toclose ; $i++) {
$text .= "[/quote]";
}
}elseif($quoteclose > $quoteopen) {
$toopen = $quoteclose - $quoteopen;
for($i = 0 ; $i < $toopen ; $i++) {
$text = "[quote]$text";
}
}
$text = preg_replace($search_array, $replace_array, $text);
if (!$bbcode_img) {
$text = preg_replace("/\[img\](.*?)\[\/img\]/si", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $text);
$text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
}else{
$text = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">", $text);
$text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" height=\"\\2\" width=\"\\1\">",$text);
$text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" height=\"\\1\" width=\"\\2\">",$text);
$text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" width=\"\\1\" height=\"\\2\">",$text);
$text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","<object classid=\"clsid: D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\\1 height=\\2><param name=movie value=\\3><param name=play value=true><param name=loop value=true><param name=quality value=high><embed src=\\3 width=\\1 height=\\2 play=true loop=true quality=high></embed></object>",$text);
}
$text = str_replace("[hr]", "<hr>", $text);
}
return replace_badwords(stripslashes($text));
}
function phphighlite($code) {
//PHP 4 only
if (floor(phpversion())<4) {
$buffer=$code;
} else {
// $code = str_replace("<br>", "", $code);
// $code = str_replace("<br />", "", $code);
$code = str_replace(">", ">", $code);
$code = str_replace("<", "<", $code);
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
$code="<?\n".trim($code)."\n?>";
$addedtags=1;
}
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$buffer = ob_get_contents();
ob_end_clean();
if ($addedtags) {
$openingpos = strpos($buffer,'<?');
$closingpos = strrpos($buffer, '?');
$buffer=substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
}
// $buffer = str_replace(""", "\"", $buffer);
}
return "<div class=\"codehead\"><b>PHP:</b><div class=\"codeblock\">".preg_replace("/<code><font color=\"#000000\">\n<font color=\"(.*)\">\n/si", "<code><font color=\"#000000\"><font color=\"\\1\">", str_replace("\n</font>\n</code>", "</font></code>", $buffer))."</div></div>";
}
//--------------------------
//--------Smiles------------
//--------------------------
function smiles($text,$enablesmilies = 1) {
global $smileyfromcache, $smileytocache;
$imagesdir = TEMPLATE_PATH."/smiles";
if(gettype($smileyfromcache) != "array") {
$smilesfrom = get_smiles();
foreach ($smilesfrom as $key => $val) {
$smileyfromcache[] ='/(((>[^<]*)|(^[^<]*))([\s\n\r]|^|<br( \/)?[>]))('.str_replace('|','\|', quotemeta(str_replace("<", "<", str_replace(">", ">", str_replace("\/", "\\\/", $key))))).')/s';
$smileytocache[] = "\\1<img src=\"$imagesdir/$val.gif\" alt=\"\" border=\"0\">";
}
}
if ($enablesmilies) {
$text = parsesmilies($text);
}
return $text;
}
function parsesmilies($text) {
global $smileyfromcache, $smileytocache;
$oldtext = "";
while($oldtext != $text) {
$oldtext = $text;
$text = preg_replace($smileyfromcache, $smileytocache, $text);
}
return $text;
}
function get_smiles(){
$smilesfrom = array(
":)" => "happy",
"(:" => "happy",
":-))" => "very_happy",
":lol:" => "very_happy",
":D" => "big_smile",
":O" => "surprised",
":o" => "surprised",
";)" => "wink",
":wink:" => "wink",
":(" => "sad",
":*(" => "very_sad",
":cry:" => "very_sad",
":confused:" => "confused",
":shy:" => "embarrassed",
":vicious:" => "vicious",
":|" => "undecided",
":pig:" => "pig",
":P" => "tongue",
":p" => "tongue",
"B)" => "cool",
":B" => "nerd",
"X(" => "angry",
":X" => "in_love",
"|)" => "asleep",
"=;" => "talk_to_hand",
"@};-" => "rose",
"):)" => "cowboy",
"8X" => "skull",
"=:)" => "alien",
"0:)" => "angel",
":devil:" => "devil",
":clown:" => "clown",
"3:O" => "cow",
"3:o" => "cow",
":monkey:" => "monkey",
"(~~)" => "pumpkin",
"[-(" => "huff",
"*:)" => "bulb",
":$" => "shhh",
":chicken:" => "chicken",
"~o)" => "cup",
"%%-" => "clover",
"b(" => "beat_up",
":E:" => "peace",
":&" => "sick",
"=*" => "kiss",
";;)" => "flirt",
":?)" => "what",
"(%)" => "ying",
"o-+" => "april",
":billy:" => "billy",
":hiro:" => "hiro",
":mad:" => "mad",
":R:" => "praying",
"[-x" => "nono",
"[:D]" => "hugging",
":dance:" => "dancing",
"=D" => "applause",
"(?)" => "thinking",
":^o" => "liar",
"@)" => "hypnotized",
"8|" => "rolleyes",
"8}" => "crazy",
"?|" => "tired",
"=p~" => "drooling",
"$)" => "money",
":whistle:" => "whistling",
"#o" => "doh",
":alien:" => "alien2",
":S" => "scared"
);
return $smilesfrom;
}
function get_smiles_text() {
global $lang;
$smilesfrom = get_smiles();
$val_old = "";
$i = 0;
$val_old = array();
foreach ($smilesfrom as $key => $val) {
if (!in_array($val, $val_old)) {
$smiles_text .= "<a href=\"javascript:emoticon('$key')\"><img src=\"".TEMPLATE_PATH."/smiles/$val.gif\" alt=\"$key\" border=\"0\"></a> ";
}
$val_old[] = $val;
$i++;
if ($i > 18) {
$smiles_text .= "<a href=\"smiles.php\" onclick=\"window.open('smiles.php', '_4imagessmilies', 'HEIGHT=310,resizable=yes,scrollbars=yes,WIDTH=225');return false;\" target=\"_4imagessmilies\"> ".$lang['all']."</a>";
return $smiles_text;
}
}
return $smiles_text;
}
//------End Smiles-------
function get_resize($file = "", $dim, $width = 0, $height = 0, $scale = 0){
if ($file) {
if ($file = @getimagesize($file)) {
$width = $file[0];
$height = $file[1];
}
}
if ($width && $height) {
if ($width > $dim || $height > $dim || $scale) {
@$ratio = $width / $height;
if ($ratio > 1) {
$new_width = $dim;
$new_height = round(($dim/$width) * $height);
}else {
$new_width = round(($dim/$height) * $width);
$new_height = $dim;
}
}
else {
$new_width = $width;
$new_height = $height;
}
}else{
$new_width = $dim;
$new_height = $dim;
}
return array($new_width, $new_height, $file);
}
//----End of code added for PM mod-----
Step 7 Open
/includes/page_header.php Find:
$site_template->register_vars(array(
"media_url" => MEDIA_PATH,
Replace with:
//-----------------------------------------------------
//--- pm ---------------------------------------------
//-----------------------------------------------------
$inbox = "";
$outbox = "";
$sentbox = "";
$newpm = "";
$pm_popup_script = "";
$pm_popup_head = "";
$pm = "";
if ($config['pm'] && $user_info['user_level'] >= USER) {
$sql = "SELECT COUNT(pm_id) AS total
FROM ".PM_TABLE."
WHERE pm_to = ".$user_info['user_id']." AND (pm_type = ".PM_SENT." OR pm_type = ".PM_SDLT." OR pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")";
$result = $site_db->query_firstrow($sql);
$pm_inbox = $result['total'];
$sql = "SELECT COUNT(pm_id) AS total
FROM ".PM_TABLE."
WHERE pm_from = ".$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")";
$result = $site_db->query_firstrow($sql);
$pm_outbox = $result['total'];
$sql = "SELECT COUNT(pm_id) AS total
FROM ".PM_TABLE."
WHERE pm_from = ".$user_info['user_id']." AND (pm_type = ".PM_SENT." OR pm_type = ".PM_RDLT.")";
$result = $site_db->query_firstrow($sql);
$pm_sentbox = $result['total'];
$sql = "SELECT COUNT(pm_id) AS new
FROM ".PM_TABLE."
WHERE pm_to = ".$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")
ORDER BY pm_date DESC";
$result = $site_db->query_firstrow($sql);
$pm_new_count = $result['new'];
$sql = "SELECT pm_date
FROM ".PM_TABLE."
WHERE pm_to = ".$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")
ORDER BY pm_date DESC";
$result = $site_db->query_firstrow($sql);
$pm_new = "<a href=\"".$site_sess->url(ROOT_PATH."pm.php")."\">".(($pm_new_count) ? "<blink>".$pm_new_count."</blink>" : 0)."</a>";
$pm = preg_replace("/".$site_template->start."msg_new_count".$site_template->end."/siU", $pm_new, $lang['pm_link']);
$pm = preg_replace("/".$site_template->start."inbox".$site_template->end."/siU", "<a href=\"".$site_sess->url(ROOT_PATH."pm.php")."\">".$lang['pm_inbox']."</a>", $pm);
$blink = "<script language=\"JavaScript\">\n<!--\nvar flg=0;\nfunction blink(){\nvar myElement=document.getElementById('blnk');\nflg^=1;\nif(flg==1){\nmyElement.style.visibility='hidden';\n}\nelse{\nmyElement.style.visibility='visible';\n}\ntimerID = setTimeout( 'blink()' , 500 );\n}\n//-->\n</script>\n";
$show_inbox = ($pm_new_count) ? $blink."<span id=\"blnk\">".$lang['pm_inbox']."</span><script language=\"JavaScript\">blink();</script>" : $lang['pm_inbox'];
$inbox = "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=inbox")."\" title=\"".(($pm_new_count) ? $lang['pm_new_messages'].": ".$pm_new_count."\n" : "").$lang['pm_total'].": ".$pm_inbox."\">".$show_inbox."</a>";
$sentbox = "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=sentbox")."\" title=\"".$lang['pm_total'].": ".$pm_sentbox."\">".$lang['pm_sentbox']."</a>";
$outbox = "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=outbox")."\" title=\"".$lang['pm_total'].": ".$pm_outbox."\">".$lang['pm_outbox']."</a>";
$newpm = "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=new")."\">".$lang['pm_new']."</a>";
if ($result && $user_info['user_pm_popup']) {
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_pmnewpopup = isset($HTTP_COOKIE_VARS[$cookie_name.'pmnewpopup']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'pmnewpopup'])) : 0;
if ($cookie_pmnewpopup < $result['pm_date']) {
if (ereg("pm.php", $self_url) && $action == "inbox") {
$cookie_expire = time() + 60 * 60 * 24 * 90;
setcookie($cookie_name.'pmnewpopup', serialize($result['pm_date']), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
}elseif (!ereg("pm.php", $self_url) || (ereg("pm.php", $self_url) && ($action == "sentbox" || $action == "outbox"))){
$cookie_expire = gmdate('D, d M Y H:i:s \G\M\T', time() + 60 * 60 * 24 * 90);
$pm_popup_script = " <script language=\"JavaScript\">
<!--
function SetCookie (name, value, expire, path, domain, secure) {
document.cookie = name + '=' + escape(value) + ((expire)?(';expires=' + expire):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':'');
}
function confirm_newpm() {
input_box=confirm('".$lang['pm_popup_confirm']."');
if (input_box==true) { // Output when OK is clicked
second_box=confirm('".$lang['pm_popup_newwindow']."');
if (second_box==true) {
SetCookie('".$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."');
window.open('".$site_sess->url(ROOT_PATH."pm.php")."','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
} else {
SetCookie('".$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."');
window.location='".$site_sess->url(ROOT_PATH."pm.php")."';
}
} else {
SetCookie('".$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."');
}
}
// -->
</script>";
$pm_popup_header = " onload=\"Javascript:confirm_newpm()\"";
}
}
}
}
$site_template->register_vars(array(
"pm" => $pm,
"pm_boxes" => ($inbox) ? $inbox." | ".$sentbox." | ".$outbox." | ".$newpm : "",
"pm_inbox" => $inbox,
"pm_sentbox" => $sentbox,
"pm_outbox" => $outbox,
"pm_newpm" => $newpm,
"pm_popup_script" => $pm_popup_script,
"pm_popup_header" => $pm_popup_header,
"bbcode2" => (BBCODE == "bbcode") ? 0 : 1,
"pm_inbox_total" => ($pm_inbox) ? $pm_inbox : 0,
"pm_outbox_total" => ($pm_outbox) ? $pm_outbox : 0,
"pm_sentbox_total" => ($pm_sentbox) ? $pm_sentbox : 0,
"pm_new_total" => ($pm_new_count) ? $pm_new_count : 0,
"media_url" => MEDIA_PATH,
Step 8 Open
/includes/db_field_definitions.php At the end of the file, just before closing ?> add:
$additional_user_fields['user_pm_inbox'] = array($lang['pm_user_inbox'], "text", 0);
$additional_user_fields['user_pm_sentbox'] = array($lang['pm_user_sentbox'], "text", 0);
$additional_user_fields['user_pm_email'] = array($lang['pm_email'], "radio", 0);
$additional_user_fields['user_pm_popup'] = array($lang['pm_popup'], "radio", 0);
Step 9 In your browser start
pm_install.php * in address bar type something like this: http://<YOURSITE>/4images/pm_install.php
Finish the installation.
After this step the main installation is complete.
U can check it by going to:
http://<YOURSITE>/4images/pm.php Step 10 Edit templates where u want to show links to the PM folders.
Use these tags:
{pm_boxes} - this will show folders: "Inbox | Sentbox | Outbox | New Message"
{pm} - this will show "You have XX new images in Inbox"
You also can use:
{pm_inbox} - link to inbox
{pm_sentbox} - link to sentbox
{pm_outbox} - link to outbox
{pm_newpm} - link to new message
{pm_inbox_total} - # of messages in inbox
{pm_outbox_total} - # of messages in outbox
{pm_sentbox_total} - # of messages in sentbox
{pm_new_total} - # of new messages
Step 11 Open /member.php
Find:
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
"user_name" => (isset($user_row['user_name'])) ? htmlspecialchars($user_row['user_name']) : REPLACE_EMPTY,
Add after:
"lang_pm" => ($user_info['user_id'] != $user_row['user_id']) ? "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=new&user_id=".$user_row['user_id'])."\">".$lang['pm_user_pm_alt']."</a>" : "",
Step 12 Open
/details.php Find:
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq")."
Replace with:
$additional_sql = "";
if (!empty($additional_user_fields)) {
$table_fields = $site_db->get_table_fields(USERS_TABLE);
foreach ($additional_user_fields as $key => $val) {
if (isset($table_fields[$key])) {
$additional_sql .= ", u.$key";
}
}
}
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq").get_user_table_field(", u.", "user_id").$additional_sql."
Step 12.2 Find:
"comment_id" => $comment_row[$i]['comment_id'],
Add after:
"comment_user_pm" => ($config['pm'] && $comment_row[$i]['user_id'] != GUEST && $user_info['user_level'] > GUEST && $user_info['user_id'] != $comment_row[$i]['user_id']) ? "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=quote&mode=comment&id=".$comment_row[$i]['comment_id']."&user_id=".$comment_row[$i]['user_id'])."\" /><img src=\"".get_gallery_image("pm.gif")."\" border=\"0\" alt=\"".$lang['pm_user_pm_alt']."\" /></a>" : "",
Step 13 In
/templates/<yourtemplate>/member_profile.html use {lang_pm} tag
In
/templates/<yourtemplate>/comment_bit.html use {comment_user_pm} tag to show link to PM the user
Step 14 Open
/templates/<yourtemplate>/member_editprofile.html Add this:
<tr>
<td class="row2"><b>{lang_user_pm_email}</b></td>
<td class="row2">
<input type="radio" name="user_pm_email" value="1"{user_pm_email_yes} />
{lang_yes}
<input type="radio" name="user_pm_email" value="0"{user_pm_email_no} />
{lang_no}
</td>
</tr>
<tr>
<td class="row1"><b>{lang_user_pm_popup}</b></td>
<td class="row1">
<input type="radio" name="user_pm_popup" value="1"{user_pm_popup_yes} />
{lang_yes}
<input type="radio" name="user_pm_popup" value="0"{user_pm_popup_no} />
{lang_no}
</td>
</tr>
Step 15 Open
/templates/<yourtemplate>/header.html 1. in between <head> and </head> add this:
{pm_popup_script} 2. inside <body> tag add
{pm_popup_header} Should looks like this: <body {pm_popup_header}
Step 16 In
/templates/<yourtemplate>/style.css Add those classes:
.msg0 {
background-color: #FFCECE;
color: #2F6B9D;
}
.msg1 {
background-color: #CEFFDD;
color: #2F6B9D;
}
.msg_good {
background-color: #CEFFDD;
font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}
.msg_error {
background-color: #FFCECE;
font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}
.msg_plain {
background-color: transparent;
font-weight: bold;
border: 1px solid #5E6C80;
padding: 3px 3px 3px 3px ;
margin: 3px 0px 3px 0px ;
}
/*--BBCode--------------------------------------------------*/
input.bbcbutton {
background-color : #EFEFEF;
color : #000000;
font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif;
}
.helpline {
width: 300px;
height: 30px;
overflow: hidden;
background-color: transparent;
border-style: none;
font-family: Verdana,Tahoma,Arial,Helvetica,sans-serif;
font-size : 10px;
color: #666666;
}
div.quotehead {
font-size: 11px;
color: black;
padding: 0px 24px 0px 24px ;
}
div.quoteblock {
border: 1px solid #5E6C80;
font-size: 10px;
padding: 8px 8px 8px 8px ;
}
div.codehead {
font-size: 11px;
color: black;
padding: 0px 24px 0px 24px ;
}
div.codeblock {
border: 1px solid #5E6C80;
font-family: Courier, 'Courier New', sans-serif;
font-size: 10px;
padding: 8px 8px 8px 8px ;
background-color: #F5F5F5;
white-space: pre;
}
Step 17 / 18 Continue on next reply below
-----------| Note |----------------------------- If u get an error message:
Fatal error: Cannot redeclare <name>
then search for the function <name> in the file where the error sais,
just comment that function, the same way as u did in Step 6.
For upgrade from PMS v1 read next reply below.[/quote][/quote]