• [MOD] PMv2 Tutorial Republished here 5 0 5 1
Currently:  

Author Topic: [MOD] PMv2 Tutorial Republished here  (Read 812826 times)

0 Members and 1 Guest are viewing this topic.

Offline Mark Gunter

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • http://www.allservico.com/
[MOD] PMv2 Tutorial Republished here
« on: March 13, 2005, 02:41:55 PM »
PM v.2 with revisions by V@no is Republished below. Thanks V@no for this mod!  8)

Offline Mark Gunter

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • http://www.allservico.com/
Re: [MOD] PMv2 Tutorial Republished here
« Reply #1 on: March 18, 2005, 02:47:11 PM »
******************************
----------------------------------------------------
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:

Code: [Select]
// 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:

Code: [Select]

//-----------------------------------------------------
//--- PM (Private Messenging) -------------------------
//-----------------------------------------------------
$lang['pm'] = "Private Messaging";
$lang['pm_inbox'] = "Inbox";
$lang['pm_outbox'] = "Outbox";
$lang['pm_sentbox'] = "Sentbox";
$lang['pm_link'] = "&nbsp;&nbsp;&nbsp;You have<br />&raquo&nbsp;<b>{msg_new_count}</b> new message(s)<br />&nbsp;&nbsp;&nbsp;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 &raquo;";
$lang['pm_prev'] = "&laquo; 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:

Code: [Select]

  show_table_separator($setting_group

Look what is the number of the last set:

Quote

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
Quote

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:
Code: [Select]

show_form_footer($lang['save_changes'], "", 2);


Add before:
Code: [Select]

  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 ?>:
Code: [Select]

/*-- 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:
Code: [Select]

function format_text


just comment entire function by doing this:
Add before that line:
Code: [Select]

/*

and at the end of the function find (in default 4images it would be):
Code: [Select]

  return replace_badwords($text);
}

add after that closing bracket } add this:
Code: [Select]

*/


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: [Select]
//---Code added for PM MOD------
function strip_brackets($text){
  global $lang;
   $code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#');
   $code_entities_replace = array('&lt;', '&gt;', '&quot;', ':', '[', ']', '(', ')', '&#123;', '&#125;');
  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("\"", "&quot;", $row['image_name'])."\" align=\"".$align."\" border=\"1\" /></a>";
  }
  return $text;
}
function bb_code($text){
  global $lang;
  $text = strip_brackets($text);
  $text = str_replace("  ", "&nbsp; ", $text);
   // now Replace 2 spaces with " &nbsp;" to catch odd #s of spaces.
   $text = str_replace("  ", " &nbsp;", $text);
   // Replace tabs with "&nbsp; &nbsp;" so tabbed code indents sorta right without making huge long lines.
   $text = str_replace("\t", "&nbsp; &nbsp;", $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',
    '&#123;\1&#125;',
    $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('&#123;', '&#125;');
    $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("&gt;", ">", $code);
      $code = str_replace("&lt;", "<", $code);

      $code = str_replace("&amp;", "&", $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,'&lt;?');
        $closingpos = strrpos($buffer, '?');
        $buffer=substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
      }
//      $buffer = str_replace("&quot;", "\"", $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("<", "&lt;", str_replace(">", "&gt;", 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\">&nbsp;&nbsp;&nbsp;".$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:
Code: [Select]

$site_template->register_vars(array(
  "media_url" => MEDIA_PATH,

Replace with:
Code: [Select]

//-----------------------------------------------------
//--- 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."&nbsp;&nbsp;|&nbsp;&nbsp;".$sentbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$outbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$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:
Code: [Select]

$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. :wink: :D
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:
Code: [Select]

    $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:
Code: [Select]

       "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:
Code: [Select]
 $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:
Code: [Select]

  $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:
Code: [Select]

        "comment_id" => $comment_row[$i]['comment_id'],

Add after:
Code: [Select]

        "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:
Code: [Select]

          <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}&nbsp;&nbsp;&nbsp;
              <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}&nbsp;&nbsp;&nbsp;
              <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:
Code: [Select]

.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:
 
Quote
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]
« Last Edit: August 12, 2010, 04:40:06 AM by V@no »

