Revert INCLUDE template change, fixed attachment display.

git-svn-id: file:///svn/phpbb/trunk@3882 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-04-18 11:07:50 +00:00
parent 5286de6f0e
commit 25015ecc0b
2 changed files with 25 additions and 28 deletions

View file

@ -231,7 +231,7 @@ class Template {
$this->files[$handle] = $this->make_filename($filename); $this->files[$handle] = $this->make_filename($filename);
$_str = ''; $_str = '';
if (!($this->compile_load($_str, $handle, true))) if (!($this->compile_load($_str, $handle, false)))
{ {
global $user, $phpEx; global $user, $phpEx;
@ -243,7 +243,7 @@ class Template {
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]); $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
$this->compile_write($handle, $this->compiled_code[$handle]); $this->compile_write($handle, $this->compiled_code[$handle]);
eval($this->compiled_code[$handle]); return $handle;
} }
} }
@ -368,7 +368,8 @@ class Template {
case 'INCLUDE': case 'INCLUDE':
$temp = ''; $temp = '';
list(, $temp) = each($include_blocks); list(, $temp) = each($include_blocks);
$compile_blocks[] = "// INCLUDE $temp\n\$this->assign_from_include('" . $temp . "');\n"; $compile_blocks[] = "// INCLUDE $temp\ninclude('" . $this->cachedir . $temp . ".' . \$phpEx);\n";
$this->assign_from_include($temp);
break; break;
/* case 'INCLUDEPHP': /* case 'INCLUDEPHP':
$compile_blocks[] = '// INCLUDEPHP ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include_php($blocks[2][$curr_tb]); $compile_blocks[] = '// INCLUDEPHP ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include_php($blocks[2][$curr_tb]);

View file

@ -766,18 +766,18 @@ if (count($attach_list))
if (!$db->sql_fetchrow($result)) if (!$db->sql_fetchrow($result))
{ {
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id"); $db->sql_query("UPDATE " . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id");
} }
} }
else else
{ {
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id"); $db->sql_query("UPDATE " . TOPICS_TABLE . " SET topic_attachment = 0 WHERE topic_id = $topic_id");
} }
} }
elseif ($has_attachments && !$topic_data['topic_attachment']) elseif ($has_attachments && !$topic_data['topic_attachment'])
{ {
// Topic has approved attachments but its flag is wrong // Topic has approved attachments but its flag is wrong
$db->sql_query('UPDATE ' . TOPICS_TABLE . " SET topic_attachment = 1 WHERE topic_id = $topic_id"); $db->sql_query("UPDATE " . TOPICS_TABLE . " SET topic_attachment = 1 WHERE topic_id = $topic_id");
} }
} }
@ -1022,6 +1022,8 @@ foreach ($rowset as $key => $row)
// Process Attachments for this post // Process Attachments for this post
if (sizeof($attachments[$row['post_id']])) if (sizeof($attachments[$row['post_id']]))
{ {
$update_count = array();
foreach ($attachments[$row['post_id']] as $attachment) foreach ($attachments[$row['post_id']] as $attachment)
{ {
// Some basics... // Some basics...
@ -1056,9 +1058,8 @@ foreach ($rowset as $key => $row)
$comment = stripslashes(trim(nl2br($attachment['comment']))); $comment = stripslashes(trim(nl2br($attachment['comment'])));
$denied = false; $denied = false;
$update_count = false;
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin // Admin is allowed to view forbidden Attachments
if ((!in_array($attachment['extension'], $extensions['_allowed_']))) if ((!in_array($attachment['extension'], $extensions['_allowed_'])))
{ {
$denied = true; $denied = true;
@ -1128,29 +1129,21 @@ foreach ($rowset as $key => $row)
// NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the // NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the
// Section between BEGIN and END with (Without the // of course): // Section between BEGIN and END with (Without the // of course):
// $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; // $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
// $download_link = TRUE;
// //
// BEGIN // BEGIN
if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '') if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '')
{ {
$img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
$download_link = TRUE;
} }
else else
{ {
$img_source = $filename; $img_source = $filename;
$download_link = FALSE; $update_count[] = $attachment['attach_id'];
} }
// END // END
$l_downloaded_viewed = $user->lang['VIEWED']; $l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $img_source; $download_link = $img_source;
// Directly Viewed Image ... update the download count
if (!$download_link)
{
$update_count = true;
}
} }
if ($thumbnail) if ($thumbnail)
@ -1187,7 +1180,10 @@ foreach ($rowset as $key => $row)
// $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; // $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'];
// Viewed/Heared File ... update the download count (download.php is not called here) // Viewed/Heared File ... update the download count (download.php is not called here)
$update_count = !preg_match("#&t=$topic_id#", $user->data['session_page']) ? true : false; if (!preg_match("#&t=$topic_id#", $user->data['session_page']))
{
$update_count[] = $attachment['attach_id'];
}
} }
/* /*
if ($swf) if ($swf)
@ -1204,7 +1200,7 @@ foreach ($rowset as $key => $row)
); );
// Viewed/Heared File ... update the download count (download.php is not called here) // Viewed/Heared File ... update the download count (download.php is not called here)
$update_count = true; $update_count[] = $attachment['attach_id'];
} }
*/ */
if ($link) if ($link)
@ -1235,17 +1231,17 @@ foreach ($rowset as $key => $row)
$template->assign_block_vars('postrow.attachment', $template_array); $template->assign_block_vars('postrow.attachment', $template_array);
} }
// NOTE: rather store attach_id in an array then update all download counts at once, outside of the loop -- Ashe
if ($update_count)
{
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
SET download_count = download_count + 1
WHERE attach_id = ' . $attachment['attach_id'];
$db->sql_query($sql);
}
} }
} }
// Update download count
if (count($update_count))
{
$sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "
SET download_count = download_count + 1
WHERE attach_id IN (" . implode(', ', array_unique($update_count)) . ")";
$db->sql_query($sql);
}
} }
unset($rowset[$key]); unset($rowset[$key]);