Просмотр файла attach_mod/displaying.php

Размер файла: 22Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. if ( !defined('IN_PHPBB') )
  7. {
  8. die('Hacking attempt');
  9. exit;
  10. }
  11.  
  12. $allowed_extensions = array();
  13. $display_categories = array();
  14. $download_modes = array();
  15. $upload_icons = array();
  16. $attachments = array();
  17.  
  18. function display_compile_cache_clear($filename, $template_var)
  19. {
  20. global $template, $phpEx;
  21. if (isset($template->cachedir))
  22. {
  23. $filename = str_replace($template->root, '', $filename);
  24. if (substr($filename, 0, 1) == '/')
  25. {
  26. $filename = substr($filename, 1, strlen($filename));
  27. }
  28.  
  29. if (file_exists($template->cachedir . $filename . '.' . $phpEx))
  30. {
  31. @unlink($template->cachedir . $filename . '.' . $phpEx);
  32. }
  33. }
  34.  
  35. return;
  36. }
  37.  
  38. function init_complete_extensions_data()
  39. {
  40. global $db, $allowed_extensions, $display_categories, $download_modes, $upload_icons;
  41.  
  42. $extension_informations = get_extension_informations();
  43. $allowed_extensions = array();
  44.  
  45. for ($i = 0, $size = sizeof($extension_informations); $i < $size; $i++)
  46. {
  47. $extension = strtolower(trim($extension_informations[$i]['extension']));
  48. $allowed_extensions[] = $extension;
  49. $display_categories[$extension] = intval($extension_informations[$i]['cat_id']);
  50. $download_modes[$extension] = intval($extension_informations[$i]['download_mode']);
  51. $upload_icons[$extension] = trim($extension_informations[$i]['upload_icon']);
  52. }
  53. }
  54.  
  55. function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach_body.tpl')
  56.  
  57. {
  58. global $template;
  59.  
  60. if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var]))
  61. {
  62. if (!isset($template->files[$template_var]))
  63. {
  64. die("Template->loadfile(): No file specified for handle $template_var");
  65. }
  66.  
  67. $filename_2 = $template->files[$template_var];
  68.  
  69. $str = implode('', @file($filename_2));
  70. if (empty($str))
  71. {
  72. die("Template->loadfile(): File $filename_2 for handle $template_var is empty");
  73. }
  74.  
  75. $template->uncompiled_code[$template_var] = $str;
  76. }
  77.  
  78. $complete_filename = $filename;
  79. if (substr($complete_filename, 0, 1) != '/')
  80. {
  81. $complete_filename = $template->root . '/' . $complete_filename;
  82. }
  83.  
  84. if (!file_exists($complete_filename))
  85. {
  86. die("Template->make_filename(): Error - file $complete_filename does not exist");
  87. }
  88.  
  89. $content = implode('', file($complete_filename));
  90. if (empty($content))
  91. {
  92. die('Template->loadfile(): File ' . $complete_filename . ' is empty');
  93. }
  94.  
  95. $template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
  96. display_compile_cache_clear($template->files[$template_var], $template_var);
  97. }
  98.  
  99. function topic_attachment_image($switch_attachment)
  100. {
  101. global $attach_config, $is_auth;
  102.  
  103. if (intval($switch_attachment) == 0 || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($attach_config['disable_mod']) || $attach_config['topic_icon'] == '')
  104. {
  105. return '';
  106. }
  107.  
  108. $image = '<img src="' . $attach_config['topic_icon'] . '" alt="" />';
  109.  
  110. return $image;
  111. }
  112.  
  113. function display_post_attachments($post_id, $switch_attachment)
  114. {
  115. global $attach_config, $is_auth;
  116. if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
  117. {
  118. return;
  119. }
  120.  
  121. if ($is_auth['auth_download'] && $is_auth['auth_view'])
  122. {
  123. display_attachments($post_id);
  124. }
  125. }
  126.  
  127. function init_display_post_attachments($switch_attachment)
  128. {
  129. global $attach_config, $db, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $forum_topic_data;
  130.  
  131. if (empty($forum_topic_data) && !empty($forum_row))
  132. {
  133. $switch_attachment = $forum_row['topic_attachment'];
  134. }
  135.  
  136. if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])))
  137. {
  138. return;
  139. }
  140.  
  141. $post_id_array = array();
  142. for ($i = 0; $i < $total_posts; $i++)
  143. {
  144. if ($postrow[$i]['post_attachment'] == 1)
  145. {
  146. $post_id_array[] = (int) $postrow[$i]['post_id'];
  147. }
  148. }
  149.  
  150. if (sizeof($post_id_array) == 0)
  151. {
  152. return;
  153. }
  154.  
  155. $rows = get_attachments_from_post($post_id_array);
  156. $num_rows = sizeof($rows);
  157.  
  158. if ($num_rows == 0)
  159. {
  160. return;
  161. }
  162.  
  163. @reset($attachments);
  164.  
  165. for ($i = 0; $i < $num_rows; $i++)
  166. {
  167. $attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
  168. }
  169.  
  170. init_display_template('body', '{postrow.ATTACHMENTS}');
  171.  
  172. init_complete_extensions_data();
  173.  
  174. $template->assign_vars(array(
  175. 'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
  176. 'L_KILOBYTE' => $lang['KB'])
  177. );
  178. }
  179.  
  180. function privmsgs_attachment_image($privmsg_id)
  181. {
  182. global $attach_config, $userdata;
  183.  
  184. $auth = ($userdata['user_level'] == ADMIN) ? 1 : intval($attach_config['allow_pm_attach']);
  185. if (!attachment_exists_db($privmsg_id, PAGE_PRIVMSGS) || !$auth || intval($attach_config['disable_mod']) || $attach_config['topic_icon'] == '')
  186. {
  187. return '';
  188. }
  189.  
  190. $image = '<img src="' . $attach_config['topic_icon'] . '" alt="" />';
  191.  
  192. return $image;
  193. }
  194.  
  195. function display_pm_attachments($privmsgs_id, $switch_attachment)
  196. {
  197. global $attach_config, $userdata, $template, $lang;
  198. if ($userdata['user_level'] == ADMIN)
  199. {
  200. $auth_download = 1;
  201. }
  202. else
  203. {
  204. $auth_download = intval($attach_config['allow_pm_attach']);
  205. }
  206.  
  207. if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || !$auth_download)
  208. {
  209. return;
  210. }
  211.  
  212. display_attachments($privmsgs_id);
  213. $template->assign_block_vars('switch_attachments', array());
  214. $template->assign_vars(array(
  215. 'L_DELETE_ATTACHMENTS' => $lang['Delete_attachments'])
  216. );
  217. }
  218.  
  219. function init_display_pm_attachments($switch_attachment)
  220. {
  221. global $attach_config, $template, $userdata, $lang, $attachments, $privmsg;
  222.  
  223. if ($userdata['user_level'] == ADMIN)
  224. {
  225. $auth_download = 1;
  226. }
  227. else
  228. {
  229. $auth_download = intval($attach_config['allow_pm_attach']);
  230. }
  231.  
  232. if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || !$auth_download)
  233. {
  234. return;
  235. }
  236.  
  237. $privmsgs_id = $privmsg['privmsgs_id'];
  238. @reset($attachments);
  239. $attachments['_' . $privmsgs_id] = get_attachments_from_pm($privmsgs_id);
  240.  
  241. if (sizeof($attachments['_' . $privmsgs_id]) == 0)
  242. {
  243. return;
  244. }
  245.  
  246. $template->assign_block_vars('postrow', array());
  247. init_display_template('body', '{ATTACHMENTS}');
  248.  
  249. init_complete_extensions_data();
  250. $template->assign_vars(array(
  251. 'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
  252. 'L_KILOBYTE' => $lang['KB'])
  253. );
  254.  
  255. display_pm_attachments($privmsgs_id, $switch_attachment);
  256. }
  257.  
  258. function display_review_attachments($post_id, $switch_attachment, $is_auth)
  259. {
  260. global $attach_config, $attachments;
  261. if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($attach_config['attachment_topic_review']) == 0)
  262. {
  263. return;
  264. }
  265.  
  266. @reset($attachments);
  267. $attachments['_' . $post_id] = get_attachments_from_post($post_id);
  268.  
  269. if (sizeof($attachments['_' . $post_id]) == 0)
  270. {
  271. return;
  272. }
  273.  
  274. display_attachments($post_id);
  275. }
  276.  
  277. function init_display_review_attachments($is_auth)
  278. {
  279. global $attach_config;
  280.  
  281. if (intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($attach_config['attachment_topic_review']) == 0)
  282. {
  283. return;
  284. }
  285.  
  286. init_display_template('reviewbody', '{postrow.ATTACHMENTS}');
  287.  
  288. init_complete_extensions_data();
  289. }
  290.  
  291. function display_attachments_preview($attachment_list, $attachment_filesize_list, $attachment_filename_list, $attachment_comment_list, $attachment_extension_list, $attachment_thumbnail_list)
  292. {
  293. global $attach_config, $is_auth, $allowed_extensions, $lang, $userdata, $display_categories, $upload_dir, $upload_icons, $template, $db;
  294.  
  295. if (sizeof($attachment_list) != 0)
  296. {
  297. init_display_template('preview', '{ATTACHMENTS}');
  298. init_complete_extensions_data();
  299.  
  300. $template->assign_block_vars('postrow', array());
  301. $template->assign_block_vars('postrow.attach', array());
  302. $template->assign_vars(array(
  303. 'T_BODY_TEXT' => '',
  304. 'T_TR_COLOR3' => '')
  305. );
  306.  
  307. for ($i = 0, $size = sizeof($attachment_list); $i < $size; $i++)
  308. {
  309. $filename = $upload_dir . '/' . basename($attachment_list[$i]);
  310. $thumb_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachment_list[$i]);
  311.  
  312. $filesize = $attachment_filesize_list[$i];
  313. $size_lang = ($filesize >= 1048576) ? $lang['MB'] : ( ($filesize >= 1024) ? $lang['KB'] : $lang['Bytes'] );
  314.  
  315. if ($filesize >= 1048576)
  316. {
  317. $filesize = (round((round($filesize / 1048576 * 100) / 100), 2));
  318. }
  319. else if ($filesize >= 1024)
  320. {
  321. $filesize = (round((round($filesize / 1024 * 100) / 100), 2));
  322. }
  323.  
  324. $display_name = $attachment_filename_list[$i];
  325. $comment = $attachment_comment_list[$i];
  326. $comment = str_replace("\n", '<br />', $comment);
  327. $extension = $attachment_extension_list[$i];
  328.  
  329. $denied = false;
  330.  
  331. if (!in_array($extension, $allowed_extensions))
  332. {
  333. $denied = true;
  334.  
  335. $template->assign_block_vars('postrow.attach.denyrow', array(
  336. 'L_DENIED' => sprintf($lang['Extension_disabled_after_posting'], $extension))
  337. );
  338. }
  339.  
  340. if (!$denied)
  341. {
  342. $template->assign_vars(array(
  343. 'L_DESCRIPTION' => $lang['Description'],
  344. 'L_DOWNLOAD' => $lang['Download'],
  345. 'L_FILENAME' => $lang['File_name'],
  346. 'L_FILESIZE' => $lang['Filesize'])
  347. );
  348.  
  349. $image = FALSE;
  350. $stream = FALSE;
  351. $swf = FALSE;
  352. $thumbnail = FALSE;
  353. $link = FALSE;
  354.  
  355. if (intval($display_categories[$extension]) == STREAM_CAT)
  356. {
  357. $stream = TRUE;
  358. }
  359. else if (intval($display_categories[$extension]) == SWF_CAT)
  360. {
  361. $swf = TRUE;
  362. }
  363. else if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attach_config['img_display_inlined']))
  364. {
  365. if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0)
  366. {
  367. list($width, $height) = image_getdimension($filename);
  368.  
  369. if ($width == 0 && $height == 0)
  370. {
  371. $image = TRUE;
  372. }
  373. else
  374. {
  375. if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height']))
  376. {
  377. $image = TRUE;
  378. }
  379. }
  380. }
  381. else
  382. {
  383. $image = TRUE;
  384. }
  385. }
  386. if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attachment_thumbnail_list[$i]) == 1)
  387. {
  388. $thumbnail = TRUE;
  389. $image = FALSE;
  390. }
  391.  
  392. if (!$image && !$stream && !$swf && !$thumbnail)
  393. {
  394. $link = TRUE;
  395. }
  396.  
  397. if ($image)
  398. {
  399. $template->assign_block_vars('postrow.attach.cat_images', array(
  400. 'DOWNLOAD_NAME' => $display_name,
  401. 'IMG_SRC' => $filename,
  402. 'FILESIZE' => $filesize,
  403. 'SIZE_VAR' => $size_lang,
  404. 'COMMENT' => $comment,
  405. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'])
  406. );
  407. }
  408. if ($thumbnail)
  409. {
  410. $template->assign_block_vars('postrow.attach.cat_thumb_images', array(
  411. 'DOWNLOAD_NAME' => $display_name,
  412. 'IMG_SRC' => $filename,
  413. 'IMG_THUMB_SRC' => $thumb_filename,
  414. 'FILESIZE' => $filesize,
  415. 'SIZE_VAR' => $size_lang,
  416. 'COMMENT' => $comment,
  417. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'])
  418. );
  419. }
  420.  
  421. if ($stream)
  422. {
  423. $template->assign_block_vars('postrow.attach.cat_stream', array(
  424. 'U_DOWNLOAD_LINK' => $filename,
  425. 'DOWNLOAD_NAME' => $display_name,
  426. 'FILESIZE' => $filesize,
  427. 'SIZE_VAR' => $size_lang,
  428. 'COMMENT' => $comment,
  429. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'])
  430. );
  431. }
  432. if ($swf)
  433. {
  434. list($width, $height) = swf_getdimension($filename);
  435. $template->assign_block_vars('postrow.attach.cat_swf', array(
  436. //'U_DOWNLOAD_LINK' => $filename,
  437. 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'down/' . $attachments['_' . $post_id][$i]['physical_filename']),
  438. 'DOWNLOAD_NAME' => $display_name,
  439. 'FILESIZE' => $filesize,
  440. 'SIZE_VAR' => $size_lang,
  441. 'COMMENT' => $comment,
  442. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
  443. 'WIDTH' => $width,
  444. 'HEIGHT' => $height)
  445. );
  446. }
  447.  
  448. if ($link)
  449. {
  450. $upload_image = '';
  451.  
  452. if ($attach_config['upload_img'] != '' && $upload_icons[$extension] == '')
  453. {
  454. $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
  455. }
  456. else if (trim($upload_icons[$extension]) != '')
  457. {
  458. $upload_image = '<img src="' . $upload_icons[$extension] . '" alt="" border="0" />';
  459. }
  460.  
  461. $target_blank = 'target="_blank"';
  462. $template->assign_block_vars('postrow.attach.attachrow', array(
  463. //'U_DOWNLOAD_LINK' => $filename,
  464. 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'down/' . $attachments['_' . $post_id][$i]['physical_filename']),
  465. 'S_UPLOAD_IMAGE' => $upload_image,
  466. 'DOWNLOAD_NAME' => $display_name,
  467. 'FILESIZE' => $filesize,
  468. 'SIZE_VAR' => $size_lang,
  469. 'COMMENT' => $comment,
  470. 'L_DOWNLOADED_VIEWED' => $lang['Downloaded'],
  471. 'TARGET_BLANK' => $target_blank)
  472. );
  473. }
  474. }
  475. }
  476. }
  477. }
  478.  
  479. function display_attachments($post_id)
  480. {
  481. global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $db, $lang, $phpEx, $attachments, $upload_icons, $attach_config;
  482. global $phpbb_root_path;
  483.  
  484. $num_attachments = sizeof($attachments['_' . $post_id]);
  485. if ($num_attachments == 0)
  486. {
  487. return;
  488. }
  489.  
  490. $template->assign_block_vars('postrow.attach', array());
  491. for ($i = 0; $i < $num_attachments; $i++)
  492. {
  493. $filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']);
  494. $thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']);
  495. $upload_image = '';
  496.  
  497. if ($attach_config['upload_img'] != '' && trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) == '')
  498. {
  499. $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
  500. }
  501. else if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '')
  502. {
  503. $upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
  504. }
  505. $filesize = $attachments['_' . $post_id][$i]['filesize'];
  506. $size_lang = ($filesize >= 1048576) ? $lang['MB'] : ( ($filesize >= 1024) ? $lang['KB'] : $lang['Bytes'] );
  507.  
  508. if ($filesize >= 1048576)
  509. {
  510. $filesize = (round((round($filesize / 1048576 * 100) / 100), 2));
  511. }
  512. else if ($filesize >= 1024)
  513. {
  514. $filesize = (round((round($filesize / 1024 * 100) / 100), 2));
  515. }
  516.  
  517. $display_name = $attachments['_' . $post_id][$i]['real_filename'];
  518. $comment = $attachments['_' . $post_id][$i]['comment'];
  519. $comment = str_replace("\n", '<br />', $comment);
  520.  
  521. $denied = false;
  522. if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions))
  523. {
  524. $denied = true;
  525.  
  526. $template->assign_block_vars('postrow.attach.denyrow', array(
  527. 'L_DENIED' => sprintf($lang['Extension_disabled_after_posting'], $attachments['_' . $post_id][$i]['extension']))
  528. );
  529. }
  530.  
  531. if (!$denied || $userdata['user_level'] == ADMIN)
  532. {
  533. $template->assign_vars(array(
  534. 'L_DESCRIPTION' => $lang['Description'],
  535. 'L_DOWNLOAD' => $lang['Download'],
  536. 'L_FILENAME' => $lang['File_name'],
  537. 'L_FILESIZE' => $lang['Filesize'])
  538. );
  539.  
  540. $image = FALSE;
  541. $stream = FALSE;
  542. $swf = FALSE;
  543. $thumbnail = FALSE;
  544. $link = FALSE;
  545.  
  546. if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == STREAM_CAT)
  547. {
  548. $stream = TRUE;
  549. }
  550. else if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == SWF_CAT)
  551. {
  552. $swf = TRUE;
  553. }
  554. else if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined']))
  555. {
  556. if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0)
  557. {
  558. list($width, $height) = image_getdimension($filename);
  559.  
  560. if ($width == 0 && $height == 0)
  561. {
  562. $image = TRUE;
  563. }
  564. else
  565. {
  566. if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height']))
  567. {
  568. $image = TRUE;
  569. }
  570. }
  571. }
  572. else
  573. {
  574. $image = TRUE;
  575. }
  576. }
  577. if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1)
  578. {
  579. $thumbnail = TRUE;
  580. $image = FALSE;
  581. }
  582.  
  583. if (!$image && !$stream && !$swf && !$thumbnail)
  584. {
  585. $link = TRUE;
  586. }
  587.  
  588. if ($image)
  589. {
  590. if (intval($attach_config['allow_ftp_upload']) && trim($attach_config['download_path']) == '')
  591. {
  592. $img_source = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']);
  593. $download_link = TRUE;
  594. }
  595. else
  596. {
  597. if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
  598. {
  599. $img_source = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']);
  600. $download_link = TRUE;
  601. }
  602. else
  603. {
  604. $img_source = $filename;
  605. $download_link = FALSE;
  606. }
  607. }
  608.  
  609. $template->assign_block_vars('postrow.attach.cat_images', array(
  610. 'DOWNLOAD_NAME' => $display_name,
  611. 'S_UPLOAD_IMAGE' => $upload_image,
  612.  
  613. 'IMG_SRC' => $img_source,
  614. 'FILESIZE' => $filesize,
  615. 'SIZE_VAR' => $size_lang,
  616. 'COMMENT' => $comment,
  617. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
  618. 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
  619. );
  620.  
  621. if (!$download_link)
  622. {
  623. $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
  624. SET download_count = download_count + 1
  625. WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
  626. if ( !($db->sql_query($sql)) )
  627. {
  628. message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count.', '', __LINE__, __FILE__, $sql);
  629. }
  630. }
  631. }
  632. if ($thumbnail)
  633. {
  634. if (intval($attach_config['allow_ftp_upload']) && trim($attach_config['download_path']) == '')
  635. {
  636. $thumb_source = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1');
  637. }
  638. else
  639. {
  640. if ($attach_config['upload_dir'][0] == '/' || ( $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':'))
  641. {
  642. $thumb_source = append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1');
  643. }
  644. else
  645. {
  646. $thumb_source = $thumbnail_filename;
  647. }
  648. }
  649. $template->assign_block_vars('postrow.attach.cat_thumb_images', array(
  650. 'DOWNLOAD_NAME' => $display_name,
  651. 'S_UPLOAD_IMAGE' => $upload_image,
  652.  
  653. 'IMG_SRC' => append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
  654. 'IMG_THUMB_SRC' => $thumb_source,
  655. 'FILESIZE' => $filesize,
  656. 'SIZE_VAR' => $size_lang,
  657. 'COMMENT' => $comment,
  658. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
  659. 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
  660. );
  661. }
  662.  
  663. if ($stream)
  664. {
  665. $template->assign_block_vars('postrow.attach.cat_stream', array(
  666. //'U_DOWNLOAD_LINK' => $filename,
  667. 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'down/' . $attachments['_' . $post_id][$i]['physical_filename']),
  668. 'S_UPLOAD_IMAGE' => $upload_image,
  669.  
  670. // 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
  671. 'DOWNLOAD_NAME' => $display_name,
  672. 'FILESIZE' => $filesize,
  673. 'SIZE_VAR' => $size_lang,
  674. 'COMMENT' => $comment,
  675. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
  676. 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
  677. );
  678.  
  679. $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
  680. SET download_count = download_count + 1
  681. WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
  682. if ( !($db->sql_query($sql)) )
  683. {
  684. message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  685. }
  686. }
  687. if ($swf)
  688. {
  689. list($width, $height) = swf_getdimension($filename);
  690. $template->assign_block_vars('postrow.attach.cat_swf', array(
  691. //'U_DOWNLOAD_LINK' => $filename,
  692. 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'down/' . $attachments['_' . $post_id][$i]['physical_filename']),
  693. 'S_UPLOAD_IMAGE' => $upload_image,
  694.  
  695. 'DOWNLOAD_NAME' => $display_name,
  696. 'FILESIZE' => $filesize,
  697. 'SIZE_VAR' => $size_lang,
  698. 'COMMENT' => $comment,
  699. 'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
  700. 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']),
  701. 'WIDTH' => $width,
  702. 'HEIGHT' => $height)
  703. );
  704.  
  705. $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
  706. SET download_count = download_count + 1
  707. WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id'];
  708. if ( !($db->sql_query($sql)) )
  709. {
  710. message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  711. }
  712. }
  713.  
  714. if ($link)
  715. {
  716. $target_blank = '';
  717.  
  718. $template->assign_block_vars('postrow.attach.attachrow', array(
  719. //'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
  720. 'U_DOWNLOAD_LINK' => append_sid($phpbb_root_path . 'down/' . $attachments['_' . $post_id][$i]['physical_filename']),
  721. 'S_UPLOAD_IMAGE' => $upload_image,
  722. 'DOWNLOAD_NAME' => $display_name,
  723. 'FILESIZE' => $filesize,
  724. 'SIZE_VAR' => $size_lang,
  725. 'COMMENT' => $comment,
  726. 'TARGET_BLANK' => $target_blank,
  727.  
  728. 'L_DOWNLOADED_VIEWED' => $lang['Downloaded'],
  729. 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
  730. );
  731.  
  732. }
  733. }
  734. }
  735. }
  736.  
  737. ?>