Offline Mark Gunter

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • http://www.allservico.com/
Re: [MOD] PMv2 Tutorial Republished here
« Reply #2 on: March 18, 2005, 02:50:40 PM »

Continue PM v2

Step 17

If u wish use smiles in comments, in details.php find:
Code: [Select]

        "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
        "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),

Replace with:
Code: [Select]

        "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0, 1, 1),
        "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments'], 1 , 1),



In case u want use smiles somewhere else, u'll need use format_text function, set 6th parameter to 1.
The parameters are:
format_text(param1 <text>, param2 <html> (0 or 1), param3 <words wrap> (number), param4 <bbcode> (0 or 1), param5 <bbcode-img> (0 or 1), param6 <smiles> (0 or 1), param7 <bracket> (0 or 1));
7th parameter (<bracket>) should be used if u need to use { and } bracket, otherwise 4images would treat it as a template tag and result could be unexpected.

Step 18

Open logout.php
Find:
Code: [Select]

if (!ereg("index.php", $url) && !ereg("lightbox.php", $url) && !ereg("login.php", $url) && !ereg("register.php", $url) && !ereg("member.php", $url)) {

Replace with:
Code: [Select]

if (!ereg("index.php", $url) && !ereg("lightbox.php", $url) && !ereg("login.php", $url) && !ereg("register.php", $url) && !ereg("member.php", $url) && !ereg("pm.php", $url)) {





Upgrade from PMS v1

I must warn u, the upgrade will be pretty much painfull because:
- all previous changes must be removed
- you will lose your templates
- after u uninstall the previous version u'll need do the installation above.

But there is good news, u will NOT loose your messages, the database update will be automatic and lossless.


Remmeber: ALWAYS DO BACKUPS WHEN U MODIFY ANYTHING!

Step 1
 
Delete thise files:
/pms.php
/pms_install.php
/templates/<yourtemplate>/pms.html
/templates/<yourtemplate>/pms_delete.html
/templates/<yourtemplate>/pms_folder.html
/templates/<yourtemplate>/pms_new.html
/templates/<yourtemplate>/pms_view.html
/templates/<yourtemplate>/pms_perpage_dropdown_form.html
/templates/<yourtemplate>/images/asc_order.png
/templates/<yourtemplate>/images/desc_order.png
/lang/<yourlanguage>/email/notify.html



Step 2
 
Remove from /includes/constants.php:
Code: [Select]

//PMS
define('PMS_TABLE', $table_prefix.'pms');
define('PMS_RDLT', 0); //Recipient deleted message (message only in: Sender's Setbox)
define('PMS_SDLT', 1); //Sender deleted message (message only in: Recipient's Inbox)
define('PMS_SENT', 2); //Recipient read message (message in: Sender's Sentbox and Recipient's Inbox)
define('PMS_UNREAD', 3); //Recipient not read message (message in: Sender's Outbox and Recipient's Inbox - New Message)




Step 3
Remove from /lang/<yourlanguage>/main.php:
Code: [Select]

//--- PMS ----
$lang['pms_inbox'] = "Inbox";
$lang['pms_outbox'] = "Outbox";
$lang['pms_sentbox'] = "Sentbox";
$lang['pms_link'] = "&nbsp;&nbsp;&nbsp;You have<br />&raquo&nbsp;<b>{msg_new_count}</b> new message(s)<br />&nbsp;&nbsp;&nbsp;in your <b>{inbox}</b>.";
$lang['pms'] = "Private Messaging";
$lang['pms_short'] = "PMS";
$lang['pms_error'] = "Error";
$lang['pms_error_to'] = "You must select a recipient.";
$lang['pms_error_subject'] = "You must enter a subject.";
$lang['pms_error_message'] = "You must enter a message.";
$lang['pms_error_folder'] = "No folder selected.";
$lang['pms_error_id'] = "Nothing to show.";
$lang['pms_error_delete'] = "Nothing to delete.";
$lang['pms_compose'] = "Compose";
$lang['pms_delete'] = "Delete";
$lang['pms_delete_selected'] = "Delete selected";
$lang['pms_delete_all'] = "Delete all";
$lang['pms_delete_success'] = "The messages where deleted successfuly";
$lang['pms_delete_confirm'] = "Are you sure you want to delete that message from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_delete_confirm_select'] = "Are you sure you want to delete selected messages from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_delete_confirm_all'] = "Are you sure you want to delete ALL messages from <b>".$lang['pms_'.$mode]."</b>?";
$lang['pms_new'] = "New message";
$lang['pms_select_user'] = "Select a user";
$lang['pms_sent_success'] = "The message was send successfully";
$lang['pms_redirect'] = "Please wait a moment";
$lang['pms_empty'] = "No messages in this folder";
$lang['pms_reply'] = "Reply";
$lang['pms_view'] = "View message";
$lang['pms_mark'] = "Mark";
$lang['pms_edit'] = "Edit";
$lang['pms_subject'] = "Subject";
$lang['pms_message'] = "Message";
$lang['pms_to'] = "Recipient";
$lang['pms_date'] = "Date";
$lang['pms_send'] = "Send";
$lang['pms_preview'] = "Preview";
$lang['pms_status'] = "Status";
$lang['pms_from'] = "Sender";
$lang['pms_html'] = "Anable HTML in this message";
$lang['pms_bbcode'] = "Anable BBCode in this message";
$lang['pms_perpage'] = "Messages per page";
$lang['pms_user_pm'] = "PM";
$lang['pms_user_pm_alt'] = "PM to this user";
$lang['pms_total'] = "Total messages";
$lang['pms_received'] = "Received";
$lang['pms_quote'] = "Quote";
$lang['pms_error_save'] = "Error saving message. (the message could has been received)";
$lang['pms_error_notfound'] = "Can't find message.";
$lang['pms_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['pms_email'] = "Notify by email on new Private Message";
$lang['pms_popup'] = "Pop up window on new Private Message";
$lang['pms_popup_confirm'] = "You have a new private message. Click OK to view it, or cancel to hide this prompt.";
$lang['pms_popup_newwindow'] = "Open in new window?\\n\\n(Press cancel to open your Inbox in the current window.)";
$lang['pms_email_new'] = "New private message";




Step 4

Remove from /includes/page_header.php
Code: [Select]

//-----------------------------------------------------
//--- PMS ---------------------------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(pms_id) AS total
            FROM ".PMS_TABLE."
            WHERE pms_to = ".$user_info['user_id']." AND (pms_type = ".PMS_SENT." OR pms_type = ".PMS_SDLT." OR pms_type = ".PMS_UNREAD.")";
$result = $site_db->query_firstrow($sql);
$pms_inbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS total
            FROM ".PMS_TABLE."
            WHERE pms_from = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD;
$result = $site_db->query_firstrow($sql);
$pms_outbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS total
            FROM ".PMS_TABLE."
            WHERE pms_from = ".$user_info['user_id']." AND (pms_type = ".PMS_SENT." OR pms_type = ".PMS_RDLT.")";
$result = $site_db->query_firstrow($sql);
$pms_sentbox = $result['total'];
$sql = "SELECT COUNT(pms_id) AS new
            FROM ".PMS_TABLE."
            WHERE pms_to = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD;
$result = $site_db->query_firstrow($sql);
$pms_new = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php")."\">".(($result['new']) ? "<blink>".$result['new']."</blink>" : 0)."</a>";
$pms = preg_replace("/".$site_template->start."msg_new_count".$site_template->end."/siU", $pms_new, $lang['pms_link']);
$pms = preg_replace("/".$site_template->start."inbox".$site_template->end."/siU", "<a href=\"".$site_sess->url(ROOT_PATH."pms.php")."\">".$lang['pms_inbox']."</a>", $pms);
// PMS Boxes
$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 = ($result['new']) ? $blink."<span id=\"blnk\">".$lang['pms_inbox']."</span><script language=\"JavaScript\">blink();</script>" : $lang['pms_inbox'];
$inbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=inbox")."\" title=\"".$lang['pms_total']." (".$pms_inbox.")\">".$show_inbox."</a>";
$sentbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=sentbox")."\" title=\"".$lang['pms_total']." (".$pms_sentbox.")\">".$lang['pms_sentbox']."</a>";
$outbox = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=outbox")."\" title=\"".$lang['pms_total']." (".$pms_outbox.")\">".$lang['pms_outbox']."</a>";
$newpms = "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=new")."\">".$lang['pms_new']."</a>";

$sql = "SELECT pms_date
            FROM ".PMS_TABLE."
            WHERE pms_to = ".$user_info['user_id']." AND pms_type = ".PMS_UNREAD."
            ORDER BY pms_date DESC";
$result = $site_db->query_firstrow($sql);
$pms_popup_script = "";
$pms_popup_header = "";
if ($result && $user_info['user_pms_popup'] && !ereg("pms.php", $self_url)) {
   $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
   $cookie_pmsnewpopup = isset($HTTP_COOKIE_VARS[$cookie_name.'pmsnewpopup']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'pmsnewpopup'])) : 0;
   $pmsnewpopup = (isset($session_info['pmsnewpopup'])) ? $session_info['pmsnewpopup'] : $cookie_pmsnewpopup;
   if ($pmsnewpopup < $result['pms_date']) {
      $cookie_expire = time() + 60 * 60 * 24 * 90;
      setcookie($cookie_name.'pmsnewpopup', serialize($result['pms_date']), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      $site_sess->set_session_var("pmsnewpopup", $result['pms_date']);
      $pms_popup_script = "<script language=\"JavaScript\">
      <!--
      function confirm_newpm() {
         input_box=confirm('".$lang['pms_popup_confirm']."');
         if (input_box==true) { // Output when OK is clicked
            second_box=confirm('".$lang['pms_popup_newwindow']."');
            if (second_box==true) {
               window.open('".$site_sess->url(ROOT_PATH."pms.php")."','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
            } else {
               window.location='".$site_sess->url(ROOT_PATH."pms.php")."';
            }
         } else {
         // Output when Cancel is clicked
         }
      }
      // -->
      </script>";
      $pms_popup_header = "onload=\"Javascript:confirm_newpm()\"";
   }
}



Step 4.2
 
Remove:
Code: [Select]

   "pms_boxes" => ($user_info['user_level'] < USER) ? "" : $inbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$sentbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$outbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$newpms,
   "pms_popup_script" => $pms_popup_script,
   "pms_popup_header" => $pms_popup_header,



Step 4.3

Remove:
Code: [Select]

"pms" => $pms,



Step 5
 
Replace all {pms} and {pms_boxes} tags in your templates with {pm} and {pm_boxes}


Step 6
 
Remove from /member.php
Code: [Select]

       "lang_pm" => ($user_info['user_id'] != $user_row['user_id']) ? "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=reply&user_id=".$user_row['user_id'])."\" alt=\"".$lang['pms_user_pm_alt']."\">".$lang['pms_user_pm']."</a>" : "",



Step 7

Remove from /details.php
Code: [Select]

"lang_pm" => ($user_info['user_id'] != $comment_row[$i]['user_id'] && $user_info['user_level'] >= USER && $comment_row[$i]['user_id'] >= USER) ? "<a href=\"".$site_sess->url(ROOT_PATH."pms.php?action=reply&user_id=".$comment_row[$i]['user_id'])."\" alt=\"".$lang['pms_user_pm_alt']."\">".$lang['pms_user_pm']."</a>" : "",




Step 8
 
Remove from /includes/db_field_definitions.php
Code: [Select]

$additional_user_fields['user_pms_email'] = array($lang['pms_email'], "radio", 0);
$additional_user_fields['user_pms_popup'] = array($lang['pms_popup'], "radio", 0);



Step 9

In /templates/<yourtemplate>/member_editprofile.html and in /templates/<yourtemplate>/header.html replace all pms u can find, with pm (then u can skip Step 14 and Step 15 in installation)
Also, if u installed any addons to PMS v1 or changed any code from "official" code, then u'll need search for PMS and pms strings in ALL the files u possible could change anything in and replace them with PM and pm



Now u can do the installation above.
Good luck Smile

Offline Mark Gunter

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • http://www.allservico.com/
Re: [MOD] PMv2 Tutorial Republished here
« Reply #3 on: March 18, 2005, 02:53:47 PM »
PLEASE if anyone has an answer to my problem - PREVIEW doesn't work on PMs, the preview button sends the message, just like the send button - I need help with this.

I know that V@no and others are very busy restoring mods, so if anyone else has had this problem and found a solution, please help . . .

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] PMv2 Tutorial Republished here
« Reply #4 on: March 29, 2005, 01:07:58 PM »
I'm also trying to fix that problem with PMS v2.5.3 on my page - first I thought, I found a solution, but it worked only with IE all other browsers were sending the message instead of previewing it...

