diff --git a/e107_plugins/forum/forum_admin_class.php b/e107_plugins/forum/forum_admin_class.php
index d3400608d..9e24394d1 100755
--- a/e107_plugins/forum/forum_admin_class.php
+++ b/e107_plugins/forum/forum_admin_class.php
@@ -9,8 +9,8 @@
* Forum admin functions
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_admin_class.php,v $
-* $Revision: 1.7 $
-* $Date: 2008-12-05 20:28:05 $
+* $Revision: 1.8 $
+* $Date: 2008-12-08 02:33:34 $
* $Author: mcfly_e107 $
*
*/
@@ -676,6 +676,10 @@ class forumAdmin
{
$text .= "
".FORLAN_139."";
}
+ if(!is_writable(e_PLUGIN.'forum/attachments'))
+ {
+ $text .= "
Attachment file is not writable!";
+ }
$text .= "
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index f89da5076..70c46bf44 100644
--- a/e107_plugins/forum/forum_post.php
+++ b/e107_plugins/forum/forum_post.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
-| $Revision: 1.25 $
-| $Date: 2008-12-07 04:16:38 $
+| $Revision: 1.26 $
+| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -251,12 +251,14 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
{
foreach($uploadResult as $ur)
{
- $postInfo['post_entry'] .= $ur['txt'];
- $attachments[] = $ur['att'];
+ //$postInfo['post_entry'] .= $ur['txt'];
+ $_tmp = $ur['type'].'*'.$ur['file'];
+ if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
+ $attachments[] = $_tmp;
}
$postInfo['post_attachments'] = implode(',', $attachments);
- var_dump($uploadResult);
}
+ var_dump($uploadResult);
switch($action)
{
@@ -542,11 +544,15 @@ function process_upload()
$postId = (int)$postId;
$ret = array();
+// var_dump($_FILES);
if (isset($_FILES['file_userfile']['error']))
{
require_once(e_HANDLER.'upload_handler.php');
- if ($uploaded = file_upload('/'.e_FILE.'public/', 'attachment', 'FT_'))
+ $attachmentDir = e_PLUGIN.'forum/attachments/';
+ $thumbDir = e_PLUGIN.'forum/attachments/thumb/';
+
+ if ($uploaded = process_uploaded_files($attachmentDir, 'attachment', ''))
{
foreach($uploaded as $upload)
{
@@ -554,58 +560,63 @@ function process_upload()
{
$_txt = '';
$_att = '';
- $fpath = "{e_FILE}public/";
+ $_file = '';
+ $_thumb = '';
+ $fpath = '{e_PLUGIN}forum/attachments/';
if(strstr($upload['type'], 'image'))
{
+ $_type = 'img';
if(isset($pref['forum_maxwidth']) && $pref['forum_maxwidth'] > 0)
{
require_once(e_HANDLER.'resize_handler.php');
$orig_file = $upload['name'];
- $p = strrpos($orig_file,'.');
- $new_file = substr($orig_file, 0 , $p).'_'.substr($orig_file, $p);
- if(resize_image(e_FILE.'public/'.$orig_file, e_FILE.'public/'.$new_file, $pref['forum_maxwidth']))
+ $new_file = 'th_'.$orig_file;
+ if(resize_image($attachmentDir.$orig_file, $attachmentDir.'thumb/'.$new_file, $pref['forum_maxwidth']))
{
if($pref['forum_linkimg'])
{
- $parms = image_getsize(e_FILE.'public/'.$new_file);
+ $parms = image_getsize($attachmentDir.$new_file);
$_txt = '[br][link='.$fpath.$orig_file."][img{$parms}]".$fpath.$new_file.'[/img][/link][br]';
- $_att = $new_file;
+ $_file = $orig_file;
+ $_thumb = $new_file;
//show resized, link to fullsize
}
else
{
- @unlink(e_FILE.'public/'.$orig_file);
+ @unlink($attachmentDir.$orig_file);
//show resized
- $parms = image_getsize(e_FILE.'public/'.$new_file);
+ $parms = image_getsize($attachmentDir.$new_file);
$_txt = "[br][img{$parms}]".$fpath.$new_file.'[/img][br]';
- $_att = $new_file;
+ $_file = $new_file;
}
}
else
{ //resize failed, show original
- $parms = image_getsize(e_FILE.'public/'.$upload['name']);
+ $parms = image_getsize($attachmentDir.$upload['name']);
$_txt = "[br][img{$parms}]".$fpath.$upload['name'].'[/img]';
- $_att = $upload['name'];
+ $_file = $upload['name'];
}
}
else
{ //resizing disabled, show original
- $parms = image_getsize(e_FILE.'public/'.$upload['name']);
+ $parms = image_getsize($attachmentDir.$upload['name']);
//resizing disabled, show original
$_txt = "[br][img{$parms}]".$fpath.$upload['name']."[/img]
\n";
- $_att = $upload['name'];
+ $_file = $upload['name'];
}
}
else
{
//upload was not an image, link to file
+ $_type = 'file';
$_fname = (isset($upload['rawname']) ? $upload['rawname'] : $upload['name']);
$_txt = '[br][file='.$fpath.$upload['name'].']'.$_fname.'[/file]';
- $_att = $upload['name'];
+ $_file = $upload['name'];
+ $_thumb = $_fname;
}
- if($_txt && $_att)
+ if($_txt && $_file)
{
- $ret[] = array('txt' => $_txt, 'att' => $_att);
+ $ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb);
}
}
else
diff --git a/e107_plugins/forum/forum_shortcodes.php b/e107_plugins/forum/forum_shortcodes.php
index 1b96a0a86..abec08afb 100644
--- a/e107_plugins/forum/forum_shortcodes.php
+++ b/e107_plugins/forum/forum_shortcodes.php
@@ -27,11 +27,39 @@ $e107 = e107::getInstance();
return $e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY', 'class:'.$post_info['user_class']);
SC_END
-SC_BEGIN PRIVMESSAGE
-global $pref, $post_info, $tp;
-if(isset($pref['plug_installed']['pm']) && ($post_info['user_id'] > 0))
+SC_BEGIN ATTACHMENTS
+global $postInfo;
+$e107 = e107::getInstance();
+if($postInfo['post_attachments'])
{
- return $tp->parseTemplate("{SENDPM={$post_info['user_id']}}");
+ $attachments = explode(',', $postInfo['post_attachments']);
+ $txt = '';
+ foreach($attachments as $a)
+ {
+ $info = explode('*', $a);
+ switch($info[0])
+ {
+ case 'file':
+ $txt .= IMAGE_attachment." {$info[2]}
";
+ break;
+
+ case 'img':
+ //if image has a thumb, show it and link to main
+ if(isset($info[2]))
+ {
+ $txt .= "
";
+ }
+ }
+ }
+ return $txt;
+}
+SC_END
+
+SC_BEGIN PRIVMESSAGE
+global $postInfo, $tp;
+if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
+{
+ return $tp->parseTemplate("{SENDPM={$postInfo['post_user']}}");
}
SC_END
@@ -99,18 +127,18 @@ return '';
SC_END
SC_BEGIN EMAILITEM
-global $post_info, $tp;
-if($post_info['thread_parent'] == 0)
+global $postInfo, $tp;
+if($postInfo['thread_start'])
{
- return $tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$post_info['thread_id']}}");
+ return $tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$postInfo['post_thread']}}");
}
SC_END
SC_BEGIN PRINTITEM
-global $post_info, $tp;
-if($post_info['thread_parent'] == 0)
+global $postInfo, $tp;
+if($postInfo['thread_start'])
{
- return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$post_info['thread_id']}}");
+ return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$postInfo['post_thread']}}");
}
SC_END
@@ -130,11 +158,10 @@ return ($postInfo['user_signature'] ? "
parseTemplate("{PROFILE={$post_info['user_id']}}");
-} else {
-return "";
+global $postInfo, $tp;
+if (USER && $postInfo['user_name'])
+{
+ return $tp->parseTemplate("{PROFILE={$postInfo['post_user']}}");
}
SC_END
@@ -147,9 +174,10 @@ if ($postInfo['post_user'])
SC_END
SC_BEGIN VISITS
-global $post_info;
-if ($post_info['user_id']) {
-return LAN_09.": ".$post_info['user_visits']."
";
+global $postInfo;
+if ($postInfo['user_name'])
+{
+return LAN_09.': '.$postInfo['user_visits'].'
';
}
SC_END
@@ -163,16 +191,17 @@ if ($postInfo['user_customtitle'])
SC_END
SC_BEGIN WEBSITE
-global $post_info, $tp;
-if ($post_info['user_homepage']) {
-return LAN_08.": ".$post_info['user_homepage']."
";
+global $postInfo, $tp;
+if ($postInfo['user_homepage']) {
+return LAN_08.': '.$postInfo['user_homepage'].'
';
}
SC_END
SC_BEGIN WEBSITEIMG
-global $post_info;
-if ($post_info['user_homepage'] && $post_info['user_homepage'] != "http://") {
-return "".IMAGE_website."";
+global $postInfo;
+if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://')
+{
+ return "".IMAGE_website.'';
}
SC_END
@@ -209,8 +238,8 @@ if (USER) {
SC_END
SC_BEGIN RPG
-global $post_info;
-return rpg($post_info['user_join'],$post_info['user_forums']);
+global $postInfo;
+return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']);
SC_END
SC_BEGIN MEMBERID
@@ -263,8 +292,9 @@ return $ldata[$post_info['user_id']][1];
SC_END
SC_BEGIN MODOPTIONS
-if (MODERATOR) {
-return showmodoptions();
+if (MODERATOR)
+{
+ return showmodoptions();
}
SC_END
@@ -274,7 +304,6 @@ if ($postInfo['post_edit_datestamp'])
{
return $gen->convert_date($postInfo['thread_edit_datestamp'],'forum');
}
-return '';
SC_END
SC_BEGIN LASTEDITBY
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php
index a0dd867f5..65b878e1f 100644
--- a/e107_plugins/forum/forum_viewtopic.php
+++ b/e107_plugins/forum/forum_viewtopic.php
@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
-| $Revision: 1.9 $
-| $Date: 2008-12-07 04:16:38 $
+| $Revision: 1.10 $
+| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -45,6 +45,13 @@ $thread = new e107ForumThread;
$thread->init();
+if(isset($_POST['track_toggle']))
+{
+ $thread->toggle_track();
+ exit;
+}
+//print_a($_POST);
+
if(isset($_GET['f']))
{
$thread->processFunction();
@@ -92,7 +99,6 @@ if (MODERATOR && isset($_POST['mod']))
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
//var_dump($thread->threadInfo);
-require_once (HEADERF);
require_once (e_HANDLER . 'level_handler.php');
$gen = new convert;
if ($thread->message)
@@ -143,19 +149,25 @@ $NEXTPREV .= "
if ($pref['forum_track'] && USER)
{
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
- $url = $e107->url->getUrl('forum', 'thread', array('func' => 'track_toggle', 'id' => $thread->threadId));
+ $url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$TRACK .= "
{$img}
";
}
@@ -206,6 +218,7 @@ foreach ($postList as $postInfo)
if ($i > 1)
{
+ $postInfo['thread_start'] = false;
$alt = !$alt;
if (isset($FORUMREPLYSTYLE_ALT) && $alt)
{
@@ -218,6 +231,7 @@ foreach ($postList as $postInfo)
}
else
{
+ $postInfo['thread_start'] = true;
$forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
}
}
@@ -247,6 +261,7 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
$forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
$forumstring = $forstr . $forthr . $forrep . $forend;
+require_once (HEADERF);
//If last post came after USERLV and not yet marked as read, mark the thread id as read
if ($thread->threadInfo['thread_lastpost'] > USERLV && (strpos($currentUser['user_plugin_forum_viewed'], '.' . $thread->threadId . '.') === false))
{
@@ -457,6 +472,29 @@ class e107ForumThread
$this->noInc = false;
}
+ function toggle_track()
+ {
+ global $forum, $thread;
+ $e107 = e107::getInstance();
+ if (!USER || !isset($_GET['id'])) { return; }
+ if($thread->threadInfo['track_userid'])
+ {
+ $forum->track('del', USERID, $_GET['id']);
+ $img = IMAGE_untrack;
+ }
+ else
+ {
+ $forum->track('add', USERID, $_GET['id']);
+ $img = IMAGE_track;
+ }
+ if(e_AJAX_REQUEST)
+ {
+ $url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
+ echo "{$img}";
+ exit();
+ }
+ }
+
function processFunction()
{
global $forum, $thread;
@@ -487,7 +525,7 @@ class e107ForumThread
exit;
}
break;
-
+/*
case 'track':
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('add', USERID, $_GET['id']);
@@ -510,27 +548,7 @@ class e107ForumThread
exit();
}
break;
-
- case 'track_toggle':
- if (!USER || !isset($_GET['id'])) { return; }
- if($thread->threadInfo['track_userid'])
- {
- $forum->track('del', USERID, $_GET['id']);
- $img = IMAGE_untrack;
- }
- else
- {
- $forum->track('add', USERID, $_GET['id']);
- $img = IMAGE_track;
- }
- if(e_AJAX_REQUEST)
- {
- $url = $e107->url->getUrl('forum', 'thread', array('func' => 'track_toggle', 'id' => $thread->threadId));
- echo "{$img}";
- exit();
- }
- break;
-
+*/
case 'last':
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
diff --git a/e107_plugins/forum/templates/forum_icons_template.php b/e107_plugins/forum/templates/forum_icons_template.php
index 4e101a18d..314585b98 100644
--- a/e107_plugins/forum/templates/forum_icons_template.php
+++ b/e107_plugins/forum/templates/forum_icons_template.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_icons_template.php,v $
-| $Revision: 1.4 $
-| $Date: 2008-12-07 04:16:39 $
+| $Revision: 1.5 $
+| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -51,6 +51,7 @@ define("IMAGE_admin_move2", "
");
define("IMAGE_post2", "
");
define("IMAGE_report", "
");
+define("IMAGE_attachment", "
");
define("IMAGE_track", "
");
define("IMAGE_untrack", "
");
diff --git a/e107_plugins/forum/templates/forum_viewtopic_template.php b/e107_plugins/forum/templates/forum_viewtopic_template.php
index e6b8f810d..5d724f909 100644
--- a/e107_plugins/forum/templates/forum_viewtopic_template.php
+++ b/e107_plugins/forum/templates/forum_viewtopic_template.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_viewtopic_template.php,v $
-| $Revision: 1.2 $
-| $Date: 2006-12-16 14:13:28 $
+| $Revision: 1.3 $
+| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -27,6 +27,9 @@ $sc_style['LASTEDIT']['post'] = " ]";
$sc_style['LEVEL']['pre'] = "";
$sc_style['LEVEL']['post'] = "
";
+$sc_style['ATTACHMENTS']['pre'] = "
";
+$sc_style['ATTACHMENTS']['post'] = "
";
+
$sc_style['ANON_IP']['pre'] = "
";
$sc_style['ANON_IP']['post'] = "
";
@@ -104,7 +107,7 @@ $FORUMTHREADSTYLE = "
{THREADDATESTAMP}
- {REPORTIMG}{EDITIMG}{QUOTEIMG}
+ {EMAILITEM} {PRINTITEM} {REPORTIMG}{EDITIMG}{QUOTEIMG}
|
@@ -125,6 +128,7 @@ $FORUMTHREADSTYLE = "
@@ -210,6 +214,7 @@ $FORUMREPLYSTYLE = "