diff --git a/e107_plugins/forum/e_url/thread.php b/e107_plugins/forum/e_url/thread.php
index 72909a666..3e5cd8a28 100644
--- a/e107_plugins/forum/e_url/thread.php
+++ b/e107_plugins/forum/e_url/thread.php
@@ -1,5 +1,5 @@
fieldTypes['forum_post']['post_datestamp'] = 'int';
$this->fieldTypes['forum_post']['post_thread'] = 'int';
$this->fieldTypes['forum_post']['post_options'] = 'escape';
+ $this->fieldTypes['forum_post']['post_attachments'] = 'escape';
$this->fieldTypes['forum_thread']['thread_user'] = 'int';
$this->fieldTypes['forum_thread']['thread_lastpost'] = 'int';
@@ -156,12 +157,13 @@ class e107forum
{
//Future option, will just set to true here
$addUserPostCount = true;
+ $result = false;
$e107 = e107::getInstance();
- $result = $e107->sql->db_Insert('forum_post', $postInfo);
+ $postId = $e107->sql->db_Insert('forum_post', $postInfo);
$forumInfo = array();
- if($result && $updateThread)
+ if($postId && $updateThread)
{
$threadInfo = array();
if(varset($postInfo['post_user']))
@@ -229,6 +231,7 @@ class e107forum
';
$result = $e107->sql->db_Select_gen($qry);
}
+ return $postId;
}
@@ -240,8 +243,8 @@ class e107forum
{
$postInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$postInfo['post_thread'] = $newThreadId;
- $result = $this->postAdd($postInfo, false);
- return $newThreadId;
+ $newPostId = $this->postAdd($postInfo, false);
+ return array('postid' => $newPostId, 'threadid' => $newThreadId);
}
return false;
}
diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php
index 5dce1af37..f89da5076 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.24 $
-| $Date: 2008-12-07 00:21:21 $
+| $Revision: 1.25 $
+| $Date: 2008-12-07 04:16:38 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -49,16 +49,6 @@ switch($action)
case 'rp':
$threadInfo = $forum->threadGet($id, false);
$forumId = $threadInfo['thread_forum_id'];
-// var_dump($threadInfo);
-// if (!is_array($thread_info) || !count($thread_info))
-// {
-// $forum_info = false; // Someone fed us a dud forum id - should exist if replying
-// }
-// else
-// {
-// $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
-// }
-// $forum_id = $forum_info['forum_id'];
break;
case 'nt':
@@ -116,15 +106,16 @@ define('e_PAGETITLE', LAN_01.' / '.$forumInfo['forum_name'].' / '.($action == 'r
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-if (is_readable(e_ADMIN.'filetypes.php'))
+if($pref['forum_attach'])
{
- $a_filetypes = trim(file_get_contents(e_ADMIN.'filetypes.php'));
- $a_filetypes = explode(',', $a_filetypes);
- foreach ($a_filetypes as $ftype)
- {
- $sa_filetypes[] = '.'.trim(str_replace('.', '', $ftype));
- }
- $allowed_filetypes = implode(' | ', $sa_filetypes);
+ global $allowed_filetypes, $max_upload_size;
+ include_once(e_HANDLER.'upload_handler.php');
+ $a_filetypes = get_filetypes();
+ $max_upload_size = calc_max_upload_size(-1); // Find overriding maximum upload size
+ $max_upload_size = set_max_size($a_filetypes, $max_upload_size);
+ $max_upload_size = $e107->parseMemorySize($max_upload_size, 0);
+ $a_filetypes = array_keys($a_filetypes);
+ $allowed_filetypes = implode(' | ', $a_filetypes);
}
if (isset($_POST['submitpoll']))
@@ -196,17 +187,17 @@ if (isset($_POST['fpreview']))
$post = $tp->post_toForm($_POST['post']);
$subject = $tp->post_toHTML($_POST['subject'], false);
- if ($action == "edit")
+ if ($action == 'edit')
{
if ($_POST['subject'])
{
- $action = "edit";
+ $action = 'edit';
}
else
{
- $action = "reply";
+ $action = 'reply';
}
- $eaction = TRUE;
+ $eaction = true;
}
else if($action == 'quote')
{
@@ -234,7 +225,6 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
exit;
}
$hasPoll = ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '');
- process_upload();
$postInfo['post_ip'] = $e107->getip();
if (USER)
@@ -256,13 +246,25 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$postInfo['post_datestamp'] = $time;
$threadInfo['thread_lastpost'] = $time;
+ //If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
+ if($uploadResult = process_upload($newPostId))
+ {
+ foreach($uploadResult as $ur)
+ {
+ $postInfo['post_entry'] .= $ur['txt'];
+ $attachments[] = $ur['att'];
+ }
+ $postInfo['post_attachments'] = implode(',', $attachments);
+ var_dump($uploadResult);
+ }
+
switch($action)
{
// Reply only. Add the post, update thread record with latest post info.
// Update forum with latest post info
case 'rp':
$postInfo['post_thread'] = $id;
- $postResult = $forum->postAdd($postInfo);
+ $newPostId = $forum->postAdd($postInfo);
break;
// New thread started. Add the thread info (with lastest post info), add the post.
@@ -278,7 +280,11 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$threadOptions['poll'] = '1';
}
$threadInfo['thread_options'] = serialize($threadOptions);
- $postResult = $forum->threadAdd($threadInfo, $postInfo);
+ if($postResult = $forum->threadAdd($threadInfo, $postInfo))
+ {
+ $newPostId = $postResult['postid'];
+ $newThreadId = $postResult['threadid'];
+ }
break;
}
@@ -300,8 +306,10 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
exit;
}
- $threadId = ($action == 'nt' ? $postResult : $id);
+ $threadId = ($action == 'nt' ? $newThreadId : $id);
+
+ //If a poll was submitted, let's add it to the poll db
if ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '')
{
require_once(e_PLUGIN.'poll/poll_class.php');
@@ -351,7 +359,7 @@ if (isset($_POST['update_thread']))
{
if (!isAuthor())
{
- $ns->tablerender(LAN_95, "
".LAN_96."
");
+ $ns->tablerender(LAN_95, "".LAN_96.'
');
require_once(FOOTERF);
exit;
}
@@ -452,13 +460,13 @@ if ($action == 'edit' || $action == 'quote')
if (!$FORUMPOST)
{
- if (is_readable(THEME."forum_post_template.php"))
+ if (is_readable(THEME.'forum_post_template.php'))
{
- include_once(THEME."forum_post_template.php");
+ include_once(THEME.'forum_post_template.php');
}
else
{
- include_once(e_PLUGIN."forum/templates/forum_post_template.php");
+ include_once(e_PLUGIN.'forum/templates/forum_post_template.php');
}
}
@@ -515,67 +523,6 @@ function isAuthor()
return ((USERID === $postInfo['post_user']) || MODERATOR);
}
-function getuser($name)
-{
- global $tp, $sql, $e107;
- $ret = array();
- $ip = $e107->getip();
- $name = str_replace("'", "", $name);
- if (!$name)
- {
- // anonymous guest
-// $name = "0.".LAN_311.chr(1).$ip;
- $ret['post_userid'] = "0";
- $ret['post_user_name'] = LAN_311;
- return $ret;
- }
- else
- {
- if ($sql->db_Select("user", "user_id, user_ip", "user_name='".$tp -> toDB($name)."'"))
- {
- $row = $sql->db_Fetch();
- if ($row['user_ip'] == $ip)
- {
- $ret['post_userid'] = $row['user_id'];
- $ret['post_user_name'] = $name;
- }
- else
- {
- return -1;
- }
- }
- else
- {
-// $name = "0.".substr($tp->toDB($name), 0, 20).chr(1).$ip;
- $ret['post_userid'] = "0";
- $ret['post_user_name'] = $tp->toDB($name);
- }
- }
- return $ret;
-}
-
-function loginf() {
- $text .= "";
- $ns = new e107table;
- $ns->tablerender(LAN_175, $text);
-}
-
function forumjump()
{
global $forum;
@@ -589,48 +536,40 @@ function forumjump()
return $text;
}
-function redirect($url)
-{
- echo "\n";
-}
-
function process_upload()
{
global $pref, $forum_info, $thread_info, $admin_log;
-
- if(isset($thread_info['head']['thread_id']))
- {
- $tid = $thread_info['head']['thread_id'];
- }
- else
- {
- $tid = 0;
- }
+
+ $postId = (int)$postId;
+ $ret = array();
if (isset($_FILES['file_userfile']['error']))
{
- require_once(e_HANDLER."upload_handler.php");
- if ($uploaded = file_upload('/'.e_FILE."public/", "attachment", "FT{$tid}_"))
+ require_once(e_HANDLER.'upload_handler.php');
+ if ($uploaded = file_upload('/'.e_FILE.'public/', 'attachment', 'FT_'))
{
foreach($uploaded as $upload)
{
if ($upload['error'] == 0)
{
+ $_txt = '';
+ $_att = '';
$fpath = "{e_FILE}public/";
- if(strstr($upload['type'], "image"))
+ if(strstr($upload['type'], 'image'))
{
if(isset($pref['forum_maxwidth']) && $pref['forum_maxwidth'] > 0)
{
- require_once(e_HANDLER."resize_handler.php");
+ 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);
+ $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']))
{
if($pref['forum_linkimg'])
{
$parms = image_getsize(e_FILE.'public/'.$new_file);
- $_POST['post'] .= "[br][link=".$fpath.$orig_file."][img{$parms}]".$fpath.$new_file."[/img][/link][br]";
+ $_txt = '[br][link='.$fpath.$orig_file."][img{$parms}]".$fpath.$new_file.'[/img][/link][br]';
+ $_att = $new_file;
//show resized, link to fullsize
}
else
@@ -638,33 +577,43 @@ function process_upload()
@unlink(e_FILE.'public/'.$orig_file);
//show resized
$parms = image_getsize(e_FILE.'public/'.$new_file);
- $_POST['post'] .= "[br][img{$parms}]".$fpath.$new_file."[/img][br]";
+ $_txt = "[br][img{$parms}]".$fpath.$new_file.'[/img][br]';
+ $_att = $new_file;
}
}
else
{ //resize failed, show original
$parms = image_getsize(e_FILE.'public/'.$upload['name']);
- $_POST['post'] .= "[br][img{$parms}]".$fpath.$upload['name']."[/img]";
+ $_txt = "[br][img{$parms}]".$fpath.$upload['name'].'[/img]';
+ $_att = $upload['name'];
}
}
else
{ //resizing disabled, show original
$parms = image_getsize(e_FILE.'public/'.$upload['name']);
//resizing disabled, show original
- $_POST['post'] .= "[br][img{$parms}]".$fpath.$upload['name']."[/img]
\n";
+ $_txt = "[br][img{$parms}]".$fpath.$upload['name']."[/img]
\n";
+ $_att = $upload['name'];
}
}
else
{
//upload was not an image, link to file
- $_POST['post'] .= "[br][file=".$fpath.$upload['name']."]".(isset($upload['rawname']) ? $upload['rawname'] : $upload['name'])."[/file]";
+ $_fname = (isset($upload['rawname']) ? $upload['rawname'] : $upload['name']);
+ $_txt = '[br][file='.$fpath.$upload['name'].']'.$_fname.'[/file]';
+ $_att = $upload['name'];
+ }
+ if($_txt && $_att)
+ {
+ $ret[] = array('txt' => $_txt, 'att' => $_att);
}
}
else
{ // Error in uploaded file
- echo "Error in uploaded file: ".(isset($upload['rawname']) ? $upload['rawname'] : $upload['name'])."
";
+ echo 'Error in uploaded file: '.(isset($upload['rawname']) ? $upload['rawname'] : $upload['name']).'
';
}
}
+ return $ret;
}
}
}
@@ -677,7 +626,7 @@ function image_getsize($fname)
}
else
{
- return "";
+ return '';
}
}
diff --git a/e107_plugins/forum/forum_post_shortcodes.php b/e107_plugins/forum/forum_post_shortcodes.php
index 950b7b53a..baafc63db 100644
--- a/e107_plugins/forum/forum_post_shortcodes.php
+++ b/e107_plugins/forum/forum_post_shortcodes.php
@@ -83,9 +83,9 @@ SC_END
SC_BEGIN FILEATTACH
global $pref, $fileattach, $fileattach_alert;
-if ($pref['forum_attach'] && strpos(e_QUERY, "edit") === FALSE && (check_class($pref['upload_class']) || getperms('0')))
+if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0')))
{
- if (is_writable(e_FILE."public"))
+ if (is_writable(e_FILE.'public'))
{
return $fileattach;
}
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php
index c7530ff96..a0dd867f5 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.8 $
-| $Date: 2008-12-07 00:21:21 $
+| $Revision: 1.9 $
+| $Date: 2008-12-07 04:16:38 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -142,53 +142,22 @@ $NEXTPREV .= "
if ($pref['forum_track'] && USER)
{
- if ($thread->threadInfo['track_userid'])
- {
- $TRACK = "
-
- 'untrack', 'id' => $thread->threadId)) . "'>" . LAN_392 . "
- ";
- $url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
- $TRACK = "
+ $img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
+ $url = $e107->url->getUrl('forum', 'thread', array('func' => 'track_toggle', 'id' => $thread->threadId));
+ $TRACK .= "
- ".IMAGE_untrack."
+ {$img}
-
- ";
- }
- else
- {
- $TRACK = "
-
- 'track', 'id' => $thread->threadId)) . "'>" . LAN_391 . "
-
- ";
- $url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
- $TRACK = "
-
- ".IMAGE_track."
-
-
-
- ";
- }
+ ";
}
$MODERATORS = LAN_321 . implode(', ', $modArray);
@@ -542,6 +511,27 @@ class e107ForumThread
}
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);
$pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage);
diff --git a/e107_plugins/forum/images/dark/attach.png b/e107_plugins/forum/images/dark/attach.png
new file mode 100755
index 000000000..faa19ed9f
Binary files /dev/null and b/e107_plugins/forum/images/dark/attach.png differ
diff --git a/e107_plugins/forum/images/dark/track.png b/e107_plugins/forum/images/dark/track.png
new file mode 100755
index 000000000..c6fae12c8
Binary files /dev/null and b/e107_plugins/forum/images/dark/track.png differ
diff --git a/e107_plugins/forum/images/dark/untrack.png b/e107_plugins/forum/images/dark/untrack.png
new file mode 100755
index 000000000..71385bebb
Binary files /dev/null and b/e107_plugins/forum/images/dark/untrack.png differ
diff --git a/e107_plugins/forum/images/lite/attach.png b/e107_plugins/forum/images/lite/attach.png
new file mode 100755
index 000000000..faa19ed9f
Binary files /dev/null and b/e107_plugins/forum/images/lite/attach.png differ
diff --git a/e107_plugins/forum/images/lite/track.png b/e107_plugins/forum/images/lite/track.png
new file mode 100755
index 000000000..c6fae12c8
Binary files /dev/null and b/e107_plugins/forum/images/lite/track.png differ
diff --git a/e107_plugins/forum/images/lite/untrack.png b/e107_plugins/forum/images/lite/untrack.png
new file mode 100755
index 000000000..71385bebb
Binary files /dev/null and b/e107_plugins/forum/images/lite/untrack.png differ
diff --git a/e107_plugins/forum/templates/forum_icons_template.php b/e107_plugins/forum/templates/forum_icons_template.php
index 548fc7cf2..4e101a18d 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.3 $
-| $Date: 2008-12-07 00:21:21 $
+| $Revision: 1.4 $
+| $Date: 2008-12-07 04:16:39 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -52,8 +52,8 @@ define("IMAGE_post", "
");
define("IMAGE_report", "
");
-define("IMAGE_track", "
");
-define("IMAGE_untrack", "
");
+define("IMAGE_track", "
");
+define("IMAGE_untrack", "
");
// Admin Icons
diff --git a/e107_plugins/forum/templates/forum_post_template.php b/e107_plugins/forum/templates/forum_post_template.php
index 8802830f1..783a76203 100644
--- a/e107_plugins/forum/templates/forum_post_template.php
+++ b/e107_plugins/forum/templates/forum_post_template.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_post_template.php,v $
-| $Revision: 1.1.1.1 $
-| $Date: 2006-12-02 04:35:18 $
+| $Revision: 1.2 $
+| $Date: 2008-12-07 04:16:39 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -45,10 +45,10 @@ $subjectbox = "
// the poll is optional, be careful when changing the values here, only change if you know what you're doing ...
if(!$poll_form)
{
- if(is_readable(e_PLUGIN."poll/poll_class.php")) {
- require_once(e_PLUGIN."poll/poll_class.php");
+ if(is_readable(e_PLUGIN.'poll/poll_class.php')) {
+ require_once(e_PLUGIN.'poll/poll_class.php');
$pollo = new poll;
- $poll_form = $pollo -> renderPollForm("forum");
+ $poll_form = $pollo -> renderPollForm('forum');
}
}
@@ -61,7 +61,7 @@ $fileattach = "
-