xf_storage.class.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: xf_storage.class.php 29353 2012-04-06 03:00:07Z liudongdong $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class plugin_xf_storage {
  12. protected $value = array();
  13. protected $appStatus = '';
  14. protected $jsCode = '';
  15. public function plugin_xf_storage() {
  16. global $_G;
  17. $cloudAppService = Cloud::loadClass('Service_App');
  18. $this->appStatus = $cloudAppService->getCloudAppStatus('storage');
  19. }
  20. public function common(){
  21. global $_G;
  22. if (!$this->appStatus) {
  23. return false;
  24. }
  25. if(CURMODULE == 'post' && CURSCRIPT == 'forum' && $_G['uid']){
  26. $_G['config']['output']['iecompatible'] = '7';
  27. }
  28. return true;
  29. }
  30. public function global_footer(){
  31. if (!$this->appStatus) {
  32. return false;
  33. }
  34. include template('xf_storage:css');
  35. return $return;
  36. }
  37. public function _output($aid, $sha, $filename) {
  38. include_once libfile('function/attachment');
  39. $storageService = Cloud::loadClass('Service_Storage');
  40. $qqdlUrl = $storageService->makeQQdlUrl($sha, $filename);
  41. $aidencode = packaids(array('aid' => $aid));
  42. include template('xf_storage:link');
  43. return $return;
  44. }
  45. public function _jsOutput($aid, $return) {
  46. $spanId = 'attach_' . $aid;
  47. $return = str_replace(array("\r\n", '\'', '<p class="xg2">', '</p>', "\n"), array('', '\\\''), $return);
  48. include template('xf_storage:jscode');
  49. return $jscode;
  50. }
  51. }
  52. class plugin_xf_storage_forum extends plugin_xf_storage {
  53. public function post_attach_btn_extra() {
  54. global $_G;
  55. if (!$this->appStatus) {
  56. return false;
  57. }
  58. include template('xf_storage:editor');
  59. return $return;
  60. }
  61. public function post_attach_tab_extra() {
  62. global $_G;
  63. if (!$this->appStatus) {
  64. return false;
  65. }
  66. $editorid = 'e';
  67. include template('xf_storage:ftnupload');
  68. return $return;
  69. }
  70. public function viewthread_attach_extra_output() {
  71. global $postlist, $_G;
  72. $return = array();
  73. foreach ($postlist as $pid => $post) {
  74. foreach ($post['attachments'] as $aid => $attachment) {
  75. if (strpos($attachment['attachment'], 'storage:') !== false) {
  76. $sha1 = substr($attachment['attachment'], -40);
  77. $return[$aid] = $this->_output($aid, $sha1, $attachment['filename']);
  78. if (in_array($aid, $_G['forum_attachtags'][$pid])) {
  79. $postlist[$pid]['message'] .= $this->_jsOutput($aid, $return[$aid]);
  80. unset($return[$aid]);
  81. }
  82. if ($attachment['isimage']) {
  83. unset($return[$aid]);
  84. }
  85. }
  86. }
  87. }
  88. return $return;
  89. }
  90. }