The strange thing is, that the form-data is absolutely similar to the form-data on other pages, where the preview-button works fine (e.g. V@no's gallery), so the problem must be somewhere in the php-code of my site.
MAяTRIX


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] PMv2 Tutorial Republished here
« Reply #5 on: March 29, 2005, 08:44:18 PM »
actualy the problem is in PHP itself...some PHP versions cant "see" value of the "submit" button - and that what preview button is based on...u'll have to use javascript in the preview button:
Code: [Select]
onClick="action.value='preview';"
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] PMv2 Tutorial Republished here
« Reply #6 on: March 30, 2005, 07:24:23 PM »
I*T  W*O*R*K*S*!
I was searching me mad because of that "error" and @ the end the reason is, because my hoster changed the PHP version w/o telling me... and I thought I made a typo somewhere in the code, whilst playing around with it.  :D

Thank you V@no :)

BTW: In the original PMS2.5.3 package is the MOST IMPORTANT emoticon missing:
 :wink:
have fun
MAяTRIX


Offline Mark Gunter

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
    • http://www.allservico.com/
Re: [MOD] PMv2 Tutorial Republished here
« Reply #7 on: March 31, 2005, 10:44:41 PM »
FANTASTIC!  :lol:

Such a simple solution! Thanks, Vano!

Are you happy with the formatting of the PM tutorial above? I can send the formatted version in an email to you, or post it, as it is, in "Mods Publishing . . ." forum if you like. Also, can help to re-format some of the other "lost" mods if you like.

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] PMv2 Tutorial Republished here
« Reply #8 on: April 12, 2005, 05:00:45 AM »
OMG!!! what a great MOD!!! The best MOD ever!

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] PMv2 Tutorial Republished here
« Reply #9 on: April 12, 2005, 04:42:01 PM »
Hi everyone How can use the bbcode from the the mod PM v.2 in my commments? I have installed the Both MODS Smillies and PM

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] PMv2 Tutorial Republished here
« Reply #10 on: April 12, 2005, 04:49:35 PM »
If you'd like to use the PMv2 BBCode, you'd have to implement the PMv2...  :wink:

And then I guess it could go by replacing

{bbcode}
with {bbcode2} in the comment_form.html template...  :?:

For smilies:
Quote
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 ?>...

and check step 17 here:
http://www.4homepages.de/forum/index.php?topic=6692.msg30080#msg30080

For PM version 1 uninstall:
Check the text after
Quote
Upgrade from PMS v1
here
http://www.4homepages.de/forum/index.php?topic=6692.msg30080#msg30080 (just a few posts above)
MAяTRIX


Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] PMv2 Tutorial Republished here
« Reply #11 on: April 12, 2005, 05:23:43 PM »
I have implement PMv.2 that what I asked that ;) but my smilies don't work any more in comments, i don't know how to put the PMv.2 bbcode i try to change {bbcode} with {bbcode2} but it does not work

I also put this in details.php
Code: [Select]
        "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0, 1, 1),
        "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments'], 1 , 1),

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] PMv2 Tutorial Republished here
« Reply #12 on: April 12, 2005, 10:05:51 PM »
 onClick="action.value='preview';" where I shoul put this?

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] PMv2 Tutorial Republished here
« Reply #13 on: April 12, 2005, 11:25:59 PM »
Well,

1) you should first completely remove the old PMS version 1.

2) Then remove (or comment out) the old smilie-mod.

3) Install the PM system v2.5.3

And after all these steps it should work just fine...

the onClick=blablabla has to be in the pm-template called pm_new.html as a new attribute of the preview button there...
But you need that only if the preview function does not work on your site...
MAяTRIX


Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] PMv2 Tutorial Republished here
« Reply #14 on: April 12, 2005, 11:33:33 PM »
Thanks for your help!! :)
but I have never installed the old PMS version 1.
I installed  Install the PM system v2.5.3 last week :)
the preview function does not work on my site